Bug 1508656 - migrate cancel picker to nodePicker; r=ochameau

Depends on D12126

Differential Revision: https://phabricator.services.mozilla.com/D12290

--HG--
extra : moz-landing-system : lando
This commit is contained in:
yulia 2018-12-18 08:45:16 +00:00
Родитель 36350fa576
Коммит 9acadd4e5b
6 изменённых файлов: 10 добавлений и 9 удалений

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

@ -1294,7 +1294,7 @@ Toolbox.prototype = {
if (currentPanel.cancelPicker) {
currentPanel.cancelPicker();
} else {
this.highlighterUtils.cancelPicker();
this.inspector.nodePicker.cancel();
}
// Stop the console from toggling.
event.stopImmediatePropagation();
@ -1309,12 +1309,10 @@ Toolbox.prototype = {
_onPickerStarted: async function() {
this.doc.addEventListener("keypress", this._onPickerKeypress, true);
this.inspector.nodePicker.on("picker-node-canceled", this._onPickerCanceled);
},
_onPickerStopped: function() {
this.off("select", this.inspector.nodePicker.stop);
this.inspector.nodePicker.off("picker-node-canceled", this._onPickerCanceled);
this.doc.removeEventListener("keypress", this._onPickerKeypress, true);
this.pickerButton.isChecked = false;
},
@ -1323,7 +1321,7 @@ Toolbox.prototype = {
* When the picker is canceled, make sure the toolbox
* gets the focus.
*/
_onPickerCanceled: function(data) {
_onPickerCanceled: function() {
this.win.focus();
},
@ -2728,6 +2726,7 @@ Toolbox.prototype = {
this.inspector.nodePicker.on("picker-starting", this._onPickerStarting);
this.inspector.nodePicker.on("picker-started", this._onPickerStarted);
this.inspector.nodePicker.on("picker-stopped", this._onPickerStopped);
this.inspector.nodePicker.on("picker-node-canceled", this._onPickerCanceled);
this.walker.on("highlighter-ready", this._highlighterReady);
this.walker.on("highlighter-hide", this._highlighterHidden);
this._selection.on("new-node-front", this._onNewSelectedNodeFront);

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

@ -121,7 +121,9 @@ function MarkupView(inspector, frame, controllerWindow) {
this.walker.on("mutations", this._mutationObserver);
this.win.addEventListener("copy", this._onCopy);
this.win.addEventListener("mouseup", this._onMouseUp);
this.toolbox.on("picker-canceled", this._onToolboxPickerCanceled);
this.inspector.inspector.nodePicker.on(
"picker-node-canceled", this._onToolboxPickerCanceled
);
this.toolbox.on("picker-node-hovered", this._onToolboxPickerHover);
if (flags.testing) {

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

@ -31,7 +31,7 @@ add_task(async function() {
function cancelPickerByShortcut() {
info("Key pressed. Waiting for picker to be canceled.");
testActor.synthesizeKey({key: "VK_ESCAPE", options: {}});
return inspector.toolbox.once("picker-canceled");
return inspector.inspector.nodePicker.once("picker-node-canceled");
}
function moveMouseOver(selector) {

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

@ -24,7 +24,7 @@ add_task(async function() {
await onHover;
info("Press escape and wait for the picker to stop");
const onPickerStopped = toolbox.inspector.nodePicker.once("picker-stopped");
const onPickerStopped = toolbox.inspector.nodePicker.once("picker-node-canceled");
testActor.synthesizeKey({
key: "VK_ESCAPE",
options: {},

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

@ -169,7 +169,7 @@ class SwatchColorPickerTooltip extends SwatchBasedEditorTooltip {
telemetry.getHistogramById(TELEMETRY_PICKER_EYEDROPPER_OPEN_COUNT).add(true);
// cancelling picker(if it is already selected) on opening eye-dropper
toolbox.highlighterUtils.cancelPicker();
inspector.nodePicker.cancel();
// pickColorFromPage will focus the content document. If the devtools are in a
// separate window, the colorpicker tooltip will be closed before pickColorFromPage

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

@ -100,8 +100,8 @@ class NodePicker extends EventEmitter {
* Stop the picker, but also emit an event that the picker was canceled.
*/
async cancel() {
this.emit("picker-node-canceled");
await this.stop();
this.emit("picker-node-canceled");
}
/**