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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 unsigned 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 if (max <= (unsigned)input->selectionStart()) |
|
tkent
2014/04/29 23:55:44
Do not use C-style cast. Probably Making |max| in
harpreet.sk
2014/04/30 14:36:27
Done.
| |
| 165 input->setSelectionRange(max, max); | |
| 166 else if ((max > (unsigned)input->selectionStart()) && (max < (unsigned)i nput->selectionEnd())) | |
| 167 input->setSelectionRange(input->selectionStart(), max); | |
| 168 else | |
| 169 input->setSelectionRange(input->selectionStart(), input->selectionEn d()); | |
| 170 } | |
| 165 | 171 |
| 166 if (!valueChanged) | 172 if (!valueChanged) |
| 167 return; | 173 return; |
| 168 | 174 |
| 169 switch (eventBehavior) { | 175 switch (eventBehavior) { |
| 170 case DispatchChangeEvent: | 176 case DispatchChangeEvent: |
| 171 // 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. |
| 172 // The change event will be dispatched when editing finishes. | 178 // The change event will be dispatched when editing finishes. |
| 173 if (input->focused()) | 179 if (input->focused()) |
| 174 input->dispatchFormControlInputEvent(); | 180 input->dispatchFormControlInputEvent(); |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 565 return shouldSpinButtonRespondToMouseEvents() && element().focused(); | 571 return shouldSpinButtonRespondToMouseEvents() && element().focused(); |
| 566 } | 572 } |
| 567 | 573 |
| 568 void TextFieldInputType::spinButtonDidReleaseMouseCapture(SpinButtonElement::Eve ntDispatch eventDispatch) | 574 void TextFieldInputType::spinButtonDidReleaseMouseCapture(SpinButtonElement::Eve ntDispatch eventDispatch) |
| 569 { | 575 { |
| 570 if (eventDispatch == SpinButtonElement::EventDispatchAllowed) | 576 if (eventDispatch == SpinButtonElement::EventDispatchAllowed) |
| 571 element().dispatchFormControlChangeEvent(); | 577 element().dispatchFormControlChangeEvent(); |
| 572 } | 578 } |
| 573 | 579 |
| 574 } // namespace WebCore | 580 } // namespace WebCore |
| OLD | NEW |