Bug 1499056 - Use target.getFront for screenshot front; r=ochameau
authoryulia <ystartsev@mozilla.com>
Wed, 17 Oct 2018 10:40:48 +0000
changeset 500113 ee2d80610d72755a8b2b58c6c8e8cd11a323da47
parent 500112 745dab0eb0111f2c0d537e51db67cf6bcf4ad0ac
child 500114 e7995331d6386309dbe2caca5f947a54fc088249
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1499056
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 1499056 - Use target.getFront for screenshot front; r=ochameau Differential Revision: https://phabricator.services.mozilla.com/D8866
devtools/client/definitions.js
devtools/client/inspector/inspector.js
devtools/shared/fronts/screenshot.js
devtools/shared/specs/index.js
--- a/devtools/client/definitions.js
+++ b/devtools/client/definitions.js
@@ -28,17 +28,16 @@ loader.lazyGetter(this, "AccessibilityPa
 loader.lazyGetter(this, "ApplicationPanel", () => require("devtools/client/application/panel").ApplicationPanel);
 loader.lazyGetter(this, "reloadAndRecordTab", () => require("devtools/client/webreplay/menu.js").reloadAndRecordTab);
 loader.lazyGetter(this, "reloadAndStopRecordingTab", () => require("devtools/client/webreplay/menu.js").reloadAndStopRecordingTab);
 
 // Other dependencies
 loader.lazyRequireGetter(this, "AccessibilityStartup", "devtools/client/accessibility/accessibility-startup", true);
 loader.lazyRequireGetter(this, "ResponsiveUIManager", "devtools/client/responsive.html/manager", true);
 loader.lazyImporter(this, "ScratchpadManager", "resource://devtools/client/scratchpad/scratchpad-manager.jsm");
-loader.lazyRequireGetter(this, "getScreenshotFront", "resource://devtools/shared/fronts/screenshot", true);
 
 const {MultiLocalizationHelper} = require("devtools/shared/l10n");
 const L10N = new MultiLocalizationHelper(
   "devtools/client/locales/startup.properties",
   "devtools/startup/locales/key-shortcuts.properties"
 );
 
 var Tools = {};
@@ -586,17 +585,17 @@ exports.ToolboxButtons = [
     async onClick(event, toolbox) {
       // Special case for screenshot button to check for clipboard preference
       const clipboardEnabled = Services.prefs
         .getBoolPref("devtools.screenshot.clipboard.enabled");
       const args = { fullpage: true, file: true };
       if (clipboardEnabled) {
         args.clipboard = true;
       }
-      const screenshotFront = getScreenshotFront(toolbox.target);
+      const screenshotFront = toolbox.target.getFront("screenshot");
       await screenshotFront.captureAndSave(toolbox.win, args);
     }
   },
   createHighlightButton("RulersHighlighter", "rulers"),
   createHighlightButton("MeasuringToolHighlighter", "measure"),
 ];
 
 function createHighlightButton(highlighterName, id) {
--- a/devtools/client/inspector/inspector.js
+++ b/devtools/client/inspector/inspector.js
@@ -29,17 +29,16 @@ loader.lazyRequireGetter(this, "ToolSide
 loader.lazyRequireGetter(this, "MarkupView", "devtools/client/inspector/markup/markup");
 loader.lazyRequireGetter(this, "HighlightersOverlay", "devtools/client/inspector/shared/highlighters-overlay");
 loader.lazyRequireGetter(this, "nodeConstants", "devtools/shared/dom-node-constants");
 loader.lazyRequireGetter(this, "Menu", "devtools/client/framework/menu");
 loader.lazyRequireGetter(this, "MenuItem", "devtools/client/framework/menu-item");
 loader.lazyRequireGetter(this, "ExtensionSidebar", "devtools/client/inspector/extensions/extension-sidebar");
 loader.lazyRequireGetter(this, "clipboardHelper", "devtools/shared/platform/clipboard");
 loader.lazyRequireGetter(this, "openContentLink", "devtools/client/shared/link", true);
-loader.lazyRequireGetter(this, "getScreenshotFront", "devtools/shared/fronts/screenshot", true);
 loader.lazyRequireGetter(this, "saveScreenshot", "devtools/shared/screenshot/save");
 loader.lazyRequireGetter(this, "ChangesManager",
 "devtools/client/inspector/changes/ChangesManager");
 
 loader.lazyImporter(this, "DeferredTask", "resource://gre/modules/DeferredTask.jsm");
 
 const {LocalizationHelper, localizeMarkup} = require("devtools/shared/l10n");
 const INSPECTOR_L10N =
@@ -2329,17 +2328,17 @@ Inspector.prototype = {
 
     const clipboardEnabled = Services.prefs
       .getBoolPref("devtools.screenshot.clipboard.enabled");
     const args = {
       file: true,
       selector: this.selectionCssSelector,
       clipboard: clipboardEnabled
     };
-    const screenshotFront = getScreenshotFront(this.target);
+    const screenshotFront = this.target.getFront("screenshot");
     const screenshot = await screenshotFront.capture(args);
     await saveScreenshot(this.panelWin, args, screenshot);
   },
 
   /**
    * Scroll the node into view.
    */
   scrollNodeIntoView: function() {
--- a/devtools/shared/fronts/screenshot.js
+++ b/devtools/shared/fronts/screenshot.js
@@ -15,24 +15,9 @@ const ScreenshotFront = protocol.FrontCl
   },
 
   async captureAndSave(window, args) {
     const screenshot = await this.capture(args);
     return saveScreenshot(window, args, screenshot);
   }
 });
 
-// A cache of created fronts: WeakMap<Client, Front>
-const knownFronts = new WeakMap();
-
-/**
- * Create a screenshot front only when needed
- */
-function getScreenshotFront(target) {
-  let front = knownFronts.get(target.client);
-  if (front == null && target.form.screenshotActor != null) {
-    front = new ScreenshotFront(target.client, target.form);
-    knownFronts.set(target.client, front);
-  }
-  return front;
-}
-
-exports.getScreenshotFront = getScreenshotFront;
+exports.ScreenshotFront = ScreenshotFront;
--- a/devtools/shared/specs/index.js
+++ b/devtools/shared/specs/index.js
@@ -177,16 +177,21 @@ const Types = exports.__TypesForTests = 
     spec: "devtools/shared/specs/property-iterator",
     front: null,
   },
   {
     types: ["reflow"],
     spec: "devtools/shared/specs/reflow",
     front: "devtools/shared/fronts/reflow",
   },
+  {
+    types: ["screenshot"],
+    spec: "devtools/shared/specs/screenshot",
+    front: "devtools/shared/fronts/screenshot",
+  },
   /* Script and source have old fashion client and no front */
   {
     types: ["context"],
     spec: "devtools/shared/specs/script",
     front: null,
   },
   {
     types: ["source"],