diff --git a/cssom-view-1/Overview.bs b/cssom-view-1/Overview.bs index 9376d0d3cb2..5b2d74f7497 100644 --- a/cssom-view-1/Overview.bs +++ b/cssom-view-1/Overview.bs @@ -2006,6 +2006,10 @@ partial interface Range { }; +
+spec:dom; type:interface; text:FormControlRange ++ The getClientRects() method, when invoked, must return an empty {{DOMRectList}} object if the range is not in the document and otherwise a {{DOMRectList}} object containing a list of {{DOMRect}} objects in content order that matches the following constraints: @@ -2044,6 +2048,75 @@ Note: The {{DOMRect}} object returned by {{Range/getBoundingClientRect()}} is no range-bounding-client-rect-with-display-contents.html +
This section defines {{FormControlRange/getClientRects()}} and +{{FormControlRange/getBoundingClientRect()}} for {{FormControlRange}} (interface defined in [[DOM]]). +They mirror {{Range/getClientRects()}} and {{Range/getBoundingClientRect()}}, but operate on the +selected portion of a text control’s value.
+ +The IDL for these methods appears in [[DOM]]; it is not repeated here to avoid +duplication.
+ +The associated control of a {{FormControlRange}} is the <textarea>
or
+text-supporting <input>
whose editable value the range indexes into.
User agents typically represent the control’s value with a single internal text node. +If a future implementation were to use multiple nodes, this specification would need adjustment; +until then, algorithms assume a single backing text node.
+ +Unlike {{Range/getClientRects()}}, which historically returns an empty list for a +collapsed {{Range}}, this specification explicitly preserves that legacy behavior for +{{FormControlRange/getClientRects()}}: a collapsed {{FormControlRange}} also returns an empty +{{DOMRectList}}. Authors that need caret metrics should use +{{FormControlRange/getBoundingClientRect()}}.
+ +The getClientRects() method, when invoked, must run these +steps:
+If the associated control is not connected or its computed display
+ is none
, return an empty {{DOMRectList}}.
Update style and layout for the associated control.
Let value length be the current length of the associated control's value.
Let start be min(this range’s start boundary point offset, value length) + and end be min(this range’s end boundary point offset, value length).
If start > end, set end to start. This collapses backwards ranges per current implementations.
If start = end, return an empty {{DOMRectList}}.
Let text be the single text node that backs the control’s editable value. If none, return an empty {{DOMRectList}}.
Let r be a conceptual {{Range}} whose start is (text, start) and end is (text, end).
Return r.{{Range/getClientRects()}}.
The getBoundingClientRect() method, when invoked, must run +these steps:
+Let rects be the result of {{FormControlRange/getClientRects()}}.
If rects is empty:
+If this range is {{AbstractRange/collapsed}} and the associated control is visible
+ (its computed display
is not none
), return a zero-width [=scaled=]
+ {{DOMRect}} positioned at the caret (insertion point). Its block-size (height in horizontal
+ writing modes) is the line box block-size at that position, with any transforms that
+ apply to the control and its ancestors applied.
Otherwise, return a {{DOMRect}} whose {{DOMRect/x}}, {{DOMRect/y}}, {{DOMRect/width}}, and + {{DOMRect/height}} members are zero.
Otherwise, return a {{DOMRect}} describing the smallest rectangle that includes every + rectangle in rects whose width or height is not zero, as for + {{Range/getBoundingClientRect()}}.
If implementations later expose a caret rectangle via +{{FormControlRange/getClientRects()}} for collapsed ranges, this section will be updated. Authors +SHOULD NOT rely on observing an empty list vs. a zero-width caret rectangle to detect collapse; +use {{AbstractRange/collapsed}}.
+