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

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: 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
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 dfe3167499f4eb0c9bd22e9339cc9621921d009b..d5e4cd2e06e124d95f95c26a66a27093e202f022 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
@@ -642,18 +642,22 @@ void LayoutBlock::collapseAnonymousBlockChild(LayoutBlock* parent, LayoutBlock*
child->destroy();
}
-static inline bool shouldMakeChildrenInline(const LayoutBlock* block)
+void LayoutBlock::makeChildrenInlineIfPossible()
{
- if (!block->isLayoutBlockFlow())
- return false;
- LayoutObject* child = block->firstChild();
+ if (!isLayoutBlockFlow() || isRubyRun())
mstensho (USE GERRIT) 2015/10/22 19:19:57 Where does the ruby check come from? Do we have a
+ return;
+ Vector<LayoutBox*, 16> blocksToRemove;
mstensho (USE GERRIT) 2015/10/22 19:19:58 How many anonymous blocks can we possibly find her
+ 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(toLayoutBox(child));
+ else if (!child->isFloatingOrOutOfFlowPositioned())
+ return;
child = child->nextSibling();
}
- return true;
+ for (size_t i = 0; i < blocksToRemove.size(); i++)
+ collapseAnonymousBlockChild(this, toLayoutBlock(blocksToRemove[i]));
mstensho (USE GERRIT) 2015/10/22 19:19:58 Looks like blocksToRemove should hold LayoutBlock
+ setChildrenInline(true);
}
void LayoutBlock::removeChild(LayoutObject* oldChild)
@@ -758,9 +762,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();
}
}

Powered by Google App Engine
This is Rietveld 408576698