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

When told to break to honor widows, just do so.

We have some special-code for tall unbreakable lines; if a line in
itself is taller than the fragmentainer, don't break before it like we
normally do when out of space. This piece of code was here for
compatibility reasons (or maybe just to work around another bug), but we
need to avoid this special behavior if the line is the one to break
before in order to honor a widows requirement. Otherwise we'd get
nowhere, stuck in a loop enternally re-laying out, attempting to break
before this line but refusing to do so.

Bug: 1022348
Change-Id: I2b9f702194dc0b7e6cbf8f37dffa95ea5722d045
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1911205Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714535}
parent ffa8f10a
......@@ -1235,7 +1235,14 @@ void LayoutBlockFlow::AdjustLinePositionForPagination(RootInlineBox& line_box,
// Moving to a different page or column may mean that its height is
// different.
page_logical_height = PageLogicalHeightForOffset(new_logical_offset);
if (line_height > page_logical_height) {
// We need to insert a break now, either because there's no room for the
// line in the current column / page, or because we have determined that we
// need a break to satisfy widow requirements.
if (ShouldBreakAtLineToAvoidWidow() &&
LineBreakToAvoidWidow() == line_index) {
ClearShouldBreakAtLineToAvoidWidow();
SetDidBreakAtLineToAvoidWidow();
} else if (line_height > page_logical_height) {
// Too tall to fit in one page / column. Give up. Don't push to the next
// page / column.
// TODO(mstensho): Get rid of this. This is just utter weirdness, but the
......@@ -1246,14 +1253,6 @@ void LayoutBlockFlow::AdjustLinePositionForPagination(RootInlineBox& line_box,
return;
}
// We need to insert a break now, either because there's no room for the
// line in the current column / page, or because we have determined that we
// need a break to satisfy widow requirements.
if (ShouldBreakAtLineToAvoidWidow() &&
LineBreakToAvoidWidow() == line_index) {
ClearShouldBreakAtLineToAvoidWidow();
SetDidBreakAtLineToAvoidWidow();
}
if (ShouldSetStrutOnBlock(*this, line_box, logical_offset, line_index,
page_logical_height)) {
// Note that when setting the strut on a block, it may be propagated to
......
<!DOCTYPE html>
<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org">
<link rel="help" href="https://drafts.csswg.org/css-break/#widows-orphans">
<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1022348">
<meta name="assert" content="Here's a multicol container with four lines, and a widows requirement of 2. We cannot honor that requirement, because the third line alone is too tall to fit in a column.">
<style>
.multicol {
position: relative;
columns: 3;
column-fill: auto;
column-gap: 10px;
width: 320px;
height: 200px;
orphans: 1;
widows: 2;
column-rule: 1px dotted;
line-height: 20px;
}
.ibk {
display: inline-block;
width: 70px;
}
</style>
<p>
There should be three columns below. In the first column there should be a
black rectangle and a yellow rectangle. In the second column there should be a
cyan rectangle. In the third column there should be a hotpink rectangle.</p>
<div class="multicol">
<div class="ibk" style="height:50px; background:black;" data-offset-x="0"></div><br>
<div class="ibk" style="height:50px; background:yellow;" data-offset-x="0"></div><br>
<div class="ibk" style="height:285px;" data-offset-x="110">
<!-- The implementations differ here. Gecko lets the inline-block overflow
the column, while Blink slices the inline-block and puts what doesn't
fit in the second column into the third. Blink has a bug, but that's
not the bug we want to test here. -->
<div style="height:100px; background:cyan;"></div>
</div><br>
<div class="ibk" style="height:10px; background:hotpink;" data-offset-x="220"></div><br>
</div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script>
checkLayout("[data-offset-x]");
</script>
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