Index: Source/core/rendering/RenderBlockFlow.cpp |
diff --git a/Source/core/rendering/RenderBlockFlow.cpp b/Source/core/rendering/RenderBlockFlow.cpp |
index 8e86cd9c3a371df555fd7d5b3ae7a4a0cf41af42..07048ce680645a70b866ca6f6c79689cb98f9a31 100644 |
--- a/Source/core/rendering/RenderBlockFlow.cpp |
+++ b/Source/core/rendering/RenderBlockFlow.cpp |
@@ -1864,7 +1864,8 @@ void RenderBlockFlow::styleDidChange(StyleDifference diff, const RenderStyle* ol |
parentBlockFlow->markSiblingsWithFloatsForLayout(); |
} |
- createMultiColumnFlowThreadIfNeeded(); |
+ if (diff == StyleDifferenceLayout || !oldStyle) |
+ createOrDestroyMultiColumnFlowThreadIfNeeded(); |
} |
void RenderBlockFlow::updateStaticInlinePositionForChild(RenderBox* child, LayoutUnit logicalTop) |
@@ -2778,20 +2779,25 @@ RootInlineBox* RenderBlockFlow::createRootInlineBox() |
return new RootInlineBox(*this); |
} |
-void RenderBlockFlow::createMultiColumnFlowThreadIfNeeded() |
+void RenderBlockFlow::createOrDestroyMultiColumnFlowThreadIfNeeded() |
{ |
- if ((style()->hasAutoColumnCount() && style()->hasAutoColumnWidth()) || !document().regionBasedColumnsEnabled()) |
+ if (!document().regionBasedColumnsEnabled()) |
return; |
- if (multiColumnFlowThread()) |
- return; |
- |
- setChildrenInline(false); |
- RenderMultiColumnFlowThread* flowThread = RenderMultiColumnFlowThread::createAnonymous(document(), style()); |
- RenderBlock::addChild(flowThread); |
- RenderBlockFlowRareData& rareData = ensureRareData(); |
- ASSERT(!rareData.m_multiColumnFlowThread); |
- rareData.m_multiColumnFlowThread = flowThread; |
+ bool needsFlowThread = style()->specifiesColumns(); |
+ if (needsFlowThread != static_cast<bool>(multiColumnFlowThread())) { |
+ if (needsFlowThread) { |
+ RenderMultiColumnFlowThread* flowThread = RenderMultiColumnFlowThread::createAnonymous(document(), style()); |
+ addChild(flowThread); |
+ flowThread->populate(); |
+ RenderBlockFlowRareData& rareData = ensureRareData(); |
+ ASSERT(!rareData.m_multiColumnFlowThread); |
+ rareData.m_multiColumnFlowThread = flowThread; |
+ } else { |
+ multiColumnFlowThread()->evacuateAndDestroy(); |
+ ASSERT(!multiColumnFlowThread()); |
+ } |
+ } |
} |
RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() |