зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1037353 - Don't show autocomplete popup after selecting an autocomplete value. r=jchen
This commit is contained in:
Родитель
7e6d458629
Коммит
aa1d2d7d4e
|
@ -5512,6 +5512,12 @@ var FormAssistant = {
|
|||
// autocomplete suggestions
|
||||
_currentInputElement: null,
|
||||
|
||||
// The value of the currently focused input
|
||||
_currentInputValue: null,
|
||||
|
||||
// Whether we're in the middle of an autocomplete
|
||||
_doingAutocomplete: false,
|
||||
|
||||
_isBlocklisted: false,
|
||||
|
||||
// Keep track of whether or not an invalid form has been submitted
|
||||
|
@ -5526,6 +5532,7 @@ var FormAssistant = {
|
|||
|
||||
// We need to use a capturing listener for focus events
|
||||
BrowserApp.deck.addEventListener("focus", this, true);
|
||||
BrowserApp.deck.addEventListener("blur", this, true);
|
||||
BrowserApp.deck.addEventListener("click", this, true);
|
||||
BrowserApp.deck.addEventListener("input", this, false);
|
||||
BrowserApp.deck.addEventListener("pageshow", this, false);
|
||||
|
@ -5541,6 +5548,7 @@ var FormAssistant = {
|
|||
Services.obs.removeObserver(this, "PanZoom:StateChange");
|
||||
|
||||
BrowserApp.deck.removeEventListener("focus", this);
|
||||
BrowserApp.deck.removeEventListener("blur", this);
|
||||
BrowserApp.deck.removeEventListener("click", this);
|
||||
BrowserApp.deck.removeEventListener("input", this);
|
||||
BrowserApp.deck.removeEventListener("pageshow", this);
|
||||
|
@ -5572,6 +5580,8 @@ var FormAssistant = {
|
|||
|
||||
let editableElement = this._currentInputElement.QueryInterface(Ci.nsIDOMNSEditableElement);
|
||||
|
||||
this._doingAutocomplete = true;
|
||||
|
||||
// If we have an active composition string, commit it before sending
|
||||
// the autocomplete event with the text that will replace it.
|
||||
try {
|
||||
|
@ -5581,10 +5591,14 @@ var FormAssistant = {
|
|||
} catch (e) {}
|
||||
|
||||
editableElement.setUserInput(aData);
|
||||
this._currentInputValue = aData;
|
||||
|
||||
let event = this._currentInputElement.ownerDocument.createEvent("Events");
|
||||
event.initEvent("DOMAutoComplete", true, true);
|
||||
this._currentInputElement.dispatchEvent(event);
|
||||
|
||||
this._doingAutocomplete = false;
|
||||
|
||||
break;
|
||||
|
||||
case "FormAssist:Blocklisted":
|
||||
|
@ -5615,15 +5629,21 @@ var FormAssistant = {
|
|||
|
||||
handleEvent: function(aEvent) {
|
||||
switch (aEvent.type) {
|
||||
case "focus":
|
||||
case "focus": {
|
||||
let currentElement = aEvent.target;
|
||||
|
||||
// Only show a validation message on focus.
|
||||
this._showValidationMessage(currentElement);
|
||||
break;
|
||||
}
|
||||
|
||||
case "click":
|
||||
currentElement = aEvent.target;
|
||||
case "blur": {
|
||||
this._currentInputValue = null;
|
||||
break;
|
||||
}
|
||||
|
||||
case "click": {
|
||||
let currentElement = aEvent.target;
|
||||
|
||||
// Prioritize a form validation message over autocomplete suggestions
|
||||
// when the element is first focused (a form validation message will
|
||||
|
@ -5639,9 +5659,21 @@ var FormAssistant = {
|
|||
|
||||
this._showAutoCompleteSuggestions(currentElement, checkResultsClick);
|
||||
break;
|
||||
}
|
||||
|
||||
case "input":
|
||||
currentElement = aEvent.target;
|
||||
case "input": {
|
||||
let currentElement = aEvent.target;
|
||||
|
||||
// If this element isn't focused, we're already in middle of an
|
||||
// autocomplete, or its value hasn't changed, don't show the
|
||||
// autocomplete popup.
|
||||
if (currentElement !== BrowserApp.getFocusedInput(BrowserApp.selectedBrowser) ||
|
||||
this._doingAutocomplete ||
|
||||
currentElement.value === this._currentInputValue) {
|
||||
break;
|
||||
}
|
||||
|
||||
this._currentInputValue = currentElement.value;
|
||||
|
||||
// Since we can only show one popup at a time, prioritze autocomplete
|
||||
// suggestions over a form validation message
|
||||
|
@ -5658,9 +5690,10 @@ var FormAssistant = {
|
|||
|
||||
this._showAutoCompleteSuggestions(currentElement, checkResultsInput);
|
||||
break;
|
||||
}
|
||||
|
||||
// Reset invalid submit state on each pageshow
|
||||
case "pageshow":
|
||||
case "pageshow": {
|
||||
if (!this._invalidSubmit)
|
||||
return;
|
||||
|
||||
|
@ -5671,6 +5704,8 @@ var FormAssistant = {
|
|||
if (target == selectedDocument || target.ownerDocument == selectedDocument)
|
||||
this._invalidSubmit = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче