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

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

Issue 1310253005: Strip anonymous wrappers when a block flow no longer requires them (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 5 years, 4 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 | « 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: 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;
}
}
« no previous file with comments | « Source/core/layout/LayoutBlock.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698