OLD | NEW |
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 Loading... |
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()) { |
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 Loading... |
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 |
OLD | NEW |