Chromium Code Reviews| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 // changes input type. | 152 // changes input type. |
| 153 RefPtr<HTMLInputElement> input(element()); | 153 RefPtr<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 int max = visibleValue().length(); |
| 163 if (input->focused()) | 163 if (input->focused()) { |
| 164 input->setSelectionRange(max, max); | 164 input->setSelectionRange(max, max); |
| 165 else | 165 } else { |
| 166 input->cacheSelectionInResponseToSetValue(max); | 166 if (max < input->selectionStart()) |
|
tkent
2014/05/19 00:00:34
This |if| statement should be
input->setSelect
harpreet.sk
2014/05/19 11:16:52
Done.
| |
| 167 input->setSelectionRange(max, max); | |
| 168 else if (max >= input->selectionStart() && max < input->selectionEnd()) | |
| 169 input->setSelectionRange(input->selectionStart(), max); | |
| 170 else | |
| 171 input->setSelectionRange(input->selectionStart(), input->selectionEn d()); | |
| 172 } | |
| 167 | 173 |
| 168 if (!valueChanged) | 174 if (!valueChanged) |
| 169 return; | 175 return; |
| 170 | 176 |
| 171 switch (eventBehavior) { | 177 switch (eventBehavior) { |
| 172 case DispatchChangeEvent: | 178 case DispatchChangeEvent: |
| 173 // If the user is still editing this field, dispatch an input event rath er than a change event. | 179 // 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. | 180 // The change event will be dispatched when editing finishes. |
| 175 if (input->focused()) | 181 if (input->focused()) |
| 176 input->dispatchFormControlInputEvent(); | 182 input->dispatchFormControlInputEvent(); |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 553 return shouldSpinButtonRespondToMouseEvents() && element().focused(); | 559 return shouldSpinButtonRespondToMouseEvents() && element().focused(); |
| 554 } | 560 } |
| 555 | 561 |
| 556 void TextFieldInputType::spinButtonDidReleaseMouseCapture(SpinButtonElement::Eve ntDispatch eventDispatch) | 562 void TextFieldInputType::spinButtonDidReleaseMouseCapture(SpinButtonElement::Eve ntDispatch eventDispatch) |
| 557 { | 563 { |
| 558 if (eventDispatch == SpinButtonElement::EventDispatchAllowed) | 564 if (eventDispatch == SpinButtonElement::EventDispatchAllowed) |
| 559 element().dispatchFormControlChangeEvent(); | 565 element().dispatchFormControlChangeEvent(); |
| 560 } | 566 } |
| 561 | 567 |
| 562 } // namespace WebCore | 568 } // namespace WebCore |
| OLD | NEW |