зеркало из https://github.com/mozilla/gecko-dev.git
Fix some problems related to dynamic enabling/disabling of form autocomplete: make autocomplete ignore all key navigation if the input is disabled, also, instead of trying to keep autocomplete state in sync on every browser instance, just set the disabled state on the global form fill controller. Bug 249610, r=blake.
This commit is contained in:
Родитель
ad9896bd58
Коммит
1a8b51b957
|
@ -465,6 +465,7 @@ function delayedStartup()
|
|||
gFormFillPrefListener = new FormFillPrefListener();
|
||||
var pbi = gPrefService.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
|
||||
pbi.addObserver(gFormFillPrefListener.domain, gFormFillPrefListener, false);
|
||||
gFormFillPrefListener.toggleFormFill();
|
||||
|
||||
// Enable/Disable URL Bar Auto Fill
|
||||
gURLBarAutoFillPrefListener = new URLBarAutoFillPrefListener();
|
||||
|
@ -637,7 +638,8 @@ FormFillPrefListener.prototype =
|
|||
}
|
||||
catch (e) {
|
||||
}
|
||||
gBrowser.setAttribute("autocompleteenabled", gFormFillEnabled);
|
||||
var formController = Components.classes["@mozilla.org/satchel/form-fill-controller;1"].getService(Components.interfaces.nsIAutoCompleteInput);
|
||||
formController.disableAutoComplete = !gFormFillEnabled;
|
||||
|
||||
var searchBar = document.getElementById("search-bar");
|
||||
if (searchBar) {
|
||||
|
|
|
@ -410,7 +410,6 @@
|
|||
flex="1" contenttooltip="aHTMLTooltip"
|
||||
contentcontextmenu="contentAreaContextMenu"
|
||||
onnewtab="BrowserOpenTab();"
|
||||
autocompleteenabled="true"
|
||||
autocompletepopup="PopupAutoComplete"
|
||||
ondragdrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);"
|
||||
onclick="return contentAreaClick(event, false);"/>
|
||||
|
|
|
@ -175,7 +175,7 @@ nsAutoCompleteController::HandleText()
|
|||
|
||||
PRBool disabled;
|
||||
mInput->GetDisableAutoComplete(&disabled);
|
||||
NS_ENSURE_TRUE(!disabled, NS_OK;);
|
||||
NS_ENSURE_TRUE(!disabled, NS_OK);
|
||||
|
||||
nsAutoString newValue;
|
||||
mInput->GetTextValue(newValue);
|
||||
|
@ -270,6 +270,10 @@ nsAutoCompleteController::HandleKeyNavigation(PRUint16 aKey, PRBool *_retval)
|
|||
mInput->GetPopup(getter_AddRefs(popup));
|
||||
NS_ENSURE_TRUE(popup != nsnull, NS_ERROR_FAILURE);
|
||||
|
||||
PRBool disabled;
|
||||
mInput->GetDisableAutoComplete(&disabled);
|
||||
NS_ENSURE_TRUE(!disabled, NS_OK);
|
||||
|
||||
if (aKey == nsIAutoCompleteController::KEY_UP ||
|
||||
aKey == nsIAutoCompleteController::KEY_DOWN ||
|
||||
aKey == nsIAutoCompleteController::KEY_PAGE_UP ||
|
||||
|
|
|
@ -354,9 +354,7 @@
|
|||
<body>
|
||||
<![CDATA[
|
||||
this.removeEventListener("load", this.handleEvent, true);
|
||||
|
||||
if (this.hasAttribute("autocompleteenabled"))
|
||||
this.attachFormFill();
|
||||
this.attachFormFill();
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
|
|
@ -809,12 +809,6 @@
|
|||
b.setAttribute("tooltip", this.getAttribute("contenttooltip"));
|
||||
b.setAttribute("autocompletepopup", this.getAttribute("autocompletepopup"));
|
||||
|
||||
// To avoid unnecessary string compares on pageload in <browser>, only set the
|
||||
// autocomplete attribute if autocomplete is actually enabled, so we can
|
||||
// just test with |hasAttribute| in <browser>'s load handler.
|
||||
if (this.getAttribute("autocompleteenabled") == "true")
|
||||
b.setAttribute("autocompleteenabled", "true");
|
||||
|
||||
this.mPanelContainer.appendChild(b);
|
||||
|
||||
b.addEventListener("DOMTitleChanged", this.onTitleChanged, false);
|
||||
|
@ -1268,9 +1262,6 @@
|
|||
var browsers = this.mPanelContainer.childNodes;
|
||||
for (var i = 0; i < browsers.length; ++i) {
|
||||
var cb = browsers[i];
|
||||
// We can do stuff like this here because we aren't called on every
|
||||
// page load, like <browser>'s |attachFormFill| method is.
|
||||
cb.setAttribute("autocompleteenabled", "true");
|
||||
cb.attachFormFill();
|
||||
}
|
||||
]]></body>
|
||||
|
@ -1281,7 +1272,6 @@
|
|||
var browsers = this.mPanelContainer.childNodes;
|
||||
for (var i = 0; i < browsers.length; ++i) {
|
||||
var cb = browsers[i];
|
||||
cb.removeAttribute("autocompleteenabled");
|
||||
cb.detachFormFill();
|
||||
}
|
||||
]]></body>
|
||||
|
|
Загрузка…
Ссылка в новой задаче