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

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
Index: Source/core/rendering/RenderBlock.cpp
diff --git a/Source/core/rendering/RenderBlock.cpp b/Source/core/rendering/RenderBlock.cpp
index 25c4d2a6ee51a933700af5e15b0dabfed9b9ada1..e7d0a624cd4f50502d71b566e11060620fd78bd5 100644
--- a/Source/core/rendering/RenderBlock.cpp
+++ b/Source/core/rendering/RenderBlock.cpp
@@ -328,6 +328,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()) {
@@ -1077,6 +1080,21 @@ static bool canMergeContiguousAnonymousBlocks(RenderObject* oldChild, RenderObje
&& prev->isAnonymousColumnSpanBlock() == next->isAnonymousColumnSpanBlock();
}
+void RenderBlock::removeAnonymousWrappersIfRequired()
+{
+ RenderBox* child = firstChildBox();
+ while (child && (child->isAnonymousBlock() || child->isFloatingOrOutOfFlowPositioned())) {
+ RenderBox* next = child->nextSiblingBox();
+ // A continuation means the wrappers are still required.
+ if (next && next->isRenderBlock() && toRenderBlock(next)->continuation())
+ return;
+ if (child->isAnonymousBlock())
+ collapseAnonymousBlockChild(this, toRenderBlock(child));
+ // |child| may have been destroyed.
+ child = next;
+ }
+}
+
void RenderBlock::collapseAnonymousBlockChild(RenderBlock* parent, RenderBlock* child)
{
// It's possible that this block's destruction may have been triggered by the

Powered by Google App Engine
This is Rietveld 408576698