| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 HTMLFormElement::HTMLFormElement(Document& document) | 64 HTMLFormElement::HTMLFormElement(Document& document) |
| 65 : HTMLElement(formTag, document) | 65 : HTMLElement(formTag, document) |
| 66 #if !ENABLE(OILPAN) | 66 #if !ENABLE(OILPAN) |
| 67 , m_weakPtrFactory(this) | 67 , m_weakPtrFactory(this) |
| 68 #endif | 68 #endif |
| 69 , m_associatedElementsAreDirty(false) | 69 , m_associatedElementsAreDirty(false) |
| 70 , m_imageElementsAreDirty(false) | 70 , m_imageElementsAreDirty(false) |
| 71 , m_hasElementsAssociatedByParser(false) | 71 , m_hasElementsAssociatedByParser(false) |
| 72 , m_didFinishParsingChildren(false) | 72 , m_didFinishParsingChildren(false) |
| 73 , m_wasUserSubmitted(false) | 73 , m_wasUserSubmitted(false) |
| 74 , m_isSubmittingOrInUserJSSubmitEvent(false) |
| 75 , m_shouldSubmit(false) |
| 74 , m_isInResetFunction(false) | 76 , m_isInResetFunction(false) |
| 75 , m_wasDemoted(false) | 77 , m_wasDemoted(false) |
| 76 , m_pendingAutocompleteEventsQueue(GenericEventQueue::create(this)) | 78 , m_pendingAutocompleteEventsQueue(GenericEventQueue::create(this)) |
| 77 { | 79 { |
| 78 ScriptWrappable::init(this); | 80 ScriptWrappable::init(this); |
| 79 } | 81 } |
| 80 | 82 |
| 81 PassRefPtrWillBeRawPtr<HTMLFormElement> HTMLFormElement::create(Document& docume
nt) | 83 PassRefPtrWillBeRawPtr<HTMLFormElement> HTMLFormElement::create(Document& docume
nt) |
| 82 { | 84 { |
| 83 UseCounter::count(document, UseCounter::FormElement); | 85 UseCounter::count(document, UseCounter::FormElement); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 document().addConsoleMessage(RenderingMessageSource, ErrorMessageLev
el, message); | 313 document().addConsoleMessage(RenderingMessageSource, ErrorMessageLev
el, message); |
| 312 } | 314 } |
| 313 } | 315 } |
| 314 return false; | 316 return false; |
| 315 } | 317 } |
| 316 | 318 |
| 317 void HTMLFormElement::prepareForSubmission(Event* event) | 319 void HTMLFormElement::prepareForSubmission(Event* event) |
| 318 { | 320 { |
| 319 RefPtrWillBeRawPtr<HTMLFormElement> protector(this); | 321 RefPtrWillBeRawPtr<HTMLFormElement> protector(this); |
| 320 LocalFrame* frame = document().frame(); | 322 LocalFrame* frame = document().frame(); |
| 321 if (!frame) | 323 if (!frame || m_isSubmittingOrInUserJSSubmitEvent) |
| 322 return; | 324 return; |
| 323 | 325 |
| 324 // Interactive validation must be done before dispatching the submit event. | 326 // Interactive validation must be done before dispatching the submit event. |
| 325 if (!validateInteractively(event)) | 327 if (!validateInteractively(event)) |
| 326 return; | 328 return; |
| 327 | 329 |
| 330 m_isSubmittingOrInUserJSSubmitEvent = true; |
| 331 m_shouldSubmit = false; |
| 332 |
| 328 frame->loader().client()->dispatchWillSendSubmitEvent(this); | 333 frame->loader().client()->dispatchWillSendSubmitEvent(this); |
| 329 | 334 |
| 330 if (dispatchEvent(Event::createCancelableBubble(EventTypeNames::submit))) | 335 if (dispatchEvent(Event::createCancelableBubble(EventTypeNames::submit))) |
| 336 m_shouldSubmit = true; |
| 337 |
| 338 m_isSubmittingOrInUserJSSubmitEvent = false; |
| 339 |
| 340 if (m_shouldSubmit) |
| 331 submit(event, true, true, NotSubmittedByJavaScript); | 341 submit(event, true, true, NotSubmittedByJavaScript); |
| 332 } | 342 } |
| 333 | 343 |
| 334 void HTMLFormElement::submit() | 344 void HTMLFormElement::submit() |
| 335 { | 345 { |
| 336 submit(0, false, true, NotSubmittedByJavaScript); | 346 submit(0, false, true, NotSubmittedByJavaScript); |
| 337 } | 347 } |
| 338 | 348 |
| 339 void HTMLFormElement::submitFromJavaScript() | 349 void HTMLFormElement::submitFromJavaScript() |
| 340 { | 350 { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 351 } | 361 } |
| 352 } | 362 } |
| 353 | 363 |
| 354 void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool proce
ssingUserGesture, FormSubmissionTrigger formSubmissionTrigger) | 364 void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool proce
ssingUserGesture, FormSubmissionTrigger formSubmissionTrigger) |
| 355 { | 365 { |
| 356 FrameView* view = document().view(); | 366 FrameView* view = document().view(); |
| 357 LocalFrame* frame = document().frame(); | 367 LocalFrame* frame = document().frame(); |
| 358 if (!view || !frame || !frame->page()) | 368 if (!view || !frame || !frame->page()) |
| 359 return; | 369 return; |
| 360 | 370 |
| 371 if (m_isSubmittingOrInUserJSSubmitEvent) { |
| 372 m_shouldSubmit = true; |
| 373 return; |
| 374 } |
| 375 |
| 376 m_isSubmittingOrInUserJSSubmitEvent = true; |
| 361 m_wasUserSubmitted = processingUserGesture; | 377 m_wasUserSubmitted = processingUserGesture; |
| 362 | 378 |
| 363 RefPtrWillBeRawPtr<HTMLFormControlElement> firstSuccessfulSubmitButton = nul
lptr; | 379 RefPtrWillBeRawPtr<HTMLFormControlElement> firstSuccessfulSubmitButton = nul
lptr; |
| 364 bool needButtonActivation = activateSubmitButton; // do we need to activate
a submit button? | 380 bool needButtonActivation = activateSubmitButton; // do we need to activate
a submit button? |
| 365 | 381 |
| 366 const FormAssociatedElement::List& elements = associatedElements(); | 382 const FormAssociatedElement::List& elements = associatedElements(); |
| 367 for (unsigned i = 0; i < elements.size(); ++i) { | 383 for (unsigned i = 0; i < elements.size(); ++i) { |
| 368 FormAssociatedElement* associatedElement = elements[i]; | 384 FormAssociatedElement* associatedElement = elements[i]; |
| 369 if (!associatedElement->isFormControlElement()) | 385 if (!associatedElement->isFormControlElement()) |
| 370 continue; | 386 continue; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 382 | 398 |
| 383 RefPtrWillBeRawPtr<FormSubmission> formSubmission = FormSubmission::create(t
his, m_attributes, event, formSubmissionTrigger); | 399 RefPtrWillBeRawPtr<FormSubmission> formSubmission = FormSubmission::create(t
his, m_attributes, event, formSubmissionTrigger); |
| 384 EventQueueScope scopeForDialogClose; // Delay dispatching 'close' to dialog
until done submitting. | 400 EventQueueScope scopeForDialogClose; // Delay dispatching 'close' to dialog
until done submitting. |
| 385 if (formSubmission->method() == FormSubmission::DialogMethod) | 401 if (formSubmission->method() == FormSubmission::DialogMethod) |
| 386 submitDialog(formSubmission.release()); | 402 submitDialog(formSubmission.release()); |
| 387 else | 403 else |
| 388 scheduleFormSubmission(formSubmission.release()); | 404 scheduleFormSubmission(formSubmission.release()); |
| 389 | 405 |
| 390 if (needButtonActivation && firstSuccessfulSubmitButton) | 406 if (needButtonActivation && firstSuccessfulSubmitButton) |
| 391 firstSuccessfulSubmitButton->setActivatedSubmit(false); | 407 firstSuccessfulSubmitButton->setActivatedSubmit(false); |
| 408 |
| 409 m_shouldSubmit = false; |
| 410 m_isSubmittingOrInUserJSSubmitEvent = false; |
| 392 } | 411 } |
| 393 | 412 |
| 394 void HTMLFormElement::scheduleFormSubmission(PassRefPtrWillBeRawPtr<FormSubmissi
on> submission) | 413 void HTMLFormElement::scheduleFormSubmission(PassRefPtrWillBeRawPtr<FormSubmissi
on> submission) |
| 395 { | 414 { |
| 396 ASSERT(submission->method() == FormSubmission::PostMethod || submission->met
hod() == FormSubmission::GetMethod); | 415 ASSERT(submission->method() == FormSubmission::PostMethod || submission->met
hod() == FormSubmission::GetMethod); |
| 397 ASSERT(submission->data()); | 416 ASSERT(submission->data()); |
| 398 ASSERT(submission->state()); | 417 ASSERT(submission->state()); |
| 399 if (submission->action().isEmpty()) | 418 if (submission->action().isEmpty()) |
| 400 return; | 419 return; |
| 401 if (document().isSandboxed(SandboxForms)) { | 420 if (document().isSandboxed(SandboxForms)) { |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 } | 845 } |
| 827 | 846 |
| 828 void HTMLFormElement::setDemoted(bool demoted) | 847 void HTMLFormElement::setDemoted(bool demoted) |
| 829 { | 848 { |
| 830 if (demoted) | 849 if (demoted) |
| 831 UseCounter::count(document(), UseCounter::DemotedFormElement); | 850 UseCounter::count(document(), UseCounter::DemotedFormElement); |
| 832 m_wasDemoted = demoted; | 851 m_wasDemoted = demoted; |
| 833 } | 852 } |
| 834 | 853 |
| 835 } // namespace | 854 } // namespace |
| OLD | NEW |