Bug 1436659 - Use updatePlaybackRate in DevTools; r?daisuke
updatePlaybackRate provides a smoother update than setting playbackRate
directly.
MozReview-Commit-ID: 7AbJYuDADvg
--- 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))
+ );
}
});