Chromium Code Reviews| Index: Source/core/layout/LayoutBlock.cpp |
| diff --git a/Source/core/layout/LayoutBlock.cpp b/Source/core/layout/LayoutBlock.cpp |
| index f9a4e434cf19610c9211a54a49f60fc627167371..17738ec4f65af5fde9ef9b948b78a95dfa9ca41c 100644 |
| --- a/Source/core/layout/LayoutBlock.cpp |
| +++ b/Source/core/layout/LayoutBlock.cpp |
| @@ -377,6 +377,23 @@ void LayoutBlock::invalidateDisplayItemClients(const LayoutBoxModelObject& paint |
| invalidateDisplayItemClientForStartOfContinuationsIfNeeded(*this); |
| } |
| +void LayoutBlock::addAdjacentSiblingsToAnonymousBox(AdjacentSiblings siblings, LayoutBlock* anonymousBox) |
| +{ |
| + bool previousSiblings = siblings == PreviousSiblings; |
| + LayoutObject* child = previousSiblings ? anonymousBox->previousSibling() : anonymousBox->nextSibling(); |
| + while (child && (child->isFloatingOrOutOfFlowPositioned() || (child->isAnonymousBlock() && child->childrenInline()))) { |
| + LayoutObject* sibling = previousSiblings ? child->previousSibling() : child->nextSibling(); |
| + if (child->isAnonymousBlock()) { |
| + LayoutBlockFlow* block = toLayoutBlockFlow(child); |
|
mstensho (USE GERRIT)
2015/09/03 08:44:30
I still think that if we find another anonymous bl
rhogan
2015/09/06 15:09:27
Yup - addressed this by parenting floating/out-of-
|
| + block->moveAllChildrenTo(anonymousBox, previousSiblings ? anonymousBox->firstChild() : 0, true); |
| + block->destroy(); |
| + } else { |
| + moveChildTo(anonymousBox, child, previousSiblings ? anonymousBox->firstChild() : 0, false); |
| + } |
| + child = sibling; |
| + } |
| +} |
| + |
| void LayoutBlock::addChildIgnoringContinuation(LayoutObject* newChild, LayoutObject* beforeChild) |
| { |
| if (beforeChild && beforeChild->parent() != this) { |
| @@ -446,11 +463,29 @@ void LayoutBlock::addChildIgnoringContinuation(LayoutObject* newChild, LayoutObj |
| return; |
| } |
| + LayoutObject* nextChild = firstChild(); |
| + bool needsAnonymousBox = isFlexibleBoxIncludingDeprecated() || isLayoutGrid(); |
|
mstensho (USE GERRIT)
2015/09/03 08:44:30
I cannot find this condition anywhere else in the
rhogan
2015/09/06 15:09:27
These seem to be the only two layout blocks that d
|
| + while (nextChild && !needsAnonymousBox) { |
|
mstensho (USE GERRIT)
2015/09/03 08:44:30
We're walking through all children to figure out i
rhogan
2015/09/06 15:09:27
Clarified what's happening in the comments - we ca
|
| + if (!nextChild->isFloatingOrOutOfFlowPositioned()) { |
| + needsAnonymousBox = true; |
| + break; |
| + } |
| + nextChild = nextChild->nextSibling(); |
| + } |
| + if (!needsAnonymousBox) { |
| + LayoutBox::addChild(newChild, beforeChild); |
| + setChildrenInline(true); |
| + return; |
| + } |
| + |
| if (newChild->isInline()) { |
| // No suitable existing anonymous box - create a new one. |
| LayoutBlock* newBox = createAnonymousBlock(); |
| LayoutBox::addChild(newBox, beforeChild); |
| + // Reparent adjacent inline siblings to the new box. |
| + addAdjacentSiblingsToAnonymousBox(PreviousSiblings, newBox); |
| newBox->addChild(newChild); |
| + addAdjacentSiblingsToAnonymousBox(NextSiblings, newBox); |
| return; |
| } |
| } |