Title: [176354] trunk
Revision
176354
Author
[email protected]
Date
2014-11-19 15:40:23 -0800 (Wed, 19 Nov 2014)

Log Message

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 - <rdar://problem/18296371>

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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (176353 => 176354)


--- trunk/LayoutTests/ChangeLog	2014-11-19 23:36:08 UTC (rev 176353)
+++ trunk/LayoutTests/ChangeLog	2014-11-19 23:40:23 UTC (rev 176354)
@@ -1,3 +1,20 @@
+2014-11-19  David Hyatt  <[email protected]>
+
+        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 - <rdar://problem/18296371>
+
+        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.
+
 2014-11-18  Ada Chan  <[email protected]>
 
         Take Web Audio into account for the Page::isPlayingAudio() API.

Added: trunk/LayoutTests/fast/multicol/tall-image-behavior-lr.html (0 => 176354)


--- 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)
@@ -0,0 +1,12 @@
+<!doctype html>
+<body style="-webkit-writing-mode:vertical-lr">
+<div style="-webkit-columns:2; width:300px; border:2px solid blue;-webkit-line-box-contain:glyphs replaced">
+<p>This image should not be split across columns.<br>
+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.
+</p>
+<div style="display:inline-block; width:100%; height:50px;background-color:lime"></div>
+
+<div style="display:inline-block; height:100%; width:50px;background-color:purple"></div>
+</div></div>
\ No newline at end of file

Added: trunk/LayoutTests/fast/multicol/tall-image-behavior-rl.html (0 => 176354)


--- 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)
@@ -0,0 +1,12 @@
+<!doctype html>
+<body style="-webkit-writing-mode:vertical-rl">
+<div style="-webkit-columns:2; width:300px; border:2px solid blue;-webkit-line-box-contain:glyphs replaced">
+<p>This image should not be split across columns.<br>
+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.
+</p>
+<div style="display:inline-block; width:100%; height:50px;background-color:lime"></div>
+
+<div style="display:inline-block; height:100%; width:50px;background-color:purple"></div>
+</div></div>
\ No newline at end of file

Added: trunk/LayoutTests/fast/multicol/tall-image-behavior.html (0 => 176354)


--- 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)
@@ -0,0 +1,11 @@
+<!doctype html>
+<div style="-webkit-columns:2; height:300px; border:2px solid blue;-webkit-line-box-contain:glyphs replaced">
+<p>This image should not be split across columns.<br>
+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.
+</p>
+<div style="display:inline-block; height:100%; width:50px;background-color:lime"></div>
+
+<div style="display:inline-block; width:100%; height:50px;background-color:purple"></div>
+</div></div>
\ No newline at end of file

Added: trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-expected.txt (0 => 176354)


--- 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)
@@ -0,0 +1,23 @@
+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: "This image should not be split across columns."
+      RenderBR {BR} at (293,-3) size 0x18
+      RenderText {#text} at (0,12) size 368x48
+        text run at (0,12) width 368: "The reason it should not be split is that the line contains no"
+        text run at (0,27) width 367: "text and so we should be willing to allow it to sit at the top"
+        text run at (0,42) width 93: "of a new page."
+    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

Added: trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-lr-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-lr-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-lr-expected.txt (0 => 176354)


--- 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)
@@ -0,0 +1,25 @@
+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: "This image should not be split across"
+        text run at (18,0) width 57: "columns."
+      RenderBR {BR} at (18,57) size 18x0
+      RenderText {#text} at (36,0) size 72x266
+        text run at (36,0) width 265: "The reason it should not be split is that the"
+        text run at (54,0) width 259: "line contains no text and so we should be"
+        text run at (72,0) width 266: "willing to allow it to sit at the top of a new"
+        text run at (90,0) width 34: "page."
+    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

Added: trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-rl-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-rl-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/platform/mac/fast/multicol/tall-image-behavior-rl-expected.txt (0 => 176354)


--- 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)
@@ -0,0 +1,25 @@
+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: "This image should not be split across"
+        text run at (18,0) width 57: "columns."
+      RenderBR {BR} at (18,57) size 18x0
+      RenderText {#text} at (36,0) size 72x266
+        text run at (36,0) width 265: "The reason it should not be split is that the"
+        text run at (54,0) width 259: "line contains no text and so we should be"
+        text run at (72,0) width 266: "willing to allow it to sit at the top of a new"
+        text run at (90,0) width 34: "page."
+    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

Modified: trunk/Source/WebCore/ChangeLog (176353 => 176354)


--- 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)
@@ -1,3 +1,25 @@
+2014-11-19  David Hyatt  <[email protected]>
+
+        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 - <rdar://problem/18296371>
+
+        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.
+
 2014-11-18  Ada Chan  <[email protected]>
 
         Take Web Audio into account for the Page::isPlayingAudio() API.

Modified: trunk/Source/WebCore/rendering/InlineFlowBox.cpp (176353 => 176354)


--- 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)
@@ -1636,6 +1636,20 @@
     }
 }
 
+void InlineFlowBox::computeReplacedAndTextLineTopAndBottom(LayoutUnit& lineTop, LayoutUnit& lineBottom) const
+{
+    for (const auto* box = firstChild(); box; box = box->nextOnLine()) {
+        if (is<InlineFlowBox>(*box))
+            downcast<InlineFlowBox>(*box).computeReplacedAndTextLineTopAndBottom(lineTop, lineBottom);
+        else {
+            if (box->logicalTop() < lineTop)
+                lineTop = box->logicalTop();
+            if (box->logicalBottom() > lineBottom)
+                lineBottom = box->logicalBottom();
+        }
+    }
+}
+
 #ifndef NDEBUG
 
 const char* InlineFlowBox::boxName() const

Modified: trunk/Source/WebCore/rendering/InlineFlowBox.h (176353 => 176354)


--- 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)
@@ -291,6 +291,8 @@
             parent()->clearDescendantsHaveSameLineHeightAndBaseline();
     }
 
+    void computeReplacedAndTextLineTopAndBottom(LayoutUnit& lineTop, LayoutUnit& lineBottom) const;
+    
 private:
     virtual bool isInlineFlowBox() const override final { return true; }
     void boxModelObject() const = delete;

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (176353 => 176354)


--- 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)
@@ -1640,11 +1640,28 @@
     bool hasUniformPageLogicalHeight = !flowThread || flowThread->regionsHaveUniformLogicalHeight();
     // If lineHeight is greater than pageLogicalHeight, but logicalVisualOverflow.height() still fits, we are
     // still going to add a strut, so that the visible overflow fits on a single page.
-    if (!pageLogicalHeight || (hasUniformPageLogicalHeight && logicalVisualOverflow.height() > pageLogicalHeight)
-        || !hasNextPage(logicalOffset))
+    if (!pageLogicalHeight || !hasNextPage(logicalOffset)) {
         // 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.
         // 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.
         return;
+    }
+
+    if (hasUniformPageLogicalHeight && logicalVisualOverflow.height() > 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 "blank space". 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->computeReplacedAndTextLineTopAndBottom(logicalOffset, logicalBottom);
+        lineHeight = logicalBottom - logicalOffset;
+        if (logicalOffset == intMaxForLayoutUnit || lineHeight > pageLogicalHeight)
+            return; // Give up. We're genuinely too big even after excluding blank space and overflow.
+        pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
+    }
+    
     LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logicalOffset, ExcludePageBoundary);
     overflowsRegion = (lineHeight > remainingLogicalHeight);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to