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: | DOM | Assignee: | 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
<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 | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/145038689>
Brent Fulgham
Shouldn't this be `document.caretPositionForPoint()`?
Brent Fulgham
https://software.hixie.ch/utilities/js/live-dom-viewer/saved/13608
Anne van Kesteren
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
Pull request: https://github.com/WebKit/WebKit/pull/48997
Aditya Keerthi
Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/54176
EWS
Committed 298313@main (74c2e1e966aa): <https://commits.webkit.org/298313@main>
Reviewed commits have been landed. Closing PR #48997 and removing active labels.
Aditya Keerthi
*** Bug 287796 has been marked as a duplicate of this bug. ***