w3c / w3c/csswg-drafts

[cssom-view] Range.getClientRects is inconsistent

Open
#12,331 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cssom-view-1
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:

  1. Visit https://edg2s.github.io/rangefix/
  2. 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 about Element.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 the getClientRects() 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.