Expose a way to get computed style taking only UA and user sheets into account (getDefaultComputedStyle)

RESOLVED FIXED in mozilla19

Status

()

Core
DOM: CSS Object Model
RESOLVED FIXED
5 years ago
2 months ago

People

(Reporter: bz, Assigned: bz)

Tracking

({dev-doc-complete})

unspecified
mozilla19
x86
Mac OS X
dev-doc-complete
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

I'm going to call this getDefaultComputedStyle.
Created attachment 670868 [details] [diff] [review]
Expose a getter for default computed style.   alternative implementation strategy is to add "default-only"

versions of ResolveStyleFor and ResolvePseudoElementStyle and then
modify FileRules to support those, or use a cut-down custom version of
FileRules for them.  That would be faster, but more complicated on the
style set side.  We can always make that switch if we need to, I guess.
Attachment #670868 - Flags: review?(dbaron)
Oh, an open question is whether preshints should be counted as "default" style or not.  Either way is easy to implement.  For now I did not include them.  This is generally OK, modulo things like @hidden, for which we treat them as preshints but the spec technically treats them as UA rules or something.
Whiteboard: [need review]
Comment on attachment 670868 [details] [diff] [review]
Expose a getter for default computed style.   alternative implementation strategy is to add "default-only"

Could you:

 (1) replace the boolean with an enum (with useful names for the values)?

 (2) append to an array, and then either (a) reverse into another array (preferably with SetCapacity first) or (b) add a Reverse method to nsTArray and use nsTArray<nsCOMPtr<nsIStyleRule> >

?

r=dbaron with that
Attachment #670868 - Flags: review?(dbaron) → review+
For #2, I did a combination, because knowing that I have an nsTArray of nsCOMPtr means I can reverse without refcounting like so:

    for (uint32_t i = 0, length = rules.Length(), stop = length / 2;
         i < stop; ++i) {
      rules[i].swap(rules[length - i - 1]);
    }
Oh, and I can't use the enum in nsGlobalWindow function signatures, unfortunately, because I can't include nsComputedDOMStyle.h in nsGlobalWindow.h due to include hell.  :(
https://hg.mozilla.org/integration/mozilla-inbound/rev/fd12a2c69e93
Flags: in-testsuite+
Keywords: dev-doc-needed
Whiteboard: [need review]
Target Milestone: --- → mozilla19
I wrote some docs at https://developer.mozilla.org/en-US/docs/DOM/window.getDefaultComputedStyle
Keywords: dev-doc-needed → dev-doc-complete
https://hg.mozilla.org/mozilla-central/rev/fd12a2c69e93
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Summary: Expose a way to get computed style taking only UA and user sheets into account → Expose a way to get computed style taking only UA and user sheets into account (getDefaultComputedStyle)
You need to log in before you can comment on or make changes to this bug.