Bug 1206616 - Part 1: Fire input event for type=checkbox,radio,file. r=smaug

This commit is contained in:
Jessica Jong
2016-04-25 19:52:00 +02:00
parent cd8c642325
commit e6db634428
3 changed files with 58 additions and 12 deletions

View File

@@ -537,10 +537,20 @@ HTMLInputElement::nsFilePickerShownCallback::Done(int16_t aResult)
// event because it will think this is done by a script.
// So, we can safely send one by ourself.
mInput->SetFilesOrDirectories(newFilesOrDirectories, true);
return nsContentUtils::DispatchTrustedEvent(mInput->OwnerDoc(),
static_cast<nsIDOMHTMLInputElement*>(mInput.get()),
NS_LITERAL_STRING("change"), true,
false);
nsresult rv = NS_OK;
rv = nsContentUtils::DispatchTrustedEvent(mInput->OwnerDoc(),
static_cast<nsIDOMHTMLInputElement*>(mInput.get()),
NS_LITERAL_STRING("input"), true,
false);
NS_WARN_IF(NS_FAILED(rv));
rv = nsContentUtils::DispatchTrustedEvent(mInput->OwnerDoc(),
static_cast<nsIDOMHTMLInputElement*>(mInput.get()),
NS_LITERAL_STRING("change"), true,
false);
return rv;
}
NS_IMPL_ISUPPORTS(HTMLInputElement::nsFilePickerShownCallback,
@@ -3849,6 +3859,12 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
DoSetChecked(originalCheckedValue, true, true);
}
} else {
// Fire input event and then change event.
nsContentUtils::DispatchTrustedEvent(OwnerDoc(),
static_cast<nsIDOMHTMLInputElement*>(this),
NS_LITERAL_STRING("input"), true,
false);
nsContentUtils::DispatchTrustedEvent(OwnerDoc(),
static_cast<nsIDOMHTMLInputElement*>(this),
NS_LITERAL_STRING("change"), true,