Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: Source/core/html/HTMLFormElement.cpp

Issue 199633017: Blink doesnt respect the form.submit() when called on "focus" event for invalid form (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed unnecessary lines from Layout Test Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/html/HTMLFormElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_isSubmittingOrPreparingForSubmission(false)
70 , m_shouldSubmit(false) 69 , m_shouldSubmit(false)
71 , m_isInResetFunction(false) 70 , m_isInResetFunction(false)
72 , m_wasDemoted(false) 71 , m_wasDemoted(false)
73 , m_requestAutocompleteTimer(this, &HTMLFormElement::requestAutocompleteTime rFired) 72 , m_requestAutocompleteTimer(this, &HTMLFormElement::requestAutocompleteTime rFired)
74 { 73 {
75 ScriptWrappable::init(this); 74 ScriptWrappable::init(this);
76 } 75 }
77 76
78 PassRefPtr<HTMLFormElement> HTMLFormElement::create(Document& document) 77 PassRefPtr<HTMLFormElement> HTMLFormElement::create(Document& document)
79 { 78 {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 document().addConsoleMessage(RenderingMessageSource, ErrorMessageLev el, message); 275 document().addConsoleMessage(RenderingMessageSource, ErrorMessageLev el, message);
277 } 276 }
278 } 277 }
279 return false; 278 return false;
280 } 279 }
281 280
282 bool HTMLFormElement::prepareForSubmission(Event* event) 281 bool HTMLFormElement::prepareForSubmission(Event* event)
283 { 282 {
284 RefPtr<HTMLFormElement> protector(this); 283 RefPtr<HTMLFormElement> protector(this);
285 LocalFrame* frame = document().frame(); 284 LocalFrame* frame = document().frame();
286 if (m_isSubmittingOrPreparingForSubmission || !frame) 285 if (!frame)
287 return m_isSubmittingOrPreparingForSubmission; 286 return false;
288 287
289 m_isSubmittingOrPreparingForSubmission = true;
290 m_shouldSubmit = false; 288 m_shouldSubmit = false;
291 289
292 // Interactive validation must be done before dispatching the submit event. 290 // Interactive validation must be done before dispatching the submit event.
293 if (!validateInteractively(event)) { 291 if (!validateInteractively(event))
294 m_isSubmittingOrPreparingForSubmission = false;
295 return false; 292 return false;
296 }
297 293
298 frame->loader().client()->dispatchWillSendSubmitEvent(this); 294 frame->loader().client()->dispatchWillSendSubmitEvent(this);
299 295
300 // Set flag before submission as dispatchEvent could trigger another event
301 m_isSubmittingOrPreparingForSubmission = false;
302
303 if (dispatchEvent(Event::createCancelableBubble(EventTypeNames::submit))) 296 if (dispatchEvent(Event::createCancelableBubble(EventTypeNames::submit)))
304 m_shouldSubmit = true; 297 m_shouldSubmit = true;
305 298
306 if (m_shouldSubmit) 299 if (m_shouldSubmit)
307 submit(event, true, true, NotSubmittedByJavaScript); 300 submit(event, true, true, NotSubmittedByJavaScript);
308 301
309 return m_shouldSubmit; 302 return m_shouldSubmit;
310 } 303 }
311 304
312 void HTMLFormElement::submit() 305 void HTMLFormElement::submit()
(...skipping 16 matching lines...) Expand all
329 } 322 }
330 } 323 }
331 324
332 void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool proce ssingUserGesture, FormSubmissionTrigger formSubmissionTrigger) 325 void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool proce ssingUserGesture, FormSubmissionTrigger formSubmissionTrigger)
333 { 326 {
334 FrameView* view = document().view(); 327 FrameView* view = document().view();
335 LocalFrame* frame = document().frame(); 328 LocalFrame* frame = document().frame();
336 if (!view || !frame || !frame->page()) 329 if (!view || !frame || !frame->page())
337 return; 330 return;
338 331
339 if (m_isSubmittingOrPreparingForSubmission) {
340 m_shouldSubmit = true;
341 return;
342 }
343
344 m_isSubmittingOrPreparingForSubmission = true;
345 m_wasUserSubmitted = processingUserGesture; 332 m_wasUserSubmitted = processingUserGesture;
346 333
347 RefPtr<HTMLFormControlElement> firstSuccessfulSubmitButton; 334 RefPtr<HTMLFormControlElement> firstSuccessfulSubmitButton;
348 bool needButtonActivation = activateSubmitButton; // do we need to activate a submit button? 335 bool needButtonActivation = activateSubmitButton; // do we need to activate a submit button?
349 336
350 const Vector<FormAssociatedElement*>& elements = associatedElements(); 337 const Vector<FormAssociatedElement*>& elements = associatedElements();
351 for (unsigned i = 0; i < elements.size(); ++i) { 338 for (unsigned i = 0; i < elements.size(); ++i) {
352 FormAssociatedElement* associatedElement = elements[i]; 339 FormAssociatedElement* associatedElement = elements[i];
353 if (!associatedElement->isFormControlElement()) 340 if (!associatedElement->isFormControlElement())
354 continue; 341 continue;
(...skipping 13 matching lines...) Expand all
368 EventQueueScope scopeForDialogClose; // Delay dispatching 'close' to dialog until done submitting. 355 EventQueueScope scopeForDialogClose; // Delay dispatching 'close' to dialog until done submitting.
369 if (formSubmission->method() == FormSubmission::DialogMethod) 356 if (formSubmission->method() == FormSubmission::DialogMethod)
370 submitDialog(formSubmission.release()); 357 submitDialog(formSubmission.release());
371 else 358 else
372 scheduleFormSubmission(formSubmission.release()); 359 scheduleFormSubmission(formSubmission.release());
373 360
374 if (needButtonActivation && firstSuccessfulSubmitButton) 361 if (needButtonActivation && firstSuccessfulSubmitButton)
375 firstSuccessfulSubmitButton->setActivatedSubmit(false); 362 firstSuccessfulSubmitButton->setActivatedSubmit(false);
376 363
377 m_shouldSubmit = false; 364 m_shouldSubmit = false;
378 m_isSubmittingOrPreparingForSubmission = false;
379 } 365 }
380 366
381 void HTMLFormElement::scheduleFormSubmission(PassRefPtr<FormSubmission> submissi on) 367 void HTMLFormElement::scheduleFormSubmission(PassRefPtr<FormSubmission> submissi on)
382 { 368 {
383 ASSERT(submission->method() == FormSubmission::PostMethod || submission->met hod() == FormSubmission::GetMethod); 369 ASSERT(submission->method() == FormSubmission::PostMethod || submission->met hod() == FormSubmission::GetMethod);
384 ASSERT(submission->data()); 370 ASSERT(submission->data());
385 ASSERT(submission->state()); 371 ASSERT(submission->state());
386 if (submission->action().isEmpty()) 372 if (submission->action().isEmpty())
387 return; 373 return;
388 if (document().isSandboxed(SandboxForms)) { 374 if (document().isSandboxed(SandboxForms)) {
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 } 773 }
788 774
789 void HTMLFormElement::setDemoted(bool demoted) 775 void HTMLFormElement::setDemoted(bool demoted)
790 { 776 {
791 if (demoted) 777 if (demoted)
792 UseCounter::count(document(), UseCounter::DemotedFormElement); 778 UseCounter::count(document(), UseCounter::DemotedFormElement);
793 m_wasDemoted = demoted; 779 m_wasDemoted = demoted;
794 } 780 }
795 781
796 } // namespace 782 } // namespace
OLDNEW
« no previous file with comments | « Source/core/html/HTMLFormElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698