W3C home > Mailing lists > Public > www-style@w3.org > January 2012

Re: [css3-*] Review of functional syntax in CSS

From: Dirk Schulze <dschulze@adobe.com>
Date: Fri, 20 Jan 2012 11:33:07 -0800
To: Matthew Wilcox <elvendil@gmail.com>
CC: Aryeh Gregor <ayg@aryeh.name>, "Tab Atkins Jr." <jackalmage@gmail.com>, Henri Sivonen <hsivonen@iki.fi>, www-style list <www-style@w3.org>
Message-ID: <C73E76AF-4337-41AF-AAC5-8AF0C41775BC@adobe.com>
The CSS Transforms specification tries to merge all existing transforms specification like SVG Transforms, CSS 2D Transforms and CSS 3D Transforms.

One main difference and issue between the CSS syntax and the SVG syntax is optional comma for argument separation on SVG! You can add a comma or leave it. It's up to the author. This means that the parser is a lot more tolerant and flexible. And I think that is better for the author than being more strict.

I would vote for making commas optional in general for functions and allow separation of arguments just by spaces.

But just picking matrices for CSS Transforms from your proposal: It makes absolutely no sense to me why we should group arguments there. Even if matlab is doing it (haven't checked that), I am not aware of any graphic library or implementation that groups arguments. Neither Qt, Skia, Cairo Graphics, nor SVGMatrix, CSSMatrix or HTML Canvas group certain arguments. And I would assume that grouping arguments is more confusing for authors than less. This just seem to make it more important to let the author decide where and when to add a comma.


On Jan 20, 2012, at 11:09 AM, Matthew Wilcox wrote:

> I am all for making CSS syntax as similar to JS as possible - as the CSS features become more powerful and complex to express it simply makes sense to borrow the syntax from a more powerful sibling web technology.
> As for the prefix pattern whereby authors are dropping a no-prefix property at the end of the list: I'm guilty of it whenever I use any prefixed property. The idea is to be forward compatible otherwise when a spec goes final and vendors remove support for the prefixed version website's *appear* to break.
> Arguably that's an author's problem for using incomplete properties in production environments instead of for personal projects - but that's what happens because it's the fancy new stuff which sells and make's client's happy, so it's the fancy new stuff that get's used as soon as it's practical to do so. 
> I'd suggest that the only way to avoid this kind of problem is to get browser vendors to disable all experimental vendor-specific prefixes unless the user has opted in through a preference or special build. The problem there is it's not in the vendor's interest to do this because it is the fact that Safari and Chrome can do fancy stuff that pushes their share of the market up. It's certainly one reason I like Chrome/Safari - I love those hardware accelerated 3D Transforms, they make clients drool and developers lust.
> -Matt
> On 20 Jan 2012, at 18:55, Aryeh Gregor wrote:
>> On Thu, Jan 19, 2012 at 9:01 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
>>> General Principles
>>> ==================
>>> 1. Functions group/namespace a set of CSS-like values, and so should
>>> abide by general CSS value syntax principles
>>> 1.1 Optionality is handled per #3, as far as possible
>>> 1.2 Ordering should be flexible as much as possible/prudent
>>> 2. Lists of parallel items are comma-separated
>>> 3. Lowest operator is comma
>>> 4. Backwards compat should be preserved unless there's a very good
>>> reason otherwise
>> I think this misses two noteworthy points:
>> a) Functions look like programming-language functions, which always
>> have a comma between arguments.  Allowing multiple arguments with no
>> comma will be confusing to anyone with even slight scripting
>> experience, and *requiring* no comma will be even more confusing.
>> b) If all functions require a comma between arguments, it's easy to
>> remember.  If some functions require it and some forbid it, it will be
>> very hard to remember which is which unless the choice is very
>> consistently applied.
>> I think requiring commas between all arguments always, like
>> programming-language functions, is the most natural and simplest for
>> authors to understand.  Most people who do a decent amount of CSS work
>> have at least some exposure to JS, and having the function syntax look
>> similar strikes me as very valuable.  I think the syntax should be
>> made more analogous to JS functions than to CSS property values --
>> which it already is, by and large.
>> On Fri, Jan 20, 2012 at 3:51 AM, Henri Sivonen <hsivonen@iki.fi> wrote:
>>> Are the proposed comma removals backwards-compatible in the sense that
>>> prefixed properties would work with extra commas if unprefixed? (It
>>> seems to me that wouldn't be the case.) Without that kind of
>>> compatibility with what's deployed, I expected it to be very confusing
>>> to authors if dropping prefixes needs to be couples with dropping
>>> well-selected commas, too.
>> Particularly since it's common to see authors using unprefixed
>> properties before any browser actually implements them, like
>> -ms-transform: translate(10px, 10px);
>> -moz-transform: translate(10px, 10px);
>> -webkit-transform: translate(10px, 10px);
>> -o-transform: translate(10px, 10px);
>> transform: translate(10px, 10px);
>> Mozilla, for one, seems to systematically advocate this pattern.  I've
>> certainly seen it in the wild, and I haven't even looked.  The
>> advantage is that if there's no change in syntax when unprefixing,
>> things will continue to just work.  But if there is, things will
>> break.  The same goes for if authors copy-paste the existing lines and
>> remove the prefix -- it will work fine as long as the syntax hasn't
>> changed.
>> I don't mean to bring up the whole prefixing argument again, but I'll
>> observe that even if you like prefixing, that doesn't mean there are
>> no compatibility constraints on property syntax until we unprefix.
>> They just aren't quite as strong.  We can change the syntax when
>> unprefixing without actually breaking many sites, as long as browsers
>> still support the prefixed syntax for long enough that authors switch
>> over.  But the transition is still easiest if we don't change the
>> syntax at all.  Even though we *could* change it, we *shouldn't*
>> without good reason.
>> For things like matrix3d() or Bezier curves, where it's really hard to
>> read if there's a comma between each pair of entries, it might be
>> worth it -- although who's really writing these by hand, and why can't
>> they make grouping clear with whitespace?  I definitely don't see the
>> value in not requiring commas for translate() and such.  I think it's
>> more confusing than anything.
Received on Friday, 20 January 2012 19:33:43 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:10 UTC