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

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

Issue 60573007: Non-activated default buttons prevent implicit form submission. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 166 }
167 167
168 Node* HTMLFormElement::item(unsigned index) 168 Node* HTMLFormElement::item(unsigned index)
169 { 169 {
170 return elements()->item(index); 170 return elements()->item(index);
171 } 171 }
172 172
173 void HTMLFormElement::submitImplicitly(Event* event, bool fromImplicitSubmission Trigger) 173 void HTMLFormElement::submitImplicitly(Event* event, bool fromImplicitSubmission Trigger)
174 { 174 {
175 int submissionTriggerCount = 0; 175 int submissionTriggerCount = 0;
176 bool seenDefaultButton = false;
176 for (unsigned i = 0; i < m_associatedElements.size(); ++i) { 177 for (unsigned i = 0; i < m_associatedElements.size(); ++i) {
177 FormAssociatedElement* formAssociatedElement = m_associatedElements[i]; 178 FormAssociatedElement* formAssociatedElement = m_associatedElements[i];
178 if (!formAssociatedElement->isFormControlElement()) 179 if (!formAssociatedElement->isFormControlElement())
179 continue; 180 continue;
180 HTMLFormControlElement* control = toHTMLFormControlElement(formAssociate dElement); 181 HTMLFormControlElement* control = toHTMLFormControlElement(formAssociate dElement);
181 if (control->isSuccessfulSubmitButton()) { 182 if (!seenDefaultButton && control->canBeSuccessfulSubmitButton()) {
eseidel 2013/11/14 16:40:32 I think you mean couldBeSuccessful? http://en.wiki
sof 2013/11/15 08:52:15 Maybe the naming could be made clearer, it current
182 if (control->renderer()) { 183 if (fromImplicitSubmissionTrigger)
183 control->dispatchSimulatedClick(event); 184 seenDefaultButton = true;
185 if (control->isSuccessfulSubmitButton()) {
186 if (control->renderer()) {
187 control->dispatchSimulatedClick(event);
188 return;
189 }
190 } else if (fromImplicitSubmissionTrigger) {
191 // Default (submit) button is not activated; no implicit submiss ion.
184 return; 192 return;
185 } 193 }
186 } else if (control->canTriggerImplicitSubmission()) 194 } else if (control->canTriggerImplicitSubmission()) {
187 ++submissionTriggerCount; 195 ++submissionTriggerCount;
196 }
188 } 197 }
189 if (fromImplicitSubmissionTrigger && submissionTriggerCount == 1) 198 if (fromImplicitSubmissionTrigger && submissionTriggerCount == 1)
190 prepareForSubmission(event); 199 prepareForSubmission(event);
191 } 200 }
192 201
193 // FIXME: Consolidate this and similar code in FormSubmission.cpp. 202 // FIXME: Consolidate this and similar code in FormSubmission.cpp.
194 static inline HTMLFormControlElement* submitElementFromEvent(const Event* event) 203 static inline HTMLFormControlElement* submitElementFromEvent(const Event* event)
195 { 204 {
196 for (Node* node = event->target()->toNode(); node; node = node->parentOrShad owHostNode()) { 205 for (Node* node = event->target()->toNode(); node; node = node->parentOrShad owHostNode()) {
197 if (node->isElementNode() && toElement(node)->isFormControlElement()) 206 if (node->isElementNode() && toElement(node)->isFormControlElement())
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 } 808 }
800 809
801 void HTMLFormElement::setDemoted(bool demoted) 810 void HTMLFormElement::setDemoted(bool demoted)
802 { 811 {
803 if (demoted) 812 if (demoted)
804 UseCounter::count(document(), UseCounter::DemotedFormElement); 813 UseCounter::count(document(), UseCounter::DemotedFormElement);
805 m_wasDemoted = demoted; 814 m_wasDemoted = demoted;
806 } 815 }
807 816
808 } // namespace 817 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698