Skip to content

script: Consider a selection collapsed when the edit point equals the selection origin - #41978

Merged
mrobinson merged 1 commit into
servo:mainfrom
mrobinson:treat-collapsed-selection
Jan 19, 2026
Merged

mrobinson merged 1 commit into
servo:mainfrom
mrobinson:treat-collapsed-selection

Conversation

@mrobinson

Copy link
Copy Markdown
Member

In text inputs, the edit point can be equal to a non-None selection
origin for a variety of reasons such as when the selection is set by a
DOM API or when a composition event inserts a zero length string. In
both of these cases, we should treat the selection as collapsed. It is
important to do this because for the purposes of arrow key movement and
context menu entries, we should think of the text input as not having a
selection at all.

Testing: This change adds a Servo-specific WPT test, as key press behavior is
platform specific.

@mrobinson
mrobinson requested a review from gterzian as a code owner January 17, 2026 18:09
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jan 17, 2026
@mrobinson
mrobinson force-pushed the treat-collapsed-selection branch from 2007703 to 11b1a5d Compare January 17, 2026 18:21
… selection origin

In text inputs, the edit point can be equal to a non-`None` selection
origin for a variety of reasons such as when the selection is set by a
DOM API or when a composition event inserts a zero length string. In
both of these cases, we should treat the selection as collapsed. It is
important to do this because for the purposes of arrow key movement and
context menu entries, we should think of the text input as not having a
selection at all.

Signed-off-by: Martin Robinson <[email protected]>
@mrobinson
mrobinson force-pushed the treat-collapsed-selection branch from 11b1a5d to ae7d32a Compare January 17, 2026 18:29
github-merge-queue Bot pushed a commit that referenced this pull request Jan 17, 2026
Some platforms send empty composition events (winit on Linux, for
example). These should be ignored appropriately as they can cause
unecessary rendering updates even when the content of the text area does
not change.

Testing: This is mainly an optimization, so no tests are added. It does
prevent
some misbehavior, but that is a secondary effect fixed by #41978.

Signed-off-by: Martin Robinson <[email protected]>
@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Jan 19, 2026
@jdm
jdm added this pull request to the merge queue Jan 19, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jan 19, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jan 19, 2026
@servo-highfive servo-highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jan 19, 2026
@mrobinson
mrobinson added this pull request to the merge queue Jan 19, 2026
@servo-highfive servo-highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Jan 19, 2026
Merged via the queue into servo:main with commit e8f8846 Jan 19, 2026
@mrobinson
mrobinson deleted the treat-collapsed-selection branch January 19, 2026 15:54
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants