Bug 1340322 - Part 13: Update CSS Animations with servo's computed values. r=birtles
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Mon, 06 Mar 2017 10:09:47 +0900
changeset 394959 5233a7d951daa594edc37f5b5d3a7f4119822922
parent 394958 33d72dd744907cd6598a6d41058e1a6783eb36ab
child 394960 bbdc5fc3db27ecab0a69bb884cd2cb677aa09fe2
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 13: Update CSS Animations with servo's computed values. r=birtles MozReview-Commit-ID: B7uSH7wrx3b
layout/style/ServoStyleSet.cpp
layout/style/nsAnimationManager.cpp
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -163,23 +163,29 @@ ServoStyleSet::GetContext(already_AddRef
 
   // Ignore animations for print or print preview, and for elements
   // that are not attached to the document tree.
   if (mPresContext->IsDynamic() &&
       aElementForAnimation &&
       aElementForAnimation->IsInComposedDoc()) {
     // Update/build CSS animations in the case where animation properties are
     // changed.
-    // FIXME: This isn't right place to update CSS animations. We should do it
-    // , presumably, in cascade_node() in servo side and process the initial
-    // restyle there too.
-    // To do that we need to make updating CSS animations process independent
-    // from nsStyleContext. Also we need to make the process thread safe.
-    mPresContext->AnimationManager()->UpdateAnimations(result,
-                                                       aElementForAnimation);
+    // FIXME: Bug 1341985: This isn't right place to update CSS animations.
+    // We should do it in a SequentialTask and trigger the second traversal for
+    // the animation's restyle after the SequentialTask.
+    const ServoComputedValues* currentStyle =
+      result->StyleSource().AsServoComputedValues();
+    const ServoComputedValues* parentStyle =
+      result->GetParent()
+        ? result->GetParent()->StyleSource().AsServoComputedValues()
+        : nullptr;
+    mPresContext->AnimationManager()->UpdateAnimations(aElementForAnimation,
+                                                       aPseudoTag,
+                                                       currentStyle,
+                                                       parentStyle);
   }
 
   return result.forget();
 }
 
 void
 ServoStyleSet::ResolveMappedAttrDeclarationBlocks()
 {
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -637,38 +637,26 @@ BuildAnimation(nsPresContext* aPresConte
 }
 
 bool
 GeckoCSSAnimationBuilder::BuildKeyframes(nsPresContext* aPresContext,
                                          const StyleAnimation& aSrc,
                                          nsTArray<Keyframe>& aKeyframes)
 {
   MOZ_ASSERT(aPresContext);
+  MOZ_ASSERT(aPresContext->StyleSet()->IsGecko());
 
-  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);
+  nsCSSKeyframesRule* rule =
+    aPresContext->StyleSet()->AsGecko()->KeyframesRuleForName(aSrc.GetName());
+  if (!rule) {
+    return false;
   }
 
+  aKeyframes = BuildAnimationFrames(aPresContext, aSrc, rule);
+
   return true;
 }
 
 nsTArray<Keyframe>
 GeckoCSSAnimationBuilder::BuildAnimationFrames(nsPresContext* aPresContext,
                                                const StyleAnimation& aSrc,
                                                const nsCSSKeyframesRule* aRule)
 {