Bug 1278430 - Update the first keyframe value as well as property value when replacing transition. r=birtles
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Wed, 08 Jun 2016 06:25:46 +0900
changeset 300970 f58943bca186445327240d9f7b5cd584f3a7ab56
parent 300969 234044e5e8045ccc1c0e4be8ac7c55ceb33de38c
child 300971 376b59c84c6f652ac061a66a2c20899eb2476b3c
push id19599
push usercbook@mozilla.com
push dateWed, 08 Jun 2016 10:16:21 +0000
treeherderfx-team@81f4cc3f6f4c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1278430
milestone50.0a1
Bug 1278430 - Update the first keyframe value as well as property value when replacing transition. r=birtles MozReview-Commit-ID: teNZdJdKoy
layout/style/nsTransitionManager.cpp
layout/style/test/file_transitions_replacement_on_busy_frame.html
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -100,16 +100,28 @@ ElementPropertyTransition::UpdateStartVa
     if (StyleAnimationValue::Interpolate(mProperties[0].mProperty,
                                          mReplacedTransition->mFromValue,
                                          mReplacedTransition->mToValue,
                                          valuePosition, startValue)) {
       MOZ_ASSERT(mProperties.Length() == 1 &&
                  mProperties[0].mSegments.Length() == 1,
                  "The transition should have one property and one segment");
       mProperties[0].mSegments[0].mFromValue = Move(startValue);
+      nsCSSValue cssValue;
+      DebugOnly<bool> uncomputeResult =
+        StyleAnimationValue::UncomputeValue(mProperties[0].mProperty,
+                                            startValue,
+                                            cssValue);
+      MOZ_ASSERT(uncomputeResult, "UncomputeValue should not fail");
+      MOZ_ASSERT(mKeyframes.Length() == 2,
+          "Transitions should have exactly two animation keyframes");
+      MOZ_ASSERT(mKeyframes[0].mPropertyValues.Length() == 1,
+          "Transitions should have exactly one property in their first "
+          "frame");
+      mKeyframes[0].mPropertyValues[0].mValue = cssValue;
     }
   }
 
   mReplacedTransition.reset();
 }
 
 ////////////////////////// CSSTransition ////////////////////////////
 
--- a/layout/style/test/file_transitions_replacement_on_busy_frame.html
+++ b/layout/style/test/file_transitions_replacement_on_busy_frame.html
@@ -42,46 +42,51 @@ window.addEventListener("load", function
 
   var div = document.getElementById("target");
   // Start first transition
   div.style.transform = "translateX(300px)";
   getComputedStyle(div);
 
   // Wait for a paint to ensure that the first transition has started.
   waitForAllPaints(function() {
-    var previousMatrix;
+    var previousPropertyValue;
+    var previousKeyframeValue;
     var anim;
     requestAnimationFrame(function() {
       // Start second transition
       div.style.transform = "translateX(0px)";
       getComputedStyle(div).transform;
 
       anim = div.getAnimations()[0];
       var properties = SpecialPowers.wrap(anim.effect).getProperties();
-      previousMatrix = properties[0].values[0].value;
+      previousPropertyValue = properties[0].values[0].value;
+      previousKeyframeValue = anim.effect.getKeyframes()[0].transform;
     });
 
     requestAnimationFrame(function() {
       // Tie up main thread for 300ms. In the meantime, the first transition
       // will continue running on the compositor. If we don't update the start
       // point of the second transition, it will appear to jump when it starts.
       var startTime = performance.now();
       while (performance.now() - startTime < 300);
 
       // Ensure that our paint process has been done.
       // Note that requestAnimationFrame is not suitable here since on Android
       // there is a case where the paint process has not completed even when the
       // requestAnimationFrame callback is run (and it is during the paint
       // process that we update the transition start point).
       waitForAllPaints(function() {
         var properties = SpecialPowers.wrap(anim.effect).getProperties();
-        var currentMatrix = properties[0].values[0].value;
-        isnot(currentMatrix, previousMatrix,
+        var currentPropertyValue = properties[0].values[0].value;
+        isnot(currentPropertyValue, previousPropertyValue,
               "From value of transition is updated since the moment when " +
               "it was generated");
+        isnot(anim.effect.getKeyframes()[0].transform, previousKeyframeValue,
+              "Keyframe value of transition is updated since the moment when " +
+              "it was generated");
         finish();
       });
     });
   });
 });
 
 </script>
 </body>