Commit 6b18d3da authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

Don't let outer multicol height confuse orphans/widows on inner multicol.

In the initial layout pass of a multicol container with auto height,
there'll be no known breaks, but we will honor the contraints of any
outer fragmentation context, and insert pagination struts if necessary.
These pagination struts need to be ignored when we calculate the height
requirements imposed by orphans and widows requirements, or we risk
making the inner multicol too tall.

Bug: 891703
Change-Id: Ia9281508fcbba3572d653f1bbf863f045db71827
Reviewed-on: https://chromium-review.googlesource.com/c/1296492
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Commit-Queue: Emil A Eklund <eae@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601923}
parent 6cf533cf
<!DOCTYPE html>
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
<link rel="help" href="https://www.w3.org/TR/css-multicol-1/#filling-columns">
<link rel="help" href="https://www.w3.org/TR/css-break-3/#widows-orphans">
<meta name="assert" content="Make sure that orphans and widows handling inside an inner balanced multicol container doesn't get messed up by the constraining height of an outer multicol container">
<p>There should be three columns below. The text in each column should match the
column number that the text actually ends up in.</p>
<div style="columns:2; height:250px; line-height:50px; column-fill:auto;">
<div style="columns:3; column-rule:solid;" id="inner">
1<br>1<br>2<br>2<br>3<br>3<br>
</div>
</div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(()=> {
assert_equals(inner.offsetHeight, 100);
}, "Check that orphans and widows don't make a multicol container taller than necessary");
</script>
...@@ -237,10 +237,14 @@ static inline LayoutUnit ColumnLogicalHeightRequirementForLine( ...@@ -237,10 +237,14 @@ static inline LayoutUnit ColumnLogicalHeightRequirementForLine(
// satisfy orphans and widows, and that may affect the minimum page height. // satisfy orphans and widows, and that may affect the minimum page height.
unsigned minimum_line_count = unsigned minimum_line_count =
std::max<unsigned>(style.Orphans(), style.Widows()); std::max<unsigned>(style.Orphans(), style.Widows());
const RootInlineBox* first_line = &last_line; const RootInlineBox* line = &last_line;
for (unsigned i = 1; i < minimum_line_count && first_line->PrevRootBox(); i++) LayoutUnit logical_height_requirement;
first_line = first_line->PrevRootBox(); for (unsigned i = 0; i < minimum_line_count && line; i++) {
return last_line.LineBottomWithLeading() - first_line->LineTopWithLeading(); logical_height_requirement +=
line->LineBottomWithLeading() - line->LineTopWithLeading();
line = line->PrevRootBox();
}
return logical_height_requirement;
} }
void InitialColumnHeightFinder::ExamineLine(const RootInlineBox& line) { void InitialColumnHeightFinder::ExamineLine(const RootInlineBox& line) {
......
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