Bug 1463372 - Part 1: Introduce createdTime to keyframes progress bar. r?pbro draft
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Fri, 25 May 2018 17:01:20 +0900
changeset 799724 5b1817d545c8061a9ee245f4ee532ca843940dd5
parent 799721 ab027d359f54391d99512b5be023033f400dbc8a
child 799725 2fda41661cdecc201c24dc86f8c774b6de63dc95
child 799728 ad7f48eda2fb46cf472ad68ce5b8dbf6731717df
push id111151
push userbmo:dakatsuka@mozilla.com
push dateFri, 25 May 2018 08:31:54 +0000
reviewerspbro
bugs1463372
milestone62.0a1
Bug 1463372 - Part 1: Introduce createdTime to keyframes progress bar. r?pbro MozReview-Commit-ID: Biy0AhZZxLQ
devtools/client/inspector/animation/components/KeyframesProgressBar.js
--- a/devtools/client/inspector/animation/components/KeyframesProgressBar.js
+++ b/devtools/client/inspector/animation/components/KeyframesProgressBar.js
@@ -57,22 +57,27 @@ class KeyframesProgressBar extends PureC
 
   onCurrentTimeUpdated(currentTime) {
     const { animation, timeScale } = this.props;
     this.updateOffset(currentTime, animation, timeScale);
   }
 
   updateOffset(currentTime, animation, timeScale) {
     const {
+      createdTime,
       playbackRate,
-      previousStartTime = 0,
     } = animation.state;
 
-    const time =
-      (timeScale.minStartTime + currentTime - previousStartTime) * playbackRate;
+    // If createdTime is not defined (which happens when connected to server older
+    // than FF62), use previousStartTime instead. See bug 1454392
+    const baseTime = typeof createdTime === "undefined"
+                       ? (animation.state.previousStartTime || 0)
+                       : createdTime;
+    const time = (timeScale.minStartTime + currentTime - baseTime) * playbackRate;
+
     if (isNaN(time)) {
       // Setting an invalid currentTime will throw so bail out if time is not a number for
       // any reason.
       return;
     }
 
     this.simulatedAnimation.currentTime = time;
     const offset = this.element.offsetWidth *