Last Comment Bug 529750 - Move GetImportantRule to nsICSSStyleRule and make it nonvirtual
: Move GetImportantRule to nsICSSStyleRule and make it nonvirtual
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: CSS Parsing and Computation (show other bugs)
: Trunk
: x86 Mac OS X
: P1 normal (vote)
: mozilla7
Assigned To: Boris Zbarsky [:bz] (still a bit busy)
:
: Jet Villegas (:jet)
Mentors:
Depends on: 522595 523148 529749 576831
Blocks:
  Show dependency treegraph
 
Reported: 2009-11-18 22:48 PST by Boris Zbarsky [:bz] (still a bit busy)
Modified: 2011-05-25 23:40 PDT (History)
7 users (show)
bzbarsky: in‑testsuite-
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
part 1. Don't walk non-CSS UA rules when checking for important UA rules. (3.56 KB, patch)
2011-05-06 17:25 PDT, Boris Zbarsky [:bz] (still a bit busy)
dbaron: review+
Details | Diff | Splinter Review
part 2. Assume that in AssertNoImportantRules and AddImportantRules the rule is a StyleRule. (4.42 KB, patch)
2011-05-06 17:35 PDT, Boris Zbarsky [:bz] (still a bit busy)
dbaron: review+
Details | Diff | Splinter Review
part 3. Switch nsRuleWalker to only calling GetImportantRule on CSS StyleRules. (3.03 KB, patch)
2011-05-06 17:35 PDT, Boris Zbarsky [:bz] (still a bit busy)
dbaron: review+
Details | Diff | Splinter Review
part 4. Move GetImportantRule to css::StyleRule. (4.45 KB, patch)
2011-05-06 17:36 PDT, Boris Zbarsky [:bz] (still a bit busy)
dbaron: review+
Details | Diff | Splinter Review
followup; reenable the assertion. (3.75 KB, patch)
2011-05-23 21:18 PDT, Boris Zbarsky [:bz] (still a bit busy)
dbaron: review+
Details | Diff | Splinter Review

Description Boris Zbarsky [:bz] (still a bit busy) 2009-11-18 22:48:27 PST
See bug 523148 comment 2.
Comment 1 Boris Zbarsky [:bz] (still a bit busy) 2009-11-18 22:54:29 PST
Need to wait for bug 522595 to land before working on this.
Comment 2 Boris Zbarsky [:bz] (still a bit busy) 2011-05-06 13:09:18 PDT
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).
Comment 3 Boris Zbarsky [:bz] (still a bit busy) 2011-05-06 17:25:16 PDT
Created attachment 530778 [details] [diff] [review]
part 1.  Don't walk non-CSS UA rules when checking for important UA rules.
Comment 4 Boris Zbarsky [:bz] (still a bit busy) 2011-05-06 17:35:06 PDT
Created attachment 530779 [details] [diff] [review]
part 2.  Assume that in AssertNoImportantRules and AddImportantRules the rule is a StyleRule.
Comment 5 Boris Zbarsky [:bz] (still a bit busy) 2011-05-06 17:35:31 PDT
Created attachment 530780 [details] [diff] [review]
part 3.  Switch nsRuleWalker to only calling GetImportantRule on CSS StyleRules.
Comment 6 Boris Zbarsky [:bz] (still a bit busy) 2011-05-06 17:36:53 PDT
Created attachment 530781 [details] [diff] [review]
part 4.  Move GetImportantRule to css::StyleRule.
Comment 7 David Baron :dbaron: ⌚️UTC-10 (vacation, returning December 19) 2011-05-21 22:22:04 PDT
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
Comment 8 David Baron :dbaron: ⌚️UTC-10 (vacation, returning December 19) 2011-05-21 22:22:23 PDT
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
Comment 9 David Baron :dbaron: ⌚️UTC-10 (vacation, returning December 19) 2011-05-21 22:22:47 PDT
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
Comment 10 David Baron :dbaron: ⌚️UTC-10 (vacation, returning December 19) 2011-05-21 22:23:05 PDT
Comment on attachment 530781 [details] [diff] [review]
part 4.  Move GetImportantRule to css::StyleRule.

r=dbaron
Comment 11 Boris Zbarsky [:bz] (still a bit busy) 2011-05-23 12:59:06 PDT
> 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.
Comment 12 Boris Zbarsky [:bz] (still a bit busy) 2011-05-23 16:44:31 PDT
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.
Comment 13 Boris Zbarsky [:bz] (still a bit busy) 2011-05-23 16:45:00 PDT
I disabled that assert for now.  Please let me know if you'd prefer some other solution.
Comment 14 Boris Zbarsky [:bz] (still a bit busy) 2011-05-23 16:45:26 PDT
David, see comment 12 and comment 13.
Comment 16 David Baron :dbaron: ⌚️UTC-10 (vacation, returning December 19) 2011-05-23 19:55:49 PDT
The other solution would be to add a third Forward() method (ForwardOnPossiblyCSSRule) that doesn't have the assert.  I'd sort of prefer that...
Comment 17 Boris Zbarsky [:bz] (still a bit busy) 2011-05-23 20:11:16 PDT
I can do that.
Comment 18 Boris Zbarsky [:bz] (still a bit busy) 2011-05-23 21:18:12 PDT
Created attachment 534669 [details] [diff] [review]
followup; reenable the assertion.
Comment 19 Matt Brubeck (:mbrubeck) 2011-05-24 15:03:03 PDT
Merged all parts from Cedar to mozilla-central:
http://hg.mozilla.org/mozilla-central/pushloghtml?changeset=e0580e4f3825
Comment 20 David Baron :dbaron: ⌚️UTC-10 (vacation, returning December 19) 2011-05-25 13:43:32 PDT
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
Comment 21 Boris Zbarsky [:bz] (still a bit busy) 2011-05-25 19:20:17 PDT
Done, and pushed http://hg.mozilla.org/projects/cedar/rev/db398bf9cffe with that.
Comment 22 Mounir Lamouri (:mounir) 2011-05-25 23:40:49 PDT
http://hg.mozilla.org/mozilla-central/rev/db398bf9cffe

Note You need to log in before you can comment on or make changes to this bug.