Closed Bug 227280 Opened 21 years ago Closed 14 years ago

getComputedStyle should return CSS2.1 Computed Value now

Categories

(Core :: DOM: CSS Object Model, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: ian, Unassigned)

References

Details

CSS2.1 changed the definition of Computed Style.

We should use the new definition of Computed Value for getComputedStyle() (and 
inheritance, although unless the codepath is the same -- which ideally it should 
be, since they are identically defined now -- that should be another bug).

Each property has a Computed Value line that defines how the computed value is 
to be found.

http://www.w3.org/TR/CSS21/
(o 132458)
Blocks: 117887
Blocks: 200089
Do a lot of sites depend on out current getComputedStyle behavior for auto-width
or percent-width boxes?  Would changing this be an evang nightmare?  Or have we
succcessfully weaned everyone off onto the offset* properties?
there are some "cross-browser" element style retrieving methods that use
getComputedStyle for Moz and for IE its own currentStyle.  I believe some
O'Reilly books have it.

So currently we would return for <div style="width:50%" /> the actuall pixel
width.  The new spec is layout independent and will return "50%".

Most sites will be safe as they use offset*, but this will break some sites,
possibly radical standards compliant ones.

I suggest this go in when we branch and the 1.7 tree opens and we keep our eyes
open for reported breakage. 
Yeah, this is totally 1.7-stuff.  The question I wanted to ask was whether it
was safe to do it at all... If it's just "radical standards compliant" sites
that will break, we can deal with that...
I'm not so sure that this change is right.  The CSSOM refers to CSS2.  Any
revision of the CSSOM that refers to CSS 2.1 might refer to something other than
the "computed value" -- and perhaps should.
CSS2.1 is still CSS2, just a more recent revision.

I don't feel strongly about this. However, if we (Mozilla) do decide that this 
shouldn't change, we need to decide what (in terms of CSS2.1) getComputedStyle() 
really should be referring to (the "used value"?), and we (the CSSWG) need to 
publish an errata to DOM2 clarifying this. And I would prefer it if this got 
decided before we (Opera) fixed our equivalent of this bug...
Please get back to me once the WG decides something here, ok?
I think we settled on getComputedStyle returning the used value... so I think this bug is invalid.
The getComputedStyle spec clearly says:
 > http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSview-getComputedStyle
 > Return Value, CSSStyleDeclaration, The computed style. The CSSStyleDeclaration is read-only and contains only absolute values.

Absolute values is the same as used value:
 > http://www.w3.org/TR/CSS21/cascade.html#used-value

So this means that getComputedStyle should always return pixel dimensions, rgb of hex for colors, number for unitless but quantitative properties (like font-weight). IMO, this bug is invalid.

Thank you.

> CSSStyleDeclaration is read-only and contains only absolute values.

This only applies to lengths (since "absolute value" doesn't make sense for anything else), and predates the computed/used distinction (which wasn't introduced until CSS 2.1, when people realized that computed values as defined in CSS 2 didn't make much sense).

That spec is also being rewritten, last I checked.  Until that happens, it's not worth worrying about any computed style stuff, imo, since the new spec might change it all...
Assignee: general → nobody
QA Contact: ian → general
Yeah, I think this is WONTFIX and/or INVALID, and we'll worry about the new spec when it's written.
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.