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

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

Issue 1423573002: Remove anonymous block wrapper when all children become inline (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated Created 5 years, 2 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.h ('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/LayoutBlock.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
index 75fabaddfae7c3372eb547349e52000fce1ab42a..24a4a0f90a651229ac588dd53af26fafad1afc94 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
@@ -607,7 +607,7 @@ static bool canMergeContiguousAnonymousBlocks(LayoutObject* oldChild, LayoutObje
void LayoutBlock::removeAnonymousWrappersIfRequired()
{
ASSERT(isLayoutBlockFlow());
- Vector<LayoutBox*, 16> blocksToRemove;
+ Vector<LayoutBox*, 3> blocksToRemove;
for (LayoutBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
if (child->isFloatingOrOutOfFlowPositioned())
continue;
@@ -646,18 +646,22 @@ void LayoutBlock::collapseAnonymousBlockChild(LayoutBlock* parent, LayoutBlock*
child->destroy();
}
-static inline bool shouldMakeChildrenInline(const LayoutBlock* block)
+void LayoutBlock::makeChildrenInlineIfPossible()
mstensho (USE GERRIT) 2015/10/26 13:42:46 Before doing anything (object type checks and esta
{
- if (!block->isLayoutBlockFlow())
- return false;
- LayoutObject* child = block->firstChild();
+ if (!isLayoutBlockFlow() || isRubyRun())
mstensho (USE GERRIT) 2015/10/26 13:42:46 I'm wondering if we need more checks here. What ab
+ return;
+ Vector<LayoutBlock*, 3> blocksToRemove;
+ LayoutObject* child = firstChild();
while (child) {
- // TODO(rhogan): If we encounter anonymous blocks with inline children we should fold them in here.
- if (!child->isFloatingOrOutOfFlowPositioned())
- return false;
+ if (child->isAnonymousBlock() && child->childrenInline())
+ blocksToRemove.append(toLayoutBlock(child));
+ else if (!child->isFloatingOrOutOfFlowPositioned())
+ return;
child = child->nextSibling();
}
- return true;
+ for (size_t i = 0; i < blocksToRemove.size(); i++)
+ collapseAnonymousBlockChild(this, blocksToRemove[i]);
+ setChildrenInline(true);
}
void LayoutBlock::removeChild(LayoutObject* oldChild)
@@ -762,9 +766,9 @@ void LayoutBlock::removeChild(LayoutObject* oldChild)
setContinuation(nullptr);
destroy();
}
- } else if (!beingDestroyed() && !oldChild->isFloatingOrOutOfFlowPositioned() && shouldMakeChildrenInline(this)) {
+ } else if (!beingDestroyed() && !oldChild->isFloatingOrOutOfFlowPositioned()) {
// If the child we're removing means that we can now treat all children as inline without the need for anonymous blocks, then do that.
- setChildrenInline(true);
+ makeChildrenInlineIfPossible();
}
}
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlock.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698