Bug 1328787 - Part 12: Fill Gecko's Keyframe. r?heycam draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Fri, 27 Jan 2017 10:27:02 +0900
changeset 467027 a207162fe9601c5ddb56bd2aa6afd13ac465fdd5
parent 467026 c2be81b19ec461eb66706406b980915b6f635cf6
child 467028 a8e6691d0731c8aa951d0a993bdb1b96b3380fb7
child 467029 fe41e2923147be18ad591183552c7947763b8e2d
push id43089
push userhikezoe@mozilla.com
push dateFri, 27 Jan 2017 01:33:18 +0000
reviewersheycam
bugs1328787
milestone54.0a1
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"
@@ -603,27 +604,41 @@ ConvertTimingFunction(const nsTimingFunc
 
 already_AddRefed<CSSAnimation>
 CSSAnimationBuilder::Build(nsPresContext* aPresContext,
                            const StyleAnimation& aSrc,
                            uint64_t aAnimationIndex)
 {
   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);
 
@@ -1092,20 +1107,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, static_cast<uint64_t>(animIdx));
     if (!dest) {
       continue;
     }
 
     dest->SetAnimationIndex(static_cast<uint64_t>(animIdx));
     aAnimations.AppendElement(dest);