<!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>[169110] 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/169110">169110</a></dd>
<dt>Author</dt> <dd>stavila@adobe.com</dd>
<dt>Date</dt> <dd>2014-05-20 07:34:56 -0700 (Tue, 20 May 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[CSS Regions] Block incorrectly sized when containing an unsplittable box
https://bugs.webkit.org/show_bug.cgi?id=132601

Reviewed by Antti Koivisto.

Source/WebCore:
When laying out elements in a region, when an inline element is encountered
the size of its parent must not be increased beyond the bottom of the current region,
unless if its the last region. This will ensure that the next sibling of the
inline element is correctly laid out at the top of the next region, instead
of leaving an empty space equal to the height of the overflow, as it did until now.

Tests: fast/regions/inline-block-inside-anonymous-overflow.html
       fast/regions/inline-block-overflow.html

* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::adjustLinePositionForPagination):
(WebCore::RenderBlockFlow::hasNextPage):
* rendering/RenderBlockFlow.h:
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlockFlow::layoutRunsAndFloatsInRange):
(WebCore::RenderBlockFlow::linkToEndLineIfNeeded):
(WebCore::RenderBlockFlow::determineStartPosition):
(WebCore::RenderBlockFlow::checkPaginationAndFloatsAtEndLine):

LayoutTests:
Added tests for the layout of elements following inline-block elements
that overflow their region, with and without anonymous blocks.

* fast/regions/inline-block-inside-anonymous-overflow-expected.html: Added.
* fast/regions/inline-block-inside-anonymous-overflow.html: Added.
* fast/regions/inline-block-overflow-expected.html: Added.
* fast/regions/inline-block-overflow.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockFlowcpp">trunk/Source/WebCore/rendering/RenderBlockFlow.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockFlowh">trunk/Source/WebCore/rendering/RenderBlockFlow.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockLineLayoutcpp">trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastregionsinlineblockinsideanonymousoverflowexpectedhtml">trunk/LayoutTests/fast/regions/inline-block-inside-anonymous-overflow-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastregionsinlineblockinsideanonymousoverflowhtml">trunk/LayoutTests/fast/regions/inline-block-inside-anonymous-overflow.html</a></li>
<li><a href="#trunkLayoutTestsfastregionsinlineblockoverflowexpectedhtml">trunk/LayoutTests/fast/regions/inline-block-overflow-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastregionsinlineblockoverflowhtml">trunk/LayoutTests/fast/regions/inline-block-overflow.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (169109 => 169110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-05-20 13:56:27 UTC (rev 169109)
+++ trunk/LayoutTests/ChangeLog        2014-05-20 14:34:56 UTC (rev 169110)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2014-05-20  Radu Stavila  &lt;stavila@adobe.com&gt;
+
+        [CSS Regions] Block incorrectly sized when containing an unsplittable box
+        https://bugs.webkit.org/show_bug.cgi?id=132601
+
+        Reviewed by Antti Koivisto.
+
+        Added tests for the layout of elements following inline-block elements 
+        that overflow their region, with and without anonymous blocks.
+
+        * fast/regions/inline-block-inside-anonymous-overflow-expected.html: Added.
+        * fast/regions/inline-block-inside-anonymous-overflow.html: Added.
+        * fast/regions/inline-block-overflow-expected.html: Added.
+        * fast/regions/inline-block-overflow.html: Added.
+
</ins><span class="cx"> 2014-05-20  Zoltan Horvath  &lt;zoltan@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         [CSS Regions] Add polygon tests for shapes on regions and shapes on the content flow
</span></span></pre></div>
<a id="trunkLayoutTestsfastregionsinlineblockinsideanonymousoverflowexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/regions/inline-block-inside-anonymous-overflow-expected.html (0 => 169110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/regions/inline-block-inside-anonymous-overflow-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/regions/inline-block-inside-anonymous-overflow-expected.html        2014-05-20 14:34:56 UTC (rev 169110)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            .region {
+                border: 3px solid blue;
+                float: left;
+            }
+            #region1 {
+                height: 250px;
+            }
+            #region2 {
+                width: 300px;
+                height: 200px;
+                margin-left: 50px;
+            }
+            .article {
+                background-color: #009999;
+            }
+            #article1 {
+                height: 230px;
+            }
+            #video {
+                width: 320px;
+                height: 300px;
+                background-color: salmon;
+                border: 3px solid black;
+            }
+        &lt;/style&gt;
+    &lt;/head&gt;
+
+    &lt;body&gt;
+        &lt;a href=&quot;https://bugs.webkit.org/show_bug.cgi?id=132601&quot;&gt;Bug 132601 - [CSS Regions] Block incorrectly sized when containing an unsplittable box&lt;/a&gt;
+        &lt;p&gt;This test passes if the &lt;span style=&quot;color:#00BB00&quot;&gt;green text&lt;/span&gt; is positioned at the very top of the second &lt;span style=&quot;color:blue&quot;&gt;region&lt;/span&gt; and the &lt;span style=&quot;color:blue&quot;&gt;blue text&lt;/span&gt; immediately after it.&lt;/p&gt;
+        &lt;div class=&quot;region&quot; id=&quot;region1&quot;&gt;
+            &lt;div class=&quot;article&quot; id=&quot;article1&quot;&gt;
+                &lt;video id=&quot;video&quot; controls&gt;&lt;/video&gt;&lt;span style=&quot;color:#00FF00&quot;&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+        
+        &lt;div class=&quot;region&quot; id=&quot;region2&quot;&gt;
+            &lt;div class=&quot;article&quot; id=&quot;article2&quot;&gt;
+                &lt;span style=&quot;color:#00FF00&quot;&gt;This text, together with the video element, are inside an anonymouse block&lt;/span&gt;
+                &lt;div id=&quot;after&quot; style=&quot;color:blue&quot;&gt;This div is after the anonymous block&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+        
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastregionsinlineblockinsideanonymousoverflowhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/regions/inline-block-inside-anonymous-overflow.html (0 => 169110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/regions/inline-block-inside-anonymous-overflow.html                                (rev 0)
+++ trunk/LayoutTests/fast/regions/inline-block-inside-anonymous-overflow.html        2014-05-20 14:34:56 UTC (rev 169110)
</span><span class="lines">@@ -0,0 +1,41 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            .region {
+                -webkit-flow-from: flow;
+                border: 3px solid blue;
+                float: left;
+            }
+            #region1 {
+                height: 250px;
+            }
+            #region2 {
+                width: 300px;
+                height: 200px;
+                margin-left: 50px;
+            }
+            #article {
+                -webkit-flow-into: flow;
+                background-color: #009999;
+            }
+            #video {
+                width: 320px;
+                height: 300px;
+                background-color: salmon;
+                border: 3px solid black;
+            }
+        &lt;/style&gt;
+    &lt;/head&gt;
+
+    &lt;body&gt;
+        &lt;a href=&quot;https://bugs.webkit.org/show_bug.cgi?id=132601&quot;&gt;Bug 132601 - [CSS Regions] Block incorrectly sized when containing an unsplittable box&lt;/a&gt;
+        &lt;p&gt;This test passes if the &lt;span style=&quot;color:#00BB00&quot;&gt;green text&lt;/span&gt; is positioned at the very top of the second &lt;span style=&quot;color:blue&quot;&gt;region&lt;/span&gt; and the &lt;span style=&quot;color:blue&quot;&gt;blue text&lt;/span&gt; immediately after it.&lt;/p&gt;
+        &lt;div class=&quot;region&quot; id=&quot;region1&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;region&quot; id=&quot;region2&quot;&gt;&lt;/div&gt;
+        &lt;div id=&quot;article&quot;&gt;
+            &lt;video id=&quot;video&quot; controls&gt;&lt;/video&gt;&lt;span style=&quot;color:#00FF00&quot;&gt;This text, together with the video element, are inside an anonymouse block&lt;/span&gt;
+            &lt;div id=&quot;after&quot; style=&quot;color:blue&quot;&gt;This div is after the anonymous block&lt;/div&gt;
+        &lt;/div&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastregionsinlineblockoverflowexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/regions/inline-block-overflow-expected.html (0 => 169110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/regions/inline-block-overflow-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/regions/inline-block-overflow-expected.html        2014-05-20 14:34:56 UTC (rev 169110)
</span><span class="lines">@@ -0,0 +1,48 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            .region {
+                border: 3px solid blue;
+                float: left;
+            }
+            #region1 {
+                height: 250px;
+            }
+            #region2 {
+                width: 300px;
+                height: 200px;
+                margin-left: 50px;
+            }
+            .article {
+                background-color: #009999;
+            }
+            #article1 {
+                height: 230px;
+            }
+            #video {
+                width: 320px;
+                height: 300px;
+                background-color: salmon;
+                border: 3px solid black;
+                display: inline-block;
+            }
+        &lt;/style&gt;
+    &lt;/head&gt;
+
+    &lt;body&gt;
+        &lt;a href=&quot;https://bugs.webkit.org/show_bug.cgi?id=132601&quot;&gt;Bug 132601 - [CSS Regions] Block incorrectly sized when containing an unsplittable box&lt;/a&gt;
+        &lt;p&gt;This test passes if the &lt;span style=&quot;color:#00BB00&quot;&gt;green text&lt;/span&gt; is positioned at the very top of the second &lt;span style=&quot;color:blue&quot;&gt;region&lt;/span&gt;.&lt;/p&gt;
+        &lt;div class=&quot;region&quot; id=&quot;region1&quot;&gt;
+            &lt;div class=&quot;article&quot; id=&quot;article1&quot;&gt;
+                &lt;video id=&quot;video&quot; controls&gt;&lt;/video&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+
+        &lt;div class=&quot;region&quot; id=&quot;region2&quot;&gt;
+            &lt;div class=&quot;article&quot; id=&quot;article2&quot;&gt;
+                &lt;div id=&quot;after&quot; style=&quot;color:#00FF00&quot;&gt;This div is flowed after the video element.&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastregionsinlineblockoverflowhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/regions/inline-block-overflow.html (0 => 169110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/regions/inline-block-overflow.html                                (rev 0)
+++ trunk/LayoutTests/fast/regions/inline-block-overflow.html        2014-05-20 14:34:56 UTC (rev 169110)
</span><span class="lines">@@ -0,0 +1,44 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            .region {
+                -webkit-flow-from: flow;
+                border: 3px solid blue;
+                float: left;
+            }
+            #region1 {
+                height: 250px;
+            }
+            #region2 {
+                width: 300px;
+                height: 200px;
+                margin-left: 50px;
+            }
+            .article {
+                -webkit-flow-into: flow;
+                background-color: #009999;
+            }
+            #video {
+                width: 320px;
+                height: 300px;
+                background-color: salmon;
+                border: 3px solid black;
+                display: inline-block;
+            }
+        &lt;/style&gt;
+    &lt;/head&gt;
+
+    &lt;body&gt;
+        &lt;a href=&quot;https://bugs.webkit.org/show_bug.cgi?id=132601&quot;&gt;Bug 132601 - [CSS Regions] Block incorrectly sized when containing an unsplittable box&lt;/a&gt;
+        &lt;p&gt;This test passes if the &lt;span style=&quot;color:#00BB00&quot;&gt;green text&lt;/span&gt; is positioned at the very top of the second &lt;span style=&quot;color:blue&quot;&gt;region&lt;/span&gt;.&lt;/p&gt;
+        &lt;div class=&quot;region&quot; id=&quot;region1&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;region&quot; id=&quot;region2&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;article&quot; id=&quot;article1&quot;&gt;
+            &lt;video id=&quot;video&quot; controls&gt;&lt;/video&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;article&quot; id=&quot;article2&quot;&gt;
+            &lt;div id=&quot;after&quot; style=&quot;color:#00FF00&quot;&gt;This div is flowed after the video element.&lt;/div&gt;
+        &lt;/div&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (169109 => 169110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-05-20 13:56:27 UTC (rev 169109)
+++ trunk/Source/WebCore/ChangeLog        2014-05-20 14:34:56 UTC (rev 169110)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2014-05-20  Radu Stavila  &lt;stavila@adobe.com&gt;
+
+        [CSS Regions] Block incorrectly sized when containing an unsplittable box
+        https://bugs.webkit.org/show_bug.cgi?id=132601
+
+        Reviewed by Antti Koivisto.
+
+        When laying out elements in a region, when an inline element is encountered
+        the size of its parent must not be increased beyond the bottom of the current region,
+        unless if its the last region. This will ensure that the next sibling of the
+        inline element is correctly laid out at the top of the next region, instead
+        of leaving an empty space equal to the height of the overflow, as it did until now.
+
+        Tests: fast/regions/inline-block-inside-anonymous-overflow.html
+               fast/regions/inline-block-overflow.html
+
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::adjustLinePositionForPagination):
+        (WebCore::RenderBlockFlow::hasNextPage):
+        * rendering/RenderBlockFlow.h:
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::RenderBlockFlow::layoutRunsAndFloatsInRange):
+        (WebCore::RenderBlockFlow::linkToEndLineIfNeeded):
+        (WebCore::RenderBlockFlow::determineStartPosition):
+        (WebCore::RenderBlockFlow::checkPaginationAndFloatsAtEndLine):
+
</ins><span class="cx"> 2014-05-20  Mihnea Ovidenie  &lt;mihnea@adobe.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [CSS Regions] Crash while painting block selection gaps in regions
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockFlowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (169109 => 169110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp        2014-05-20 13:56:27 UTC (rev 169109)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp        2014-05-20 14:34:56 UTC (rev 169110)
</span><span class="lines">@@ -1620,7 +1620,7 @@
</span><span class="cx">     return lineBottom - lineTop;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RenderBlockFlow::adjustLinePositionForPagination(RootInlineBox* lineBox, LayoutUnit&amp; delta, RenderFlowThread* flowThread)
</del><ins>+void RenderBlockFlow::adjustLinePositionForPagination(RootInlineBox* lineBox, LayoutUnit&amp; delta, bool&amp; overflowsRegion, RenderFlowThread* flowThread)
</ins><span class="cx"> {
</span><span class="cx">     // FIXME: For now we paginate using line overflow. This ensures that lines don't overlap at all when we
</span><span class="cx">     // put a strut between them for pagination purposes. However, this really isn't the desired rendering, since
</span><span class="lines">@@ -1641,6 +1641,7 @@
</span><span class="cx">     // FIXME: Another problem with simply moving lines is that the available line width may change (because of floats).
</span><span class="cx">     // Technically if the location we move the line to has a different line width than our old position, then we need to dirty the
</span><span class="cx">     // line and all following lines.
</span><ins>+    overflowsRegion = false;
</ins><span class="cx">     LayoutRect logicalVisualOverflow = lineBox-&gt;logicalVisualOverflowRect(lineBox-&gt;lineTop(), lineBox-&gt;lineBottom());
</span><span class="cx">     LayoutUnit logicalOffset = std::min(lineBox-&gt;lineTopWithLeading(), logicalVisualOverflow.y());
</span><span class="cx">     LayoutUnit logicalBottom = std::max(lineBox-&gt;lineBottomWithLeading(), logicalVisualOverflow.maxY());
</span><span class="lines">@@ -1659,6 +1660,7 @@
</span><span class="cx">         // From here, the fix is not straightforward because it's not easy to always determine when the current line is the first in the page.
</span><span class="cx">         return;
</span><span class="cx">     LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logicalOffset, ExcludePageBoundary);
</span><ins>+    overflowsRegion = (lineHeight &gt; remainingLogicalHeight);
</ins><span class="cx"> 
</span><span class="cx">     int lineIndex = lineCount(lineBox);
</span><span class="cx">     if (remainingLogicalHeight &lt; lineHeight || (shouldBreakAtLineToAvoidWidow() &amp;&amp; lineBreakToAvoidWidow() == lineIndex)) {
</span><span class="lines">@@ -1673,6 +1675,8 @@
</span><span class="cx">             // Split the top margin in order to avoid splitting the visible part of the line.
</span><span class="cx">             remainingLogicalHeight -= std::min(lineHeight - pageLogicalHeight, std::max&lt;LayoutUnit&gt;(0, logicalVisualOverflow.y() - lineBox-&gt;lineTopWithLeading()));
</span><span class="cx">         }
</span><ins>+        LayoutUnit remainingLogicalHeightAtNewOffset = pageRemainingLogicalHeightForOffset(logicalOffset + remainingLogicalHeight, ExcludePageBoundary);
+        overflowsRegion = (lineHeight &gt; remainingLogicalHeightAtNewOffset);
</ins><span class="cx">         LayoutUnit totalLogicalHeight = lineHeight + std::max&lt;LayoutUnit&gt;(0, logicalOffset);
</span><span class="cx">         LayoutUnit pageLogicalHeightAtNewOffset = hasUniformPageLogicalHeight ? pageLogicalHeight : pageLogicalHeightForOffset(logicalOffset + remainingLogicalHeight);
</span><span class="cx">         setPageBreak(logicalOffset, lineHeight - remainingLogicalHeight);
</span><span class="lines">@@ -1758,7 +1762,7 @@
</span><span class="cx">     RenderRegion* startRegion = nullptr;
</span><span class="cx">     RenderRegion* endRegion = nullptr;
</span><span class="cx">     flowThread-&gt;getRegionRangeForBox(this, startRegion, endRegion);
</span><del>-    return region != endRegion;
</del><ins>+    return (endRegion &amp;&amp; region != endRegion);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> LayoutUnit RenderBlockFlow::adjustForUnsplittableChild(RenderBox&amp; child, LayoutUnit logicalOffset, bool includeMargins)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockFlowh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.h (169109 => 169110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlockFlow.h        2014-05-20 13:56:27 UTC (rev 169109)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.h        2014-05-20 14:34:56 UTC (rev 169110)
</span><span class="lines">@@ -590,7 +590,7 @@
</span><span class="cx"> 
</span><span class="cx"> public:
</span><span class="cx">     // FIXME-BLOCKFLOW: These can be made protected again once all callers have been moved here.
</span><del>-    void adjustLinePositionForPagination(RootInlineBox*, LayoutUnit&amp; deltaOffset, RenderFlowThread*); // Computes a deltaOffset value that put a line at the top of the next page if it doesn't fit on the current page.
</del><ins>+    void adjustLinePositionForPagination(RootInlineBox*, LayoutUnit&amp; deltaOffset, bool&amp; overflowsRegion, RenderFlowThread*); // Computes a deltaOffset value that put a line at the top of the next page if it doesn't fit on the current page.
</ins><span class="cx">     void updateRegionForLine(RootInlineBox*) const;
</span><span class="cx">     void createRenderNamedFlowFragmentIfNeeded();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockLineLayoutcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (169109 => 169110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp        2014-05-20 13:56:27 UTC (rev 169109)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp        2014-05-20 14:34:56 UTC (rev 169110)
</span><span class="lines">@@ -1134,7 +1134,8 @@
</span><span class="cx"> 
</span><span class="cx">                 if (paginated) {
</span><span class="cx">                     LayoutUnit adjustment = 0;
</span><del>-                    adjustLinePositionForPagination(lineBox, adjustment, layoutState.flowThread());
</del><ins>+                    bool overflowsRegion;
+                    adjustLinePositionForPagination(lineBox, adjustment, overflowsRegion, layoutState.flowThread());
</ins><span class="cx">                     if (adjustment) {
</span><span class="cx">                         LayoutUnit oldLineWidth = availableLogicalWidthForLine(oldLogicalHeight, layoutState.lineInfo().isFirstLine());
</span><span class="cx">                         lineBox-&gt;adjustBlockDirectionPosition(adjustment);
</span><span class="lines">@@ -1150,6 +1151,16 @@
</span><span class="cx"> 
</span><span class="cx">                         setLogicalHeight(lineBox-&gt;lineBottomWithLeading());
</span><span class="cx">                     }
</span><ins>+                    
+                    if (RenderFlowThread* flowThread = flowThreadContainingBlock()) {
+                        if (flowThread-&gt;isRenderNamedFlowThread() &amp;&amp; overflowsRegion &amp;&amp; hasNextPage(lineBox-&gt;lineTop())) {
+                            // Limit the height of this block to the end of the current region because
+                            // it is also fragmented into the next region.
+                            LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logicalTop(), ExcludePageBoundary);
+                            if (logicalHeight() &gt; remainingLogicalHeight)
+                                setLogicalHeight(remainingLogicalHeight);
+                        }
+                    }
</ins><span class="cx"> 
</span><span class="cx">                     if (layoutState.flowThread())
</span><span class="cx">                         updateRegionForLine(lineBox);
</span><span class="lines">@@ -1265,7 +1276,8 @@
</span><span class="cx">                 line-&gt;attachLine();
</span><span class="cx">                 if (paginated) {
</span><span class="cx">                     delta -= line-&gt;paginationStrut();
</span><del>-                    adjustLinePositionForPagination(line, delta, layoutState.flowThread());
</del><ins>+                    bool overflowsRegion;
+                    adjustLinePositionForPagination(line, delta, overflowsRegion, layoutState.flowThread());
</ins><span class="cx">                 }
</span><span class="cx">                 if (delta) {
</span><span class="cx">                     layoutState.updateRepaintRangeFromBox(line, delta);
</span><span class="lines">@@ -1505,7 +1517,8 @@
</span><span class="cx">                     break;
</span><span class="cx">                 }
</span><span class="cx">                 paginationDelta -= curr-&gt;paginationStrut();
</span><del>-                adjustLinePositionForPagination(curr, paginationDelta, layoutState.flowThread());
</del><ins>+                bool overflowsRegion;
+                adjustLinePositionForPagination(curr, paginationDelta, overflowsRegion, layoutState.flowThread());
</ins><span class="cx">                 if (paginationDelta) {
</span><span class="cx">                     if (containsFloats() || !layoutState.floats().isEmpty()) {
</span><span class="cx">                         // FIXME: Do better eventually.  For now if we ever shift because of pagination and floats are present just go to a full layout.
</span><span class="lines">@@ -1653,8 +1666,9 @@
</span><span class="cx">                 // This isn't the real move we're going to do, so don't update the line box's pagination
</span><span class="cx">                 // strut yet.
</span><span class="cx">                 LayoutUnit oldPaginationStrut = lineBox-&gt;paginationStrut();
</span><ins>+                bool overflowsRegion;
</ins><span class="cx">                 lineDelta -= oldPaginationStrut;
</span><del>-                adjustLinePositionForPagination(lineBox, lineDelta, layoutState.flowThread());
</del><ins>+                adjustLinePositionForPagination(lineBox, lineDelta, overflowsRegion, layoutState.flowThread());
</ins><span class="cx">                 lineBox-&gt;setPaginationStrut(oldPaginationStrut);
</span><span class="cx">             }
</span><span class="cx">             if (lineWidthForPaginatedLineChanged(lineBox, lineDelta, layoutState.flowThread()))
</span></span></pre>
</div>
</div>

</body>
</html>