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

Re: [css3-values] RE: CSSStyleDeclaration#length and shorthands.

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Wed, 01 Feb 2012 16:46:36 -0500
Message-ID: <4F29B2BC.1010701@mit.edu>
To: Glenn Adams <glenn@skynav.com>
CC: www-style@w3.org
On 2/1/12 4:30 PM, Boris Zbarsky wrote:
>> So, if cssText returns only a shorthand, then is length 0?
>
> No, it's the number of longhand properties set by that shorthand.

OK.  I sense we're going in circles here.  Let me back up and try to 
clearly define some terms.

CSS defines various stages of value computation.  Currently the first 
well-defined stage is "specified value", but there are clearly stages 
before that one.  Specifically, for a given longhand property P for a 
given element E the determination of its "specified value" is done as 
follows:

1)  Cascading, as defined at 
http://dev.w3.org/csswg/css3-cascade/#cascading to detemine the "winning 
declaration" for the pair (E,P).
2)  Handling of "inherit" and "initial", as well as handling of 
properties that are not set but are inherited by default.

There have been proposals for calling the output of step (1) above the 
"cascaded value" of the property.

But implicit in the determination of this "cascaded value", and in 
particular of the "winning declaration" is the concept of a declaration 
having a value for a longhand property.  The "winning declaration" is 
not really defined, of course, because the concept it depends on (that 
of a declaration specifying a value for a longhand) is not really 
defined....

If we take cascading behavior as a given (which is a bit of a stretch; 
we should actually define it, though it's obvious to all of us what it 
should do), then for object model purposes I would like to define the 
"declared value" of a property P in a declaration D as follows:

   The "declared value" of a property P in a declaration D is the same
   as the cascaded value of property P for an element E if D is the only
   declaration that applies to E.  If there is no such cascaded value,
   then P does not have a "declared value" in D.

Or somesuch.  If desired we could define "cascaded value" in terms of 
the declared value of the most-important declaration which actually has 
a declared value, and then we'd need a primitive definition of declared 
value.  I don't care which approach we take from a formal point of view; 
the definitions end up being equivalent.

In any case, now that we have a concept of "declared value", my proposal 
can be stated as follows: The "length" of a CSSStyleDeclaration is the 
number of longhand properties that have a declared value in the 
corresponding CSS declaration.

Note that defining "declared value" for non-longhands would require a 
lot more machinery.  If we really wanted to, of course, it could be 
done, along the lines of Brian's proposals; we'd have to define 
precisely when shorthands are "composable".

Is that clearer, at least in terms of definitions?

-Boris
Received on Wednesday, 1 February 2012 21:47:16 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:50 GMT