Bug 376668 - Make login fields show autocomplete on focus. r=mattn

This commit is contained in:
Dale Harvey
2016-11-21 15:20:44 +00:00
parent df3308737e
commit d22815a8fa
3 changed files with 46 additions and 0 deletions

View File

@@ -69,6 +69,7 @@ nsFormFillController::nsFormFillController() :
mTimeout(50),
mMinResultsForPopup(1),
mMaxRows(0),
mContextMenuFiredBeforeFocus(false),
mDisableAutoComplete(false),
mCompleteDefaultIndex(false),
mCompleteSelectedIndex(false),
@@ -857,6 +858,7 @@ nsFormFillController::HandleEvent(nsIDOMEvent* aEvent)
return NS_OK;
}
if (type.EqualsLiteral("contextmenu")) {
mContextMenuFiredBeforeFocus = true;
if (mFocusedPopup)
mFocusedPopup->ClosePopup();
return NS_OK;
@@ -932,6 +934,14 @@ nsFormFillController::Focus(nsIDOMEvent* aEvent)
nsCOMPtr<nsIDOMHTMLInputElement> input = do_QueryInterface(
aEvent->InternalDOMEvent()->GetTarget());
MaybeStartControllingInput(input);
// If this focus doesn't immediately follow a contextmenu event then show
// the autocomplete popup
if (!mContextMenuFiredBeforeFocus && mPwmgrInputs.Get(mFocusedInputNode)) {
ShowPopup();
}
mContextMenuFiredBeforeFocus = false;
return NS_OK;
}
@@ -1064,6 +1074,12 @@ nsFormFillController::MouseDown(nsIDOMEvent* aEvent)
if (button != 0)
return NS_OK;
return ShowPopup();
}
nsresult
nsFormFillController::ShowPopup()
{
bool isOpen = false;
GetPopupOpen(&isOpen);
if (isOpen) {
@@ -1227,6 +1243,10 @@ nsFormFillController::StopControllingInput()
mFocusedInputNode = nullptr;
mFocusedInput = nullptr;
}
if (mFocusedPopup) {
mFocusedPopup->ClosePopup();
}
mFocusedPopup = nullptr;
}