mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 01:05:45 +00:00
Bug 1330561 - Check if a relevant field is already focused when attaching autocomplete. r=MattN
Differential Revision: https://phabricator.services.mozilla.com/D21267 --HG-- extra : rebase_source : 34ff0ae0b4572e80f5b7de1d03ee4646b87ed31b extra : histedit_source : 4dd3e5a461b492c936aa22627be89242f8bf2a8a
This commit is contained in:
parent
2d986f3a3a
commit
c8923c1b00
@ -223,6 +223,12 @@ nsFormFillController::AttachToBrowser(nsIDocShell* aDocShell,
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window = GetWindowForDocShell(aDocShell);
|
||||
AddWindowListeners(window);
|
||||
|
||||
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
if (fm) {
|
||||
nsCOMPtr<nsIContent> focusedContent = fm->GetFocusedElement();
|
||||
this->HandleFocus(HTMLInputElement::FromNodeOrNull(focusedContent));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -943,9 +949,8 @@ void nsFormFillController::MaybeStartControllingInput(
|
||||
#endif
|
||||
}
|
||||
|
||||
nsresult nsFormFillController::Focus(Event* aEvent) {
|
||||
nsCOMPtr<nsIContent> input = do_QueryInterface(aEvent->GetComposedTarget());
|
||||
MaybeStartControllingInput(HTMLInputElement::FromNodeOrNull(input));
|
||||
nsresult nsFormFillController::HandleFocus(HTMLInputElement* aInput) {
|
||||
MaybeStartControllingInput(aInput);
|
||||
|
||||
// Bail if we didn't start controlling the input.
|
||||
if (!mFocusedInput) {
|
||||
@ -981,6 +986,11 @@ nsresult nsFormFillController::Focus(Event* aEvent) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsFormFillController::Focus(Event* aEvent) {
|
||||
nsCOMPtr<nsIContent> input = do_QueryInterface(aEvent->GetComposedTarget());
|
||||
return this->HandleFocus(HTMLInputElement::FromNodeOrNull(input));
|
||||
}
|
||||
|
||||
nsresult nsFormFillController::KeyDown(Event* aEvent) {
|
||||
NS_ASSERTION(mController, "should have a controller!");
|
||||
if (!mFocusedInput || !mController) {
|
||||
|
@ -73,6 +73,9 @@ class nsFormFillController final : public nsIFormFillController,
|
||||
|
||||
void StartControllingInput(mozilla::dom::HTMLInputElement* aInput);
|
||||
void StopControllingInput();
|
||||
|
||||
nsresult HandleFocus(mozilla::dom::HTMLInputElement* aInput);
|
||||
|
||||
/**
|
||||
* Checks that aElement is a type of element we want to fill, then calls
|
||||
* StartControllingInput on it.
|
||||
|
Loading…
Reference in New Issue
Block a user