From 757498eface89be14e758dc2c29430c19c85ec46 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Tue, 12 Mar 2024 06:11:45 +0000 Subject: [PATCH] Make `ShadowRoot` notify mutation observers of "parent chain changed" Currently, `ShadowRoot::Unbind` does not notify the observers of the notification. With this change, `nsRange` starts removing itself from all `Selection`s if its root becomes disconnected. This behavior is different from Chrome, Chrome allows the disconnected range in shadow as a selection range. However, it does not match with the behavior tested in `move-selection-range-into-different-root.tentative.html` [1][2]. Therefore, I think that removing the range from `Selection` is reasonable for now because it's not reasonable to add a check to all selection range getters/users to check whether the range is in the composed tree. 1. https://searchfox.org/mozilla-central/rev/b60cb73160843adb5a5a3ec8058e75a69b46acf7/testing/web-platform/tests/selection/move-selection-range-into-different-root.tentative.html 2. https://wpt.fyi/results/selection/move-selection-range-into-different-root.tentative.html?run_id=5070898326929408&run_id=5147803004698624&run_id=5098392828510208&run_id=5175063246012416 Differential Revision: https://phabricator.services.mozilla.com/D204218 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1883802 gecko-commit: dda1e753390ebd7e848058e896da8b74bb105068 gecko-reviewers: smaug --- ...ge-in-shadow-after-the-shadow-removed.html | 47 +++++++++ ...on-modify-line-boundary-around-shadow.html | 30 ++++++ ...ction-range-after-editinghost-removed.html | 69 +++++++++++++ ...ction-range-after-textcontrol-removed.html | 55 +++++++++++ ...ow-after-the-shadow-removed.tentative.html | 96 +++++++++++++++++++ 5 files changed, 297 insertions(+) create mode 100644 dom/ranges/Range-in-shadow-after-the-shadow-removed.html create mode 100644 selection/crashtests/selection-modify-line-boundary-around-shadow.html create mode 100644 selection/selection-range-after-editinghost-removed.html create mode 100644 selection/selection-range-after-textcontrol-removed.html create mode 100644 selection/selection-range-in-shadow-after-the-shadow-removed.tentative.html diff --git a/dom/ranges/Range-in-shadow-after-the-shadow-removed.html b/dom/ranges/Range-in-shadow-after-the-shadow-removed.html new file mode 100644 index 00000000000000..54ea8aabeab733 --- /dev/null +++ b/dom/ranges/Range-in-shadow-after-the-shadow-removed.html @@ -0,0 +1,47 @@ + + + + + + +Range in shadow after removing the shadow + + + + + + diff --git a/selection/crashtests/selection-modify-line-boundary-around-shadow.html b/selection/crashtests/selection-modify-line-boundary-around-shadow.html new file mode 100644 index 00000000000000..bfca0402a7096a --- /dev/null +++ b/selection/crashtests/selection-modify-line-boundary-around-shadow.html @@ -0,0 +1,30 @@ + + + + + + + +
+
+ + diff --git a/selection/selection-range-after-editinghost-removed.html b/selection/selection-range-after-editinghost-removed.html new file mode 100644 index 00000000000000..921903062ac608 --- /dev/null +++ b/selection/selection-range-after-editinghost-removed.html @@ -0,0 +1,69 @@ + + + + +Selection range in an editing host after the host is removed + + + + +
+ diff --git a/selection/selection-range-after-textcontrol-removed.html b/selection/selection-range-after-textcontrol-removed.html new file mode 100644 index 00000000000000..e618f10f1d88e1 --- /dev/null +++ b/selection/selection-range-after-textcontrol-removed.html @@ -0,0 +1,55 @@ + + + + + + + + +Selection range after text control is removed + + + + + + diff --git a/selection/selection-range-in-shadow-after-the-shadow-removed.tentative.html b/selection/selection-range-in-shadow-after-the-shadow-removed.tentative.html new file mode 100644 index 00000000000000..e9f63715a2f154 --- /dev/null +++ b/selection/selection-range-in-shadow-after-the-shadow-removed.tentative.html @@ -0,0 +1,96 @@ + + + + + + +Selection range in shadow after removing the shadow + + + + +
+