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

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.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson
2026-01-19 16:08:40 +01:00
committed by GitHub
parent eacdbd9a34
commit e8f88468d0
7 changed files with 52 additions and 18 deletions

View File

@@ -270,8 +270,8 @@ impl TextControlElement for HTMLTextAreaElement {
!self.textinput.borrow().get_content().is_empty()
}
fn has_selection(&self) -> bool {
self.textinput.borrow().has_selection()
fn has_uncollapsed_selection(&self) -> bool {
self.textinput.borrow().has_uncollapsed_selection()
}
fn set_dirty_value_flag(&self, value: bool) {