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.
document.caretPositionFromPoint API is in CSSOM View and is already implemented by Gecko. 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://bugs.webkit.org/show_bug.cgi?id=27046 http://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. The switch happened around 2009 and we don't have the historical context about the decision. Given how long it has been since the spec was updated, we believe it's best that Blink complies with the spec so that future innovations with the API can be spec compliant and have lower interop/compat risk.
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
Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?
None
None
The API is tested in WPT: https://github.com/web-platform-tests/wpt/blob/c18cfd4eb319ca535db8c194941719598b3b6ea8/css/cssom/caretPositionFromPoint.html
No milestones specified
This is not directly related to this one function but more to the whole API. I quickly skimmed the spec and I could not find out how it handles line breaks which make caret positions ambigious?
When you press the END key at one line, and the HOME key at the
following line your caret DOM position can be the same, but the
visual caret positions should be different, and so should certain
actions like arrow-down and arrow-up.
When developing code to handle this in Opera, I solved it by letting carets know if they were connected forward or backwards (basically a bool) in the dom element, but maybe this is solved in some other way now?
/Daniel
--
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/0169dc69-72a5-46e4-b377-e682f8818a80n%40chromium.org.
Sounds like something that should be reflected in the specs. Again, not directly related to this Intent, but maybe something that should happen in parallel.
/Daniel
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/7183ed6f-73e0-4858-a477-5469d764efc8n%40chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/f93cdcfd-9ed8-4695-ae03-4afdc5d93975n%40chromium.org.