Bug 1468364 - Part 1. Calculate the created time of animation every creating the AnimationPlayerActor. r=daisuke a=lizzard
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Mon, 02 Jul 2018 14:52:47 +0900
changeset 477840 c599d36fb1a357867f0b66886cddb9e5aecaf76e
parent 477839 13622431fb712c21c582fe78b6f1154146b0d7a8
child 477841 e00ac12fb0dad0c257ae278f1feb0c1386c0279d
push id9444
push userarchaeopteryx@coole-files.de
push dateSat, 07 Jul 2018 21:01:06 +0000
treeherdermozilla-beta@3c8ab5a011e3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdaisuke, lizzard
bugs1468364
milestone62.0
Bug 1468364 - Part 1. Calculate the created time of animation every creating the AnimationPlayerActor. r=daisuke a=lizzard This patch will drop animationCreatedTimeMap in order to calculate created time every creating the AnimationPlayerActor, as result of it, we can adjust the current time even if AnimationsActor has the different current times of animation. MozReview-Commit-ID: DZ7m5wZcJF7
devtools/server/actors/animation.js
--- a/devtools/server/actors/animation.js
+++ b/devtools/server/actors/animation.js
@@ -613,30 +613,25 @@ exports.AnimationsActor = protocol.Actor
 
     this.onWillNavigate = this.onWillNavigate.bind(this);
     this.onNavigate = this.onNavigate.bind(this);
     this.onAnimationMutation = this.onAnimationMutation.bind(this);
 
     this.allAnimationsPaused = false;
     this.targetActor.on("will-navigate", this.onWillNavigate);
     this.targetActor.on("navigate", this.onNavigate);
-
-    this.animationCreatedTimeMap = new Map();
   },
 
   destroy: function() {
     Actor.prototype.destroy.call(this);
     this.targetActor.off("will-navigate", this.onWillNavigate);
     this.targetActor.off("navigate", this.onNavigate);
 
     this.stopAnimationPlayerUpdates();
     this.targetActor = this.observer = this.actors = this.walker = null;
-
-    this.animationCreatedTimeMap.clear();
-    this.animationCreatedTimeMap = null;
   },
 
   /**
    * Clients can optionally call this with a reference to their WalkerActor.
    * If they do, then AnimationPlayerActor's forms are going to also include
    * NodeActor IDs when the corresponding NodeActors do exist.
    * This, in turns, is helpful for clients to avoid having to go back once more
    * to the server to get a NodeActor for a particular animation.
@@ -652,18 +647,16 @@ exports.AnimationsActor = protocol.Actor
    * Note that calling this method a second time will destroy all previously
    * retrieved AnimationPlayerActors. Indeed, the lifecycle of these actors
    * is managed here on the server and tied to getAnimationPlayersForNode
    * being called.
    * @param {NodeActor} nodeActor The NodeActor as defined in
    * /devtools/server/actors/inspector
    */
   getAnimationPlayersForNode: function(nodeActor) {
-    this.updateAllAnimationsCreatedTime();
-
     const animations = nodeActor.rawNode.getAnimations({subtree: true});
 
     // Destroy previously stored actors
     if (this.actors) {
       for (const actor of this.actors) {
         actor.destroy();
       }
     }
@@ -742,17 +735,16 @@ exports.AnimationsActor = protocol.Actor
         if (index !== -1) {
           eventData.push({
             type: "removed",
             player: this.actors[index]
           });
           this.actors.splice(index, 1);
         }
 
-        this.updateAnimationCreatedTime(player);
         const createdTime = this.getCreatedTime(player);
         const actor = AnimationPlayerActor(this, player, createdTime);
         this.actors.push(actor);
         eventData.push({
           type: "added",
           player: actor
         });
         readyPromises.push(player.ready);
@@ -960,49 +952,18 @@ exports.AnimationsActor = protocol.Actor
   },
 
   /**
    * Return created fime of given animaiton.
    *
    * @param {Object} animation
    */
   getCreatedTime(animation) {
-    return this.animationCreatedTimeMap.get(animation);
-  },
-
-  /**
-   * Update all animation created time map.
-   */
-  updateAllAnimationsCreatedTime() {
-    const currentAnimations = this.getAllAnimations(this.targetActor.window.document);
-
-    // Remove invalid animations.
-    for (const previousAnimation of this.animationCreatedTimeMap.keys()) {
-      if (!currentAnimations.includes(previousAnimation)) {
-        this.animationCreatedTimeMap.delete(previousAnimation);
-      }
-    }
-
-    for (const animation of currentAnimations) {
-      this.updateAnimationCreatedTime(animation);
-    }
-  },
-
-  /**
-   * Update animation created time map.
-   *
-   * @param {Object} animation
-   */
-  updateAnimationCreatedTime(animation) {
-    if (!this.animationCreatedTimeMap.has(animation)) {
-      const createdTime =
-        animation.startTime ||
-        animation.timeline.currentTime - animation.currentTime / animation.playbackRate;
-      this.animationCreatedTimeMap.set(animation, createdTime);
-    }
+    return animation.startTime ||
+          animation.timeline.currentTime - animation.currentTime / animation.playbackRate;
   },
 
   /**
    * Wait for next animation frame.
    *
    * @param {Array} actors
    * @return {Promise} which waits for next frame
    */