DescriptionHTMLTextAreaElement.setSelectionRange should not change focus.
HTMLTextAreaElement.setSelectionRange(start,end) changes focus if |start| is not
|end|.
However, HTMLTextAreaElement.setSelectionRange should not change focus in any
condition.
FireFox follows such behavior at least.
Source/core/html/HTMLTextFormControlElement.cpp/h:
- Let setSelectionRange not change focus without the ChangeFocus option.
- SelectionOption option is used to change text selection like select() calling
on disabled input field.
- 278L: We must set 'forward' direction if direction is 'none' on not Mac.
- FrameSelection.setSelection is called when selectionOption is ChangeSelection
or this TextFormControl element is already focused.
Source/core/html/HTMLTextAreaElement.cpp/h:
- Change setValueCommon to call setSelectionRange except for initialize.
- setSelectionRange calls update layout, which needs updated validity so call
setNeedsValidityCheck earlier.
LayoutTests/fast/forms/selection-setSelectionRange-focusing.html:
- Added test. Check focus not to be changed.
LayoutTests/fast/forms/textarea-selection-preservation.html:
- Add test cases resetting selection. This is following the FireFox behavior.
(Other layout tests):
- Some tests expect setSelectionRange to change focus, thus I add extra focus.
- Some tests expect resetting value of textarea to change selection to 0, thus I
add extra setSelectionRange(0, 0);
TEST=LayoutTests/fast/forms/selection-setSelectionRange-focusing.html, textarea-
selection-preservation.html
BUG=393504
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=178822
Patch Set 1 : rename #
Total comments: 11
Patch Set 2 : Rename FocusOption #
Total comments: 2
Patch Set 3 : Change focusing #Patch Set 4 : Rebase #Patch Set 5 : Fixed failed tests #
Total comments: 4
Patch Set 6 : Update #Patch Set 7 : Call setSelectionRange inside setValueCommon #
Total comments: 3
Patch Set 8 : Update validity before updatelayout #
Total comments: 6
Patch Set 9 : Set selection to end from setNonDirtyValue #
Total comments: 1
Patch Set 10 : Fix tests #Messages
Total messages: 39 (0 generated)
|