<!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>[166938] 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/166938">166938</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2014-04-08 11:19:47 -0700 (Tue, 08 Apr 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[New Multicolumn] Child top margin sometimes ignored for column balancing
https://bugs.webkit.org/show_bug.cgi?id=122754

Patch by Morten Stenshorne &lt;mstensho@opera.com&gt; on 2014-04-08
Reviewed by David Hyatt.

Source/WebCore:

We need to set zero page logical height in LayoutState when column
height is unknown (when the columns haven't yet been
balanced). There's code that assumes that non-zero page height means
that page height is known. Lying about this makes the pagination code
believe that every top margin is adjacent to a column break, which
makes it eat and ignore all top margins.

This should be cleaned up, but it's easier to wait until the old
multicol code has been removed.

Tests: fast/multicol/break-in-scrollable.html
       fast/multicol/newmulticol/leading-and-trailing-margin.html
       fast/multicol/newmulticol/leading-margin.html

* rendering/LayoutState.cpp:
(WebCore::LayoutState::LayoutState):
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::checkForPaginationLogicalHeightChange):
* rendering/RenderFlowThread.h:
* rendering/RenderMultiColumnFlowThread.cpp:
(WebCore::RenderMultiColumnFlowThread::isPageLogicalHeightKnown):
* rendering/RenderMultiColumnFlowThread.h:

LayoutTests:

* fast/multicol/break-in-scrollable-expected.html: Added.
* fast/multicol/break-in-scrollable.html: Added.
* fast/multicol/newmulticol/leading-and-trailing-margin-expected.html: Added.
* fast/multicol/newmulticol/leading-and-trailing-margin.html: Added.
* fast/multicol/newmulticol/leading-margin-expected.html: Added.
* fast/multicol/newmulticol/leading-margin.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="#trunkSourceWebCorerenderingLayoutStatecpp">trunk/Source/WebCore/rendering/LayoutState.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockFlowcpp">trunk/Source/WebCore/rendering/RenderBlockFlow.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderFlowThreadh">trunk/Source/WebCore/rendering/RenderFlowThread.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderMultiColumnFlowThreadcpp">trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderMultiColumnFlowThreadh">trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastmulticolbreakinscrollableexpectedhtml">trunk/LayoutTests/fast/multicol/break-in-scrollable-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastmulticolbreakinscrollablehtml">trunk/LayoutTests/fast/multicol/break-in-scrollable.html</a></li>
<li><a href="#trunkLayoutTestsfastmulticolnewmulticolleadingandtrailingmarginexpectedhtml">trunk/LayoutTests/fast/multicol/newmulticol/leading-and-trailing-margin-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastmulticolnewmulticolleadingandtrailingmarginhtml">trunk/LayoutTests/fast/multicol/newmulticol/leading-and-trailing-margin.html</a></li>
<li><a href="#trunkLayoutTestsfastmulticolnewmulticolleadingmarginexpectedhtml">trunk/LayoutTests/fast/multicol/newmulticol/leading-margin-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastmulticolnewmulticolleadingmarginhtml">trunk/LayoutTests/fast/multicol/newmulticol/leading-margin.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (166937 => 166938)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-04-08 18:06:11 UTC (rev 166937)
+++ trunk/LayoutTests/ChangeLog        2014-04-08 18:19:47 UTC (rev 166938)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2014-04-08  Morten Stenshorne  &lt;mstensho@opera.com&gt;
+
+        [New Multicolumn] Child top margin sometimes ignored for column balancing
+        https://bugs.webkit.org/show_bug.cgi?id=122754
+
+        Reviewed by David Hyatt.
+
+        * fast/multicol/break-in-scrollable-expected.html: Added.
+        * fast/multicol/break-in-scrollable.html: Added.
+        * fast/multicol/newmulticol/leading-and-trailing-margin-expected.html: Added.
+        * fast/multicol/newmulticol/leading-and-trailing-margin.html: Added.
+        * fast/multicol/newmulticol/leading-margin-expected.html: Added.
+        * fast/multicol/newmulticol/leading-margin.html: Added.
+
</ins><span class="cx"> 2014-04-07  Brent Fulgham  &lt;bfulgham@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [WebVTT] Begin Enabling W3C VTT Tests
</span></span></pre></div>
<a id="trunkLayoutTestsfastmulticolbreakinscrollableexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/multicol/break-in-scrollable-expected.html (0 => 166938)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/multicol/break-in-scrollable-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/multicol/break-in-scrollable-expected.html        2014-04-08 18:19:47 UTC (rev 166938)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;title&gt;Forced break inside scrollable container&lt;/title&gt;
+        &lt;script&gt;
+            if (window.internals)
+                internals.settings.setRegionBasedColumnsEnabled(true);
+        &lt;/script&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;p&gt;The word 'PASS' should be seen on the left below. The scrollbars shouldn't be scrollable.&lt;/p&gt;
+        &lt;div style=&quot;-webkit-columns:2; columns:2; orphans:1; widows:1;&quot;&gt;
+            &lt;div style=&quot;overflow:scroll; height:10em;&quot;&gt;
+                &amp;nbsp;
+                &lt;div&gt;PASS&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastmulticolbreakinscrollablehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/multicol/break-in-scrollable.html (0 => 166938)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/multicol/break-in-scrollable.html                                (rev 0)
+++ trunk/LayoutTests/fast/multicol/break-in-scrollable.html        2014-04-08 18:19:47 UTC (rev 166938)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;title&gt;Forced break inside scrollable container&lt;/title&gt;
+        &lt;script&gt;
+            if (window.internals)
+                internals.settings.setRegionBasedColumnsEnabled(true);
+        &lt;/script&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;p&gt;The word 'PASS' should be seen on the left below. The scrollbars shouldn't be scrollable.&lt;/p&gt;
+        &lt;div style=&quot;-webkit-columns:2; columns:2; orphans:1; widows:1;&quot;&gt;
+            &lt;div style=&quot;overflow:scroll; height:10em;&quot;&gt;
+                &amp;nbsp;
+                &lt;div style=&quot;-webkit-column-break-before:always; break-before:column;&quot;&gt;PASS&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastmulticolnewmulticolleadingandtrailingmarginexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/multicol/newmulticol/leading-and-trailing-margin-expected.html (0 => 166938)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/multicol/newmulticol/leading-and-trailing-margin-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/multicol/newmulticol/leading-and-trailing-margin-expected.html        2014-04-08 18:19:47 UTC (rev 166938)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;title&gt;Leading and trailing margin&lt;/title&gt;
+        &lt;script&gt;
+            if (window.internals)
+                internals.settings.setRegionBasedColumnsEnabled(true);
+        &lt;/script&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;p&gt;There should be no scrollbars.&lt;/p&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastmulticolnewmulticolleadingandtrailingmarginhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/multicol/newmulticol/leading-and-trailing-margin.html (0 => 166938)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/multicol/newmulticol/leading-and-trailing-margin.html                                (rev 0)
+++ trunk/LayoutTests/fast/multicol/newmulticol/leading-and-trailing-margin.html        2014-04-08 18:19:47 UTC (rev 166938)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;title&gt;Leading and trailing margin&lt;/title&gt;
+        &lt;script&gt;
+            if (window.internals)
+                internals.settings.setRegionBasedColumnsEnabled(true);
+        &lt;/script&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;p&gt;There should be no scrollbars.&lt;/p&gt;
+        &lt;div style=&quot;-webkit-columns:3; columns:3;&quot;&gt;
+            &lt;div style=&quot;margin-top:1em; margin-bottom:10em;&quot;&gt;&amp;nbsp;&lt;/div&gt;
+        &lt;/div&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastmulticolnewmulticolleadingmarginexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/multicol/newmulticol/leading-margin-expected.html (0 => 166938)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/multicol/newmulticol/leading-margin-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/multicol/newmulticol/leading-margin-expected.html        2014-04-08 18:19:47 UTC (rev 166938)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;title&gt;Leading margins&lt;/title&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;p&gt;There should be no scrollbars.&lt;/p&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastmulticolnewmulticolleadingmarginhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/multicol/newmulticol/leading-margin.html (0 => 166938)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/multicol/newmulticol/leading-margin.html                                (rev 0)
+++ trunk/LayoutTests/fast/multicol/newmulticol/leading-margin.html        2014-04-08 18:19:47 UTC (rev 166938)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;title&gt;Leading margins&lt;/title&gt;
+        &lt;script&gt;
+            if (window.internals)
+                internals.settings.setRegionBasedColumnsEnabled(true);
+        &lt;/script&gt;
+        &lt;style&gt;
+            .test { margin-top:100px; border:2px solid transparent; }
+        &lt;/style&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;p&gt;There should be no scrollbars.&lt;/p&gt;
+        &lt;div style=&quot;-webkit-column-count:2; column-count:2;&quot;&gt;
+            &lt;div class=&quot;test&quot;&gt;&lt;/div&gt;
+            &lt;div class=&quot;test&quot;&gt;&lt;/div&gt;
+            &lt;div class=&quot;test&quot;&gt;&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 (166937 => 166938)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-04-08 18:06:11 UTC (rev 166937)
+++ trunk/Source/WebCore/ChangeLog        2014-04-08 18:19:47 UTC (rev 166938)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2014-04-08  Morten Stenshorne  &lt;mstensho@opera.com&gt;
+
+        [New Multicolumn] Child top margin sometimes ignored for column balancing
+        https://bugs.webkit.org/show_bug.cgi?id=122754
+
+        Reviewed by David Hyatt.
+
+        We need to set zero page logical height in LayoutState when column
+        height is unknown (when the columns haven't yet been
+        balanced). There's code that assumes that non-zero page height means
+        that page height is known. Lying about this makes the pagination code
+        believe that every top margin is adjacent to a column break, which
+        makes it eat and ignore all top margins.
+
+        This should be cleaned up, but it's easier to wait until the old
+        multicol code has been removed.
+
+        Tests: fast/multicol/break-in-scrollable.html
+               fast/multicol/newmulticol/leading-and-trailing-margin.html
+               fast/multicol/newmulticol/leading-margin.html
+
+        * rendering/LayoutState.cpp:
+        (WebCore::LayoutState::LayoutState):
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::checkForPaginationLogicalHeightChange):
+        * rendering/RenderFlowThread.h:
+        * rendering/RenderMultiColumnFlowThread.cpp:
+        (WebCore::RenderMultiColumnFlowThread::isPageLogicalHeightKnown):
+        * rendering/RenderMultiColumnFlowThread.h:
+
</ins><span class="cx"> 2014-04-07  Dean Jackson  &lt;dino@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Allow elements to register for changes in page scale
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingLayoutStatecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/LayoutState.cpp (166937 => 166938)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/LayoutState.cpp        2014-04-08 18:06:11 UTC (rev 166937)
+++ trunk/Source/WebCore/rendering/LayoutState.cpp        2014-04-08 18:19:47 UTC (rev 166938)
</span><span class="lines">@@ -88,6 +88,7 @@
</span><span class="cx">         m_pageOffset = LayoutSize(m_layoutOffset.width() + (!isFlipped ? renderer-&gt;borderLeft() + renderer-&gt;paddingLeft() : renderer-&gt;borderRight() + renderer-&gt;paddingRight()),
</span><span class="cx">                                m_layoutOffset.height() + (!isFlipped ? renderer-&gt;borderTop() + renderer-&gt;paddingTop() : renderer-&gt;borderBottom() + renderer-&gt;paddingBottom()));
</span><span class="cx">         m_pageLogicalHeightChanged = pageLogicalHeightChanged;
</span><ins>+        m_isPaginated = true;
</ins><span class="cx">     } else {
</span><span class="cx">         // If we don't establish a new page height, then propagate the old page height and offset down.
</span><span class="cx">         m_pageLogicalHeight = m_next-&gt;m_pageLogicalHeight;
</span><span class="lines">@@ -96,8 +97,11 @@
</span><span class="cx">         
</span><span class="cx">         // Disable pagination for objects we don't support. For now this includes overflow:scroll/auto, inline blocks and
</span><span class="cx">         // writing mode roots.
</span><del>-        if (renderer-&gt;isUnsplittableForPagination())
</del><ins>+        if (renderer-&gt;isUnsplittableForPagination()) {
</ins><span class="cx">             m_pageLogicalHeight = 0;
</span><ins>+            m_isPaginated = false;
+        } else
+            m_isPaginated = m_pageLogicalHeight || m_next-&gt;m_columnInfo || renderer-&gt;flowThreadContainingBlock();
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     // Propagate line grid information.
</span><span class="lines">@@ -111,8 +115,6 @@
</span><span class="cx">     m_layoutDeltaXSaturated = m_next-&gt;m_layoutDeltaXSaturated;
</span><span class="cx">     m_layoutDeltaYSaturated = m_next-&gt;m_layoutDeltaYSaturated;
</span><span class="cx"> #endif
</span><del>-    
-    m_isPaginated = m_pageLogicalHeight || m_columnInfo || renderer-&gt;isRenderFlowThread();
</del><span class="cx"> 
</span><span class="cx">     if (lineGrid() &amp;&amp; (lineGrid()-&gt;style().writingMode() == renderer-&gt;style().writingMode()) &amp;&amp; renderer-&gt;isRenderBlock())
</span><span class="cx">         toRenderBlock(renderer)-&gt;computeLineGridPaginationOrigin(*this);
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockFlowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (166937 => 166938)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp        2014-04-08 18:06:11 UTC (rev 166937)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp        2014-04-08 18:19:47 UTC (rev 166938)
</span><span class="lines">@@ -3548,8 +3548,20 @@
</span><span class="cx"> 
</span><span class="cx">         colInfo-&gt;setPaginationUnit(paginationUnit());
</span><span class="cx">     } else if (isRenderFlowThread()) {
</span><del>-        pageLogicalHeight = 1; // This is just a hack to always make sure we have a page logical height.
-        pageLogicalHeightChanged = toRenderFlowThread(this)-&gt;pageLogicalSizeChanged();
</del><ins>+        RenderFlowThread* flowThread = toRenderFlowThread(this);
+
+        // FIXME: This is a hack to always make sure we have a page logical height, if said height
+        // is known. The page logical height thing in LayoutState is meaningless for flow
+        // thread-based pagination (page height isn't necessarily uniform throughout the flow
+        // thread), but as long as it is used universally as a means to determine whether page
+        // height is known or not, we need this. Page height is unknown when column balancing is
+        // enabled and flow thread height is still unknown (i.e. during the first layout pass). When
+        // it's unknown, we need to prevent the pagination code from assuming page breaks everywhere
+        // and thereby eating every top margin. It should be trivial to clean up and get rid of this
+        // hack once the old multicol implementation is gone.
+        pageLogicalHeight = flowThread-&gt;isPageLogicalHeightKnown() ? LayoutUnit(1) : LayoutUnit(0);
+
+        pageLogicalHeightChanged = flowThread-&gt;pageLogicalSizeChanged();
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderFlowThreadh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderFlowThread.h (166937 => 166938)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderFlowThread.h        2014-04-08 18:06:11 UTC (rev 166937)
+++ trunk/Source/WebCore/rendering/RenderFlowThread.h        2014-04-08 18:19:47 UTC (rev 166938)
</span><span class="lines">@@ -138,6 +138,7 @@
</span><span class="cx">     virtual bool addForcedRegionBreak(const RenderBlock*, LayoutUnit, RenderBox* breakChild, bool isBefore, LayoutUnit* offsetBreakAdjustment = 0);
</span><span class="cx">     void applyBreakAfterContent(LayoutUnit);
</span><span class="cx"> 
</span><ins>+    virtual bool isPageLogicalHeightKnown() const { return true; }
</ins><span class="cx">     bool pageLogicalSizeChanged() const { return m_pageLogicalSizeChanged; }
</span><span class="cx"> 
</span><span class="cx">     bool hasAutoLogicalHeightRegions() const { ASSERT(isAutoLogicalHeightRegionsCountConsistent()); return m_autoLogicalHeightRegionsCount; }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderMultiColumnFlowThreadcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp (166937 => 166938)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp        2014-04-08 18:06:11 UTC (rev 166937)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp        2014-04-08 18:19:47 UTC (rev 166938)
</span><span class="lines">@@ -211,4 +211,14 @@
</span><span class="cx">     return renderRegion;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool RenderMultiColumnFlowThread::isPageLogicalHeightKnown() const
+{
+    for (RenderBox* renderer = parentBox()-&gt;lastChildBox(); renderer; renderer = renderer-&gt;previousSiblingBox()) {
+        if (renderer-&gt;isRenderMultiColumnSet())
+            return toRenderMultiColumnSet(renderer)-&gt;computedColumnHeight();
+    }
+    // A column set hasn't been created yet. Height may already be known if column-fill is 'auto', though.
+    return !requiresBalancing();
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderMultiColumnFlowThreadh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.h (166937 => 166938)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.h        2014-04-08 18:06:11 UTC (rev 166937)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.h        2014-04-08 18:19:47 UTC (rev 166938)
</span><span class="lines">@@ -73,6 +73,7 @@
</span><span class="cx">     virtual void setPageBreak(const RenderBlock*, LayoutUnit offset, LayoutUnit spaceShortage) override;
</span><span class="cx">     virtual void updateMinimumPageHeight(const RenderBlock*, LayoutUnit offset, LayoutUnit minHeight) override;
</span><span class="cx">     virtual bool addForcedRegionBreak(const RenderBlock*, LayoutUnit, RenderBox* breakChild, bool isBefore, LayoutUnit* offsetBreakAdjustment = 0) override;
</span><ins>+    virtual bool isPageLogicalHeightKnown() const override;
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     unsigned m_columnCount;   // The default column count/width that are based off our containing block width. These values represent only the default,
</span></span></pre>
</div>
</div>

</body>
</html>