[cssom-view] Range.getClientRects is inconsistent
Nobody has claimed this yet.
- Dominant language
- Bikeshed
- Stars
- 4.9k
- Forks
- 816
- PR merge metrics
- PR metrics pending
Description
Originally reported as an issue with vendors (Chromium bug, Bugzilla):
Steps to reproduce:
- Visit https://edg2s.github.io/rangefix/
- Click the "Firefox triple click bug" button or triple click the paragraph which contains the inline image.
Actual results:
The rectangle for the tag does not include the full height of the image tag.
Expected results:
The computed rectangles are correct.
a Mozilla contributor suggested this is in fact an issue with the spec
Ah, this is about
Range.getClientRects, not aboutElement.getClientRects, sorry...So spec is in https://drafts.csswg.org/cssom-view-1/#dom-range-getclientrects:
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.
So it seems to me that if
<u>is selected by the range completely, then we'd return an smaller rect than if it wasn't per the above definition (because when<u>is not fully selected, then we union thegetClientRects()of the text and the image, instead of just returning the rects of the<u>). That seems unfortunate, though it's what the spec seems to call for.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the CSSOM View specification's Range.getClientRects section and reproduce the behavior at the linked rangefix demo. Compare the result for a fully selected element with the algorithm's treatment of text and the inline image; done means the specification clearly resolves which rectangles should be returned.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100