Bug 1355349 - Get unanimated style in nsComputedDOMStyle::DoGetStyleContextNoFlush for Servo too; r?hiro draft
authorBrian Birtles <birtles@gmail.com>
Fri, 02 Jun 2017 14:23:22 +0900
changeset 588794 2c2938beac021b43986ef43fe92c82b42c754b31
parent 588793 2aab746d53a88b843f8704f4c07e8fdf9b5b07aa
child 588795 8187e2f5eabd48a04ba56291462332b1fcc3acdd
push id62159
push userbbirtles@mozilla.com
push dateMon, 05 Jun 2017 03:26:35 +0000
reviewershiro
bugs1355349
milestone55.0a1
Bug 1355349 - Get unanimated style in nsComputedDOMStyle::DoGetStyleContextNoFlush for Servo too; r?hiro MozReview-Commit-ID: BPtpVfbQ5Kk
layout/style/nsComputedDOMStyle.cpp
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -632,19 +632,21 @@ nsComputedDOMStyle::DoGetStyleContextNoF
         if (aAnimationFlag == eWithoutAnimation) {
           nsPresContext* presContext = presShell->GetPresContext();
           MOZ_ASSERT(presContext, "Should have a prescontext if we have a frame");
           if (presContext && presContext->StyleSet()->IsGecko()) {
             nsStyleSet* styleSet = presContext->StyleSet()->AsGecko();
             return styleSet->ResolveStyleByRemovingAnimation(
                      aElement, result, eRestyle_AllHintsWithAnimations);
           } else {
-            NS_WARNING("stylo: Getting the unanimated style context is not yet"
-                       " supported for Servo");
-            return nullptr;
+            RefPtr<ServoComputedValues> baseComputedValues =
+              presContext->StyleSet()->AsServo()->
+                GetBaseComputedValuesForElement(aElement, pseudoType);
+            return NS_NewStyleContext(nullptr, presContext, aPseudo,
+                                      pseudoType, baseComputedValues.forget());
           }
         }
 
         // this function returns an addrefed style context
         RefPtr<nsStyleContext> ret = result;
         return ret.forget();
       }
     }
@@ -660,17 +662,26 @@ nsComputedDOMStyle::DoGetStyleContextNoF
   StyleSetHandle styleSet = presShell->StyleSet();
 
   // 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, pseudoType, rules);
+    RefPtr<nsStyleContext> result =
+       servoSet->ResolveTransientStyle(aElement, aPseudo, pseudoType, rules);
+    if (aAnimationFlag == eWithAnimation) {
+      return result.forget();
+    }
+
+    RefPtr<ServoComputedValues> baseComputedValues =
+      servoSet->GetBaseComputedValuesForElement(aElement, pseudoType);
+    return NS_NewStyleContext(nullptr, presContext, aPseudo,
+                              pseudoType, baseComputedValues.forget());
   }
 
   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);