Bug 1330111 - Always attempt to autocomplete on type=password fields upon focus. r=daleharvey

Let password manager handle opening the popup on username fields itself.

MozReview-Commit-ID: FbI6CgsadEd

--HG--
extra : rebase_source : a52ffb5e7e5ae0f15a71309bdf5bf3bbf246b09e
This commit is contained in:
Matthew Noorenberghe 2017-02-07 11:15:35 +08:00
Родитель 9e65b95fe1
Коммит 3e2d9794ad
2 изменённых файлов: 15 добавлений и 10 удалений

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

@ -172,6 +172,7 @@ pref("browser.helperApps.deleteTempFileOnExit", false);
/* password manager */
pref("signon.rememberSignons", true);
pref("signon.autofillForms.http", true);
pref("signon.expireMasterPassword", false);
pref("signon.debug", false);

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

@ -291,7 +291,6 @@ nsFormFillController::MarkAsLoginManagerField(nsIDOMHTMLInputElement *aInput)
if (!mFocusedInput) {
MaybeStartControllingInput(input);
}
ShowPopup();
}
}
@ -706,6 +705,7 @@ nsFormFillController::StartSearch(const nsAString &aSearchString, const nsAStrin
// If the login manager has indicated it's responsible for this field, let it
// handle the autocomplete. Otherwise, handle with form history.
// This method is sometimes called in unit tests and from XUL without a focused node.
if (mFocusedInputNode && (mPwmgrInputs.Get(mFocusedInputNode) ||
formControl->GetType() == NS_FORM_INPUT_PASSWORD)) {
@ -715,6 +715,10 @@ nsFormFillController::StartSearch(const nsAString &aSearchString, const nsAStrin
mLoginManager = do_GetService("@mozilla.org/login-manager;1");
}
if (NS_WARN_IF(!mLoginManager)) {
return NS_ERROR_FAILURE;
}
// XXX aPreviousResult shouldn't ever be a historyResult type, since we're not letting
// satchel manage the field?
mLastListener = aListener;
@ -992,8 +996,10 @@ nsFormFillController::MaybeStartControllingInput(nsIDOMHTMLInputElement* aInput)
bool hasList = datalist != nullptr;
bool isPwmgrInput = false;
if (mPwmgrInputs.Get(inputNode))
isPwmgrInput = true;
if (mPwmgrInputs.Get(inputNode) ||
formControl->GetType() == NS_FORM_INPUT_PASSWORD) {
isPwmgrInput = true;
}
if (isPwmgrInput || hasList || autocomplete) {
StartControllingInput(aInput);
@ -1013,19 +1019,17 @@ nsFormFillController::Focus(nsIDOMEvent* aEvent)
return NS_OK;
}
#ifndef ANDROID
nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(mFocusedInputNode);
MOZ_ASSERT(formControl);
// If this focus doesn't immediately follow a contextmenu event then show
// the autocomplete popup
if (!mContextMenuFiredBeforeFocus &&
(mPwmgrInputs.Get(mFocusedInputNode)
#ifndef ANDROID
|| formControl->GetType() == NS_FORM_INPUT_PASSWORD
#endif
)) {
// the autocomplete popup for all password fields.
if (!mContextMenuFiredBeforeFocus
&& formControl->GetType() == NS_FORM_INPUT_PASSWORD) {
ShowPopup();
}
#endif
mContextMenuFiredBeforeFocus = false;
return NS_OK;