[line-clamp] Support truncating line-clamp: auto
inside a nested block
Our previous patch, https://crrev.com/c/5490736, implemented
line-clamp: auto
, which clamps a line-clamp container based on its
height constraints. However, that patch only worked when the clamp
point is directly inside the line-clamp container (or its
InlineNode
), rather than inside a nested block.
Clamping by height inside nested blocks adds some challenges, which we
resolve in this CL:
-
The bottom padding, border and margin need to be taken into
account, since they mean the BFC offset at which the content of a
block container clamps might be different from the parent's BFC
offset. We fixed this by updating the clamp BFC offset for every
block descendant according to their bottom padding and border. We
leave margins for a follow-up CL. -
previous_inflow_position->logical_block_offset
was previously
used as both the intrinsic size so far of the current block
container after a child layout, and the BFC offset after the
laid out child. These are only the same if the block box
establishes a new BFC (i.e. is the line-clamp container). This CL
passesBlockLineClampData::UpdateAfterLayout
the block box's
BFC offset, which solves this issue. -
Since every block box which contains the clamp point needs to have
its intrinsic size set depending on the clamp point, it is
possible for a block box to change its intrinsic size such that,
as far as the parent is concerned, the BFC offset has not yet been
reached. To avoid this, we add aHasContentAfterLineClamp
method
toLayoutResult
, and pass the child'sLayoutResult*
to
BlockLineClampData::UpdateAfterLayout
.
Bug: 40336192
Change-Id: Ied3cb5f60460d4746a4ce13b4684d623adf0ddcd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5547983
Commit-Queue: Andreu Botella abotella@igalia.com
Reviewed-by: Ian Kilpatrick ikilpatrick@chromium.org
Cr-Commit-Position: refs/heads/main@{#1325358}