Change information
Commit message:
[M144] [line-clamp] Don't count phantom/empty lines when choosing to relayout
Original change's description:
> [line-clamp] Don't count phantom/empty lines when choosing to relayout
>
> The CSS-INLINE spec defines a concept called "phantom line boxes"
> (previously also known as "invisible line boxes"), which Chromium
> refers to as "empty lines" (e.g. `LineInfo::IsEmptyLine`). Such line
> boxes and their in-flow content must be treated as non-existing for
> any purpose other than determining the position of their OOF
> descendants, and for `line-clamp` they are indeed not counted when
> clamping by lines.
>
> Line-clamping should only have any effect when there is any content
> after the clamp point; and in https://crrev.com/c/7009807 we fixed a
> bug where lineless blocks and IFCs were ignored after the clamp point
> by having them decrease the number of lines until clamp if the current
> number is zero. However, this code only checked whether an in-flow
> fragment did not decrease the number of lines, and assumed that it
> must then be either a lineless block or an IFC.
>
> As it turns out, however, phantom/empty line boxes are also in-flow
> fragments that don't decrease the number of lines, but which are not
> lineless blocks or IFCs. This change then made the presence of a
> phantom/empty line box not be treated as non-existent if it is the
> only content between the clamp point and the end of the line-clamp
> container. To fix this, we added the condition that the fragment must
> not be a line box.
>
> Additionally, when writing tests, we also noticed that the DCHECK
> inside this condition, which makes sure that there has been a previous
> clamp point that we've previously chosen, would not hold if the
> current block box starts immediately after the clamp point, since the
> initial value of the number of lines until clamp would be zero. We
> fixed this by removing this assertion, which in this case is harmless.
>
> Bug: 467448802, 40336192
> Change-Id: I4ab2fba137d1a2f5ca8f13991bf377ca64ae6fe6
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7253151
> Commit-Queue: Ian Kilpatrick <ikilp...@chromium.org>
> Reviewed-by: Ian Kilpatrick <ikilp...@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1558875}
(cherry picked from commit 65558713a249870c9f381ecf39acada6fc037472)
Bug: 470087026,467448802,40336192
Change-Id: I4ab2fba137d1a2f5ca8f13991bf377ca64ae6fe6
Cr-Commit-Position: refs/branch-heads/7559@{#1948}
Cr-Branched-From: 223dfbac1c7542a06b422390d954afe5b560b607-refs/heads/main@{#1552494}
Files:
- M third_party/blink/renderer/core/layout/block_layout_algorithm.cc
- A third_party/blink/web_tests/external/wpt/css/css-overflow/line-clamp/line-clamp-037.html
- A third_party/blink/web_tests/external/wpt/css/css-overflow/line-clamp/line-clamp-038.html
Change size: M
Delta: 3 files changed, 55 insertions(+), 3 deletions(-)
Branch: refs/branch-heads/7559
Submit Requirements:
Code-Review: Bot-Commit+1 by Rubber Stamper