List Info

Thread: getComputedStyle results




getComputedStyle results
country flaguser name
Portugal
2008-03-30 20:21:15

Hi!

The spec for getComputedStyle says the following:
  >  
http://www.w3.org/TR/DOM-Level-2-Sty
le/css.html#CSS-CSSview-getComputedStyle
  > Return Value, CSSStyleDeclaration, The computed
style. The  
CSSStyleDeclaration is read-only and contains only absolute
values.

A broad description for absolute (or used) value can be
found here
  > ht
tp://www.w3.org/TR/CSS21/cascade.html#used-value

Now, the problem is that the absolute value description is
too generic,  
and currently browsers return different results for
different properties,  
when calling getComputedStyle. Like:
  - Mozilla and Safari retuns rgb(n,n,n) for colors while
Opera returns  
#rrggbb (imo, Safari copied Moz just for the sake of market
share)
  - Mozilla many times retuns auto for many dimensions
properties like  
height, width, top,left... while Opera returns always proper
pixel  
dimensions
  - Mozilla and Safari sometimes return keywords for
quantitative  
properties like font-weight. By default getComputesTyle
returns "normal"  
for these browsers, while Opera returns a numeric value
(normal computes  
to 700).

So, we need the spec to detail how colors, dimensions and
other properties  
should be represented when returned by getComputedStyle.
IMO, Opera's  
implementation is more useful. Having keywords for
quantitative properties  
is useles, you can't do arithmetics with them.

But these are use cases where we need to get the current
applied cascaded  
styles, not absolute ones. How can we get this kind of
information? Does  
getOverrideStyle fit this profile ?

Thank you.


Re: getComputedStyle results
country flaguser name
Portugal
2008-03-30 20:46:32
Na , Kartikaya Gupta <kaguptarim.com> escreveu:

> The getComputedStyle return value is already well
defined to be the  
> "computed" values as described in  
> http://www.w3.org/TR/CSS21/cascade.html#computed-value.

Yes, computed values are well defined, but DOM 2 StyleSheets
defines  
getComputedStyle to return absolute (or used) values, not
computed values.
That's the issue.

> That's what UAs are supposed to be returning. The
computed results are  
> what come out of the cascade, but before the actual
layout algorithm is  
> run. In some cases "auto" is the correct
value to be returned, since  
> those values cannot be determined until layout time.
The actual  
> representation of the value (i.e. rgb(n,n,n) vs
#rrggbb) isn't  
> specified, so if you want to be safe you can use the
getPropertyCSSValue  
> method on the CSSStyleDeclaration interface to retrieve
a structured  
> object rather than a string.
>
> As for getOverrideStyle, that's provided so that DOM
implementers can  
> override specific styles. Styles that are returned by
getOverrideStyle  
> have the highest weight in the cascade and will
override all other  
> styles. It's not really of much use to web developers
though.
>
> Hope that helps.
>
> -----Original Message-----
> From: www-dom-requestw3.org
[mailto:www-dom-requestw3.org] On Behalf  
> Of Joćo Eiras
> Sent: Sunday, March 30, 2008 9:21 PM
> To: www-domw3.org
> Subject: getComputedStyle results
>
>
>
> Hi!
>
> The spec for getComputedStyle says the following:
>   >
> http://www.w3.org/TR/DOM-Level-2-Sty
le/css.html#CSS-CSSview-getComputedStyle
>   > Return Value, CSSStyleDeclaration, The computed
style. The
> CSSStyleDeclaration is read-only and contains only
absolute values.
>
> A broad description for absolute (or used) value can be
found here
>   > ht
tp://www.w3.org/TR/CSS21/cascade.html#used-value
>
> Now, the problem is that the absolute value description
is too generic,
> and currently browsers return different results for
different properties,
> when calling getComputedStyle. Like:
>   - Mozilla and Safari retuns rgb(n,n,n) for colors
while Opera returns
> #rrggbb (imo, Safari copied Moz just for the sake of
market share)
>   - Mozilla many times retuns auto for many dimensions
properties like
> height, width, top,left... while Opera returns always
proper pixel
> dimensions
>   - Mozilla and Safari sometimes return keywords for
quantitative
> properties like font-weight. By default getComputesTyle
returns "normal"
> for these browsers, while Opera returns a numeric value
(normal computes
> to 700).
>
> So, we need the spec to detail how colors, dimensions
and other  
> properties
> should be represented when returned by
getComputedStyle. IMO, Opera's
> implementation is more useful. Having keywords for
quantitative  
> properties
> is useles, you can't do arithmetics with them.
>
> But these are use cases where we need to get the
current applied cascaded
> styles, not absolute ones. How can we get this kind of
information? Does
> getOverrideStyle fit this profile ?
>
> Thank you.
>
>
>
------------------------------------------------------------
---------
> This transmission (including any attachments) may
contain confidential  
> information, privileged material (including material
protected by the  
> solicitor-client or other applicable privileges), or
constitute  
> non-public information. Any use of this information by
anyone other than  
> the intended recipient is prohibited. If you have
received this  
> transmission in error, please immediately reply to the
sender and delete  
> this information from your system. Use, dissemination,
distribution, or  
> reproduction of this transmission by unintended
recipients is not  
> authorized and may be unlawful.




Re: getComputedStyle results
country flaguser name
United States
2008-03-30 22:22:00
> The getComputedStyle return value is already well
defined to be the 
> "computed" values as described in 
> http://www.w3.org/TR/CSS21/cascade.html#computed-value.

That definition postdates the definition of
getComputedStyle.  The "computed 
style" getComputedStyle references is the CSS2 one. 
Since UAs currently on the 
market do not implement the CSS2 computed style (which is
neither equivalent to 
the CSS2.1 computed style nor quite to the CSS2.1 used
style, iirc), it's 
actually not that clear what getComputedStyle should be
doing.

> Yes, computed values are well defined, but DOM 2
StyleSheets defines 
> getComputedStyle to return absolute (or used) values

The term "absolute value" only makes sense for
lengths.  I don't believe DOM 2 
StyleSheets uses the term "used style" anywhere
(which makes sense, since that 
term postdates the spec in question).

-Boris


Re: getComputedStyle results
user name
2008-07-16 12:45:55
On Sun, Mar 30, 2008 at 11:34 PM, Joćo Eiras
<joao.eirasgmail.com> wrote:
>
> Na , Boris Zbarsky <bzbarskyMIT.EDU> escreveu:
>
>>
>>> The getComputedStyle return value is already
well defined to be the
>>> "computed" values as described in
>>> http://www.w3.org/TR/CSS21/cascade.html#computed-value.
>>
>> That definition postdates the definition of
getComputedStyle.  The
>> "computed style" getComputedStyle
references is the CSS2 one.  Since UAs
>> currently on the market do not implement the CSS2
computed style (which is
>> neither equivalent to the CSS2.1 computed style nor
quite to the CSS2.1 used
>> style, iirc), it's actually not that clear what
getComputedStyle should be
>> doing.
>>

This is also a problem with clip() values.
https:/
/bugs.webkit.org/show_bug.cgi?id=17433

Garrett

>
>>
>> -Boris
>>
>
>
>
>


[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )