<!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>[162726] trunk/Source/WebCore</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/162726">162726</a></dd>
<dt>Author</dt> <dd>hyatt@apple.com</dd>
<dt>Date</dt> <dd>2014-01-24 14:52:41 -0800 (Fri, 24 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[New Multicolumn] Don't destroy all the renderers when a multi-column block stops being multi-column (and vice versa)
https://bugs.webkit.org/show_bug.cgi?id=127584

Make the logic for when you need columns and when you don't shared between the
old multi-column code and the new multi-column code. Make sure that the flow thread
and sets get created lazily and destroyed on-demand when whether or not we should
have multiple columns changes.

Reviewed by Beth Dakin.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::updateLogicalWidthAndColumnWidth):
No longer virtual. The new column code now uses this function too.

(WebCore::RenderBlock::availableLogicalWidth):
Renamed desiredColumnWidth() to computedColumnWidth().

(WebCore::RenderBlock::computeColumnCountAndWidth):
Renamed calcColumnWidth to computeColumnCountAndWidth.

(WebCore::RenderBlock::setComputedColumnCountAndWidth):
Rename setDesiredColumnCountAndWidth to computed.

(WebCore::RenderBlock::computedColumnWidth):
(WebCore::RenderBlock::computedColumnCount):
Renamed desiredColumnWidth/Count to computedColumnWidth/Count and made them virtual.

(WebCore::RenderBlock::updateFirstLetterStyle):
desired -&gt; computed rename.

* rendering/RenderBlock.h:
Renames and made a few functions virtual so that RenderBlockFlow can override.

* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::RenderBlockFlow):
Don't create the flow thread at construction time any longer.

(WebCore::RenderBlockFlow::createMultiColumnFlowThread):
(WebCore::RenderBlockFlow::destroyMultiColumnFlowThread):
The methods to create and destroy flow threads. These work at any time now and will
fix up the render tree accordingly.

(WebCore::RenderBlockFlow::setComputedColumnCountAndWidth):
Virtual override that creates/destroys the new multi-column information as needed.

(WebCore::RenderBlockFlow::computedColumnWidth):
(WebCore::RenderBlockFlow::computedColumnCount):
Overrides to return the cached column width and count from the flow thread.

* rendering/RenderBlockFlow.h:
Has overrides of the virtual functions needed to turn multi-column state on/off and
to hand back computed count/width information.

* rendering/RenderMultiColumnFlowThread.cpp:
* rendering/RenderMultiColumnFlowThread.h:
Removed the algorithm to compute column count and width, since this has been combined
with the old multi-column layout code.

* rendering/RenderView.cpp:
(WebCore::RenderView::computeColumnCountAndWidth):
Renamed desired -&gt; computed.

* rendering/RenderView.h:
Renamed desired -&gt; computed.

* style/StyleResolveTree.cpp:
(WebCore::Style::determineChange):
(WebCore::Style::resolveLocal):
(WebCore::Style::resolveTree):
* style/StyleResolveTree.h:
The Settings argument is no longer needed now that we don't destroy and re-create
the renderer for a block flow if it stops being (or becomes) multi-column.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockcpp">trunk/Source/WebCore/rendering/RenderBlock.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockh">trunk/Source/WebCore/rendering/RenderBlock.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockFlowcpp">trunk/Source/WebCore/rendering/RenderBlockFlow.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockFlowh">trunk/Source/WebCore/rendering/RenderBlockFlow.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderMultiColumnFlowThreadcpp">trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderMultiColumnFlowThreadh">trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderViewcpp">trunk/Source/WebCore/rendering/RenderView.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderViewh">trunk/Source/WebCore/rendering/RenderView.h</a></li>
<li><a href="#trunkSourceWebCorestyleStyleResolveTreecpp">trunk/Source/WebCore/style/StyleResolveTree.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleStyleResolveTreeh">trunk/Source/WebCore/style/StyleResolveTree.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (162725 => 162726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-01-24 22:29:03 UTC (rev 162725)
+++ trunk/Source/WebCore/ChangeLog        2014-01-24 22:52:41 UTC (rev 162726)
</span><span class="lines">@@ -1,3 +1,78 @@
</span><ins>+2014-01-24  David Hyatt  &lt;hyatt@apple.com&gt;
+
+        [New Multicolumn] Don't destroy all the renderers when a multi-column block stops being multi-column (and vice versa)
+        https://bugs.webkit.org/show_bug.cgi?id=127584
+
+        Make the logic for when you need columns and when you don't shared between the
+        old multi-column code and the new multi-column code. Make sure that the flow thread
+        and sets get created lazily and destroyed on-demand when whether or not we should
+        have multiple columns changes.
+
+        Reviewed by Beth Dakin.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::updateLogicalWidthAndColumnWidth):
+        No longer virtual. The new column code now uses this function too.
+
+        (WebCore::RenderBlock::availableLogicalWidth):
+        Renamed desiredColumnWidth() to computedColumnWidth().
+
+        (WebCore::RenderBlock::computeColumnCountAndWidth):
+        Renamed calcColumnWidth to computeColumnCountAndWidth.
+
+        (WebCore::RenderBlock::setComputedColumnCountAndWidth):
+        Rename setDesiredColumnCountAndWidth to computed.
+
+        (WebCore::RenderBlock::computedColumnWidth):
+        (WebCore::RenderBlock::computedColumnCount):
+        Renamed desiredColumnWidth/Count to computedColumnWidth/Count and made them virtual.
+
+        (WebCore::RenderBlock::updateFirstLetterStyle):
+        desired -&gt; computed rename.
+
+        * rendering/RenderBlock.h:
+        Renames and made a few functions virtual so that RenderBlockFlow can override.
+
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::RenderBlockFlow):
+        Don't create the flow thread at construction time any longer.
+
+        (WebCore::RenderBlockFlow::createMultiColumnFlowThread):
+        (WebCore::RenderBlockFlow::destroyMultiColumnFlowThread):
+        The methods to create and destroy flow threads. These work at any time now and will
+        fix up the render tree accordingly.
+
+        (WebCore::RenderBlockFlow::setComputedColumnCountAndWidth):
+        Virtual override that creates/destroys the new multi-column information as needed.
+
+        (WebCore::RenderBlockFlow::computedColumnWidth):
+        (WebCore::RenderBlockFlow::computedColumnCount):
+        Overrides to return the cached column width and count from the flow thread.
+
+        * rendering/RenderBlockFlow.h:
+        Has overrides of the virtual functions needed to turn multi-column state on/off and
+        to hand back computed count/width information.
+
+        * rendering/RenderMultiColumnFlowThread.cpp:
+        * rendering/RenderMultiColumnFlowThread.h:
+        Removed the algorithm to compute column count and width, since this has been combined
+        with the old multi-column layout code.
+
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::computeColumnCountAndWidth):
+        Renamed desired -&gt; computed.
+
+        * rendering/RenderView.h:
+        Renamed desired -&gt; computed.
+
+        * style/StyleResolveTree.cpp:
+        (WebCore::Style::determineChange):
+        (WebCore::Style::resolveLocal):
+        (WebCore::Style::resolveTree):
+        * style/StyleResolveTree.h:
+        The Settings argument is no longer needed now that we don't destroy and re-create
+        the renderer for a block flow if it stops being (or becomes) multi-column.
+
</ins><span class="cx"> 2014-01-24  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix 32-bit build.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (162725 => 162726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlock.cpp        2014-01-24 22:29:03 UTC (rev 162725)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp        2014-01-24 22:52:41 UTC (rev 162726)
</span><span class="lines">@@ -1547,15 +1547,15 @@
</span><span class="cx"> bool RenderBlock::updateLogicalWidthAndColumnWidth()
</span><span class="cx"> {
</span><span class="cx">     LayoutUnit oldWidth = logicalWidth();
</span><del>-    LayoutUnit oldColumnWidth = desiredColumnWidth();
</del><ins>+    LayoutUnit oldColumnWidth = computedColumnWidth();
</ins><span class="cx"> 
</span><span class="cx">     updateLogicalWidth();
</span><del>-    calcColumnWidth();
</del><ins>+    computeColumnCountAndWidth();
</ins><span class="cx"> 
</span><span class="cx">     bool hasBorderOrPaddingLogicalWidthChanged = m_hasBorderOrPaddingLogicalWidthChanged;
</span><span class="cx">     m_hasBorderOrPaddingLogicalWidthChanged = false;
</span><span class="cx"> 
</span><del>-    return oldWidth != logicalWidth() || oldColumnWidth != desiredColumnWidth() || hasBorderOrPaddingLogicalWidthChanged;
</del><ins>+    return oldWidth != logicalWidth() || oldColumnWidth != computedColumnWidth() || hasBorderOrPaddingLogicalWidthChanged;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderBlock::layoutBlock(bool, LayoutUnit)
</span><span class="lines">@@ -3631,7 +3631,7 @@
</span><span class="cx"> {
</span><span class="cx">     // If we have multiple columns, then the available logical width is reduced to our column width.
</span><span class="cx">     if (hasColumns())
</span><del>-        return desiredColumnWidth();
</del><ins>+        return computedColumnWidth();
</ins><span class="cx">     return RenderBox::availableLogicalWidth();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -3642,11 +3642,8 @@
</span><span class="cx">     return static_cast&lt;int&gt;(style().columnGap());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RenderBlock::calcColumnWidth()
</del><ins>+void RenderBlock::computeColumnCountAndWidth()
</ins><span class="cx"> {   
</span><del>-    if (document().regionBasedColumnsEnabled())
-        return;
-
</del><span class="cx">     // Calculate our column width and column count.
</span><span class="cx">     // FIXME: Can overflow on fast/block/float/float-not-removed-from-next-sibling4.html, see https://bugs.webkit.org/show_bug.cgi?id=68744
</span><span class="cx">     unsigned desiredColumnCount = 1;
</span><span class="lines">@@ -3654,7 +3651,7 @@
</span><span class="cx">     
</span><span class="cx">     // For now, we don't support multi-column layouts when printing, since we have to do a lot of work for proper pagination.
</span><span class="cx">     if (document().paginated() || (style().hasAutoColumnCount() &amp;&amp; style().hasAutoColumnWidth()) || !style().hasInlineColumnAxis()) {
</span><del>-        setDesiredColumnCountAndWidth(desiredColumnCount, desiredColumnWidth);
</del><ins>+        setComputedColumnCountAndWidth(desiredColumnCount, desiredColumnWidth);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">         
</span><span class="lines">@@ -3673,7 +3670,7 @@
</span><span class="cx">         desiredColumnCount = std::max&lt;LayoutUnit&gt;(std::min&lt;LayoutUnit&gt;(colCount, (availWidth + colGap) / (colWidth + colGap)), 1);
</span><span class="cx">         desiredColumnWidth = ((availWidth + colGap) / desiredColumnCount) - colGap;
</span><span class="cx">     }
</span><del>-    setDesiredColumnCountAndWidth(desiredColumnCount, desiredColumnWidth);
</del><ins>+    setComputedColumnCountAndWidth(desiredColumnCount, desiredColumnWidth);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool RenderBlock::requiresColumns(int desiredColumnCount) const
</span><span class="lines">@@ -3688,7 +3685,7 @@
</span><span class="cx">         &amp;&amp; !firstChild()-&gt;isAnonymousColumnSpanBlock();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RenderBlock::setDesiredColumnCountAndWidth(int count, LayoutUnit width)
</del><ins>+void RenderBlock::setComputedColumnCountAndWidth(int count, LayoutUnit width)
</ins><span class="cx"> {
</span><span class="cx">     bool destroyColumns = !requiresColumns(count);
</span><span class="cx">     if (destroyColumns) {
</span><span class="lines">@@ -3740,14 +3737,14 @@
</span><span class="cx">         setNeedsLayoutAndPrefWidthsRecalc();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-LayoutUnit RenderBlock::desiredColumnWidth() const
</del><ins>+LayoutUnit RenderBlock::computedColumnWidth() const
</ins><span class="cx"> {
</span><span class="cx">     if (!hasColumns())
</span><span class="cx">         return contentLogicalWidth();
</span><span class="cx">     return gColumnInfoMap-&gt;get(this)-&gt;desiredColumnWidth();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-unsigned RenderBlock::desiredColumnCount() const
</del><ins>+unsigned RenderBlock::computedColumnCount() const
</ins><span class="cx"> {
</span><span class="cx">     if (!hasColumns())
</span><span class="cx">         return 1;
</span><span class="lines">@@ -4832,7 +4829,7 @@
</span><span class="cx">     RenderStyle* pseudoStyle = styleForFirstLetter(firstLetterBlock, firstLetterContainer);
</span><span class="cx">     ASSERT(firstLetter-&gt;isFloating() || firstLetter-&gt;isInline());
</span><span class="cx"> 
</span><del>-    if (Style::determineChange(&amp;firstLetter-&gt;style(), pseudoStyle, &amp;frame().settings()) == Style::Detach) {
</del><ins>+    if (Style::determineChange(&amp;firstLetter-&gt;style(), pseudoStyle) == Style::Detach) {
</ins><span class="cx">         // The first-letter renderer needs to be replaced. Create a new renderer of the right type.
</span><span class="cx">         RenderBoxModelObject* newFirstLetter;
</span><span class="cx">         if (pseudoStyle-&gt;display() == INLINE)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlock.h (162725 => 162726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlock.h        2014-01-24 22:29:03 UTC (rev 162725)
+++ trunk/Source/WebCore/rendering/RenderBlock.h        2014-01-24 22:52:41 UTC (rev 162726)
</span><span class="lines">@@ -416,7 +416,8 @@
</span><span class="cx">     bool simplifiedLayout();
</span><span class="cx">     virtual void simplifiedNormalFlowLayout();
</span><span class="cx"> 
</span><del>-    void setDesiredColumnCountAndWidth(int, LayoutUnit);
</del><ins>+    // FIXME: Can de-virtualize this once old columns go away.
+    virtual void setComputedColumnCountAndWidth(int, LayoutUnit);
</ins><span class="cx"> 
</span><span class="cx"> public:
</span><span class="cx">     virtual void computeOverflow(LayoutUnit oldClientAfterEdge, bool recomputeFloats = false);
</span><span class="lines">@@ -542,8 +543,9 @@
</span><span class="cx">     virtual void absoluteRects(Vector&lt;IntRect&gt;&amp;, const LayoutPoint&amp; accumulatedOffset) const override;
</span><span class="cx">     virtual void absoluteQuads(Vector&lt;FloatQuad&gt;&amp;, bool* wasFixed) const override;
</span><span class="cx"> 
</span><del>-    LayoutUnit desiredColumnWidth() const;
-    unsigned desiredColumnCount() const;
</del><ins>+    // FIXME: Can de-virtualize once old columns go away.
+    virtual LayoutUnit computedColumnWidth() const;
+    virtual unsigned computedColumnCount() const;
</ins><span class="cx"> 
</span><span class="cx">     void paintContinuationOutlines(PaintInfo&amp;, const LayoutPoint&amp;);
</span><span class="cx"> 
</span><span class="lines">@@ -554,7 +556,7 @@
</span><span class="cx">     // FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to RenderBlockFlow
</span><span class="cx">     virtual VisiblePosition positionForPointWithInlineChildren(const LayoutPoint&amp;);
</span><span class="cx"> 
</span><del>-    virtual void calcColumnWidth();
</del><ins>+    virtual void computeColumnCountAndWidth();
</ins><span class="cx">     void makeChildrenAnonymousColumnBlocks(RenderObject* beforeChild, RenderBlock* newBlockBox, RenderObject* newChild);
</span><span class="cx"> 
</span><span class="cx">     bool expandsToEncloseOverhangingFloats() const;
</span><span class="lines">@@ -586,9 +588,9 @@
</span><span class="cx">     // Adjust from painting offsets to the local coords of this renderer
</span><span class="cx">     void offsetForContents(LayoutPoint&amp;) const;
</span><span class="cx"> 
</span><del>-    virtual bool requiresColumns(int desiredColumnCount) const;
</del><ins>+    virtual bool requiresColumns(int computedColumnCount) const;
</ins><span class="cx"> 
</span><del>-    virtual bool updateLogicalWidthAndColumnWidth();
</del><ins>+    bool updateLogicalWidthAndColumnWidth();
</ins><span class="cx"> 
</span><span class="cx">     virtual bool canCollapseAnonymousBlockChild() const { return true; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockFlowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (162725 => 162726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp        2014-01-24 22:29:03 UTC (rev 162725)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp        2014-01-24 22:52:41 UTC (rev 162726)
</span><span class="lines">@@ -103,7 +103,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> {
</span><span class="cx">     setChildrenInline(true);
</span><del>-    createMultiColumnFlowThreadIfNeeded();
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> RenderBlockFlow::RenderBlockFlow(Document&amp; document, PassRef&lt;RenderStyle&gt; style)
</span><span class="lines">@@ -114,25 +113,39 @@
</span><span class="cx"> #endif
</span><span class="cx"> {
</span><span class="cx">     setChildrenInline(true);
</span><del>-    createMultiColumnFlowThreadIfNeeded();
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> RenderBlockFlow::~RenderBlockFlow()
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RenderBlockFlow::createMultiColumnFlowThreadIfNeeded()
</del><ins>+void RenderBlockFlow::createMultiColumnFlowThread()
</ins><span class="cx"> {
</span><del>-    if ((style().hasAutoColumnCount() &amp;&amp; style().hasAutoColumnWidth()) || !document().regionBasedColumnsEnabled())
-        return;
-    
-    setChildrenInline(false);
</del><span class="cx">     RenderMultiColumnFlowThread* flowThread = new RenderMultiColumnFlowThread(document(), RenderStyle::createAnonymousStyleWithDisplay(&amp;style(), BLOCK));
</span><span class="cx">     flowThread-&gt;initializeStyle();
</span><ins>+    moveAllChildrenTo(flowThread, true);
</ins><span class="cx">     RenderBlock::addChild(flowThread);
</span><span class="cx">     setMultiColumnFlowThread(flowThread);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RenderBlockFlow::destroyMultiColumnFlowThread()
+{
+    // Get the flow thread out of our list.
+    multiColumnFlowThread()-&gt;removeFromParent();
+    
+    // Destroy all the multicolumn sets.
+    destroyLeftoverChildren();
+    
+    // Move all the children of the flow thread into our block.
+    multiColumnFlowThread()-&gt;moveAllChildrenTo(this, true);
+    
+    // Now destroy the flow thread.
+    multiColumnFlowThread()-&gt;destroy();
+    
+    // Clear the multi-column flow thread pointer.
+    setMultiColumnFlowThread(nullptr);
+}
+
</ins><span class="cx"> void RenderBlockFlow::insertedIntoTree()
</span><span class="cx"> {
</span><span class="cx">     RenderBlock::insertedIntoTree();
</span><span class="lines">@@ -3519,16 +3532,6 @@
</span><span class="cx">     return multiColumnFlowThread();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-
-bool RenderBlockFlow::updateLogicalWidthAndColumnWidth()
-{
-    bool relayoutChildren = RenderBlock::updateLogicalWidthAndColumnWidth();
-    if (multiColumnFlowThread() &amp;&amp; multiColumnFlowThread()-&gt;computeColumnCountAndWidth())
-        relayoutChildren = true;
-    return relayoutChildren;
-}
-
-
</del><span class="cx"> void RenderBlockFlow::addChild(RenderObject* newChild, RenderObject* beforeChild)
</span><span class="cx"> {
</span><span class="cx">     if (multiColumnFlowThread())
</span><span class="lines">@@ -3536,7 +3539,6 @@
</span><span class="cx">     RenderBlock::addChild(newChild, beforeChild);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> void RenderBlockFlow::checkForPaginationLogicalHeightChange(LayoutUnit&amp; pageLogicalHeight, bool&amp; pageLogicalHeightChanged, bool&amp; hasSpecifiedPageLogicalHeight)
</span><span class="cx"> {
</span><span class="cx">     // If we don't use either of the two column implementations or a flow thread, then bail.
</span><span class="lines">@@ -3578,5 +3580,42 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RenderBlockFlow::setComputedColumnCountAndWidth(int count, LayoutUnit width)
+{
+    if (!document().regionBasedColumnsEnabled())
+        return RenderBlock::setComputedColumnCountAndWidth(count, width);
+    
+    bool destroyColumns = !requiresColumns(count);
+    if (destroyColumns) {
+        if (multiColumnFlowThread())
+            destroyMultiColumnFlowThread();
+    } else {
+        if (!multiColumnFlowThread())
+            createMultiColumnFlowThread();
+        multiColumnFlowThread()-&gt;setColumnCountAndWidth(count, width);
+    }
</ins><span class="cx"> }
</span><ins>+
+LayoutUnit RenderBlockFlow::computedColumnWidth() const
+{
+    if (!document().regionBasedColumnsEnabled())
+        return RenderBlock::computedColumnWidth();
+    
+    if (multiColumnFlowThread())
+        return multiColumnFlowThread()-&gt;computedColumnWidth();
+    return contentLogicalWidth();
+}
+
+unsigned RenderBlockFlow::computedColumnCount() const
+{
+    if (!document().regionBasedColumnsEnabled())
+        return RenderBlock::computedColumnCount();
+    
+    if (multiColumnFlowThread())
+        return multiColumnFlowThread()-&gt;computedColumnCount();
+    
+    return 1;
+}
+
+}
</ins><span class="cx"> // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockFlowh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.h (162725 => 162726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlockFlow.h        2014-01-24 22:29:03 UTC (rev 162725)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.h        2014-01-24 22:52:41 UTC (rev 162726)
</span><span class="lines">@@ -376,7 +376,8 @@
</span><span class="cx"> 
</span><span class="cx">     void addChild(RenderObject* newChild, RenderObject* beforeChild = 0) override;
</span><span class="cx">     
</span><del>-    void createMultiColumnFlowThreadIfNeeded();
</del><ins>+    void createMultiColumnFlowThread();
+    void destroyMultiColumnFlowThread();
</ins><span class="cx">     
</span><span class="cx"> protected:
</span><span class="cx">     // A page break is required at some offset due to space shortage in the current fragmentainer.
</span><span class="lines">@@ -431,11 +432,14 @@
</span><span class="cx"> 
</span><span class="cx">     virtual int firstLineBaseline() const override;
</span><span class="cx">     virtual int inlineBlockBaseline(LineDirectionMode) const override;
</span><del>-    
-    bool updateLogicalWidthAndColumnWidth() override;
</del><span class="cx"> 
</span><span class="cx">     virtual bool isMultiColumnBlockFlow() const override { return multiColumnFlowThread(); }
</span><span class="cx">     
</span><ins>+    virtual void setComputedColumnCountAndWidth(int, LayoutUnit) override;
+    
+    virtual LayoutUnit computedColumnWidth() const override;
+    virtual unsigned computedColumnCount() const override;
+
</ins><span class="cx"> private:
</span><span class="cx">     // Called to lay out the legend for a fieldset or the ruby text of a ruby run. Also used by multi-column layout to handle
</span><span class="cx">     // the flow thread child.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderMultiColumnFlowThreadcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp (162725 => 162726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp        2014-01-24 22:29:03 UTC (rev 162725)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp        2014-01-24 22:52:41 UTC (rev 162726)
</span><span class="lines">@@ -62,40 +62,6 @@
</span><span class="cx">     return columnWidth();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-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-&gt;contentLogicalWidth();
-    
-    const RenderStyle&amp; columnStyle = columnBlock-&gt;style();
-    
-    ASSERT(!columnStyle.hasAutoColumnCount() || !columnStyle.hasAutoColumnWidth());
-
-    LayoutUnit availWidth = m_columnWidth;
-    LayoutUnit colGap = columnBlock-&gt;columnGap();
-    LayoutUnit colWidth = std::max&lt;LayoutUnit&gt;(1, LayoutUnit(columnStyle.columnWidth()));
-    int colCount = std::max&lt;int&gt;(1, columnStyle.columnCount());
-
-    if (columnStyle.hasAutoColumnWidth() &amp;&amp; !columnStyle.hasAutoColumnCount()) {
-        m_columnCount = colCount;
-        m_columnWidth = std::max&lt;LayoutUnit&gt;(0, (availWidth - ((m_columnCount - 1) * colGap)) / m_columnCount);
-    } else if (!columnStyle.hasAutoColumnWidth() &amp;&amp; columnStyle.hasAutoColumnCount()) {
-        m_columnCount = std::max&lt;LayoutUnit&gt;(1, (availWidth + colGap) / (colWidth + colGap));
-        m_columnWidth = ((availWidth + colGap) / m_columnCount) - colGap;
-    } else {
-        m_columnCount = std::max&lt;LayoutUnit&gt;(std::min&lt;LayoutUnit&gt;(colCount, (availWidth + colGap) / (colWidth + colGap)), 1);
-        m_columnWidth = ((availWidth + colGap) / m_columnCount) - colGap;
-    }
-    
-    return m_columnWidth != oldColumnWidth;
-}
-
</del><span class="cx"> void RenderMultiColumnFlowThread::autoGenerateRegionsToBlockOffset(LayoutUnit /*offset*/)
</span><span class="cx"> {
</span><span class="cx">     // This function ensures we have the correct column set information at all times.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderMultiColumnFlowThreadh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.h (162725 => 162726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.h        2014-01-24 22:29:03 UTC (rev 162725)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.h        2014-01-24 22:52:41 UTC (rev 162726)
</span><span class="lines">@@ -44,13 +44,17 @@
</span><span class="cx">     void setInBalancingPass(bool balancing) { m_inBalancingPass = balancing; }
</span><span class="cx">     bool needsRebalancing() const { return m_needsRebalancing; }
</span><span class="cx">     void setNeedsRebalancing(bool balancing) { m_needsRebalancing = balancing; }
</span><del>-
-    bool computeColumnCountAndWidth();
</del><span class="cx">     
</span><span class="cx">     bool shouldRelayoutForPagination() const { return !m_inBalancingPass &amp;&amp; m_needsRebalancing; }
</span><span class="cx">     
</span><span class="cx">     bool requiresBalancing() const { return !columnHeightAvailable() || parent()-&gt;style().columnFill() == ColumnFillBalance; }
</span><span class="cx"> 
</span><ins>+    void setColumnCountAndWidth(unsigned count, LayoutUnit width)
+    {
+        m_columnCount = count;
+        m_columnWidth = width;
+    }
+
</ins><span class="cx"> private:
</span><span class="cx">     virtual const char* renderName() const override;
</span><span class="cx">     virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues&amp;) const override;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderView.cpp (162725 => 162726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderView.cpp        2014-01-24 22:29:03 UTC (rev 162725)
+++ trunk/Source/WebCore/rendering/RenderView.cpp        2014-01-24 22:52:41 UTC (rev 162726)
</span><span class="lines">@@ -461,14 +461,14 @@
</span><span class="cx">     return frameView().pagination().mode != Pagination::Unpaginated;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RenderView::calcColumnWidth()
</del><ins>+void RenderView::computeColumnCountAndWidth()
</ins><span class="cx"> {
</span><span class="cx">     int columnWidth = contentLogicalWidth();
</span><span class="cx">     if (style().hasInlineColumnAxis()) {
</span><span class="cx">         if (int pageLength = frameView().pagination().pageLength)
</span><span class="cx">             columnWidth = pageLength;
</span><span class="cx">     }
</span><del>-    setDesiredColumnCountAndWidth(1, columnWidth);
</del><ins>+    setComputedColumnCountAndWidth(1, columnWidth);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ColumnInfo::PaginationUnit RenderView::paginationUnit() const
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderView.h (162725 => 162726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderView.h        2014-01-24 22:29:03 UTC (rev 162725)
+++ trunk/Source/WebCore/rendering/RenderView.h        2014-01-24 22:52:41 UTC (rev 162726)
</span><span class="lines">@@ -243,7 +243,7 @@
</span><span class="cx"> private:
</span><span class="cx">     bool initializeLayoutState(LayoutState&amp;);
</span><span class="cx"> 
</span><del>-    virtual void calcColumnWidth() override;
</del><ins>+    virtual void computeColumnCountAndWidth() override;
</ins><span class="cx">     virtual ColumnInfo::PaginationUnit paginationUnit() const override;
</span><span class="cx"> 
</span><span class="cx">     bool shouldRepaint(const LayoutRect&amp;) const;
</span></span></pre></div>
<a id="trunkSourceWebCorestyleStyleResolveTreecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/StyleResolveTree.cpp (162725 => 162726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleResolveTree.cpp        2014-01-24 22:29:03 UTC (rev 162725)
+++ trunk/Source/WebCore/style/StyleResolveTree.cpp        2014-01-24 22:52:41 UTC (rev 162726)
</span><span class="lines">@@ -65,7 +65,7 @@
</span><span class="cx"> static void detachRenderTree(Element&amp;, DetachType);
</span><span class="cx"> static void resolveTree(Element&amp;, Change);
</span><span class="cx"> 
</span><del>-Change determineChange(const RenderStyle* s1, const RenderStyle* s2, Settings* settings)
</del><ins>+Change determineChange(const RenderStyle* s1, const RenderStyle* s2)
</ins><span class="cx"> {
</span><span class="cx">     if (!s1 || !s2)
</span><span class="cx">         return Detach;
</span><span class="lines">@@ -77,12 +77,6 @@
</span><span class="cx">     // typically won't contain much content.
</span><span class="cx">     if (s1-&gt;columnSpan() != s2-&gt;columnSpan())
</span><span class="cx">         return Detach;
</span><del>-    if (settings-&gt;regionBasedColumnsEnabled()) {
-        bool specifiesColumns1 = !s1-&gt;hasAutoColumnCount() || !s1-&gt;hasAutoColumnWidth();
-        bool specifiesColumns2 = !s2-&gt;hasAutoColumnCount() || !s2-&gt;hasAutoColumnWidth();
-        if (specifiesColumns1 != specifiesColumns2)
-            return Detach;
-    }
</del><span class="cx">     if (!s1-&gt;contentDataEquivalent(s2))
</span><span class="cx">         return Detach;
</span><span class="cx">     // When text-combine property has been changed, we need to prepare a separate renderer object.
</span><span class="lines">@@ -676,7 +670,7 @@
</span><span class="cx">     Document&amp; document = current.document();
</span><span class="cx">     if (currentStyle &amp;&amp; current.styleChangeType() != ReconstructRenderTree) {
</span><span class="cx">         newStyle = current.styleForRenderer();
</span><del>-        localChange = determineChange(currentStyle.get(), newStyle.get(), document.settings());
</del><ins>+        localChange = determineChange(currentStyle.get(), newStyle.get());
</ins><span class="cx">     }
</span><span class="cx">     if (localChange == Detach) {
</span><span class="cx">         if (current.renderer() || current.inNamedFlow())
</span><span class="lines">@@ -897,7 +891,7 @@
</span><span class="cx">                 documentStyle.get().font().update(styleResolver-&gt;fontSelector());
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        Style::Change documentChange = determineChange(&amp;documentStyle.get(), &amp;document.renderView()-&gt;style(), document.settings());
</del><ins>+        Style::Change documentChange = determineChange(&amp;documentStyle.get(), &amp;document.renderView()-&gt;style());
</ins><span class="cx">         if (documentChange != NoChange)
</span><span class="cx">             document.renderView()-&gt;setStyle(std::move(documentStyle));
</span><span class="cx">         else
</span></span></pre></div>
<a id="trunkSourceWebCorestyleStyleResolveTreeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/StyleResolveTree.h (162725 => 162726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleResolveTree.h        2014-01-24 22:29:03 UTC (rev 162725)
+++ trunk/Source/WebCore/style/StyleResolveTree.h        2014-01-24 22:52:41 UTC (rev 162726)
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx"> 
</span><span class="cx"> void updateTextRendererAfterContentChange(Text&amp;, unsigned offsetOfReplacedData, unsigned lengthOfReplacedData);
</span><span class="cx"> 
</span><del>-Change determineChange(const RenderStyle*, const RenderStyle*, Settings*);
</del><ins>+Change determineChange(const RenderStyle*, const RenderStyle*);
</ins><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>