Intent to Ship: document.caretPositionFromPoint API

421 views
Skip to first unread message

Siye Liu

unread,
Jun 5, 2024, 2:20:24 PMJun 5
to blin...@chromium.org
Contact emails
Explainer
None

Specification
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. To get CaretPosition inside Shadow DOM, caller needs to provide reference to all the shadow roots that this API can pierce into.


Blink component
TAG review

TAG review status
Issues open

Risks


Interoperability and Compatibility
Gecko already implemented the API without the argument that contains shadow roots that this API can pierce into. Webkit/Blink didn't implement it. The Gecko implementation in shadow DOM scenario is not spec-compliant either (Spec changed recently to cover shadow DOM scenario). Gecko 's position is positive on this API. We expect that Gecko's behavior will be changed to be spec-compliant in the future. There is also a future compat risk too if we decided to deprecate the non-standard API `document.caretRangeFromPoint`: https://crbug.com/690599
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


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?
Yes



Flag name on chrome://flags
None

Finch feature name
CaretPositionFromPoint

Requires code in //chrome?
False

Tracking bug
Estimated milestones
Shipping on desktop
127
DevTrial on desktop
127


Anticipated spec changes
Open questions about a feature may be a source of future web compat or interop issues. Please list open issues (e.g. links to known github issues in the project for the feature specification) whose resolution may introduce web compat/interop risk (e.g., changing to naming or structure of the API in a non-backward-compatible way).
None

Link to entry on the Chrome Platform Status
Links to previous Intent discussions
This intent message was generated by Chrome Platform Status.

Brian Birtles

unread,
Jun 5, 2024, 8:10:18 PMJun 5
to blink-dev, si...@microsoft.com
Hi,

Does this return the offset inside text input elements like Gecko's implementation?

Best regards,

Brian

2024年6月6日木曜日 3:20:24 UTC+9 si...@microsoft.com:

Siye Liu

unread,
Jun 5, 2024, 11:09:35 PMJun 5
to blink-dev, Brian Birtles, Siye Liu
Yes, the API returns offset inside text input and textarea elements.

Thanks,
Siye

Chris Harrelson

unread,
Jun 6, 2024, 12:47:37 PMJun 6
to Siye Liu, blink-dev, Brian Birtles
Hi, please fill out these reviews on your chromestatus entry:

image.png

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/4127f29a-82e6-41d0-bab4-596f66fa43c9n%40chromium.org.

Siye Liu

unread,
Jun 6, 2024, 3:03:02 PMJun 6
to blink-dev, Chris Harrelson, blink-dev, Brian Birtles, Siye Liu
Reviews requested.

Thanks,
Siye

Yoav Weiss (@Shopify)

unread,
Jun 12, 2024, 7:03:35 AMJun 12
to Siye Liu, blink-dev, Chris Harrelson, Brian Birtles

Are we passing the tests with the flag enabled? Do the few Mozilla failures represent their deviation from the spec? Or something else?

Siye Liu

unread,
Jun 12, 2024, 4:26:44 PM (14 days ago) Jun 12
to blink-dev, yoav...@chromium.org, blink-dev, Chris Harrelson, Brian Birtles, Siye Liu
Yes, these tests will all pass if we enable the runtime flag `CaretPositionFromPoint`. 

The few Mozilla failures do represent their non-spec compliant behavior.

Thanks,
Siye

Chris Harrelson

unread,
Jun 13, 2024, 4:32:15 AM (13 days ago) Jun 13
to Siye Liu, blink-dev, yoav...@chromium.org, Brian Birtles

Yoav Weiss (@Shopify)

unread,
Jun 13, 2024, 4:56:25 AM (13 days ago) Jun 13
to Chris Harrelson, Siye Liu, blink-dev, Brian Birtles
LGTM2

Daniel Bratell

unread,
Jun 13, 2024, 8:34:32 AM (13 days ago) Jun 13
to Yoav Weiss (@Shopify), Chris Harrelson, Siye Liu, blink-dev, Brian Birtles

Yoav Weiss (@Shopify)

unread,
Jun 17, 2024, 7:37:59 AM (9 days ago) Jun 17
to Daniel Bratell, Chris Harrelson, Siye Liu, blink-dev, Brian Birtles
Note that the TAG just came back with some feedback regarding the API shape. Please address it before shipping.
Message has been deleted

Siye Liu

unread,
Jun 17, 2024, 12:16:41 PM (9 days ago) Jun 17
to blink-dev, yoav...@chromium.org, Chris Harrelson, Siye Liu, blink-dev, Brian Birtles, Daniel Bratell
TAG suggested we put the shadow roots in a dictionary with a `shadowRoots` option (The API shape changed in spec after the TAG review was filed). That's what Chromium implemented: document.idl - Chromium Code Search. I think we are good here.

Yoav Weiss (@Shopify)

unread,
Jun 17, 2024, 2:33:06 PM (9 days ago) Jun 17
to Siye Liu, blink-dev, Chris Harrelson, Brian Birtles, Daniel Bratell
On Mon, Jun 17, 2024 at 6:16 PM 'Siye Liu' via blink-dev <blin...@chromium.org> wrote:
TAG suggested we put the shadow roots in a dictionary with a `shadowRoots` option (The API shape changed in spec after the TAG review was filed). That's what Chromium implemented: document.idl - Chromium Code Search. I think we are good here.

Awesome, thanks!
 

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
Reply all
Reply to author
Forward
0 new messages