From d59096e3a076cdf95aaf6608f67e2dec6394e309 Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Sat, 2 Aug 2014 19:37:44 -0700 Subject: [PATCH] Bug 996796 patch 10 - Separate the rule node replacement code from the style context handling so that we can make visited handling correct. r=heycam --- layout/style/nsStyleSet.cpp | 33 ++++++++++++++++++++++----------- layout/style/nsStyleSet.h | 6 ++++++ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/layout/style/nsStyleSet.cpp b/layout/style/nsStyleSet.cpp index 1405b29ca69..7a5de2b9b5a 100644 --- a/layout/style/nsStyleSet.cpp +++ b/layout/style/nsStyleSet.cpp @@ -1327,11 +1327,11 @@ static const CascadeLevel gCascadeLevels[] = { { nsStyleSet::eTransitionSheet, false, eRestyle_CSSTransitions }, }; -already_AddRefed -nsStyleSet::ResolveStyleWithReplacement(Element* aElement, - nsStyleContext* aNewParentContext, - nsStyleContext* aOldStyleContext, - nsRestyleHint aReplacements) +nsRuleNode* +nsStyleSet::RuleNodeWithReplacement(Element* aElement, + nsRuleNode* aOldRuleNode, + nsCSSPseudoElements::Type aPseudoType, + nsRestyleHint aReplacements) { NS_ABORT_IF_FALSE(!(aReplacements & ~(eRestyle_CSSTransitions | eRestyle_CSSAnimations)), @@ -1341,7 +1341,7 @@ nsStyleSet::ResolveStyleWithReplacement(Element* aElement, uint32_t(aReplacements)).get()); nsTArray rules; - for (nsRuleNode* ruleNode = aOldStyleContext->RuleNode(); !ruleNode->IsRoot(); + for (nsRuleNode* ruleNode = aOldRuleNode; !ruleNode->IsRoot(); ruleNode = ruleNode->GetParent()) { RuleNodeInfo* curRule = rules.AppendElement(); curRule->mRule = ruleNode->GetRule(); @@ -1364,7 +1364,7 @@ nsStyleSet::ResolveStyleWithReplacement(Element* aElement, nsAnimationManager* animationManager = PresContext()->AnimationManager(); ElementAnimationCollection* collection = animationManager->GetElementAnimations( - aElement, aOldStyleContext->GetPseudoType(), false); + aElement, aPseudoType, false); if (collection) { animationManager->UpdateStyleAndEvents( @@ -1380,9 +1380,7 @@ nsStyleSet::ResolveStyleWithReplacement(Element* aElement, nsPresContext* presContext = PresContext(); ElementAnimationCollection* collection = presContext->TransitionManager()->GetElementTransitions( - aElement, - aOldStyleContext->GetPseudoType(), - false); + aElement, aPseudoType, false); if (collection) { collection->EnsureStyleRuleFor( @@ -1415,6 +1413,19 @@ nsStyleSet::ResolveStyleWithReplacement(Element* aElement, } } + return ruleWalker.CurrentNode(); +} + +already_AddRefed +nsStyleSet::ResolveStyleWithReplacement(Element* aElement, + nsStyleContext* aNewParentContext, + nsStyleContext* aOldStyleContext, + nsRestyleHint aReplacements) +{ + nsRuleNode* ruleNode = + RuleNodeWithReplacement(aElement, aOldStyleContext->RuleNode(), + aOldStyleContext->GetPseudoType(), aReplacements); + // FIXME: Does this handle visited contexts correctly??? uint32_t flags = eNoFlags; @@ -1425,7 +1436,7 @@ nsStyleSet::ResolveStyleWithReplacement(Element* aElement, flags |= eIsVisitedLink; } - return GetContext(aNewParentContext, ruleWalker.CurrentNode(), nullptr, + return GetContext(aNewParentContext, ruleNode, nullptr, nullptr, nsCSSPseudoElements::ePseudo_NotPseudoElement, nullptr, flags); } diff --git a/layout/style/nsStyleSet.h b/layout/style/nsStyleSet.h index 12230e021b3..44cc98a725b 100644 --- a/layout/style/nsStyleSet.h +++ b/layout/style/nsStyleSet.h @@ -399,6 +399,12 @@ class nsStyleSet ElementDependentRuleProcessorData* aData, bool aWalkAllXBLStylesheets); + // Helper for ResolveStyleWithReplacement + nsRuleNode* RuleNodeWithReplacement(mozilla::dom::Element* aElement, + nsRuleNode* aOldRuleNode, + nsCSSPseudoElements::Type aPseudoType, + nsRestyleHint aReplacements); + /** * Bit-flags that can be passed to GetContext() in its parameter 'aFlags'. */