Bug 1340322 - Part 5: Split off BuildKeyframes() r=birtles
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Mon, 06 Mar 2017 09:48:50 +0900
changeset 394951 4d1293edbdb7f161be04646ac367303b2d03b35a
parent 394950 ab3ba7fa8608999e3c7107e7de0a4c48ca75915b
child 394952 e7a8cd3a2eba6bdbbb054a1f6564c32f4e66054e
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 5: Split off BuildKeyframes() r=birtles ServoCSSAnimationBuilder will also have the same name method. MozReview-Commit-ID: CySTBGuTZn7
layout/style/nsAnimationManager.cpp
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -474,20 +474,23 @@ public:
                       const NonOwningAnimationTarget& aTarget)
     : mStyleContext(aStyleContext)
     , mTarget(aTarget)
   {
     MOZ_ASSERT(aStyleContext);
     MOZ_ASSERT(aTarget.mElement);
   }
 
+  bool BuildKeyframes(nsPresContext* aPresContext,
+                      const StyleAnimation& aSrc,
+                      nsTArray<Keyframe>& aKeyframs);
+private:
   nsTArray<Keyframe> BuildAnimationFrames(nsPresContext* aPresContext,
                                           const StyleAnimation& aSrc,
                                           const nsCSSKeyframesRule* aRule);
-private:
   Maybe<ComputedTimingFunction> GetKeyframeTimingFunction(
     nsPresContext* aPresContext,
     nsCSSKeyframeRule* aKeyframeRule,
     const Maybe<ComputedTimingFunction>& aInheritedTimingFunction);
   nsTArray<PropertyValuePair> GetKeyframePropertyValues(
     nsPresContext* aPresContext,
     nsCSSKeyframeRule* aKeyframeRule,
     nsCSSPropertyIDSet& aAnimatedProperties);
@@ -523,36 +526,18 @@ BuildAnimation(nsPresContext* aPresConte
                const NonOwningAnimationTarget& aTarget,
                const StyleAnimation& aSrc,
                CSSAnimationBuilder& aBuilder,
                nsAnimationManager::CSSAnimationCollection* aCollection)
 {
   MOZ_ASSERT(aPresContext);
 
   nsTArray<Keyframe> keyframes;
-  if (aPresContext->StyleSet()->IsServo()) {
-    ServoStyleSet* styleSet = aPresContext->StyleSet()->AsServo();
-    MOZ_ASSERT(styleSet);
-    const ServoComputedValues* computedValues =
-      aStyleContext->StyleSource().AsServoComputedValues();
-    const nsTimingFunction& timingFunction = aSrc.GetTimingFunction();
-    if (!styleSet->FillKeyframesForName(aSrc.GetName(),
-                                        timingFunction,
-                                        computedValues,
-                                        keyframes)) {
-      return nullptr;
-    }
-  } else {
-    nsCSSKeyframesRule* rule =
-      aPresContext->StyleSet()->AsGecko()->KeyframesRuleForName(aSrc.GetName());
-    if (!rule) {
-      return nullptr;
-    }
-
-    keyframes = aBuilder.BuildAnimationFrames(aPresContext, aSrc, rule);
+  if (!aBuilder.BuildKeyframes(aPresContext, aSrc, keyframes)) {
+    return nullptr;
   }
 
   TimingParams timing = TimingParamsFromCSSParams(aSrc.GetDuration(),
                                                   aSrc.GetDelay(),
                                                   aSrc.GetIterationCount(),
                                                   aSrc.GetDirection(),
                                                   aSrc.GetFillMode());
 
@@ -604,16 +589,47 @@ BuildAnimation(nsPresContext* aPresConte
     animation->PauseFromStyle();
   } else {
     animation->PlayFromStyle();
   }
 
   return animation.forget();
 }
 
+bool
+CSSAnimationBuilder::BuildKeyframes(nsPresContext* aPresContext,
+                                    const StyleAnimation& aSrc,
+                                    nsTArray<Keyframe>& aKeyframes)
+{
+  MOZ_ASSERT(aPresContext);
+
+  if (aPresContext->StyleSet()->IsServo()) {
+    ServoStyleSet* styleSet = aPresContext->StyleSet()->AsServo();
+    MOZ_ASSERT(styleSet);
+    const ServoComputedValues* computedValues =
+      mStyleContext->StyleSource().AsServoComputedValues();
+    const nsTimingFunction& timingFunction = aSrc.GetTimingFunction();
+    if (!styleSet->FillKeyframesForName(aSrc.GetName(),
+                                        timingFunction,
+                                        computedValues,
+                                        aKeyframes)) {
+      return false;
+    }
+  } else {
+    nsCSSKeyframesRule* rule =
+      aPresContext->StyleSet()->AsGecko()->KeyframesRuleForName(aSrc.GetName());
+    if (!rule) {
+      return false;
+    }
+    aKeyframes = BuildAnimationFrames(aPresContext, aSrc, rule);
+  }
+
+  return true;
+}
+
 nsTArray<Keyframe>
 CSSAnimationBuilder::BuildAnimationFrames(nsPresContext* aPresContext,
                                           const StyleAnimation& aSrc,
                                           const nsCSSKeyframesRule* aRule)
 {
   // Ideally we'd like to build up a set of Keyframe objects that more-or-less
   // reflect the keyframes as-specified in the @keyframes rule(s) so that
   // authors get something intuitive when they call anim.effect.getKeyframes().