Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-overflow] Invisible line boxes and line-clamp #11021

Closed
andreubotella opened this issue Oct 11, 2024 · 3 comments
Closed

[css-overflow] Invisible line boxes and line-clamp #11021

andreubotella opened this issue Oct 11, 2024 · 3 comments
Labels
Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. css-overflow-4

Comments

@andreubotella
Copy link
Member

andreubotella commented Oct 11, 2024

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. But currently every browser ignores invisible line boxes for (-webkit-)line-clamp, clamping at "Line 4" in this example:

<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 #10816 (comment)). This should be changed to only allow clamping immediately after a visible line box.

cc @frivoal @emilio

@frivoal
Copy link
Collaborator

frivoal commented Nov 4, 2024

I'd say there's two parts:

  • I agree that invisible line boxes should not be counted when you're counting lines to find what the clamp point is.
  • if, when clamping by height, you end up with invisible line boxes after the last visible one, what happens to them is part of issue [css-overflow] What counts as "immediately preceding" for block-ellipsis? #10868, so we don't have to handle it separately here (but yes, if we go with the logic discussed at TPAC of only clamping directly after lines even when going by height, then it needs to be visible lines)

@frivoal frivoal added the Agenda+ label Nov 4, 2024
@frivoal
Copy link
Collaborator

frivoal commented Nov 4, 2024

Well, maybe a third part:

@fantasai
Copy link
Collaborator

fantasai commented Nov 12, 2024

The spec for invisible line boxes says:

Such boxes must be treated as zero-height line boxes for the purposes of determining the positions of any descendant content (such as absolutely positioned boxes), and both the line box and its in-flow content must be treated as not existing for any other layout or rendering purpose.

We don't want to mention invisible line boxes everywhere we mention line boxes. That would make our specs unnecessarily hard to read. These are effectively display: none except as mentioned in this specific paragraph: they do not exist for any other purpose. You cannot count them. You cannot measure them. You cannot introspect their content. You cannot insert ellipses into them. They just don't exist.

@fantasai fantasai added Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. and removed Agenda+ labels Nov 12, 2024
fantasai added a commit that referenced this issue Nov 12, 2024
This lines up closer to CSS2 terminology.

Related to #11021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. css-overflow-4
Projects
None yet
Development

No branches or pull requests

3 participants