From 49502ebb3d36d35c2deed6fa2c587c55f7148765 Mon Sep 17 00:00:00 2001 From: Brian Birtles Date: Fri, 2 Jun 2017 14:21:32 +0900 Subject: [PATCH] Bug 1355349 - Move calculation of pseudo type in nsComputedDOMStyle::DoGetStyleContextNoFlush; r=hiro This patch just moves the calculation of the pseudo type earlier in the method so we can re-use it in the next patch in this series to get the style context from the Servo backend for the case where we don't need to resolve style. This patch also renames the local variable from 'type' to 'pseudoType' since that seems less ambiguous. MozReview-Commit-ID: 6pi2F1vZYHJ --HG-- extra : rebase_source : 1b9c610edbe4f07000b6cc2087f45dd04792228b --- layout/style/nsComputedDOMStyle.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 2086d2fda4c6..7551bb2aca57 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -598,6 +598,15 @@ nsComputedDOMStyle::DoGetStyleContextNoFlush(Element* aElement, return nullptr; } + auto pseudoType = CSSPseudoElementType::NotPseudo; + if (aPseudo) { + pseudoType = nsCSSPseudoElements:: + GetPseudoType(aPseudo, CSSEnabledState::eIgnoreEnabledState); + if (pseudoType >= CSSPseudoElementType::Count) { + return nullptr; + } + } + // XXX the !aElement->IsHTMLElement(nsGkAtoms::area) // check is needed due to bug 135040 (to avoid using // mPrimaryFrame). Remove it once that's fixed. @@ -650,22 +659,13 @@ nsComputedDOMStyle::DoGetStyleContextNoFlush(Element* aElement, StyleSetHandle styleSet = presShell->StyleSet(); - auto type = CSSPseudoElementType::NotPseudo; - if (aPseudo) { - type = nsCSSPseudoElements:: - GetPseudoType(aPseudo, CSSEnabledState::eIgnoreEnabledState); - if (type >= CSSPseudoElementType::Count) { - return nullptr; - } - } - // For Servo, compute the result directly without recursively building up // a throwaway style context chain. if (ServoStyleSet* servoSet = styleSet->GetAsServo()) { StyleRuleInclusion rules = aStyleType == eDefaultOnly ? StyleRuleInclusion::DefaultOnly : StyleRuleInclusion::All; - return servoSet->ResolveTransientStyle(aElement, aPseudo, type, rules); + return servoSet->ResolveTransientStyle(aElement, aPseudo, pseudoType, rules); } RefPtr parentContext; @@ -680,14 +680,14 @@ nsComputedDOMStyle::DoGetStyleContextNoFlush(Element* aElement, if (aAnimationFlag == eWithAnimation) { return styleResolver.ResolveWithAnimation(styleSet, - aElement, type, + aElement, pseudoType, parentContext, aStyleType, inDocWithShell); } return styleResolver.ResolveWithoutAnimation(styleSet, - aElement, type, + aElement, pseudoType, parentContext, inDocWithShell); }