Ready for Developer Testing: document.caretPositionFromPoint API

222 views
Skip to first unread message

Siye Liu

unread,
Mar 8, 2024, 5:43:29 PMMar 8
to blink-dev
Contact emails
si...@microsoft.comsa...@microsoft.com

Explainer
None

Specification
https://www.w3.org/TR/cssom-view-1/#dom-document-caretpositionfrompoint

Summary

This new API allows users to get current caret position from a given screen point. The API returns a CaretPosition object which represents the caret position indicating current text insertion point including the containing DOM node, caret's character offset, and the client rectangle of caret range. The API also supports get CaretPosition inside Shadow DOM.



Blink component
Blink>CSS

TAG review
None

TAG review status
Not applicable. This qualifies for an exception - has already shipped in another browser.

Risks

Interoperability and Compatibility

Gecko already implemented the API. Webkit/Blink didn't implement it. The interop risk is that it's unclear at this moment about Webkit's position on this. We won't be able to achieve full interop with this API if Webkit isn't willing to support this API. There is a compat risk too if we decided to deprecate the old API: https://crbug.com/690599



Gecko: Shipped/Shipping

WebKit: No signal (https://github.com/WebKit/standards-positions/issues/301)

Web developers: Positive (https://bugs.chromium.org/p/chromium/issues/detail?id=388976#c34) Web developers are asking to have document.caretPositionFromPoint API implemented in Blink: https://bugs.chromium.org/p/chromium/issues/detail?id=388976#c28 https://bugs.chromium.org/p/chromium/issues/detail?id=388976#c34

Other signals:

WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?

None



Goals for experimentation

Get feedback from web developers and assess whether the API meets developer needs.

Ongoing technical constraints

None



Debuggability

None



Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, ChromeOS, Android, and Android WebView)?
Yes

Is this feature fully tested by web-platform-tests?

The API is tested for main DOM in WPT: https://github.com/web-platform-tests/wpt/blob/c18cfd4eb319ca535db8c194941719598b3b6ea8/css/cssom/caretPositionFromPoint.html Will add additional tests including cases for Shadow DOM scenario once https://github.com/w3c/csswg-drafts/issues/9932 is resolved.



Flag name on chrome://flags
None

Finch feature name
CaretPositionFromPoint

Requires code in //chrome?
False

Tracking bug
https://crbug.com/388976

Estimated milestones
DevTrial on desktop
123


Link to entry on the Chrome Platform Status
https://chromestatus.com/feature/5201014343073792

Links to previous Intent discussions
Intent to prototype:
Reply all
Reply to author
Forward
0 new messages