From 2a6de263f1fa054d7a5842c9a4b7142f859d358f Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Tue, 7 Feb 2017 22:21:54 +0100 Subject: [PATCH] Bug 1337510 - Remove dead code related to gcli command buttons. r=jryans MozReview-Commit-ID: 8mF3u2hvjnu --HG-- extra : rebase_source : 7da81f8a906541ddcd16f1dd4010d05ccd28a1c9 --- devtools/client/framework/toolbox.js | 11 --- devtools/client/shared/developer-toolbar.js | 93 --------------------- 2 files changed, 104 deletions(-) diff --git a/devtools/client/framework/toolbox.js b/devtools/client/framework/toolbox.js index e5ee01b75a21..b28b03e4b256 100644 --- a/devtools/client/framework/toolbox.js +++ b/devtools/client/framework/toolbox.js @@ -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). diff --git a/devtools/client/shared/developer-toolbar.js b/devtools/client/shared/developer-toolbar.js index ae7a7a32b35a..52b3a578e9cb 100644 --- a/devtools/client/shared/developer-toolbar.js +++ b/devtools/client/shared/developer-toolbar.js @@ -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.