Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document.caretPositionFromPoint API #301

Closed
siliu1 opened this issue Jan 11, 2024 · 7 comments
Closed

document.caretPositionFromPoint API #301

siliu1 opened this issue Jan 11, 2024 · 7 comments
Assignees
Labels
position: support topic: css Spec relates to CSS (Cascading Style Sheets) venue: W3C CSS WG

Comments

@siliu1
Copy link

siliu1 commented Jan 11, 2024

WebKittens

@pxlcoder @rniwa @whsieh

Title of the spec

CSSOM View: document.caretPositionFromPoint()

URL to the spec

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

URL to the spec's repository

No response

Issue Tracker URL

No response

Explainer URL

No response

TAG Design Review URL

No response

Mozilla standards-positions issue URL

No response

WebKit Bugzilla URL

https://bugs.webkit.org/show_bug.cgi?id=172137

Radar URL

No response

Description

WebKit/Blink has similar document.caretRangeFromPoint API which returns a text range indicating the text insertion point. The existing API was in CSSOM View at the time it was implemented: https://web.archive.org/web/20090708002518/http://dev.w3.org/csswg/cssom-view/#the-documentview-interface

The existing API was replaced by the new API later: https://hg.csswg.org/drafts/rev/4c7b6f843171

Gecko already implemented the new API.

@Ahmad-S792
Copy link

Bugzilla Ticket: https://bugs.webkit.org/show_bug.cgi?id=172137

@annevk
Copy link
Contributor

annevk commented Jan 13, 2024

Bit sad that nobody improved upon my 2009 definition of this method.

One thing that's not clear to me looking at this today is what happens if node tree mutations happen after you invoke this method. If it's an actual Range underneath, it would be impacted, which would then impact the result of caret position's getClientRect(). Whether that's desirable is a separate question.

@marcoscaceres
Copy link
Contributor

@pxlcoder, @rniwa, @whsieh, any opinions about this?

@siliu1
Copy link
Author

siliu1 commented Apr 17, 2024

CSS working group discussed this API (details in w3c/csswg-drafts#9932). The proposal is to add a new shadowRoots parameter to the API so that only the provided shadow roots can be pierced.

@annevk
Copy link
Contributor

annevk commented Apr 23, 2024

It seems w3c/csswg-drafts#10230 was filed on the issue I mentioned above. Overall this API seems reasonable to me, modulo that issue.

@siliu1
Copy link
Author

siliu1 commented May 16, 2024

w3c/csswg-drafts#10307 was merged. CaretPosition is not backed by a live range now. @annevk FYI. Thanks!

@annevk
Copy link
Contributor

annevk commented May 17, 2024

w3c/csswg-drafts#10345 modifies the API a bit further.

In any event, I suggest we resolve this as "position: support" one week from now. This API has been standardized for a long time already and this mainly adds support for shadow roots in a manner compatible with other APIs.

@annevk annevk added position: support topic: css Spec relates to CSS (Cascading Style Sheets) venue: W3C CSS WG labels May 27, 2024
@annevk annevk closed this as completed May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
position: support topic: css Spec relates to CSS (Cascading Style Sheets) venue: W3C CSS WG
Projects
None yet
Development

No branches or pull requests

7 participants