Closed Bug 958118 Opened 10 years ago Closed 10 years ago

getAuthoredPropertyValue() returns computed value when object obtained using getComputedStyle()

Categories

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

defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: miker, Unassigned)

References

Details

Attachments

(1 file)

getAuthoredPropertyValue() returns the computed value when style object is obtained using getComputedStyle(). It would be far more useful for us if this would return the authored property value (we only really care about authored colors).

Run the following in a scratchpad in browser context:

let span = content.document.createElement("span");
span.setAttribute("style", "color: #F00");

span.style.getAuthoredPropertyValue("color"); // Correctly returns #F00

let computed = content.window.getComputedStyle(span);
computed.getAuthoredPropertyValue("color"); // Incorrectly returns rgb(255, 0, 0)
Uh... why would you ever call getAuthoredPropertyValue on computed style?  What exactly do you expect it to return???  The whole operation is nonsensical, like the code comments in nsComputedDOMStyle::GetAuthoredPropertyValue say.
And in particular, computed values are synthesized out of thin air in many cases and don't correspond to any specified, much less authored, value.

Arguably we should have made getAuthoredPropertyValue just throw on computed style.
Attached image Authored.PNG
(In reply to Boris Zbarsky [:bz] from comment #1)
> Uh... why would you ever call getAuthoredPropertyValue on computed style? 
> What exactly do you expect it to return???  The whole operation is
> nonsensical, like the code comments in
> nsComputedDOMStyle::GetAuthoredPropertyValue say.

Out of context it probably is nonsensical.

We have a computed style panel and would like the styles containing colors to show the authored style. It wouldn't make sense to display them as authored in the rule view and when a computed style is expanded but use rgb(r, g, b) in the rest of the computed view (see image).
Computed style data simply doesn't have that information.  For example, if your computed color is rgb(255, 0, 0) then the authored style could have been any of a variety of things, but all the layout data structures contain is a single 32-bit integer representing the color....

Given how common the color struct is, I'm not sure we want to pay the memory cost of storing the authored representation in it.
Fair enough, we can compute these values ourselves by looping through the DOM rules.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: