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
This commit is contained in:
Brian Birtles 2017-06-02 14:21:32 +09:00
Родитель 278dcb4bda
Коммит 49502ebb3d
1 изменённых файлов: 12 добавлений и 12 удалений

Просмотреть файл

@ -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<nsStyleContext> 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);
}