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..e934fc126337e9c9dbb73464e3c0639a9fa19ee4 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,12 @@ 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; |
+ AutoReset<bool> submitScope(&m_isSubmitting, true); |
HTMLFormControlElement* firstSuccessfulSubmitButton = nullptr; |
bool needButtonActivation = activateSubmitButton; // do we need to activate a submit button? |
@@ -380,16 +378,18 @@ void HTMLFormElement::submit(Event* event, bool activateSubmitButton) |
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; |
tkent
2016/08/17 14:02:57
Layout test submit-dialog-close-event.html failed
|
} |
void HTMLFormElement::scheduleFormSubmission(FormSubmission* submission) |