Bug 1333539 - Part 2: Send animations with null-timeline to the compositor if necessary. r=birtles
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Thu, 02 Feb 2017 15:11:29 +0900
changeset 469864 a8f1dbc491d8bf47d6d38ea396e0d63da8b71410
parent 469863 205c3c6c123fe277268770e3bdf082f89ec47ec5
child 469865 3e459ccf6e096fba29cf8124bb609347ebaeb6e0
push id43881
push userbmo:gps@mozilla.com
push dateThu, 02 Feb 2017 23:49:03 +0000
reviewersbirtles
bugs1333539
milestone54.0a1
Bug 1333539 - Part 2: Send animations with null-timeline to the compositor if necessary. r=birtles MozReview-Commit-ID: KJf7B8AuAzo
dom/animation/test/style/file_missing-keyframe-on-compositor.html
layout/painting/nsDisplayList.cpp
--- a/dom/animation/test/style/file_missing-keyframe-on-compositor.html
+++ b/dom/animation/test/style/file_missing-keyframe-on-compositor.html
@@ -505,11 +505,38 @@ promise_test(t => {
       SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'transform');
     assert_matrix_equals(transform, 'matrix(1, 0, 0, 1, 300, 0)',
       'Transform value for animation with no keyframe at offset 1 and its ' +
       'iterationComposite is accumulate');
   });
 }, 'Transform value for animation with no keyframe at offset 1 and its ' +
    'iterationComposite is accumulate');
 
+promise_test(t => {
+  useTestRefreshMode(t);
+
+  var div = addDiv(t);
+  var lowerAnimation =
+    div.animate({ transform: [ 'translateX(100px)', 'translateX(200px)' ] },
+                100 * MS_PER_SEC);
+  var higherAnimation = div.animate({ transform: 'translateX(300px)' },
+                                    100 * MS_PER_SEC);
+
+  lowerAnimation.timeline = null;
+  // Set current time at 50% duration.
+  lowerAnimation.currentTime = 50 * MS_PER_SEC;
+
+  return waitForPaintsFlushed().then(() => {
+    SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(50 * MS_PER_SEC);
+
+    var transform =
+      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'transform');
+    // (150px + 300px) * (50 * MS_PER_SEC / 100 * MS_PER_SEC) = 225px.
+    assert_matrix_equals(transform, 'matrix(1, 0, 0, 1, 225, 0)',
+      'Composed transform value should be composed onto the value of ' +
+      'lower-priority animation without timeline');
+  });
+}, 'Transform value for animation with no keyframe at offset 0 at 50% when ' +
+   'composed onto an animation without timeline');
+
 done();
 </script>
 </body>
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -622,17 +622,17 @@ AddAnimationsForProperty(nsIFrame* aFram
     // If we can't convert that wallclock time back to an equivalent timeline
     // time, we won't be able to update the content animation and it will end
     // up being out of sync with the layer animation.
     //
     // Currently this only happens when the timeline is driven by a refresh
     // driver under test control. In this case, the next time the refresh
     // driver is advanced it will trigger any pending animations.
     if (anim->PlayState() == AnimationPlayState::Pending &&
-        (!anim->GetTimeline() ||
+        (anim->GetTimeline() &&
          !anim->GetTimeline()->TracksWallclockTime())) {
       continue;
     }
 
     AddAnimationForProperty(aFrame, *property, anim, aLayer, aData, aPending);
     keyframeEffect->SetIsRunningOnCompositor(aProperty, true);
   }
 }