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

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

Issue 177683004: Don't delay submit in onsubmit event handler (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Send form data at time of method invocation 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
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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 if (!validateInteractively(event)) { 296 if (!validateInteractively(event)) {
297 m_isSubmittingOrPreparingForSubmission = false; 297 m_isSubmittingOrPreparingForSubmission = false;
298 return false; 298 return false;
299 } 299 }
300 300
301 StringPairVector controlNamesAndValues; 301 StringPairVector controlNamesAndValues;
302 getTextFieldValues(controlNamesAndValues); 302 getTextFieldValues(controlNamesAndValues);
303 RefPtr<FormState> formState = FormState::create(this, controlNamesAndValues, &document(), NotSubmittedByJavaScript); 303 RefPtr<FormState> formState = FormState::create(this, controlNamesAndValues, &document(), NotSubmittedByJavaScript);
304 frame->loader().client()->dispatchWillSendSubmitEvent(formState.release()); 304 frame->loader().client()->dispatchWillSendSubmitEvent(formState.release());
305 305
306 // Set flag before submission as dispatchEvent could trigger another event
307 m_isSubmittingOrPreparingForSubmission = false;
308
306 if (dispatchEvent(Event::createCancelableBubble(EventTypeNames::submit))) 309 if (dispatchEvent(Event::createCancelableBubble(EventTypeNames::submit)))
307 m_shouldSubmit = true; 310 m_shouldSubmit = true;
308 311
309 m_isSubmittingOrPreparingForSubmission = false;
310
311 if (m_shouldSubmit) 312 if (m_shouldSubmit)
312 submit(event, true, true, NotSubmittedByJavaScript); 313 submit(event, true, true, NotSubmittedByJavaScript);
313 314
314 return m_shouldSubmit; 315 return m_shouldSubmit;
315 } 316 }
316 317
317 void HTMLFormElement::submit() 318 void HTMLFormElement::submit()
318 { 319 {
319 submit(0, false, true, NotSubmittedByJavaScript); 320 submit(0, false, true, NotSubmittedByJavaScript);
320 } 321 }
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 } 818 }
818 819
819 void HTMLFormElement::setDemoted(bool demoted) 820 void HTMLFormElement::setDemoted(bool demoted)
820 { 821 {
821 if (demoted) 822 if (demoted)
822 UseCounter::count(document(), UseCounter::DemotedFormElement); 823 UseCounter::count(document(), UseCounter::DemotedFormElement);
823 m_wasDemoted = demoted; 824 m_wasDemoted = demoted;
824 } 825 }
825 826
826 } // namespace 827 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698