Bug 1488378 - Use target.getFront to instantiate CSSUsageFront; r=ochameau
authoryulia <ystartsev@mozilla.com>
Mon, 08 Oct 2018 10:53:50 +0000
changeset 495706 e6bdfb617164e4e88919b6cc55491b411a962033
parent 495705 10ad4a4352f9e87bac30494aced99e362d8d1a52
child 495707 14f893f7de2dac98a5690d11507cadd1f6bd0030
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1488378
milestone64.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 1488378 - Use target.getFront to instantiate CSSUsageFront; r=ochameau Differential Revision: https://phabricator.services.mozilla.com/D7887
devtools/client/styleeditor/StyleEditorUI.jsm
devtools/shared/fronts/csscoverage.js
--- a/devtools/client/styleeditor/StyleEditorUI.jsm
+++ b/devtools/client/styleeditor/StyleEditorUI.jsm
@@ -18,17 +18,16 @@ const {
   text,
   wire,
   showFilePicker,
 } = require("resource://devtools/client/styleeditor/StyleEditorUtil.jsm");
 const {SplitView} = require("resource://devtools/client/shared/SplitView.jsm");
 const {StyleSheetEditor} = require("resource://devtools/client/styleeditor/StyleSheetEditor.jsm");
 const {PluralForm} = require("devtools/shared/plural-form");
 const {PrefObserver} = require("devtools/client/shared/prefs");
-const csscoverage = require("devtools/shared/fronts/csscoverage");
 const {KeyCodes} = require("devtools/client/shared/keycodes");
 const {OriginalSource} = require("devtools/client/styleeditor/original-source");
 
 loader.lazyRequireGetter(this, "ResponsiveUIManager", "devtools/client/responsive.html/manager", true);
 loader.lazyRequireGetter(this, "openContentLink", "devtools/client/shared/link", true);
 
 const LOAD_ERROR = "error-load";
 const STYLE_EDITOR_TEMPLATE = "stylesheet";
@@ -631,17 +630,17 @@ StyleEditorUI.prototype = {
             await showEditor.load(inputElement, this._cssProperties);
           }
 
           showEditor.onShow();
 
           this.emit("editor-selected", showEditor);
 
           // Is there any CSS coverage markup to include?
-          const usage = await csscoverage.getUsage(this._target);
+          const usage = this._target.getFront("cssUsage");
           if (usage == null) {
             return;
           }
 
           const sheet = showEditor.styleSheet;
           const {reports} = await usage.createEditorReportForSheet(sheet);
 
           showEditor.removeAllUnusedRegions();
--- a/devtools/shared/fronts/csscoverage.js
+++ b/devtools/shared/fronts/csscoverage.js
@@ -100,26 +100,8 @@ const CSSUsageFront = protocol.FrontClas
    * We count STARTING and STOPPING as 'running'
    */
   isRunning: function() {
     return isRunning;
   }
 });
 
 exports.CSSUsageFront = CSSUsageFront;
-
-const knownFronts = new WeakMap();
-
-/**
- * Create a CSSUsageFront only when needed (returns a promise)
- * For notes on target.attach(), see
- * https://bugzilla.mozilla.org/show_bug.cgi?id=1016330#c7
- */
-exports.getUsage = function(trgt) {
-  return trgt.attach().then(() => {
-    let front = knownFronts.get(trgt.client);
-    if (front == null && trgt.form.cssUsageActor != null) {
-      front = new CSSUsageFront(trgt.client, trgt.form);
-      knownFronts.set(trgt.client, front);
-    }
-    return front;
-  });
-};