From d4a94e8c29a00bf7e5d865d6df2003389039a3f4 Mon Sep 17 00:00:00 2001
From: Stephanie Zhang This section defines {{FormControlRange/getClientRects()}} and
+{{FormControlRange/getBoundingClientRect()}}. The {{FormControlRange}} interface is defined in
+[[DOM]]. These methods mirror {{Range/getClientRects()}} and {{Range/getBoundingClientRect()}}, but
+apply to the selected portion of a text control’s value. The getClientRects() method, when invoked, must run these
+steps: If the associated control is not connected or its computed Update style and layout for the associated control. Let start and end be this range’s boundary offsets, clamped to the
+ current length of the control’s value. Let text be the single text node that backs the control’s editable value. If there
+ is no such node, return an empty {{DOMRectList}}. Let r be a {{Range}} whose start and end are (text, start)
+ and (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 control is visible (its computed
+ Otherwise, return a {{DOMRect}} with zero width and height. Otherwise, return the union of the rectangles in rects, as for
+ {{Range/getBoundingClientRect()}}. This section defines {{FormControlRange/getClientRects()}} and
-{{FormControlRange/getBoundingClientRect()}}. The {{FormControlRange}} interface is defined in
-[[DOM]]. These methods mirror {{Range/getClientRects()}} and {{Range/getBoundingClientRect()}}, but
-apply to the selected portion of a text control’s value.
+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,49 @@ Note: The {{DOMRect}} object returned by {{Range/getBoundingClientRect()}} is no
range-bounding-client-rect-with-display-contents.html
+FormControlRange geometry
+
+
+
+display is
+ none, return an empty {{DOMRectList}}.
+
+
+
+ display is not none), return a zero-width {{DOMRect}} positioned at the
+ caret, whose height equals the line height at that position.Extensions to the {{MouseEvent}} Interface
Issue: The object IDL fragment redefines some members. Can we resolve this somehow?
From 09c8acb7fb60b8944967b63b8253f70113605775 Mon Sep 17 00:00:00 2001
From: Stephanie Y Zhang FormControlRange geometry
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 start and end be this range’s boundary offsets, clamped to the - current length of the control’s value.
Let text be the single text node that backs the control’s editable value. If there - is no such node, return an empty {{DOMRectList}}.
Let r be a {{Range}} whose start and end are (text, start) - and (text, end).
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()}}.
If rects is empty:
If this range is {{AbstractRange/collapsed}} and the control is visible (its computed
- display is not none), return a zero-width {{DOMRect}} positioned at the
- caret, whose height equals the line height at that position.
Otherwise, return a {{DOMRect}} with zero width and height.
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 the union of the rectangles in rects, as for +
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}}.
+