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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBox.cpp

Issue 1611413007: Remove unnecessary anonymous blocks when splitting anonymous boxes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@568387-RemovePercentHeight
Patch Set: Created 4 years, 11 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: third_party/WebKit/Source/core/layout/LayoutBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
index fb82a7c0afc2369dcb56c705915c16ed387d0d39..2eabd41a472a538b2f76cd0ac81669ba83d564d0 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -4670,6 +4670,23 @@ static void markBoxForRelayoutAfterSplit(LayoutBox* box)
box->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalidationReason::AnonymousBlockChange);
}
+static bool collapseIfWillBecomeLoneAnonymousBlock(LayoutBox* child)
mstensho (USE GERRIT) 2016/01/28 20:45:14 I think this would fit better in LayoutBlock. Doin
rhogan 2016/01/30 12:38:58 Waaaah! I moved it here because you thought it sho
+{
+ if (!child->isAnonymousBlock())
+ return false;
+ LayoutBlock* childBlock = toLayoutBlock(child);
+ if (childBlock->beingDestroyed())
+ return false;
+ // We're splitting from our previousSibling().
mstensho (USE GERRIT) 2016/01/28 20:45:14 I'm still uneasy about this. I think we should ra
rhogan 2016/01/30 12:38:57 We're not guessing though - if we create postBox h
+ if (child->nextSibling() || childBlock->continuation())
+ return false;
+ LayoutBlock* parent = child->containingBlock();
mstensho (USE GERRIT) 2016/01/28 20:45:14 This should always be the same as child->parent(),
rhogan 2016/01/30 12:38:57 Done.
+ if (parent->isRubyBase() || parent->isRubyRun())
+ return false;
+ LayoutBlock::collapseAnonymousBlockChild(parent, childBlock);
+ return true;
+}
+
LayoutObject* LayoutBox::splitAnonymousBoxesAroundChild(LayoutObject* beforeChild)
{
bool didSplitParentAnonymousBoxes = false;
@@ -4696,7 +4713,10 @@ LayoutObject* LayoutBox::splitAnonymousBoxesAroundChild(LayoutObject* beforeChil
beforeChild = postBox;
} else {
- beforeChild = boxToSplit;
+ // If a lone anonymous block is now unnecessary collapse it away - this will make beforeChild's current
+ // grandparent its parent so no need to set it before looping.
+ if (!collapseIfWillBecomeLoneAnonymousBlock(boxToSplit))
+ beforeChild = boxToSplit;
}
}

Powered by Google App Engine
This is Rietveld 408576698