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

[line-clamp] Support truncating line-clamp: auto inside a nested block #46372

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chromium-wpt-export-bot
Copy link
Collaborator

@chromium-wpt-export-bot chromium-wpt-export-bot commented May 20, 2024

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
    passes BlockLineClampData::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 a HasContentAfterLineClamp method
    to LayoutResult, and pass the child's LayoutResult* to
    BlockLineClampData::UpdateAfterLayout.

Bug: 40336192
Change-Id: Ied3cb5f60460d4746a4ce13b4684d623adf0ddcd
Reviewed-on: https://chromium-review.googlesource.com/5547983
WPT-Export-Revision: 145c33f3d5123cf43d994043cba1ad619b74b4a2

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
    passes `BlockLineClampData::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 a `HasContentAfterLineClamp` method
    to `LayoutResult`, and pass the child's `LayoutResult*` to
    `BlockLineClampData::UpdateAfterLayout`.

Bug: 40336192
Change-Id: Ied3cb5f60460d4746a4ce13b4684d623adf0ddcd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants