<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[213639] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/213639">213639</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2017-03-09 07:25:12 -0800 (Thu, 09 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Simple line layout: Add top level pagination support.
https://bugs.webkit.org/show_bug.cgi?id=169410
&lt;rdar://problem/28536227&gt;

Reviewed by Antti Koivisto.

Source/WebCore:

This patch enables top level pagination for simple line layout.

Covered by existing tests.

* rendering/RenderMultiColumnFlowThread.h:
* rendering/RenderView.cpp:
(WebCore::RenderView::pushLayoutStateForPagination): Pagination flag needs to be set before calling pushLayoutStateForCurrentFlowThread.
* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::canUseForWithReason):
* rendering/SimpleLineLayoutCoverage.cpp:
(WebCore::SimpleLineLayout::printReason):
* rendering/SimpleLineLayoutCoverage.h:
* rendering/SimpleLineLayoutFunctions.cpp:
(WebCore::SimpleLineLayout::paintFlow):
* rendering/SimpleLineLayoutPagination.cpp:
(WebCore::SimpleLineLayout::computeLineTopAndBottomWithOverflow): Matching normal line layout values.
(WebCore::SimpleLineLayout::setPageBreakForLine): Logic here matches RenderBlockFlow::adjustLinePositionForPagination

LayoutTests:

* TestExpectations:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsTestExpectations">trunk/LayoutTests/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderMultiColumnFlowThreadh">trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderViewcpp">trunk/Source/WebCore/rendering/RenderView.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayoutcpp">trunk/Source/WebCore/rendering/SimpleLineLayout.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayoutCoveragecpp">trunk/Source/WebCore/rendering/SimpleLineLayoutCoverage.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayoutCoverageh">trunk/Source/WebCore/rendering/SimpleLineLayoutCoverage.h</a></li>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayoutPaginationcpp">trunk/Source/WebCore/rendering/SimpleLineLayoutPagination.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (213638 => 213639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-03-09 14:24:04 UTC (rev 213638)
+++ trunk/LayoutTests/ChangeLog        2017-03-09 15:25:12 UTC (rev 213639)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2017-03-09  Zalan Bujtas  &lt;zalan@apple.com&gt;
+
+        Simple line layout: Add top level pagination support.
+        https://bugs.webkit.org/show_bug.cgi?id=169410
+        &lt;rdar://problem/28536227&gt;
+
+        Reviewed by Antti Koivisto.
+
+        * TestExpectations:
+
</ins><span class="cx"> 2017-03-08  Per Arne Vollan  &lt;pvollan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Implement stroke-width CSS property.
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (213638 => 213639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations        2017-03-09 14:24:04 UTC (rev 213638)
+++ trunk/LayoutTests/TestExpectations        2017-03-09 15:25:12 UTC (rev 213639)
</span><span class="lines">@@ -1209,6 +1209,9 @@
</span><span class="cx"> # Test disabled until we can fix layout of orthogonal writing mode roots
</span><span class="cx"> fast/table/colspanMinWidth-vertical.html [ Skip ]
</span><span class="cx"> 
</span><ins>+# Orphan lines with visual overflow vs. simple line layout.
+webkit.org/b/169409 fast/multicol/orphans-negative-line-spacing.html [ ImageOnlyFailure ]
+
</ins><span class="cx"> ### END OF -disabled tests
</span><span class="cx"> ########################################
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (213638 => 213639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-03-09 14:24:04 UTC (rev 213638)
+++ trunk/Source/WebCore/ChangeLog        2017-03-09 15:25:12 UTC (rev 213639)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2017-03-09  Zalan Bujtas  &lt;zalan@apple.com&gt;
+
+        Simple line layout: Add top level pagination support.
+        https://bugs.webkit.org/show_bug.cgi?id=169410
+        &lt;rdar://problem/28536227&gt;
+
+        Reviewed by Antti Koivisto.
+
+        This patch enables top level pagination for simple line layout.
+
+        Covered by existing tests.
+
+        * rendering/RenderMultiColumnFlowThread.h:
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::pushLayoutStateForPagination): Pagination flag needs to be set before calling pushLayoutStateForCurrentFlowThread.
+        * rendering/SimpleLineLayout.cpp:
+        (WebCore::SimpleLineLayout::canUseForWithReason):
+        * rendering/SimpleLineLayoutCoverage.cpp:
+        (WebCore::SimpleLineLayout::printReason):
+        * rendering/SimpleLineLayoutCoverage.h:
+        * rendering/SimpleLineLayoutFunctions.cpp:
+        (WebCore::SimpleLineLayout::paintFlow):
+        * rendering/SimpleLineLayoutPagination.cpp:
+        (WebCore::SimpleLineLayout::computeLineTopAndBottomWithOverflow): Matching normal line layout values.
+        (WebCore::SimpleLineLayout::setPageBreakForLine): Logic here matches RenderBlockFlow::adjustLinePositionForPagination
+
</ins><span class="cx"> 2017-03-09  Tomas Popela  &lt;tpopela@redhat.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GStreamer][MSE] Fix 'comparison between signed and unsigned integer
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderMultiColumnFlowThreadh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.h (213638 => 213639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.h        2017-03-09 14:24:04 UTC (rev 213638)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.h        2017-03-09 15:25:12 UTC (rev 213639)
</span><span class="lines">@@ -43,6 +43,7 @@
</span><span class="cx">     RenderMultiColumnSet* firstMultiColumnSet() const;
</span><span class="cx">     RenderMultiColumnSet* lastMultiColumnSet() const;
</span><span class="cx">     RenderBox* firstColumnSetOrSpanner() const;
</span><ins>+    bool hasColumnSpanner() const { return !m_spannerMap.isEmpty(); }
</ins><span class="cx">     static RenderBox* nextColumnSetOrSpannerSiblingOf(const RenderBox*);
</span><span class="cx">     static RenderBox* previousColumnSetOrSpannerSiblingOf(const RenderBox*);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderView.cpp (213638 => 213639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderView.cpp        2017-03-09 14:24:04 UTC (rev 213638)
+++ trunk/Source/WebCore/rendering/RenderView.cpp        2017-03-09 15:25:12 UTC (rev 213639)
</span><span class="lines">@@ -1237,11 +1237,12 @@
</span><span class="cx"> 
</span><span class="cx"> void RenderView::pushLayoutStateForPagination(RenderBlockFlow&amp; layoutRoot)
</span><span class="cx"> {
</span><del>-    pushLayoutState(layoutRoot);
-    ASSERT(m_layoutState);
</del><ins>+    ASSERT(!m_layoutState);
+    m_layoutState = std::make_unique&lt;LayoutState&gt;(layoutRoot);
</ins><span class="cx">     m_layoutState-&gt;m_isPaginated = true;
</span><span class="cx">     // This is just a flag for known page height (see RenderBlockFlow::checkForPaginationLogicalHeightChange).
</span><span class="cx">     m_layoutState-&gt;m_pageLogicalHeight = 1;
</span><ins>+    pushLayoutStateForCurrentFlowThread(layoutRoot);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> IntSize RenderView::viewportSizeForCSSViewportUnits() const
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.cpp (213638 => 213639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayout.cpp        2017-03-09 14:24:04 UTC (rev 213638)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.cpp        2017-03-09 15:25:12 UTC (rev 213639)
</span><span class="lines">@@ -40,10 +40,13 @@
</span><span class="cx"> #include &quot;PaintInfo.h&quot;
</span><span class="cx"> #include &quot;RenderBlockFlow.h&quot;
</span><span class="cx"> #include &quot;RenderChildIterator.h&quot;
</span><ins>+#include &quot;RenderFlowThread.h&quot;
</ins><span class="cx"> #include &quot;RenderLineBreak.h&quot;
</span><ins>+#include &quot;RenderMultiColumnFlowThread.h&quot;
</ins><span class="cx"> #include &quot;RenderStyle.h&quot;
</span><span class="cx"> #include &quot;RenderText.h&quot;
</span><span class="cx"> #include &quot;RenderTextControl.h&quot;
</span><ins>+#include &quot;RenderView.h&quot;
</ins><span class="cx"> #include &quot;Settings.h&quot;
</span><span class="cx"> #include &quot;SimpleLineLayoutFlowContents.h&quot;
</span><span class="cx"> #include &quot;SimpleLineLayoutFunctions.h&quot;
</span><span class="lines">@@ -246,8 +249,21 @@
</span><span class="cx">         SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNoParent, reasons, includeReasons);
</span><span class="cx">     if (!flow.firstChild())
</span><span class="cx">         SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNoChild, reasons, includeReasons);
</span><del>-    if (flow.flowThreadState() != RenderObject::NotInsideFlowThread)
-        SET_REASON_AND_RETURN_IF_NEEDED(FlowIsInsideRegion, reasons, includeReasons);
</del><ins>+    if (flow.flowThreadState() != RenderObject::NotInsideFlowThread) {
+        auto* flowThread = flow.flowThreadContainingBlock();
+        if (!is&lt;RenderMultiColumnFlowThread&gt;(flowThread))
+            SET_REASON_AND_RETURN_IF_NEEDED(FlowIsInsideANonMultiColumnThread, reasons, includeReasons);
+        auto&amp; columnThread = downcast&lt;RenderMultiColumnFlowThread&gt;(*flowThread);
+        if (columnThread.parent() != &amp;flow.view())
+            SET_REASON_AND_RETURN_IF_NEEDED(MultiColumnFlowIsNotTopLevel, reasons, includeReasons);
+        if (columnThread.hasColumnSpanner())
+            SET_REASON_AND_RETURN_IF_NEEDED(MultiColumnFlowHasColumnSpanner, reasons, includeReasons);
+        auto&amp; style = flow.style();
+        if (style.verticalAlign() != BASELINE)
+            SET_REASON_AND_RETURN_IF_NEEDED(MultiColumnFlowVerticalAlign, reasons, includeReasons);
+        if (style.isFloating())
+            SET_REASON_AND_RETURN_IF_NEEDED(MultiColumnFlowIsFloating, reasons, includeReasons);
+    }
</ins><span class="cx">     if (!flow.isHorizontalWritingMode())
</span><span class="cx">         SET_REASON_AND_RETURN_IF_NEEDED(FlowHasHorizonalWritingMode, reasons, includeReasons);
</span><span class="cx">     if (flow.hasOutline())
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutCoveragecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutCoverage.cpp (213638 => 213639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutCoverage.cpp        2017-03-09 14:24:04 UTC (rev 213638)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutCoverage.cpp        2017-03-09 15:25:12 UTC (rev 213639)
</span><span class="lines">@@ -42,8 +42,8 @@
</span><span class="cx"> static void printReason(AvoidanceReason reason, TextStream&amp; stream)
</span><span class="cx"> {
</span><span class="cx">     switch (reason) {
</span><del>-    case FlowIsInsideRegion:
-        stream &lt;&lt; &quot;flow is inside region&quot;;
</del><ins>+    case FlowIsInsideANonMultiColumnThread:
+        stream &lt;&lt; &quot;flow is inside a non-multicolumn container&quot;;
</ins><span class="cx">         break;
</span><span class="cx">     case FlowHasHorizonalWritingMode:
</span><span class="cx">         stream &lt;&lt; &quot;horizontal writing mode&quot;;
</span><span class="lines">@@ -183,6 +183,18 @@
</span><span class="cx">     case FlowTextHasSurrogatePair:
</span><span class="cx">         stream &lt;&lt; &quot;surrogate pair&quot;;
</span><span class="cx">         break;
</span><ins>+    case MultiColumnFlowIsNotTopLevel:
+        stream &lt;&lt; &quot;non top level column&quot;;
+        break;
+    case MultiColumnFlowHasColumnSpanner:
+        stream &lt;&lt; &quot;column has spanner&quot;;
+        break;
+    case MultiColumnFlowVerticalAlign:
+        stream &lt;&lt; &quot;column with vertical-align != baseline&quot;;
+        break;
+    case MultiColumnFlowIsFloating:
+        stream &lt;&lt; &quot;column with floating objecgts&quot;;
+        break;
</ins><span class="cx">     case FlowTextIsEmpty:
</span><span class="cx">     case FlowHasNoChild:
</span><span class="cx">     case FlowHasNoParent:
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutCoverageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutCoverage.h (213638 => 213639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutCoverage.h        2017-03-09 14:24:04 UTC (rev 213638)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutCoverage.h        2017-03-09 15:25:12 UTC (rev 213639)
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> enum AvoidanceReason_ : uint64_t {
</span><del>-    FlowIsInsideRegion                    = 1LLU  &lt;&lt; 0,
</del><ins>+    FlowIsInsideANonMultiColumnThread     = 1LLU  &lt;&lt; 0,
</ins><span class="cx">     FlowHasHorizonalWritingMode           = 1LLU  &lt;&lt; 1,
</span><span class="cx">     FlowHasOutline                        = 1LLU  &lt;&lt; 2,
</span><span class="cx">     FlowIsRuby                            = 1LLU  &lt;&lt; 3,
</span><span class="lines">@@ -86,7 +86,11 @@
</span><span class="cx">     FlowHasHangingPunctuation             = 1LLU  &lt;&lt; 48,
</span><span class="cx">     FlowFontHasOverflowGlyph              = 1LLU  &lt;&lt; 49,
</span><span class="cx">     FlowTextHasSurrogatePair              = 1LLU  &lt;&lt; 50,
</span><del>-    EndOfReasons                          = 1LLU  &lt;&lt; 51
</del><ins>+    MultiColumnFlowIsNotTopLevel          = 1LLU  &lt;&lt; 51,
+    MultiColumnFlowHasColumnSpanner       = 1LLU  &lt;&lt; 52,
+    MultiColumnFlowVerticalAlign          = 1LLU  &lt;&lt; 53,
+    MultiColumnFlowIsFloating             = 1LLU  &lt;&lt; 54,
+    EndOfReasons                          = 1LLU  &lt;&lt; 55
</ins><span class="cx"> };
</span><span class="cx"> const unsigned NoReason = 0;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutPaginationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutPagination.cpp (213638 => 213639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutPagination.cpp        2017-03-09 14:24:04 UTC (rev 213638)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutPagination.cpp        2017-03-09 15:25:12 UTC (rev 213639)
</span><span class="lines">@@ -44,8 +44,8 @@
</span><span class="cx"> {
</span><span class="cx">     // FIXME: Add visualOverflowForDecorations.
</span><span class="cx">     auto&amp; fontMetrics = flow.style().fontCascade().fontMetrics();
</span><del>-    auto ascent = fontMetrics.floatAscent();
-    auto descent = fontMetrics.floatDescent();
</del><ins>+    auto ascent = fontMetrics.ascent();
+    auto descent = fontMetrics.descent();
</ins><span class="cx">     auto lineHeight = lineHeightFromFlow(flow);
</span><span class="cx">     LayoutUnit offset = flow.borderAndPaddingBefore();
</span><span class="cx">     for (auto&amp; strut : struts) {
</span><span class="lines">@@ -94,17 +94,20 @@
</span><span class="cx"> static void setPageBreakForLine(unsigned lineBreakIndex, PaginatedLines&amp; lines, RenderBlockFlow&amp; flow, Layout::SimpleLineStruts&amp; struts,
</span><span class="cx">     bool atTheTopOfColumnOrPage)
</span><span class="cx"> {
</span><del>-    if (!lineBreakIndex) {
-        // When the first line does not fit the current page, just add a page break in front and set the strut on the block.
-        auto line = lines.first();
-        auto remainingLogicalHeight = flow.pageRemainingLogicalHeightForOffset(line.top, RenderBlockFlow::ExcludePageBoundary);
</del><ins>+    auto line = lines.at(lineBreakIndex);
+    auto remainingLogicalHeight = flow.pageRemainingLogicalHeightForOffset(line.top, RenderBlockFlow::ExcludePageBoundary);
+    auto&amp; style = flow.style();
+    auto firstLineWithDoesNotFit = !lineBreakIndex &amp;&amp; line.height &lt; flow.pageLogicalHeightForOffset(line.top);
+    auto orphanDoesNotFit = !style.hasAutoOrphans() &amp;&amp; style.orphans() &gt; (short)lineBreakIndex;
+    if (firstLineWithDoesNotFit || orphanDoesNotFit) {
</ins><span class="cx">         flow.setPageBreak(line.top, line.height - remainingLogicalHeight);
</span><del>-        flow.setPaginationStrut(remainingLogicalHeight);
</del><ins>+        flow.setPaginationStrut(line.top + remainingLogicalHeight);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    auto beforeLineBreak = lines.at(lineBreakIndex - 1);
-    auto spaceShortage = flow.pageRemainingLogicalHeightForOffset(beforeLineBreak.top, RenderBlockFlow::ExcludePageBoundary) - beforeLineBreak.height;
-    flow.setPageBreak(beforeLineBreak.bottom, spaceShortage);
</del><ins>+    if (atTheTopOfColumnOrPage)
+        flow.setPageBreak(line.top, line.height);
+    else
+        flow.setPageBreak(line.top, line.height - remainingLogicalHeight);
</ins><span class="cx">     struts.append({ lineBreakIndex, computeOffsetAfterLineBreak(lines[lineBreakIndex].top, !lineBreakIndex, atTheTopOfColumnOrPage, flow) });
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>