W3C home > Mailing lists > Public > www-style@w3.org > March 2008

Re: Fwd: cssom - clientTop, et v

From: Anne van Kesteren <annevk@opera.com>
Date: Mon, 10 Mar 2008 08:59:27 +0100
To: "Garrett Smith" <dhtmlkitchen@gmail.com>
Cc: Www-style <www-style@w3.org>
Message-ID: <op.t7si5dzj64w2qv@annevk-t60.oslo.opera.com>

On Mon, 10 Mar 2008 06:24:46 +0100, Garrett Smith <dhtmlkitchen@gmail.com>  
> Puts the 'px' in the wrong place. It complicate scripts that properly
> typecheck:-
> if(typeof el.currentStyle.borderRightWidth == "string") {
> }

Do you know of any site that does that? I'd love to have some pointers.

> The real "use case" for (3) is for hand-rolled javascript based
> animations. [...]

Indeed. There seem to be various other proposals for animations now that  
make it worthwhile delaying extensions to the CSSOM. (CSS Animations and  
SVG Animation.)

> I did not find the currentStyle specified in the CSSOM draft
> (http://www.w3.org/TR/cssom-view/), so I googled and found:
> http://dev.w3.org/csswg/cssom/
> This document appears to be outdated. Please confirm. What is the  
> correct URI?

That is the correct URI. I'm not updating everything at the same time ;-)

> [...]
> Element.getComputedValueAs(property, desiredUnit), would avoid this
> painful and limited approach. It would open other possibilities.

How does that work for properties that don't take units, but keywords? Or  
properties that take <color> values?

> Of the three possible methods, which are the most useful? This is an
> open question to anyone now - post up and speak your mind. Let's hear
> it.
> Case (1) el.cascadedStyle - get the cascaded style
> Keywords are not useful. "Inherit" is not useful.
> Implementations of currentStyle sometimes return keywords or "inherit".
> Why currentStyle's Keywords are Undesirable -
> In IE and Opera, currentStyle return values are not clearly defined
> and, in many cases, returns values that are undesirable. Such
> undesirable values are "auto", "", "inherit", "medium", "bold" and
> other keywords. When I get an undesirable value like "inherit", I
> usually want the inherited value. For animation, it's not possible to
> perform math on "inherit" -- i need a number. So I have to check the
> parentNode, then the parentNode of the parentNode, all the way up
> until I get a value. If the value is the keyword "red", I degrade. I
> do not believe in sending down the wire a javascript colorKeyword ->
> hex map. The browser should do the conversion.

That sounds reasonable. I've added a note about cascadedStyle.

> Regarding "CSS Pixel" - Is this a floating point number, a floating
> point number as a string with "px", a rounded number, or a rounded
> number plus "px"?

A CSS pixel is a CSS pixel. The representation depends on the context.

> [ getComputedStyle examples ]
>> A new API doesn't solve any problems we have with the existing APIs. It
>> just adds more. Whether we like it or not, clientTop is part of the Web.
> Adding a new API creates fewer problems because the existing API can
> be replaced with something that is more consistent across browsers.

It can be not be replaced. Browsers have to support both. Hence, more  

Anne van Kesteren
Received on Monday, 10 March 2008 07:59:25 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:55:02 GMT