зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1337510 - Remove dead code related to gcli command buttons. r=jryans
MozReview-Commit-ID: 8mF3u2hvjnu --HG-- extra : rebase_source : 7da81f8a906541ddcd16f1dd4010d05ccd28a1c9
This commit is contained in:
Родитель
f58c583f2b
Коммит
2a6de263f1
|
@ -34,8 +34,6 @@ const { BrowserLoader } =
|
|||
const {LocalizationHelper} = require("devtools/shared/l10n");
|
||||
const L10N = new LocalizationHelper("devtools/client/locales/toolbox.properties");
|
||||
|
||||
loader.lazyRequireGetter(this, "CommandUtils",
|
||||
"devtools/client/shared/developer-toolbar", true);
|
||||
loader.lazyRequireGetter(this, "getHighlighterUtils",
|
||||
"devtools/client/framework/toolbox-highlighter-utils", true);
|
||||
loader.lazyRequireGetter(this, "Selection",
|
||||
|
@ -1204,15 +1202,6 @@ Toolbox.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the toolbar spec for toolbox
|
||||
*/
|
||||
getToolbarSpec: function () {
|
||||
let spec = CommandUtils.getCommandbarSpec("devtools.toolbox.toolbarSpec");
|
||||
|
||||
return spec;
|
||||
},
|
||||
|
||||
/**
|
||||
* Return all toolbox buttons (command buttons, plus any others that were
|
||||
* added manually).
|
||||
|
|
|
@ -78,99 +78,6 @@ var CommandUtils = {
|
|||
gcliInit.releaseSystem(target);
|
||||
},
|
||||
|
||||
/**
|
||||
* Read a toolbarSpec from preferences
|
||||
* @param pref The name of the preference to read
|
||||
*/
|
||||
getCommandbarSpec: function (pref) {
|
||||
let value = prefBranch.getComplexValue(pref, Ci.nsISupportsString).data;
|
||||
return JSON.parse(value);
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a list of props for React components that manage the state of the buttons.
|
||||
*
|
||||
* @param {Array} toolbarSpec - An array of strings each of which is a GCLI command.
|
||||
* @param {Object} target
|
||||
* @param {Object} document - Used to listen to unload event of the window.
|
||||
* @param {Requisition} requisition
|
||||
* @param {Function} createButtonState - A function that provides a common interface
|
||||
* to create a button for the toolbox.
|
||||
*
|
||||
* @return {Array} List of ToolboxButton objects..
|
||||
*
|
||||
* Warning: this method uses the unload event of the window that owns the
|
||||
* buttons that are of type checkbox. this means that we don't properly
|
||||
* unregister event handlers until the window is destroyed.
|
||||
*/
|
||||
createCommandButtons: function (toolbarSpec, target, document, requisition,
|
||||
createButtonState) {
|
||||
return util.promiseEach(toolbarSpec, typed => {
|
||||
// Ask GCLI to parse the typed string (doesn't execute it)
|
||||
return requisition.update(typed).then(() => {
|
||||
// Ignore invalid commands
|
||||
let command = requisition.commandAssignment.value;
|
||||
if (command == null) {
|
||||
throw new Error("No command '" + typed + "'");
|
||||
}
|
||||
if (!command.buttonId) {
|
||||
throw new Error("Attempting to add a button to the toolbar, and the command " +
|
||||
"did not have an id.");
|
||||
}
|
||||
// Create the ToolboxButton.
|
||||
let button = createButtonState({
|
||||
id: command.buttonId,
|
||||
className: command.buttonClass,
|
||||
description: command.tooltipText || command.description,
|
||||
onClick: requisition.updateExec.bind(requisition, typed)
|
||||
});
|
||||
|
||||
// Allow the command button to be toggleable.
|
||||
if (command.state) {
|
||||
/**
|
||||
* The onChange event should be called with an event object that
|
||||
* contains a target property which specifies which target the event
|
||||
* applies to. For legacy reasons the event object can also contain
|
||||
* a tab property.
|
||||
*/
|
||||
const onChange = (eventName, ev) => {
|
||||
if (ev.target == target || ev.tab == target.tab) {
|
||||
let updateChecked = (checked) => {
|
||||
// This will emit a ToolboxButton update event.
|
||||
button.isChecked = checked;
|
||||
};
|
||||
|
||||
// isChecked would normally be synchronous. An annoying quirk
|
||||
// of the 'csscoverage toggle' command forces us to accept a
|
||||
// promise here, but doing Promise.resolve(reply).then(...) here
|
||||
// makes this async for everyone, which breaks some tests so we
|
||||
// treat non-promise replies separately to keep then synchronous.
|
||||
let reply = command.state.isChecked(target);
|
||||
if (typeof reply.then == "function") {
|
||||
reply.then(updateChecked, console.error);
|
||||
} else {
|
||||
updateChecked(reply);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
command.state.onChange(target, onChange);
|
||||
onChange("", { target: target });
|
||||
|
||||
document.defaultView.addEventListener("unload", function (event) {
|
||||
if (command.state.offChange) {
|
||||
command.state.offChange(target, onChange);
|
||||
}
|
||||
}, { once: true });
|
||||
}
|
||||
|
||||
requisition.clear();
|
||||
|
||||
return button;
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* A helper function to create the environment object that is passed to
|
||||
* GCLI commands.
|
||||
|
|
Загрузка…
Ссылка в новой задаче