Bug 866138 - Refactor disabling logic for a tool and convert options panel to a tool too, r=jwalker

This commit is contained in:
Girish Sharma 2013-05-04 12:01:07 +05:30
Родитель 398bc8f36b
Коммит dc8f680d63
21 изменённых файлов: 254 добавлений и 269 удалений

Просмотреть файл

@ -1032,7 +1032,6 @@ pref("devtools.toolbox.host", "bottom");
pref("devtools.toolbox.selectedTool", "webconsole"); pref("devtools.toolbox.selectedTool", "webconsole");
pref("devtools.toolbox.toolbarSpec", '["paintflashing toggle","tilt toggle","scratchpad","resize toggle"]'); pref("devtools.toolbox.toolbarSpec", '["paintflashing toggle","tilt toggle","scratchpad","resize toggle"]');
pref("devtools.toolbox.sideEnabled", true); pref("devtools.toolbox.sideEnabled", true);
pref("devtools.toolbox.disabledTools", "[]");
// Enable the Inspector // Enable the Inspector
pref("devtools.inspector.enabled", true); pref("devtools.inspector.enabled", true);

Просмотреть файл

@ -222,8 +222,8 @@ DevTools.prototype = {
* *
* Each toolDefinition has the following properties: * Each toolDefinition has the following properties:
* - id: Unique identifier for this tool (string|required) * - id: Unique identifier for this tool (string|required)
* - killswitch: Property name to allow us to turn this tool on/off globally * - visibilityswitch: Property name to allow us to hide this tool from the
* (string|required) (TODO: default to devtools.{id}.enabled?) * DevTools Toolbox.
* - icon: URL pointing to a graphic which will be used as the src for an * - icon: URL pointing to a graphic which will be used as the src for an
* 16x16 img tag (string|required) * 16x16 img tag (string|required)
* - url: URL pointing to a XUL/XHTML document containing the user interface * - url: URL pointing to a XUL/XHTML document containing the user interface
@ -241,7 +241,7 @@ DevTools.prototype = {
throw new Error("Invalid definition.id"); throw new Error("Invalid definition.id");
} }
toolDefinition.killswitch = toolDefinition.killswitch || toolDefinition.visibilityswitch = toolDefinition.visibilityswitch ||
"devtools." + toolId + ".enabled"; "devtools." + toolId + ".enabled";
this._tools.set(toolId, toolDefinition); this._tools.set(toolId, toolDefinition);
@ -307,21 +307,17 @@ DevTools.prototype = {
*/ */
getToolDefinitionMap: function DT_getToolDefinitionMap() { getToolDefinitionMap: function DT_getToolDefinitionMap() {
let tools = new Map(); let tools = new Map();
let disabledTools = [];
try {
disabledTools = JSON.parse(Services.prefs.getCharPref("devtools.toolbox.disabledTools"));
} catch(ex) {}
for (let [key, value] of this._tools) { for (let [key, value] of this._tools) {
let enabled; let enabled;
try { try {
enabled = Services.prefs.getBoolPref(value.killswitch); enabled = Services.prefs.getBoolPref(value.visibilityswitch);
} catch(e) { } catch(e) {
enabled = true; enabled = true;
} }
if (enabled && disabledTools.indexOf(key) == -1) { if (enabled || value.id == "options") {
tools.set(key, value); tools.set(key, value);
} }
} }
@ -454,7 +450,7 @@ DevTools.prototype = {
destroy: function() { destroy: function() {
Services.obs.removeObserver(this.destroy, "quit-application"); Services.obs.removeObserver(this.destroy, "quit-application");
for (let [key, tool] of this._tools) { for (let [key, tool] of this.getToolDefinitionMap()) {
this.unregisterTool(key, true); this.unregisterTool(key, true);
} }
@ -578,15 +574,23 @@ let gDevToolsBrowser = {
}, },
/** /**
* Add the menuitem for a tool to all open browser windows. Also toggles the * Add the menuitem for a tool to all open browser windows.
* kill switch preference of the tool.
* *
* @param {object} toolDefinition * @param {object} toolDefinition
* properties of the tool to add * properties of the tool to add
*/ */
_addToolToWindows: function DT_addToolToWindows(toolDefinition) { _addToolToWindows: function DT_addToolToWindows(toolDefinition) {
// Set the kill switch pref boolean to true // No menu item or global shortcut is required for options panel.
Services.prefs.setBoolPref(toolDefinition.killswitch, true); if (toolDefinition.id == "options") {
return;
}
// Skip if the tool is disabled.
try {
if (!Services.prefs.getBoolPref(toolDefinition.visibilityswitch)) {
return;
}
} catch(e) {}
// We need to insert the new tool in the right place, which means knowing // We need to insert the new tool in the right place, which means knowing
// the tool that comes before the tool that we're trying to add // the tool that comes before the tool that we're trying to add
@ -642,6 +646,17 @@ let gDevToolsBrowser = {
let fragMenuItems = doc.createDocumentFragment(); let fragMenuItems = doc.createDocumentFragment();
for (let toolDefinition of gDevTools.getToolDefinitionArray()) { for (let toolDefinition of gDevTools.getToolDefinitionArray()) {
if (toolDefinition.id == "options") {
continue;
}
// Skip if the tool is disabled.
try {
if (!Services.prefs.getBoolPref(toolDefinition.visibilityswitch)) {
continue;
}
} catch(e) {}
let elements = gDevToolsBrowser._createToolMenuElements(toolDefinition, doc); let elements = gDevToolsBrowser._createToolMenuElements(toolDefinition, doc);
if (!elements) { if (!elements) {
@ -767,16 +782,12 @@ let gDevToolsBrowser = {
}, },
/** /**
* Remove the menuitem for a tool to all open browser windows. Also sets the * Remove the menuitem for a tool to all open browser windows.
* kill switch boolean pref to false.
* *
* @param {object} toolId * @param {string} toolId
* id of the tool to remove * id of the tool to remove
* @param {string} killswitch
* The kill switch preference string of the tool
*/ */
_removeToolFromWindows: function DT_removeToolFromWindows(toolId, killswitch) { _removeToolFromWindows: function DT_removeToolFromWindows(toolId) {
Services.prefs.setBoolPref(killswitch, false);
for (let win of gDevToolsBrowser._trackedBrowserWindows) { for (let win of gDevToolsBrowser._trackedBrowserWindows) {
gDevToolsBrowser._removeToolFromMenu(toolId, win.document); gDevToolsBrowser._removeToolFromMenu(toolId, win.document);
} }
@ -854,15 +865,10 @@ gDevTools.on("tool-registered", function(ev, toolId) {
}); });
gDevTools.on("tool-unregistered", function(ev, toolId) { gDevTools.on("tool-unregistered", function(ev, toolId) {
let killswitch; if (typeof toolId != "string") {
if (typeof toolId == "string") {
killswitch = "devtools." + toolId + ".enabled";
}
else {
killswitch = toolId.killswitch;
toolId = toolId.id; toolId = toolId.id;
} }
gDevToolsBrowser._removeToolFromWindows(toolId, killswitch); gDevToolsBrowser._removeToolFromWindows(toolId);
}); });
gDevTools.on("toolbox-ready", gDevToolsBrowser._updateMenuCheckbox); gDevTools.on("toolbox-ready", gDevToolsBrowser._updateMenuCheckbox);

Просмотреть файл

@ -20,7 +20,7 @@ function runTests(aTab) {
let toolDefinition = { let toolDefinition = {
id: toolId, id: toolId,
isTargetSupported: function() true, isTargetSupported: function() true,
killswitch: "devtools.test-tool.enabled", visibilityswitch: "devtools.test-tool.enabled",
url: "about:blank", url: "about:blank",
label: "someLabel", label: "someLabel",
build: function(iframeWindow, toolbox) { build: function(iframeWindow, toolbox) {

Просмотреть файл

@ -26,24 +26,16 @@ function testSelectTool(aToolbox) {
function testOptionsShortcut() { function testOptionsShortcut() {
ok(true, "Toolbox selected via selectTool method"); ok(true, "Toolbox selected via selectTool method");
toolbox.once("options-selected", testOptionsButtonClick); toolbox.once("options-selected", testOptions);
toolbox.selectTool("webconsole") toolbox.selectTool("webconsole")
.then(() => synthesizeKeyFromKeyTag("toolbox-options-key", doc)); .then(() => synthesizeKeyFromKeyTag("toolbox-options-key", doc));
} }
function testOptionsButtonClick() { function testOptions(event, tool) {
ok(true, "Toolbox selected via shortcut");
toolbox.once("options-selected", testOptions);
toolbox.selectTool("webconsole")
.then(() => doc.getElementById("toolbox-tab-options").click());
}
function testOptions(event, iframe) {
ok(true, "Toolbox selected via button click"); ok(true, "Toolbox selected via button click");
panelWin = iframe.contentWindow; panelWin = tool.panelWin;
let panelDoc = iframe.contentDocument;
// Testing pref changes // Testing pref changes
let prefCheckboxes = panelDoc.querySelectorAll("checkbox[data-pref]"); let prefCheckboxes = tool.panelDoc.querySelectorAll("checkbox[data-pref]");
for (let checkbox of prefCheckboxes) { for (let checkbox of prefCheckboxes) {
prefNodes.push(checkbox); prefNodes.push(checkbox);
prefValues.push(Services.prefs.getBoolPref(checkbox.getAttribute("data-pref"))); prefValues.push(Services.prefs.getBoolPref(checkbox.getAttribute("data-pref")));

Просмотреть файл

@ -24,7 +24,7 @@ function test() {
let toolDefinition = { let toolDefinition = {
id: "fakeTool4242", id: "fakeTool4242",
killswitch: "devtools.fakeTool4242.enabled", visibilityswitch: "devtools.fakeTool4242.enabled",
url: toolURL, url: toolURL,
label: "FAKE TOOL!!!", label: "FAKE TOOL!!!",
isTargetSupported: function() true, isTargetSupported: function() true,

Просмотреть файл

@ -4,51 +4,78 @@
"use strict"; "use strict";
const { utils: Cu } = Components; const {Cu} = require("chrome");
const DISABLED_TOOLS = "devtools.toolbox.disabledTools";
let Promise = require("sdk/core/promise");
let EventEmitter = require("devtools/shared/event-emitter");
Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource:///modules/devtools/gDevTools.jsm"); Cu.import("resource:///modules/devtools/gDevTools.jsm");
window.addEventListener("load", function onLoad() { exports.OptionsPanel = OptionsPanel;
window.removeEventListener("load", onLoad);
setupToolsList();
populatePreferences();
});
function setupToolsList() { /**
let disabledTools = []; * Represents the Options Panel in the Toolbox.
try { */
disabledTools = JSON.parse(Services.prefs.getCharPref(DISABLED_TOOLS)); function OptionsPanel(iframeWindow, toolbox) {
} catch(ex) { this.panelDoc = iframeWindow.document;
Cu.reportError("Error parsing pref " + DISABLED_TOOLS + " as JSON."); this.panelWin = iframeWindow;
}
let defaultToolsBox = document.getElementById("default-tools-box"); EventEmitter.decorate(this);
let additionalToolsBox = document.getElementById("additional-tools-box"); };
OptionsPanel.prototype = {
open: function OP_open() {
let deferred = Promise.defer();
this.setupToolsList();
this.populatePreferences();
this.emit("ready");
deferred.resolve(this);
return deferred.promise;
},
setupToolsList: function OP_setupToolsList() {
let defaultToolsBox = this.panelDoc.getElementById("default-tools-box");
let additionalToolsBox = this.panelDoc.getElementById("additional-tools-box");
defaultToolsBox.textContent = ""; defaultToolsBox.textContent = "";
additionalToolsBox.textContent = ""; additionalToolsBox.textContent = "";
let pref = function(key) {
try {
return Services.prefs.getBoolPref(key);
}
catch (ex) {
return true;
}
};
let onCheckboxClick = function(id) { let onCheckboxClick = function(id) {
if (disabledTools.indexOf(id) > -1) { let toolDefinition = gDevTools._tools.get(id);
disabledTools.splice(disabledTools.indexOf(id), 1); // Set the kill switch pref boolean to true
Services.prefs.setCharPref(DISABLED_TOOLS, JSON.stringify(disabledTools)); Services.prefs.setBoolPref(toolDefinition.visibilityswitch, this.checked);
if (this.checked) {
gDevTools.emit("tool-registered", id); gDevTools.emit("tool-registered", id);
} }
else { else {
disabledTools.push(id); gDevTools.emit("tool-unregistered", toolDefinition);
Services.prefs.setCharPref(DISABLED_TOOLS, JSON.stringify(disabledTools));
gDevTools.emit("tool-unregistered", gDevTools._tools.get(id));
} }
}; };
// Populating the default tools lists // Populating the default tools lists
for (let tool of gDevTools.getDefaultTools()) { for (let tool of gDevTools.getDefaultTools()) {
let checkbox = document.createElement("checkbox"); if (tool.id == "options") {
continue;
}
let checkbox = this.panelDoc.createElement("checkbox");
checkbox.setAttribute("id", tool.id); checkbox.setAttribute("id", tool.id);
checkbox.setAttribute("label", tool.label); checkbox.setAttribute("label", tool.label);
checkbox.setAttribute("tooltiptext", tool.tooltip || ""); checkbox.setAttribute("tooltiptext", tool.tooltip || "");
checkbox.setAttribute("checked", disabledTools.indexOf(tool.id) == -1); checkbox.setAttribute("checked", pref(tool.visibilityswitch));
checkbox.addEventListener("command", onCheckboxClick.bind(null, tool.id)); checkbox.addEventListener("command", onCheckboxClick.bind(checkbox, tool.id));
defaultToolsBox.appendChild(checkbox); defaultToolsBox.appendChild(checkbox);
} }
@ -56,12 +83,12 @@ function setupToolsList() {
let atleastOneAddon = false; let atleastOneAddon = false;
for (let tool of gDevTools.getAdditionalTools()) { for (let tool of gDevTools.getAdditionalTools()) {
atleastOneAddon = true; atleastOneAddon = true;
let checkbox = document.createElement("checkbox"); let checkbox = this.panelDoc.createElement("checkbox");
checkbox.setAttribute("id", tool.id); checkbox.setAttribute("id", tool.id);
checkbox.setAttribute("label", tool.label); checkbox.setAttribute("label", tool.label);
checkbox.setAttribute("tooltiptext", tool.tooltip || ""); checkbox.setAttribute("tooltiptext", tool.tooltip || "");
checkbox.setAttribute("checked", disabledTools.indexOf(tool.id) == -1); checkbox.setAttribute("checked", pref(tool.visibilityswitch));
checkbox.addEventListener("command", onCheckboxClick.bind(null, tool.id)); checkbox.addEventListener("command", onCheckboxClick.bind(checkbox, tool.id));
additionalToolsBox.appendChild(checkbox); additionalToolsBox.appendChild(checkbox);
} }
@ -70,11 +97,11 @@ function setupToolsList() {
additionalToolsBox.previousSibling.style.display = "none"; additionalToolsBox.previousSibling.style.display = "none";
} }
window.focus(); this.panelWin.focus();
} },
function populatePreferences() { populatePreferences: function OP_populatePreferences() {
let prefCheckboxes = document.querySelectorAll("checkbox[data-pref]"); let prefCheckboxes = this.panelDoc.querySelectorAll("checkbox[data-pref]");
for (let checkbox of prefCheckboxes) { for (let checkbox of prefCheckboxes) {
checkbox.checked = Services.prefs.getBoolPref(checkbox.getAttribute("data-pref")); checkbox.checked = Services.prefs.getBoolPref(checkbox.getAttribute("data-pref"));
checkbox.addEventListener("command", function() { checkbox.addEventListener("command", function() {
@ -87,7 +114,7 @@ function populatePreferences() {
gDevTools.emit("pref-changed", data); gDevTools.emit("pref-changed", data);
}.bind(checkbox)); }.bind(checkbox));
} }
let prefRadiogroups = document.querySelectorAll("radiogroup[data-pref]"); let prefRadiogroups = this.panelDoc.querySelectorAll("radiogroup[data-pref]");
for (let radiogroup of prefRadiogroups) { for (let radiogroup of prefRadiogroups) {
let selectedValue = Services.prefs.getCharPref(radiogroup.getAttribute("data-pref")); let selectedValue = Services.prefs.getCharPref(radiogroup.getAttribute("data-pref"));
for (let radio of radiogroup.childNodes) { for (let radio of radiogroup.childNodes) {
@ -107,4 +134,9 @@ function populatePreferences() {
gDevTools.emit("pref-changed", data); gDevTools.emit("pref-changed", data);
}.bind(radiogroup)); }.bind(radiogroup));
} }
} },
destroy: function OP_destroy() {
this.panelWin = this.panelDoc = null;
}
};

Просмотреть файл

@ -11,7 +11,6 @@
<?xml-stylesheet rel="stylesheet" href="chrome://browser/skin/devtools/toolbox.css" type="text/css"?> <?xml-stylesheet rel="stylesheet" href="chrome://browser/skin/devtools/toolbox.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript;version=1.8" src="toolbox-options.js"></script>
<hbox id="options-panel-container" flex="1"> <hbox id="options-panel-container" flex="1">
<hbox id="options-panel" flex="1"> <hbox id="options-panel" flex="1">
<vbox id="tools-box" class="options-vertical-pane" flex="1"> <vbox id="tools-box" class="options-vertical-pane" flex="1">

Просмотреть файл

@ -220,14 +220,6 @@ Toolbox.prototype = {
}, },
_buildOptions: function TBOX__buildOptions() { _buildOptions: function TBOX__buildOptions() {
this.optionsButton = this.doc.getElementById("toolbox-tab-options");
this.optionsButton.addEventListener("command", function() {
this.selectTool("options");
}.bind(this), false);
let iframe = this.doc.getElementById("toolbox-panel-iframe-options");
this._toolPanels.set("options", iframe);
let key = this.doc.getElementById("toolbox-options-key"); let key = this.doc.getElementById("toolbox-options-key");
key.addEventListener("command", function(toolId) { key.addEventListener("command", function(toolId) {
this.selectTool(toolId); this.selectTool(toolId);
@ -358,7 +350,6 @@ Toolbox.prototype = {
let radio = this.doc.createElement("radio"); let radio = this.doc.createElement("radio");
radio.className = "toolbox-tab devtools-tab"; radio.className = "toolbox-tab devtools-tab";
radio.id = "toolbox-tab-" + id; radio.id = "toolbox-tab-" + id;
radio.setAttribute("flex", "1");
radio.setAttribute("toolid", id); radio.setAttribute("toolid", id);
if (toolDefinition.ordinal == undefined || toolDefinition.ordinal < 0) { if (toolDefinition.ordinal == undefined || toolDefinition.ordinal < 0) {
toolDefinition.ordinal = MAX_ORDINAL; toolDefinition.ordinal = MAX_ORDINAL;
@ -376,16 +367,19 @@ Toolbox.prototype = {
radio.appendChild(image); radio.appendChild(image);
} }
if (toolDefinition.label) {
let label = this.doc.createElement("label"); let label = this.doc.createElement("label");
label.setAttribute("value", toolDefinition.label) label.setAttribute("value", toolDefinition.label)
label.setAttribute("crop", "end"); label.setAttribute("crop", "end");
label.setAttribute("flex", "1"); label.setAttribute("flex", "1");
radio.appendChild(label);
radio.setAttribute("flex", "1");
}
let vbox = this.doc.createElement("vbox"); let vbox = this.doc.createElement("vbox");
vbox.className = "toolbox-panel"; vbox.className = "toolbox-panel";
vbox.id = "toolbox-panel-" + id; vbox.id = "toolbox-panel-" + id;
radio.appendChild(label);
// If there is no tab yet, or the ordinal to be added is the largest one. // If there is no tab yet, or the ordinal to be added is the largest one.
if (tabs.childNodes.length == 0 || if (tabs.childNodes.length == 0 ||
@ -398,8 +392,7 @@ Toolbox.prototype = {
Array.some(tabs.childNodes, (node, i) => { Array.some(tabs.childNodes, (node, i) => {
if (+node.getAttribute("ordinal") > toolDefinition.ordinal) { if (+node.getAttribute("ordinal") > toolDefinition.ordinal) {
tabs.insertBefore(radio, node); tabs.insertBefore(radio, node);
deck.insertBefore(vbox, deck.childNodes[i + 1]); deck.insertBefore(vbox, deck.childNodes[i]);
// + 1 because of options panel.
return true; return true;
} }
}); });
@ -440,8 +433,9 @@ Toolbox.prototype = {
let tabstrip = this.doc.getElementById("toolbox-tabs"); let tabstrip = this.doc.getElementById("toolbox-tabs");
// select the right tab // select the right tab, making 0th index the default tab if right tab not
let index = -1; // found
let index = 0;
let tabs = tabstrip.childNodes; let tabs = tabstrip.childNodes;
for (let i = 0; i < tabs.length; i++) { for (let i = 0; i < tabs.length; i++) {
if (tabs[i] === tab) { if (tabs[i] === tab) {
@ -453,15 +447,7 @@ Toolbox.prototype = {
// and select the right iframe // and select the right iframe
let deck = this.doc.getElementById("toolbox-deck"); let deck = this.doc.getElementById("toolbox-deck");
// offset by 1 due to options panel deck.selectedIndex = index;
if (id == "options") {
deck.selectedIndex = 0;
this.optionsButton.setAttribute("checked", true);
}
else {
deck.selectedIndex = index != -1 ? index + 1: -1;
this.optionsButton.removeAttribute("checked");
}
let definition = gDevTools.getToolDefinitionMap().get(id); let definition = gDevTools.getToolDefinitionMap().get(id);
@ -668,7 +654,7 @@ Toolbox.prototype = {
if (this.hostType == Toolbox.HostType.WINDOW) { if (this.hostType == Toolbox.HostType.WINDOW) {
let doc = this.doc.defaultView.parent.document; let doc = this.doc.defaultView.parent.document;
let key = doc.getElementById("key_" + id); let key = doc.getElementById("key_" + toolId);
if (key) { if (key) {
key.parentNode.removeChild(key); key.parentNode.removeChild(key);
} }
@ -709,7 +695,6 @@ Toolbox.prototype = {
let outstanding = []; let outstanding = [];
this._toolPanels.delete("options");
for (let [id, panel] of this._toolPanels) { for (let [id, panel] of this._toolPanels) {
outstanding.push(panel.destroy()); outstanding.push(panel.destroy());
} }

Просмотреть файл

@ -34,10 +34,6 @@
<hbox id="toolbox-dock-buttons"/> <hbox id="toolbox-dock-buttons"/>
</hbox> </hbox>
#endif #endif
<toolbarbutton id="toolbox-tab-options"
autocheck="false"
class="command-button toolbox-tab devtools-tab"
tooltiptext="&toolboxOptionsButton.tooltip;"/>
<hbox id="toolbox-tabs" flex="1"> <hbox id="toolbox-tabs" flex="1">
</hbox> </hbox>
<hbox id="toolbox-buttons" pack="end"/> <hbox id="toolbox-buttons" pack="end"/>
@ -51,14 +47,6 @@
#endif #endif
</toolbar> </toolbar>
<deck id="toolbox-deck" flex="1"> <deck id="toolbox-deck" flex="1">
<vbox id="toolbox-panel-options"
class="toolbox-panel">
<iframe id="toolbox-panel-iframe-options"
class="toolbox-panel-iframe"
flex="1" forceOwnRefreshDriver=""
src="chrome://browser/content/devtools/framework/toolbox-options.xul">
</iframe>
</vbox>
</deck> </deck>
</notificationbox> </notificationbox>
</window> </window>

Просмотреть файл

@ -29,6 +29,7 @@ Object.defineProperty(exports, "TargetFactory", {
loader.lazyGetter(this, "osString", () => Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS); loader.lazyGetter(this, "osString", () => Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS);
// Panels // Panels
loader.lazyGetter(this, "OptionsPanel", function() require("devtools/framework/toolbox-options").OptionsPanel);
loader.lazyGetter(this, "InspectorPanel", function() require("devtools/inspector/inspector-panel").InspectorPanel); loader.lazyGetter(this, "InspectorPanel", function() require("devtools/inspector/inspector-panel").InspectorPanel);
loader.lazyImporter(this, "WebConsolePanel", "resource:///modules/WebConsolePanel.jsm"); loader.lazyImporter(this, "WebConsolePanel", "resource:///modules/WebConsolePanel.jsm");
loader.lazyImporter(this, "DebuggerPanel", "resource:///modules/devtools/DebuggerPanel.jsm"); loader.lazyImporter(this, "DebuggerPanel", "resource:///modules/devtools/DebuggerPanel.jsm");
@ -37,12 +38,14 @@ loader.lazyImporter(this, "ProfilerPanel", "resource:///modules/devtools/Profile
loader.lazyImporter(this, "NetMonitorPanel", "resource:///modules/devtools/NetMonitorPanel.jsm"); loader.lazyImporter(this, "NetMonitorPanel", "resource:///modules/devtools/NetMonitorPanel.jsm");
// Strings // Strings
const toolboxProps = "chrome://browser/locale/devtools/toolbox.properties";
const inspectorProps = "chrome://browser/locale/devtools/inspector.properties"; const inspectorProps = "chrome://browser/locale/devtools/inspector.properties";
const debuggerProps = "chrome://browser/locale/devtools/debugger.properties"; const debuggerProps = "chrome://browser/locale/devtools/debugger.properties";
const styleEditorProps = "chrome://browser/locale/devtools/styleeditor.properties"; const styleEditorProps = "chrome://browser/locale/devtools/styleeditor.properties";
const webConsoleProps = "chrome://browser/locale/devtools/webconsole.properties"; const webConsoleProps = "chrome://browser/locale/devtools/webconsole.properties";
const profilerProps = "chrome://browser/locale/devtools/profiler.properties"; const profilerProps = "chrome://browser/locale/devtools/profiler.properties";
const netMonitorProps = "chrome://browser/locale/devtools/netmonitor.properties"; const netMonitorProps = "chrome://browser/locale/devtools/netmonitor.properties";
loader.lazyGetter(this, "toolboxStrings", () => Services.strings.createBundle(toolboxProps));
loader.lazyGetter(this, "webConsoleStrings", () => Services.strings.createBundle(webConsoleProps)); loader.lazyGetter(this, "webConsoleStrings", () => Services.strings.createBundle(webConsoleProps));
loader.lazyGetter(this, "debuggerStrings", () => Services.strings.createBundle(debuggerProps)); loader.lazyGetter(this, "debuggerStrings", () => Services.strings.createBundle(debuggerProps));
loader.lazyGetter(this, "styleEditorStrings", () => Services.strings.createBundle(styleEditorProps)); loader.lazyGetter(this, "styleEditorStrings", () => Services.strings.createBundle(styleEditorProps));
@ -54,12 +57,27 @@ let Tools = {};
exports.Tools = Tools; exports.Tools = Tools;
// Definitions // Definitions
Tools.options = {
id: "options",
ordinal: 0,
url: "chrome://browser/content/devtools/framework/toolbox-options.xul",
icon: "chrome://browser/skin/devtools/tool-options.png",
tooltip: l10n("optionsButton.tooltip", toolboxStrings),
isTargetSupported: function(target) {
return true;
},
build: function(iframeWindow, toolbox) {
let panel = new OptionsPanel(iframeWindow, toolbox);
return panel.open();
}
}
Tools.webConsole = { Tools.webConsole = {
id: "webconsole", id: "webconsole",
key: l10n("cmd.commandkey", webConsoleStrings), key: l10n("cmd.commandkey", webConsoleStrings),
accesskey: l10n("webConsoleCmd.accesskey", webConsoleStrings), accesskey: l10n("webConsoleCmd.accesskey", webConsoleStrings),
modifiers: Services.appinfo.OS == "Darwin" ? "accel,alt" : "accel,shift", modifiers: Services.appinfo.OS == "Darwin" ? "accel,alt" : "accel,shift",
ordinal: 0, ordinal: 1,
icon: "chrome://browser/skin/devtools/tool-webconsole.png", icon: "chrome://browser/skin/devtools/tool-webconsole.png",
url: "chrome://browser/content/devtools/webconsole.xul", url: "chrome://browser/content/devtools/webconsole.xul",
label: l10n("ToolboxWebconsole.label", webConsoleStrings), label: l10n("ToolboxWebconsole.label", webConsoleStrings),
@ -74,33 +92,11 @@ Tools.webConsole = {
} }
}; };
Tools.jsdebugger = {
id: "jsdebugger",
key: l10n("open.commandkey", debuggerStrings),
accesskey: l10n("debuggerMenu.accesskey", debuggerStrings),
modifiers: osString == "Darwin" ? "accel,alt" : "accel,shift",
ordinal: 2,
killswitch: "devtools.debugger.enabled",
icon: "chrome://browser/skin/devtools/tool-debugger.png",
url: "chrome://browser/content/devtools/debugger.xul",
label: l10n("ToolboxDebugger.label", debuggerStrings),
tooltip: l10n("ToolboxDebugger.tooltip", debuggerStrings),
isTargetSupported: function(target) {
return true;
},
build: function(iframeWindow, toolbox) {
let panel = new DebuggerPanel(iframeWindow, toolbox);
return panel.open();
}
};
Tools.inspector = { Tools.inspector = {
id: "inspector", id: "inspector",
accesskey: l10n("inspector.accesskey", inspectorStrings), accesskey: l10n("inspector.accesskey", inspectorStrings),
key: l10n("inspector.commandkey", inspectorStrings), key: l10n("inspector.commandkey", inspectorStrings),
ordinal: 1, ordinal: 2,
modifiers: osString == "Darwin" ? "accel,alt" : "accel,shift", modifiers: osString == "Darwin" ? "accel,alt" : "accel,shift",
icon: "chrome://browser/skin/devtools/tool-inspector.png", icon: "chrome://browser/skin/devtools/tool-inspector.png",
url: "chrome://browser/content/devtools/inspector/inspector.xul", url: "chrome://browser/content/devtools/inspector/inspector.xul",
@ -117,10 +113,32 @@ Tools.inspector = {
} }
}; };
Tools.jsdebugger = {
id: "jsdebugger",
key: l10n("open.commandkey", debuggerStrings),
accesskey: l10n("debuggerMenu.accesskey", debuggerStrings),
modifiers: osString == "Darwin" ? "accel,alt" : "accel,shift",
ordinal: 3,
visibilityswitch: "devtools.debugger.enabled",
icon: "chrome://browser/skin/devtools/tool-debugger.png",
url: "chrome://browser/content/devtools/debugger.xul",
label: l10n("ToolboxDebugger.label", debuggerStrings),
tooltip: l10n("ToolboxDebugger.tooltip", debuggerStrings),
isTargetSupported: function(target) {
return true;
},
build: function(iframeWindow, toolbox) {
let panel = new DebuggerPanel(iframeWindow, toolbox);
return panel.open();
}
};
Tools.styleEditor = { Tools.styleEditor = {
id: "styleeditor", id: "styleeditor",
key: l10n("open.commandkey", styleEditorStrings), key: l10n("open.commandkey", styleEditorStrings),
ordinal: 3, ordinal: 4,
accesskey: l10n("open.accesskey", styleEditorStrings), accesskey: l10n("open.accesskey", styleEditorStrings),
modifiers: "shift", modifiers: "shift",
icon: "chrome://browser/skin/devtools/tool-styleeditor.png", icon: "chrome://browser/skin/devtools/tool-styleeditor.png",
@ -142,9 +160,9 @@ Tools.jsprofiler = {
id: "jsprofiler", id: "jsprofiler",
accesskey: l10n("profiler.accesskey", profilerStrings), accesskey: l10n("profiler.accesskey", profilerStrings),
key: l10n("profiler2.commandkey", profilerStrings), key: l10n("profiler2.commandkey", profilerStrings),
ordinal: 4, ordinal: 5,
modifiers: "shift", modifiers: "shift",
killswitch: "devtools.profiler.enabled", visibilityswitch: "devtools.profiler.enabled",
icon: "chrome://browser/skin/devtools/tool-profiler.png", icon: "chrome://browser/skin/devtools/tool-profiler.png",
url: "chrome://browser/content/devtools/profiler.xul", url: "chrome://browser/content/devtools/profiler.xul",
label: l10n("profiler.label", profilerStrings), label: l10n("profiler.label", profilerStrings),
@ -164,9 +182,9 @@ Tools.netMonitor = {
id: "netmonitor", id: "netmonitor",
accesskey: l10n("netmonitor.accesskey", netMonitorStrings), accesskey: l10n("netmonitor.accesskey", netMonitorStrings),
key: l10n("netmonitor.commandkey", netMonitorStrings), key: l10n("netmonitor.commandkey", netMonitorStrings),
ordinal: 5, ordinal: 6,
modifiers: osString == "Darwin" ? "accel,alt" : "accel,shift", modifiers: osString == "Darwin" ? "accel,alt" : "accel,shift",
killswitch: "devtools.netmonitor.enabled", visibilityswitch: "devtools.netmonitor.enabled",
icon: "chrome://browser/skin/devtools/tool-profiler.png", icon: "chrome://browser/skin/devtools/tool-profiler.png",
url: "chrome://browser/content/devtools/netmonitor.xul", url: "chrome://browser/content/devtools/netmonitor.xul",
label: l10n("netmonitor.label", netMonitorStrings), label: l10n("netmonitor.label", netMonitorStrings),
@ -183,6 +201,7 @@ Tools.netMonitor = {
}; };
let defaultTools = [ let defaultTools = [
Tools.options,
Tools.styleEditor, Tools.styleEditor,
Tools.webConsole, Tools.webConsole,
Tools.jsdebugger, Tools.jsdebugger,
@ -201,7 +220,7 @@ var unloadObserver = {
observe: function(subject, topic, data) { observe: function(subject, topic, data) {
if (subject.wrappedJSObject === require("@loader/unload")) { if (subject.wrappedJSObject === require("@loader/unload")) {
Services.obs.removeObserver(unloadObserver, "sdk:loader:destroy"); Services.obs.removeObserver(unloadObserver, "sdk:loader:destroy");
for (let definition of defaultTools) { for (let definition of gDevTools.getToolDefinitionArray()) {
gDevTools.unregisterTool(definition.id); gDevTools.unregisterTool(definition.id);
} }
} }

Просмотреть файл

@ -8,7 +8,6 @@
<!ENTITY closeCmd.key "W"> <!ENTITY closeCmd.key "W">
<!ENTITY toolboxCloseButton.tooltip "Close Developer Tools"> <!ENTITY toolboxCloseButton.tooltip "Close Developer Tools">
<!ENTITY toolboxOptionsButton.tooltip "Toggle Options Panel">
<!ENTITY toolboxOptionsButton.key "O"> <!ENTITY toolboxOptionsButton.key "O">
<!-- LOCALIZATION NOTE (options.context.label): This is the label for the <!-- LOCALIZATION NOTE (options.context.label): This is the label for the

Просмотреть файл

@ -34,3 +34,7 @@ toolbox.titleTemplate=%1$S - %2$S
# LOCALIZATION NOTE (toolbox.defaultTitle): This is used as the tool # LOCALIZATION NOTE (toolbox.defaultTitle): This is used as the tool
# name when no tool is selected. # name when no tool is selected.
toolbox.defaultTitle=Developer Tools toolbox.defaultTitle=Developer Tools
# LOCALIZATION NOTE (optionsButton.tooltip): This is used as the tooltip
# for the optiosn panel tab.
optionsButton.tooltip=Toolbox Options

Двоичные данные
browser/themes/linux/devtools/tool-options.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 931 B

Просмотреть файл

@ -128,20 +128,6 @@
-moz-image-region: rect(0px, 48px, 16px, 32px); -moz-image-region: rect(0px, 48px, 16px, 32px);
} }
#toolbox-tab-options {
list-style-image: url("chrome://browser/skin/devtools/option-icon.png");
-moz-image-region: rect(0px 16px 16px 0px);
}
#toolbox-tab-options[checked=true] {
-moz-image-region: rect(0px 32px 16px 16px);
}
#toolbox-tab-options > image {
opacity: 1;
-moz-margin-start: 0;
}
/* Tabs */ /* Tabs */
.devtools-tabbar { .devtools-tabbar {

Просмотреть файл

@ -201,6 +201,7 @@ browser.jar:
skin/classic/browser/devtools/floating-scrollbars-light.css (devtools/floating-scrollbars-light.css) skin/classic/browser/devtools/floating-scrollbars-light.css (devtools/floating-scrollbars-light.css)
skin/classic/browser/devtools/inspector.css (devtools/inspector.css) skin/classic/browser/devtools/inspector.css (devtools/inspector.css)
skin/classic/browser/devtools/toolbox.css (devtools/toolbox.css) skin/classic/browser/devtools/toolbox.css (devtools/toolbox.css)
skin/classic/browser/devtools/tool-options.png (devtools/tool-options.png)
skin/classic/browser/devtools/tool-webconsole.png (devtools/tool-webconsole.png) skin/classic/browser/devtools/tool-webconsole.png (devtools/tool-webconsole.png)
skin/classic/browser/devtools/tool-debugger.png (devtools/tool-debugger.png) skin/classic/browser/devtools/tool-debugger.png (devtools/tool-debugger.png)
skin/classic/browser/devtools/tool-inspector.png (devtools/tool-inspector.png) skin/classic/browser/devtools/tool-inspector.png (devtools/tool-inspector.png)

Двоичные данные
browser/themes/osx/devtools/tool-options.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 931 B

Просмотреть файл

@ -116,21 +116,6 @@
-moz-image-region: rect(0px, 48px, 16px, 32px); -moz-image-region: rect(0px, 48px, 16px, 32px);
} }
#toolbox-tab-options {
list-style-image: url("chrome://browser/skin/devtools/option-icon.png");
-moz-image-region: rect(0px 16px 16px 0px);
border-left: 1px solid hsla(206,37%,4%,.45);
}
#toolbox-tab-options[checked=true] {
-moz-image-region: rect(0px 32px 16px 16px);
}
#toolbox-tab-options > image {
opacity: 1;
-moz-margin-start: 0;
}
/* Tabs */ /* Tabs */
.devtools-tabbar { .devtools-tabbar {
@ -148,6 +133,7 @@
#toolbox-tabs { #toolbox-tabs {
margin: 0; margin: 0;
border-left: 1px solid hsla(206,37%,4%,.45);
} }
.devtools-tab { .devtools-tab {

Просмотреть файл

@ -292,6 +292,7 @@ browser.jar:
skin/classic/browser/devtools/floating-scrollbars-light.css (devtools/floating-scrollbars-light.css) skin/classic/browser/devtools/floating-scrollbars-light.css (devtools/floating-scrollbars-light.css)
* skin/classic/browser/devtools/inspector.css (devtools/inspector.css) * skin/classic/browser/devtools/inspector.css (devtools/inspector.css)
skin/classic/browser/devtools/toolbox.css (devtools/toolbox.css) skin/classic/browser/devtools/toolbox.css (devtools/toolbox.css)
skin/classic/browser/devtools/tool-options.png (devtools/tool-options.png)
skin/classic/browser/devtools/tool-webconsole.png (devtools/tool-webconsole.png) skin/classic/browser/devtools/tool-webconsole.png (devtools/tool-webconsole.png)
skin/classic/browser/devtools/tool-debugger.png (devtools/tool-debugger.png) skin/classic/browser/devtools/tool-debugger.png (devtools/tool-debugger.png)
skin/classic/browser/devtools/tool-inspector.png (devtools/tool-inspector.png) skin/classic/browser/devtools/tool-inspector.png (devtools/tool-inspector.png)

Двоичные данные
browser/themes/windows/devtools/tool-options.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 931 B

Просмотреть файл

@ -131,20 +131,6 @@
-moz-image-region: rect(0px, 48px, 16px, 32px); -moz-image-region: rect(0px, 48px, 16px, 32px);
} }
#toolbox-tab-options {
list-style-image: url("chrome://browser/skin/devtools/option-icon.png");
-moz-image-region: rect(0px 16px 16px 0px);
}
#toolbox-tab-options[checked=true] {
-moz-image-region: rect(0px 32px 16px 16px);
}
#toolbox-tab-options > image {
opacity: 1;
-moz-margin-start: 0;
}
/* Tabs */ /* Tabs */
.devtools-tabbar { .devtools-tabbar {

Просмотреть файл

@ -229,6 +229,7 @@ browser.jar:
skin/classic/browser/devtools/floating-scrollbars-light.css (devtools/floating-scrollbars-light.css) skin/classic/browser/devtools/floating-scrollbars-light.css (devtools/floating-scrollbars-light.css)
skin/classic/browser/devtools/inspector.css (devtools/inspector.css) skin/classic/browser/devtools/inspector.css (devtools/inspector.css)
skin/classic/browser/devtools/toolbox.css (devtools/toolbox.css) skin/classic/browser/devtools/toolbox.css (devtools/toolbox.css)
skin/classic/browser/devtools/tool-options.png (devtools/tool-options.png)
skin/classic/browser/devtools/tool-webconsole.png (devtools/tool-webconsole.png) skin/classic/browser/devtools/tool-webconsole.png (devtools/tool-webconsole.png)
skin/classic/browser/devtools/tool-debugger.png (devtools/tool-debugger.png) skin/classic/browser/devtools/tool-debugger.png (devtools/tool-debugger.png)
skin/classic/browser/devtools/tool-inspector.png (devtools/tool-inspector.png) skin/classic/browser/devtools/tool-inspector.png (devtools/tool-inspector.png)
@ -479,6 +480,7 @@ browser.jar:
skin/classic/aero/browser/devtools/floating-scrollbars-light.css (devtools/floating-scrollbars-light.css) skin/classic/aero/browser/devtools/floating-scrollbars-light.css (devtools/floating-scrollbars-light.css)
skin/classic/aero/browser/devtools/inspector.css (devtools/inspector.css) skin/classic/aero/browser/devtools/inspector.css (devtools/inspector.css)
skin/classic/aero/browser/devtools/toolbox.css (devtools/toolbox.css) skin/classic/aero/browser/devtools/toolbox.css (devtools/toolbox.css)
skin/classic/aero/browser/devtools/tool-options.png (devtools/tool-options.png)
skin/classic/aero/browser/devtools/tool-webconsole.png (devtools/tool-webconsole.png) skin/classic/aero/browser/devtools/tool-webconsole.png (devtools/tool-webconsole.png)
skin/classic/aero/browser/devtools/tool-debugger.png (devtools/tool-debugger.png) skin/classic/aero/browser/devtools/tool-debugger.png (devtools/tool-debugger.png)
skin/classic/aero/browser/devtools/tool-inspector.png (devtools/tool-inspector.png) skin/classic/aero/browser/devtools/tool-inspector.png (devtools/tool-inspector.png)