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

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: Updated 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlock.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 65fcc59a155771b05adca84f275a5b7209287676..f7dcd81787bc6b285ae6c2f231cf9764dcd95327 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -4372,6 +4372,17 @@ static void markBoxForRelayoutAfterSplit(LayoutBox* box)
box->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalidationReason::AnonymousBlockChange);
}
+static void collapseLoneAnonymousBlockChild(LayoutObject* child)
+{
+ ASSERT(child);
+ if (!child->isAnonymousBlock())
+ return;
+ LayoutObject* parent = child->parent();
+ if (!parent->isLayoutBlock())
+ return;
+ LayoutBlock::collapseAnonymousBlockChild(toLayoutBlock(parent), toLayoutBlock(child));
+}
+
LayoutObject* LayoutBox::splitAnonymousBoxesAroundChild(LayoutObject* beforeChild)
{
bool didSplitParentAnonymousBoxes = false;
@@ -4393,6 +4404,13 @@ LayoutObject* LayoutBox::splitAnonymousBoxesAroundChild(LayoutObject* beforeChil
parentBox->virtualChildren()->insertChildNode(parentBox, postBox, boxToSplit->nextSibling());
boxToSplit->moveChildrenTo(postBox, beforeChild, 0, true);
+ LayoutObject* child = postBox->slowFirstChild();
+ if (child && !child->nextSibling())
+ collapseLoneAnonymousBlockChild(child);
+ child = boxToSplit->slowFirstChild();
mstensho (USE GERRIT) 2016/02/01 12:25:36 Could ASSERT(child) here (and above) instead of "i
rhogan 2016/02/02 21:38:25 True. I think we should ASSERT and null check thou
+ if (child && !child->previousSibling())
+ collapseLoneAnonymousBlockChild(child);
+
markBoxForRelayoutAfterSplit(boxToSplit);
markBoxForRelayoutAfterSplit(postBox);
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlock.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698