Bug 1303235 - Part 1: Add ResolveServoStyleByAddingAnimation. r=hiro, a=ritu
authorBoris Chiou <boris.chiou@gmail.com>
Thu, 19 Oct 2017 10:51:55 +0800
changeset 435138 a3f558c2926173a6ff6adcf6f9f641662ed0fce8
parent 435137 df3cc0ef0e479d928dc4d1e75bdd81089fe109af
child 435139 167961e9d88e1c3e2a2bf442c5c3df1a76b50fee
push id1567
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 12:36:05 +0000
treeherdermozilla-release@e512c14a0406 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershiro, ritu
bugs1303235
milestone57.0
Bug 1303235 - Part 1: Add ResolveServoStyleByAddingAnimation. r=hiro, a=ritu We need to create a temporary ServoStyleContext with the animation value for calculating the Cumulative change hints. MozReview-Commit-ID: JzArnaGqVeV
layout/style/ServoBindingList.h
layout/style/ServoStyleSet.cpp
layout/style/ServoStyleSet.h
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -633,16 +633,24 @@ SERVO_BINDING_FUNC(Servo_MaybeGCRuleTree
 // 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)
+// 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)
 
 // For canvas font.
 SERVO_BINDING_FUNC(Servo_SerializeFontValueForCanvas, void,
                    RawServoDeclarationBlockBorrowed declarations,
                    nsAString* buffer)
 
 // Get custom property value.
 SERVO_BINDING_FUNC(Servo_GetCustomPropertyValue, bool,
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -1218,16 +1218,35 @@ ServoStyleSet::GetBaseContextForElement(
   AutoClearStaleData guard(aElement);
   return Servo_StyleSet_GetBaseComputedValuesForElement(mRawSet.get(),
                                                         aElement,
                                                         aStyle,
                                                         &Snapshots(),
                                                         aPseudoType).Consume();
 }
 
+already_AddRefed<ServoStyleContext>
+ServoStyleSet::ResolveServoStyleByAddingAnimation(
+  Element* aElement,
+  const ServoStyleContext* aStyle,
+  RawServoAnimationValue* aAnimationValue)
+{
+  MOZ_RELEASE_ASSERT(!aElement->OwnerDoc()->GetBFCacheEntry(),
+                     "ResolveServoStyleByAddingAniamtion does not support "
+                     "documents in the bfcache");
+
+  AutoClearStaleData guard(aElement);
+  return Servo_StyleSet_GetComputedValuesByAddingAnimation(
+    mRawSet.get(),
+    aElement,
+    aStyle,
+    &Snapshots(),
+    aAnimationValue).Consume();
+}
+
 already_AddRefed<RawServoAnimationValue>
 ServoStyleSet::ComputeAnimationValue(
   Element* aElement,
   RawServoDeclarationBlock* aDeclarations,
   const ServoStyleContext* aContext)
 {
   // Servo_AnimationValue_Compute below won't handle ignoring existing element
   // data for bfcached documents. (See comment in ResolveStyleLazily about
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -390,16 +390,31 @@ public:
   already_AddRefed<ServoStyleContext>
   GetBaseContextForElement(dom::Element* aElement,
                            ServoStyleContext* aParentContext,
                            nsPresContext* aPresContext,
                            nsIAtom* aPseudoTag,
                            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
+  //   level of the cascade, which is the highest level of the cascade.
+  //   (This is the case for one current caller, the cover rule used
+  //   for CSS transitions.)
+  // Note: |aElement| should be the generated element if it is pseudo.
+  already_AddRefed<ServoStyleContext>
+  ResolveServoStyleByAddingAnimation(dom::Element* aElement,
+                                     const ServoStyleContext* aStyle,
+                                     RawServoAnimationValue* aAnimationValue);
+
   /**
    * Resolve style for a given declaration block with/without the parent style.
    * If the parent style is not specified, the document default computed values
    * is used.
    */
   already_AddRefed<ServoStyleContext>
   ResolveForDeclarations(const ServoStyleContext* aParentOrNull,
                          RawServoDeclarationBlockBorrowed aDeclarations);