Bug 1374893 - Don't handle the input event for inputs that aren't text controls; r=MattN

This commit is contained in:
Ehsan Akhgari
2017-06-20 21:37:20 -04:00
parent ab72c537c8
commit b9bffa40b9
2 changed files with 19 additions and 2 deletions

View File

@@ -916,6 +916,12 @@ nsFormFillController::HandleEvent(nsIDOMEvent* aEvent)
return KeyPress(aEvent);
case eEditorInput:
{
nsCOMPtr<nsINode> input = do_QueryInterface(
aEvent->InternalDOMEvent()->GetTarget());
if (!IsTextControl(input)) {
return NS_OK;
}
bool unused = false;
return (!mSuppressOnInput && mController && mFocusedInput) ?
mController->HandleText(&unused) : NS_OK;
@@ -996,6 +1002,14 @@ nsFormFillController::RemoveForDocument(nsIDocument* aDoc)
}
}
bool
nsFormFillController::IsTextControl(nsINode* aNode)
{
nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(aNode);
return formControl &&
formControl->IsSingleLineTextControl(false);
}
void
nsFormFillController::MaybeStartControllingInput(nsIDOMHTMLInputElement* aInput)
{
@@ -1004,8 +1018,7 @@ nsFormFillController::MaybeStartControllingInput(nsIDOMHTMLInputElement* aInput)
return;
}
nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(aInput);
if (!formControl || !formControl->IsSingleLineTextControl(false)) {
if (!IsTextControl(inputNode)) {
return;
}
@@ -1022,6 +1035,8 @@ nsFormFillController::MaybeStartControllingInput(nsIDOMHTMLInputElement* aInput)
bool hasList = datalist != nullptr;
bool isPwmgrInput = false;
nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(aInput);
MOZ_ASSERT(formControl, "If we have a text control, we have a form control!");
if (mPwmgrInputs.Get(inputNode) ||
formControl->ControlType() == NS_FORM_INPUT_PASSWORD) {
isPwmgrInput = true;

View File

@@ -87,6 +87,8 @@ protected:
void RemoveForDocument(nsIDocument* aDoc);
bool IsEventTrusted(nsIDOMEvent *aEvent);
bool IsTextControl(nsINode* aNode);
// members //////////////////////////////////////////
nsCOMPtr<nsIAutoCompleteController> mController;