diff --git a/cssom-view-1/Overview.bs b/cssom-view-1/Overview.bs index c3c4087f6e0..b4d3fb30a6e 100644 --- a/cssom-view-1/Overview.bs +++ b/cssom-view-1/Overview.bs @@ -1024,6 +1024,7 @@ partial interface Document { Element? elementFromPoint(double x, double y); sequence<Element> elementsFromPoint(double x, double y); CaretPosition? caretPositionFromPoint(double x, double y, optional CaretPositionFromPointOptions options = {}); + Range? caretRangeFromPoint(double x, double y); readonly attribute Element? scrollingElement; }; @@ -1097,6 +1098,52 @@ result of running these steps: Note: This caret position is not live. +The caretRangeFromPoint(x, y) method must return the +result of running these steps: + +1. If there is no viewport associated with the document, return null. +1. If either argument is negative, x is greater + than the viewport width excluding the size of a rendered + scroll bar (if any), y is greater than the + viewport height excluding the size of a rendered scroll bar + (if any) return null. +1. If at the coordinates x,y + in the viewport no text insertion point indicator would have + been inserted when applying the transforms that apply to the descendants of the viewport, return null. +1. If at the coordinates x,y + in the viewport a text insertion point indicator would have + been inserted in a text entry widget which is also a replaced element, when applying the transforms that apply to the descendants of the + viewport, return a range with its properties set as follows: + +
+
range start node +
The node corresponding to the text entry widget. + +
range end node +
The node corresponding to the text entry widget. + +
range start offset +
The amount of 16-bit units to the left of where the + text insertion point indicator would have inserted. + +
range end offset +
The amount of 16-bit units to the left of where the + text insertion point indicator would have inserted. +
+1. Otherwise: + + 1. Let caretPosition be a tuple consisting of a caretPositionNode (a node) and a caretPositionOffset (a non-negative integer) for the position where the text insertion point indicator would have been inserted when applying + the transforms that apply to the descendants of the viewport. + 1. Let startNode be the caretPositionNode of the caretPosition, and let startOffset be the caretPositionOffset of the caretPosition. + 1. While startNode is a [=node=], startNode's [=tree/root=] is a [=shadow root=], and startNode's [=tree/root=] is not a [=shadow-including inclusive ancestor=] of any of options["{{CaretPositionFromPointOptions/shadowRoots}}"], repeat these steps: + 1. Set startOffset to [=tree/index=] of startNode's [=tree/root=]'s [=host=]. + 1. Set startNode to startNode's [=tree/root=]'s [=host=]'s [=tree/parent=]. + 1. Return a range with its properties set as follows: + 1. range start node is set to startNode. + 1. range end node is set to startNode. + 1. range start offset is set to startOffset. + 1. range end offset is set to startOffset. + Note: The specifics of hit testing are out of scope of this specification and therefore the exact details of {{elementFromPoint()}} and {{caretPositionFromPoint()}}