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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 RefPtrWillBeRawPtr<HTMLInputElement> input(element()); | 153 RefPtrWillBeRawPtr<HTMLInputElement> input(element()); |
154 | 154 |
155 // We don't ask InputType::setValue to dispatch events because | 155 // We don't ask InputType::setValue to dispatch events because |
156 // TextFieldInputType dispatches events different way from InputType. | 156 // TextFieldInputType dispatches events different way from InputType. |
157 InputType::setValue(sanitizedValue, valueChanged, DispatchNoEvent); | 157 InputType::setValue(sanitizedValue, valueChanged, DispatchNoEvent); |
158 | 158 |
159 if (valueChanged) | 159 if (valueChanged) |
160 input->updateView(); | 160 input->updateView(); |
161 | 161 |
162 unsigned max = visibleValue().length(); | 162 unsigned max = visibleValue().length(); |
163 if (input->focused()) | 163 if (input->focused()) { |
164 input->setSelectionRange(max, max); | 164 if (input->selectionStart() != input->selectionEnd()) |
165 else | 165 input->setSelectionRange(input->selectionStart(), input->selectionEn d()); |
166 input->cacheSelectionInResponseToSetValue(max); | 166 else |
167 input->setSelectionRange(max, max); | |
168 } else { | |
169 input->setSelectionRange(input->selectionStart(), input->selectionEnd()) ; | |
yosin_UTC9
2014/07/03 01:58:36
Why do we need to set same value to input field se
harpreet.sk
2014/07/04 13:50:27
In case if input field is focused and selection is
| |
170 } | |
167 | 171 |
168 if (!valueChanged) | 172 if (!valueChanged) |
169 return; | 173 return; |
170 | 174 |
171 switch (eventBehavior) { | 175 switch (eventBehavior) { |
172 case DispatchChangeEvent: | 176 case DispatchChangeEvent: |
173 // If the user is still editing this field, dispatch an input event rath er than a change event. | 177 // If the user is still editing this field, dispatch an input event rath er than a change event. |
174 // The change event will be dispatched when editing finishes. | 178 // The change event will be dispatched when editing finishes. |
175 if (input->focused()) | 179 if (input->focused()) |
176 input->dispatchFormControlInputEvent(); | 180 input->dispatchFormControlInputEvent(); |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
554 return shouldSpinButtonRespondToMouseEvents() && element().focused(); | 558 return shouldSpinButtonRespondToMouseEvents() && element().focused(); |
555 } | 559 } |
556 | 560 |
557 void TextFieldInputType::spinButtonDidReleaseMouseCapture(SpinButtonElement::Eve ntDispatch eventDispatch) | 561 void TextFieldInputType::spinButtonDidReleaseMouseCapture(SpinButtonElement::Eve ntDispatch eventDispatch) |
558 { | 562 { |
559 if (eventDispatch == SpinButtonElement::EventDispatchAllowed) | 563 if (eventDispatch == SpinButtonElement::EventDispatchAllowed) |
560 element().dispatchFormControlChangeEvent(); | 564 element().dispatchFormControlChangeEvent(); |
561 } | 565 } |
562 | 566 |
563 } // namespace WebCore | 567 } // namespace WebCore |
OLD | NEW |