Commit ed8d921f authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

[LayoutNG] Correct column balancing with restricted size after spanner.

If the block-size of a multicol container is constrained, we need to pay
attention to space already used by preceding content.

Bug: 829028
Change-Id: Ie27bbf0b4a587716690a1bbd5a67cfa595ada7dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2410247Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807161}
parent 8bb1f09e
...@@ -973,16 +973,20 @@ LayoutUnit NGColumnLayoutAlgorithm::ConstrainColumnBlockSize( ...@@ -973,16 +973,20 @@ LayoutUnit NGColumnLayoutAlgorithm::ConstrainColumnBlockSize(
ConstraintSpace(), style, BorderPadding(), style.LogicalMaxHeight(), ConstraintSpace(), style, BorderPadding(), style.LogicalMaxHeight(),
LengthResolvePhase::kLayout); LengthResolvePhase::kLayout);
LayoutUnit extent = ResolveMainBlockLength( LayoutUnit extent = ResolveMainBlockLength(
ConstraintSpace(), style, BorderPadding(), style.LogicalHeight(), size, ConstraintSpace(), style, BorderPadding(), style.LogicalHeight(),
LengthResolvePhase::kLayout); kIndefiniteSize, LengthResolvePhase::kLayout);
if (extent != kIndefiniteSize) { if (extent != kIndefiniteSize) {
// A specified height/width will just constrain the maximum length. // A specified height/width will just constrain the maximum length.
max = std::min(max, extent); max = std::min(max, extent);
} }
// We may already have used some of the available space in earlier column rows
// or spanners.
max -= CurrentContentBlockOffset();
// Constrain and convert the value back to content-box. // Constrain and convert the value back to content-box.
size = std::min(size, max); size = std::min(size, max);
return size - extra; return (size - extra).ClampNegativeToZero();
} }
scoped_refptr<const NGLayoutResult> scoped_refptr<const NGLayoutResult>
......
<!DOCTYPE html>
<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org">
<link rel="help" href="https://www.w3.org/TR/css-multicol-1/#filling-columns">
<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; height:100px; background:red;">
<div style="columns:3; width:75px; height:100px; column-gap:0;">
<div style="column-span:all; width:100px; height:70px; background:green;"></div>
<div style="height:120px; background:green;"></div>
</div>
</div>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment