Modified: trunk/LayoutTests/ChangeLog (213732 => 213733)
--- trunk/LayoutTests/ChangeLog 2017-03-10 23:47:42 UTC (rev 213732)
+++ trunk/LayoutTests/ChangeLog 2017-03-11 00:33:18 UTC (rev 213733)
@@ -1,3 +1,13 @@
+2017-03-10 Zalan Bujtas <za...@apple.com>
+
+ Simple line layout: Check how many orphans needed on the current page before breaking.
+ https://bugs.webkit.org/show_bug.cgi?id=169477
+
+ Reviewed by Antti Koivisto.
+
+ * fast/multicol/simple-line-layout-orphans-and-widows-expected.html: Added.
+ * fast/multicol/simple-line-layout-orphans-and-widows.html: Added.
+
2017-03-10 Ryan Haddad <ryanhad...@apple.com>
Mark webrtc/libwebrtc/descriptionGetters.html as a flaky.
Added: trunk/LayoutTests/fast/multicol/simple-line-layout-orphans-and-widows-expected.html (0 => 213733)
--- trunk/LayoutTests/fast/multicol/simple-line-layout-orphans-and-widows-expected.html (rev 0)
+++ trunk/LayoutTests/fast/multicol/simple-line-layout-orphans-and-widows-expected.html 2017-03-11 00:33:18 UTC (rev 213733)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests orphans handling with simple line layout.</title>
+<script>
+ if (window.internals)
+ internals.setPagination("LeftToRightPaginated", 0);
+</script>
+<style>
+body {
+ width: 494px;
+}
+
+div {
+ font-size: 54px;
+ margin: 0px;
+}
+</style>
+</head>
+<body>
+<div>foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar</div>
+<div>foobar foobar foobar foobar foobar foobar foobar</div>
+</body>
+</html>
Added: trunk/LayoutTests/fast/multicol/simple-line-layout-orphans-and-widows.html (0 => 213733)
--- trunk/LayoutTests/fast/multicol/simple-line-layout-orphans-and-widows.html (rev 0)
+++ trunk/LayoutTests/fast/multicol/simple-line-layout-orphans-and-widows.html 2017-03-11 00:33:18 UTC (rev 213733)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests orphans handling with simple line layout.</title>
+<script>
+ if (window.internals)
+ internals.setPagination("LeftToRightPaginated", 0);
+</script>
+<style>
+body {
+ orphans: 2;
+ widows: 3;
+ width: 494px;
+}
+
+div {
+ font-size: 54px;
+ margin: 0px;
+}
+</style>
+</head>
+<body>
+<div>foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar</div>
+<div>foobar foobar foobar foobar foobar foobar foobar</div>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (213732 => 213733)
--- trunk/Source/WebCore/ChangeLog 2017-03-10 23:47:42 UTC (rev 213732)
+++ trunk/Source/WebCore/ChangeLog 2017-03-11 00:33:18 UTC (rev 213733)
@@ -1,3 +1,18 @@
+2017-03-10 Zalan Bujtas <za...@apple.com>
+
+ Simple line layout: Check how many orphans needed on the current page before breaking.
+ https://bugs.webkit.org/show_bug.cgi?id=169477
+
+ Reviewed by Antti Koivisto.
+
+ Before breaking for the widows we actually need to check for orphans first.
+
+ Test: fast/multicol/simple-line-layout-orphans-and-widows.html
+
+ * rendering/SimpleLineLayoutPagination.cpp:
+ (WebCore::SimpleLineLayout::computeLineBreakIndex):
+ (WebCore::SimpleLineLayout::adjustLinePositionsForPagination):
+
2017-03-10 Dean Jackson <d...@apple.com>
WebGPU: Backend - Textures and TextureDescriptors
Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutPagination.cpp (213732 => 213733)
--- trunk/Source/WebCore/rendering/SimpleLineLayoutPagination.cpp 2017-03-10 23:47:42 UTC (rev 213732)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutPagination.cpp 2017-03-11 00:33:18 UTC (rev 213733)
@@ -63,18 +63,20 @@
return { topPosition, bottomPosition, bottomPosition - topPosition };
}
-static unsigned computeLineBreakIndex(unsigned breakCandidate, unsigned lineCount, unsigned widows, const Layout::SimpleLineStruts& struts)
+static unsigned computeLineBreakIndex(unsigned breakCandidate, unsigned lineCount, int orphansNeeded, int widowsNeeded,
+ const Layout::SimpleLineStruts& struts)
{
// First line does not fit the current page.
if (!breakCandidate)
return breakCandidate;
- auto remainingLineCount = lineCount - breakCandidate;
- if (widows <= remainingLineCount)
+ int widowsOnTheNextPage = lineCount - breakCandidate;
+ if (widowsNeeded <= widowsOnTheNextPage)
return breakCandidate;
-
// Only break after the first line with widows.
- auto lineBreak = std::max<int>(lineCount - widows, 1);
+ auto lineBreak = std::max<int>(lineCount - widowsNeeded, 1);
+ if (orphansNeeded > lineBreak)
+ return breakCandidate;
// Break on current page only.
if (struts.isEmpty())
return lineBreak;
@@ -97,9 +99,9 @@
auto line = lines.at(lineBreakIndex);
auto remainingLogicalHeight = flow.pageRemainingLogicalHeightForOffset(line.top, RenderBlockFlow::ExcludePageBoundary);
auto& style = flow.style();
- auto firstLineWithDoesNotFit = !lineBreakIndex && line.height < flow.pageLogicalHeightForOffset(line.top);
+ auto firstLineDoesNotFit = !lineBreakIndex && line.height < flow.pageLogicalHeightForOffset(line.top);
auto orphanDoesNotFit = !style.hasAutoOrphans() && style.orphans() > (short)lineBreakIndex;
- if (firstLineWithDoesNotFit || orphanDoesNotFit) {
+ if (firstLineDoesNotFit || orphanDoesNotFit) {
auto firstLine = lines.first();
auto firstLineOverflowRect = computeOverflow(flow, LayoutRect(0, firstLine.top, 0, firstLine.height));
auto firstLineUpperOverhang = std::max<LayoutUnit>(-firstLineOverflowRect.y(), 0);
@@ -132,6 +134,7 @@
return;
unsigned lineIndex = 0;
auto widows = flow.style().hasAutoWidows() ? 1 : std::max<int>(flow.style().widows(), 1);
+ auto orphans = flow.style().hasAutoOrphans() ? 1 : std::max<int>(flow.style().orphans(), 1);
PaginatedLines lines;
for (unsigned runIndex = 0; runIndex < simpleLines.runCount(); ++runIndex) {
auto& run = simpleLines.runAt(runIndex);
@@ -143,11 +146,11 @@
auto remainingHeight = flow.pageRemainingLogicalHeightForOffset(line.top, RenderBlockFlow::ExcludePageBoundary);
auto atTheTopOfColumnOrPage = flow.pageLogicalHeightForOffset(line.top) == remainingHeight;
if (line.height > remainingHeight || (atTheTopOfColumnOrPage && lineIndex)) {
- auto lineBreakIndex = computeLineBreakIndex(lineIndex, lineCount, widows, struts);
+ auto lineBreakIndex = computeLineBreakIndex(lineIndex, lineCount, orphans, widows, struts);
// Are we still at the top of the column/page?
atTheTopOfColumnOrPage = atTheTopOfColumnOrPage ? lineIndex == lineBreakIndex : false;
setPageBreakForLine(lineBreakIndex, lines, flow, struts, atTheTopOfColumnOrPage);
- // Recompute line positions that we already visited but window break pushed them to a new page.
+ // Recompute line positions that we already visited but widow break pushed them to a new page.
for (auto i = lineBreakIndex; i < lines.size(); ++i)
lines.at(i) = computeLineTopAndBottomWithOverflow(flow, i, struts);
}