Chromium Code Reviews| Index: Source/core/rendering/RenderBlockFlow.cpp |
| diff --git a/Source/core/rendering/RenderBlockFlow.cpp b/Source/core/rendering/RenderBlockFlow.cpp |
| index 601e798dfc88fa3d61c70ce487e112bc7085dec1..90593ecd8f1577f933ac08d59a2a4dac419c92e6 100644 |
| --- a/Source/core/rendering/RenderBlockFlow.cpp |
| +++ b/Source/core/rendering/RenderBlockFlow.cpp |
| @@ -38,6 +38,7 @@ |
| #include "core/rendering/RenderFlowThread.h" |
| #include "core/rendering/RenderLayer.h" |
| #include "core/rendering/RenderMultiColumnFlowThread.h" |
| +#include "core/rendering/RenderPagedFlowThread.h" |
| #include "core/rendering/RenderText.h" |
| #include "core/rendering/RenderView.h" |
| #include "core/rendering/line/LineWidth.h" |
| @@ -1827,7 +1828,7 @@ void RenderBlockFlow::styleDidChange(StyleDifference diff, const RenderStyle* ol |
| } |
| if (diff.needsFullLayout() || !oldStyle) |
| - createOrDestroyMultiColumnFlowThreadIfNeeded(); |
| + createOrDestroyMultiColumnFlowThreadIfNeeded(oldStyle); |
| } |
| void RenderBlockFlow::updateStaticInlinePositionForChild(RenderBox* child, LayoutUnit logicalTop) |
| @@ -2734,25 +2735,55 @@ RootInlineBox* RenderBlockFlow::createRootInlineBox() |
| return new RootInlineBox(*this); |
| } |
| -void RenderBlockFlow::createOrDestroyMultiColumnFlowThreadIfNeeded() |
| +bool RenderBlockFlow::isPagedOverflow(const RenderStyle* style) |
| +{ |
| + return style->isOverflowPaged() && node() != document().viewportDefiningElement(); |
| +} |
| + |
| +RenderBlockFlow::FlowThreadType RenderBlockFlow::flowThreadType(const RenderStyle* style) |
| +{ |
| + if (isPagedOverflow(style)) |
| + return PagedFlowThread; |
| + if (style->specifiesColumns()) |
| + return MultiColumnFlowThread; |
| + return NoFlowThread; |
| +} |
| + |
| +void RenderBlockFlow::createOrDestroyMultiColumnFlowThreadIfNeeded(const RenderStyle* oldStyle) |
| { |
| if (!document().regionBasedColumnsEnabled()) |
| return; |
| - 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 { |
| + // Paged overflow trumps multicol in this implementation. Ideally, it should be possible to have |
| + // both paged overflow and multicol on the same element, but then we need two flow |
| + // threads. Anyway, this is nothing to worry about until we can actually nest multicol properly |
| + // inside other fragmentation contexts. |
| + FlowThreadType type = flowThreadType(style()); |
| + |
| + if (multiColumnFlowThread()) { |
| + ASSERT(oldStyle); |
| + if (type != flowThreadType(oldStyle)) { |
| + // If we're no longer to be multicol/paged, destroy the flow thread. Also destroy it |
| + // when switching between multicol and paged, since that affects the column set |
| + // structure (multicol containers may have spanners, paged containers may not). |
| multiColumnFlowThread()->evacuateAndDestroy(); |
| ASSERT(!multiColumnFlowThread()); |
| } |
| } |
| + if ((type != NoFlowThread) && !multiColumnFlowThread()) { |
|
rune
2014/07/04 09:44:25
The blink code often use early returns. How about:
|
| + RenderMultiColumnFlowThread* flowThread; |
| + if (type == PagedFlowThread) { |
| + // Paged overflow is currently done using the multicol implementation. |
| + flowThread = RenderPagedFlowThread::createAnonymous(document(), style()); |
| + } else { |
| + flowThread = RenderMultiColumnFlowThread::createAnonymous(document(), style()); |
| + } |
| + addChild(flowThread); |
| + flowThread->populate(); |
| + RenderBlockFlowRareData& rareData = ensureRareData(); |
| + ASSERT(!rareData.m_multiColumnFlowThread); |
| + rareData.m_multiColumnFlowThread = flowThread; |
| + } |
| } |
| RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() |