Title: [162702] trunk/Source/WebCore
Revision
162702
Author
hy...@apple.com
Date
2014-01-24 09:14:22 -0800 (Fri, 24 Jan 2014)

Log Message

[New Multicolumn] Table cells and list items need to work as multicolumn blocks.
https://bugs.webkit.org/show_bug.cgi?id=127365
        
This patch is a first step towards eliminating RenderMultiColumnBlock and moving
all its functionality into RenderBlockFlow. Doing so will allow table cells, list
items and the RenderView to use the new multi-column layout.
        
Reviewed by Simon Fraser.

* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::setMultiColumnFlowThread):
* rendering/RenderBlockFlow.h:
(WebCore::RenderBlockFlow::RenderBlockFlowRareData::RenderBlockFlowRareData):
(WebCore::RenderBlockFlow::multiColumnFlowThread):
Add the flow thread pointer to the multi-column flow thread to RenderBlockFlow's
rare data. This lets us use only one pointer in the rare data to point to an object
that can hold all of the rest of the multi-column info.

* rendering/RenderMultiColumnBlock.cpp:
(WebCore::RenderMultiColumnBlock::RenderMultiColumnBlock):
Move the construction of the flow thread to the constructor. This ensures we
never have a null flow thread and lets us avoid having to null check it for
empty multi-column blocks.

(WebCore::RenderMultiColumnBlock::columnHeightAvailable):
(WebCore::RenderMultiColumnBlock::columnWidth):
(WebCore::RenderMultiColumnBlock::columnCount):
(WebCore::RenderMultiColumnBlock::updateLogicalWidthAndColumnWidth):
The above functions now call through to the multi-column flow thread for results.

(WebCore::RenderMultiColumnBlock::checkForPaginationLogicalHeightChange):
 Set the column height available on the flow thread.

(WebCore::RenderMultiColumnBlock::relayoutForPagination):
The balancing pass and guard is in the multi-column flow thread now.

(WebCore::RenderMultiColumnBlock::addChild):
Don't have to create the flow thread here any longer, since we do it up front
in the constructor of RenderMultiColumnBlock.

(WebCore::RenderMultiColumnBlock::layoutSpecialExcludedChild):
Don't need the null check of the flow thread any more.

* rendering/RenderMultiColumnBlock.h:
Change the inlined functions to not be inlined, since they need to call
RenderMultiColumnFlowThread functions now.

* rendering/RenderMultiColumnFlowThread.cpp:
(WebCore::RenderMultiColumnFlowThread::RenderMultiColumnFlowThread):
Init the new member variables we moved here from RenderMultiColumnBlock.

(WebCore::RenderMultiColumnFlowThread::computeColumnCountAndWidth):
Moved from RenderMultiColumnBlock.

* rendering/RenderMultiColumnFlowThread.h:
Add public getters/setters to the member variables so that RenderMultiColumnBlock can
still see them. Move the member variables here from RenderMultiColumnBlock.

* rendering/RenderMultiColumnSet.cpp:
(WebCore::RenderMultiColumnSet::calculateBalancedHeight):
(WebCore::RenderMultiColumnSet::prepareForLayout):
(WebCore::RenderMultiColumnSet::columnCount):
Call through to the flow thread instead.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (162701 => 162702)


--- trunk/Source/WebCore/ChangeLog	2014-01-24 16:34:24 UTC (rev 162701)
+++ trunk/Source/WebCore/ChangeLog	2014-01-24 17:14:22 UTC (rev 162702)
@@ -1,3 +1,69 @@
+2014-01-21  David Hyatt  <hy...@apple.com>
+
+        [New Multicolumn] Table cells and list items need to work as multicolumn blocks.
+        https://bugs.webkit.org/show_bug.cgi?id=127365
+        
+        This patch is a first step towards eliminating RenderMultiColumnBlock and moving
+        all its functionality into RenderBlockFlow. Doing so will allow table cells, list
+        items and the RenderView to use the new multi-column layout.
+        
+        Reviewed by Simon Fraser.
+
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::setMultiColumnFlowThread):
+        * rendering/RenderBlockFlow.h:
+        (WebCore::RenderBlockFlow::RenderBlockFlowRareData::RenderBlockFlowRareData):
+        (WebCore::RenderBlockFlow::multiColumnFlowThread):
+        Add the flow thread pointer to the multi-column flow thread to RenderBlockFlow's
+        rare data. This lets us use only one pointer in the rare data to point to an object
+        that can hold all of the rest of the multi-column info.
+
+        * rendering/RenderMultiColumnBlock.cpp:
+        (WebCore::RenderMultiColumnBlock::RenderMultiColumnBlock):
+        Move the construction of the flow thread to the constructor. This ensures we
+        never have a null flow thread and lets us avoid having to null check it for
+        empty multi-column blocks.
+
+        (WebCore::RenderMultiColumnBlock::columnHeightAvailable):
+        (WebCore::RenderMultiColumnBlock::columnWidth):
+        (WebCore::RenderMultiColumnBlock::columnCount):
+        (WebCore::RenderMultiColumnBlock::updateLogicalWidthAndColumnWidth):
+        The above functions now call through to the multi-column flow thread for results.
+
+        (WebCore::RenderMultiColumnBlock::checkForPaginationLogicalHeightChange):
+         Set the column height available on the flow thread.
+
+        (WebCore::RenderMultiColumnBlock::relayoutForPagination):
+        The balancing pass and guard is in the multi-column flow thread now.
+
+        (WebCore::RenderMultiColumnBlock::addChild):
+        Don't have to create the flow thread here any longer, since we do it up front
+        in the constructor of RenderMultiColumnBlock.
+
+        (WebCore::RenderMultiColumnBlock::layoutSpecialExcludedChild):
+        Don't need the null check of the flow thread any more.
+
+        * rendering/RenderMultiColumnBlock.h:
+        Change the inlined functions to not be inlined, since they need to call
+        RenderMultiColumnFlowThread functions now.
+
+        * rendering/RenderMultiColumnFlowThread.cpp:
+        (WebCore::RenderMultiColumnFlowThread::RenderMultiColumnFlowThread):
+        Init the new member variables we moved here from RenderMultiColumnBlock.
+
+        (WebCore::RenderMultiColumnFlowThread::computeColumnCountAndWidth):
+        Moved from RenderMultiColumnBlock.
+
+        * rendering/RenderMultiColumnFlowThread.h:
+        Add public getters/setters to the member variables so that RenderMultiColumnBlock can
+        still see them. Move the member variables here from RenderMultiColumnBlock.
+
+        * rendering/RenderMultiColumnSet.cpp:
+        (WebCore::RenderMultiColumnSet::calculateBalancedHeight):
+        (WebCore::RenderMultiColumnSet::prepareForLayout):
+        (WebCore::RenderMultiColumnSet::columnCount):
+        Call through to the flow thread instead.
+
 2014-01-24  Zan Dobersek  <zdober...@igalia.com>
 
         Unreviewed GTK build fix after r162663.

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (162701 => 162702)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2014-01-24 16:34:24 UTC (rev 162701)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2014-01-24 17:14:22 UTC (rev 162702)
@@ -2890,6 +2890,12 @@
     rareData.m_renderNamedFlowFragment = flowFragment;
 }
 
+void RenderBlockFlow::setMultiColumnFlowThread(RenderMultiColumnFlowThread* flowThread)
+{
+    RenderBlockFlowRareData& rareData = ensureRareBlockFlowData();
+    rareData.m_multiColumnFlowThread = flowThread;
+}
+
 static bool shouldCheckLines(const RenderBlockFlow& blockFlow)
 {
     return !blockFlow.isFloatingOrOutOfFlowPositioned() && !blockFlow.isRunIn() && blockFlow.style().height().isAuto();

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.h (162701 => 162702)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.h	2014-01-24 16:34:24 UTC (rev 162701)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.h	2014-01-24 17:14:22 UTC (rev 162702)
@@ -35,6 +35,7 @@
 class LineBreaker;
 class LineInfo;
 class LineWidth;
+class RenderMultiColumnFlowThread;
 class RenderNamedFlowFragment;
 class RenderRubyRun;
 
@@ -117,6 +118,7 @@
             : m_margins(positiveMarginBeforeDefault(block), negativeMarginBeforeDefault(block), positiveMarginAfterDefault(block), negativeMarginAfterDefault(block))
             , m_lineBreakToAvoidWidow(-1)
             , m_renderNamedFlowFragment(nullptr)
+            , m_multiColumnFlowThread(nullptr)
             , m_discardMarginBefore(false)
             , m_discardMarginAfter(false)
             , m_didBreakAtLineToAvoidWidow(false)
@@ -149,6 +151,8 @@
         std::unique_ptr<RootInlineBox> m_lineGridBox;
         RenderNamedFlowFragment* m_renderNamedFlowFragment;
 
+        RenderMultiColumnFlowThread* m_multiColumnFlowThread;
+        
         bool m_discardMarginBefore : 1;
         bool m_discardMarginAfter : 1;
         bool m_didBreakAtLineToAvoidWidow : 1;
@@ -270,6 +274,9 @@
     RenderNamedFlowFragment* renderNamedFlowFragment() const { return hasRareBlockFlowData() ? rareBlockFlowData()->m_renderNamedFlowFragment : nullptr; }
     void setRenderNamedFlowFragment(RenderNamedFlowFragment*);
 
+    RenderMultiColumnFlowThread* multiColumnFlowThread() const { return hasRareBlockFlowData() ? rareBlockFlowData()->m_multiColumnFlowThread : nullptr; }
+    void setMultiColumnFlowThread(RenderMultiColumnFlowThread*);
+    
     bool containsFloats() const override { return m_floatingObjects && !m_floatingObjects->set().isEmpty(); }
     bool containsFloat(RenderBox&) const;
 

Modified: trunk/Source/WebCore/rendering/RenderMultiColumnBlock.cpp (162701 => 162702)


--- trunk/Source/WebCore/rendering/RenderMultiColumnBlock.cpp	2014-01-24 16:34:24 UTC (rev 162701)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnBlock.cpp	2014-01-24 17:14:22 UTC (rev 162702)
@@ -33,56 +33,47 @@
 
 namespace WebCore {
 
-RenderMultiColumnBlock::RenderMultiColumnBlock(Element& element, PassRef<RenderStyle> style)
-    : RenderBlockFlow(element, std::move(style))
-    , m_flowThread(0)
-    , m_columnCount(1)
-    , m_columnWidth(0)
-    , m_columnHeightAvailable(0)
-    , m_inBalancingPass(false)
-    , m_needsRebalancing(false)
+RenderMultiColumnBlock::RenderMultiColumnBlock(Element& element, PassRef<RenderStyle> stylePtr)
+    : RenderBlockFlow(element, std::move(stylePtr))
 {
+    setChildrenInline(false);
+    RenderMultiColumnFlowThread* flowThread = new RenderMultiColumnFlowThread(document(), RenderStyle::createAnonymousStyleWithDisplay(&style(), BLOCK));
+    flowThread->initializeStyle();
+    RenderBlockFlow::addChild(flowThread);
+    setMultiColumnFlowThread(flowThread);
 }
 
-void RenderMultiColumnBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
+bool RenderMultiColumnBlock::requiresBalancing() const
 {
-    RenderBlockFlow::styleDidChange(diff, oldStyle);
-    for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox())
-        child->setStyle(RenderStyle::createAnonymousStyleWithDisplay(&style(), BLOCK));
+    return multiColumnFlowThread()->requiresBalancing();
 }
 
-void RenderMultiColumnBlock::computeColumnCountAndWidth()
+LayoutUnit RenderMultiColumnBlock::columnHeightAvailable() const
 {
-    // Calculate our column width and column count.
-    // FIXME: Can overflow on fast/block/float/float-not-removed-from-next-sibling4.html, see https://bugs.webkit.org/show_bug.cgi?id=68744
-    m_columnCount = 1;
-    m_columnWidth = contentLogicalWidth();
-    
-    ASSERT(!style().hasAutoColumnCount() || !style().hasAutoColumnWidth());
+    return multiColumnFlowThread()->columnHeightAvailable();
+}
 
-    LayoutUnit availWidth = m_columnWidth;
-    LayoutUnit colGap = columnGap();
-    LayoutUnit colWidth = std::max<LayoutUnit>(1, LayoutUnit(style().columnWidth()));
-    int colCount = std::max<int>(1, style().columnCount());
+LayoutUnit RenderMultiColumnBlock::columnWidth() const
+{
+    return multiColumnFlowThread()->columnWidth();
+}
 
-    if (style().hasAutoColumnWidth() && !style().hasAutoColumnCount()) {
-        m_columnCount = colCount;
-        m_columnWidth = std::max<LayoutUnit>(0, (availWidth - ((m_columnCount - 1) * colGap)) / m_columnCount);
-    } else if (!style().hasAutoColumnWidth() && style().hasAutoColumnCount()) {
-        m_columnCount = std::max<LayoutUnit>(1, (availWidth + colGap) / (colWidth + colGap));
-        m_columnWidth = ((availWidth + colGap) / m_columnCount) - colGap;
-    } else {
-        m_columnCount = std::max<LayoutUnit>(std::min<LayoutUnit>(colCount, (availWidth + colGap) / (colWidth + colGap)), 1);
-        m_columnWidth = ((availWidth + colGap) / m_columnCount) - colGap;
-    }
+unsigned RenderMultiColumnBlock::columnCount() const
+{
+    return multiColumnFlowThread()->columnCount();
 }
+    
+void RenderMultiColumnBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
+{
+    RenderBlockFlow::styleDidChange(diff, oldStyle);
+    for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox())
+        child->setStyle(RenderStyle::createAnonymousStyleWithDisplay(&style(), BLOCK));
+}
 
 bool RenderMultiColumnBlock::updateLogicalWidthAndColumnWidth()
 {
     bool relayoutChildren = RenderBlockFlow::updateLogicalWidthAndColumnWidth();
-    LayoutUnit oldColumnWidth = m_columnWidth;
-    computeColumnCountAndWidth();
-    if (m_columnWidth != oldColumnWidth)
+    if (multiColumnFlowThread()->computeColumnCountAndWidth())
         relayoutChildren = true;
     return relayoutChildren;
 }
@@ -91,16 +82,17 @@
 {
     // We don't actually update any of the variables. We just subclassed to adjust our column height.
     updateLogicalHeight();
-    m_columnHeightAvailable = std::max<LayoutUnit>(contentLogicalHeight(), 0);
+    multiColumnFlowThread()->setColumnHeightAvailable(std::max<LayoutUnit>(contentLogicalHeight(), 0));
     setLogicalHeight(0);
 }
 
 bool RenderMultiColumnBlock::relayoutForPagination(bool, LayoutUnit, LayoutStateMaintainer& statePusher)
 {
-    if (m_inBalancingPass || !m_needsRebalancing)
+    if (!multiColumnFlowThread()->shouldRelayoutForPagination())
         return false;
-    m_needsRebalancing = false;
-    m_inBalancingPass = true; // Prevent re-entering this method (and recursion into layout).
+    
+    multiColumnFlowThread()->setNeedsRebalancing(false);
+    multiColumnFlowThread()->setInBalancingPass(true); // Prevent re-entering this method (and recursion into layout).
 
     bool needsRelayout;
     bool neededRelayout = false;
@@ -113,7 +105,7 @@
         // columns, unless we have a bug.
         needsRelayout = false;
         for (RenderBox* childBox = firstChildBox(); childBox; childBox = childBox->nextSiblingBox())
-            if (childBox != m_flowThread && childBox->isRenderMultiColumnSet()) {
+            if (childBox != multiColumnFlowThread() && childBox->isRenderMultiColumnSet()) {
                 RenderMultiColumnSet* multicolSet = toRenderMultiColumnSet(childBox);
                 if (multicolSet->recalculateBalancedHeight(firstPass)) {
                     multicolSet->setChildNeedsLayout(MarkOnlyThis);
@@ -124,7 +116,7 @@
         if (needsRelayout) {
             // Layout again. Column balancing resulted in a new height.
             neededRelayout = true;
-            m_flowThread->setChildNeedsLayout(MarkOnlyThis);
+            multiColumnFlowThread()->setChildNeedsLayout(MarkOnlyThis);
             setChildNeedsLayout(MarkOnlyThis);
             if (firstPass)
                 statePusher.pop();
@@ -132,47 +124,41 @@
         }
         firstPass = false;
     } while (needsRelayout);
-    m_inBalancingPass = false;
+    
+    multiColumnFlowThread()->setInBalancingPass(false);
+    
     return neededRelayout;
 }
 
 void RenderMultiColumnBlock::addChild(RenderObject* newChild, RenderObject* beforeChild)
 {
-    if (!m_flowThread) {
-        m_flowThread = new RenderMultiColumnFlowThread(document(), RenderStyle::createAnonymousStyleWithDisplay(&style(), BLOCK));
-        m_flowThread->initializeStyle();
-        RenderBlockFlow::addChild(m_flowThread);
-    }
-    m_flowThread->addChild(newChild, beforeChild);
+    multiColumnFlowThread()->addChild(newChild, beforeChild);
 }
     
 RenderObject* RenderMultiColumnBlock::layoutSpecialExcludedChild(bool relayoutChildren)
 {
-    if (!m_flowThread)
-        return 0;
-    
     // Update the dimensions of our regions before we lay out the flow thread.
     // FIXME: Eventually this is going to get way more complicated, and we will be destroying regions
     // instead of trying to keep them around.
     bool shouldInvalidateRegions = false;
     for (RenderBox* childBox = firstChildBox(); childBox; childBox = childBox->nextSiblingBox()) {
-        if (childBox == m_flowThread)
+        if (childBox == multiColumnFlowThread())
             continue;
 
         if (relayoutChildren || childBox->needsLayout()) {
-            if (!m_inBalancingPass && childBox->isRenderMultiColumnSet())
+            if (!multiColumnFlowThread()->inBalancingPass() && childBox->isRenderMultiColumnSet())
                 toRenderMultiColumnSet(childBox)->prepareForLayout();
             shouldInvalidateRegions = true;
         }
     }
     
     if (shouldInvalidateRegions)
-        m_flowThread->invalidateRegions();
+        multiColumnFlowThread()->invalidateRegions();
 
     if (relayoutChildren)
-        m_flowThread->setChildNeedsLayout(MarkOnlyThis);
+        multiColumnFlowThread()->setChildNeedsLayout(MarkOnlyThis);
     
-    if (requiresBalancing()) {
+    if (multiColumnFlowThread()->requiresBalancing()) {
         // At the end of multicol layout, relayoutForPagination() is called unconditionally, but if
         // no children are to be laid out (e.g. fixed width with layout already being up-to-date),
         // we want to prevent it from doing any work, so that the column balancing machinery doesn't
@@ -181,14 +167,14 @@
         // are actually required to guarantee this. The calculation of implicit breaks needs to be
         // preceded by a proper layout pass, since it's layout that sets up content runs, and the
         // runs get deleted right after every pass.
-        m_needsRebalancing = shouldInvalidateRegions || m_flowThread->needsLayout();
+        multiColumnFlowThread()->setNeedsRebalancing(shouldInvalidateRegions || multiColumnFlowThread()->needsLayout());
     }
 
-    setLogicalTopForChild(*m_flowThread, borderAndPaddingBefore());
-    m_flowThread->layoutIfNeeded();
-    determineLogicalLeftPositionForChild(*m_flowThread);
+    setLogicalTopForChild(*multiColumnFlowThread(), borderAndPaddingBefore());
+    multiColumnFlowThread()->layoutIfNeeded();
+    determineLogicalLeftPositionForChild(*multiColumnFlowThread());
     
-    return m_flowThread;
+    return multiColumnFlowThread();
 }
 
 const char* RenderMultiColumnBlock::renderName() const

Modified: trunk/Source/WebCore/rendering/RenderMultiColumnBlock.h (162701 => 162702)


--- trunk/Source/WebCore/rendering/RenderMultiColumnBlock.h	2014-01-24 16:34:24 UTC (rev 162701)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnBlock.h	2014-01-24 17:14:22 UTC (rev 162702)
@@ -38,15 +38,13 @@
     RenderMultiColumnBlock(Element&, PassRef<RenderStyle>);
     Element& element() const { return toElement(nodeForNonAnonymous()); }
 
-    LayoutUnit columnHeightAvailable() const { return m_columnHeightAvailable; }
+    LayoutUnit columnHeightAvailable() const;
 
-    LayoutUnit columnWidth() const { return m_columnWidth; }
-    unsigned columnCount() const { return m_columnCount; }
+    LayoutUnit columnWidth() const;
+    unsigned columnCount() const;
 
-    RenderMultiColumnFlowThread* flowThread() const { return m_flowThread; }
-
-    bool requiresBalancing() const { return !m_columnHeightAvailable || style().columnFill() == ColumnFillBalance; }
-
+    bool requiresBalancing() const;
+    
 private:
     virtual bool isRenderMultiColumnBlock() const { return true; }
     virtual const char* renderName() const;
@@ -64,14 +62,6 @@
     void computeColumnCountAndWidth();
 
     void ensureColumnSets();
-
-    RenderMultiColumnFlowThread* m_flowThread;
-    unsigned m_columnCount;   // The default column count/width that are based off our containing block width. These values represent only the default,
-    LayoutUnit m_columnWidth; // since a multi-column block that is split across variable width pages or regions will have different column counts and widths in each.
-                              // These values will be cached (eventually) for multi-column blocks.
-    LayoutUnit m_columnHeightAvailable; // Total height available to columns, or 0 if auto.
-    bool m_inBalancingPass; // Set when relayouting for column balancing.
-    bool m_needsRebalancing;
 };
 
 RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnBlock, isRenderMultiColumnBlock())

Modified: trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp (162701 => 162702)


--- trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp	2014-01-24 16:34:24 UTC (rev 162701)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp	2014-01-24 17:14:22 UTC (rev 162702)
@@ -33,6 +33,11 @@
 
 RenderMultiColumnFlowThread::RenderMultiColumnFlowThread(Document& document, PassRef<RenderStyle> style)
     : RenderFlowThread(document, std::move(style))
+    , m_columnCount(1)
+    , m_columnWidth(0)
+    , m_columnHeightAvailable(0)
+    , m_inBalancingPass(false)
+    , m_needsRebalancing(false)
 {
     setFlowThreadState(InsideInFlowThread);
 }
@@ -59,6 +64,40 @@
     return parentBlock->columnWidth();
 }
 
+bool RenderMultiColumnFlowThread::computeColumnCountAndWidth()
+{
+    RenderBlock* columnBlock = toRenderBlock(parent());
+    
+    LayoutUnit oldColumnWidth = m_columnWidth;
+    
+    // Calculate our column width and column count.
+    // FIXME: Can overflow on fast/block/float/float-not-removed-from-next-sibling4.html, see https://bugs.webkit.org/show_bug.cgi?id=68744
+    m_columnCount = 1;
+    m_columnWidth = columnBlock->contentLogicalWidth();
+    
+    const RenderStyle& columnStyle = columnBlock->style();
+    
+    ASSERT(!columnStyle.hasAutoColumnCount() || !columnStyle.hasAutoColumnWidth());
+
+    LayoutUnit availWidth = m_columnWidth;
+    LayoutUnit colGap = columnBlock->columnGap();
+    LayoutUnit colWidth = std::max<LayoutUnit>(1, LayoutUnit(columnStyle.columnWidth()));
+    int colCount = std::max<int>(1, columnStyle.columnCount());
+
+    if (columnStyle.hasAutoColumnWidth() && !columnStyle.hasAutoColumnCount()) {
+        m_columnCount = colCount;
+        m_columnWidth = std::max<LayoutUnit>(0, (availWidth - ((m_columnCount - 1) * colGap)) / m_columnCount);
+    } else if (!columnStyle.hasAutoColumnWidth() && columnStyle.hasAutoColumnCount()) {
+        m_columnCount = std::max<LayoutUnit>(1, (availWidth + colGap) / (colWidth + colGap));
+        m_columnWidth = ((availWidth + colGap) / m_columnCount) - colGap;
+    } else {
+        m_columnCount = std::max<LayoutUnit>(std::min<LayoutUnit>(colCount, (availWidth + colGap) / (colWidth + colGap)), 1);
+        m_columnWidth = ((availWidth + colGap) / m_columnCount) - colGap;
+    }
+    
+    return m_columnWidth != oldColumnWidth;
+}
+
 void RenderMultiColumnFlowThread::autoGenerateRegionsToBlockOffset(LayoutUnit /*offset*/)
 {
     // This function ensures we have the correct column set information at all times.

Modified: trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.h (162701 => 162702)


--- trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.h	2014-01-24 16:34:24 UTC (rev 162701)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.h	2014-01-24 17:14:22 UTC (rev 162702)
@@ -36,6 +36,21 @@
     RenderMultiColumnFlowThread(Document&, PassRef<RenderStyle>);
     ~RenderMultiColumnFlowThread();
 
+    unsigned columnCount() const { return m_columnCount; }
+    LayoutUnit columnWidth() const { return m_columnWidth; }
+    LayoutUnit columnHeightAvailable() const { return m_columnHeightAvailable; }
+    void setColumnHeightAvailable(LayoutUnit available) { m_columnHeightAvailable = available; }
+    bool inBalancingPass() const { return m_inBalancingPass; }
+    void setInBalancingPass(bool balancing) { m_inBalancingPass = balancing; }
+    bool needsRebalancing() const { return m_needsRebalancing; }
+    void setNeedsRebalancing(bool balancing) { m_needsRebalancing = balancing; }
+
+    bool computeColumnCountAndWidth();
+    
+    bool shouldRelayoutForPagination() const { return !m_inBalancingPass && m_needsRebalancing; }
+    
+    bool requiresBalancing() const { return !columnHeightAvailable() || parent()->style().columnFill() == ColumnFillBalance; }
+
 private:
     virtual const char* renderName() const override;
     virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues&) const override;
@@ -44,6 +59,14 @@
     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;
+
+private:
+    unsigned m_columnCount;   // The default column count/width that are based off our containing block width. These values represent only the default,
+    LayoutUnit m_columnWidth; // A multi-column block that is split across variable width pages or regions will have different column counts and widths in each.
+                              // These values will be cached (eventually) for multi-column blocks.
+    LayoutUnit m_columnHeightAvailable; // Total height available to columns, or 0 if auto.
+    bool m_inBalancingPass; // Guard to avoid re-entering column balancing.
+    bool m_needsRebalancing;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp (162701 => 162702)


--- trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp	2014-01-24 16:34:24 UTC (rev 162701)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp	2014-01-24 17:14:22 UTC (rev 162702)
@@ -232,7 +232,7 @@
     // Set box width.
     updateLogicalWidth();
 
-    if (multicolBlock->requiresBalancing()) {
+    if (multicolBlock->multiColumnFlowThread()->requiresBalancing()) {
         // Set maximum column height. We will not stretch beyond this.
         m_maxColumnHeight = RenderFlowThread::maxLogicalHeight();
         if (!multicolStyle.logicalHeight().isAuto()) {
@@ -281,6 +281,9 @@
 
     // Our portion rect determines our column count. We have as many columns as needed to fit all the content.
     LayoutUnit logicalHeightInColumns = flowThread()->isHorizontalWritingMode() ? flowThreadPortionRect().height() : flowThreadPortionRect().width();
+    if (!logicalHeightInColumns)
+        return 1;
+    
     unsigned count = ceil(static_cast<float>(logicalHeightInColumns) / computedColumnHeight());
     ASSERT(count >= 1);
     return count;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to