Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: third_party/WebKit/Source/core/html/HTMLFormElement.cpp

Issue 2245263005: Split HTMLFormElement::m_isSubmittingOrInUserJSSubmitEvent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change the order of AutoReset<> and EventQueueScope Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLFormElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLFormElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLFormElement.cpp b/third_party/WebKit/Source/core/html/HTMLFormElement.cpp
index 4675fc34b6e08b16f46645d1e815d935b7e51cd4..764102ff84827ab38789db1352d0d886c4b96c4d 100644
--- a/third_party/WebKit/Source/core/html/HTMLFormElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLFormElement.cpp
@@ -55,6 +55,7 @@
#include "core/loader/NavigationScheduler.h"
#include "platform/UserGestureIndicator.h"
#include "public/platform/WebInsecureRequestPolicy.h"
+#include "wtf/AutoReset.h"
#include "wtf/text/AtomicString.h"
#include <limits>
@@ -69,7 +70,6 @@ HTMLFormElement::HTMLFormElement(Document& document)
, m_hasElementsAssociatedByParser(false)
, m_hasElementsAssociatedByFormAttribute(false)
, m_didFinishParsingChildren(false)
- , m_isSubmittingOrInUserJSSubmitEvent(false)
, m_shouldSubmit(false)
, m_isInResetFunction(false)
, m_wasDemoted(false)
@@ -293,7 +293,7 @@ bool HTMLFormElement::validateInteractively()
void HTMLFormElement::prepareForSubmission(Event* event)
{
LocalFrame* frame = document().frame();
- if (!frame || m_isSubmittingOrInUserJSSubmitEvent)
+ if (!frame || m_isSubmitting || m_inUserJSSubmitEvent)
return;
if (document().isSandboxed(SandboxForms)) {
@@ -312,15 +312,13 @@ void HTMLFormElement::prepareForSubmission(Event* event)
if (!skipValidation && !validateInteractively())
return;
- m_isSubmittingOrInUserJSSubmitEvent = true;
- m_shouldSubmit = false;
-
- frame->loader().client()->dispatchWillSendSubmitEvent(this);
-
- if (dispatchEvent(Event::createCancelableBubble(EventTypeNames::submit)) == DispatchEventResult::NotCanceled)
- m_shouldSubmit = true;
-
- m_isSubmittingOrInUserJSSubmitEvent = false;
+ {
+ AutoReset<bool> submitEventHandlerScope(&m_inUserJSSubmitEvent, true);
+ m_shouldSubmit = false;
+ frame->loader().client()->dispatchWillSendSubmitEvent(this);
+ if (dispatchEvent(Event::createCancelableBubble(EventTypeNames::submit)) == DispatchEventResult::NotCanceled)
+ m_shouldSubmit = true;
+ }
if (m_shouldSubmit)
submit(event, true);
@@ -351,12 +349,14 @@ void HTMLFormElement::submit(Event* event, bool activateSubmitButton)
if (!isConnected())
UseCounter::count(document(), UseCounter::FormSubmissionNotInDocumentTree);
- if (m_isSubmittingOrInUserJSSubmitEvent) {
+ if (m_isSubmitting || m_inUserJSSubmitEvent) {
m_shouldSubmit = true;
return;
}
- m_isSubmittingOrInUserJSSubmitEvent = true;
+ // Delay dispatching 'close' to dialog until done submitting.
+ EventQueueScope scopeForDialogClose;
+ AutoReset<bool> submitScope(&m_isSubmitting, true);
HTMLFormControlElement* firstSuccessfulSubmitButton = nullptr;
bool needButtonActivation = activateSubmitButton; // do we need to activate a submit button?
@@ -379,17 +379,18 @@ void HTMLFormElement::submit(Event* event, bool activateSubmitButton)
firstSuccessfulSubmitButton->setActivatedSubmit(true);
FormSubmission* formSubmission = FormSubmission::create(this, m_attributes, event);
- EventQueueScope scopeForDialogClose; // Delay dispatching 'close' to dialog until done submitting.
- if (formSubmission->method() == FormSubmission::DialogMethod)
+ if (formSubmission->method() == FormSubmission::DialogMethod) {
submitDialog(formSubmission);
- else
+ } else {
+ // This runs JavaScript code if action attribute value is javascript:
+ // protocol.
scheduleFormSubmission(formSubmission);
+ }
if (needButtonActivation && firstSuccessfulSubmitButton)
firstSuccessfulSubmitButton->setActivatedSubmit(false);
m_shouldSubmit = false;
- m_isSubmittingOrInUserJSSubmitEvent = false;
}
void HTMLFormElement::scheduleFormSubmission(FormSubmission* submission)
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLFormElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698