Changeset 213733 in webkit
- Timestamp:
- Mar 10, 2017 4:33:18 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r213729 r213733 1 2017-03-10 Zalan Bujtas <zalan@apple.com> 2 3 Simple line layout: Check how many orphans needed on the current page before breaking. 4 https://bugs.webkit.org/show_bug.cgi?id=169477 5 6 Reviewed by Antti Koivisto. 7 8 * fast/multicol/simple-line-layout-orphans-and-widows-expected.html: Added. 9 * fast/multicol/simple-line-layout-orphans-and-widows.html: Added. 10 1 11 2017-03-10 Ryan Haddad <ryanhaddad@apple.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r213731 r213733 1 2017-03-10 Zalan Bujtas <zalan@apple.com> 2 3 Simple line layout: Check how many orphans needed on the current page before breaking. 4 https://bugs.webkit.org/show_bug.cgi?id=169477 5 6 Reviewed by Antti Koivisto. 7 8 Before breaking for the widows we actually need to check for orphans first. 9 10 Test: fast/multicol/simple-line-layout-orphans-and-widows.html 11 12 * rendering/SimpleLineLayoutPagination.cpp: 13 (WebCore::SimpleLineLayout::computeLineBreakIndex): 14 (WebCore::SimpleLineLayout::adjustLinePositionsForPagination): 15 1 16 2017-03-10 Dean Jackson <dino@apple.com> 2 17 -
trunk/Source/WebCore/rendering/SimpleLineLayoutPagination.cpp
r213723 r213733 64 64 } 65 65 66 static unsigned computeLineBreakIndex(unsigned breakCandidate, unsigned lineCount, unsigned widows, const Layout::SimpleLineStruts& struts) 66 static unsigned computeLineBreakIndex(unsigned breakCandidate, unsigned lineCount, int orphansNeeded, int widowsNeeded, 67 const Layout::SimpleLineStruts& struts) 67 68 { 68 69 // First line does not fit the current page. … … 70 71 return breakCandidate; 71 72 72 auto remainingLineCount= lineCount - breakCandidate;73 if (widows <= remainingLineCount)73 int widowsOnTheNextPage = lineCount - breakCandidate; 74 if (widowsNeeded <= widowsOnTheNextPage) 74 75 return breakCandidate; 75 76 76 // Only break after the first line with widows. 77 auto lineBreak = std::max<int>(lineCount - widows, 1); 77 auto lineBreak = std::max<int>(lineCount - widowsNeeded, 1); 78 if (orphansNeeded > lineBreak) 79 return breakCandidate; 78 80 // Break on current page only. 79 81 if (struts.isEmpty()) … … 98 100 auto remainingLogicalHeight = flow.pageRemainingLogicalHeightForOffset(line.top, RenderBlockFlow::ExcludePageBoundary); 99 101 auto& style = flow.style(); 100 auto firstLine WithDoesNotFit = !lineBreakIndex && line.height < flow.pageLogicalHeightForOffset(line.top);102 auto firstLineDoesNotFit = !lineBreakIndex && line.height < flow.pageLogicalHeightForOffset(line.top); 101 103 auto orphanDoesNotFit = !style.hasAutoOrphans() && style.orphans() > (short)lineBreakIndex; 102 if (firstLine WithDoesNotFit || orphanDoesNotFit) {104 if (firstLineDoesNotFit || orphanDoesNotFit) { 103 105 auto firstLine = lines.first(); 104 106 auto firstLineOverflowRect = computeOverflow(flow, LayoutRect(0, firstLine.top, 0, firstLine.height)); … … 133 135 unsigned lineIndex = 0; 134 136 auto widows = flow.style().hasAutoWidows() ? 1 : std::max<int>(flow.style().widows(), 1); 137 auto orphans = flow.style().hasAutoOrphans() ? 1 : std::max<int>(flow.style().orphans(), 1); 135 138 PaginatedLines lines; 136 139 for (unsigned runIndex = 0; runIndex < simpleLines.runCount(); ++runIndex) { … … 144 147 auto atTheTopOfColumnOrPage = flow.pageLogicalHeightForOffset(line.top) == remainingHeight; 145 148 if (line.height > remainingHeight || (atTheTopOfColumnOrPage && lineIndex)) { 146 auto lineBreakIndex = computeLineBreakIndex(lineIndex, lineCount, widows, struts);149 auto lineBreakIndex = computeLineBreakIndex(lineIndex, lineCount, orphans, widows, struts); 147 150 // Are we still at the top of the column/page? 148 151 atTheTopOfColumnOrPage = atTheTopOfColumnOrPage ? lineIndex == lineBreakIndex : false; 149 152 setPageBreakForLine(lineBreakIndex, lines, flow, struts, atTheTopOfColumnOrPage); 150 // Recompute line positions that we already visited but wi ndow break pushed them to a new page.153 // Recompute line positions that we already visited but widow break pushed them to a new page. 151 154 for (auto i = lineBreakIndex; i < lines.size(); ++i) 152 155 lines.at(i) = computeLineTopAndBottomWithOverflow(flow, i, struts);
Note: See TracChangeset
for help on using the changeset viewer.