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

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

Issue 1969203003: Move makeChildrenInlineIfPossible to LayoutBlockFlow (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 8dbe35c8211d51ab4164216d7eb338e62464d00d..a9d94efa8b46f107e32a2e688b7b89f16372ef4b 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
@@ -2548,6 +2548,49 @@ void LayoutBlockFlow::reparentPrecedingFloatingOrOutOfFlowSiblings()
}
}
+void LayoutBlockFlow::makeChildrenInlineIfPossible()
+{
+ // Collapsing away anonymous wrappers isn't relevant for the children of anonymous blocks, unless they are ruby bases.
+ if (isAnonymousBlock() && !isRubyBase())
+ return;
+
+ Vector<LayoutBlock*, 3> blocksToRemove;
+ for (LayoutObject* child = firstChild(); child; child = child->nextSibling()) {
+ if (child->isFloating())
+ continue;
+ if (child->isOutOfFlowPositioned())
+ continue;
+
+ // There are still block children in the container, so any anonymous wrappers are still needed.
+ if (!child->isAnonymousBlock())
+ 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.
+ if (toLayoutBlock(child)->beingDestroyed())
+ return;
+ // We can't remove anonymous wrappers if they contain continuations as this means there are block children present.
+ if (toLayoutBlock(child)->continuation())
+ return;
+ // We are only interested in removing anonymous wrappers if there are inline siblings underneath them.
+ if (!child->childrenInline())
+ 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;
+
+ blocksToRemove.append(toLayoutBlock(child));
+ }
+
+ // If we make an object's children inline we are going to frustrate any future attempts to remove
+ // floats from its children's float-lists before the next layout happens so clear down all the floatlists
+ // now - they will be rebuilt at layout.
+ removeFloatingObjectsFromDescendants();
+
+ for (size_t i = 0; i < blocksToRemove.size(); i++)
+ collapseAnonymousBlockChild(this, blocksToRemove[i]);
+ setChildrenInline(true);
+}
+
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