mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 891556 - Add Ctrl-Shift-C (Cmd-Opt-C) shortcut to toggle highlighting; r=jwalker
This commit is contained in:
parent
37a492acf5
commit
6505f8e6d7
@ -345,15 +345,24 @@ let gDevToolsBrowser = {
|
|||||||
selectToolCommand: function(gBrowser, toolId) {
|
selectToolCommand: function(gBrowser, toolId) {
|
||||||
let target = devtools.TargetFactory.forTab(gBrowser.selectedTab);
|
let target = devtools.TargetFactory.forTab(gBrowser.selectedTab);
|
||||||
let toolbox = gDevTools.getToolbox(target);
|
let toolbox = gDevTools.getToolbox(target);
|
||||||
|
let tools = gDevTools.getToolDefinitionMap();
|
||||||
|
let toolDefinition = tools.get(toolId);
|
||||||
|
|
||||||
if (toolbox && toolbox.currentToolId == toolId) {
|
if (toolbox && toolbox.currentToolId == toolId) {
|
||||||
if (toolbox.hostType == devtools.Toolbox.HostType.WINDOW) {
|
toolbox.fireCustomKey(toolId);
|
||||||
|
|
||||||
|
if (toolDefinition.preventClosingOnKey || toolbox.hostType == devtools.Toolbox.HostType.WINDOW) {
|
||||||
toolbox.raise();
|
toolbox.raise();
|
||||||
} else {
|
} else {
|
||||||
toolbox.destroy();
|
toolbox.destroy();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gDevTools.showToolbox(target, toolId);
|
gDevTools.showToolbox(target, toolId).then(() => {
|
||||||
|
let target = devtools.TargetFactory.forTab(gBrowser.selectedTab);
|
||||||
|
let toolbox = gDevTools.getToolbox(target);
|
||||||
|
|
||||||
|
toolbox.fireCustomKey(toolId);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ MOCHITEST_BROWSER_FILES = \
|
|||||||
browser_toolbox_options_disablejs_iframe.html \
|
browser_toolbox_options_disablejs_iframe.html \
|
||||||
browser_toolbox_highlight.js \
|
browser_toolbox_highlight.js \
|
||||||
browser_toolbox_raise.js \
|
browser_toolbox_raise.js \
|
||||||
|
browser_keybindings.js \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
include $(topsrcdir)/config/rules.mk
|
include $(topsrcdir)/config/rules.mk
|
||||||
|
119
browser/devtools/framework/test/browser_keybindings.js
Normal file
119
browser/devtools/framework/test/browser_keybindings.js
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
// Tests that the keybindings for opening and closing the inspector work as expected
|
||||||
|
// Can probably make this a shared test that tests all of the tools global keybindings
|
||||||
|
|
||||||
|
function test()
|
||||||
|
{
|
||||||
|
waitForExplicitFinish();
|
||||||
|
|
||||||
|
let doc;
|
||||||
|
let node;
|
||||||
|
let inspector;
|
||||||
|
let keysetMap = { };
|
||||||
|
|
||||||
|
gBrowser.selectedTab = gBrowser.addTab();
|
||||||
|
gBrowser.selectedBrowser.addEventListener("load", function onload() {
|
||||||
|
gBrowser.selectedBrowser.removeEventListener("load", onload, true);
|
||||||
|
doc = content.document;
|
||||||
|
waitForFocus(setupKeyBindingsTest, content);
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
content.location = "data:text/html,<html><head><title>Test for the " +
|
||||||
|
"highlighter keybindings</title></head><body>" +
|
||||||
|
"<h1>Keybindings!</h1></body></html>";
|
||||||
|
|
||||||
|
function buildDevtoolsKeysetMap(keyset) {
|
||||||
|
[].forEach.call(keyset.querySelectorAll("key"), function(key) {
|
||||||
|
|
||||||
|
if (!key.getAttribute("key")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let modifiers = key.getAttribute("modifiers");
|
||||||
|
|
||||||
|
keysetMap[key.id.split("_")[1]] = {
|
||||||
|
key: key.getAttribute("key"),
|
||||||
|
modifiers: modifiers,
|
||||||
|
modifierOpt: {
|
||||||
|
shiftKey: modifiers.match("shift"),
|
||||||
|
ctrlKey: modifiers.match("ctrl"),
|
||||||
|
altKey: modifiers.match("alt"),
|
||||||
|
metaKey: modifiers.match("meta"),
|
||||||
|
accelKey: modifiers.match("accel")
|
||||||
|
},
|
||||||
|
synthesizeKey: function() {
|
||||||
|
EventUtils.synthesizeKey(this.key, this.modifierOpt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupKeyBindingsTest()
|
||||||
|
{
|
||||||
|
for (let win of gDevToolsBrowser._trackedBrowserWindows) {
|
||||||
|
buildDevtoolsKeysetMap(win.document.getElementById("devtoolsKeyset"));
|
||||||
|
}
|
||||||
|
|
||||||
|
gDevTools.once("toolbox-ready", (e, toolbox) => {
|
||||||
|
inspectorShouldBeOpenAndHighlighting(toolbox.getCurrentPanel(), toolbox)
|
||||||
|
});
|
||||||
|
|
||||||
|
keysetMap.inspector.synthesizeKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
function inspectorShouldBeOpenAndHighlighting(aInspector, aToolbox)
|
||||||
|
{
|
||||||
|
is (aToolbox.currentToolId, "inspector", "Correct tool has been loaded");
|
||||||
|
is (aInspector.highlighter.locked, true, "Highlighter should be locked");
|
||||||
|
|
||||||
|
aInspector.highlighter.once("unlocked", () => {
|
||||||
|
is (aInspector.highlighter.locked, false, "Highlighter should be unlocked");
|
||||||
|
keysetMap.inspector.synthesizeKey();
|
||||||
|
is (aInspector.highlighter.locked, true, "Highlighter should be locked");
|
||||||
|
keysetMap.inspector.synthesizeKey();
|
||||||
|
is (aInspector.highlighter.locked, false, "Highlighter should be unlocked");
|
||||||
|
keysetMap.inspector.synthesizeKey();
|
||||||
|
is (aInspector.highlighter.locked, true, "Highlighter should be locked");
|
||||||
|
|
||||||
|
aToolbox.once("webconsole-ready", (e, panel) => {
|
||||||
|
webconsoleShouldBeSelected(aToolbox, panel);
|
||||||
|
});
|
||||||
|
keysetMap.webconsole.synthesizeKey();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function webconsoleShouldBeSelected(aToolbox, panel)
|
||||||
|
{
|
||||||
|
is (aToolbox.currentToolId, "webconsole");
|
||||||
|
|
||||||
|
aToolbox.once("jsdebugger-ready", (e, panel) => {
|
||||||
|
jsdebuggerShouldBeSelected(aToolbox, panel);
|
||||||
|
});
|
||||||
|
keysetMap.jsdebugger.synthesizeKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
function jsdebuggerShouldBeSelected(aToolbox, panel)
|
||||||
|
{
|
||||||
|
is (aToolbox.currentToolId, "jsdebugger");
|
||||||
|
|
||||||
|
aToolbox.once("netmonitor-ready", (e, panel) => {
|
||||||
|
netmonitorShouldBeSelected(aToolbox, panel);
|
||||||
|
});
|
||||||
|
|
||||||
|
keysetMap.netmonitor.synthesizeKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
function netmonitorShouldBeSelected(aToolbox, panel)
|
||||||
|
{
|
||||||
|
is (aToolbox.currentToolId, "netmonitor");
|
||||||
|
finishUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
function finishUp() {
|
||||||
|
doc = node = inspector = keysetMap = null;
|
||||||
|
gBrowser.removeCurrentTab();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
@ -264,13 +264,30 @@ Toolbox.prototype = {
|
|||||||
key.setAttribute("modifiers", toolDefinition.modifiers);
|
key.setAttribute("modifiers", toolDefinition.modifiers);
|
||||||
key.setAttribute("oncommand", "void(0);"); // needed. See bug 371900
|
key.setAttribute("oncommand", "void(0);"); // needed. See bug 371900
|
||||||
key.addEventListener("command", function(toolId) {
|
key.addEventListener("command", function(toolId) {
|
||||||
this.selectTool(toolId);
|
this.selectTool(toolId).then(() => {
|
||||||
|
this.fireCustomKey(toolId);
|
||||||
|
});
|
||||||
}.bind(this, id), true);
|
}.bind(this, id), true);
|
||||||
doc.getElementById("toolbox-keyset").appendChild(key);
|
doc.getElementById("toolbox-keyset").appendChild(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle any custom key events. Returns true if there was a custom key binding run
|
||||||
|
* @param {string} toolId
|
||||||
|
* Which tool to run the command on (skip if not current)
|
||||||
|
*/
|
||||||
|
fireCustomKey: function TBOX_fireCustomKey(toolId) {
|
||||||
|
let tools = gDevTools.getToolDefinitionMap();
|
||||||
|
let activeToolDefinition = tools.get(toolId);
|
||||||
|
|
||||||
|
if (activeToolDefinition.onkey && this.currentToolId === toolId) {
|
||||||
|
activeToolDefinition.onkey(this.getCurrentPanel());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the buttons for changing hosts. Called every time
|
* Build the buttons for changing hosts. Called every time
|
||||||
* the host changes.
|
* the host changes.
|
||||||
|
@ -129,8 +129,6 @@ Highlighter.prototype = {
|
|||||||
this.transitionDisabler = null;
|
this.transitionDisabler = null;
|
||||||
this.pageEventsMuter = null;
|
this.pageEventsMuter = null;
|
||||||
|
|
||||||
this.unlockAndFocus();
|
|
||||||
|
|
||||||
this.selection.on("new-node", this.highlight);
|
this.selection.on("new-node", this.highlight);
|
||||||
this.selection.on("new-node", this.updateInfobar);
|
this.selection.on("new-node", this.updateInfobar);
|
||||||
this.selection.on("pseudoclass", this.updateInfobar);
|
this.selection.on("pseudoclass", this.updateInfobar);
|
||||||
|
@ -137,10 +137,6 @@ InspectorPanel.prototype = {
|
|||||||
// All the components are initialized. Let's select a node.
|
// All the components are initialized. Let's select a node.
|
||||||
this._selection.setNodeFront(defaultSelection);
|
this._selection.setNodeFront(defaultSelection);
|
||||||
|
|
||||||
if (this.highlighter) {
|
|
||||||
this.highlighter.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.markup.expandNode(this.selection.nodeFront);
|
this.markup.expandNode(this.selection.nodeFront);
|
||||||
|
|
||||||
this.emit("ready");
|
this.emit("ready");
|
||||||
|
@ -29,6 +29,7 @@ function test()
|
|||||||
function runObjectInspectionTest(inspector)
|
function runObjectInspectionTest(inspector)
|
||||||
{
|
{
|
||||||
inspector.highlighter.once("locked", performTestComparison);
|
inspector.highlighter.once("locked", performTestComparison);
|
||||||
|
inspector.highlighter.unlock();
|
||||||
inspector.selection.setNode(objectNode, "");
|
inspector.selection.setNode(objectNode, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ function test()
|
|||||||
|
|
||||||
function runTests(inspector)
|
function runTests(inspector)
|
||||||
{
|
{
|
||||||
|
inspector.highlighter.unlock();
|
||||||
executeSoon(function() {
|
executeSoon(function() {
|
||||||
inspector.highlighter.once("highlighting", isTheIframeSelected);
|
inspector.highlighter.once("highlighting", isTheIframeSelected);
|
||||||
moveMouseOver(iframeNode, 1, 1);
|
moveMouseOver(iframeNode, 1, 1);
|
||||||
|
@ -51,6 +51,7 @@ function moveMouseOver(aElement)
|
|||||||
|
|
||||||
function runIframeTests()
|
function runIframeTests()
|
||||||
{
|
{
|
||||||
|
getActiveInspector().highlighter.unlock();
|
||||||
getActiveInspector().selection.once("new-node", performTestComparisons1);
|
getActiveInspector().selection.once("new-node", performTestComparisons1);
|
||||||
moveMouseOver(div1)
|
moveMouseOver(div1)
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ function inspectNode(aInspector)
|
|||||||
|
|
||||||
inspector.highlighter.once("locked", performScrollingTest);
|
inspector.highlighter.once("locked", performScrollingTest);
|
||||||
executeSoon(function() {
|
executeSoon(function() {
|
||||||
|
inspector.highlighter.unlock();
|
||||||
inspector.selection.setNode(div, "");
|
inspector.selection.setNode(div, "");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,13 @@ Tools.inspector = {
|
|||||||
label: l10n("inspector.label", inspectorStrings),
|
label: l10n("inspector.label", inspectorStrings),
|
||||||
tooltip: l10n("inspector.tooltip", inspectorStrings),
|
tooltip: l10n("inspector.tooltip", inspectorStrings),
|
||||||
|
|
||||||
|
preventClosingOnKey: true,
|
||||||
|
onkey: function(panel) {
|
||||||
|
if (panel.highlighter) {
|
||||||
|
panel.highlighter.toggleLockState();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
isTargetSupported: function(target) {
|
isTargetSupported: function(target) {
|
||||||
return !target.isRemote;
|
return !target.isRemote;
|
||||||
},
|
},
|
||||||
|
@ -35,7 +35,7 @@ nodeMenu.tooltiptext=Node operations
|
|||||||
# LOCALIZATION NOTE (inspector.*)
|
# LOCALIZATION NOTE (inspector.*)
|
||||||
# Used for the menuitem in the tool menu
|
# Used for the menuitem in the tool menu
|
||||||
inspector.label=Inspector
|
inspector.label=Inspector
|
||||||
inspector.commandkey=I
|
inspector.commandkey=C
|
||||||
inspector.accesskey=I
|
inspector.accesskey=I
|
||||||
|
|
||||||
# LOCALIZATION NOTE (markupView.more.*)
|
# LOCALIZATION NOTE (markupView.more.*)
|
||||||
|
Loading…
Reference in New Issue
Block a user