зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1203079 - Allow Ctrl+Shift+C to cancel element picker even if page becomes unfocused; r=pbro
--HG-- extra : rebase_source : b8859d16fdf64903b55779fb5972d4ccb840b0ce
This commit is contained in:
Родитель
f1de083a08
Коммит
f79cb6e071
|
@ -6,33 +6,42 @@
|
|||
|
||||
// Test that the keybindings for Picker work alright
|
||||
|
||||
const IS_OSX = Services.appinfo.OS === "Darwin";
|
||||
const TEST_URL = URL_ROOT + "doc_inspector_highlighter_dom.html";
|
||||
|
||||
add_task(function* () {
|
||||
let {inspector, toolbox, testActor} = yield openInspectorForURL(TEST_URL);
|
||||
|
||||
yield startPicker(toolbox);
|
||||
|
||||
info("Selecting the #another DIV");
|
||||
yield moveMouseOver("#another");
|
||||
|
||||
// Testing pick-node shortcut
|
||||
info("Testing enter/return key as pick-node command");
|
||||
yield doKeyPick({key: "VK_RETURN", options: {}});
|
||||
is(inspector.selection.nodeFront.id, "another",
|
||||
"The #another node was selected. Passed.");
|
||||
|
||||
// Testing cancel-picker command
|
||||
yield startPicker(toolbox);
|
||||
|
||||
info("Selecting the ahoy DIV");
|
||||
yield moveMouseOver("#ahoy");
|
||||
|
||||
info("Testing escape key as cancel-picker command");
|
||||
yield startPicker(toolbox);
|
||||
yield moveMouseOver("#ahoy");
|
||||
yield doKeyStop({key: "VK_ESCAPE", options: {}});
|
||||
is(inspector.selection.nodeFront.id, "another",
|
||||
"The #another DIV is still selected. Passed.");
|
||||
|
||||
info("Testing Ctrl+Shift+C shortcut as cancel-picker command");
|
||||
yield startPicker(toolbox);
|
||||
yield moveMouseOver("#ahoy");
|
||||
let shortcutOpts = {key: "VK_C", options: {}};
|
||||
if (IS_OSX) {
|
||||
shortcutOpts.options.metaKey = true;
|
||||
shortcutOpts.options.altKey = true;
|
||||
} else {
|
||||
shortcutOpts.options.ctrlKey = true;
|
||||
shortcutOpts.options.shiftKey = true;
|
||||
}
|
||||
yield doKeyStop(shortcutOpts);
|
||||
is(inspector.selection.nodeFront.id, "another",
|
||||
"The #another DIV is still selected. Passed.");
|
||||
|
||||
function doKeyPick(args) {
|
||||
info("Key pressed. Waiting for element to be picked");
|
||||
testActor.synthesizeKey(args);
|
||||
|
|
|
@ -10,12 +10,14 @@ const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
|
|||
const EventEmitter = require("devtools/shared/event-emitter");
|
||||
const events = require("sdk/event/core");
|
||||
const protocol = require("devtools/shared/protocol");
|
||||
const Services = require("Services");
|
||||
const { isWindowIncluded } = require("devtools/shared/layout/utils");
|
||||
const { highlighterSpec, customHighlighterSpec } = require("devtools/shared/specs/highlighters");
|
||||
const { isXUL, isNodeValid } = require("./highlighters/utils/markup");
|
||||
const { SimpleOutlineHighlighter } = require("./highlighters/simple-outline");
|
||||
|
||||
const HIGHLIGHTER_PICKED_TIMER = 1000;
|
||||
const IS_OSX = Services.appinfo.OS === "Darwin";
|
||||
|
||||
/**
|
||||
* The registration mechanism for highlighters provide a quick way to
|
||||
|
@ -291,7 +293,7 @@ var HighlighterActor = exports.HighlighterActor = protocol.ActorClassWithSpec(hi
|
|||
* LEFT_KEY: wider or parent
|
||||
* RIGHT_KEY: narrower or child
|
||||
* ENTER/CARRIAGE_RETURN: Picks currentNode
|
||||
* ESC: Cancels picker, picks currentNode
|
||||
* ESC/CTRL+SHIFT+C: Cancels picker, picks currentNode
|
||||
*/
|
||||
switch (event.keyCode) {
|
||||
// Wider.
|
||||
|
@ -332,7 +334,13 @@ var HighlighterActor = exports.HighlighterActor = protocol.ActorClassWithSpec(hi
|
|||
this.cancelPick();
|
||||
events.emit(this._walker, "picker-node-canceled");
|
||||
return;
|
||||
|
||||
case Ci.nsIDOMKeyEvent.DOM_VK_C:
|
||||
if ((IS_OSX && event.metaKey && event.altKey) ||
|
||||
(!IS_OSX && event.ctrlKey && event.shiftKey)) {
|
||||
this.cancelPick();
|
||||
events.emit(this._walker, "picker-node-canceled");
|
||||
return;
|
||||
}
|
||||
default: return;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче