Closed siliu1 closed 1 month ago
Bugzilla Ticket: https://bugs.webkit.org/show_bug.cgi?id=172137
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.
@pxlcoder, @rniwa, @whsieh, any opinions about this?
CSS working group discussed this API (details in https://github.com/w3c/csswg-drafts/issues/9932). The proposal is to add a new shadowRoots
parameter to the API so that only the provided shadow roots can be pierced.
It seems https://github.com/w3c/csswg-drafts/issues/10230 was filed on the issue I mentioned above. Overall this API seems reasonable to me, modulo that issue.
https://github.com/w3c/csswg-drafts/pull/10307 was merged. CaretPosition
is not backed by a live range now. @annevk FYI. Thanks!
https://github.com/w3c/csswg-drafts/issues/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.
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.