Index: Source/core/rendering/RenderBlock.cpp |
diff --git a/Source/core/rendering/RenderBlock.cpp b/Source/core/rendering/RenderBlock.cpp |
index 53b3e20d026e5576ed942c7588440137d27b4004..25c4398f7c7f54c988c1deb82aeca362d6b9e515 100644 |
--- a/Source/core/rendering/RenderBlock.cpp |
+++ b/Source/core/rendering/RenderBlock.cpp |
@@ -345,6 +345,9 @@ void RenderBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldSty |
{ |
RenderBox::styleDidChange(diff, oldStyle); |
+ if (isFloatingOrOutOfFlowPositioned() && oldStyle && !oldStyle->isFloating() && !oldStyle->hasOutOfFlowPosition() && parent() && parent()->isRenderBlockFlow()) |
+ toRenderBlock(parent())->removeAnonymousWrappersIfRequired(); |
+ |
RenderStyle* newStyle = style(); |
if (!isAnonymousBlock()) { |
@@ -1101,6 +1104,28 @@ static bool canMergeContiguousAnonymousBlocks(RenderObject* oldChild, RenderObje |
&& prev->isAnonymousColumnSpanBlock() == next->isAnonymousColumnSpanBlock(); |
} |
+void RenderBlock::removeAnonymousWrappersIfRequired() |
+{ |
+ ASSERT(isRenderBlockFlow()); |
+ Vector<RenderBox*, 16> blocksToRemove; |
+ for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) { |
+ // There are still block children in the container, so any anonymous wrappers are still needed. |
+ if (!child->isAnonymousBlock() && !child->isFloatingOrOutOfFlowPositioned()) |
+ return; |
+ // We can't remove anonymous wrappers if they contain continuations as this means there are block children present. |
+ if (child->isRenderBlock() && toRenderBlock(child)->continuation()) |
+ return; |
+ // We are only interested in removing anonymous wrappers if there are inline siblings underneath them. |
+ if (!child->childrenInline()) |
+ return; |
+ if (child->isAnonymousBlock()) |
+ blocksToRemove.append(child); |
+ } |
+ |
+ for (size_t i = 0; i < blocksToRemove.size(); i++) |
+ collapseAnonymousBlockChild(this, toRenderBlock(blocksToRemove[i])); |
+} |
+ |
void RenderBlock::collapseAnonymousBlockChild(RenderBlock* parent, RenderBlock* child) |
{ |
// It's possible that this block's destruction may have been triggered by the |