Chromium Code Reviews| 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(); |
| } |
| } |