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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp

Issue 1980473002: Move collapseAnonymousBlockChild() to LayoutBlockFlow, and make it non-static. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/LayoutBlockFlow.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
index a9d94efa8b46f107e32a2e688b7b89f16372ef4b..d51b8ab90b2c7f6ccfd316c45f4861b2aaa2a31a 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
@@ -2385,7 +2385,7 @@ void LayoutBlockFlow::removeChild(LayoutObject* oldChild)
// The removal has knocked us down to containing only a single anonymous
// box. We can go ahead and pull the content right back up into our
// box.
- collapseAnonymousBlockChild(this, toLayoutBlock(child));
+ collapseAnonymousBlockChild(toLayoutBlockFlow(child));
}
if (!firstChild()) {
@@ -2486,6 +2486,27 @@ void LayoutBlockFlow::childBecameFloatingOrOutOfFlow(LayoutBox* child)
}
}
+void LayoutBlockFlow::collapseAnonymousBlockChild(LayoutBlockFlow* child)
+{
+ // It's possible that this block's destruction may have been triggered by the
+ // child's removal. Just bail if the anonymous child block is already being
+ // destroyed. See crbug.com/282088
+ if (child->beingDestroyed())
+ return;
+ if (child->continuation())
+ return;
+ // Ruby elements use anonymous wrappers for ruby runs and ruby bases by design, so we don't remove them.
+ if (child->isRubyRun() || child->isRubyBase())
+ return;
+ setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalidationReason::ChildAnonymousBlockChanged);
+
+ child->moveAllChildrenTo(this, child->nextSibling(), child->hasLayer());
+ setChildrenInline(child->childrenInline());
+
+ children()->removeChildNode(this, child, child->hasLayer());
+ child->destroy();
+}
+
static bool isMergeableAnonymousBlock(const LayoutBlockFlow* block)
{
return block->isAnonymousBlock() && !block->continuation() && !block->beingDestroyed() && !block->isRubyRun() && !block->isRubyBase();
@@ -2554,7 +2575,7 @@ void LayoutBlockFlow::makeChildrenInlineIfPossible()
if (isAnonymousBlock() && !isRubyBase())
return;
- Vector<LayoutBlock*, 3> blocksToRemove;
+ Vector<LayoutBlockFlow*, 3> blocksToRemove;
for (LayoutObject* child = firstChild(); child; child = child->nextSibling()) {
if (child->isFloating())
continue;
@@ -2562,7 +2583,7 @@ void LayoutBlockFlow::makeChildrenInlineIfPossible()
continue;
// There are still block children in the container, so any anonymous wrappers are still needed.
- if (!child->isAnonymousBlock())
+ if (!child->isAnonymousBlock() || !child->isLayoutBlockFlow())
return;
// If one of the children is being destroyed then it is unsafe to clean up anonymous wrappers as the
// entire branch may be being destroyed.
@@ -2578,7 +2599,7 @@ void LayoutBlockFlow::makeChildrenInlineIfPossible()
if (child->isRubyRun() || child->isRubyBase())
return;
- blocksToRemove.append(toLayoutBlock(child));
+ blocksToRemove.append(toLayoutBlockFlow(child));
}
// If we make an object's children inline we are going to frustrate any future attempts to remove
@@ -2587,7 +2608,7 @@ void LayoutBlockFlow::makeChildrenInlineIfPossible()
removeFloatingObjectsFromDescendants();
for (size_t i = 0; i < blocksToRemove.size(); i++)
- collapseAnonymousBlockChild(this, blocksToRemove[i]);
+ collapseAnonymousBlockChild(blocksToRemove[i]);
setChildrenInline(true);
}
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlockFlow.h ('k') | third_party/WebKit/Source/core/layout/LayoutBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698