OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * Copyright (C) 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 bool value_changed, | 150 bool value_changed, |
151 TextFieldEventBehavior event_behavior, | 151 TextFieldEventBehavior event_behavior, |
152 TextControlSetValueSelection selection) { | 152 TextControlSetValueSelection selection) { |
153 // We don't use InputType::setValue. TextFieldInputType dispatches events | 153 // We don't use InputType::setValue. TextFieldInputType dispatches events |
154 // different way from InputType::setValue. | 154 // different way from InputType::setValue. |
155 if (event_behavior == kDispatchNoEvent) | 155 if (event_behavior == kDispatchNoEvent) |
156 GetElement().SetNonAttributeValue(sanitized_value); | 156 GetElement().SetNonAttributeValue(sanitized_value); |
157 else | 157 else |
158 GetElement().SetNonAttributeValueByUserEdit(sanitized_value); | 158 GetElement().SetNonAttributeValueByUserEdit(sanitized_value); |
159 | 159 |
160 if (value_changed) | 160 // The following early-return can't be moved to the beginning of this |
161 GetElement().UpdateView(); | 161 // function. We need to update non-attribute value even if the value is not |
| 162 // changed. For example, <input type=number> has a badInput string, that is |
| 163 // to say, IDL value=="", and new value is "", which should clear the badInput |
| 164 // string and update validiity. |
| 165 if (!value_changed) |
| 166 return; |
| 167 GetElement().UpdateView(); |
162 | 168 |
163 if (selection == TextControlSetValueSelection::kSetSelectionToEnd) { | 169 if (selection == TextControlSetValueSelection::kSetSelectionToEnd) { |
164 unsigned max = VisibleValue().length(); | 170 unsigned max = VisibleValue().length(); |
165 GetElement().SetSelectionRange(max, max); | 171 GetElement().SetSelectionRange(max, max); |
166 } | 172 } |
167 | 173 |
168 if (!value_changed) | |
169 return; | |
170 | |
171 switch (event_behavior) { | 174 switch (event_behavior) { |
172 case kDispatchChangeEvent: | 175 case kDispatchChangeEvent: |
173 // If the user is still editing this field, dispatch an input event rather | 176 // If the user is still editing this field, dispatch an input event rather |
174 // than a change event. The change event will be dispatched when editing | 177 // than a change event. The change event will be dispatched when editing |
175 // finishes. | 178 // finishes. |
176 if (GetElement().IsFocused()) | 179 if (GetElement().IsFocused()) |
177 GetElement().DispatchInputEvent(); | 180 GetElement().DispatchInputEvent(); |
178 else | 181 else |
179 GetElement().DispatchFormControlChangeEvent(); | 182 GetElement().DispatchFormControlChangeEvent(); |
180 break; | 183 break; |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 return ShouldSpinButtonRespondToMouseEvents() && GetElement().IsFocused(); | 561 return ShouldSpinButtonRespondToMouseEvents() && GetElement().IsFocused(); |
559 } | 562 } |
560 | 563 |
561 void TextFieldInputType::SpinButtonDidReleaseMouseCapture( | 564 void TextFieldInputType::SpinButtonDidReleaseMouseCapture( |
562 SpinButtonElement::EventDispatch event_dispatch) { | 565 SpinButtonElement::EventDispatch event_dispatch) { |
563 if (event_dispatch == SpinButtonElement::kEventDispatchAllowed) | 566 if (event_dispatch == SpinButtonElement::kEventDispatchAllowed) |
564 GetElement().DispatchFormControlChangeEvent(); | 567 GetElement().DispatchFormControlChangeEvent(); |
565 } | 568 } |
566 | 569 |
567 } // namespace blink | 570 } // namespace blink |
OLD | NEW |