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 // changes input type. | 150 // changes input type. |
151 RefPtr<HTMLInputElement> input(element()); | 151 RefPtr<HTMLInputElement> input(element()); |
152 | 152 |
153 // We don't ask InputType::setValue to dispatch events because | 153 // We don't ask InputType::setValue to dispatch events because |
154 // TextFieldInputType dispatches events different way from InputType. | 154 // TextFieldInputType dispatches events different way from InputType. |
155 InputType::setValue(sanitizedValue, valueChanged, DispatchNoEvent); | 155 InputType::setValue(sanitizedValue, valueChanged, DispatchNoEvent); |
156 | 156 |
157 if (valueChanged) | 157 if (valueChanged) |
158 input->updateView(); | 158 input->updateView(); |
159 | 159 |
160 unsigned max = visibleValue().length(); | 160 int max = visibleValue().length(); |
161 if (input->focused()) | 161 if (input->focused()) |
162 input->setSelectionRange(max, max); | 162 input->setSelectionRange(max, max); |
163 else | 163 else |
164 input->cacheSelectionInResponseToSetValue(max); | 164 input->setSelectionRange(input->selectionStartForJavascriptBindings(), i
nput->selectionEndForJavascriptBindings()); |
165 | 165 |
166 if (!valueChanged) | 166 if (!valueChanged) |
167 return; | 167 return; |
168 | 168 |
169 switch (eventBehavior) { | 169 switch (eventBehavior) { |
170 case DispatchChangeEvent: | 170 case DispatchChangeEvent: |
171 // If the user is still editing this field, dispatch an input event rath
er than a change event. | 171 // If the user is still editing this field, dispatch an input event rath
er than a change event. |
172 // The change event will be dispatched when editing finishes. | 172 // The change event will be dispatched when editing finishes. |
173 if (input->focused()) | 173 if (input->focused()) |
174 input->dispatchFormControlInputEvent(); | 174 input->dispatchFormControlInputEvent(); |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 return shouldSpinButtonRespondToMouseEvents() && element().focused(); | 565 return shouldSpinButtonRespondToMouseEvents() && element().focused(); |
566 } | 566 } |
567 | 567 |
568 void TextFieldInputType::spinButtonDidReleaseMouseCapture(SpinButtonElement::Eve
ntDispatch eventDispatch) | 568 void TextFieldInputType::spinButtonDidReleaseMouseCapture(SpinButtonElement::Eve
ntDispatch eventDispatch) |
569 { | 569 { |
570 if (eventDispatch == SpinButtonElement::EventDispatchAllowed) | 570 if (eventDispatch == SpinButtonElement::EventDispatchAllowed) |
571 element().dispatchFormControlChangeEvent(); | 571 element().dispatchFormControlChangeEvent(); |
572 } | 572 } |
573 | 573 |
574 } // namespace WebCore | 574 } // namespace WebCore |
OLD | NEW |