mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 09:45:41 +00:00
Bug 1268450 - Convert toolbox key shortcut to stop using XUL. r=jryans
This commit is contained in:
parent
866de622fc
commit
c77bd1981b
@ -10,6 +10,8 @@
|
||||
const URL = "data:text/html;charset=utf8,test page";
|
||||
|
||||
var {Toolbox} = require("devtools/client/framework/toolbox");
|
||||
var strings = Services.strings.createBundle(
|
||||
"chrome://devtools/locale/toolbox.properties");
|
||||
|
||||
add_task(function* () {
|
||||
info("Create a test tab and open the toolbox");
|
||||
@ -33,26 +35,26 @@ add_task(function* () {
|
||||
});
|
||||
|
||||
function zoomWithKey(toolbox, key) {
|
||||
if (!key) {
|
||||
let shortcut = strings.GetStringFromName(key);
|
||||
if (!shortcut) {
|
||||
info("Key was empty, skipping zoomWithKey");
|
||||
return;
|
||||
}
|
||||
|
||||
info("Zooming with key: " + key);
|
||||
let currentZoom = toolbox.zoomValue;
|
||||
EventUtils.synthesizeKey(key, {accelKey: true}, toolbox.win);
|
||||
synthesizeKeyShortcut(shortcut);
|
||||
isnot(toolbox.zoomValue, currentZoom, "The zoom level was changed in the toolbox");
|
||||
}
|
||||
|
||||
function* checkKeyBindings(toolbox) {
|
||||
zoomWithKey(toolbox, toolbox.doc.getElementById("toolbox-zoom-in-key").getAttribute("key"));
|
||||
zoomWithKey(toolbox, toolbox.doc.getElementById("toolbox-zoom-in-key2").getAttribute("key"));
|
||||
zoomWithKey(toolbox, toolbox.doc.getElementById("toolbox-zoom-in-key3").getAttribute("key"));
|
||||
zoomWithKey(toolbox, "toolbox.zoomIn.key");
|
||||
zoomWithKey(toolbox, "toolbox.zoomIn2.key");
|
||||
zoomWithKey(toolbox, "toolbox.zoomIn3.key");
|
||||
|
||||
zoomWithKey(toolbox, toolbox.doc.getElementById("toolbox-zoom-reset-key").getAttribute("key"));
|
||||
zoomWithKey(toolbox, "toolbox.zoomReset.key");
|
||||
|
||||
zoomWithKey(toolbox, toolbox.doc.getElementById("toolbox-zoom-out-key").getAttribute("key"));
|
||||
zoomWithKey(toolbox, toolbox.doc.getElementById("toolbox-zoom-out-key2").getAttribute("key"));
|
||||
zoomWithKey(toolbox, "toolbox.zoomOut.key");
|
||||
zoomWithKey(toolbox, "toolbox.zoomOut2.key");
|
||||
|
||||
zoomWithKey(toolbox, toolbox.doc.getElementById("toolbox-zoom-reset-key2").getAttribute("key"));
|
||||
zoomWithKey(toolbox, "toolbox.zoomReset2.key");
|
||||
}
|
||||
|
@ -11,6 +11,8 @@
|
||||
const URL = "data:text/html;charset=utf8,test page for toolbox switching";
|
||||
|
||||
var {Toolbox} = require("devtools/client/framework/toolbox");
|
||||
var strings = Services.strings.createBundle(
|
||||
"chrome://devtools/locale/toolbox.properties");
|
||||
|
||||
add_task(function* () {
|
||||
info("Create a test tab and open the toolbox");
|
||||
@ -18,19 +20,21 @@ add_task(function* () {
|
||||
let target = TargetFactory.forTab(tab);
|
||||
let toolbox = yield gDevTools.showToolbox(target, "webconsole");
|
||||
|
||||
let keyElement = toolbox.doc.getElementById("toolbox-toggle-host-key");
|
||||
let shortcut = strings.GetStringFromName("toolbox.toggleHost.key");
|
||||
|
||||
let {SIDE, BOTTOM, WINDOW} = Toolbox.HostType;
|
||||
checkHostType(toolbox, BOTTOM, SIDE);
|
||||
|
||||
info("Switching from bottom to side");
|
||||
synthesizeKeyElement(keyElement);
|
||||
yield toolbox.once("host-changed");
|
||||
let onHostChanged = toolbox.once("host-changed");
|
||||
synthesizeKeyShortcut(shortcut, toolbox.win);
|
||||
yield onHostChanged;
|
||||
checkHostType(toolbox, SIDE, BOTTOM);
|
||||
|
||||
info("Switching from side to bottom");
|
||||
synthesizeKeyElement(keyElement);
|
||||
yield toolbox.once("host-changed");
|
||||
onHostChanged = toolbox.once("host-changed");
|
||||
synthesizeKeyShortcut(shortcut, toolbox.win);
|
||||
yield onHostChanged;
|
||||
checkHostType(toolbox, BOTTOM, SIDE);
|
||||
|
||||
info("Switching to window");
|
||||
@ -38,8 +42,9 @@ add_task(function* () {
|
||||
checkHostType(toolbox, WINDOW, BOTTOM);
|
||||
|
||||
info("Switching from window to bottom");
|
||||
synthesizeKeyElement(keyElement);
|
||||
yield toolbox.once("host-changed");
|
||||
onHostChanged = toolbox.once("host-changed");
|
||||
synthesizeKeyShortcut(shortcut, toolbox.win);
|
||||
yield onHostChanged;
|
||||
checkHostType(toolbox, BOTTOM, WINDOW);
|
||||
|
||||
yield toolbox.destroy();
|
||||
|
@ -10,6 +10,8 @@
|
||||
// and toggles appropriate things in the toolbox.
|
||||
|
||||
var doc = null, toolbox = null, panelWin = null, modifiedPrefs = [];
|
||||
var strings = Services.strings.createBundle(
|
||||
"chrome://devtools/locale/toolbox.properties");
|
||||
|
||||
add_task(function* () {
|
||||
const URL = "data:text/html;charset=utf8,test for dynamically registering " +
|
||||
@ -58,18 +60,18 @@ function* testOptionsShortcut() {
|
||||
|
||||
yield toolbox.selectTool("webconsole");
|
||||
is(toolbox.currentToolId, "webconsole", "webconsole is selected");
|
||||
synthesizeKeyFromKeyTag(doc.getElementById("toolbox-options-key"));
|
||||
synthesizeKeyShortcut(strings.GetStringFromName("toolbox.options.key"));
|
||||
is(toolbox.currentToolId, "options", "Toolbox selected via shortcut key (1)");
|
||||
synthesizeKeyFromKeyTag(doc.getElementById("toolbox-options-key"));
|
||||
synthesizeKeyShortcut(strings.GetStringFromName("toolbox.options.key"));
|
||||
is(toolbox.currentToolId, "webconsole", "webconsole is selected (1)");
|
||||
|
||||
yield toolbox.selectTool("webconsole");
|
||||
is(toolbox.currentToolId, "webconsole", "webconsole is selected");
|
||||
synthesizeKeyFromKeyTag(doc.getElementById("toolbox-options-key2"));
|
||||
synthesizeKeyShortcut(strings.GetStringFromName("toolbox.help.key"));
|
||||
is(toolbox.currentToolId, "options", "Toolbox selected via shortcut key (2)");
|
||||
synthesizeKeyFromKeyTag(doc.getElementById("toolbox-options-key"));
|
||||
synthesizeKeyShortcut(strings.GetStringFromName("toolbox.options.key"));
|
||||
is(toolbox.currentToolId, "webconsole", "webconsole is reselected (2)");
|
||||
synthesizeKeyFromKeyTag(doc.getElementById("toolbox-options-key2"));
|
||||
synthesizeKeyShortcut(strings.GetStringFromName("toolbox.help.key"));
|
||||
is(toolbox.currentToolId, "options", "Toolbox selected via shortcut key (2)");
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
requestLongerTimeout(2);
|
||||
|
||||
var {Toolbox} = require("devtools/client/framework/toolbox");
|
||||
var strings = Services.strings.createBundle(
|
||||
"chrome://devtools/locale/toolbox.properties");
|
||||
|
||||
add_task(function* () {
|
||||
let tab = yield addTab("about:blank");
|
||||
@ -18,45 +20,43 @@ add_task(function* () {
|
||||
|
||||
let toolbox = yield gDevTools.showToolbox(target, toolIDs[0],
|
||||
Toolbox.HostType.BOTTOM);
|
||||
let nextKey = toolbox.doc.getElementById("toolbox-next-tool-key")
|
||||
.getAttribute("key");
|
||||
let prevKey = toolbox.doc.getElementById("toolbox-previous-tool-key")
|
||||
.getAttribute("key");
|
||||
let nextShortcut = strings.GetStringFromName("toolbox.nextTool.key")
|
||||
let prevShortcut = strings.GetStringFromName("toolbox.previousTool.key")
|
||||
|
||||
// Iterate over all tools, starting from options to netmonitor, in normal
|
||||
// order.
|
||||
for (let i = 1; i < toolIDs.length; i++) {
|
||||
yield testShortcuts(toolbox, i, nextKey, toolIDs);
|
||||
yield testShortcuts(toolbox, i, nextShortcut, toolIDs);
|
||||
}
|
||||
|
||||
// Iterate again, in the same order, starting from netmonitor (so next one is
|
||||
// 0: options).
|
||||
for (let i = 0; i < toolIDs.length; i++) {
|
||||
yield testShortcuts(toolbox, i, nextKey, toolIDs);
|
||||
yield testShortcuts(toolbox, i, nextShortcut, toolIDs);
|
||||
}
|
||||
|
||||
// Iterate over all tools in reverse order, starting from netmonitor to
|
||||
// options.
|
||||
for (let i = toolIDs.length - 2; i >= 0; i--) {
|
||||
yield testShortcuts(toolbox, i, prevKey, toolIDs);
|
||||
yield testShortcuts(toolbox, i, prevShortcut, toolIDs);
|
||||
}
|
||||
|
||||
// Iterate again, in reverse order again, starting from options (so next one
|
||||
// is length-1: netmonitor).
|
||||
for (let i = toolIDs.length - 1; i >= 0; i--) {
|
||||
yield testShortcuts(toolbox, i, prevKey, toolIDs);
|
||||
yield testShortcuts(toolbox, i, prevShortcut, toolIDs);
|
||||
}
|
||||
|
||||
yield toolbox.destroy();
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
function* testShortcuts(toolbox, index, key, toolIDs) {
|
||||
function* testShortcuts(toolbox, index, shortcut, toolIDs) {
|
||||
info("Testing shortcut to switch to tool " + index + ":" + toolIDs[index] +
|
||||
" using key " + key);
|
||||
" using shortcut " + shortcut);
|
||||
|
||||
let onToolSelected = toolbox.once("select");
|
||||
EventUtils.synthesizeKey(key, {accelKey: true}, toolbox.win);
|
||||
synthesizeKeyShortcut(shortcut);
|
||||
let id = yield onToolSelected;
|
||||
|
||||
info("toolbox-select event from " + id);
|
||||
|
@ -10,6 +10,8 @@ const TEST_URL = "data:text/html;charset=utf-8," +
|
||||
"<body><h1>Testing reload from devtools</h1></body></html>";
|
||||
|
||||
var {Toolbox} = require("devtools/client/framework/toolbox");
|
||||
var strings = Services.strings.createBundle(
|
||||
"chrome://devtools/locale/toolbox.properties");
|
||||
|
||||
var target, toolbox, description, reloadsSent, toolIDs;
|
||||
|
||||
@ -60,10 +62,10 @@ function testAllTheTools(docked, callback, toolNum = 0) {
|
||||
return callback();
|
||||
}
|
||||
toolbox.selectTool(toolIDs[toolNum]).then(() => {
|
||||
testReload("toolbox-reload-key", docked, toolIDs[toolNum], () => {
|
||||
testReload("toolbox-reload-key2", docked, toolIDs[toolNum], () => {
|
||||
testReload("toolbox-force-reload-key", docked, toolIDs[toolNum], () => {
|
||||
testReload("toolbox-force-reload-key2", docked, toolIDs[toolNum], () => {
|
||||
testReload("toolbox.reload.key", docked, toolIDs[toolNum], () => {
|
||||
testReload("toolbox.reload2.key", docked, toolIDs[toolNum], () => {
|
||||
testReload("toolbox.forceReload.key", docked, toolIDs[toolNum], () => {
|
||||
testReload("toolbox.forceReload2.key", docked, toolIDs[toolNum], () => {
|
||||
testAllTheTools(docked, callback, toolNum + 1);
|
||||
});
|
||||
});
|
||||
@ -72,17 +74,16 @@ function testAllTheTools(docked, callback, toolNum = 0) {
|
||||
});
|
||||
}
|
||||
|
||||
function testReload(key, docked, toolID, callback) {
|
||||
function testReload(shortcut, docked, toolID, callback) {
|
||||
let complete = () => {
|
||||
gBrowser.selectedBrowser.messageManager.removeMessageListener("devtools:test:load", complete);
|
||||
return callback();
|
||||
};
|
||||
gBrowser.selectedBrowser.messageManager.addMessageListener("devtools:test:load", complete);
|
||||
|
||||
description = docked + " devtools with tool " + toolID + ", key #" + key;
|
||||
description = docked + " devtools with tool " + toolID + ", shortcut #" + shortcut;
|
||||
info("Testing reload in " + description);
|
||||
let el = toolbox.doc.getElementById(key);
|
||||
synthesizeKeyElement(el);
|
||||
synthesizeKeyShortcut(strings.GetStringFromName(shortcut), toolbox.win);
|
||||
reloadsSent++;
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,8 @@ var modifiers = {
|
||||
};
|
||||
|
||||
var toolbox;
|
||||
var strings = Services.strings.createBundle(
|
||||
"chrome://devtools/locale/toolbox.properties");
|
||||
|
||||
function test() {
|
||||
addTab("about:blank").then(openToolbox);
|
||||
@ -25,15 +27,15 @@ function openToolbox() {
|
||||
function testZoom() {
|
||||
info("testing zoom keys");
|
||||
|
||||
testZoomLevel("in", 2, 1.2);
|
||||
testZoomLevel("out", 3, 0.9);
|
||||
testZoomLevel("reset", 1, 1);
|
||||
testZoomLevel("In", 2, 1.2);
|
||||
testZoomLevel("Out", 3, 0.9);
|
||||
testZoomLevel("Reset", 1, 1);
|
||||
|
||||
tidyUp();
|
||||
}
|
||||
|
||||
function testZoomLevel(type, times, expected) {
|
||||
sendZoomKey("toolbox-zoom-" + type + "-key", times);
|
||||
sendZoomKey("toolbox.zoom" + type + ".key", times);
|
||||
|
||||
let zoom = getCurrentZoom(toolbox);
|
||||
is(zoom.toFixed(2), expected, "zoom level correct after zoom " + type);
|
||||
@ -42,10 +44,9 @@ function testZoomLevel(type, times, expected) {
|
||||
"saved zoom level is correct after zoom " + type);
|
||||
}
|
||||
|
||||
function sendZoomKey(id, times) {
|
||||
let key = toolbox.doc.getElementById(id).getAttribute("key");
|
||||
function sendZoomKey(shortcut, times) {
|
||||
for (let i = 0; i < times; i++) {
|
||||
EventUtils.synthesizeKey(key, modifiers, toolbox.win);
|
||||
synthesizeKeyShortcut(strings.GetStringFromName(shortcut));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,8 +168,10 @@ function synthesizeKeyFromKeyTag(key) {
|
||||
* https://github.com/electron/electron/blob/master/docs/api/accelerator.md
|
||||
*
|
||||
* @param {String} key
|
||||
* @param {DOMWindow} target
|
||||
* Optional window where to fire the key event
|
||||
*/
|
||||
function synthesizeKeyShortcut(key) {
|
||||
function synthesizeKeyShortcut(key, target) {
|
||||
// parseElectronKey requires any window, just to access `KeyboardEvent`
|
||||
let window = Services.appShell.hiddenDOMWindow;
|
||||
let shortcut = KeyShortcuts.parseElectronKey(window, key);
|
||||
@ -181,7 +183,7 @@ function synthesizeKeyShortcut(key) {
|
||||
ctrlKey: shortcut.ctrl,
|
||||
metaKey: shortcut.meta,
|
||||
shiftKey: shortcut.shift
|
||||
});
|
||||
}, target);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,6 +68,9 @@ loader.lazyRequireGetter(this, "system",
|
||||
"devtools/shared/system");
|
||||
loader.lazyRequireGetter(this, "getPreferenceFront",
|
||||
"devtools/server/actors/preference", true);
|
||||
loader.lazyRequireGetter(this, "KeyShortcuts",
|
||||
"devtools/client/shared/key-shortcuts", true);
|
||||
|
||||
loader.lazyGetter(this, "osString", () => {
|
||||
return Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS;
|
||||
});
|
||||
@ -417,19 +420,20 @@ Toolbox.prototype = {
|
||||
this.textboxContextMenuPopup.addEventListener("popupshowing",
|
||||
this._updateTextboxMenuItems, true);
|
||||
|
||||
var shortcuts = new KeyShortcuts({
|
||||
window: this.doc.defaultView
|
||||
});
|
||||
this._buildDockButtons();
|
||||
this._buildOptions();
|
||||
this._buildOptions(shortcuts);
|
||||
this._buildTabs();
|
||||
this._applyCacheSettings();
|
||||
this._applyServiceWorkersTestingSettings();
|
||||
this._addKeysToWindow();
|
||||
this._addReloadKeys();
|
||||
this._addHostListeners();
|
||||
this._addReloadKeys(shortcuts);
|
||||
this._addHostListeners(shortcuts);
|
||||
this._registerOverlays();
|
||||
if (this._hostOptions && this._hostOptions.zoom === false) {
|
||||
this._disableZoomKeys();
|
||||
} else {
|
||||
this._addZoomKeys();
|
||||
if (!this._hostOptions || this._hostOptions.zoom === true) {
|
||||
this._addZoomKeys(shortcuts);
|
||||
this._loadInitialZoom();
|
||||
}
|
||||
this._setToolbarKeyboardNavigation();
|
||||
@ -523,8 +527,8 @@ Toolbox.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
_buildOptions: function () {
|
||||
let selectOptions = () => {
|
||||
_buildOptions: function (shortcuts) {
|
||||
let selectOptions = (name, event) => {
|
||||
// Flip back to the last used panel if we are already
|
||||
// on the options panel.
|
||||
if (this.currentToolId === "options" &&
|
||||
@ -533,11 +537,11 @@ Toolbox.prototype = {
|
||||
} else {
|
||||
this.selectTool("options");
|
||||
}
|
||||
// Prevent the opening of bookmarks window on toolbox.options.key
|
||||
event.preventDefault();
|
||||
};
|
||||
let key = this.doc.getElementById("toolbox-options-key");
|
||||
key.addEventListener("command", selectOptions, true);
|
||||
let key2 = this.doc.getElementById("toolbox-options-key2");
|
||||
key2.addEventListener("command", selectOptions, true);
|
||||
shortcuts.on(toolboxStrings("toolbox.options.key"), selectOptions);
|
||||
shortcuts.on(toolboxStrings("toolbox.help.key"), selectOptions);
|
||||
},
|
||||
|
||||
_splitConsoleOnKeypress: function (e) {
|
||||
@ -551,6 +555,7 @@ Toolbox.prototype = {
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a shortcut key that should work when a split console
|
||||
* has focus to the toolbox.
|
||||
@ -574,34 +579,31 @@ Toolbox.prototype = {
|
||||
this.doc.getElementById("toolbox-keyset").appendChild(cloned);
|
||||
},
|
||||
|
||||
_addReloadKeys: function () {
|
||||
_addReloadKeys: function (shortcuts) {
|
||||
[
|
||||
["toolbox-reload-key", false],
|
||||
["toolbox-reload-key2", false],
|
||||
["toolbox-force-reload-key", true],
|
||||
["toolbox-force-reload-key2", true]
|
||||
["reload", false],
|
||||
["reload2", false],
|
||||
["forceReload", true],
|
||||
["forceReload2", true]
|
||||
].forEach(([id, force]) => {
|
||||
this.doc.getElementById(id).addEventListener("command", () => {
|
||||
this.reloadTarget(force);
|
||||
}, true);
|
||||
let key = toolboxStrings("toolbox." + id + ".key");
|
||||
shortcuts.on(key, this.reloadTarget.bind(this, force));
|
||||
});
|
||||
},
|
||||
|
||||
_addHostListeners: function () {
|
||||
let nextKey = this.doc.getElementById("toolbox-next-tool-key");
|
||||
nextKey.addEventListener("command", this.selectNextTool.bind(this), true);
|
||||
_addHostListeners: function (shortcuts) {
|
||||
shortcuts.on(toolboxStrings("toolbox.nextTool.key"),
|
||||
this.selectNextTool.bind(this));
|
||||
shortcuts.on(toolboxStrings("toolbox.previousTool.key"),
|
||||
this.selectPreviousTool.bind(this));
|
||||
shortcuts.on(toolboxStrings("toolbox.minimize.key"),
|
||||
this._toggleMinimizeMode.bind(this));
|
||||
shortcuts.on(toolboxStrings("toolbox.toggleHost.key"),
|
||||
(name, event) => {
|
||||
this.switchToPreviousHost();
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
let prevKey = this.doc.getElementById("toolbox-previous-tool-key");
|
||||
prevKey.addEventListener("command", this.selectPreviousTool.bind(this), true);
|
||||
|
||||
let minimizeKey = this.doc.getElementById("toolbox-minimize-key");
|
||||
minimizeKey.addEventListener("command", this._toggleMinimizeMode, true);
|
||||
|
||||
let toggleKey = this.doc.getElementById("toolbox-toggle-host-key");
|
||||
toggleKey.addEventListener("command", this.switchToPreviousHost.bind(this), true);
|
||||
|
||||
// Split console uses keypress instead of command so the event can be
|
||||
// cancelled with stopPropagation on the keypress, and not preventDefault.
|
||||
this.doc.addEventListener("keypress", this._splitConsoleOnKeypress, false);
|
||||
|
||||
this.doc.addEventListener("focus", this._onFocus, true);
|
||||
@ -653,50 +655,31 @@ Toolbox.prototype = {
|
||||
/**
|
||||
* Wire up the listeners for the zoom keys.
|
||||
*/
|
||||
_addZoomKeys: function () {
|
||||
let inKey = this.doc.getElementById("toolbox-zoom-in-key");
|
||||
inKey.addEventListener("command", this.zoomIn.bind(this), true);
|
||||
_addZoomKeys: function (shortcuts) {
|
||||
shortcuts.on(toolboxStrings("toolbox.zoomIn.key"),
|
||||
this.zoomIn.bind(this));
|
||||
let zoomIn2 = toolboxStrings("toolbox.zoomIn2.key");
|
||||
if (zoomIn2) {
|
||||
shortcuts.on(zoomIn2, this.zoomIn.bind(this));
|
||||
}
|
||||
let zoomIn3 = toolboxStrings("toolbox.zoomIn2.key");
|
||||
if (zoomIn3) {
|
||||
shortcuts.on(zoomIn3, this.zoomIn.bind(this));
|
||||
}
|
||||
|
||||
let inKey2 = this.doc.getElementById("toolbox-zoom-in-key2");
|
||||
inKey2.addEventListener("command", this.zoomIn.bind(this), true);
|
||||
shortcuts.on(toolboxStrings("toolbox.zoomOut.key"),
|
||||
this.zoomOut.bind(this));
|
||||
let zoomOut2 = toolboxStrings("toolbox.zoomOut2.key");
|
||||
if (zoomOut2) {
|
||||
shortcuts.on(zoomOut2, this.zoomOut.bind(this));
|
||||
}
|
||||
|
||||
let inKey3 = this.doc.getElementById("toolbox-zoom-in-key3");
|
||||
inKey3.addEventListener("command", this.zoomIn.bind(this), true);
|
||||
|
||||
let outKey = this.doc.getElementById("toolbox-zoom-out-key");
|
||||
outKey.addEventListener("command", this.zoomOut.bind(this), true);
|
||||
|
||||
let outKey2 = this.doc.getElementById("toolbox-zoom-out-key2");
|
||||
outKey2.addEventListener("command", this.zoomOut.bind(this), true);
|
||||
|
||||
let resetKey = this.doc.getElementById("toolbox-zoom-reset-key");
|
||||
resetKey.addEventListener("command", this.zoomReset.bind(this), true);
|
||||
|
||||
let resetKey2 = this.doc.getElementById("toolbox-zoom-reset-key2");
|
||||
resetKey2.addEventListener("command", this.zoomReset.bind(this), true);
|
||||
},
|
||||
|
||||
_disableZoomKeys: function () {
|
||||
let inKey = this.doc.getElementById("toolbox-zoom-in-key");
|
||||
inKey.setAttribute("disabled", "true");
|
||||
|
||||
let inKey2 = this.doc.getElementById("toolbox-zoom-in-key2");
|
||||
inKey2.setAttribute("disabled", "true");
|
||||
|
||||
let inKey3 = this.doc.getElementById("toolbox-zoom-in-key3");
|
||||
inKey3.setAttribute("disabled", "true");
|
||||
|
||||
let outKey = this.doc.getElementById("toolbox-zoom-out-key");
|
||||
outKey.setAttribute("disabled", "true");
|
||||
|
||||
let outKey2 = this.doc.getElementById("toolbox-zoom-out-key2");
|
||||
outKey2.setAttribute("disabled", "true");
|
||||
|
||||
let resetKey = this.doc.getElementById("toolbox-zoom-reset-key");
|
||||
resetKey.setAttribute("disabled", "true");
|
||||
|
||||
let resetKey2 = this.doc.getElementById("toolbox-zoom-reset-key2");
|
||||
resetKey2.setAttribute("disabled", "true");
|
||||
shortcuts.on(toolboxStrings("toolbox.zoomReset.key"),
|
||||
this.zoomReset.bind(this));
|
||||
let zoomReset2 = toolboxStrings("toolbox.zoomReset2.key");
|
||||
if (zoomReset2) {
|
||||
shortcuts.on(zoomReset2, this.zoomReset.bind(this));
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -709,22 +692,25 @@ Toolbox.prototype = {
|
||||
/**
|
||||
* Increase zoom level of toolbox window - make things bigger.
|
||||
*/
|
||||
zoomIn: function () {
|
||||
zoomIn: function (name, event) {
|
||||
this.setZoom(this.zoomValue + 0.1);
|
||||
event.preventDefault();
|
||||
},
|
||||
|
||||
/**
|
||||
* Decrease zoom level of toolbox window - make things smaller.
|
||||
*/
|
||||
zoomOut: function () {
|
||||
zoomOut: function (name, event) {
|
||||
this.setZoom(this.zoomValue - 0.1);
|
||||
event.preventDefault();
|
||||
},
|
||||
|
||||
/**
|
||||
* Reset zoom level of the toolbox window.
|
||||
*/
|
||||
zoomReset: function () {
|
||||
zoomReset: function (name, event) {
|
||||
this.setZoom(1);
|
||||
event.preventDefault();
|
||||
},
|
||||
|
||||
/**
|
||||
@ -900,10 +886,9 @@ Toolbox.prototype = {
|
||||
},
|
||||
|
||||
_getMinimizeButtonShortcutTooltip: function () {
|
||||
let key = this.doc.getElementById("toolbox-minimize-key")
|
||||
.getAttribute("key");
|
||||
return "(" + (osString == "Darwin" ? "Cmd+Shift+" : "Ctrl+Shift+") +
|
||||
key.toUpperCase() + ")";
|
||||
let str = toolboxStrings("toolbox.minimize.key");
|
||||
let key = KeyShortcuts.parseElectronKey(this.win, str);
|
||||
return "(" + KeyShortcuts.stringify(key) + ")";
|
||||
},
|
||||
|
||||
_onBottomHostMinimized: function () {
|
||||
|
@ -29,75 +29,7 @@
|
||||
|
||||
<commandset id="editMenuCommands"/>
|
||||
<keyset id="editMenuKeys"/>
|
||||
<keyset id="toolbox-keyset">
|
||||
<key id="toolbox-options-key"
|
||||
key="&toolboxOptionsButton.key;"
|
||||
oncommand="void(0);"
|
||||
modifiers="shift, accel"/>
|
||||
<key id="toolbox-options-key2"
|
||||
keycode="&openHelp.commandkey;"
|
||||
oncommand="void(0);"/>
|
||||
<key id="toolbox-next-tool-key"
|
||||
key="&toolboxNextTool.key;"
|
||||
oncommand="void(0);"
|
||||
modifiers="accel"/>
|
||||
<key id="toolbox-previous-tool-key"
|
||||
key="&toolboxPreviousTool.key;"
|
||||
oncommand="void(0);"
|
||||
modifiers="accel"/>
|
||||
<key id="toolbox-zoom-in-key"
|
||||
key="&fullZoomEnlargeCmd.commandkey;"
|
||||
oncommand="void(0);"
|
||||
modifiers="accel"/>
|
||||
<key id="toolbox-zoom-in-key2"
|
||||
key="&fullZoomEnlargeCmd.commandkey2;"
|
||||
oncommand="void(0);"
|
||||
modifiers="accel"/>
|
||||
<key id="toolbox-zoom-in-key3"
|
||||
key="&fullZoomEnlargeCmd.commandkey3;"
|
||||
oncommand="void(0);"
|
||||
modifiers="accel"/>
|
||||
<key id="toolbox-zoom-out-key"
|
||||
key="&fullZoomReduceCmd.commandkey;"
|
||||
oncommand="void(0);"
|
||||
modifiers="accel"/>
|
||||
<key id="toolbox-zoom-out-key2"
|
||||
key="&fullZoomReduceCmd.commandkey2;"
|
||||
oncommand="void(0);"
|
||||
modifiers="accel"/>
|
||||
<key id="toolbox-zoom-reset-key"
|
||||
key="&fullZoomResetCmd.commandkey;"
|
||||
oncommand="void(0);"
|
||||
modifiers="accel"/>
|
||||
<key id="toolbox-zoom-reset-key2"
|
||||
key="&fullZoomResetCmd.commandkey2;"
|
||||
oncommand="void(0);"
|
||||
modifiers="accel"/>
|
||||
<key id="toolbox-reload-key"
|
||||
key="&toolboxReload.key;"
|
||||
oncommand="void(0);"
|
||||
modifiers="accel"/>
|
||||
<key id="toolbox-force-reload-key"
|
||||
key="&toolboxReload.key;"
|
||||
oncommand="void(0);"
|
||||
modifiers="accel shift"/>
|
||||
<key id="toolbox-reload-key2"
|
||||
keycode="VK_F5"
|
||||
oncommand="void(0);"
|
||||
modifiers=""/>
|
||||
<key id="toolbox-force-reload-key2"
|
||||
keycode="VK_F5"
|
||||
oncommand="void(0);"
|
||||
modifiers="accel"/>
|
||||
<key id="toolbox-minimize-key"
|
||||
key="&toolboxToggleMinimize.key;"
|
||||
oncommand="void(0);"
|
||||
modifiers="shift, accel"/>
|
||||
<key id="toolbox-toggle-host-key"
|
||||
key="&toolboxToggle.key;"
|
||||
oncommand="void(0);"
|
||||
modifiers="accel shift"/>
|
||||
</keyset>
|
||||
<keyset id="toolbox-keyset"/>
|
||||
|
||||
<popupset>
|
||||
<menupopup id="toolbox-textbox-context-popup">
|
||||
|
@ -11,31 +11,7 @@
|
||||
<!ENTITY toggleToolboxF12.keytext "F12">
|
||||
|
||||
<!ENTITY toolboxCloseButton.tooltip "Close Developer Tools">
|
||||
<!ENTITY toolboxOptionsButton.key "O">
|
||||
<!ENTITY toolboxNextTool.key "]">
|
||||
<!ENTITY toolboxPreviousTool.key "[">
|
||||
|
||||
<!-- LOCALIZATION NOTE :
|
||||
fullZoomEnlargeCmd.commandkey, fullZoomEnlargeCmd.commandkey2,
|
||||
fullZoomEnlargeCmd.commandkey3, fullZoomReduceCmd.commandkey,
|
||||
fullZoomReduceCmd.commandkey2, fullZoomResetCmd.commandkey,
|
||||
and fullZoomResetCmd.commandkey2 should all match the corresponding
|
||||
values from browser.dtd. -->
|
||||
<!ENTITY fullZoomEnlargeCmd.commandkey "+">
|
||||
<!ENTITY fullZoomEnlargeCmd.commandkey2 "=">
|
||||
<!ENTITY fullZoomEnlargeCmd.commandkey3 "">
|
||||
|
||||
<!ENTITY fullZoomReduceCmd.commandkey "-">
|
||||
<!ENTITY fullZoomReduceCmd.commandkey2 "">
|
||||
|
||||
<!ENTITY fullZoomResetCmd.commandkey "0">
|
||||
<!ENTITY fullZoomResetCmd.commandkey2 "">
|
||||
|
||||
<!ENTITY toolboxReload.key "r">
|
||||
<!-- This key is used with the accel+shift modifiers to minimize the toolbox -->
|
||||
<!ENTITY toolboxToggleMinimize.key "U">
|
||||
|
||||
<!ENTITY toolboxToggle.key "d">
|
||||
<!-- LOCALIZATION NOTE (toolboxFramesButton): This is the label for
|
||||
- the iframes menu list that appears only when the document has some.
|
||||
- It allows you to switch the context of the whole toolbox. -->
|
||||
|
@ -135,3 +135,50 @@ toolbox.viewCssSourceInStyleEditor.label=Open File in Style-Editor
|
||||
toolbox.viewJsSourceInDebugger.label=Open File in Debugger
|
||||
|
||||
toolbox.resumeOrderWarning=Page did not resume after the debugger was attached. To fix this, please close and re-open the toolbox.
|
||||
|
||||
# LOCALIZATION NOTE (toolbox.options.key)
|
||||
# Key shortcut used to open the options panel
|
||||
toolbox.options.key=CmdOrCtrl+Shift+O
|
||||
|
||||
# LOCALIZATION NOTE (toolbox.help.key)
|
||||
# Key shortcut used to open the options panel
|
||||
toolbox.help.key=F1
|
||||
|
||||
# LOCALIZATION NOTE (toolbox.nextTool.key)
|
||||
# Key shortcut used to select the next tool
|
||||
toolbox.nextTool.key=CmdOrCtrl+]
|
||||
|
||||
# LOCALIZATION NOTE (toolbox.previousTool.key)
|
||||
# Key shortcut used to select the previous tool
|
||||
toolbox.previousTool.key=CmdOrCtrl+[
|
||||
|
||||
# LOCALIZATION NOTE (toolbox.zoom*.key)
|
||||
# Key shortcuts used to zomm in/out or reset the toolbox
|
||||
# Should match fullZoom*Cmd.commandkey values from browser.dtd
|
||||
toolbox.zoomIn.key=CmdOrCtrl+Plus
|
||||
toolbox.zoomIn2.key=CmdOrCtrl+=
|
||||
toolbox.zoomIn3.key=
|
||||
|
||||
toolbox.zoomOut.key=CmdOrCtrl+-
|
||||
toolbox.zoomOut2.key=
|
||||
|
||||
toolbox.zoomReset.key=CmdOrCtrl+0
|
||||
toolbox.zoomReset2.key=
|
||||
|
||||
# LOCALIZATION NOTE (toolbox.reload*.key)
|
||||
# Key shortcuts used to reload the page
|
||||
toolbox.reload.key=CmdOrCtrl+R
|
||||
toolbox.reload2.key=F5
|
||||
|
||||
# LOCALIZATION NOTE (toolbox.forceReload*.key)
|
||||
# Key shortcuts used to force reload of the page by bypassing caches
|
||||
toolbox.forceReload.key=CmdOrCtrl+Shift+R
|
||||
toolbox.forceReload2.key=CmdOrCtrl+F5
|
||||
|
||||
# LOCALIZATION NOTE (toolbox.minimize.key)
|
||||
# Key shortcut used to minimize the toolbox
|
||||
toolbox.minimize.key=CmdOrCtrl+Shift+U
|
||||
|
||||
# LOCALIZATION NOTE (toolbox.toggleHost.key)
|
||||
# Key shortcut used to move the toolbox in bottom or side of the browser window
|
||||
toolbox.toggleHost.key=CmdOrCtrl+Shift+D
|
||||
|
@ -129,6 +129,8 @@ KeyShortcuts.parseElectronKey = function (window, str) {
|
||||
// Maps the others manually to DOM API DOM_VK_*
|
||||
key = ElectronKeysMapping[key];
|
||||
shortcut.keyCode = window.KeyboardEvent[key];
|
||||
// Used only to stringify the shortcut
|
||||
shortcut.keyCodeString = key;
|
||||
} else {
|
||||
throw new Error("Unsupported key: " + key);
|
||||
}
|
||||
@ -136,6 +138,30 @@ KeyShortcuts.parseElectronKey = function (window, str) {
|
||||
return shortcut;
|
||||
};
|
||||
|
||||
KeyShortcuts.stringify = function (shortcut) {
|
||||
let list = [];
|
||||
if (shortcut.alt) {
|
||||
list.push("Alt");
|
||||
}
|
||||
if (shortcut.ctrl) {
|
||||
list.push("Ctrl");
|
||||
}
|
||||
if (shortcut.meta) {
|
||||
list.push("Cmd");
|
||||
}
|
||||
if (shortcut.shift) {
|
||||
list.push("Shift");
|
||||
}
|
||||
let key;
|
||||
if (shortcut.key) {
|
||||
key = shortcut.key.toUpperCase();
|
||||
} else {
|
||||
key = shortcut.keyCodeString;
|
||||
}
|
||||
list.push(key);
|
||||
return list.join("+");
|
||||
};
|
||||
|
||||
KeyShortcuts.prototype = {
|
||||
destroy() {
|
||||
this.window.removeEventListener("keydown", this);
|
||||
|
Loading…
Reference in New Issue
Block a user