Bug 1328787 - Part 12: Fill Gecko's Keyframe. r=heycam
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Sun, 29 Jan 2017 12:58:51 +0900
changeset 331593 224a64d933243586e45bcd4a6f88a43174128e92
parent 331592 2162612b5857ea591eebadca18a13d6006b0cdbe
child 331594 2fe14ee4e5a868c5ce44d26f0bc5445532156e7f
push id31275
push userphilringnalda@gmail.com
push dateSun, 29 Jan 2017 17:02:37 +0000
treeherdermozilla-central@77af15f468e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1328787
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 1328787 - Part 12: Fill Gecko's Keyframe. r=heycam MozReview-Commit-ID: 5QdUtFj9lK9
layout/style/nsAnimationManager.cpp
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -5,16 +5,17 @@
 
 #include "nsAnimationManager.h"
 #include "nsTransitionManager.h"
 #include "mozilla/dom/CSSAnimationBinding.h"
 
 #include "mozilla/EffectCompositor.h"
 #include "mozilla/EffectSet.h"
 #include "mozilla/MemoryReporting.h"
+#include "mozilla/ServoStyleSet.h"
 #include "mozilla/StyleAnimationValue.h"
 #include "mozilla/dom/DocumentTimeline.h"
 #include "mozilla/dom/KeyframeEffectReadOnly.h"
 
 #include "nsPresContext.h"
 #include "nsStyleSet.h"
 #include "nsStyleChangeList.h"
 #include "nsCSSRules.h"
@@ -596,27 +597,41 @@ static Maybe<ComputedTimingFunction>
 ConvertTimingFunction(const nsTimingFunction& aTimingFunction);
 
 already_AddRefed<CSSAnimation>
 CSSAnimationBuilder::Build(nsPresContext* aPresContext,
                            const StyleAnimation& aSrc)
 {
   MOZ_ASSERT(aPresContext);
 
-  nsCSSKeyframesRule* rule =
-    aPresContext->StyleSet()->AsGecko()->KeyframesRuleForName(aSrc.GetName());
-  if (!rule) {
-    return nullptr;
+  nsTArray<Keyframe> keyframes;
+  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,
+                                        keyframes)) {
+      return nullptr;
+    }
+  } else {
+    nsCSSKeyframesRule* rule =
+      aPresContext->StyleSet()->AsGecko()->KeyframesRuleForName(aSrc.GetName());
+    if (!rule) {
+      return nullptr;
+    }
+
+    keyframes = BuildAnimationFrames(aPresContext, aSrc, rule);
   }
 
   TimingParams timing = TimingParamsFrom(aSrc);
 
-  nsTArray<Keyframe> keyframes =
-    BuildAnimationFrames(aPresContext, aSrc, rule);
-
   bool isStylePaused =
     aSrc.GetPlayState() == NS_STYLE_ANIMATION_PLAY_STATE_PAUSED;
 
   // Find the matching animation with animation name in the old list
   // of animations and remove the matched animation from the list.
   RefPtr<CSSAnimation> oldAnim =
     PopExistingAnimation(aSrc.GetName(), mCollection);
 
@@ -1084,20 +1099,16 @@ nsAnimationManager::BuildAnimations(nsSt
     // not generate animation events. This includes when the animation-name is
     // "none" which is represented by an empty name in the StyleAnimation.
     // Since such animations neither affect style nor dispatch events, we do
     // not generate a corresponding CSSAnimation for them.
     if (src.GetName().IsEmpty()) {
       continue;
     }
 
-    MOZ_ASSERT(mPresContext->StyleSet()->IsGecko(),
-               "ServoStyleSet should not use nsAnimationManager for "
-               "animations");
-
     RefPtr<CSSAnimation> dest =
       builder.Build(mPresContext, src);
     if (!dest) {
       continue;
     }
 
     dest->SetAnimationIndex(static_cast<uint64_t>(animIdx));
     aAnimations.AppendElement(dest);