Bug 1278430 - Update the first keyframe value as well as property value when replacing transition. r?birtles draft
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Wed, 08 Jun 2016 06:25:46 +0900
changeset 376394 f609a5b3e4004e305c77a9dee22525367da6798c
parent 376275 ec20b463c04f57a4bfca1edb987fcb9e9707c364
child 523142 12dc427ab39c1fd1f1b5725f98daec76b0c89610
push id20566
push userhiikezoe@mozilla-japan.org
push dateTue, 07 Jun 2016 21:26:20 +0000
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>