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

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

Issue 2416033002: Fixed the behaviour of form submit to match the standard: no submit is taken place when the form is… (Closed)
Patch Set: Modified layout tests for the new behaviour Created 4 years, 2 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
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 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
6 * reserved. 6 * reserved.
7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 } 340 }
341 } 341 }
342 342
343 void HTMLFormElement::submit(Event* event, 343 void HTMLFormElement::submit(Event* event,
344 HTMLFormControlElement* submitButton) { 344 HTMLFormControlElement* submitButton) {
345 FrameView* view = document().view(); 345 FrameView* view = document().view();
346 LocalFrame* frame = document().frame(); 346 LocalFrame* frame = document().frame();
347 if (!view || !frame || !frame->page()) 347 if (!view || !frame || !frame->page())
348 return; 348 return;
349 349
350 // See crbug.com/586749. 350 // https://html.spec.whatwg.org/multipage/forms.html#form-submission-algorithm
351 if (!isConnected()) 351 // 2. If form document is not connected, has no associated browsing context,
352 UseCounter::count(document(), UseCounter::FormSubmissionNotInDocumentTree); 352 // or its active sandboxing flag set has its sandboxed forms browsing
353 // context flag set, then abort these steps without doing anything.
354 if (!isConnected()) {
355 document().addConsoleMessage(ConsoleMessage::create(
356 JSMessageSource, WarningMessageLevel,
357 "Form submission canceled because the form is not connected"));
358 return;
359 }
353 360
354 if (m_isSubmitting) 361 if (m_isSubmitting)
355 return; 362 return;
356 363
357 // Delay dispatching 'close' to dialog until done submitting. 364 // Delay dispatching 'close' to dialog until done submitting.
358 EventQueueScope scopeForDialogClose; 365 EventQueueScope scopeForDialogClose;
359 AutoReset<bool> submitScope(&m_isSubmitting, true); 366 AutoReset<bool> submitScope(&m_isSubmitting, true);
360 367
361 if (event && !submitButton) { 368 if (event && !submitButton) {
362 // In a case of implicit submission without a submit button, 'submit' 369 // In a case of implicit submission without a submit button, 'submit'
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 for (const auto& control : associatedElements()) { 813 for (const auto& control : associatedElements()) {
807 if (!control->isFormControlElement()) 814 if (!control->isFormControlElement())
808 continue; 815 continue;
809 if (toHTMLFormControlElement(control)->canBeSuccessfulSubmitButton()) 816 if (toHTMLFormControlElement(control)->canBeSuccessfulSubmitButton())
810 toHTMLFormControlElement(control)->pseudoStateChanged( 817 toHTMLFormControlElement(control)->pseudoStateChanged(
811 CSSSelector::PseudoDefault); 818 CSSSelector::PseudoDefault);
812 } 819 }
813 } 820 }
814 821
815 } // namespace blink 822 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/UseCounter.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698