[line-clamp] Support truncating line-clamp: auto
inside a nested block
#46372
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Our previous patch, https://crrev.com/c/5490736, implemented
line-clamp: auto
, which clamps a line-clamp container based on itsheight 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 previouslyused 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
passes
BlockLineClampData::UpdateAfterLayout
the block box'sBFC 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 a
HasContentAfterLineClamp
methodto
LayoutResult
, and pass the child'sLayoutResult*
toBlockLineClampData::UpdateAfterLayout
.Bug: 40336192
Change-Id: Ied3cb5f60460d4746a4ce13b4684d623adf0ddcd
Reviewed-on: https://chromium-review.googlesource.com/5547983
WPT-Export-Revision: 145c33f3d5123cf43d994043cba1ad619b74b4a2