<!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>[176354] 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/176354">176354</a></dd>
<dt>Author</dt> <dd>hyatt@apple.com</dd>
<dt>Date</dt> <dd>2014-11-19 15:40:23 -0800 (Wed, 19 Nov 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Images/replaced elements that are as tall as a page should be on their own page
https://bugs.webkit.org/show_bug.cgi?id=138886 - &lt;rdar://problem/18296371&gt;

Reviewed by Dean Jackson.

Source/WebCore:

Added fast/multicol/tall-image-behavior.html (and RL/LR variants)

* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::computeReplacedAndTextLineTopAndBottom):
* rendering/InlineFlowBox.h:
Add a new method that computes the line top and line bottom ignoring all margins,
overflow and line-height. This allows us to see if a line that is taller than a page
can be made to fit if we ignored margins and unused descent.

* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::adjustLinePositionForPagination):
Call the new helper function, computeReplacedAndTextLineTopAndBottom and push
to a new page if we see that we can fit on a page by ourselves without blank space
included.

LayoutTests:

* fast/multicol/tall-image-behavior-lr.html: Added.
* fast/multicol/tall-image-behavior-rl.html: Added.
* fast/multicol/tall-image-behavior.html: Added.
* platform/mac/fast/multicol/tall-image-behavior-expected.png: Added.
* platform/mac/fast/multicol/tall-image-behavior-expected.txt: Added.
* platform/mac/fast/multicol/tall-image-behavior-lr-expected.png: Added.
* platform/mac/fast/multicol/tall-image-behavior-lr-expected.txt: Added.
* platform/mac/fast/multicol/tall-image-behavior-rl-expected.png: Added.
* platform/mac/fast/multicol/tall-image-behavior-rl-expected.txt: 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="#trunkSourceWebCorerenderingInlineFlowBoxcpp">trunk/Source/WebCore/rendering/InlineFlowBox.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingInlineFlowBoxh">trunk/Source/WebCore/rendering/InlineFlowBox.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockFlowcpp">trunk/Source/WebCore/rendering/RenderBlockFlow.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastmulticoltallimagebehaviorlrhtml">trunk/LayoutTests/fast/multicol/tall-image-behavior-lr.html</a></li>
<li><a href="#trunkLayoutTestsfastmulticoltallimagebehaviorrlhtml">trunk/LayoutTests/fast/multicol/tall-image-behavior-rl.html</a></li>
<li><a href="#trunkLayoutTestsfastmulticoltallimagebehaviorhtml">trunk/LayoutTests/fast/multicol/tall-image-behavior.html</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastmulticoltallimagebehaviorexpectedpng">trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-expected.png</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastmulticoltallimagebehaviorexpectedtxt">trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastmulticoltallimagebehaviorlrexpectedpng">trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-lr-expected.png</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastmulticoltallimagebehaviorlrexpectedtxt">trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-lr-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastmulticoltallimagebehaviorrlexpectedpng">trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-rl-expected.png</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastmulticoltallimagebehaviorrlexpectedtxt">trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-rl-expected.txt</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (176353 => 176354)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-11-19 23:36:08 UTC (rev 176353)
+++ trunk/LayoutTests/ChangeLog        2014-11-19 23:40:23 UTC (rev 176354)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2014-11-19  David Hyatt  &lt;hyatt@apple.com&gt;
+
+        Images/replaced elements that are as tall as a page should be on their own page
+        https://bugs.webkit.org/show_bug.cgi?id=138886 - &lt;rdar://problem/18296371&gt;
+
+        Reviewed by Dean Jackson.
+
+        * fast/multicol/tall-image-behavior-lr.html: Added.
+        * fast/multicol/tall-image-behavior-rl.html: Added.
+        * fast/multicol/tall-image-behavior.html: Added.
+        * platform/mac/fast/multicol/tall-image-behavior-expected.png: Added.
+        * platform/mac/fast/multicol/tall-image-behavior-expected.txt: Added.
+        * platform/mac/fast/multicol/tall-image-behavior-lr-expected.png: Added.
+        * platform/mac/fast/multicol/tall-image-behavior-lr-expected.txt: Added.
+        * platform/mac/fast/multicol/tall-image-behavior-rl-expected.png: Added.
+        * platform/mac/fast/multicol/tall-image-behavior-rl-expected.txt: Added.
+
</ins><span class="cx"> 2014-11-18  Ada Chan  &lt;adachan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Take Web Audio into account for the Page::isPlayingAudio() API.
</span></span></pre></div>
<a id="trunkLayoutTestsfastmulticoltallimagebehaviorlrhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/multicol/tall-image-behavior-lr.html (0 => 176354)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/multicol/tall-image-behavior-lr.html                                (rev 0)
+++ trunk/LayoutTests/fast/multicol/tall-image-behavior-lr.html        2014-11-19 23:40:23 UTC (rev 176354)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;body style=&quot;-webkit-writing-mode:vertical-lr&quot;&gt;
+&lt;div style=&quot;-webkit-columns:2; width:300px; border:2px solid blue;-webkit-line-box-contain:glyphs replaced&quot;&gt;
+&lt;p&gt;This image should not be split across columns.&lt;br&gt;
+The reason it should not be split is that the line contains no
+text and so we should be willing to allow it to sit at the top of a new
+page.
+&lt;/p&gt;
+&lt;div style=&quot;display:inline-block; width:100%; height:50px;background-color:lime&quot;&gt;&lt;/div&gt;
+
+&lt;div style=&quot;display:inline-block; height:100%; width:50px;background-color:purple&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;&lt;/div&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsfastmulticoltallimagebehaviorrlhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/multicol/tall-image-behavior-rl.html (0 => 176354)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/multicol/tall-image-behavior-rl.html                                (rev 0)
+++ trunk/LayoutTests/fast/multicol/tall-image-behavior-rl.html        2014-11-19 23:40:23 UTC (rev 176354)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;body style=&quot;-webkit-writing-mode:vertical-rl&quot;&gt;
+&lt;div style=&quot;-webkit-columns:2; width:300px; border:2px solid blue;-webkit-line-box-contain:glyphs replaced&quot;&gt;
+&lt;p&gt;This image should not be split across columns.&lt;br&gt;
+The reason it should not be split is that the line contains no
+text and so we should be willing to allow it to sit at the top of a new
+page.
+&lt;/p&gt;
+&lt;div style=&quot;display:inline-block; width:100%; height:50px;background-color:lime&quot;&gt;&lt;/div&gt;
+
+&lt;div style=&quot;display:inline-block; height:100%; width:50px;background-color:purple&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;&lt;/div&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsfastmulticoltallimagebehaviorhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/multicol/tall-image-behavior.html (0 => 176354)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/multicol/tall-image-behavior.html                                (rev 0)
+++ trunk/LayoutTests/fast/multicol/tall-image-behavior.html        2014-11-19 23:40:23 UTC (rev 176354)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;div style=&quot;-webkit-columns:2; height:300px; border:2px solid blue;-webkit-line-box-contain:glyphs replaced&quot;&gt;
+&lt;p&gt;This image should not be split across columns.&lt;br&gt;
+The reason it should not be split is that the line contains no
+text and so we should be willing to allow it to sit at the top of a new
+page.
+&lt;/p&gt;
+&lt;div style=&quot;display:inline-block; height:100%; width:50px;background-color:lime&quot;&gt;&lt;/div&gt;
+
+&lt;div style=&quot;display:inline-block; width:100%; height:50px;background-color:purple&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;&lt;/div&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacfastmulticoltallimagebehaviorexpectedpng"></a>
<div class="binary"><h4>Added: trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-expected.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-expected.png
</span><span class="cx">___________________________________________________________________
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkLayoutTestsplatformmacfastmulticoltallimagebehaviorexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-expected.txt (0 => 176354)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-expected.txt        2014-11-19 23:40:23 UTC (rev 176354)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+layer at (0,0) size 1188x585
+  RenderView at (0,0) size 800x585
+layer at (0,0) size 800x320
+  RenderBlock {HTML} at (0,0) size 800x320
+    RenderBody {BODY} at (8,8) size 784x304
+layer at (8,8) size 784x304
+  RenderBlock {DIV} at (0,0) size 784x304 [border: (2px solid #0000FF)]
+    RenderMultiColumnSet at (2,2) size 780x300
+layer at (10,10) size 382x650 backgroundClip at (0,0) size 1188x585 clip at (0,0) size 1188x585 outlineClip at (0,0) size 1188x585
+  RenderMultiColumnFlowThread at (2,2) size 382x650
+    RenderBlock {P} at (0,16) size 382x60
+      RenderText {#text} at (0,-3) size 293x18
+        text run at (0,-3) width 293: &quot;This image should not be split across columns.&quot;
+      RenderBR {BR} at (293,-3) size 0x18
+      RenderText {#text} at (0,12) size 368x48
+        text run at (0,12) width 368: &quot;The reason it should not be split is that the line contains no&quot;
+        text run at (0,27) width 367: &quot;text and so we should be willing to allow it to sit at the top&quot;
+        text run at (0,42) width 93: &quot;of a new page.&quot;
+    RenderBlock (anonymous) at (0,92) size 382x558
+      RenderBlock {DIV} at (0,208) size 50x300 [bgcolor=#00FF00]
+      RenderText {#text} at (0,0) size 0x0
+      RenderBlock {DIV} at (0,508) size 382x50 [bgcolor=#800080]
+      RenderText {#text} at (0,0) size 0x0
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacfastmulticoltallimagebehaviorlrexpectedpng"></a>
<div class="binary"><h4>Added: trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-lr-expected.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-lr-expected.png
</span><span class="cx">___________________________________________________________________
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkLayoutTestsplatformmacfastmulticoltallimagebehaviorlrexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-lr-expected.txt (0 => 176354)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-lr-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-lr-expected.txt        2014-11-19 23:40:23 UTC (rev 176354)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+layer at (0,0) size 785x888
+  RenderView at (0,0) size 785x600
+layer at (0,0) size 320x600
+  RenderBlock {HTML} at (0,0) size 320x600
+    RenderBody {BODY} at (8,8) size 304x584
+layer at (8,8) size 304x584
+  RenderBlock {DIV} at (0,0) size 304x584 [border: (2px solid #0000FF)]
+    RenderMultiColumnSet at (2,2) size 300x580
+layer at (10,10) size 650x282
+  RenderMultiColumnFlowThread at (2,2) size 650x282
+    RenderBlock {P} at (16,0) size 108x282
+      RenderText {#text} at (0,0) size 36x232
+        text run at (0,0) width 232: &quot;This image should not be split across&quot;
+        text run at (18,0) width 57: &quot;columns.&quot;
+      RenderBR {BR} at (18,57) size 18x0
+      RenderText {#text} at (36,0) size 72x266
+        text run at (36,0) width 265: &quot;The reason it should not be split is that the&quot;
+        text run at (54,0) width 259: &quot;line contains no text and so we should be&quot;
+        text run at (72,0) width 266: &quot;willing to allow it to sit at the top of a new&quot;
+        text run at (90,0) width 34: &quot;page.&quot;
+    RenderBlock (anonymous) at (140,0) size 510x282
+      RenderBlock {DIV} at (160,0) size 300x50 [bgcolor=#00FF00]
+      RenderText {#text} at (0,0) size 0x0
+      RenderBlock {DIV} at (464,0) size 50x282 [bgcolor=#800080]
+      RenderText {#text} at (0,0) size 0x0
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacfastmulticoltallimagebehaviorrlexpectedpng"></a>
<div class="binary"><h4>Added: trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-rl-expected.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-rl-expected.png
</span><span class="cx">___________________________________________________________________
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkLayoutTestsplatformmacfastmulticoltallimagebehaviorrlexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-rl-expected.txt (0 => 176354)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-rl-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-rl-expected.txt        2014-11-19 23:40:23 UTC (rev 176354)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+layer at (0,0) size 785x888
+  RenderView at (0,0) size 785x600
+layer at (465,0) size 320x600
+  RenderBlock {HTML} at (0,0) size 320x600
+    RenderBody {BODY} at (8,8) size 304x584
+layer at (473,8) size 304x584
+  RenderBlock {DIV} at (0,0) size 304x584 [border: (2px solid #0000FF)]
+    RenderMultiColumnSet at (2,2) size 300x580
+layer at (125,10) size 650x282
+  RenderMultiColumnFlowThread at (2,2) size 650x282
+    RenderBlock {P} at (16,0) size 108x282
+      RenderText {#text} at (0,0) size 36x232
+        text run at (0,0) width 232: &quot;This image should not be split across&quot;
+        text run at (18,0) width 57: &quot;columns.&quot;
+      RenderBR {BR} at (18,57) size 18x0
+      RenderText {#text} at (36,0) size 72x266
+        text run at (36,0) width 265: &quot;The reason it should not be split is that the&quot;
+        text run at (54,0) width 259: &quot;line contains no text and so we should be&quot;
+        text run at (72,0) width 266: &quot;willing to allow it to sit at the top of a new&quot;
+        text run at (90,0) width 34: &quot;page.&quot;
+    RenderBlock (anonymous) at (140,0) size 510x282
+      RenderBlock {DIV} at (160,0) size 300x50 [bgcolor=#00FF00]
+      RenderText {#text} at (0,0) size 0x0
+      RenderBlock {DIV} at (460,0) size 50x282 [bgcolor=#800080]
+      RenderText {#text} at (0,0) size 0x0
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (176353 => 176354)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-11-19 23:36:08 UTC (rev 176353)
+++ trunk/Source/WebCore/ChangeLog        2014-11-19 23:40:23 UTC (rev 176354)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2014-11-19  David Hyatt  &lt;hyatt@apple.com&gt;
+
+        Images/replaced elements that are as tall as a page should be on their own page
+        https://bugs.webkit.org/show_bug.cgi?id=138886 - &lt;rdar://problem/18296371&gt;
+
+        Reviewed by Dean Jackson.
+
+        Added fast/multicol/tall-image-behavior.html (and RL/LR variants)
+
+        * rendering/InlineFlowBox.cpp:
+        (WebCore::InlineFlowBox::computeReplacedAndTextLineTopAndBottom):
+        * rendering/InlineFlowBox.h:
+        Add a new method that computes the line top and line bottom ignoring all margins,
+        overflow and line-height. This allows us to see if a line that is taller than a page
+        can be made to fit if we ignored margins and unused descent.
+
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::adjustLinePositionForPagination):
+        Call the new helper function, computeReplacedAndTextLineTopAndBottom and push
+        to a new page if we see that we can fit on a page by ourselves without blank space
+        included.
+
</ins><span class="cx"> 2014-11-18  Ada Chan  &lt;adachan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Take Web Audio into account for the Page::isPlayingAudio() API.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingInlineFlowBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/InlineFlowBox.cpp (176353 => 176354)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/InlineFlowBox.cpp        2014-11-19 23:36:08 UTC (rev 176353)
+++ trunk/Source/WebCore/rendering/InlineFlowBox.cpp        2014-11-19 23:40:23 UTC (rev 176354)
</span><span class="lines">@@ -1636,6 +1636,20 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void InlineFlowBox::computeReplacedAndTextLineTopAndBottom(LayoutUnit&amp; lineTop, LayoutUnit&amp; lineBottom) const
+{
+    for (const auto* box = firstChild(); box; box = box-&gt;nextOnLine()) {
+        if (is&lt;InlineFlowBox&gt;(*box))
+            downcast&lt;InlineFlowBox&gt;(*box).computeReplacedAndTextLineTopAndBottom(lineTop, lineBottom);
+        else {
+            if (box-&gt;logicalTop() &lt; lineTop)
+                lineTop = box-&gt;logicalTop();
+            if (box-&gt;logicalBottom() &gt; lineBottom)
+                lineBottom = box-&gt;logicalBottom();
+        }
+    }
+}
+
</ins><span class="cx"> #ifndef NDEBUG
</span><span class="cx"> 
</span><span class="cx"> const char* InlineFlowBox::boxName() const
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingInlineFlowBoxh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/InlineFlowBox.h (176353 => 176354)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/InlineFlowBox.h        2014-11-19 23:36:08 UTC (rev 176353)
+++ trunk/Source/WebCore/rendering/InlineFlowBox.h        2014-11-19 23:40:23 UTC (rev 176354)
</span><span class="lines">@@ -291,6 +291,8 @@
</span><span class="cx">             parent()-&gt;clearDescendantsHaveSameLineHeightAndBaseline();
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    void computeReplacedAndTextLineTopAndBottom(LayoutUnit&amp; lineTop, LayoutUnit&amp; lineBottom) const;
+    
</ins><span class="cx"> private:
</span><span class="cx">     virtual bool isInlineFlowBox() const override final { return true; }
</span><span class="cx">     void boxModelObject() const = delete;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockFlowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (176353 => 176354)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp        2014-11-19 23:36:08 UTC (rev 176353)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp        2014-11-19 23:40:23 UTC (rev 176354)
</span><span class="lines">@@ -1640,11 +1640,28 @@
</span><span class="cx">     bool hasUniformPageLogicalHeight = !flowThread || flowThread-&gt;regionsHaveUniformLogicalHeight();
</span><span class="cx">     // If lineHeight is greater than pageLogicalHeight, but logicalVisualOverflow.height() still fits, we are
</span><span class="cx">     // still going to add a strut, so that the visible overflow fits on a single page.
</span><del>-    if (!pageLogicalHeight || (hasUniformPageLogicalHeight &amp;&amp; logicalVisualOverflow.height() &gt; pageLogicalHeight)
-        || !hasNextPage(logicalOffset))
</del><ins>+    if (!pageLogicalHeight || !hasNextPage(logicalOffset)) {
</ins><span class="cx">         // FIXME: In case the line aligns with the top of the page (or it's slightly shifted downwards) it will not be marked as the first line in the page.
</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><ins>+    }
+
+    if (hasUniformPageLogicalHeight &amp;&amp; logicalVisualOverflow.height() &gt; pageLogicalHeight) {
+        // We are so tall that we are bigger than a page. Before we give up and just leave the line where it is, try drilling into the
+        // line and computing a new height that excludes anything we consider &quot;blank space&quot;. We will discard margins, descent, and even overflow. If we are
+        // able to fit with the blank space and overflow excluded, we will give the line its own page with the highest non-blank element being aligned with the
+        // top of the page.
+        // FIXME: We are still honoring gigantic margins, which does leave open the possibility of blank pages caused by this heuristic. It remains to be seen whether or not
+        // this will be a real-world issue. For now we don't try to deal with this problem.
+        logicalOffset = intMaxForLayoutUnit;
+        logicalBottom = intMinForLayoutUnit;
+        lineBox-&gt;computeReplacedAndTextLineTopAndBottom(logicalOffset, logicalBottom);
+        lineHeight = logicalBottom - logicalOffset;
+        if (logicalOffset == intMaxForLayoutUnit || lineHeight &gt; pageLogicalHeight)
+            return; // Give up. We're genuinely too big even after excluding blank space and overflow.
+        pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
+    }
+    
</ins><span class="cx">     LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logicalOffset, ExcludePageBoundary);
</span><span class="cx">     overflowsRegion = (lineHeight &gt; remainingLogicalHeight);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>