зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1551264 - Move user-initiated flag for form submission from HTMLFormElement to HTMLFormSubmission; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D30945 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
4534b7e9ee
Коммит
2617857bc6
|
@ -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<nsIInputStream> 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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<Element> mOriginatingElement;
|
||||
|
||||
// Keep track of whether this form submission was user-initiated or not
|
||||
bool mInitiatedFromUserInput;
|
||||
};
|
||||
|
||||
class EncodingFormSubmission : public HTMLFormSubmission {
|
||||
|
|
Загрузка…
Ссылка в новой задаче