OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. |
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 if (!validateInteractively(event)) { | 296 if (!validateInteractively(event)) { |
297 m_isSubmittingOrPreparingForSubmission = false; | 297 m_isSubmittingOrPreparingForSubmission = false; |
298 return false; | 298 return false; |
299 } | 299 } |
300 | 300 |
301 StringPairVector controlNamesAndValues; | 301 StringPairVector controlNamesAndValues; |
302 getTextFieldValues(controlNamesAndValues); | 302 getTextFieldValues(controlNamesAndValues); |
303 RefPtr<FormState> formState = FormState::create(this, controlNamesAndValues, &document(), NotSubmittedByJavaScript); | 303 RefPtr<FormState> formState = FormState::create(this, controlNamesAndValues, &document(), NotSubmittedByJavaScript); |
304 frame->loader().client()->dispatchWillSendSubmitEvent(formState.release()); | 304 frame->loader().client()->dispatchWillSendSubmitEvent(formState.release()); |
305 | 305 |
306 if (dispatchEvent(Event::createCancelableBubble(EventTypeNames::submit))) | 306 // Set flag before submission as dispatchEvent could trigger another event |
307 m_shouldSubmit = true; | |
308 | |
309 m_isSubmittingOrPreparingForSubmission = false; | 307 m_isSubmittingOrPreparingForSubmission = false; |
310 | 308 |
311 if (m_shouldSubmit) | 309 // http://www.whatwg.org/specs/web-apps/current-work/#concept-form-submit |
310 // Submit Event can be cancelled i.e. returned false or can explicitly decla re default prevented | |
311 // http://www.w3.org/TR/DOM-Level-3-Events/#event-flow-default-cancel. | |
312 // Returning false is also considered as default prevented. | |
313 if (!dispatchEvent(Event::createCancelableBubble(EventTypeNames::submit)) | |
314 || event->defaultPrevented()) { | |
keishi
2014/02/25 15:00:57
I think prepareForSubmission is always called from
| |
315 return m_shouldSubmit; // i.e. do not proceed | |
316 } | |
317 if (!m_shouldSubmit) { | |
318 m_shouldSubmit = true; | |
312 submit(event, true, true, NotSubmittedByJavaScript); | 319 submit(event, true, true, NotSubmittedByJavaScript); |
320 } | |
313 | 321 |
314 return m_shouldSubmit; | 322 return m_shouldSubmit; |
315 } | 323 } |
316 | 324 |
317 void HTMLFormElement::submit() | 325 void HTMLFormElement::submit() |
318 { | 326 { |
319 submit(0, false, true, NotSubmittedByJavaScript); | 327 submit(0, false, true, NotSubmittedByJavaScript); |
320 } | 328 } |
321 | 329 |
322 void HTMLFormElement::submitFromJavaScript() | 330 void HTMLFormElement::submitFromJavaScript() |
(...skipping 28 matching lines...) Expand all Loading... | |
351 toHTMLDialogElement(node)->closeDialog(formSubmission->result()); | 359 toHTMLDialogElement(node)->closeDialog(formSubmission->result()); |
352 return; | 360 return; |
353 } | 361 } |
354 } | 362 } |
355 } | 363 } |
356 | 364 |
357 void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool proce ssingUserGesture, FormSubmissionTrigger formSubmissionTrigger) | 365 void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool proce ssingUserGesture, FormSubmissionTrigger formSubmissionTrigger) |
358 { | 366 { |
359 FrameView* view = document().view(); | 367 FrameView* view = document().view(); |
360 Frame* frame = document().frame(); | 368 Frame* frame = document().frame(); |
361 if (!view || !frame || !frame->page()) | 369 if (!view || !frame || !frame->page() || m_isSubmittingOrPreparingForSubmiss ion) |
362 return; | 370 return; |
363 | 371 |
364 if (m_isSubmittingOrPreparingForSubmission) { | |
365 m_shouldSubmit = true; | |
366 return; | |
367 } | |
368 | |
369 m_isSubmittingOrPreparingForSubmission = true; | 372 m_isSubmittingOrPreparingForSubmission = true; |
370 m_wasUserSubmitted = processingUserGesture; | 373 m_wasUserSubmitted = processingUserGesture; |
371 | 374 |
372 RefPtr<HTMLFormControlElement> firstSuccessfulSubmitButton; | 375 RefPtr<HTMLFormControlElement> firstSuccessfulSubmitButton; |
373 bool needButtonActivation = activateSubmitButton; // do we need to activate a submit button? | 376 bool needButtonActivation = activateSubmitButton; // do we need to activate a submit button? |
374 | 377 |
375 const Vector<FormAssociatedElement*>& elements = associatedElements(); | 378 const Vector<FormAssociatedElement*>& elements = associatedElements(); |
376 for (unsigned i = 0; i < elements.size(); ++i) { | 379 for (unsigned i = 0; i < elements.size(); ++i) { |
377 FormAssociatedElement* associatedElement = elements[i]; | 380 FormAssociatedElement* associatedElement = elements[i]; |
378 if (!associatedElement->isFormControlElement()) | 381 if (!associatedElement->isFormControlElement()) |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
817 } | 820 } |
818 | 821 |
819 void HTMLFormElement::setDemoted(bool demoted) | 822 void HTMLFormElement::setDemoted(bool demoted) |
820 { | 823 { |
821 if (demoted) | 824 if (demoted) |
822 UseCounter::count(document(), UseCounter::DemotedFormElement); | 825 UseCounter::count(document(), UseCounter::DemotedFormElement); |
823 m_wasDemoted = demoted; | 826 m_wasDemoted = demoted; |
824 } | 827 } |
825 | 828 |
826 } // namespace | 829 } // namespace |
OLD | NEW |