Bug 1382576 - Switch over from the old-event-emitter to event-emitter in the animation inspector; r=jdescottes draft
authorPatrick Brosset <pbrosset@mozilla.com>
Wed, 06 Sep 2017 16:51:50 +0200
changeset 660008 eb2facf35130f8b3805fafdb16087cf807471ae7
parent 659873 c959327c6b75cd4930a6ea087583c38b805e7524
child 730123 a1ade724a470da3409c2bc5d3dc4fade2de554e5
push id78276
push userbmo:pbrosset@mozilla.com
push dateWed, 06 Sep 2017 14:52:19 +0000
reviewersjdescottes
bugs1382576
milestone57.0a1
Bug 1382576 - Switch over from the old-event-emitter to event-emitter in the animation inspector; r=jdescottes MozReview-Commit-ID: ftItsTkomw
devtools/client/animationinspector/animation-controller.js
devtools/client/animationinspector/animation-panel.js
devtools/client/animationinspector/components/animation-details.js
devtools/client/animationinspector/components/animation-target-node.js
devtools/client/animationinspector/components/animation-time-block.js
devtools/client/animationinspector/components/animation-timeline.js
devtools/client/animationinspector/components/keyframes.js
devtools/client/animationinspector/components/rate-selector.js
devtools/client/animationinspector/utils.js
--- a/devtools/client/animationinspector/animation-controller.js
+++ b/devtools/client/animationinspector/animation-controller.js
@@ -13,17 +13,17 @@
 "use strict";
 
 var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
 
 var { loader, require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
 var { Task } = require("devtools/shared/task");
 
 loader.lazyRequireGetter(this, "promise");
-loader.lazyRequireGetter(this, "EventEmitter", "devtools/shared/old-event-emitter");
+loader.lazyRequireGetter(this, "EventEmitter", "devtools/shared/event-emitter");
 loader.lazyRequireGetter(this, "AnimationsFront", "devtools/shared/fronts/animation", true);
 
 const { LocalizationHelper } = require("devtools/shared/l10n");
 const L10N =
       new LocalizationHelper("devtools/client/locales/animationinspector.properties");
 
 // Global toolbox/inspector, set when startup is called.
 var gToolbox, gInspector;
--- a/devtools/client/animationinspector/animation-panel.js
+++ b/devtools/client/animationinspector/animation-panel.js
@@ -255,27 +255,27 @@ var AnimationsPanel = {
       .setCurrentTimeAll(0, true)
       .then(() => this.refreshAnimationsStateAndUI());
   },
 
   /**
    * Set the playback rate of all current animations shown in the timeline to
    * the value of this.rateSelectorEl.
    */
-  onRateChanged: function (e, rate) {
+  onRateChanged: function (rate) {
     AnimationsController.setPlaybackRateAll(rate)
                         .then(() => this.refreshAnimationsStateAndUI())
                         .catch(console.error);
   },
 
   onTabNavigated: function () {
     this.toggleAllButtonEl.classList.remove("paused");
   },
 
-  onTimelineDataChanged: function (e, data) {
+  onTimelineDataChanged: function (data) {
     this.timelineData = data;
     let {isMoving, isUserDrag, time} = data;
 
     this.playTimelineButtonEl.classList.toggle("paused", !isMoving);
 
     let l10nPlayProperty = isMoving ? "timeline.resumedButtonTooltip" :
                                       "timeline.pausedButtonTooltip";
 
--- a/devtools/client/animationinspector/components/animation-details.js
+++ b/devtools/client/animationinspector/components/animation-details.js
@@ -2,17 +2,16 @@
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const {Task} = require("devtools/shared/task");
-const EventEmitter = require("devtools/shared/old-event-emitter");
 const {createNode, getCssPropertyName} =
   require("devtools/client/animationinspector/utils");
 const {Keyframes} = require("devtools/client/animationinspector/components/keyframes");
 
 const { LocalizationHelper } = require("devtools/shared/l10n");
 const L10N =
   new LocalizationHelper("devtools/client/locales/animationinspector.properties");
 
@@ -20,18 +19,16 @@ const L10N =
  * UI component responsible for displaying detailed information for a given
  * animation.
  * This includes information about timing, easing, keyframes, animated
  * properties.
  *
  * @param {Object} serverTraits The list of server-side capabilities.
  */
 function AnimationDetails(serverTraits) {
-  EventEmitter.decorate(this);
-
   this.keyframeComponents = [];
   this.serverTraits = serverTraits;
 }
 
 exports.AnimationDetails = AnimationDetails;
 
 AnimationDetails.prototype = {
   // These are part of frame objects but are not animated properties. This
--- a/devtools/client/animationinspector/components/animation-target-node.js
+++ b/devtools/client/animationinspector/components/animation-target-node.js
@@ -2,17 +2,17 @@
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const {Task} = require("devtools/shared/task");
-const EventEmitter = require("devtools/shared/old-event-emitter");
+const EventEmitter = require("devtools/shared/event-emitter");
 const {DomNodePreview} = require("devtools/client/inspector/shared/dom-node-preview");
 
 // Map dom node fronts by animation fronts so we don't have to get them from the
 // walker every time the timeline is refreshed.
 var nodeFronts = new WeakMap();
 
 /**
  * UI component responsible for displaying a preview of the target dom node of
--- a/devtools/client/animationinspector/components/animation-time-block.js
+++ b/devtools/client/animationinspector/components/animation-time-block.js
@@ -1,17 +1,17 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
-const EventEmitter = require("devtools/shared/old-event-emitter");
+const EventEmitter = require("devtools/shared/event-emitter");
 const {createNode, createSVGNode, TimeScale, getFormattedAnimationTitle} =
   require("devtools/client/animationinspector/utils");
 const {SummaryGraphHelper, getPreferredKeyframesProgressThreshold,
        getPreferredProgressThreshold} =
   require("devtools/client/animationinspector/graph-helper");
 
 const { LocalizationHelper } = require("devtools/shared/l10n");
 const L10N =
--- a/devtools/client/animationinspector/components/animation-timeline.js
+++ b/devtools/client/animationinspector/components/animation-timeline.js
@@ -2,17 +2,17 @@
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const {Task} = require("devtools/shared/task");
-const EventEmitter = require("devtools/shared/old-event-emitter");
+const EventEmitter = require("devtools/shared/event-emitter");
 const {
   createNode,
   findOptimalTimeInterval,
   getFormattedAnimationTitle,
   TimeScale,
   getCssPropertyName
 } = require("devtools/client/animationinspector/utils");
 const {AnimationDetails} = require("devtools/client/animationinspector/components/animation-details");
@@ -309,17 +309,17 @@ AnimationsTimeline.prototype = {
       this.win.clearTimeout(this.windowResizeTimer);
     }
 
     this.windowResizeTimer = this.win.setTimeout(() => {
       this.drawHeaderAndBackground();
     }, TIMELINE_BACKGROUND_RESIZE_DEBOUNCE_TIMER);
   },
 
-  onAnimationSelected: Task.async(function* (e, animation) {
+  onAnimationSelected: Task.async(function* (animation) {
     let index = this.animations.indexOf(animation);
     if (index === -1) {
       return;
     }
 
     // Unselect an animation which was selected.
     const animationEls = this.rootWrapperEl.querySelectorAll(".animation");
     for (let i = 0; i < animationEls.length; i++) {
@@ -348,17 +348,17 @@ AnimationsTimeline.prototype = {
     selectedAnimationEl.classList.add("selected");
     this.animationRootEl.classList.add("animation-detail-visible");
     // Don't render if the detail displays same animation already.
     if (animation !== this.details.animation) {
       this.selectedAnimation = animation;
       yield this.details.render(animation, this.tracksMap.get(animation));
       this.animationAnimationNameEl.textContent = getFormattedAnimationTitle(animation);
     }
-    this.onTimelineDataChanged(null, { time: this.currentTime || 0 });
+    this.onTimelineDataChanged({ time: this.currentTime || 0 });
     this.emit("animation-selected", animation);
   }),
 
   /**
    * When move the scrubber to the corresponding position
    */
   onScrubberMouseDown: function (e) {
     this.moveScrubberTo(e.pageX);
@@ -516,22 +516,22 @@ AnimationsTimeline.prototype = {
     }
 
     // To indicate the animation progress in AnimationDetails.
     this.on("timeline-data-changed", this.onTimelineDataChanged);
 
     if (this.animations.length === 1) {
       // Display animation's detail if there is only one animation,
       // even if the detail pane is closing.
-      yield this.onAnimationSelected(null, this.animations[0]);
+      yield this.onAnimationSelected(this.animations[0]);
     } else if (this.animationRootEl.classList.contains("animation-detail-visible") &&
                this.animations.indexOf(this.selectedAnimation) >= 0) {
       // animation's detail displays in case of the previously displayed animation is
       // included in timeline list and the detail pane is not closing.
-      yield this.onAnimationSelected(null, this.selectedAnimation);
+      yield this.onAnimationSelected(this.selectedAnimation);
     } else {
       // Otherwise, close detail pane.
       this.onDetailCloseButtonClick();
     }
     this.emit("animation-timeline-rendering-completed");
   }),
 
   isAtLeastOneAnimationPlaying: function () {
@@ -638,17 +638,17 @@ AnimationsTimeline.prototype = {
         attributes: {
           "class": "time-tick",
           "style": `left:${pos}%`
         }
       });
     }
   },
 
-  onTimelineDataChanged: function (e, { time }) {
+  onTimelineDataChanged: function ({ time }) {
     this.currentTime = time;
     const indicateTime =
       TimeScale.minStartTime === Infinity ? 0 : this.currentTime + TimeScale.minStartTime;
     this.details.indicateProgress(indicateTime);
   },
 
   onDetailCloseButtonClick: function (e) {
     if (!this.animationRootEl.classList.contains("animation-detail-visible")) {
--- a/devtools/client/animationinspector/components/keyframes.js
+++ b/devtools/client/animationinspector/components/keyframes.js
@@ -1,32 +1,29 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
-const EventEmitter = require("devtools/shared/old-event-emitter");
 const {createNode, createSVGNode} =
   require("devtools/client/animationinspector/utils");
 const {ProgressGraphHelper, getPreferredKeyframesProgressThreshold} =
          require("devtools/client/animationinspector/graph-helper.js");
 
 // Counter for linearGradient ID.
 let LINEAR_GRADIENT_ID_COUNTER = 0;
 
 /**
  * UI component responsible for displaying a list of keyframes.
  * Also, shows a graphical graph for the animation progress of one iteration.
  */
-function Keyframes() {
-  EventEmitter.decorate(this);
-}
+function Keyframes() {}
 
 exports.Keyframes = Keyframes;
 
 Keyframes.prototype = {
   init: function (containerEl) {
     this.containerEl = containerEl;
 
     this.keyframesEl = createNode({
--- a/devtools/client/animationinspector/components/rate-selector.js
+++ b/devtools/client/animationinspector/components/rate-selector.js
@@ -1,17 +1,17 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
-const EventEmitter = require("devtools/shared/old-event-emitter");
+const EventEmitter = require("devtools/shared/event-emitter");
 const {createNode} = require("devtools/client/animationinspector/utils");
 const { LocalizationHelper } = require("devtools/shared/l10n");
 const L10N =
       new LocalizationHelper("devtools/client/locales/animationinspector.properties");
 
 // List of playback rate presets displayed in the timeline toolbar.
 const PLAYBACK_RATES = [.1, .25, .5, 1, 2, 5, 10];
 
--- a/devtools/client/animationinspector/utils.js
+++ b/devtools/client/animationinspector/utils.js
@@ -1,18 +1,16 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
-loader.lazyRequireGetter(this, "EventEmitter", "devtools/shared/old-event-emitter");
-
 const { LocalizationHelper } = require("devtools/shared/l10n");
 const L10N =
       new LocalizationHelper("devtools/client/locales/animationinspector.properties");
 
 // How many times, maximum, can we loop before we find the optimal time
 // interval in the timeline graph.
 const OPTIMAL_TIME_INTERVAL_MAX_ITERS = 100;
 // Time graduations should be multiple of one of these number.