[csswg-drafts] [cssom-view] Change or clarify Range getClientRects() behavior when collapsed in an empty element.

shiivan has just created a new issue for https://github.com/w3c/csswg-drafts:

== [cssom-view] Change or clarify Range getClientRects() behavior when collapsed in an empty element. ==
https://drafts.csswg.org/cssom-view/#dom-range-getclientrects

https://drafts.csswg.org/cssom-view/#extensions-to-the-range-interface

The current spec possibly contradicts itself or is unnecessarily confusing. For example: what is the expected behavior of the `getClientRects` method if the current range is collapsed and in an empty element (e.g. no Text nodes).

Chrome currently returns and empty DOMRectList which satisfies the requirements of the two bullet points:
`
- For each element selected by the range, whose parent is not selected by the range, include the border areas returned by invoking getClientRects() on the element.

- For each Text node selected or partially selected by the range (including when the boundary-points are identical), include a DOMRect object (for the part that is selected, not the whole line box). The bounds of these DOMRect objects are computed using font metrics; thus, for horizontal writing, the vertical dimension of each box is determined by the font ascent and descent, and the horizontal dimension by the text advance width. If the range covers a partial typographic character unit (e.g. half a surrogate pair or part of a grapheme cluster), the full typographic character unit must be included for the purpose of computing the bounds of the relevant DOMRect. [CSS-TEXT-3] The transforms that apply to the ancestors are applied.
`

but doesn't satisfy the statement in the preceding paragraph where it says that only a range not in the document should return an empty DOMRectList. 

Here's a fiddle to demonstrate the odd behavior:
https://jsfiddle.net/hozkkjqq/28/
and the bug I filed on Chromium.
https://bugs.chromium.org/p/chromium/issues/detail?id=830044

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2514 using your GitHub account

Received on Friday, 6 April 2018 22:21:04 UTC