Bug 1861379 [wpt PR 42778] - Avoid duplicate block-in-inline break tokens., a=testonly

Automatic update from web-platform-tests
Avoid duplicate block-in-inline break tokens. (#42778)

Regardless of whether the break inside a block-in-inline was to be
resumed in a parallel flow or not, we'd also include it as a break token
in the same flow.

This was usually harmless, since any next line in the same fragmentainer
would typically not be a block-in-inline, since all consecutive blocks
inside inlines are put inside the same block-in-inline wrapper during
box generation.

However, there are ways to end up with adjacent block-in-inline
wrappers: If a block that previously wasn't inflow becomes inflow
(change from float:left to float:none, for instance), a new wrapper is
created around the now-inflow block, even if there's already an adjacent
wrapper there for an adjacent block.

  <span>
    <div id="first" style="float:left;"></div>
    <div id="second"></div>
  </span>

This generates a box tree like this:

  LayoutInline           SPAN
    LayoutNGBlockFlow    (floating) DIV #first
    LayoutNGBlockFlow    (anonymous)
      LayoutNGBlockFlow  DIV #second

If we (after initial layout) change #first to float:none, we end up with
this:

  LayoutInline           SPAN
    LayoutNGBlockFlow    (anonymous)
      LayoutNGBlockFlow  DIV #first
    LayoutNGBlockFlow    (anonymous)
      LayoutNGBlockFlow  DIV #second

The fix is to make sure that we only create one break token for a
fragmented block wrapper. Move the code that examines the outgoing
block-in-inline break token a bit further up, to eliminate the need for
LineInfo::BlockInInlineBreakToken(), and to keep things a bit more
tightly together. Add a DCHECK to LineBreaker::HandleBlockInInline(),
which would have failed without this fix.

Bug: 1495515
Change-Id: I6d019b8c2e6c03046e122fecce76e044f3aeabb3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4973967
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Reviewed-by: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1216882}

Co-authored-by: Morten Stenshorne <mstensho@chromium.org>
--

wpt-commits: f78621256f99c77ef9dbced0301c1ff25f71abf5
wpt-pr: 42778
This commit is contained in:
Blink WPT Bot 2023-11-08 08:29:09 +00:00 committed by moz-wptsync-bot
parent cf9f1f50fe
commit a62b418143
2 changed files with 40 additions and 0 deletions

View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org">
<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1495515">
<div style="columns:10; column-fill:auto; height:100px;">
<div style="height:50px;"></div>
<span>
<div id="e58" style="float:left; width:70%;">
<div style="float:left; width:100%; height:60px; contain:size;"></div>
</div>
<div style="height:10px;"></div>
</span>
</div>
<script>
document.body.offsetTop;
e58.style.cssFloat = "none";
</script>

View file

@ -0,0 +1,24 @@
<!DOCTYPE html>
<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org">
<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1495515">
<link rel="match" href="../reference/ref-filled-green-100px-square.xht">
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div style="width:100px; columns:4; column-fill:auto; gap:0; height:70px; background:red;">
<span>
<div style="height:50px; background:green;"></div>
<div id="e58" style="float:left;">
<div style="float:left; width:100%;">
<div style="height:100px; contain:size; background:green;"></div>
<div style="height:100px; contain:size; background:green;"></div>
<div style="height:100px; contain:size; background:green;"></div>
</div>
</div>
<div style="height:20px; contain:size;">
<div style="height:50px; background:green;"></div>
</div>
</span>
</div>
<script>
document.body.offsetTop;
e58.style.cssFloat = "none";
</script>