Closed Bug 529750 Opened 15 years ago Closed 13 years ago

Move GetImportantRule to nsICSSStyleRule and make it nonvirtual

Categories

(Core :: CSS Parsing and Computation, defect, P1)

x86
macOS
defect

Tracking

()

RESOLVED FIXED
mozilla7

People

(Reporter: bzbarsky, Assigned: bzbarsky)

References

Details

Attachments

(5 files)

Depends on: 523148
Need to wait for bug 522595 to land before working on this.
Depends on: 522595
Depends on: 529749
Priority: -- → P2
Depends on: 576831
Priority: P2 → P3
Priority: P3 → P1
One thing to keep track of, from bug 5231348: There are some UA-level rules that are not in fact nsICSSStyleRule (e.g. the restriction rules for first-letter and first-line).
Attachment #530781 - Flags: review?(dbaron)
Whiteboard: [need review]
Comment on attachment 530778 [details] [diff] [review] part 1. Don't walk non-CSS UA rules when checking for important UA rules. You should AssertNoCSSRules between lastRestrictionRN and mRuleTree. r=dbaron with that
Attachment #530778 - Flags: review?(dbaron) → review+
Comment on attachment 530779 [details] [diff] [review] part 2. Assume that in AssertNoImportantRules and AddImportantRules the rule is a StyleRule. >+#ifdef DEBUG >+ nsRefPtr<css::StyleRule> cssRule(do_QueryObject(node->GetRule())); >+ NS_ASSERTION(cssRule, "Unexpected non-CSS rule"); >+#endif If we haven't broken the ability to do it, I'd prefer (no ifdefs): + NS_ASSERTION(nsRefPtr<css::StyleRule>(do_QueryObject(node->GetRule())), + "Unexpected non-CSS rule"); r=dbaron with that
Attachment #530779 - Flags: review?(dbaron) → review+
Comment on attachment 530780 [details] [diff] [review] part 3. Switch nsRuleWalker to only calling GetImportantRule on CSS StyleRules. Instead of having one overload of forward call the other, could you have both call a DoForward() method, and then have Forward(nsIStyleRule*) assert that its argument is not a css::StyleRule (to prevent the same mistake you had to fix earlier in the patch)? r=dbaron with that
Attachment #530780 - Flags: review?(dbaron) → review+
Comment on attachment 530781 [details] [diff] [review] part 4. Move GetImportantRule to css::StyleRule. r=dbaron
Attachment #530781 - Flags: review?(dbaron) → review+
> You should AssertNoCSSRules between lastRestrictionRN and mRuleTree. Done. >+ NS_ASSERTION(nsRefPtr<css::StyleRule>(do_QueryObject(node->GetRule())), >+ "Unexpected non-CSS rule"); Done. > could you have both call a DoForward() method, and then have > Forward(nsIStyleRule*) assert Done.
So adding that assert made tests fail because ResolveStyleByAddingRules() passes in a nsCOMArray<nsIStyleRule> &aRules. And StyleWithDeclarationAdded calls ResolveStyleByAddingRules and passes in an array containing a single StyleRule. Other callers pass non-style rules here.
I disabled that assert for now. Please let me know if you'd prefer some other solution.
David, see comment 12 and comment 13.
Target Milestone: mozilla6 → mozilla7
The other solution would be to add a third Forward() method (ForwardOnPossiblyCSSRule) that doesn't have the assert. I'd sort of prefer that...
I can do that.
Attachment #534669 - Flags: review?(dbaron)
Merged all parts from Cedar to mozilla-central: http://hg.mozilla.org/mozilla-central/pushloghtml?changeset=e0580e4f3825
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Whiteboard: fixed-in-cedar
Comment on attachment 534669 [details] [diff] [review] followup; reenable the assertion. >+ void ForwardOnPossiblyCSSRule(nsIStyleRule* aRule) { >+ DoForward(aRule); >+ } Add a comment that callers should only use this when they have a list of rules that already has the important rules in it? r=dbaron with that
Attachment #534669 - Flags: review?(dbaron) → review+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: