github web-platform-tests/wpt merge_pr_49030

latest releases: merge_pr_49470, epochs/three_hourly/2024-12-03_06H, epochs/six_hourly/2024-12-03_06H...
10 months ago

[line-clamp] [text-box-trim] Make block-in-inlines work

This patch makes block-in-inlines work together with
line-clamp: auto and text-box-trim. There are a few reasons why
they did not previously work:

  • The code in BlockLayoutAlgorithm::FinishInflow that handled the
    interaction of these features assumed that, with trim-end, every
    fragment with a break token would have a non-null TrimBlockEndBy
    set. This is not true for block-in-inline wrapper lines, so this was
    causing a crash.

    This code is used when figuring out how many lines fit in the given
    height, and it does so by always trimming by the end, and then,
    after we know this line fits, re-adding that trimmed block size.
    For block-in-inlines, if the inside trimmed, that trimmed block size
    would have already been added when laying out the inner block.
    Therefore, if there is no TrimBlockEndBy, we don't need to add
    any block size.

  • Another issue is that, when doing relayout for text-box-trim,
    which is now only needed with block-in-inlines, the number of lines
    until clamp was set to the number of lines until clamp that the
    previous block layout algorithm had when it aborted. This resulted
    in any lines that were laid out twice being counted twice. This
    number should instead be reset to its initial value at relayout
    time. Therefore we added an initial_lines_until_clamp field to
    BlockLineClampData to store this value.

  • Finally, although the block-in-inline tracked by
    BlockLayoutAlgorithm::last_non_empty_inflow_child_ might not be
    the one that contains the last line before clamp, this shouldn't
    matter after https://crrev.com/c/5987915. However, if a block ends
    with a block-in-inline which comes after the clamp point, it would
    cause an unnecessary relayout, because the trim-end has already been
    applied to the last line before clamp in the current layout.
    Therefore, we don't do this layout when we have clamped previously.

Bug: 40336192, 40254880, 372531320
Change-Id: Id228951b5db3c4bf799010e730983558567e9ddd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5987917
Commit-Queue: Andreu Botella abotella@igalia.com
Reviewed-by: Koji Ishii kojii@chromium.org
Cr-Commit-Position: refs/heads/main@{#1380464}

Don't miss a new wpt release

NewReleases is sending notifications on new releases.