OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2011 Apple Inc. All rights reserved. |
3 * Copyright (C) 2010 Google Inc. All rights reserved. | 3 * Copyright (C) 2010 Google Inc. All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 30 matching lines...) Expand all Loading... |
41 return adoptPtr(new RadioInputType(element)); | 41 return adoptPtr(new RadioInputType(element)); |
42 } | 42 } |
43 | 43 |
44 const AtomicString& RadioInputType::formControlType() const | 44 const AtomicString& RadioInputType::formControlType() const |
45 { | 45 { |
46 return InputTypeNames::radio(); | 46 return InputTypeNames::radio(); |
47 } | 47 } |
48 | 48 |
49 bool RadioInputType::valueMissing(const String&) const | 49 bool RadioInputType::valueMissing(const String&) const |
50 { | 50 { |
51 return element()->checkedRadioButtons().isInRequiredGroup(element()) && !ele
ment()->checkedRadioButtons().checkedButtonForGroup(element()->name()); | 51 return !element()->checkedRadioButtons().checkedButtonForGroup(element()->na
me()); |
52 } | 52 } |
53 | 53 |
54 String RadioInputType::valueMissingText() const | 54 String RadioInputType::valueMissingText() const |
55 { | 55 { |
56 return validationMessageValueMissingForRadioText(); | 56 return validationMessageValueMissingForRadioText(); |
57 } | 57 } |
58 | 58 |
59 void RadioInputType::handleClickEvent(MouseEvent* event) | 59 void RadioInputType::handleClickEvent(MouseEvent* event) |
60 { | 60 { |
61 event->setDefaultHandled(); | 61 event->setDefaultHandled(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 if (currentFocusedNode && currentFocusedNode->hasTagName(inputTag)) { | 126 if (currentFocusedNode && currentFocusedNode->hasTagName(inputTag)) { |
127 HTMLInputElement* focusedInput = static_cast<HTMLInputElement*>(currentF
ocusedNode); | 127 HTMLInputElement* focusedInput = static_cast<HTMLInputElement*>(currentF
ocusedNode); |
128 if (focusedInput->isRadioButton() && focusedInput->form() == element()->
form() && focusedInput->name() == element()->name()) | 128 if (focusedInput->isRadioButton() && focusedInput->form() == element()->
form() && focusedInput->name() == element()->name()) |
129 return false; | 129 return false; |
130 } | 130 } |
131 | 131 |
132 // Allow keyboard focus if we're checked or if nothing in the group is check
ed. | 132 // Allow keyboard focus if we're checked or if nothing in the group is check
ed. |
133 return element()->checked() || !element()->checkedRadioButtons().checkedButt
onForGroup(element()->name()); | 133 return element()->checked() || !element()->checkedRadioButtons().checkedButt
onForGroup(element()->name()); |
134 } | 134 } |
135 | 135 |
| 136 void RadioInputType::attach() |
| 137 { |
| 138 InputType::attach(); |
| 139 element()->updateCheckedRadioButtons(); |
| 140 } |
| 141 |
136 bool RadioInputType::shouldSendChangeEventAfterCheckedChanged() | 142 bool RadioInputType::shouldSendChangeEventAfterCheckedChanged() |
137 { | 143 { |
138 // Don't send a change event for a radio button that's getting unchecked. | 144 // Don't send a change event for a radio button that's getting unchecked. |
139 // This was done to match the behavior of other browsers. | 145 // This was done to match the behavior of other browsers. |
140 return element()->checked(); | 146 return element()->checked(); |
141 } | 147 } |
142 | 148 |
143 PassOwnPtr<ClickHandlingState> RadioInputType::willDispatchClick() | 149 PassOwnPtr<ClickHandlingState> RadioInputType::willDispatchClick() |
144 { | 150 { |
145 // An event handler can use preventDefault or "return false" to reverse the
selection we do here. | 151 // An event handler can use preventDefault or "return false" to reverse the
selection we do here. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // The work we did in willDispatchClick was default handling. | 186 // The work we did in willDispatchClick was default handling. |
181 event->setDefaultHandled(); | 187 event->setDefaultHandled(); |
182 } | 188 } |
183 | 189 |
184 bool RadioInputType::isRadioButton() const | 190 bool RadioInputType::isRadioButton() const |
185 { | 191 { |
186 return true; | 192 return true; |
187 } | 193 } |
188 | 194 |
189 } // namespace WebCore | 195 } // namespace WebCore |
OLD | NEW |