Bug 1341582 - Apply form autofill to an already-focused input, r=MattN

MozReview-Commit-ID: C6zT7jKBb4c
This commit is contained in:
Luke Chang
2017-02-23 14:44:07 +08:00
parent 5ecf995179
commit ceb079459c
5 changed files with 20 additions and 8 deletions

View File

@@ -309,9 +309,23 @@ nsFormFillController::MarkAsAutofillField(nsIDOMHTMLInputElement *aInput)
*/
nsCOMPtr<nsINode> node = do_QueryInterface(aInput);
NS_ENSURE_STATE(node);
if (mAutofillInputs.Get(node)) {
return NS_OK;
}
mAutofillInputs.Put(node, true);
node->AddMutationObserverUnlessExists(this);
nsFocusManager *fm = nsFocusManager::GetFocusManager();
if (fm) {
nsCOMPtr<nsIContent> focusedContent = fm->GetFocusedContent();
if (SameCOMIdentity(focusedContent, node)) {
nsCOMPtr<nsIDOMHTMLInputElement> input = do_QueryInterface(node);
MaybeStartControllingInput(input);
}
}
return NS_OK;
}