Bug 1465077 - Part 1: Introduce doSetCurrentTimes so as to not forget the createdTime. r?pbro
MozReview-Commit-ID: G76mJIYZ4Mm
--- a/devtools/client/inspector/animation/animation.js
+++ b/devtools/client/inspector/animation/animation.js
@@ -181,16 +181,33 @@ class AnimationInspector {
return this.inspector.store.getState().animations;
}
addAnimationsCurrentTimeListener(listener) {
this.animationsCurrentTimeListeners.push(listener);
}
/**
+ * This function calls AnimationsFront.setCurrentTimes with considering the createdTime
+ * which was introduced bug 1454392.
+ *
+ * @param {Number} currentTime
+ */
+ async doSetCurrentTimes(currentTime) {
+ const { animations, timeScale } = this.state;
+
+ // If currentTime is not defined in timeScale (which happens when connected
+ // to server older than FF62), set currentTime as it is. See bug 1454392.
+ currentTime = typeof timeScale.currentTime === "undefined"
+ ? currentTime : currentTime + timeScale.minStartTime;
+ await this.animationsFront.setCurrentTimes(animations, currentTime, true,
+ { relativeToCreatedTime: true });
+ }
+
+ /**
* Return a map of animated property from given animation actor.
*
* @param {Object} animation
* @return {Map} A map of animated property
* key: {String} Animated property name
* value: {Array} Array of keyframe object
* Also, the keyframe object is consisted as following.
* {
@@ -381,27 +398,21 @@ class AnimationInspector {
async setAnimationsCurrentTime(currentTime, shouldRefresh) {
this.stopAnimationsCurrentTimeTimer();
this.onAnimationsCurrentTimeUpdated(currentTime);
if (!shouldRefresh && this.isCurrentTimeSet) {
return;
}
- const { animations, timeScale } = this.state;
+ const { animations } = this.state;
this.isCurrentTimeSet = true;
- // If currentTime is not defined in timeScale (which happens when connected
- // to server older than FF62), set currentTime as it is. See bug 1454392.
- currentTime =
- typeof timeScale.currentTime === "undefined"
- ? currentTime : currentTime + timeScale.minStartTime;
try {
- await this.animationsFront.setCurrentTimes(animations, currentTime, true,
- { relativeToCreatedTime: true });
+ await this.doSetCurrentTimes(currentTime);
await this.updateAnimations(animations);
} catch (e) {
// Expected if we've already been destroyed or other node have been selected
// in the meantime.
console.error(e);
return;
}
@@ -440,18 +451,17 @@ class AnimationInspector {
await this.inspector.target.actorHasMethod("animations", "pauseSome");
}
const { animations, timeScale } = this.state;
try {
if (doPlay && animations.every(animation =>
timeScale.getEndTime(animation) <= animation.state.currentTime)) {
- await this.animationsFront.setCurrentTimes(animations, 0, true,
- { relativeToCreatedTime: true });
+ await this.doSetCurrentTimes(0);
}
// If the server does not support pauseSome/playSome function, (which happens
// when connected to server older than FF62), use pauseAll/playAll instead.
// See bug 1456857.
if (this.hasPausePlaySome) {
if (doPlay) {
await this.animationsFront.playSome(animations);