зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1562145 - Fix mouse-dragging regression caused by patch to 1554864
. r=dao
Differential Revision: https://phabricator.services.mozilla.com/D36329 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
997f0e4621
Коммит
e1e9f67ec1
|
@ -35,14 +35,8 @@ add_task(async function test_content_and_chrome_selection() {
|
|||
"Write something here",
|
||||
"The macOS services got the selected content text"
|
||||
);
|
||||
|
||||
gURLBar.value = "test.mozilla.org";
|
||||
await gURLBar.focus();
|
||||
await BrowserTestUtils.synthesizeKey(
|
||||
"KEY_ArrowRight",
|
||||
{ shiftKey: true, ctrlKey: true },
|
||||
gBrowser.selectedBrowser
|
||||
);
|
||||
await gURLBar.editor.selectAll();
|
||||
selectedText = DOMWindowUtils.GetSelectionAsPlaintext();
|
||||
is(
|
||||
selectedText,
|
||||
|
|
|
@ -174,8 +174,10 @@ class UrlbarInput {
|
|||
this.eventBufferer = new UrlbarEventBufferer(this);
|
||||
|
||||
this._inputFieldEvents = [
|
||||
"click",
|
||||
"compositionstart",
|
||||
"compositionend",
|
||||
"contextmenu",
|
||||
"dragover",
|
||||
"dragstart",
|
||||
"drop",
|
||||
|
@ -208,8 +210,6 @@ class UrlbarInput {
|
|||
|
||||
this._initPasteAndGo();
|
||||
|
||||
this._ignoreFocus = true;
|
||||
|
||||
// Tracks IME composition.
|
||||
this._compositionState = UrlbarUtils.COMPOSITION.NONE;
|
||||
this._compositionClosedPopup = false;
|
||||
|
@ -1381,6 +1381,22 @@ class UrlbarInput {
|
|||
Services.obs.notifyObservers({ result }, "urlbar-user-start-navigation");
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if we should select all the text in the Urlbar based on the
|
||||
* clickSelectsAll pref, Urlbar state, and whether the selection is empty.
|
||||
*/
|
||||
_maybeSelectAll() {
|
||||
if (
|
||||
!this._preventClickSelectsAll &&
|
||||
UrlbarPrefs.get("clickSelectsAll") &&
|
||||
this._compositionState != UrlbarUtils.COMPOSITION.COMPOSING &&
|
||||
this.document.activeElement == this.inputField &&
|
||||
this.inputField.selectionStart == this.inputField.selectionEnd
|
||||
) {
|
||||
this.editor.selectAll();
|
||||
}
|
||||
}
|
||||
|
||||
// Event handlers below.
|
||||
|
||||
_on_blur(event) {
|
||||
|
@ -1405,26 +1421,33 @@ class UrlbarInput {
|
|||
if (this.getAttribute("pageproxystate") != "valid") {
|
||||
this.window.UpdatePopupNotificationsVisibility();
|
||||
}
|
||||
// Don't trigger clickSelectsAll when switching application windows.
|
||||
if (this.document.activeElement == this.inputField) {
|
||||
this._ignoreFocus = true;
|
||||
}
|
||||
this._resetSearchState();
|
||||
}
|
||||
|
||||
_on_click(event) {
|
||||
this._maybeSelectAll();
|
||||
}
|
||||
|
||||
_on_contextmenu(event) {
|
||||
// On Windows, the context menu appears on mouseup. macOS and Linux require
|
||||
// special handling to selectAll when the contextmenu is displayed.
|
||||
// See bug 576135 comment 4 for details.
|
||||
if (AppConstants.platform == "win") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Context menu opened via keyboard shortcut.
|
||||
if (!event.button) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._maybeSelectAll();
|
||||
}
|
||||
|
||||
_on_focus(event) {
|
||||
this._updateUrlTooltip();
|
||||
this.formatValue();
|
||||
|
||||
if (this._ignoreFocus) {
|
||||
this._ignoreFocus = false;
|
||||
} else if (
|
||||
UrlbarPrefs.get("clickSelectsAll") &&
|
||||
this._compositionState != UrlbarUtils.COMPOSITION.COMPOSING
|
||||
) {
|
||||
this.editor.selectAll();
|
||||
}
|
||||
|
||||
// Hide popup notifications, to reduce visual noise.
|
||||
if (this.getAttribute("pageproxystate") != "valid") {
|
||||
this.window.UpdatePopupNotificationsVisibility();
|
||||
|
@ -1436,12 +1459,14 @@ class UrlbarInput {
|
|||
}
|
||||
|
||||
_on_mousedown(event) {
|
||||
// We only care about left clicks here.
|
||||
if (event.button != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.currentTarget == this.inputField) {
|
||||
this._preventClickSelectsAll = this.focused;
|
||||
|
||||
// The rest of this handler only cares about left clicks.
|
||||
if (event.button != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.detail == 2 && UrlbarPrefs.get("doubleClickSelectsAll")) {
|
||||
this.editor.selectAll();
|
||||
event.preventDefault();
|
||||
|
@ -1453,7 +1478,10 @@ class UrlbarInput {
|
|||
return;
|
||||
}
|
||||
|
||||
if (event.originalTarget.classList.contains("urlbar-history-dropmarker")) {
|
||||
if (
|
||||
event.originalTarget.classList.contains("urlbar-history-dropmarker") &&
|
||||
event.button == 0
|
||||
) {
|
||||
if (this.view.isOpen) {
|
||||
this.view.close();
|
||||
} else {
|
||||
|
@ -1461,6 +1489,7 @@ class UrlbarInput {
|
|||
this.startQuery({
|
||||
allowAutofill: false,
|
||||
});
|
||||
this._maybeSelectAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче