Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(916)

Unified Diff: Source/core/rendering/RenderBlock.cpp

Issue 253313005: Strip anonymous blocks when change in style removes need for them (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/RenderBlock.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderBlock.cpp
diff --git a/Source/core/rendering/RenderBlock.cpp b/Source/core/rendering/RenderBlock.cpp
index a95ad9ee2a5fb8d4cc81f71a43687feab0881aa4..7887b94181c8aa3bc842d7146d722b81ed45ad97 100644
--- a/Source/core/rendering/RenderBlock.cpp
+++ b/Source/core/rendering/RenderBlock.cpp
@@ -331,6 +331,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()) {
@@ -1080,6 +1083,24 @@ static bool canMergeContiguousAnonymousBlocks(RenderObject* oldChild, RenderObje
&& prev->isAnonymousColumnSpanBlock() == next->isAnonymousColumnSpanBlock();
}
+void RenderBlock::removeAnonymousWrappersIfRequired()
+{
+ Vector<RenderBox*, 16> blocksToRemove;
esprehn 2014/05/27 21:44:43 I would ASSERT(isRenderBlockFlow()) here if you ex
+ 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;
+ 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
« no previous file with comments | « Source/core/rendering/RenderBlock.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698