зеркало из 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();
|
gFormFillPrefListener = new FormFillPrefListener();
|
||||||
var pbi = gPrefService.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
|
var pbi = gPrefService.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
|
||||||
pbi.addObserver(gFormFillPrefListener.domain, gFormFillPrefListener, false);
|
pbi.addObserver(gFormFillPrefListener.domain, gFormFillPrefListener, false);
|
||||||
|
gFormFillPrefListener.toggleFormFill();
|
||||||
|
|
||||||
// Enable/Disable URL Bar Auto Fill
|
// Enable/Disable URL Bar Auto Fill
|
||||||
gURLBarAutoFillPrefListener = new URLBarAutoFillPrefListener();
|
gURLBarAutoFillPrefListener = new URLBarAutoFillPrefListener();
|
||||||
|
@ -637,7 +638,8 @@ FormFillPrefListener.prototype =
|
||||||
}
|
}
|
||||||
catch (e) {
|
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");
|
var searchBar = document.getElementById("search-bar");
|
||||||
if (searchBar) {
|
if (searchBar) {
|
||||||
|
|
|
@ -410,7 +410,6 @@
|
||||||
flex="1" contenttooltip="aHTMLTooltip"
|
flex="1" contenttooltip="aHTMLTooltip"
|
||||||
contentcontextmenu="contentAreaContextMenu"
|
contentcontextmenu="contentAreaContextMenu"
|
||||||
onnewtab="BrowserOpenTab();"
|
onnewtab="BrowserOpenTab();"
|
||||||
autocompleteenabled="true"
|
|
||||||
autocompletepopup="PopupAutoComplete"
|
autocompletepopup="PopupAutoComplete"
|
||||||
ondragdrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);"
|
ondragdrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);"
|
||||||
onclick="return contentAreaClick(event, false);"/>
|
onclick="return contentAreaClick(event, false);"/>
|
||||||
|
|
|
@ -175,7 +175,7 @@ nsAutoCompleteController::HandleText()
|
||||||
|
|
||||||
PRBool disabled;
|
PRBool disabled;
|
||||||
mInput->GetDisableAutoComplete(&disabled);
|
mInput->GetDisableAutoComplete(&disabled);
|
||||||
NS_ENSURE_TRUE(!disabled, NS_OK;);
|
NS_ENSURE_TRUE(!disabled, NS_OK);
|
||||||
|
|
||||||
nsAutoString newValue;
|
nsAutoString newValue;
|
||||||
mInput->GetTextValue(newValue);
|
mInput->GetTextValue(newValue);
|
||||||
|
@ -270,6 +270,10 @@ nsAutoCompleteController::HandleKeyNavigation(PRUint16 aKey, PRBool *_retval)
|
||||||
mInput->GetPopup(getter_AddRefs(popup));
|
mInput->GetPopup(getter_AddRefs(popup));
|
||||||
NS_ENSURE_TRUE(popup != nsnull, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(popup != nsnull, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
PRBool disabled;
|
||||||
|
mInput->GetDisableAutoComplete(&disabled);
|
||||||
|
NS_ENSURE_TRUE(!disabled, NS_OK);
|
||||||
|
|
||||||
if (aKey == nsIAutoCompleteController::KEY_UP ||
|
if (aKey == nsIAutoCompleteController::KEY_UP ||
|
||||||
aKey == nsIAutoCompleteController::KEY_DOWN ||
|
aKey == nsIAutoCompleteController::KEY_DOWN ||
|
||||||
aKey == nsIAutoCompleteController::KEY_PAGE_UP ||
|
aKey == nsIAutoCompleteController::KEY_PAGE_UP ||
|
||||||
|
|
|
@ -354,8 +354,6 @@
|
||||||
<body>
|
<body>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
this.removeEventListener("load", this.handleEvent, true);
|
this.removeEventListener("load", this.handleEvent, true);
|
||||||
|
|
||||||
if (this.hasAttribute("autocompleteenabled"))
|
|
||||||
this.attachFormFill();
|
this.attachFormFill();
|
||||||
]]>
|
]]>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -809,12 +809,6 @@
|
||||||
b.setAttribute("tooltip", this.getAttribute("contenttooltip"));
|
b.setAttribute("tooltip", this.getAttribute("contenttooltip"));
|
||||||
b.setAttribute("autocompletepopup", this.getAttribute("autocompletepopup"));
|
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);
|
this.mPanelContainer.appendChild(b);
|
||||||
|
|
||||||
b.addEventListener("DOMTitleChanged", this.onTitleChanged, false);
|
b.addEventListener("DOMTitleChanged", this.onTitleChanged, false);
|
||||||
|
@ -1268,9 +1262,6 @@
|
||||||
var browsers = this.mPanelContainer.childNodes;
|
var browsers = this.mPanelContainer.childNodes;
|
||||||
for (var i = 0; i < browsers.length; ++i) {
|
for (var i = 0; i < browsers.length; ++i) {
|
||||||
var cb = browsers[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();
|
cb.attachFormFill();
|
||||||
}
|
}
|
||||||
]]></body>
|
]]></body>
|
||||||
|
@ -1281,7 +1272,6 @@
|
||||||
var browsers = this.mPanelContainer.childNodes;
|
var browsers = this.mPanelContainer.childNodes;
|
||||||
for (var i = 0; i < browsers.length; ++i) {
|
for (var i = 0; i < browsers.length; ++i) {
|
||||||
var cb = browsers[i];
|
var cb = browsers[i];
|
||||||
cb.removeAttribute("autocompleteenabled");
|
|
||||||
cb.detachFormFill();
|
cb.detachFormFill();
|
||||||
}
|
}
|
||||||
]]></body>
|
]]></body>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче