Index: Source/core/rendering/RenderBlockFlow.cpp |
diff --git a/Source/core/rendering/RenderBlockFlow.cpp b/Source/core/rendering/RenderBlockFlow.cpp |
index 61db8cc0f25e4d307e353709688fabd97d6d00e3..7dfe8dfd2287cd8a1630d12fa636e3851e376cb1 100644 |
--- a/Source/core/rendering/RenderBlockFlow.cpp |
+++ b/Source/core/rendering/RenderBlockFlow.cpp |
@@ -548,6 +548,15 @@ void RenderBlockFlow::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo, |
{ |
LayoutUnit oldPosMarginBefore = maxPositiveMarginBefore(); |
LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore(); |
+ bool isColumnSpanner = child->isColumnSpanAll(); |
+ |
+ if (isColumnSpanner) { |
+ // Margins of a column spanner cannot collapse with anything. |
+ setLogicalHeight(logicalHeight() + marginInfo.margin()); |
+ marginInfo.clearMargin(); |
+ LayoutUnit adjustment = flowThreadContainingBlock()->enterColumnSpanner(child, logicalHeight()); |
+ setLogicalHeight(logicalHeight() + adjustment); |
+ } |
// The child is a normal flow object. Compute the margins we will use for collapsing now. |
child->computeAndSetBlockDirectionMargins(this); |
@@ -558,14 +567,6 @@ void RenderBlockFlow::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo, |
LayoutUnit estimateWithoutPagination; |
LayoutUnit logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo, estimateWithoutPagination); |
- bool isColumnSpanner = child->isColumnSpanAll(); |
- if (isColumnSpanner) { |
- LayoutUnit margin = child->marginBefore(); |
- logicalTopEstimate -= margin; |
- flowThreadContainingBlock()->enterColumnSpanner(child, logicalTopEstimate); |
- logicalTopEstimate += margin; |
- } |
- |
// Cache our old rect so that we can dirty the proper paint invalidation rects if the child moves. |
LayoutRect oldRect = child->frameRect(); |
LayoutUnit oldLogicalTop = logicalTopForChild(child); |
@@ -733,9 +734,6 @@ LayoutUnit RenderBlockFlow::adjustBlockChildForPagination(LayoutUnit logicalTopA |
// If the object has a page or column break value of "before", then we should shift to the top of the next page. |
LayoutUnit result = applyBeforeBreak(child, logicalTopAfterClear); |
- if (child->isColumnSpanAll()) |
- result += flowThreadContainingBlock()->spannerLogicalTopAdjustment(child, result - child->marginBefore()); |
- |
// For replaced elements and scrolled elements, we want to shift them to the next page if they don't fit on the current one. |
LayoutUnit logicalTopBeforeUnsplittableAdjustment = result; |
LayoutUnit logicalTopAfterUnsplittableAdjustment = adjustForUnsplittableChild(child, result); |
@@ -1183,7 +1181,7 @@ LayoutUnit RenderBlockFlow::collapseMargins(RenderBox* child, MarginInfo& margin |
// margins that will collapse with us. |
bool topQuirk = hasMarginBeforeQuirk(child); |
- if (marginInfo.canCollapseWithMarginBefore() && !mustSeparateMarginBeforeForChild(child)) { |
+ if (marginInfo.canCollapseWithMarginBefore()) { |
if (!childDiscardMarginBefore && !marginInfo.discardMargin()) { |
// This child is collapsing with the top of the |
// block. If it has larger margin values, then we need to update |
@@ -1468,9 +1466,6 @@ void RenderBlockFlow::marginBeforeEstimateForChild(RenderBox* child, LayoutUnit& |
if (!grandchildBox || grandchildBox->style()->clear() != CNONE) |
return; |
- if (childBlockFlow->mustSeparateMarginBeforeForChild(grandchildBox)) |
- return; |
- |
// Make sure to update the block margins now for the grandchild box so that we're looking at current values. |
if (grandchildBox->needsLayout()) { |
grandchildBox->computeAndSetBlockDirectionMargins(this); |
@@ -1490,7 +1485,7 @@ LayoutUnit RenderBlockFlow::estimateLogicalTopPosition(RenderBox* child, const M |
// FIXME: We need to eliminate the estimation of vertical position, because when it's wrong we sometimes trigger a pathological |
// relayout if there are intruding floats. |
LayoutUnit logicalTopEstimate = logicalHeight(); |
- if (!marginInfo.canCollapseWithMarginBefore() || mustSeparateMarginBeforeForChild(child)) { |
+ if (!marginInfo.canCollapseWithMarginBefore()) { |
LayoutUnit positiveMarginBefore = 0; |
LayoutUnit negativeMarginBefore = 0; |
bool discardMarginBefore = false; |
@@ -1685,8 +1680,7 @@ void RenderBlockFlow::setMaxMarginAfterValues(LayoutUnit pos, LayoutUnit neg) |
bool RenderBlockFlow::mustSeparateMarginBeforeForChild(const RenderBox* child) const |
{ |
- if (child->isColumnSpanAll()) |
- return true; |
+ ASSERT(!child->selfNeedsLayout()); |
const RenderStyle* childStyle = child->style(); |
if (!child->isWritingModeRoot()) |
return childStyle->marginBeforeCollapse() == MSEPARATE; |
@@ -1699,8 +1693,7 @@ bool RenderBlockFlow::mustSeparateMarginBeforeForChild(const RenderBox* child) c |
bool RenderBlockFlow::mustSeparateMarginAfterForChild(const RenderBox* child) const |
{ |
- if (child->isColumnSpanAll()) |
- return true; |
+ ASSERT(!child->selfNeedsLayout()); |
const RenderStyle* childStyle = child->style(); |
if (!child->isWritingModeRoot()) |
return childStyle->marginAfterCollapse() == MSEPARATE; |