diff --git a/dom/html/HTMLFormElement.cpp b/dom/html/HTMLFormElement.cpp
index bbffcbebd0d7..afed60b97f8d 100644
--- a/dom/html/HTMLFormElement.cpp
+++ b/dom/html/HTMLFormElement.cpp
@@ -9,7 +9,6 @@
#include "jsapi.h"
#include "mozilla/ContentEvents.h"
#include "mozilla/EventDispatcher.h"
-#include "mozilla/EventStateManager.h"
#include "mozilla/EventStates.h"
#include "mozilla/dom/nsCSPUtils.h"
#include "mozilla/dom/nsCSPContext.h"
@@ -115,7 +114,6 @@ HTMLFormElement::HTMLFormElement(
mDeferSubmission(false),
mNotifiedObservers(false),
mNotifiedObserversResult(false),
- mSubmitInitiatedFromUserInput(false),
mEverTriedInvalidSubmit(false) {
// We start out valid.
AddStatesSilently(NS_EVENT_STATE_VALID);
@@ -571,8 +569,6 @@ nsresult HTMLFormElement::DoSubmit(WidgetEvent* aEvent) {
mSubmitPopupState = PopupBlocker::openAbused;
}
- mSubmitInitiatedFromUserInput = EventStateManager::IsHandlingUserInput();
-
if (mDeferSubmission) {
// we are in an event handler, JS submitted so we have to
// defer this submission. let's remember it and return
@@ -696,7 +692,7 @@ nsresult HTMLFormElement::SubmitSubmission(
nsAutoPopupStatePusher popupStatePusher(mSubmitPopupState);
AutoHandlingUserInputStatePusher userInpStatePusher(
- mSubmitInitiatedFromUserInput, nullptr, doc);
+ aFormSubmission->IsInitiatedFromUserInput(), nullptr, doc);
nsCOMPtr postDataStream;
rv = aFormSubmission->GetEncodedSubmission(
@@ -708,7 +704,7 @@ nsresult HTMLFormElement::SubmitSubmission(
rv = linkHandler->OnLinkClickSync(
this, actionURI, target, VoidString(), postDataStream, nullptr, false,
getter_AddRefs(docShell), getter_AddRefs(mSubmittingRequest),
- EventStateManager::IsHandlingUserInput());
+ aFormSubmission->IsInitiatedFromUserInput());
NS_ENSURE_SUBMIT_SUCCESS(rv);
}
diff --git a/dom/html/HTMLFormElement.h b/dom/html/HTMLFormElement.h
index 19ba26cb66b1..1a547f0501d4 100644
--- a/dom/html/HTMLFormElement.h
+++ b/dom/html/HTMLFormElement.h
@@ -594,8 +594,6 @@ class HTMLFormElement final : public nsGenericHTMLElement,
bool mNotifiedObservers;
/** If we notified the listeners early, what was the result? */
bool mNotifiedObserversResult;
- /** Keep track of whether a submission was user-initiated or not */
- bool mSubmitInitiatedFromUserInput;
/**
* Whether the submission of this form has been ever prevented because of
* being invalid.
diff --git a/dom/html/HTMLFormSubmission.h b/dom/html/HTMLFormSubmission.h
index cd2bd83668ca..56f81ffa970e 100644
--- a/dom/html/HTMLFormSubmission.h
+++ b/dom/html/HTMLFormSubmission.h
@@ -9,6 +9,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/dom/Element.h"
+#include "mozilla/EventStateManager.h"
#include "nsCOMPtr.h"
#include "mozilla/Encoding.h"
#include "nsString.h"
@@ -103,6 +104,11 @@ class HTMLFormSubmission {
*/
void GetTarget(nsAString& aTarget) { aTarget = mTarget; }
+ /**
+ * Return true if this form submission was user-initiated.
+ */
+ bool IsInitiatedFromUserInput() const { return mInitiatedFromUserInput; }
+
protected:
/**
* Can only be constructed by subclasses.
@@ -116,7 +122,8 @@ class HTMLFormSubmission {
: mActionURL(aActionURL),
mTarget(aTarget),
mEncoding(aEncoding),
- mOriginatingElement(aOriginatingElement) {
+ mOriginatingElement(aOriginatingElement),
+ mInitiatedFromUserInput(EventStateManager::IsHandlingUserInput()) {
MOZ_COUNT_CTOR(HTMLFormSubmission);
}
@@ -131,6 +138,9 @@ class HTMLFormSubmission {
// Originating element.
RefPtr mOriginatingElement;
+
+ // Keep track of whether this form submission was user-initiated or not
+ bool mInitiatedFromUserInput;
};
class EncodingFormSubmission : public HTMLFormSubmission {