Bug 1418867 - Pass element or pseudo element to Servo_StyleSet_GetBaseComputedValuesForElement(). r?emilio draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Wed, 22 Nov 2017 11:03:40 +0900
changeset 701685 6661b4e81ec5f7e093c73b6fdd4f34dee92f9eb3
parent 701684 c9ad8a02b9e28baf321c3a707a1c9d7479a3914d
child 701686 8fe9bb8bbdf5c68b979210d445ee5d918f90e2fc
push id90239
push userhikezoe@mozilla.com
push dateWed, 22 Nov 2017 04:18:13 +0000
reviewersemilio
bugs1418867
milestone59.0a1
Bug 1418867 - Pass element or pseudo element to Servo_StyleSet_GetBaseComputedValuesForElement(). r?emilio MozReview-Commit-ID: Ae3iZ6g3x3c
dom/animation/KeyframeEffectReadOnly.cpp
layout/style/ServoBindingList.h
layout/style/ServoStyleSet.cpp
layout/style/ServoStyleSet.h
layout/style/nsComputedDOMStyle.cpp
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -555,21 +555,23 @@ KeyframeEffectReadOnly::EnsureBaseStyle(
     }
   }
 
   if (!hasAdditiveValues) {
     return;
   }
 
   if (!aBaseStyleContext) {
+    Element* animatingElement =
+      EffectCompositor::GetElementToRestyle(mTarget->mElement,
+                                            mTarget->mPseudoType);
     aBaseStyleContext =
       aPresContext->StyleSet()->AsServo()->GetBaseContextForElement(
-          mTarget->mElement,
+          animatingElement,
           aPresContext,
-          mTarget->mPseudoType,
           aComputedStyle);
   }
   RefPtr<RawServoAnimationValue> baseValue =
     Servo_ComputedValues_ExtractAnimationValue(aBaseStyleContext,
                                                aProperty.mProperty).Consume();
   mBaseStyleValuesForServo.Put(aProperty.mProperty, baseValue);
 }
 
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -689,18 +689,17 @@ SERVO_BINDING_FUNC(Servo_IsWorkerThread,
 SERVO_BINDING_FUNC(Servo_MaybeGCRuleTree, void, RawServoStyleSetBorrowed set)
 
 // Returns computed values for the given element without any animations rules.
 SERVO_BINDING_FUNC(Servo_StyleSet_GetBaseComputedValuesForElement,
                    ServoStyleContextStrong,
                    RawServoStyleSetBorrowed set,
                    RawGeckoElementBorrowed element,
                    ServoStyleContextBorrowed existing_style,
-                   const mozilla::ServoElementSnapshotTable* snapshots,
-                   mozilla::CSSPseudoElementType pseudo_type)
+                   const mozilla::ServoElementSnapshotTable* snapshots)
 // Returns computed values for the given element by adding an animation value.
 SERVO_BINDING_FUNC(Servo_StyleSet_GetComputedValuesByAddingAnimation,
                    ServoStyleContextStrong,
                    RawServoStyleSetBorrowed set,
                    RawGeckoElementBorrowed element,
                    ServoStyleContextBorrowed existing_style,
                    const mozilla::ServoElementSnapshotTable* snapshots,
                    RawServoAnimationValueBorrowed animation)
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -1104,24 +1104,22 @@ ServoStyleSet::GetAnimationValues(
                            mRawSet.get(),
                            &aAnimationValues);
 }
 
 already_AddRefed<ServoStyleContext>
 ServoStyleSet::GetBaseContextForElement(
   Element* aElement,
   nsPresContext* aPresContext,
-  CSSPseudoElementType aPseudoType,
   const ServoStyleContext* aStyle)
 {
   return Servo_StyleSet_GetBaseComputedValuesForElement(mRawSet.get(),
                                                         aElement,
                                                         aStyle,
-                                                        &Snapshots(),
-                                                        aPseudoType).Consume();
+                                                        &Snapshots()).Consume();
 }
 
 already_AddRefed<ServoStyleContext>
 ServoStyleSet::ResolveServoStyleByAddingAnimation(
   Element* aElement,
   const ServoStyleContext* aStyle,
   RawServoAnimationValue* aAnimationValue)
 {
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -387,17 +387,16 @@ public:
   nsCSSCounterStyleRule* CounterStyleRuleForName(nsAtom* aName);
 
   // Get all the currently-active font feature values set.
   already_AddRefed<gfxFontFeatureValueSet> BuildFontFeatureValueSet();
 
   already_AddRefed<ServoStyleContext>
   GetBaseContextForElement(dom::Element* aElement,
                            nsPresContext* aPresContext,
-                           CSSPseudoElementType aPseudoType,
                            const ServoStyleContext* aStyle);
 
   // Get a style context that represents |aStyle|, but as though
   // it additionally matched the rules of the newly added |aAnimaitonaValue|.
   // We use this function to temporarily generate a ServoStyleContext for
   // calculating the cumulative change hints.
   // This must hold:
   //   The additional rules must be appropriate for the transition
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -744,18 +744,19 @@ nsComputedDOMStyle::DoGetStyleContextNoF
                      eRestyle_AllHintsWithAnimations);
           } else {
             Element* elementOrPseudoElement =
               EffectCompositor::GetElementToRestyle(aElement, pseudoType);
             if (!elementOrPseudoElement) {
               return nullptr;
             }
             return presContext->StyleSet()->AsServo()->
-              GetBaseContextForElement(aElement, presContext,
-                                       pseudoType, result->AsServo());
+              GetBaseContextForElement(elementOrPseudoElement,
+                                       presContext,
+                                       result->AsServo());
           }
         }
 
         // this function returns an addrefed style context
         RefPtr<nsStyleContext> ret = result;
         return ret.forget();
       }
     }
@@ -782,18 +783,19 @@ nsComputedDOMStyle::DoGetStyleContextNoF
       return result.forget();
     }
 
     Element* elementOrPseudoElement =
       EffectCompositor::GetElementToRestyle(aElement, pseudoType);
     if (!elementOrPseudoElement) {
       return nullptr;
     }
-    return servoSet->GetBaseContextForElement(aElement, presContext,
-                                              pseudoType, result);
+    return servoSet->GetBaseContextForElement(elementOrPseudoElement,
+                                              presContext,
+                                              result);
   }
 
   RefPtr<GeckoStyleContext> parentContext;
   nsIContent* parent = aPseudo ? aElement : aElement->GetParent();
   // Don't resolve parent context for document fragments.
   if (parent && parent->IsElement()) {
     RefPtr<nsStyleContext> p =
       GetStyleContextNoFlush(parent->AsElement(), nullptr,