Chromium Code Reviews| Index: Source/core/rendering/RenderBlockFlow.cpp |
| diff --git a/Source/core/rendering/RenderBlockFlow.cpp b/Source/core/rendering/RenderBlockFlow.cpp |
| index e5fadb246635972590f86ef26c5dc2cece8f79f8..d65f741ff88c6f6488d9b67be75c46320848aff7 100644 |
| --- a/Source/core/rendering/RenderBlockFlow.cpp |
| +++ b/Source/core/rendering/RenderBlockFlow.cpp |
| @@ -39,6 +39,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" |
| @@ -1861,7 +1862,7 @@ void RenderBlockFlow::styleDidChange(StyleDifference diff, const RenderStyle* ol |
| } |
| if (diff.needsFullLayout() || !oldStyle) |
| - createOrDestroyMultiColumnFlowThreadIfNeeded(); |
| + createOrDestroyMultiColumnFlowThreadIfNeeded(oldStyle); |
| } |
| void RenderBlockFlow::updateStaticInlinePositionForChild(RenderBox* child, LayoutUnit logicalTop) |
| @@ -2779,25 +2780,49 @@ RootInlineBox* RenderBlockFlow::createRootInlineBox() |
| return new RootInlineBox(*this); |
| } |
| -void RenderBlockFlow::createOrDestroyMultiColumnFlowThreadIfNeeded() |
| +static inline bool isPagedOverflow(const RenderBlockFlow* renderer, const RenderStyle* style) |
| +{ |
| + return style->isOverflowPaged() && renderer->node() != renderer->document().viewportDefiningElement(); |
|
rune
2014/06/18 22:09:05
"this" is always passed as renderer. Why not make
|
| +} |
| + |
| +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. |
| + bool shouldBePaged = isPagedOverflow(this, style()); |
| + bool shouldBeMulticol = !shouldBePaged && style()->specifiesColumns(); |
| + |
|
rune
2014/06/18 22:09:05
We can get rid of this code duplication. Also we c
|
| + if (multiColumnFlowThread()) { |
| + ASSERT(oldStyle); |
| + bool wasPaged = isPagedOverflow(this, oldStyle); |
| + bool wasMulticol = !wasPaged && oldStyle->specifiesColumns(); |
| + if (wasMulticol != shouldBeMulticol || wasPaged != shouldBePaged) { |
| + // 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 ((shouldBeMulticol || shouldBePaged) && !multiColumnFlowThread()) { |
| + RenderMultiColumnFlowThread* flowThread; |
| + if (shouldBePaged) { |
| + // 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() |