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

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: Adding changes to rename variable Created 6 years, 9 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 using namespace HTMLNames; 60 using namespace HTMLNames;
61 61
62 HTMLFormElement::HTMLFormElement(Document& document) 62 HTMLFormElement::HTMLFormElement(Document& document)
63 : HTMLElement(formTag, document) 63 : HTMLElement(formTag, document)
64 , m_weakPtrFactory(this) 64 , m_weakPtrFactory(this)
65 , m_associatedElementsAreDirty(false) 65 , m_associatedElementsAreDirty(false)
66 , m_imageElementsAreDirty(false) 66 , m_imageElementsAreDirty(false)
67 , m_hasElementsAssociatedByParser(false) 67 , m_hasElementsAssociatedByParser(false)
68 , m_didFinishParsingChildren(false) 68 , m_didFinishParsingChildren(false)
69 , m_wasUserSubmitted(false) 69 , m_wasUserSubmitted(false)
70 , m_isSubmittingOrPreparingForSubmission(false) 70 , m_isSubmitting(false)
71 , m_shouldSubmit(false) 71 , m_shouldSubmit(false)
72 , m_isInResetFunction(false) 72 , m_isInResetFunction(false)
73 , m_wasDemoted(false) 73 , m_wasDemoted(false)
74 , m_requestAutocompleteTimer(this, &HTMLFormElement::requestAutocompleteTime rFired) 74 , m_requestAutocompleteTimer(this, &HTMLFormElement::requestAutocompleteTime rFired)
75 { 75 {
76 ScriptWrappable::init(this); 76 ScriptWrappable::init(this);
77 } 77 }
78 78
79 PassRefPtr<HTMLFormElement> HTMLFormElement::create(Document& document) 79 PassRefPtr<HTMLFormElement> HTMLFormElement::create(Document& document)
80 { 80 {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 document().addConsoleMessage(RenderingMessageSource, ErrorMessageLev el, message); 277 document().addConsoleMessage(RenderingMessageSource, ErrorMessageLev el, message);
278 } 278 }
279 } 279 }
280 return false; 280 return false;
281 } 281 }
282 282
283 bool HTMLFormElement::prepareForSubmission(Event* event) 283 bool HTMLFormElement::prepareForSubmission(Event* event)
284 { 284 {
285 RefPtr<HTMLFormElement> protector(this); 285 RefPtr<HTMLFormElement> protector(this);
286 LocalFrame* frame = document().frame(); 286 LocalFrame* frame = document().frame();
287 if (m_isSubmittingOrPreparingForSubmission || !frame) 287 if (m_isSubmitting || !frame)
288 return m_isSubmittingOrPreparingForSubmission; 288 return m_isSubmitting;
289 289
290 m_isSubmittingOrPreparingForSubmission = true;
291 m_shouldSubmit = false; 290 m_shouldSubmit = false;
292 291
293 // Interactive validation must be done before dispatching the submit event. 292 // Interactive validation must be done before dispatching the submit event.
294 if (!validateInteractively(event)) { 293 if (!validateInteractively(event)) {
tkent 2014/03/25 01:56:43 Any JavaScript code can run in validateInteractive
harpreet.sk 2014/03/26 09:16:07 According to the scenario which you mentioned if f
tkent 2014/03/27 00:35:30 form.submit() should submit the form even if the f
295 m_isSubmittingOrPreparingForSubmission = false;
296 return false; 294 return false;
297 } 295 }
298 296
299 frame->loader().client()->dispatchWillSendSubmitEvent(this); 297 frame->loader().client()->dispatchWillSendSubmitEvent(this);
300 298
301 // Set flag before submission as dispatchEvent could trigger another event
302 m_isSubmittingOrPreparingForSubmission = false;
303
304 if (dispatchEvent(Event::createCancelableBubble(EventTypeNames::submit))) 299 if (dispatchEvent(Event::createCancelableBubble(EventTypeNames::submit)))
305 m_shouldSubmit = true; 300 m_shouldSubmit = true;
306 301
307 if (m_shouldSubmit) 302 if (m_shouldSubmit)
308 submit(event, true, true, NotSubmittedByJavaScript); 303 submit(event, true, true, NotSubmittedByJavaScript);
309 304
310 return m_shouldSubmit; 305 return m_shouldSubmit;
311 } 306 }
312 307
313 void HTMLFormElement::submit() 308 void HTMLFormElement::submit()
(...skipping 16 matching lines...) Expand all
330 } 325 }
331 } 326 }
332 327
333 void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool proce ssingUserGesture, FormSubmissionTrigger formSubmissionTrigger) 328 void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool proce ssingUserGesture, FormSubmissionTrigger formSubmissionTrigger)
334 { 329 {
335 FrameView* view = document().view(); 330 FrameView* view = document().view();
336 LocalFrame* frame = document().frame(); 331 LocalFrame* frame = document().frame();
337 if (!view || !frame || !frame->page()) 332 if (!view || !frame || !frame->page())
338 return; 333 return;
339 334
340 if (m_isSubmittingOrPreparingForSubmission) { 335 if (m_isSubmitting) {
341 m_shouldSubmit = true; 336 m_shouldSubmit = true;
342 return; 337 return;
343 } 338 }
344 339
345 m_isSubmittingOrPreparingForSubmission = true; 340 m_isSubmitting = true;
346 m_wasUserSubmitted = processingUserGesture; 341 m_wasUserSubmitted = processingUserGesture;
347 342
348 RefPtr<HTMLFormControlElement> firstSuccessfulSubmitButton; 343 RefPtr<HTMLFormControlElement> firstSuccessfulSubmitButton;
349 bool needButtonActivation = activateSubmitButton; // do we need to activate a submit button? 344 bool needButtonActivation = activateSubmitButton; // do we need to activate a submit button?
350 345
351 const Vector<FormAssociatedElement*>& elements = associatedElements(); 346 const Vector<FormAssociatedElement*>& elements = associatedElements();
352 for (unsigned i = 0; i < elements.size(); ++i) { 347 for (unsigned i = 0; i < elements.size(); ++i) {
353 FormAssociatedElement* associatedElement = elements[i]; 348 FormAssociatedElement* associatedElement = elements[i];
354 if (!associatedElement->isFormControlElement()) 349 if (!associatedElement->isFormControlElement())
355 continue; 350 continue;
(...skipping 13 matching lines...) Expand all
369 EventQueueScope scopeForDialogClose; // Delay dispatching 'close' to dialog until done submitting. 364 EventQueueScope scopeForDialogClose; // Delay dispatching 'close' to dialog until done submitting.
370 if (formSubmission->method() == FormSubmission::DialogMethod) 365 if (formSubmission->method() == FormSubmission::DialogMethod)
371 submitDialog(formSubmission.release()); 366 submitDialog(formSubmission.release());
372 else 367 else
373 scheduleFormSubmission(formSubmission.release()); 368 scheduleFormSubmission(formSubmission.release());
374 369
375 if (needButtonActivation && firstSuccessfulSubmitButton) 370 if (needButtonActivation && firstSuccessfulSubmitButton)
376 firstSuccessfulSubmitButton->setActivatedSubmit(false); 371 firstSuccessfulSubmitButton->setActivatedSubmit(false);
377 372
378 m_shouldSubmit = false; 373 m_shouldSubmit = false;
379 m_isSubmittingOrPreparingForSubmission = false; 374 m_isSubmitting = false;
380 } 375 }
381 376
382 void HTMLFormElement::scheduleFormSubmission(PassRefPtr<FormSubmission> submissi on) 377 void HTMLFormElement::scheduleFormSubmission(PassRefPtr<FormSubmission> submissi on)
383 { 378 {
384 ASSERT(submission->method() == FormSubmission::PostMethod || submission->met hod() == FormSubmission::GetMethod); 379 ASSERT(submission->method() == FormSubmission::PostMethod || submission->met hod() == FormSubmission::GetMethod);
385 ASSERT(submission->data()); 380 ASSERT(submission->data());
386 ASSERT(submission->state()); 381 ASSERT(submission->state());
387 if (submission->action().isEmpty()) 382 if (submission->action().isEmpty())
388 return; 383 return;
389 if (document().isSandboxed(SandboxForms)) { 384 if (document().isSandboxed(SandboxForms)) {
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 } 783 }
789 784
790 void HTMLFormElement::setDemoted(bool demoted) 785 void HTMLFormElement::setDemoted(bool demoted)
791 { 786 {
792 if (demoted) 787 if (demoted)
793 UseCounter::count(document(), UseCounter::DemotedFormElement); 788 UseCounter::count(document(), UseCounter::DemotedFormElement);
794 m_wasDemoted = demoted; 789 m_wasDemoted = demoted;
795 } 790 }
796 791
797 } // namespace 792 } // 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