Bug 1340322 - Part 11: Introduce ServoCSSAnimationBuilder. r=birtles
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Mon, 06 Mar 2017 09:52:23 +0900
changeset 375007 6f6d0b68ef23d3647f5fa9ad053750f47625b090
parent 375006 a04bbcdfda14751ed34095fd90a5b02e1574f1e1
child 375008 33d72dd744907cd6598a6d41058e1a6783eb36ab
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1340322
milestone54.0a1
Bug 1340322 - Part 11: Introduce ServoCSSAnimationBuilder. r=birtles MozReview-Commit-ID: 6qWPPXexitN
layout/style/nsAnimationManager.cpp
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -413,16 +413,51 @@ ResolvedStyleCache::Get(nsPresContext *a
     RefPtr<nsStyleContext> resultStrong = aPresContext->StyleSet()->AsGecko()->
       ResolveStyleByAddingRules(aParentStyleContext, rules);
     mCache.Put(aKeyframeDeclaration, resultStrong);
     result = resultStrong;
   }
   return result;
 }
 
+class MOZ_STACK_CLASS ServoCSSAnimationBuilder final {
+public:
+  ServoCSSAnimationBuilder(
+    const ServoComputedValues* aComputedValues,
+    const ServoComputedValues* aParentComputedValues)
+    : mComputedValues(aComputedValues)
+    , mParentComputedValues(aParentComputedValues)
+  {
+    MOZ_ASSERT(aComputedValues);
+  }
+
+  bool BuildKeyframes(nsPresContext* aPresContext,
+                      const StyleAnimation& aSrc,
+                      nsTArray<Keyframe>& aKeyframes)
+  {
+    ServoStyleSet* styleSet = aPresContext->StyleSet()->AsServo();
+    MOZ_ASSERT(styleSet);
+    const nsTimingFunction& timingFunction = aSrc.GetTimingFunction();
+    return styleSet->FillKeyframesForName(aSrc.GetName(),
+                                          timingFunction,
+                                          mComputedValues,
+                                          aKeyframes);
+  }
+  void SetKeyframes(KeyframeEffectReadOnly& aEffect,
+                    nsTArray<Keyframe>&& aKeyframes)
+  {
+    aEffect.SetKeyframes(Move(aKeyframes),
+                         { mComputedValues, mParentComputedValues });
+  }
+
+private:
+  const ServoComputedValues* mComputedValues;
+  const ServoComputedValues* mParentComputedValues;
+};
+
 class MOZ_STACK_CLASS GeckoCSSAnimationBuilder final {
 public:
   GeckoCSSAnimationBuilder(nsStyleContext* aStyleContext,
                            const NonOwningAnimationTarget& aTarget)
     : mStyleContext(aStyleContext)
     , mTarget(aTarget)
   {
     MOZ_ASSERT(aStyleContext);