-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fire selectionchange event on input and textarea elements
https://bugs.webkit.org/show_bug.cgi?id=271033 Reviewed by Sihui Liu and Wenson Hsieh. This PR updates the implementation of selectionchange event to be fired on input element and textarea element instead of document whenever either real selection or cached selection offsets have been updated to match the specification: https://w3c.github.io/selection-api/#selectionchange-event * LayoutTests/imported/w3c/web-platform-tests/selection/textcontrols/selectionchange-bubble-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/selection/textcontrols/selectionchange-expected.txt: * LayoutTests/platform/gtk/imported/w3c/web-platform-tests/selection/textcontrols/selectionchange-expected.txt: Added. * Source/WebCore/editing/FrameSelection.cpp: (WebCore::FrameSelection::setSelectionWithoutUpdatingAppearance): Fire selectionchange event on input element and textarea element when the selection resides within those elements. * Source/WebCore/html/HTMLTextAreaElement.cpp: (WebCore::HTMLTextAreaElement::setValueCommon): Fixed a bug that this code was always updating selection even when TextControlSetValueSelection::DoNotSet is passed in. * Source/WebCore/html/HTMLTextFormControlElement.cpp: (WebCore::HTMLTextFormControlElement::selectionChanged): Made this function return a boolean indicating whether the selection end points have changed or not. (WebCore::HTMLTextFormControlElement::scheduleSelectEvent): * Source/WebCore/html/HTMLTextFormControlElement.h: Canonical link: https://commits.webkit.org/276238@main
- Loading branch information
Showing
7 changed files
with
147 additions
and
64 deletions.
There are no files selected for viewing
10 changes: 4 additions & 6 deletions
10
...mported/w3c/web-platform-tests/selection/textcontrols/selectionchange-bubble-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
|
||
|
||
|
||
Harness Error (TIMEOUT), message = null | ||
|
||
TIMEOUT selectionchange bubbles from input Test timed out | ||
NOTRUN selectionchange bubbles from input when focused | ||
NOTRUN selectionchange bubbles from textarea | ||
NOTRUN selectionchange bubbles from textarea when focused | ||
PASS selectionchange bubbles from input | ||
PASS selectionchange bubbles from input when focused | ||
PASS selectionchange bubbles from textarea | ||
PASS selectionchange bubbles from textarea when focused | ||
|
88 changes: 44 additions & 44 deletions
88
...Tests/imported/w3c/web-platform-tests/selection/textcontrols/selectionchange-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,64 @@ | ||
|
||
|
||
|
||
FAIL Modifying selectionStart value of the input element assert_equals: expected 1 but got 0 | ||
FAIL Modifying selectionEnd value of the input element assert_equals: expected 1 but got 0 | ||
FAIL Calling setSelectionRange() on the input element assert_equals: expected 1 but got 0 | ||
FAIL Calling select() on the input element assert_equals: expected 1 but got 0 | ||
FAIL Calling setRangeText() on the input element assert_equals: expected 1 but got 0 | ||
PASS Modifying selectionStart value of the input element | ||
PASS Modifying selectionEnd value of the input element | ||
PASS Calling setSelectionRange() on the input element | ||
PASS Calling select() on the input element | ||
PASS Calling setRangeText() on the input element | ||
PASS Setting initial zero selectionStart value on the input element | ||
FAIL Setting the same selectionStart value twice on the input element assert_equals: expected 1 but got 0 | ||
PASS Setting the same selectionStart value twice on the input element | ||
PASS Setting initial zero selectionEnd value on the input element | ||
FAIL Setting the same selectionEnd value twice on the input element assert_equals: expected 1 but got 0 | ||
PASS Setting the same selectionEnd value twice on the input element | ||
PASS Setting initial zero selection range on the input element | ||
FAIL Setting the same selection range twice on the input element assert_equals: expected 1 but got 0 | ||
FAIL Calling select() twice on the input element assert_equals: expected 1 but got 0 | ||
FAIL Calling setRangeText() after select() on the input element assert_equals: expected 2 but got 0 | ||
FAIL Calling setRangeText() repeatedly on the input element assert_equals: expected 4 but got 0 | ||
PASS Setting the same selection range twice on the input element | ||
PASS Calling select() twice on the input element | ||
PASS Calling setRangeText() after select() on the input element | ||
PASS Calling setRangeText() repeatedly on the input element | ||
PASS Calling setRangeText() on empty the input element | ||
FAIL Modifying selectionStart value of the disconnected input element assert_equals: expected 1 but got 0 | ||
FAIL Modifying selectionEnd value of the disconnected input element assert_equals: expected 1 but got 0 | ||
FAIL Calling setSelectionRange() on the disconnected input element assert_equals: expected 1 but got 0 | ||
FAIL Calling select() on the disconnected input element assert_equals: expected 1 but got 0 | ||
FAIL Calling setRangeText() on the disconnected input element assert_equals: expected 1 but got 0 | ||
PASS Modifying selectionStart value of the disconnected input element | ||
PASS Modifying selectionEnd value of the disconnected input element | ||
PASS Calling setSelectionRange() on the disconnected input element | ||
PASS Calling select() on the disconnected input element | ||
PASS Calling setRangeText() on the disconnected input element | ||
PASS Setting initial zero selectionStart value on the disconnected input element | ||
FAIL Setting the same selectionStart value twice on the disconnected input element assert_equals: expected 1 but got 0 | ||
PASS Setting the same selectionStart value twice on the disconnected input element | ||
PASS Setting initial zero selectionEnd value on the disconnected input element | ||
FAIL Setting the same selectionEnd value twice on the disconnected input element assert_equals: expected 1 but got 0 | ||
PASS Setting the same selectionEnd value twice on the disconnected input element | ||
PASS Setting initial zero selection range on the disconnected input element | ||
FAIL Setting the same selection range twice on the disconnected input element assert_equals: expected 1 but got 0 | ||
FAIL Calling select() twice on the disconnected input element assert_equals: expected 1 but got 0 | ||
FAIL Calling setRangeText() after select() on the disconnected input element assert_equals: expected 2 but got 0 | ||
FAIL Calling setRangeText() repeatedly on the disconnected input element assert_equals: expected 4 but got 0 | ||
PASS Setting the same selection range twice on the disconnected input element | ||
PASS Calling select() twice on the disconnected input element | ||
PASS Calling setRangeText() after select() on the disconnected input element | ||
PASS Calling setRangeText() repeatedly on the disconnected input element | ||
PASS Calling setRangeText() on empty the disconnected input element | ||
FAIL Modifying selectionStart value of the textarea element assert_equals: expected 1 but got 0 | ||
FAIL Modifying selectionEnd value of the textarea element assert_equals: expected 1 but got 0 | ||
FAIL Calling setSelectionRange() on the textarea element assert_equals: expected 1 but got 0 | ||
FAIL Calling select() on the textarea element assert_equals: expected 1 but got 0 | ||
FAIL Calling setRangeText() on the textarea element assert_equals: expected 1 but got 0 | ||
PASS Modifying selectionStart value of the textarea element | ||
PASS Modifying selectionEnd value of the textarea element | ||
PASS Calling setSelectionRange() on the textarea element | ||
PASS Calling select() on the textarea element | ||
PASS Calling setRangeText() on the textarea element | ||
PASS Setting initial zero selectionStart value on the textarea element | ||
FAIL Setting the same selectionStart value twice on the textarea element assert_equals: expected 1 but got 0 | ||
PASS Setting the same selectionStart value twice on the textarea element | ||
PASS Setting initial zero selectionEnd value on the textarea element | ||
FAIL Setting the same selectionEnd value twice on the textarea element assert_equals: expected 1 but got 0 | ||
PASS Setting the same selectionEnd value twice on the textarea element | ||
PASS Setting initial zero selection range on the textarea element | ||
FAIL Setting the same selection range twice on the textarea element assert_equals: expected 1 but got 0 | ||
FAIL Calling select() twice on the textarea element assert_equals: expected 1 but got 0 | ||
FAIL Calling setRangeText() after select() on the textarea element assert_equals: expected 2 but got 0 | ||
FAIL Calling setRangeText() repeatedly on the textarea element assert_equals: expected 4 but got 0 | ||
PASS Setting the same selection range twice on the textarea element | ||
PASS Calling select() twice on the textarea element | ||
PASS Calling setRangeText() after select() on the textarea element | ||
PASS Calling setRangeText() repeatedly on the textarea element | ||
PASS Calling setRangeText() on empty the textarea element | ||
FAIL Modifying selectionStart value of the disconnected textarea element assert_equals: expected 1 but got 0 | ||
FAIL Modifying selectionEnd value of the disconnected textarea element assert_equals: expected 1 but got 0 | ||
FAIL Calling setSelectionRange() on the disconnected textarea element assert_equals: expected 1 but got 0 | ||
FAIL Calling select() on the disconnected textarea element assert_equals: expected 1 but got 0 | ||
FAIL Calling setRangeText() on the disconnected textarea element assert_equals: expected 1 but got 0 | ||
PASS Modifying selectionStart value of the disconnected textarea element | ||
PASS Modifying selectionEnd value of the disconnected textarea element | ||
PASS Calling setSelectionRange() on the disconnected textarea element | ||
PASS Calling select() on the disconnected textarea element | ||
PASS Calling setRangeText() on the disconnected textarea element | ||
PASS Setting initial zero selectionStart value on the disconnected textarea element | ||
FAIL Setting the same selectionStart value twice on the disconnected textarea element assert_equals: expected 1 but got 0 | ||
PASS Setting the same selectionStart value twice on the disconnected textarea element | ||
PASS Setting initial zero selectionEnd value on the disconnected textarea element | ||
FAIL Setting the same selectionEnd value twice on the disconnected textarea element assert_equals: expected 1 but got 0 | ||
PASS Setting the same selectionEnd value twice on the disconnected textarea element | ||
PASS Setting initial zero selection range on the disconnected textarea element | ||
FAIL Setting the same selection range twice on the disconnected textarea element assert_equals: expected 1 but got 0 | ||
FAIL Calling select() twice on the disconnected textarea element assert_equals: expected 1 but got 0 | ||
FAIL Calling setRangeText() after select() on the disconnected textarea element assert_equals: expected 2 but got 0 | ||
FAIL Calling setRangeText() repeatedly on the disconnected textarea element assert_equals: expected 4 but got 0 | ||
PASS Setting the same selection range twice on the disconnected textarea element | ||
PASS Calling select() twice on the disconnected textarea element | ||
PASS Calling setRangeText() after select() on the disconnected textarea element | ||
PASS Calling setRangeText() repeatedly on the disconnected textarea element | ||
PASS Calling setRangeText() on empty the disconnected textarea element | ||
|
64 changes: 64 additions & 0 deletions
64
...m/gtk/imported/w3c/web-platform-tests/selection/textcontrols/selectionchange-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
|
||
|
||
|
||
PASS Modifying selectionStart value of the input element | ||
PASS Modifying selectionEnd value of the input element | ||
PASS Calling setSelectionRange() on the input element | ||
PASS Calling select() on the input element | ||
PASS Calling setRangeText() on the input element | ||
PASS Setting initial zero selectionStart value on the input element | ||
PASS Setting the same selectionStart value twice on the input element | ||
PASS Setting initial zero selectionEnd value on the input element | ||
PASS Setting the same selectionEnd value twice on the input element | ||
PASS Setting initial zero selection range on the input element | ||
PASS Setting the same selection range twice on the input element | ||
PASS Calling select() twice on the input element | ||
PASS Calling setRangeText() after select() on the input element | ||
PASS Calling setRangeText() repeatedly on the input element | ||
FAIL Calling setRangeText() on empty the input element assert_equals: expected 0 but got 1 | ||
PASS Modifying selectionStart value of the disconnected input element | ||
PASS Modifying selectionEnd value of the disconnected input element | ||
PASS Calling setSelectionRange() on the disconnected input element | ||
PASS Calling select() on the disconnected input element | ||
PASS Calling setRangeText() on the disconnected input element | ||
PASS Setting initial zero selectionStart value on the disconnected input element | ||
PASS Setting the same selectionStart value twice on the disconnected input element | ||
PASS Setting initial zero selectionEnd value on the disconnected input element | ||
PASS Setting the same selectionEnd value twice on the disconnected input element | ||
PASS Setting initial zero selection range on the disconnected input element | ||
PASS Setting the same selection range twice on the disconnected input element | ||
PASS Calling select() twice on the disconnected input element | ||
PASS Calling setRangeText() after select() on the disconnected input element | ||
PASS Calling setRangeText() repeatedly on the disconnected input element | ||
FAIL Calling setRangeText() on empty the disconnected input element assert_equals: expected 0 but got 1 | ||
PASS Modifying selectionStart value of the textarea element | ||
PASS Modifying selectionEnd value of the textarea element | ||
PASS Calling setSelectionRange() on the textarea element | ||
PASS Calling select() on the textarea element | ||
PASS Calling setRangeText() on the textarea element | ||
PASS Setting initial zero selectionStart value on the textarea element | ||
PASS Setting the same selectionStart value twice on the textarea element | ||
PASS Setting initial zero selectionEnd value on the textarea element | ||
PASS Setting the same selectionEnd value twice on the textarea element | ||
PASS Setting initial zero selection range on the textarea element | ||
PASS Setting the same selection range twice on the textarea element | ||
PASS Calling select() twice on the textarea element | ||
PASS Calling setRangeText() after select() on the textarea element | ||
PASS Calling setRangeText() repeatedly on the textarea element | ||
PASS Calling setRangeText() on empty the textarea element | ||
PASS Modifying selectionStart value of the disconnected textarea element | ||
PASS Modifying selectionEnd value of the disconnected textarea element | ||
PASS Calling setSelectionRange() on the disconnected textarea element | ||
PASS Calling select() on the disconnected textarea element | ||
PASS Calling setRangeText() on the disconnected textarea element | ||
PASS Setting initial zero selectionStart value on the disconnected textarea element | ||
PASS Setting the same selectionStart value twice on the disconnected textarea element | ||
PASS Setting initial zero selectionEnd value on the disconnected textarea element | ||
PASS Setting the same selectionEnd value twice on the disconnected textarea element | ||
PASS Setting initial zero selection range on the disconnected textarea element | ||
PASS Setting the same selection range twice on the disconnected textarea element | ||
PASS Calling select() twice on the disconnected textarea element | ||
PASS Calling setRangeText() after select() on the disconnected textarea element | ||
PASS Calling setRangeText() repeatedly on the disconnected textarea element | ||
FAIL Calling setRangeText() on empty the disconnected textarea element assert_equals: expected 0 but got 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters