Skip to content

script: Add support for selections that span shadow roots - #47895

Merged
SimonSapin merged 1 commit into
servo:mainfrom
mrobinson:selection-across-shadow-roots
Sep 9, 2026
Merged

SimonSapin merged 1 commit into
servo:mainfrom
mrobinson:selection-across-shadow-roots

Conversation

@mrobinson

Copy link
Copy Markdown
Member

Allow selections to span shadow root boundaries when possible, based on
the tentative specification changes that define this behavior. The
general characteristics of this change:

  • Boundary comparison is done by projecting the two boundaries into the
    same root and then comparing them, trying to consider deeper nodes as
    later ones.
  • When updating from live range changes, collapse the selection if it
    would reverse the direction and also properly dissassociate selections
    when the live range root changes.
  • Remove checks for whether boundary nodes are in a document tree (not in
    a shadow root) as other browsers aren't doing this and it causes
    tentative tests to fail. There's an open specification bug about this.
  • Remove temporary same root checks that prevented cross-boundary
    selections.

Testing: This gets a number of WPT tests and subtests passing.
Fixes: #47117.

@mrobinson
mrobinson requested a review from gterzian as a code owner September 8, 2026 09:30
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Sep 8, 2026
@mrobinson mrobinson added the T-linux-wpt Do a try run of the WPT label Sep 8, 2026
@github-actions github-actions Bot removed the T-linux-wpt Do a try run of the WPT label Sep 8, 2026
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

🔨 Triggering try run (#34210412483) for Linux (WPT)

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

⚠️ Try run (#34210412483) failed!

Allow selections to span shadow root boundaries when possible, based on
the tentative specification changes that define this behavior. The
general characteristics of this change:

- Boundary comparison is done by projecting the two boundaries into the
  same root and then comparing them, trying to consider deeper nodes as
  later ones.
- When updating from live range changes, collapse the selection if it
  would reverse the direction and also properly dissassociate selections
  when the live range root changes.
- Remove checks for whether boundary nodes are in a document tree (not in
  a shadow root) as other browsers aren't doing this and it causes
  tentative tests to fail. There's an open specification bug about this.
- Remove temporary same root checks that prevented cross-boundary
  selections.

Signed-off-by: Martin Robinson <[email protected]>
@mrobinson
mrobinson force-pushed the selection-across-shadow-roots branch from 3aca1b6 to d971b74 Compare September 8, 2026 10:56
@mrobinson

Copy link
Copy Markdown
Member Author

Looks like there are a good number of new passes in other places as well.

@mrobinson mrobinson added the T-linux-wpt Do a try run of the WPT label Sep 8, 2026
@github-actions github-actions Bot removed the T-linux-wpt Do a try run of the WPT label Sep 8, 2026
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

🔨 Triggering try run (#34218107507) for Linux (WPT)

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

✨ Try run (#34218107507) succeeded.

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Sep 9, 2026
@SimonSapin
SimonSapin added this pull request to the merge queue Sep 9, 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 Sep 9, 2026
Merged via the queue into servo:main with commit 3f0dfbe Sep 9, 2026
72 checks passed
@SimonSapin
SimonSapin deleted the selection-across-shadow-roots branch September 9, 2026 16:56
@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 Sep 9, 2026
RichardTjokroutomo pushed a commit to RichardTjokroutomo/servo that referenced this pull request Oct 6, 2026
Allow selections to span shadow root boundaries when possible, based on
the tentative specification changes that define this behavior. The
general characteristics of this change:

- Boundary comparison is done by projecting the two boundaries into the
  same root and then comparing them, trying to consider deeper nodes as
  later ones.
- When updating from live range changes, collapse the selection if it
  would reverse the direction and also properly dissassociate selections
  when the live range root changes.
- Remove checks for whether boundary nodes are in a document tree (not
in
  a shadow root) as other browsers aren't doing this and it causes
  tentative tests to fail. There's an open specification bug about this.
- Remove temporary same root checks that prevented cross-boundary
  selections.

Testing: This gets a number of WPT tests and subtests passing.
Fixes: servo#47117.

Signed-off-by: Martin Robinson <[email protected]>
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.

Selection's setBaseAndExtent() does not work crossing shadow boundaries

3 participants