Title: [140007] trunk
Revision
140007
Author
commit-qu...@webkit.org
Date
2013-01-17 11:15:24 -0800 (Thu, 17 Jan 2013)

Log Message

Widows and orphans test4 fails if isolated
https://bugs.webkit.org/show_bug.cgi?id=106006

Patch by Andrei Bucur <abu...@adobe.com> on 2013-01-17
Reviewed by Dean Jackson.

Source/WebCore:

To determine if the orphans condition is not respected, every time a fragmentation break is encountered adjustLinePositionForPagination() is called for the current line.
If the index on the line in the block is smaller than the number of orphans specified in the style object, the block is shifted in the next fragmentainer. The index of
the line is obtained by calling RenderBlock::lineCount. However, this only works in a full layout when lineCount() will coincidentally return the index of the line.
In subsequent layouts, during the determineStartPosition() phase, lineCount() returns all the lines in the block so the orphans condition is never triggered.
The patch modifies the lineCount() function to have two optional parameters. The first parameter is the line where lineCount should stop counting lines. The second
is an output boolean parameter indicating if the line was found or not. This change makes the lineCount() more flexible and allows retreiving the index of a
specific line (e.g. the index of the current line inside adjustLinePositionForPagination()).

Tests: fast/multicol/orphans-relayout.html

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::lineCount): See the detailed description.
(WebCore::RenderBlock::adjustLinePositionForPagination): Make use of the modified lineCount() function.
* rendering/RenderBlock.h:
(RenderBlock):

LayoutTests:

This is the "Basic Orphans" test extracted from fast/multicol/widows-and-orphans.html. It was minimized and modified to include a relayout step.

* fast/multicol/orphans-relayout-expected.txt: Added.
* fast/multicol/orphans-relayout.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (140006 => 140007)


--- trunk/LayoutTests/ChangeLog	2013-01-17 19:13:12 UTC (rev 140006)
+++ trunk/LayoutTests/ChangeLog	2013-01-17 19:15:24 UTC (rev 140007)
@@ -1,3 +1,15 @@
+2013-01-17  Andrei Bucur  <abu...@adobe.com>
+
+        Widows and orphans test4 fails if isolated
+        https://bugs.webkit.org/show_bug.cgi?id=106006
+
+        Reviewed by Dean Jackson.
+
+        This is the "Basic Orphans" test extracted from fast/multicol/widows-and-orphans.html. It was minimized and modified to include a relayout step.
+
+        * fast/multicol/orphans-relayout-expected.txt: Added.
+        * fast/multicol/orphans-relayout.html: Added.
+
 2013-01-17  Martin Robinson  <mrobin...@igalia.com>
 
         REGRESSION (r137487): Crashes in editing/execCommand/indent-paragraphs.html on GTK, EFL

Added: trunk/LayoutTests/fast/multicol/orphans-relayout-expected.txt (0 => 140007)


--- trunk/LayoutTests/fast/multicol/orphans-relayout-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/multicol/orphans-relayout-expected.txt	2013-01-17 19:15:24 UTC (rev 140007)
@@ -0,0 +1,11 @@
+Test if an element with orphans relayouts correctly. The red lines of text must be at the top of the blue rectangle. The green lines of text must be at the bottom of the blue rectangle.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS test Block 1 Line 1 is correct.
+PASS test Block 2 Line 1 is correct.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/multicol/orphans-relayout.html (0 => 140007)


--- trunk/LayoutTests/fast/multicol/orphans-relayout.html	                        (rev 0)
+++ trunk/LayoutTests/fast/multicol/orphans-relayout.html	2013-01-17 19:15:24 UTC (rev 140007)
@@ -0,0 +1,98 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<style>
+body.hide-containers .container {
+    display: none;
+}
+
+.container {
+    width: 600px;
+    height: 200px;
+    -webkit-columns: 3;
+    line-height: 20px; /* 10 lines per page */
+    font-size: 16px;
+    margin: 0 0 20px 0;
+    padding: 0;
+    overflow: hidden;
+    orphans: 2;
+}
+
+.block {
+    margin: 0 0 15px 0;
+    padding: 0;
+}
+
+.top {
+    color: red;
+}
+
+.bottom {
+    color: green;
+}
+</style>
+<script>
+
+description("Test if an element with orphans relayouts correctly. The red lines of text must be at the top of the blue rectangle. The green lines of text must be at the bottom of the blue rectangle.");
+
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+function testIsFirstInColumn(containerId, blockNumber, lineNumber)
+{
+    // Get the upper bounds of the container and line.
+    var topOfContainer = document.getElementById(containerId).getBoundingClientRect().top;
+    var topOfLine = document.getElementById(containerId + "-block-" + blockNumber + "-line-" + lineNumber).getBoundingClientRect().top;
+
+    if (Math.abs(topOfContainer - topOfLine) < 5) // Give 5 pixels to account for subpixel layout.
+        testPassed(containerId + " Block " + blockNumber + " Line " + lineNumber + " is correct.");
+    else
+        testFailed(containerId + " Block " + blockNumber + " Line " + lineNumber + " wasn't at the top of the region.");
+}
+
+function runTest()
+{
+    var container = document.getElementById("test");
+
+    document.body.offsetTop;
+
+    container.style.border = "3px solid blue"; // Modify a property that triggers a layout.
+
+    testIsFirstInColumn("test", 1, 1);
+    testIsFirstInColumn("test", 2, 1);
+
+    if (window.testRunner) {
+        // Hide all the containers and leave just the test results for text output.
+        document.body.className = "hide-containers";
+    }
+
+    isSuccessfullyParsed();
+}
+
+window.addEventListener("load", runTest, false);
+</script>
+</head>
+<body>
+    <div class="container" id="test">
+        <div class="block">
+            <span id="test-block-1-line-1" class="top">Block 1 Line 1</span><br>
+            <span id="test-block-1-line-2">Block 1 Line 2</span><br>
+            <span id="test-block-1-line-3">Block 1 Line 3</span><br>
+            <span id="test-block-1-line-4">Block 1 Line 4</span><br>
+            <span id="test-block-1-line-5">Block 1 Line 5</span><br>
+            <span id="test-block-1-line-6">Block 1 Line 6</span><br>
+            <span id="test-block-1-line-7">Block 1 Line 7</span><br>
+            <span id="test-block-1-line-8" class="bottom">Block 1 Line 8</span><br>
+        </div>
+        <div class="block">
+            <span id="test-block-2-line-1" class="top">Block 2 Line 1</span><br>
+            <span id="test-block-2-line-2">Block 2 Line 2</span><br>
+            <span id="test-block-2-line-3">Block 2 Line 3</span><br>
+            <span id="test-block-2-line-4">Block 2 Line 4</span><br>
+            <span id="test-block-2-line-5">Block 2 Line 5</span><br>
+            <span id="test-block-2-line-6">Block 2 Line 6</span><br>
+        </div>
+    </div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (140006 => 140007)


--- trunk/Source/WebCore/ChangeLog	2013-01-17 19:13:12 UTC (rev 140006)
+++ trunk/Source/WebCore/ChangeLog	2013-01-17 19:15:24 UTC (rev 140007)
@@ -1,3 +1,26 @@
+2013-01-17  Andrei Bucur  <abu...@adobe.com>
+
+        Widows and orphans test4 fails if isolated
+        https://bugs.webkit.org/show_bug.cgi?id=106006
+
+        Reviewed by Dean Jackson.
+
+        To determine if the orphans condition is not respected, every time a fragmentation break is encountered adjustLinePositionForPagination() is called for the current line.
+        If the index on the line in the block is smaller than the number of orphans specified in the style object, the block is shifted in the next fragmentainer. The index of
+        the line is obtained by calling RenderBlock::lineCount. However, this only works in a full layout when lineCount() will coincidentally return the index of the line.
+        In subsequent layouts, during the determineStartPosition() phase, lineCount() returns all the lines in the block so the orphans condition is never triggered.
+        The patch modifies the lineCount() function to have two optional parameters. The first parameter is the line where lineCount should stop counting lines. The second
+        is an output boolean parameter indicating if the line was found or not. This change makes the lineCount() more flexible and allows retreiving the index of a
+        specific line (e.g. the index of the current line inside adjustLinePositionForPagination()).
+
+        Tests: fast/multicol/orphans-relayout.html
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::lineCount): See the detailed description.
+        (WebCore::RenderBlock::adjustLinePositionForPagination): Make use of the modified lineCount() function.
+        * rendering/RenderBlock.h:
+        (RenderBlock):
+
 2013-01-17  Martin Robinson  <mrobin...@igalia.com>
 
         REGRESSION (r137487): Crashes in editing/execCommand/indent-paragraphs.html on GTK, EFL

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (140006 => 140007)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2013-01-17 19:13:12 UTC (rev 140006)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2013-01-17 19:15:24 UTC (rev 140007)
@@ -6607,17 +6607,31 @@
     return 0;
 }
 
-int RenderBlock::lineCount() const
+int RenderBlock::lineCount(const RootInlineBox* stopRootInlineBox, bool* found) const
 {
     int count = 0;
+
     if (style()->visibility() == VISIBLE) {
         if (childrenInline())
-            for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBox())
+            for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBox()) {
                 count++;
+                if (box == stopRootInlineBox) {
+                    if (found)
+                        *found = true;
+                    break;
+                }
+            }
         else
             for (RenderObject* obj = firstChild(); obj; obj = obj->nextSibling())
-                if (shouldCheckLines(obj))
-                    count += toRenderBlock(obj)->lineCount();
+                if (shouldCheckLines(obj)) {
+                    bool recursiveFound = false;
+                    count += toRenderBlock(obj)->lineCount(stopRootInlineBox, &recursiveFound);
+                    if (recursiveFound) {
+                        if (found)
+                            *found = true;
+                        break;
+                    }
+                }
     }
     return count;
 }
@@ -7171,7 +7185,7 @@
         }
         LayoutUnit totalLogicalHeight = lineHeight + max<LayoutUnit>(0, logicalOffset);
         LayoutUnit pageLogicalHeightAtNewOffset = hasUniformPageLogicalHeight ? pageLogicalHeight : pageLogicalHeightForOffset(logicalOffset + remainingLogicalHeight);
-        if (((lineBox == firstRootBox() && totalLogicalHeight < pageLogicalHeightAtNewOffset) || (!style()->hasAutoOrphans() && style()->orphans() >= lineCount()))
+        if (((lineBox == firstRootBox() && totalLogicalHeight < pageLogicalHeightAtNewOffset) || (!style()->hasAutoOrphans() && style()->orphans() >= lineCount(lineBox)))
             && !isOutOfFlowPositioned() && !isTableCell())
             setPaginationStrut(remainingLogicalHeight + max<LayoutUnit>(0, logicalOffset));
         else {

Modified: trunk/Source/WebCore/rendering/RenderBlock.h (140006 => 140007)


--- trunk/Source/WebCore/rendering/RenderBlock.h	2013-01-17 19:13:12 UTC (rev 140006)
+++ trunk/Source/WebCore/rendering/RenderBlock.h	2013-01-17 19:15:24 UTC (rev 140007)
@@ -241,7 +241,7 @@
 
     // Helper methods for computing line counts and heights for line counts.
     RootInlineBox* lineAtIndex(int) const;
-    int lineCount() const;
+    int lineCount(const RootInlineBox* = 0, bool* = 0) const;
     int heightForLineCount(int);
     void clearTruncation();
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to