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

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: Updated to latest master 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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 if (!validateInteractively(event)) { 294 if (!validateInteractively(event)) {
295 m_isSubmittingOrPreparingForSubmission = false; 295 m_isSubmittingOrPreparingForSubmission = false;
296 return false; 296 return false;
297 } 297 }
298 298
299 StringPairVector controlNamesAndValues; 299 StringPairVector controlNamesAndValues;
300 getTextFieldValues(controlNamesAndValues); 300 getTextFieldValues(controlNamesAndValues);
301 RefPtr<FormState> formState = FormState::create(this, controlNamesAndValues, &document(), NotSubmittedByJavaScript); 301 RefPtr<FormState> formState = FormState::create(this, controlNamesAndValues, &document(), NotSubmittedByJavaScript);
302 frame->loader().client()->dispatchWillSendSubmitEvent(formState.release()); 302 frame->loader().client()->dispatchWillSendSubmitEvent(formState.release());
303 303
304 // Set flag before submission as dispatchEvent could trigger another event
305 m_isSubmittingOrPreparingForSubmission = false;
306
304 if (dispatchEvent(Event::createCancelableBubble(EventTypeNames::submit))) 307 if (dispatchEvent(Event::createCancelableBubble(EventTypeNames::submit)))
305 m_shouldSubmit = true; 308 m_shouldSubmit = true;
306 309
307 m_isSubmittingOrPreparingForSubmission = false;
308
309 if (m_shouldSubmit) 310 if (m_shouldSubmit)
310 submit(event, true, true, NotSubmittedByJavaScript); 311 submit(event, true, true, NotSubmittedByJavaScript);
311 312
312 return m_shouldSubmit; 313 return m_shouldSubmit;
313 } 314 }
314 315
315 void HTMLFormElement::submit() 316 void HTMLFormElement::submit()
316 { 317 {
317 submit(0, false, true, NotSubmittedByJavaScript); 318 submit(0, false, true, NotSubmittedByJavaScript);
318 } 319 }
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 } 817 }
817 818
818 void HTMLFormElement::setDemoted(bool demoted) 819 void HTMLFormElement::setDemoted(bool demoted)
819 { 820 {
820 if (demoted) 821 if (demoted)
821 UseCounter::count(document(), UseCounter::DemotedFormElement); 822 UseCounter::count(document(), UseCounter::DemotedFormElement);
822 m_wasDemoted = demoted; 823 m_wasDemoted = demoted;
823 } 824 }
824 825
825 } // namespace 826 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698