W3C home > Mailing lists > Public > www-style@w3.org > February 2011

Re: CSS Variables

From: L. David Baron <dbaron@dbaron.org>
Date: Mon, 7 Feb 2011 17:54:22 -0800
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: www-style list <www-style@w3.org>
Message-ID: <20110208015422.GA11565@pickering.dbaron.org>
On Monday 2011-02-07 14:54 -0800, Tab Atkins Jr. wrote:
> On Mon, Feb 7, 2011 at 1:35 PM, L. David Baron <dbaron@dbaron.org> wrote:
> >  (c) @var $c 2px;           p { text-shadow: green $c $c; }
> >  (d) @var $d green 2px 2px; p { text-shadow $d; }
> >  (e) @var $e green 2px 2px; p { text-shadow $e, $e; }
> >  (f) @var $f green 2px 2px; p { text-shadow $f 3px; }
> >  (g) @var $g 2px, green;    p { text-shadow: blue 2px $g 1px 1px; }

> (a) and (b) are definitely invalid.  (c), (d), and (e) are definitely
> valid.  The variable declaration for (f) is definitely valid, but
> we're not completely decided on whether the use is valid or not.  I
> lean toward it being invalid, because "partial shadow" won't be a
> valid type.  We're somewhat more aligned toward declaring (g) invalid
> (again, the variable declaration may be valid, but not the use).
> (f) and (g) are most subject to implementation constraints.  It would
> be awesome to hear how difficult making them valid/invalid would be
> for Firefox and other browsers.

At first glance, making (f) and (g) invalid while continuing to
accept (d) and (e) seems hard.  It would require littering extra
code all over the parser to check allowed entry and exit points from
variables.  But if variables are a token-stream mechanism, then just
accepting (f) and (g) should be "easy" (i.e., wouldn't make
implementing variables any harder).

(An alternative to a token stream mechanism is some sort of a value
mechanism, but then we need to define what sorts of values we want
to accept.  In CSS, are many cases where the same token stream is a
valid value for different properties with substantially different
semantics and thus substantially different data structure
representation.  For example, "black" is a valid value for color and
for background (the shorthand) and for border (the shorthand) and
for font-family, "foo 1" is a valid value for both font-family and
counter-increment, "1px 2px" is a valid value for box-shadow and
padding and border-spacing and border-radius and
border-top-right-radius.  So I don't really see how such a mechanism
could work.)


L. David Baron                                 http://dbaron.org/
Mozilla Corporation                       http://www.mozilla.com/
Received on Tuesday, 8 February 2011 01:54:54 UTC

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