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

On 2/1/12 3:50 PM, Glenn Adams wrote:
>           1. On query operations (e.g., getting cssText, length,
>         invoking item,
>
>             getPropertyValue, etc.), does ElementCSSInlineStyle.style
>         represent
>             *only* the declarative content of @style? *OR*
>           2. On query operations, does ElementCSSInlineStyle.style
>         represent the
>
>             UA's so-called "specified values" [1] state of all
>         properties that
>             do or could apply to the element? i.e., the results of
>         applying the
>             cascading and inheritance steps of the property resolution
>         process?
>
>
>     Depending on what you mean by "declarative content", the aswer is
>     either #1 or "neither".
>
>
> By "declarative content" I mean the value returned by cssText, i.e., the
> CSS declaration block decoded from or encoded into the value of @style.

Those are different things.  The cssText is a string, but the 
declaration block is an object.  You can have lots of "equivalent" 
declaration blocks with slightly different initial text representations...

> If we give priority to that declarative content, then it may argue for
> having length/item match only those declarations returned by cssText.
> However, if we give priority to the UA's state, then it may permit that
> them not to match (e.g., due to shorthand expansion). Further, if we
> adopt the latter, then the question remains as to whether the queried
> values should in any way reflect the cascading or inheritance process.

They shouldn't.  Doing that would in fact not be web-compatible.

> For example, say we have:
>
> <body style="border-width: 1px">
> <div style="border-top-width: 2px">
>
> then is {div}.style.cssText =>
> "border-top-width: 2px; border-right-width: 1px; border-bottom-width:
> 1px; border-left-width: 1px;"
> [i.e., cssText returns corresponding longhand components with cascading
> and inheritance having been applied]

Border widths don't inherit by default.  Your example would be better 
with something like color.  And as I said, web sites depend on 
inheritance and cascading NOT taking place for div.style (as opposed to 
.currentStyle which contains the post-cascading style).

>     Is this observable?
>
> just asking the question of whether there should be a documented
> expectation about presence or absence of such behavior; at the (video)
> frame level, it could be observable

I don't see how; you can't require the entire rendering pipeline (parts 
of which are outside the control of the CSS implementation, because the 
OS manages them) to have a certain behavior.

 > it could be observable in
> performance or interleaving of  the effects of mutation;

I'm not sure what you mean.  Example, please?

> so which of these do you think is the right answer?

I already said that earlier in this thread: I think length() should 
return the number of longhand properties that are set in the declaration 
and item() should iterate the longhand properties.  That's a simple 
behavior to define (modulo the fact that the current CSS spec has no 
actual concept of "set in the declaration").  The only drawback is 
forward-compat as properties that used to be longhands become shorthands....

-Boris

Received on Wednesday, 1 February 2012 21:01:56 UTC