Bug 1355349 - Move calculation of pseudo type in nsComputedDOMStyle::DoGetStyleContextNoFlush; r=hiro
authorBrian Birtles <birtles@gmail.com>
Fri, 02 Jun 2017 14:21:32 +0900
changeset 410392 38ae6e3d3a114ba48fa13ae98cb81d943c5b6230
parent 410391 2839baa84dca69d6691fa3c81b450431c01f05c9
child 410393 862c08dd715be90afc2fd7b72ca20b8ab6f2abe7
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershiro
bugs1355349
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
layout/style/nsComputedDOMStyle.cpp
--- 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,