зеркало из https://github.com/mozilla/gecko-dev.git
bug 1504185 - remove highlighterUtils from devtools; r=ochameau
Depends on D11083 Differential Revision: https://phabricator.services.mozilla.com/D11084 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
1038ce7497
Коммит
4f24c22449
|
@ -28,7 +28,6 @@ DevToolsModules(
|
|||
'target-from-url.js',
|
||||
'target.js',
|
||||
'toolbox-context-menu.js',
|
||||
'toolbox-highlighter-utils.js',
|
||||
'toolbox-host-manager.js',
|
||||
'toolbox-hosts.js',
|
||||
'toolbox-options.js',
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
/* 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";
|
||||
|
||||
/**
|
||||
* Client-side highlighter shared module.
|
||||
* To be used by toolbox panels that need to highlight DOM elements.
|
||||
*
|
||||
* Highlighting and selecting elements is common enough that it needs to be at
|
||||
* toolbox level, accessible by any panel that needs it.
|
||||
* That's why the toolbox is the one that initializes the inspector and
|
||||
* highlighter. It's also why the API returned by this module needs a reference
|
||||
* to the toolbox which should be set once only.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the highighterUtils instance for a given toolbox.
|
||||
* This should be done once only by the toolbox itself and stored there so that
|
||||
* panels can get it from there. That's because the API returned has a stateful
|
||||
* scope that would be different for another instance returned by this function.
|
||||
*
|
||||
* @param {Toolbox} toolbox
|
||||
* @return {Object} the highlighterUtils public API
|
||||
*/
|
||||
exports.getHighlighterUtils = function(toolbox) {
|
||||
if (!toolbox) {
|
||||
throw new Error("Missing or invalid toolbox passed to getHighlighterUtils");
|
||||
}
|
||||
|
||||
// Exported API properties will go here
|
||||
const exported = {};
|
||||
|
||||
/**
|
||||
* Release this utils, nullifying the references to the toolbox
|
||||
*/
|
||||
exported.release = function() {
|
||||
toolbox = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Make a function that initializes the inspector before it runs.
|
||||
* Since the init of the inspector is asynchronous, the return value will be
|
||||
* produced by Task.async and the argument should be a generator
|
||||
* @param {Function*} generator A generator function
|
||||
* @return {Function} A function
|
||||
*/
|
||||
let isInspectorInitialized = false;
|
||||
const requireInspector = generator => {
|
||||
return async function(...args) {
|
||||
if (!isInspectorInitialized) {
|
||||
await toolbox.initInspector();
|
||||
isInspectorInitialized = true;
|
||||
}
|
||||
return generator.apply(null, args);
|
||||
};
|
||||
};
|
||||
|
||||
// Return the public API
|
||||
return exported;
|
||||
};
|
|
@ -38,8 +38,6 @@ const L10N = new LocalizationHelper("devtools/client/locales/toolbox.properties"
|
|||
|
||||
loader.lazyRequireGetter(this, "AppConstants",
|
||||
"resource://gre/modules/AppConstants.jsm", true);
|
||||
loader.lazyRequireGetter(this, "getHighlighterUtils",
|
||||
"devtools/client/framework/toolbox-highlighter-utils", true);
|
||||
loader.lazyRequireGetter(this, "flags",
|
||||
"devtools/shared/flags");
|
||||
loader.lazyRequireGetter(this, "KeyShortcuts",
|
||||
|
@ -136,7 +134,6 @@ function Toolbox(target, selectedTool, hostType, contentWindow, frameId,
|
|||
this._splitConsoleOnKeypress = this._splitConsoleOnKeypress.bind(this);
|
||||
this.closeToolbox = this.closeToolbox.bind(this);
|
||||
this.destroy = this.destroy.bind(this);
|
||||
this.highlighterUtils = getHighlighterUtils(this);
|
||||
this._highlighterReady = this._highlighterReady.bind(this);
|
||||
this._highlighterHidden = this._highlighterHidden.bind(this);
|
||||
this._applyCacheSettings = this._applyCacheSettings.bind(this);
|
||||
|
@ -374,8 +371,6 @@ Toolbox.prototype = {
|
|||
/**
|
||||
* Get the toolbox highlighter front. Note that it may not always have been
|
||||
* initialized first. Use `initInspector()` if needed.
|
||||
* Consider using highlighterUtils instead, it exposes the highlighter API in
|
||||
* a useful way for the toolbox panels
|
||||
*/
|
||||
get highlighter() {
|
||||
return this._highlighter;
|
||||
|
@ -2982,7 +2977,6 @@ Toolbox.prototype = {
|
|||
}
|
||||
const target = this._target;
|
||||
this._target = null;
|
||||
this.highlighterUtils.release();
|
||||
target.off("close", this.destroy);
|
||||
return target.destroy();
|
||||
}, console.error).then(() => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче