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

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

Issue 2847823002: Make leading OOF objects to be handled by block layout in LayoutNG (Closed)
Patch Set: fix NGBlockNodeForTest Created 3 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 540dbd3c8de5a9112a7b7c59384ef6b698f2e479..b55ccb4938fff98a52d03d2d5294a7bd7cc70d4f 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
@@ -2986,8 +2986,30 @@ void LayoutBlockFlow::AddChild(LayoutObject* new_child,
// children as blocks.
// So, if our children are currently inline and a block child has to be
// inserted, we move all our inline children into anonymous block boxes.
- bool child_is_block_level =
- !new_child->IsInline() && !new_child->IsFloatingOrOutOfFlowPositioned();
+ bool child_is_block_level = !new_child->IsInline();
+
+ // ** LayoutNG **
+ // We want to use the block layout for out of flow positioned
+ // objects when they go in front of inline blocks or if they are just
+ // standalone objects.
+ // Example 1:
+ // <div id="zero"><div id="oof"></div></div>
+ // Legacy Layout: #oof is in inline context.
+ // LayoutNG: #oof is in block context.
+ //
+ // Example 2:
+ // <div id=container><oof></oof>Hello!</div>
+ // Legacy Layout: oof is in inline context.
+ // LayoutNG: oof is in block context.
+ //
+ // Example 3:
+ // <div id=container>Hello!<oof></oof></div>
+ // Legacy Layout: oof is in inline context.
+ // LayoutNG: oof is in inline context.
+ bool layout_ng_enabled = RuntimeEnabledFeatures::layoutNGEnabled();
+ if (new_child->IsFloatingOrOutOfFlowPositioned())
+ child_is_block_level = layout_ng_enabled && !FirstChild();
+
if (ChildrenInline()) {
if (child_is_block_level) {
// Wrap the inline content in anonymous blocks, to allow for the new block
@@ -3021,7 +3043,8 @@ void LayoutBlockFlow::AddChild(LayoutObject* new_child,
LayoutBlockFlow* new_block = ToLayoutBlockFlow(CreateAnonymousBlock());
LayoutBox::AddChild(new_block, before_child);
// Reparent adjacent floating or out-of-flow siblings to the new box.
- new_block->ReparentPrecedingFloatingOrOutOfFlowSiblings();
+ if (!layout_ng_enabled)
+ new_block->ReparentPrecedingFloatingOrOutOfFlowSiblings();
new_block->AddChild(new_child);
new_block->ReparentSubsequentFloatingOrOutOfFlowSiblings();
return;

Powered by Google App Engine
This is Rietveld 408576698