Bug 1530275- Replace defer usage with async/await in SwatchCubicBezierTooltip.js; r=nchevobbe
authorpaarmita <paarmita1998@gmail.com>
Fri, 01 Mar 2019 15:19:11 +0000
changeset 519836 ccb0b59aa78e5ad68baf10c479cad30ecf44c5f3
parent 519835 7b3e30ae92a935dd09df08cf7d862f67472cd5c3
child 519837 cf0c893a00bfb28da1b2bad6046866b89befe13d
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnchevobbe
bugs1530275
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1530275- Replace defer usage with async/await in SwatchCubicBezierTooltip.js; r=nchevobbe Differential Revision: https://phabricator.services.mozilla.com/D21658
devtools/client/shared/widgets/tooltip/SwatchCubicBezierTooltip.js
--- a/devtools/client/shared/widgets/tooltip/SwatchCubicBezierTooltip.js
+++ b/devtools/client/shared/widgets/tooltip/SwatchCubicBezierTooltip.js
@@ -1,15 +1,14 @@
 /* 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 defer = require("devtools/shared/defer");
 const {CubicBezierWidget} = require("devtools/client/shared/widgets/CubicBezierWidget");
 const SwatchBasedEditorTooltip = require("devtools/client/shared/widgets/tooltip/SwatchBasedEditorTooltip");
 
 const XHTML_NS = "http://www.w3.org/1999/xhtml";
 
 /**
  * The swatch cubic-bezier tooltip class is a specific class meant to be used
  * along with rule-view's generated cubic-bezier swatches.
@@ -34,36 +33,28 @@ class SwatchCubicBezierTooltip extends S
   }
 
   /**
    * Fill the tooltip with a new instance of the cubic-bezier widget
    * initialized with the given value, and return a promise that resolves to
    * the instance of the widget
    */
 
-  setCubicBezierContent(bezier) {
+  async setCubicBezierContent(bezier) {
     const { doc } = this.tooltip;
     this.tooltip.panel.innerHTML = "";
 
     const container = doc.createElementNS(XHTML_NS, "div");
     container.className = "cubic-bezier-container";
 
     this.tooltip.panel.appendChild(container);
     this.tooltip.setContentSize({ width: 510, height: 370 });
 
-    const def = defer();
-
-    // Wait for the tooltip to be shown before calling instanciating the widget
-    // as it expect its DOM elements to be visible.
-    this.tooltip.once("shown", () => {
-      const widget = new CubicBezierWidget(container, bezier);
-      def.resolve(widget);
-    });
-
-    return def.promise;
+    await this.tooltip.once("shown");
+    return new CubicBezierWidget(container, bezier);
   }
 
   /**
    * Overriding the SwatchBasedEditorTooltip.show function to set the cubic
    * bezier curve in the widget
    */
   async show() {
     // Call the parent class' show function