[Editing] Use dom selection anchor while extending the selection #53246
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, DOMSelection::extend uses the shadow-adjusted anchor node,
which causes the selection to collapse when extended within a shadow
tree. This change updates DOMSelection::extend to use the
SelectionInDOMTree anchor instead, ensuring that the selection can be
properly extended within shadow trees without collapsing.
As per the spec [1] the anchor node may or may not be part of the
shadow tree. In current implementation if we extend the selection
after DOMSelection::collapse the selection does extend but if we
extend after mouse click at same location in the shadow tree it
collapses. After this change the DOMSelection::extend behavior will
be consistent in both mouse click and DOMSelection::collapse cases and
this behavior also aligns with Webkit and Gecko.
[1] https://www.w3.org/TR/selection-api/#dfn-anchor
Bug: 421314614
Change-Id: I81c03931b80b795a90cc15ce5b5d79e50adf94da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6631596
Reviewed-by: Kent Tamura <tkent@chromium.org>
Commit-Queue: Ashish Kumar <ashishkum@microsoft.com>
Reviewed-by: Sambamurthy Bandaru <sambamurthy.bandaru@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1475430}