Bug 1340322 - Part 11: Introduce ServoCSSAnimationBuilder. r=birtles
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Mon, 06 Mar 2017 09:52:23 +0900
changeset 394957 6f6d0b68ef23d3647f5fa9ad053750f47625b090
parent 394956 a04bbcdfda14751ed34095fd90a5b02e1574f1e1
child 394958 33d72dd744907cd6598a6d41058e1a6783eb36ab
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1340322
milestone54.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 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);