From e679be39aa83e65a06627a8a5b911648f5312f13 Mon Sep 17 00:00:00 2001 From: Di Zhang Date: Fri, 24 Jan 2025 16:06:54 -0800 Subject: [PATCH] Add UpdateSelectionBehavior to Range::UpdateSelectionIfAddedToSelection When a live range attached to a document is modified, this change is upstreamed to the FrameSelection. New spec [1] says to only update the composed live range (frame selection)'s start position if setStart is called and only update end position if setEnd is called: https://github.com/whatwg/dom/pull/1342 This is the proposal (B) discussed here: https://github.com/whatwg/dom/issues/772#issuecomment-2491887033 To do this, we define enum UpdateSelectionIfAddedToSelection to have three possible update selection behavior: 1. kAll, set selection to have the same start and end as range. --> Default case, when both setStart, setEnd are called. 2. kStartOnly, set selection to have the same start as range only. --> When only setStart is called. 3. kEndOnly, set selection to have the same end as range only. --> When only setEnd is called. We add a WPT test for this new behavior, which only affects the output of getComposedRanges() as it is the only API that accesses the frame selection's endpoints directly. Change-Id: I51ea53fe6156164ba3fbe38b14bc47ff502633b1 Bug: 40286116 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6188157 Reviewed-by: Siye Liu Commit-Queue: Di Zhang Cr-Commit-Position: refs/heads/main@{#1411209} --- ...ection-getComposedRanges-range-update.html | 190 ++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 selection/shadow-dom/tentative/Selection-getComposedRanges-range-update.html diff --git a/selection/shadow-dom/tentative/Selection-getComposedRanges-range-update.html b/selection/shadow-dom/tentative/Selection-getComposedRanges-range-update.html new file mode 100644 index 00000000000000..15f07305b0dfd5 --- /dev/null +++ b/selection/shadow-dom/tentative/Selection-getComposedRanges-range-update.html @@ -0,0 +1,190 @@ + + + + + + + + +
Start outside shadow DOM
+
outerHost + +
+ +