Bug 1528614 - Remove clickSelectsAll from textboxes. r=dao

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
harry 2019-07-19 08:54:43 +00:00
Родитель 1c016bfe56
Коммит 70fad9cef6
6 изменённых файлов: 37 добавлений и 77 удалений

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

@ -965,9 +965,6 @@ var PlacesSearchBox = {
* Set up the gray text in the search bar as the Places View loads.
*/
init: function PSB_init() {
if (Services.prefs.getBoolPref("browser.urlbar.clickSelectsAll", false)) {
this.searchFilter.setAttribute("clickSelectsAll", true);
}
this.updateCollectionTitle();
},

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

@ -182,7 +182,7 @@
is="search-textbox" id="searchInput"
data-l10n-id="search-input-box"
data-l10n-attrs="style"
hidden="true" clickSelectsAll="true"/>
hidden="true"/>
</hbox>
<vbox id="mainPrefPane">
#include searchResults.inc.xul

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

@ -415,7 +415,27 @@
}
}
/**
* Determines if we should select all the text in the searchbar based on the
* clickSelectsAll pref, searchbar state, and whether the selection is empty.
*/
_maybeSelectAll() {
if (
!this._preventClickSelectsAll &&
UrlbarPrefs.get("clickSelectsAll") &&
document.activeElement == this._textbox.inputField &&
this._textbox.inputField.selectionStart ==
this._textbox.inputField.selectionEnd
) {
this._textbox.editor.selectAll();
}
}
_setupEventListeners() {
this.addEventListener("click", event => {
this._maybeSelectAll();
});
this.addEventListener("command", event => {
const target = event.originalTarget;
if (target.engine) {
@ -437,6 +457,15 @@
this.select();
});
this.addEventListener("contextmenu", event => {
// Context menu opened via keyboard shortcut.
if (!event.button) {
return;
}
this._maybeSelectAll();
});
this.addEventListener(
"DOMMouseScroll",
event => {
@ -502,6 +531,7 @@
);
this.addEventListener("mousedown", event => {
this._preventClickSelectsAll = this._textbox.focused;
// Ignore right clicks
if (event.button != 0) {
return;
@ -529,6 +559,11 @@
// is text in the textbox.
this.openSuggestionsPanel(true);
}
if (event.detail == 2 && UrlbarPrefs.get("doubleClickSelectsAll")) {
this._textbox.editor.selectAll();
event.preventDefault();
}
});
}
@ -660,10 +695,6 @@
return;
}
if (Services.prefs.getBoolPref("browser.urlbar.clickSelectsAll")) {
this.textbox.setAttribute("clickSelectsAll", true);
}
let inputBox = document.getAnonymousElementByAttribute(
this.textbox,
"anonid",

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

@ -71,7 +71,7 @@ toolkit.jar:
content/global/bindings/richlistbox.xml (widgets/richlistbox.xml)
content/global/bindings/scrollbox.xml (widgets/scrollbox.xml)
content/global/bindings/spinner.js (widgets/spinner.js)
* content/global/bindings/textbox.xml (widgets/textbox.xml)
content/global/bindings/textbox.xml (widgets/textbox.xml)
content/global/bindings/timekeeper.js (widgets/timekeeper.js)
content/global/bindings/timepicker.js (widgets/timepicker.js)
content/global/elements/autocomplete-popup.js (widgets/autocomplete-popup.js)

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

@ -46,16 +46,6 @@
});
}
this.addEventListener("click", event => {
if (
this.clickSelectsAll &&
document.activeElement == this.inputField &&
this.inputField.selectionStart == this.inputField.selectionEnd
) {
this.editor.selectAll();
}
});
this.addEventListener("input", event => {
if (this.searchButton) {
this._searchIcons.selectedIndex = 0;
@ -211,18 +201,6 @@
return this.inputField.disabled;
}
get clickSelectsAll() {
return this.getAttribute("clickSelectsAll") == "true";
}
set clickSelectsAll(val) {
if (val) {
this.setAttribute("clickSelectsAll", "true");
} else {
this.removeAttribute("clickSelectsAll");
}
}
reset() {
this.value = this.defaultValue;
// XXX: Is this still needed ?

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

@ -36,7 +36,6 @@
<field name="mInputField">null</field>
<field name="mIgnoreClick">false</field>
<field name="mIgnoreFocus">false</field>
<field name="mEditor">null</field>
<property name="inputField" readonly="true">
@ -76,10 +75,6 @@
if (val) this.setAttribute('readonly', 'true');
else this.removeAttribute('readonly'); return val;"
onget="return this.inputField.readOnly;"/>
<property name="clickSelectsAll"
onget="return this.getAttribute('clickSelectsAll') == 'true';"
onset="if (val) this.setAttribute('clickSelectsAll', 'true');
else this.removeAttribute('clickSelectsAll'); return val;" />
<property name="editor" readonly="true">
<getter><![CDATA[
@ -152,15 +147,6 @@
]]></body>
</method>
<method name="_maybeSelectAll">
<body><![CDATA[
if (!this.mIgnoreClick && this.clickSelectsAll &&
document.activeElement == this.inputField &&
this.inputField.selectionStart == this.inputField.selectionEnd)
this.editor.selectAll();
]]></body>
</method>
<constructor><![CDATA[
var str = this._cachedInputFieldValue;
if (str) {
@ -200,14 +186,6 @@
this.setAttribute("focused", "true");
break;
case this.inputField:
if (this.mIgnoreFocus) {
this.mIgnoreFocus = false;
} else if (this.clickSelectsAll) {
try {
if (!this.editor || !this.editor.composing)
this.editor.selectAll();
} catch (e) {}
}
this.setAttribute("focused", "true");
break;
default:
@ -220,12 +198,6 @@
<handler event="blur" phase="capturing">
<![CDATA[
this.removeAttribute("focused");
// don't trigger clickSelectsAll when switching application windows
if (window == window.top &&
window.isChromeWindow &&
document.activeElement == this.inputField)
this.mIgnoreFocus = true;
]]>
</handler>
@ -234,7 +206,6 @@
this.mIgnoreClick = this.hasAttribute("focused");
if (!this.mIgnoreClick) {
this.mIgnoreFocus = true;
this.setSelectionRange(0, 0);
if (event.originalTarget == this ||
event.originalTarget == this.inputField.parentNode)
@ -242,23 +213,6 @@
}
]]>
</handler>
<handler event="click" action="this._maybeSelectAll();"/>
#ifndef XP_WIN
<handler event="contextmenu">
// Only care about context clicks on the textbox itself.
if (event.target != this)
return;
if (!event.button) // context menu opened via keyboard shortcut
return;
this._maybeSelectAll();
// see bug 576135 comment 4
let box = this.inputField.parentNode;
box._doPopupItemEnabling(box.menupopup);
</handler>
#endif
</handlers>
</binding>
</bindings>