Re: Should IE drop currentStyle/ runtimeStyle?

On Tue, Sep 22, 2009 at 5:23 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> On 9/22/09 3:21 PM, Travis Leithead wrote:
>>
>> This makes it seem like developers just want "some" value for a style, but
>> aren't looking specifically for a computed/cascaded value. That's actually
>> what I want to discover--is this true? Are there specific needs to get both
>> the computed value and the cascaded style? Or do developer care?
>
> So in practice, when people get the "computed" style for some properties
> (width, especially) via getComputedStyle they actually expect something
> closer to "used" style (or CSS2 computed style, which is different from
> CSS2.1 computed style).
>
> We (Gecko) have heard a number of requests or a getCascadedStyle or
> equivalent.  I think it would be worth agreeing on an API for that and
> implementing.
>

If you can nail down some usage patterns first.

The method should not exist on document.defaultView if IE is going to adopt it.

If IE9 implementing a - document.defaultView - would break sites that
make inferences of document.defaultView being not Internet Explorer.
IE implementing document.defaultView would necessitate an "opt in"
mode, to avoid widespread breakage.

The proposal of getCascadedStyle would cause much less damage by
putting the method directly on window, and not exposing it to
document.defaultView.

However, the method getCascadedStyle does not pertain to the window as
much as it pertains to the element whose cascaded style is of concern.

element.getCascadedStyle("width");

But this still brings about the issue of "auto" and "inherit". When a
program encounters those values, it can either be redesigned to have
actual values or it can do the heavy lifting in the script, following
the rules in CSS to either findAncestorWithStyle,  isShrinkToFit,
getContainingBlock. This is messy, cumbersome, slow, error prone, and
only works when the program calculates the CSS rules in the same way
the browser did.

That could be avoided with:-

element.getStyleAs("width", "px")

> As for computed vs used style, I'm not quite sure what authors want there
> (or even whether most of them understand the difference).
>

It would be best to nail down the problems and their contexts.

Garrett

Received on Wednesday, 23 September 2009 21:29:44 UTC