Closed Bug 800983 Opened 12 years ago Closed 12 years ago

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

Categories

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

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla19

People

(Reporter: bzbarsky, Assigned: bzbarsky)

Details

(Keywords: dev-doc-complete)

Attachments

(1 file)

I'm going to call this getDefaultComputedStyle.
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
https://hg.mozilla.org/mozilla-central/rev/fd12a2c69e93
Status: NEW → RESOLVED
Closed: 12 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.

Attachment

General

Created:
Updated:
Size: