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

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

Issue 1970453002: Move continuation and line box specific stuff to LayoutBlockFlow::removeChild(). (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
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlockFlow.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1f11e9809007648f8021300f03ebf495772820d2..8141e337ce3505b89ea601ba6b7144a09b8ea2ba 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
@@ -2253,6 +2253,52 @@ void LayoutBlockFlow::addChild(LayoutObject* newChild, LayoutObject* beforeChild
LayoutBlock::addChild(newChild, beforeChild);
}
+void LayoutBlockFlow::removeChild(LayoutObject* oldChild)
+{
+ // No need to waste time in merging or removing empty anonymous blocks.
+ // We can just bail out if our document is getting destroyed.
+ if (documentBeingDestroyed()) {
+ LayoutBox::removeChild(oldChild);
+ return;
+ }
+
+ LayoutBlock::removeChild(oldChild);
+ if (!firstChild()) {
+ // If this was our last child be sure to clear out our line boxes.
+ if (childrenInline())
+ deleteLineBoxTree();
+
+ // If we are an empty anonymous block in the continuation chain,
+ // we need to remove ourself and fix the continuation chain.
+ if (!beingDestroyed() && isAnonymousBlockContinuation() && !oldChild->isListMarker()) {
+ LayoutObject* containingBlockIgnoringAnonymous = containingBlock();
+ while (containingBlockIgnoringAnonymous && containingBlockIgnoringAnonymous->isAnonymous())
+ containingBlockIgnoringAnonymous = containingBlockIgnoringAnonymous->containingBlock();
+ for (LayoutObject* curr = this; curr; curr = curr->previousInPreOrder(containingBlockIgnoringAnonymous)) {
+ if (curr->virtualContinuation() != this)
+ continue;
+
+ // Found our previous continuation. We just need to point it to
+ // |this|'s next continuation.
+ LayoutBoxModelObject* nextContinuation = continuation();
+ if (curr->isLayoutInline())
+ toLayoutInline(curr)->setContinuation(nextContinuation);
+ else if (curr->isLayoutBlockFlow())
+ toLayoutBlockFlow(curr)->setContinuation(nextContinuation);
+ else
+ ASSERT_NOT_REACHED();
+
+ break;
+ }
+ setContinuation(nullptr);
+ destroy();
+ }
+ } else if (!beingDestroyed() && !oldChild->isFloatingOrOutOfFlowPositioned() && !oldChild->isAnonymousBlock()) {
+ // 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.
+ makeChildrenInlineIfPossible();
+ }
+}
+
void LayoutBlockFlow::moveAllChildrenIncludingFloatsTo(LayoutBlock* toBlock, bool fullRemoveInsert)
{
LayoutBlockFlow* toBlockFlow = toLayoutBlockFlow(toBlock);
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlockFlow.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698