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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp

Issue 2954433003: [LayoutNG] Make leading OOF objects not to create context
Patch Set: Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ng/inline/ng_inline_layout_algorithm_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 2982 matching lines...) Expand 10 before | Expand all | Expand 10 after
2993 AddChildBeforeDescendant(new_child, before_child); 2993 AddChildBeforeDescendant(new_child, before_child);
2994 return; 2994 return;
2995 } 2995 }
2996 2996
2997 bool made_boxes_non_inline = false; 2997 bool made_boxes_non_inline = false;
2998 2998
2999 // A block has to either have all of its children inline, or all of its 2999 // A block has to either have all of its children inline, or all of its
3000 // children as blocks. 3000 // children as blocks.
3001 // So, if our children are currently inline and a block child has to be 3001 // So, if our children are currently inline and a block child has to be
3002 // inserted, we move all our inline children into anonymous block boxes. 3002 // inserted, we move all our inline children into anonymous block boxes.
3003 bool child_is_block_level = !new_child->IsInline(); 3003 bool child_is_block_level =
3004 3004 !new_child->IsInline() && !new_child->IsFloatingOrOutOfFlowPositioned();
3005 // ** LayoutNG **
3006 // We want to use the block layout for out of flow positioned
3007 // objects when they go in front of inline blocks or if they are just
3008 // standalone objects.
3009 // Example 1:
3010 // <div id="zero"><div id="oof"></div></div>
3011 // Legacy Layout: #oof is in inline context.
3012 // LayoutNG: #oof is in block context.
3013 //
3014 // Example 2:
3015 // <div id=container><oof></oof>Hello!</div>
3016 // Legacy Layout: oof is in inline context.
3017 // LayoutNG: oof is in block context.
3018 //
3019 // Example 3:
3020 // <div id=container>Hello!<oof></oof></div>
3021 // Legacy Layout: oof is in inline context.
3022 // LayoutNG: oof is in inline context.
3023 bool layout_ng_enabled = RuntimeEnabledFeatures::LayoutNGEnabled();
3024 if (new_child->IsFloatingOrOutOfFlowPositioned())
3025 child_is_block_level = layout_ng_enabled && !FirstChild();
3026 3005
3027 if (ChildrenInline()) { 3006 if (ChildrenInline()) {
3028 if (child_is_block_level) { 3007 if (child_is_block_level) {
3029 // Wrap the inline content in anonymous blocks, to allow for the new block 3008 // Wrap the inline content in anonymous blocks, to allow for the new block
3030 // child to be inserted. 3009 // child to be inserted.
3031 MakeChildrenNonInline(before_child); 3010 MakeChildrenNonInline(before_child);
3032 made_boxes_non_inline = true; 3011 made_boxes_non_inline = true;
3033 3012
3034 if (before_child && before_child->Parent() != this) { 3013 if (before_child && before_child->Parent() != this) {
3035 before_child = before_child->Parent(); 3014 before_child = before_child->Parent();
(...skipping 14 matching lines...) Expand all
3050 if (after_child && after_child->IsAnonymousBlock()) { 3029 if (after_child && after_child->IsAnonymousBlock()) {
3051 after_child->AddChild(new_child); 3030 after_child->AddChild(new_child);
3052 return; 3031 return;
3053 } 3032 }
3054 3033
3055 if (new_child->IsInline()) { 3034 if (new_child->IsInline()) {
3056 // No suitable existing anonymous box - create a new one. 3035 // No suitable existing anonymous box - create a new one.
3057 LayoutBlockFlow* new_block = ToLayoutBlockFlow(CreateAnonymousBlock()); 3036 LayoutBlockFlow* new_block = ToLayoutBlockFlow(CreateAnonymousBlock());
3058 LayoutBox::AddChild(new_block, before_child); 3037 LayoutBox::AddChild(new_block, before_child);
3059 // Reparent adjacent floating or out-of-flow siblings to the new box. 3038 // Reparent adjacent floating or out-of-flow siblings to the new box.
3060 if (!layout_ng_enabled) 3039 new_block->ReparentPrecedingFloatingOrOutOfFlowSiblings();
3061 new_block->ReparentPrecedingFloatingOrOutOfFlowSiblings();
3062 new_block->AddChild(new_child); 3040 new_block->AddChild(new_child);
3063 new_block->ReparentSubsequentFloatingOrOutOfFlowSiblings(); 3041 new_block->ReparentSubsequentFloatingOrOutOfFlowSiblings();
3064 return; 3042 return;
3065 } 3043 }
3066 } 3044 }
3067 3045
3068 // Skip the LayoutBlock override, since that one deals with anonymous child 3046 // Skip the LayoutBlock override, since that one deals with anonymous child
3069 // insertion in a way that isn't sufficient for us, and can only cause trouble 3047 // insertion in a way that isn't sufficient for us, and can only cause trouble
3070 // at this point. 3048 // at this point.
3071 LayoutBox::AddChild(new_child, before_child); 3049 LayoutBox::AddChild(new_child, before_child);
(...skipping 1681 matching lines...) Expand 10 before | Expand all | Expand 10 after
4753 return LayoutBlock::DeprecatedInvalidatePaint(paint_invalidation_state); 4731 return LayoutBlock::DeprecatedInvalidatePaint(paint_invalidation_state);
4754 } 4732 }
4755 4733
4756 void LayoutBlockFlow::InvalidateDisplayItemClients( 4734 void LayoutBlockFlow::InvalidateDisplayItemClients(
4757 PaintInvalidationReason invalidation_reason) const { 4735 PaintInvalidationReason invalidation_reason) const {
4758 BlockFlowPaintInvalidator(*this).InvalidateDisplayItemClients( 4736 BlockFlowPaintInvalidator(*this).InvalidateDisplayItemClients(
4759 invalidation_reason); 4737 invalidation_reason);
4760 } 4738 }
4761 4739
4762 } // namespace blink 4740 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ng/inline/ng_inline_layout_algorithm_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698