From f9c2b8834031bc9a3258ab65e3d33d80c634e13f Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 23 May 2011 16:45:42 -0400 Subject: [PATCH] Bug 529750 part 1. Don't walk non-CSS UA rules when checking for important UA rules. r=dbaron --- layout/style/nsStyleSet.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/layout/style/nsStyleSet.cpp b/layout/style/nsStyleSet.cpp index 99610e212e4..b764feba527 100644 --- a/layout/style/nsStyleSet.cpp +++ b/layout/style/nsStyleSet.cpp @@ -700,6 +700,10 @@ nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc, // -. transition rules = Transition normal // [most important] + // Save off the last rule before we start walking our agent sheets; + // this will be either the root or one of the restriction rules. + nsRuleNode* lastRestrictionRN = aRuleWalker->CurrentNode(); + aRuleWalker->SetLevel(eAgentSheet, PR_FALSE, PR_TRUE); if (mRuleProcessors[eAgentSheet]) (*aCollectorFunc)(mRuleProcessors[eAgentSheet], aData); @@ -786,14 +790,18 @@ nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc, if (haveImportantUARules) { aRuleWalker->SetLevel(eAgentSheet, PR_TRUE, PR_FALSE); - AddImportantRules(lastAgentRN, mRuleTree, aRuleWalker); //agent + AddImportantRules(lastAgentRN, lastRestrictionRN, aRuleWalker); //agent } #ifdef DEBUG else { - AssertNoImportantRules(lastAgentRN, mRuleTree); + AssertNoImportantRules(lastAgentRN, lastRestrictionRN); } #endif +#ifdef DEBUG + AssertNoCSSRules(lastRestrictionRN, mRuleTree); +#endif + #ifdef DEBUG nsRuleNode *lastImportantRN = aRuleWalker->CurrentNode(); #endif @@ -1022,6 +1030,7 @@ nsStyleSet::ResolvePseudoElementStyle(Element* aParentElement, if (treeContext.HaveRelevantLink()) { treeContext.ResetForVisitedMatching(); ruleWalker.Reset(); + WalkRestrictionRule(aType, &ruleWalker); FileRules(EnumRulesMatching, &data, aParentElement, &ruleWalker); visitedRuleNode = ruleWalker.CurrentNode(); @@ -1081,6 +1090,7 @@ nsStyleSet::ProbePseudoElementStyle(Element* aParentElement, if (aTreeMatchContext.HaveRelevantLink()) { aTreeMatchContext.ResetForVisitedMatching(); ruleWalker.Reset(); + WalkRestrictionRule(aType, &ruleWalker); FileRules(EnumRulesMatching, &data, aParentElement, &ruleWalker); visitedRuleNode = ruleWalker.CurrentNode();