[csswg-drafts] [css-overflow] Invisible line boxes and `line-clamp` (#11021)

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

== [css-overflow] Invisible line boxes and `line-clamp` ==
While talking with @kojiishi earlier today, we noticed that the spec text for `block-ellipsis` and `max-lines` (which are shorthands of `line-clamp`) talks about line boxes in general, without explicitly excluding [invisible line boxes](https://drafts.csswg.org/css-inline-3/#invisible-line-boxes). But currently every browser ignores invisible line boxes for `(-webkit-)line-clamp`, clamping at "Line 4" in this example:

```html
<style>
  .clamp {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
  }
</style>
<div class="clamp">
  <div>
    Line 1 <br>
    Line 2 <br>
    Line 3
  </div>
  <div><span></span></div> <!-- Invisible line box! -->
  <div>
    Line 4 <br>
    Line 5
  </div>
</div>
```

Aside from this, there's the question of how to take into account invisible line boxes when clamping based on a height. With `continue: discard` it is possible for an invisible line box to be "immediately preceding a region break" (see also #10868), which per the spec means it should be ellipsized. However, it would be very unexpected to have an ellipsis placed there. With `continue: discard`, I think the previous line box, if there is one, should have the ellipsis.

For `continue: collapse`, in TPAC we agreed that this variant of `line-clamp` would only allow clamping immediately after a line box, whereas `continue: discard` could clamp between lineless blocks (see https://github.com/w3c/csswg-drafts/pull/10816#issuecomment-2392514493). This should be changed to only allow clamping immediately after a visible line box.

cc @frivoal @emilio 

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


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

Received on Friday, 11 October 2024 09:01:19 UTC