[csswg-drafts] [cssom-view][css-break] Expose information for all line boxes (#9433)

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

== [cssom-view][css-break] Expose information for all line boxes ==
With `getClientRects()`, authors have a way to get a `DOMRectList` containing a `DOMRect` object for each box fragment.

Though this information is still pretty limited. E.g. getting the number of lines within an element is not possible. See the [workarounds suggested on Stack Overflow](https://stackoverflow.com/q/783899/432681). The Firefox DevTools would [benefit from that regarding their inactive CSS feature for `text-wrap: balance`](https://bugzilla.mozilla.org/show_bug.cgi?id=1851756#c2). Also, additional positional and dimensional information is needed for cases like layouting and highlighting.

Therefore, there should be a way to get that information for all line boxes.

## High level examples

For an inline-level element that is split across two lines, the API should return two entries.
For an element with ten lines of text and inline-level elements, the API should return ten entries.
For an element with two columns with three lines each, the API should return six entries.

## Suggestions

### 1. Extend `getClientRects()`

`getClientRects()` could take an options parameter that controls what to return. That parameter would then have a `type` option that defines the type of rects to return, with box fragments being the default and allowing to define line boxes as alternative.

Advantages:

* Reusing a known API for similar use cases
* Aligning with other APIs that take an options parameter
* Ability to extend the API further in the future (e.g. by adding an option to control what type of rect to return)

### 2. Introduce a new API exposing `DOMRect`s for each line box

That new API would work similar to `getClientRects()` but on line boxes.

Advantages:

* Focus on one use case
* Exposes detailed information about the line box dimensions and position
* Can be extended separately from `getClientRects()`

### 3. Introduce a new API exposing line counts for box fragments

A new API that exposes the line counts of different box fragments. (Multi-column containers, page breaks and similar fragmentainers provide multiple box fragments.)

Advantages:

* Focus on one use case
* Return value focuses on line numbers
* Orthogonal to the other two solutions

Sebastian

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


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 3 October 2023 22:25:19 UTC