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

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

Issue 1968413002: Move some reparenting and anonymous block merge functionality down to LayoutBlockFlow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Is this thing on? 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 a0a91a80d385c0830d1dd6ff49458299053c02d1..8dbe35c8211d51ab4164216d7eb338e62464d00d 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
@@ -2486,6 +2486,68 @@ void LayoutBlockFlow::childBecameFloatingOrOutOfFlow(LayoutBox* child)
}
}
+static bool isMergeableAnonymousBlock(const LayoutBlockFlow* block)
+{
+ return block->isAnonymousBlock() && !block->continuation() && !block->beingDestroyed() && !block->isRubyRun() && !block->isRubyBase();
+}
+
+bool LayoutBlockFlow::mergeSiblingContiguousAnonymousBlock(LayoutBlockFlow* siblingThatMayBeDeleted)
+{
+ // Note: |this| and |siblingThatMayBeDeleted| may not be adjacent siblings at this point. There
+ // may be an object between them which is about to be removed.
+
+ if (!isMergeableAnonymousBlock(this) || !isMergeableAnonymousBlock(siblingThatMayBeDeleted))
+ return false;
+
+ setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalidationReason::AnonymousBlockChange);
+
+ // If the inlineness of children of the two block don't match, we'd need special code here
+ // (but there should be no need for it).
+ ASSERT(siblingThatMayBeDeleted->childrenInline() == childrenInline());
+ // Take all the children out of the |next| block and put them in
+ // the |prev| block.
+ siblingThatMayBeDeleted->moveAllChildrenIncludingFloatsTo(this, siblingThatMayBeDeleted->hasLayer() || hasLayer());
+ // Delete the now-empty block's lines and nuke it.
+ siblingThatMayBeDeleted->deleteLineBoxTree();
+ siblingThatMayBeDeleted->destroy();
+ return true;
+}
+
+void LayoutBlockFlow::reparentSubsequentFloatingOrOutOfFlowSiblings()
+{
+ if (!parent() || !parent()->isLayoutBlockFlow())
+ return;
+ if (beingDestroyed() || documentBeingDestroyed())
+ return;
+ LayoutBlockFlow* parentBlockFlow = toLayoutBlockFlow(parent());
+ LayoutObject* child = nextSibling();
+ while (child && child->isFloatingOrOutOfFlowPositioned()) {
+ LayoutObject* sibling = child->nextSibling();
+ parentBlockFlow->moveChildTo(this, child, nullptr, false);
+ child = sibling;
+ }
+
+ if (LayoutObject* next = nextSibling()) {
+ if (next->isLayoutBlockFlow())
+ mergeSiblingContiguousAnonymousBlock(toLayoutBlockFlow(next));
+ }
+}
+
+void LayoutBlockFlow::reparentPrecedingFloatingOrOutOfFlowSiblings()
+{
+ if (!parent() || !parent()->isLayoutBlockFlow())
+ return;
+ if (beingDestroyed() || documentBeingDestroyed())
+ return;
+ LayoutBlockFlow* parentBlockFlow = toLayoutBlockFlow(parent());
+ LayoutObject* child = previousSibling();
+ while (child && child->isFloatingOrOutOfFlowPositioned()) {
+ LayoutObject* sibling = child->previousSibling();
+ parentBlockFlow->moveChildTo(this, child, firstChild(), false);
+ child = sibling;
+ }
+}
+
void LayoutBlockFlow::invalidatePaintForOverhangingFloats(bool paintAllDescendants)
{
// Invalidate paint of any overhanging floats (if we know we're the one to paint them).
« 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