Index: Source/core/html/HTMLFormElement.cpp |
diff --git a/Source/core/html/HTMLFormElement.cpp b/Source/core/html/HTMLFormElement.cpp |
index 7e5a7859d87924d3238f3ac9ad3b22a6f35a131a..fe08960c93222cae86803474ff7804e8d7c50c8a 100644 |
--- a/Source/core/html/HTMLFormElement.cpp |
+++ b/Source/core/html/HTMLFormElement.cpp |
@@ -67,8 +67,7 @@ HTMLFormElement::HTMLFormElement(Document& document) |
, m_hasElementsAssociatedByParser(false) |
, m_didFinishParsingChildren(false) |
, m_wasUserSubmitted(false) |
- , m_isSubmittingOrPreparingForSubmission(false) |
- , m_shouldSubmit(false) |
+ , m_isSubmitting(false) |
, m_isInResetFunction(false) |
, m_wasDemoted(false) |
, m_requestAutocompleteTimer(this, &HTMLFormElement::requestAutocompleteTimerFired) |
@@ -282,36 +281,26 @@ bool HTMLFormElement::validateInteractively(Event* event) |
return false; |
} |
-bool HTMLFormElement::prepareForSubmission(Event* event) |
+void HTMLFormElement::prepareForSubmission(Event* event) |
{ |
RefPtr<HTMLFormElement> protector(this); |
Frame* frame = document().frame(); |
- if (m_isSubmittingOrPreparingForSubmission || !frame) |
- return m_isSubmittingOrPreparingForSubmission; |
- |
- m_isSubmittingOrPreparingForSubmission = true; |
- m_shouldSubmit = false; |
+ if (m_isSubmitting || !frame) |
+ return; |
// Interactive validation must be done before dispatching the submit event. |
- if (!validateInteractively(event)) { |
- m_isSubmittingOrPreparingForSubmission = false; |
- return false; |
- } |
+ if (!validateInteractively(event)) |
+ return; |
StringPairVector controlNamesAndValues; |
getTextFieldValues(controlNamesAndValues); |
RefPtr<FormState> formState = FormState::create(this, controlNamesAndValues, &document(), NotSubmittedByJavaScript); |
frame->loader().client()->dispatchWillSendSubmitEvent(formState.release()); |
- if (dispatchEvent(Event::createCancelableBubble(EventTypeNames::submit))) |
- m_shouldSubmit = true; |
- |
- m_isSubmittingOrPreparingForSubmission = false; |
- |
- if (m_shouldSubmit) |
- submit(event, true, true, NotSubmittedByJavaScript); |
+ if (!dispatchEvent(Event::createCancelableBubble(EventTypeNames::submit))) |
+ return; |
- return m_shouldSubmit; |
+ submit(event, true, true, NotSubmittedByJavaScript); |
} |
void HTMLFormElement::submit() |
@@ -358,15 +347,10 @@ void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool proce |
{ |
FrameView* view = document().view(); |
Frame* frame = document().frame(); |
- if (!view || !frame || !frame->page()) |
+ if (!view || !frame || !frame->page() || m_isSubmitting) |
return; |
- if (m_isSubmittingOrPreparingForSubmission) { |
- m_shouldSubmit = true; |
- return; |
- } |
- |
- m_isSubmittingOrPreparingForSubmission = true; |
+ m_isSubmitting = true; |
m_wasUserSubmitted = processingUserGesture; |
RefPtr<HTMLFormControlElement> firstSuccessfulSubmitButton; |
@@ -399,8 +383,7 @@ void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool proce |
if (needButtonActivation && firstSuccessfulSubmitButton) |
firstSuccessfulSubmitButton->setActivatedSubmit(false); |
- m_shouldSubmit = false; |
- m_isSubmittingOrPreparingForSubmission = false; |
+ m_isSubmitting = false; |
} |
void HTMLFormElement::scheduleFormSubmission(PassRefPtr<FormSubmission> submission) |
@@ -431,6 +414,7 @@ void HTMLFormElement::scheduleFormSubmission(PassRefPtr<FormSubmission> submissi |
} else { |
submission->clearTarget(); |
} |
+ |
if (!targetFrame->page()) |
return; |