diff --git a/layout/style/nsRuleWalker.h b/layout/style/nsRuleWalker.h index 1aebed7754d..9faa09e5446 100644 --- a/layout/style/nsRuleWalker.h +++ b/layout/style/nsRuleWalker.h @@ -56,16 +56,16 @@ public: mCurrent = aNode; } +protected: void DoForward(nsIStyleRule* aRule) { mCurrent = mCurrent->Transition(aRule, mLevel, mImportance); NS_POSTCONDITION(mCurrent, "Transition messed up"); } +public: void Forward(nsIStyleRule* aRule) { - // We'd like to assert that this is not a StyleRule, but unfortunately - // ResolveStyleByAddingRules can be passed both style and non-style rules. - // NS_PRECONDITION(!nsRefPtr(do_QueryObject(aRule)), - // "Calling the wrong Forward() overload"); + NS_PRECONDITION(!nsRefPtr(do_QueryObject(aRule)), + "Calling the wrong Forward() overload"); DoForward(aRule); } void Forward(mozilla::css::StyleRule* aRule) { @@ -73,6 +73,12 @@ public: mCheckForImportantRules = mCheckForImportantRules && !aRule->GetImportantRule(); } + // ForwardOnPossiblyCSSRule should only be used by callers that have + // an explicit list of rules they need to walk, with the list + // already containing any important rules they care about. + void ForwardOnPossiblyCSSRule(nsIStyleRule* aRule) { + DoForward(aRule); + } void Reset() { mCurrent = mRoot; } diff --git a/layout/style/nsStyleSet.cpp b/layout/style/nsStyleSet.cpp index 86495bbe574..b72aa79c466 100644 --- a/layout/style/nsStyleSet.cpp +++ b/layout/style/nsStyleSet.cpp @@ -943,7 +943,7 @@ nsStyleSet::ResolveStyleForRules(nsStyleContext* aParentContext, // matter. ruleWalker.SetLevel(eDocSheet, PR_FALSE, PR_FALSE); for (PRInt32 i = 0; i < aRules.Count(); i++) { - ruleWalker.Forward(aRules.ObjectAt(i)); + ruleWalker.ForwardOnPossiblyCSSRule(aRules.ObjectAt(i)); } return GetContext(aParentContext, ruleWalker.CurrentNode(), nsnull, @@ -964,7 +964,7 @@ nsStyleSet::ResolveStyleByAddingRules(nsStyleContext* aBaseContext, // matter. ruleWalker.SetLevel(eDocSheet, PR_FALSE, PR_FALSE); for (PRInt32 i = 0; i < aRules.Count(); i++) { - ruleWalker.Forward(aRules.ObjectAt(i)); + ruleWalker.ForwardOnPossiblyCSSRule(aRules.ObjectAt(i)); } nsRuleNode *ruleNode = ruleWalker.CurrentNode(); @@ -973,7 +973,7 @@ nsStyleSet::ResolveStyleByAddingRules(nsStyleContext* aBaseContext, if (aBaseContext->GetStyleIfVisited()) { ruleWalker.SetCurrentNode(aBaseContext->GetStyleIfVisited()->GetRuleNode()); for (PRInt32 i = 0; i < aRules.Count(); i++) { - ruleWalker.Forward(aRules.ObjectAt(i)); + ruleWalker.ForwardOnPossiblyCSSRule(aRules.ObjectAt(i)); } visitedRuleNode = ruleWalker.CurrentNode(); }