Bug 1728081 - Part 4: Make HTMLFormElement::GetDefaultSubmitElement return nsGenericHTMLFormElement; r=smaug

so that the callers don't need to queryInterface it back to nsIContent.

Differential Revision: https://phabricator.services.mozilla.com/D123952
This commit is contained in:
Edgar Chen
2021-08-30 18:44:51 +00:00
parent c791a38187
commit 82070f5956
4 changed files with 5 additions and 11 deletions

View File

@@ -2919,12 +2919,8 @@ nsresult HTMLInputElement::MaybeSubmitForm(nsPresContext* aPresContext) {
}
// Get the default submit element
nsIFormControl* submitControl = mForm->GetDefaultSubmitElement();
if (submitControl) {
nsCOMPtr<nsIContent> submitContent = do_QueryInterface(submitControl);
NS_ASSERTION(submitContent, "Form control not implementing nsIContent?!");
// Fire the button's onclick handler and let the button handle
// submitting the form.
if (RefPtr<nsGenericHTMLFormElement> submitContent =
mForm->GetDefaultSubmitElement()) {
WidgetMouseEvent event(true, eMouseClick, nullptr, WidgetMouseEvent::eReal);
nsEventStatus status = nsEventStatus_eIgnore;
presShell->HandleDOMEventWithTarget(submitContent, &event, &status);