Chromium Code Reviews| 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 fb82a7c0afc2369dcb56c705915c16ed387d0d39..060a7b55bdb7c8a9bc330b6607d1987a45e84944 100644 |
| --- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp |
| +++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp |
| @@ -4670,6 +4670,23 @@ static void markBoxForRelayoutAfterSplit(LayoutBox* box) |
| box->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalidationReason::AnonymousBlockChange); |
| } |
| +static bool collapseIfWillBecomeLoneAnonymousBlock(LayoutBox* child) |
| +{ |
| + if (!child->isAnonymousBlock()) |
| + return false; |
| + LayoutBlock* childBlock = toLayoutBlock(child); |
| + if (childBlock->beingDestroyed()) |
| + return false; |
| + // We're splitting from our previousSibling(). |
|
mstensho (USE GERRIT)
2016/01/21 19:12:33
It's not lone if it has a previousSibling(). Pleas
rhogan
2016/01/24 12:31:37
No, but it's about to split from the previousSibli
mstensho (USE GERRIT)
2016/01/25 09:17:07
That's making an assumption about what the caller
|
| + if (child->nextSibling() || childBlock->continuation()) |
| + return false; |
| + LayoutBlock* parent = child->containingBlock(); |
| + if (parent->isRubyBase() || parent->isRubyRun()) |
| + return false; |
| + LayoutBlock::collapseAnonymousBlockChild(parent, childBlock); |
| + return true; |
| +} |
| + |
| LayoutObject* LayoutBox::splitAnonymousBoxesAroundChild(LayoutObject* beforeChild) |
| { |
| bool didSplitParentAnonymousBoxes = false; |
| @@ -4694,9 +4711,17 @@ LayoutObject* LayoutBox::splitAnonymousBoxesAroundChild(LayoutObject* beforeChil |
| markBoxForRelayoutAfterSplit(boxToSplit); |
| markBoxForRelayoutAfterSplit(postBox); |
| + // Splitting the box means the left side of the container chain will lose any percent height descendants |
| + // below |postBox| in the right hand side. |
| + if (LayoutBlock::hasPercentHeightContainerMap()) |
| + LayoutBlock::clearPercentHeightDescendantsFrom(postBox); |
| + |
| beforeChild = postBox; |
| } else { |
| - beforeChild = boxToSplit; |
| + // If a lone anonymous block is now unnecessary collapse it away - this will make beforeChild's current |
| + // grandparent its parent so no need to set it before looping. |
|
mstensho (USE GERRIT)
2016/01/21 19:12:33
Thanks for explaining!
|
| + if (!collapseIfWillBecomeLoneAnonymousBlock(boxToSplit)) |
| + beforeChild = boxToSplit; |
| } |
| } |