Bug 635749 - Don't assume we can press ENTER on an <input type='file'> to submit a form. r=bz,smaug

--HG--
extra : rebase_source : 85b73e61002ebc3c68cfff3363afb29b448c6121
This commit is contained in:
Mounir Lamouri 2011-04-13 12:43:34 -07:00
parent f31a56057f
commit bb311bd679

View File

@ -2310,8 +2310,7 @@ nsHTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
}
/*
* If this is input type=text, and the user hit enter, fire onChange
* and submit the form (if we are in one)
* For some input types, if the user hits enter, the form is submitted.
*
* Bug 99920, bug 109463 and bug 147850:
* (a) if there is a submit control in the form, click the first
@ -2325,29 +2324,7 @@ nsHTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
if (aVisitor.mEvent->message == NS_KEY_PRESS &&
(keyEvent->keyCode == NS_VK_RETURN ||
keyEvent->keyCode == NS_VK_ENTER) &&
(mType == NS_FORM_INPUT_TEXT ||
mType == NS_FORM_INPUT_EMAIL ||
mType == NS_FORM_INPUT_SEARCH ||
mType == NS_FORM_INPUT_PASSWORD ||
mType == NS_FORM_INPUT_TEL ||
mType == NS_FORM_INPUT_URL ||
mType == NS_FORM_INPUT_FILE)) {
PRBool isButton = PR_FALSE;
// If this is an enter on the button of a file input, don't submit
// -- that's supposed to put up the filepicker
if (mType == NS_FORM_INPUT_FILE) {
nsCOMPtr<nsIContent> maybeButton =
do_QueryInterface(aVisitor.mEvent->originalTarget);
if (maybeButton) {
isButton = maybeButton->AttrValueIs(kNameSpaceID_None,
nsGkAtoms::type,
nsGkAtoms::button,
eCaseMatters);
}
}
if (!isButton) {
IsSingleLineTextControl(PR_FALSE, mType)) {
nsIFrame* primaryFrame = GetPrimaryFrame();
if (primaryFrame) {
nsITextControlFrame* textFrame = do_QueryFrame(primaryFrame);
@ -2361,7 +2338,6 @@ nsHTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
rv = MaybeSubmitForm(aVisitor.mPresContext);
NS_ENSURE_SUCCESS(rv, rv);
}
}
} break; // NS_KEY_PRESS || NS_KEY_UP