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
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -593,16 +593,25 @@ nsComputedDOMStyle::DoGetStyleContextNoF
bool inDocWithShell = true;
if (!presShell) {
inDocWithShell = false;
presShell = aPresShell;
if (!presShell)
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.
if (inDocWithShell &&
aStyleType == eAll &&
!aElement->IsHTMLElement(nsGkAtoms::area)) {
nsIFrame* frame = nullptr;
if (aPseudo == nsCSSPseudoElements::before) {
@@ -645,54 +654,45 @@ nsComputedDOMStyle::DoGetStyleContextNoF
// for the default style, so resolve the style ourselves.
nsPresContext* presContext = presShell->GetPresContext();
if (!presContext)
return nullptr;
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;
nsIContent* parent = aPseudo ? aElement : aElement->GetParent();
// Don't resolve parent context for document fragments.
if (parent && parent->IsElement()) {
parentContext = GetStyleContextNoFlush(parent->AsElement(), nullptr,
aPresShell, aStyleType);
}
StyleResolver styleResolver(presContext, aAnimationFlag);
if (aAnimationFlag == eWithAnimation) {
return styleResolver.ResolveWithAnimation(styleSet,
- aElement, type,
+ aElement, pseudoType,
parentContext,
aStyleType,
inDocWithShell);
}
return styleResolver.ResolveWithoutAnimation(styleSet,
- aElement, type,
+ aElement, pseudoType,
parentContext,
inDocWithShell);
}
nsMargin
nsComputedDOMStyle::GetAdjustedValuesForBoxSizing()
{
// We want the width/height of whatever parts 'width' or 'height' controls,