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 { }; + + 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 +

FormControlRange geometry

+ +

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:

+
    +
  1. If the associated control is not connected or its computed display + is none, return an empty {{DOMRectList}}.

  2. +
  3. Update style and layout for the associated control.

  4. +
  5. Let value length be the current length of the associated control's value.

  6. +
  7. 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).

  8. +
  9. If start > end, set end to start. This collapses backwards ranges per current implementations.

  10. +
  11. If start = end, return an empty {{DOMRectList}}.

  12. +
  13. Let text be the single text node that backs the control’s editable value. If none, return an empty {{DOMRectList}}.

  14. +
  15. Let r be a conceptual {{Range}} whose start is (text, start) and end is (text, end).

  16. +
  17. Return r.{{Range/getClientRects()}}.

  18. +
+
+ +
+

The getBoundingClientRect() method, when invoked, must run +these steps:

+
    +
  1. Let rects be the result of {{FormControlRange/getClientRects()}}.

  2. +
  3. +

    If rects is empty:

    +
      +
    1. 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.

    2. +
    3. Otherwise, return a {{DOMRect}} whose {{DOMRect/x}}, {{DOMRect/y}}, {{DOMRect/width}}, and + {{DOMRect/height}} members are zero.

    4. +
    +
  4. +
  5. 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()}}.

  6. +
+
+ +

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}}.

+

Extensions to the {{MouseEvent}} Interface

Issue: The object IDL fragment redefines some members. Can we resolve this somehow?