Title: [166938] trunk
Revision
166938
Author
commit-qu...@webkit.org
Date
2014-04-08 11:19:47 -0700 (Tue, 08 Apr 2014)

Log Message

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

Patch by Morten Stenshorne <msten...@opera.com> 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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (166937 => 166938)


--- trunk/LayoutTests/ChangeLog	2014-04-08 18:06:11 UTC (rev 166937)
+++ trunk/LayoutTests/ChangeLog	2014-04-08 18:19:47 UTC (rev 166938)
@@ -1,3 +1,17 @@
+2014-04-08  Morten Stenshorne  <msten...@opera.com>
+
+        [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.
+
 2014-04-07  Brent Fulgham  <bfulg...@apple.com>
 
         [WebVTT] Begin Enabling W3C VTT Tests

Added: trunk/LayoutTests/fast/multicol/break-in-scrollable-expected.html (0 => 166938)


--- 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)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>Forced break inside scrollable container</title>
+        <script>
+            if (window.internals)
+                internals.settings.setRegionBasedColumnsEnabled(true);
+        </script>
+    </head>
+    <body>
+        <p>The word 'PASS' should be seen on the left below. The scrollbars shouldn't be scrollable.</p>
+        <div style="-webkit-columns:2; columns:2; orphans:1; widows:1;">
+            <div style="overflow:scroll; height:10em;">
+                &nbsp;
+                <div>PASS</div>
+            </div>
+        </div>
+    </body>
+</html>

Added: trunk/LayoutTests/fast/multicol/break-in-scrollable.html (0 => 166938)


--- 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)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>Forced break inside scrollable container</title>
+        <script>
+            if (window.internals)
+                internals.settings.setRegionBasedColumnsEnabled(true);
+        </script>
+    </head>
+    <body>
+        <p>The word 'PASS' should be seen on the left below. The scrollbars shouldn't be scrollable.</p>
+        <div style="-webkit-columns:2; columns:2; orphans:1; widows:1;">
+            <div style="overflow:scroll; height:10em;">
+                &nbsp;
+                <div style="-webkit-column-break-before:always; break-before:column;">PASS</div>
+            </div>
+        </div>
+    </body>
+</html>

Added: trunk/LayoutTests/fast/multicol/newmulticol/leading-and-trailing-margin-expected.html (0 => 166938)


--- 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)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>Leading and trailing margin</title>
+        <script>
+            if (window.internals)
+                internals.settings.setRegionBasedColumnsEnabled(true);
+        </script>
+    </head>
+    <body>
+        <p>There should be no scrollbars.</p>
+    </body>
+</html>

Added: trunk/LayoutTests/fast/multicol/newmulticol/leading-and-trailing-margin.html (0 => 166938)


--- 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)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>Leading and trailing margin</title>
+        <script>
+            if (window.internals)
+                internals.settings.setRegionBasedColumnsEnabled(true);
+        </script>
+    </head>
+    <body>
+        <p>There should be no scrollbars.</p>
+        <div style="-webkit-columns:3; columns:3;">
+            <div style="margin-top:1em; margin-bottom:10em;">&nbsp;</div>
+        </div>
+    </body>
+</html>

Added: trunk/LayoutTests/fast/multicol/newmulticol/leading-margin-expected.html (0 => 166938)


--- 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)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>Leading margins</title>
+    </head>
+    <body>
+        <p>There should be no scrollbars.</p>
+    </body>
+</html>

Added: trunk/LayoutTests/fast/multicol/newmulticol/leading-margin.html (0 => 166938)


--- 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)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>Leading margins</title>
+        <script>
+            if (window.internals)
+                internals.settings.setRegionBasedColumnsEnabled(true);
+        </script>
+        <style>
+            .test { margin-top:100px; border:2px solid transparent; }
+        </style>
+    </head>
+    <body>
+        <p>There should be no scrollbars.</p>
+        <div style="-webkit-column-count:2; column-count:2;">
+            <div class="test"></div>
+            <div class="test"></div>
+            <div class="test"></div>
+        </div>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (166937 => 166938)


--- 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)
@@ -1,3 +1,33 @@
+2014-04-08  Morten Stenshorne  <msten...@opera.com>
+
+        [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:
+
 2014-04-07  Dean Jackson  <d...@apple.com>
 
         Allow elements to register for changes in page scale

Modified: trunk/Source/WebCore/rendering/LayoutState.cpp (166937 => 166938)


--- 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)
@@ -88,6 +88,7 @@
         m_pageOffset = LayoutSize(m_layoutOffset.width() + (!isFlipped ? renderer->borderLeft() + renderer->paddingLeft() : renderer->borderRight() + renderer->paddingRight()),
                                m_layoutOffset.height() + (!isFlipped ? renderer->borderTop() + renderer->paddingTop() : renderer->borderBottom() + renderer->paddingBottom()));
         m_pageLogicalHeightChanged = pageLogicalHeightChanged;
+        m_isPaginated = true;
     } else {
         // If we don't establish a new page height, then propagate the old page height and offset down.
         m_pageLogicalHeight = m_next->m_pageLogicalHeight;
@@ -96,8 +97,11 @@
         
         // Disable pagination for objects we don't support. For now this includes overflow:scroll/auto, inline blocks and
         // writing mode roots.
-        if (renderer->isUnsplittableForPagination())
+        if (renderer->isUnsplittableForPagination()) {
             m_pageLogicalHeight = 0;
+            m_isPaginated = false;
+        } else
+            m_isPaginated = m_pageLogicalHeight || m_next->m_columnInfo || renderer->flowThreadContainingBlock();
     }
     
     // Propagate line grid information.
@@ -111,8 +115,6 @@
     m_layoutDeltaXSaturated = m_next->m_layoutDeltaXSaturated;
     m_layoutDeltaYSaturated = m_next->m_layoutDeltaYSaturated;
 #endif
-    
-    m_isPaginated = m_pageLogicalHeight || m_columnInfo || renderer->isRenderFlowThread();
 
     if (lineGrid() && (lineGrid()->style().writingMode() == renderer->style().writingMode()) && renderer->isRenderBlock())
         toRenderBlock(renderer)->computeLineGridPaginationOrigin(*this);

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (166937 => 166938)


--- 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)
@@ -3548,8 +3548,20 @@
 
         colInfo->setPaginationUnit(paginationUnit());
     } else if (isRenderFlowThread()) {
-        pageLogicalHeight = 1; // This is just a hack to always make sure we have a page logical height.
-        pageLogicalHeightChanged = toRenderFlowThread(this)->pageLogicalSizeChanged();
+        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->isPageLogicalHeightKnown() ? LayoutUnit(1) : LayoutUnit(0);
+
+        pageLogicalHeightChanged = flowThread->pageLogicalSizeChanged();
     }
 }
 

Modified: trunk/Source/WebCore/rendering/RenderFlowThread.h (166937 => 166938)


--- 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)
@@ -138,6 +138,7 @@
     virtual bool addForcedRegionBreak(const RenderBlock*, LayoutUnit, RenderBox* breakChild, bool isBefore, LayoutUnit* offsetBreakAdjustment = 0);
     void applyBreakAfterContent(LayoutUnit);
 
+    virtual bool isPageLogicalHeightKnown() const { return true; }
     bool pageLogicalSizeChanged() const { return m_pageLogicalSizeChanged; }
 
     bool hasAutoLogicalHeightRegions() const { ASSERT(isAutoLogicalHeightRegionsCountConsistent()); return m_autoLogicalHeightRegionsCount; }

Modified: trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp (166937 => 166938)


--- 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)
@@ -211,4 +211,14 @@
     return renderRegion;
 }
 
+bool RenderMultiColumnFlowThread::isPageLogicalHeightKnown() const
+{
+    for (RenderBox* renderer = parentBox()->lastChildBox(); renderer; renderer = renderer->previousSiblingBox()) {
+        if (renderer->isRenderMultiColumnSet())
+            return toRenderMultiColumnSet(renderer)->computedColumnHeight();
+    }
+    // A column set hasn't been created yet. Height may already be known if column-fill is 'auto', though.
+    return !requiresBalancing();
 }
+
+}

Modified: trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.h (166937 => 166938)


--- 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)
@@ -73,6 +73,7 @@
     virtual void setPageBreak(const RenderBlock*, LayoutUnit offset, LayoutUnit spaceShortage) override;
     virtual void updateMinimumPageHeight(const RenderBlock*, LayoutUnit offset, LayoutUnit minHeight) override;
     virtual bool addForcedRegionBreak(const RenderBlock*, LayoutUnit, RenderBox* breakChild, bool isBefore, LayoutUnit* offsetBreakAdjustment = 0) override;
+    virtual bool isPageLogicalHeightKnown() const override;
 
 private:
     unsigned m_columnCount;   // The default column count/width that are based off our containing block width. These values represent only the default,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to