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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 using namespace HTMLNames; | 59 using namespace HTMLNames; |
60 | 60 |
61 HTMLFormElement::HTMLFormElement(Document& document) | 61 HTMLFormElement::HTMLFormElement(Document& document) |
62 : HTMLElement(formTag, document) | 62 : HTMLElement(formTag, document) |
63 , m_weakPtrFactory(this) | 63 , m_weakPtrFactory(this) |
64 , m_associatedElementsAreDirty(false) | 64 , m_associatedElementsAreDirty(false) |
65 , m_imageElementsAreDirty(false) | 65 , m_imageElementsAreDirty(false) |
66 , m_hasElementsAssociatedByParser(false) | 66 , m_hasElementsAssociatedByParser(false) |
67 , m_didFinishParsingChildren(false) | 67 , m_didFinishParsingChildren(false) |
68 , m_wasUserSubmitted(false) | 68 , m_wasUserSubmitted(false) |
69 , m_shouldSubmit(false) | |
70 , m_isInResetFunction(false) | 69 , m_isInResetFunction(false) |
71 , m_wasDemoted(false) | 70 , m_wasDemoted(false) |
72 , m_requestAutocompleteTimer(this, &HTMLFormElement::requestAutocompleteTime
rFired) | 71 , m_requestAutocompleteTimer(this, &HTMLFormElement::requestAutocompleteTime
rFired) |
73 { | 72 { |
74 ScriptWrappable::init(this); | 73 ScriptWrappable::init(this); |
75 } | 74 } |
76 | 75 |
77 PassRefPtr<HTMLFormElement> HTMLFormElement::create(Document& document) | 76 PassRefPtr<HTMLFormElement> HTMLFormElement::create(Document& document) |
78 { | 77 { |
79 UseCounter::count(document, UseCounter::FormElement); | 78 UseCounter::count(document, UseCounter::FormElement); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 if (unhandled->isFocusable() && unhandled->inDocument()) | 272 if (unhandled->isFocusable() && unhandled->inDocument()) |
274 continue; | 273 continue; |
275 String message("An invalid form control with name='%name' is not foc
usable."); | 274 String message("An invalid form control with name='%name' is not foc
usable."); |
276 message.replace("%name", unhandledAssociatedElement->name()); | 275 message.replace("%name", unhandledAssociatedElement->name()); |
277 document().addConsoleMessage(RenderingMessageSource, ErrorMessageLev
el, message); | 276 document().addConsoleMessage(RenderingMessageSource, ErrorMessageLev
el, message); |
278 } | 277 } |
279 } | 278 } |
280 return false; | 279 return false; |
281 } | 280 } |
282 | 281 |
283 bool HTMLFormElement::prepareForSubmission(Event* event) | 282 void HTMLFormElement::prepareForSubmission(Event* event) |
284 { | 283 { |
285 RefPtr<HTMLFormElement> protector(this); | 284 RefPtr<HTMLFormElement> protector(this); |
286 LocalFrame* frame = document().frame(); | 285 LocalFrame* frame = document().frame(); |
287 if (!frame) | 286 if (!frame) |
288 return false; | 287 return; |
289 | |
290 m_shouldSubmit = false; | |
291 | 288 |
292 // Interactive validation must be done before dispatching the submit event. | 289 // Interactive validation must be done before dispatching the submit event. |
293 if (!validateInteractively(event)) | 290 if (!validateInteractively(event)) |
294 return false; | 291 return; |
295 | 292 |
296 frame->loader().client()->dispatchWillSendSubmitEvent(this); | 293 frame->loader().client()->dispatchWillSendSubmitEvent(this); |
297 | 294 |
298 if (dispatchEvent(Event::createCancelableBubble(EventTypeNames::submit))) | 295 if (dispatchEvent(Event::createCancelableBubble(EventTypeNames::submit))) |
299 m_shouldSubmit = true; | |
300 | |
301 if (m_shouldSubmit) | |
302 submit(event, true, true, NotSubmittedByJavaScript); | 296 submit(event, true, true, NotSubmittedByJavaScript); |
303 | |
304 return m_shouldSubmit; | |
305 } | 297 } |
306 | 298 |
307 void HTMLFormElement::submit() | 299 void HTMLFormElement::submit() |
308 { | 300 { |
309 submit(0, false, true, NotSubmittedByJavaScript); | 301 submit(0, false, true, NotSubmittedByJavaScript); |
310 } | 302 } |
311 | 303 |
312 void HTMLFormElement::submitFromJavaScript() | 304 void HTMLFormElement::submitFromJavaScript() |
313 { | 305 { |
314 submit(0, false, UserGestureIndicator::processingUserGesture(), SubmittedByJ
avaScript); | 306 submit(0, false, UserGestureIndicator::processingUserGesture(), SubmittedByJ
avaScript); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 | 347 |
356 RefPtr<FormSubmission> formSubmission = FormSubmission::create(this, m_attri
butes, event, formSubmissionTrigger); | 348 RefPtr<FormSubmission> formSubmission = FormSubmission::create(this, m_attri
butes, event, formSubmissionTrigger); |
357 EventQueueScope scopeForDialogClose; // Delay dispatching 'close' to dialog
until done submitting. | 349 EventQueueScope scopeForDialogClose; // Delay dispatching 'close' to dialog
until done submitting. |
358 if (formSubmission->method() == FormSubmission::DialogMethod) | 350 if (formSubmission->method() == FormSubmission::DialogMethod) |
359 submitDialog(formSubmission.release()); | 351 submitDialog(formSubmission.release()); |
360 else | 352 else |
361 scheduleFormSubmission(formSubmission.release()); | 353 scheduleFormSubmission(formSubmission.release()); |
362 | 354 |
363 if (needButtonActivation && firstSuccessfulSubmitButton) | 355 if (needButtonActivation && firstSuccessfulSubmitButton) |
364 firstSuccessfulSubmitButton->setActivatedSubmit(false); | 356 firstSuccessfulSubmitButton->setActivatedSubmit(false); |
365 | |
366 m_shouldSubmit = false; | |
367 } | 357 } |
368 | 358 |
369 void HTMLFormElement::scheduleFormSubmission(PassRefPtr<FormSubmission> submissi
on) | 359 void HTMLFormElement::scheduleFormSubmission(PassRefPtr<FormSubmission> submissi
on) |
370 { | 360 { |
371 ASSERT(submission->method() == FormSubmission::PostMethod || submission->met
hod() == FormSubmission::GetMethod); | 361 ASSERT(submission->method() == FormSubmission::PostMethod || submission->met
hod() == FormSubmission::GetMethod); |
372 ASSERT(submission->data()); | 362 ASSERT(submission->data()); |
373 ASSERT(submission->state()); | 363 ASSERT(submission->state()); |
374 if (submission->action().isEmpty()) | 364 if (submission->action().isEmpty()) |
375 return; | 365 return; |
376 if (document().isSandboxed(SandboxForms)) { | 366 if (document().isSandboxed(SandboxForms)) { |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 } | 767 } |
778 | 768 |
779 void HTMLFormElement::setDemoted(bool demoted) | 769 void HTMLFormElement::setDemoted(bool demoted) |
780 { | 770 { |
781 if (demoted) | 771 if (demoted) |
782 UseCounter::count(document(), UseCounter::DemotedFormElement); | 772 UseCounter::count(document(), UseCounter::DemotedFormElement); |
783 m_wasDemoted = demoted; | 773 m_wasDemoted = demoted; |
784 } | 774 } |
785 | 775 |
786 } // namespace | 776 } // namespace |
OLD | NEW |