Bug 1436659 - Use updatePlaybackRate in DevTools; r=daisuke
authorBrian Birtles <birtles@gmail.com>
Tue, 13 Feb 2018 15:04:18 +0900
changeset 403908 1082bb7dbc526b11b32794bbc5d0f0501dcf3477
parent 403907 0b4efe60e6ec6bdc23d44f86f65a4bd0ace7d9e8
child 403909 780f43334807c1a094b67a8074d7382338e6c8f7
push id99885
push userapavel@mozilla.com
push dateThu, 15 Feb 2018 10:38:09 +0000
treeherdermozilla-inbound@99495614cba7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdaisuke
bugs1436659
milestone60.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 1436659 - Use updatePlaybackRate in DevTools; r=daisuke updatePlaybackRate provides a smoother update than setting playbackRate directly. MozReview-Commit-ID: 7AbJYuDADvg
devtools/server/actors/animation.js
--- a/devtools/server/actors/animation.js
+++ b/devtools/server/actors/animation.js
@@ -385,24 +385,26 @@ var AnimationPlayerActor = protocol.Acto
         // Reset the local copy of the state on removal, since the animation can
         // be kept on the client and re-added, its state needs to be sent in
         // full.
         this.currentState = null;
       }
 
       if (hasCurrentAnimation(changedAnimations)) {
         // Only consider the state has having changed if any of delay, duration,
-        // iterationcount or iterationStart has changed (for now at least).
+        // iterationCount, iterationStart, or playbackRate has changed (for now
+        // at least).
         let newState = this.getState();
         let oldState = this.currentState;
         hasChanged = newState.delay !== oldState.delay ||
                      newState.iterationCount !== oldState.iterationCount ||
                      newState.iterationStart !== oldState.iterationStart ||
                      newState.duration !== oldState.duration ||
-                     newState.endDelay !== oldState.endDelay;
+                     newState.endDelay !== oldState.endDelay ||
+                     newState.playbackRate !== oldState.playbackRate;
         break;
       }
     }
 
     if (hasChanged) {
       this.emit("changed", this.getCurrentState());
     }
   },
@@ -459,17 +461,18 @@ var AnimationPlayerActor = protocol.Acto
     }
     this.player.currentTime = currentTime * this.player.playbackRate;
   },
 
   /**
    * Set the playback rate of the animation player.
    */
   setPlaybackRate: function (playbackRate) {
-    this.player.playbackRate = playbackRate;
+    this.player.updatePlaybackRate(playbackRate);
+    return this.player.ready;
   },
 
   /**
    * Get data about the keyframes of this animation player.
    * @return {Object} Returns a list of frames, each frame containing the list
    * animated properties as well as the frame's offset.
    */
   getFrames: function () {
@@ -865,13 +868,13 @@ exports.AnimationsActor = protocol.Actor
   },
 
   /**
    * Set the playback rate of several animations at the same time.
    * @param {Array} players A list of AnimationPlayerActor.
    * @param {Number} rate The new rate.
    */
   setPlaybackRates: function (players, rate) {
-    for (let player of players) {
-      player.setPlaybackRate(rate);
-    }
+    return Promise.all(
+      players.map(player => player.setPlaybackRate(rate))
+    );
   }
 });