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.

git-svn-id: svn://10.0.0.236/trunk@160031 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bryner%brianryner.com 2004-07-29 08:08:11 +00:00
parent 2c6700f618
commit 47ff21d4cf
5 changed files with 9 additions and 16 deletions

View File

@ -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) {

View File

@ -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);"/>

View File

@ -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 ||

View File

@ -354,9 +354,7 @@
<body>
<![CDATA[
this.removeEventListener("load", this.handleEvent, true);
if (this.hasAttribute("autocompleteenabled"))
this.attachFormFill();
this.attachFormFill();
]]>
</body>
</method>

View File

@ -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>