Bug 287472

Summary: document.caretPositionFromPoint returns null over SVG elements and elements with `-webkit-user-select: none`
Product: WebKit Reporter: Anne van Kesteren <annevk>
Component: DOMAssignee: Aditya Keerthi <akeerthi>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, rbuis, simon.fraser, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://github.com/web-platform-tests/wpt/pull/54176
Bug Depends on:    
Bug Blocks: 286941    

Anne van Kesteren
Reported 2025-02-11 00:21:36 PST
<svg width=100 height=100><circle cx=50 cy=50 r=50 /></svg> <script> range = document.caretRangeFromPoint(50, 50); w(range); </script> logs null instead of a range pointing to the svg element. This can make shadow trees containing SVG observable (as we return null rather than a range for the host element). I discovered this in bug 286803. https://software.hixie.ch/utilities/js/live-dom-viewer/?%3Csvg%20width%3D100%20height%3D100%3E%3Ccircle%20cx%3D50%20cy%3D50%20r%3D50%20%2F%3E%3C%2Fsvg%3E%0A%3Cscript%3E%0Arange%20%3D%20document.caretRangeFromPoint(50%2C%2050)%3B%0Aw(range)%3B%0A%3C%2Fscript%3E
Attachments
Radar WebKit Bug Importer
Comment 1 2025-02-18 00:25:08 PST
Brent Fulgham
Comment 2 2025-03-31 13:46:06 PDT
Shouldn't this be `document.caretPositionForPoint()`?
Anne van Kesteren
Comment 4 2025-03-31 23:27:06 PDT
I'm pretty sure both use the same underlying infrastructure and we need to fix that as this ends up exposing shadow roots when they use SVG.
Aditya Keerthi
Comment 5 2025-08-05 20:53:17 PDT
Aditya Keerthi
Comment 6 2025-08-06 14:29:16 PDT
Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/54176
EWS
Comment 7 2025-08-06 18:08:19 PDT
Committed 298313@main (74c2e1e966aa): <https://commits.webkit.org/298313@main> Reviewed commits have been landed. Closing PR #48997 and removing active labels.
Aditya Keerthi
Comment 8 2025-08-21 13:39:11 PDT
*** Bug 287796 has been marked as a duplicate of this bug. ***
Note You need to log in before you can comment on or make changes to this bug.