Bug 1494847 - Part 2: Set proper currentTime for negative playback rate. r=pbro
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Fri, 12 Oct 2018 06:36:37 +0000
changeset 499427 3d151cbf0921c253e980f94a68535c199babb042
parent 499426 bc60f6bb6d22db3d7d6d3f1849e43cfec4544981
child 499428 4cb3f0e44e9ff613ab7c79518a64428ac91b1a0c
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspbro
bugs1494847
milestone64.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 1494847 - Part 2: Set proper currentTime for negative playback rate. r=pbro Depends on D7685 Differential Revision: https://phabricator.services.mozilla.com/D7686
devtools/server/actors/animation.js
devtools/shared/fronts/animation.js
--- a/devtools/server/actors/animation.js
+++ b/devtools/server/actors/animation.js
@@ -764,17 +764,19 @@ exports.AnimationsActor = protocol.Actor
   setCurrentTimes: function(players, time, shouldPause) {
     for (const actor of players) {
       const player = actor.player;
 
       if (shouldPause) {
         player.startTime = null;
       }
 
-      player.currentTime = (time - actor.createdTime) * player.playbackRate;
+      const currentTime =
+        player.playbackRate > 0 ? time - actor.createdTime : actor.createdTime - time;
+      player.currentTime = currentTime * Math.abs(player.playbackRate);
     }
 
     return this.waitForNextFrame(players);
   },
 
   /**
    * Set the playback rate of several animations at the same time.
    * @param {Array} actors A list of AnimationPlayerActor.
--- a/devtools/shared/fronts/animation.js
+++ b/devtools/shared/fronts/animation.js
@@ -172,17 +172,19 @@ const AnimationPlayerFront = FrontClassW
                 toRate(duration * (iterationCount || 1)) +
                 absoluteEndDelay;
     }
 
     const absoluteCreatedTime =
       isPositivePlaybackRate ? createdTime : createdTime - endTime;
     const absoluteCurrentTimeAtCreated =
       isPositivePlaybackRate ? currentTimeAtCreated : endTime - currentTimeAtCreated;
-    const absoluteCurrentTime = absoluteCreatedTime + toRate(currentTime);
+    const animationCurrentTime =
+      isPositivePlaybackRate ? currentTime : endTime - currentTime;
+    const absoluteCurrentTime = absoluteCreatedTime + toRate(animationCurrentTime);
     const absoluteStartTime = absoluteCreatedTime + Math.min(absoluteDelay, 0);
     const absoluteStartTimeAtCreated = absoluteCreatedTime + absoluteCurrentTimeAtCreated;
     // To show whole graph with endDelay, we add negative endDelay amount to endTime.
     const endTimeWithNegativeEndDelay = endTime - Math.min(absoluteEndDelay, 0);
     const absoluteEndTime = absoluteCreatedTime + endTimeWithNegativeEndDelay;
 
     return {
       createdTime: absoluteCreatedTime,