Bug 1561281 - Remove toolbox getHighlighter `isGrip` parameter. r=davidwalsh.
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Mon, 21 Oct 2019 08:27:11 +0000
changeset 498367 ed351e41d3d5a2ebf881d6a0d31bbc98fbf53aaf
parent 498366 2c1816247be7efdcfbf6894aeccd027695608bd4
child 498368 8acdee03fb76c4477c0bc168e7a21cabda7823a8
push id36717
push usernbeleuzu@mozilla.com
push dateMon, 21 Oct 2019 21:51:55 +0000
treeherdermozilla-central@563f437f24b9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdavidwalsh
bugs1561281
milestone71.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 1561281 - Remove toolbox getHighlighter `isGrip` parameter. r=davidwalsh. Some panels, like the debugger, might handle both nodeFronts and grips at the same time, so there's no way to know ahead of time which kind of object we're going to deal with. This patch remove the isGrip parameter, and perform a check on the passed object to see if it's a nodeFront instance or not. Differential Revision: https://phabricator.services.mozilla.com/D49399
devtools/client/framework/toolbox.js
devtools/client/webconsole/service-container.js
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -170,16 +170,23 @@ loader.lazyGetter(
 
 loader.lazyRequireGetter(
   this,
   "defaultThreadOptions",
   "devtools/client/shared/thread-utils",
   true
 );
 
+loader.lazyRequireGetter(
+  this,
+  "NodeFront",
+  "devtools/shared/fronts/node",
+  true
+);
+
 /**
  * A "Toolbox" is the component that holds all the tools for one specific
  * target. Visually, it's a document that includes the tools tabs and all
  * the iframes where the tool panels will be living in.
  *
  * @param {object} target
  *        The object the toolbox is debugging.
  * @param {string} selectedTool
@@ -3405,39 +3412,37 @@ Toolbox.prototype = {
     // instead of gDevTools
     this.emit("tool-unregistered", toolId);
   },
 
   /**
    * An helper function that returns an object contain a highlighter and unhighlighter
    * function.
    *
-   * @param {Boolean} isGrip: Set to true if the `highlight` function is going to be
-   *                          called with a Grip (and not from a NodeFront).
    * @returns {Object} an object of the following shape:
    *   - {AsyncFunction} highlight: A function that will initialize the highlighter front
    *                                and call highlighter.highlight with the provided node
    *                                front (which will be retrieved from a grip, if
    *                                `fromGrip` is true.)
    *   - {AsyncFunction} unhighlight: A function that will unhighlight the node that is
    *                                  currently highlighted. If the `highlight` function
    *                                  isn't settled yet, it will wait until it's done and
    *                                  then unhighlight to prevent zombie highlighters.
    *
    */
-  getHighlighter(fromGrip = false) {
+  getHighlighter() {
     let pendingHighlight;
     let currentHighlighterFront;
 
     return {
       highlight: async (object, options) => {
         pendingHighlight = (async () => {
           let nodeFront = object;
 
-          if (fromGrip) {
+          if (!(nodeFront instanceof NodeFront)) {
             const inspectorFront = await this.target.getFront("inspector");
             nodeFront = await inspectorFront.getNodeFrontFromNodeGrip(object);
           }
 
           if (!nodeFront) {
             return null;
           }
 
--- a/devtools/client/webconsole/service-container.js
+++ b/devtools/client/webconsole/service-container.js
@@ -48,17 +48,17 @@ function setupServiceContainer({
     getJsTermTooltipAnchor: () => webConsoleUI.getJsTermTooltipAnchor(),
     emitEvent: (event, value) => webConsoleUI.emit(event, value),
     attachRefToWebConsoleUI: (id, node) => webConsoleUI.attachRef(id, node),
     requestData: (id, type) => webConsoleWrapper.requestData(id, type),
     createElement: nodename => webConsoleWrapper.createElement(nodename),
   };
 
   if (toolbox) {
-    const { highlight, unhighlight } = toolbox.getHighlighter(true);
+    const { highlight, unhighlight } = toolbox.getHighlighter();
 
     Object.assign(serviceContainer, {
       sourceMapService: toolbox.sourceMapURLService,
       highlightDomElement: highlight,
       unHighlightDomElement: unhighlight,
       jumpToExecutionPoint: executionPoint =>
         toolbox.threadFront.timeWarp(executionPoint),
       onViewSourceInDebugger: frame => hud.onViewSourceInDebugger(frame),