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

Side by Side 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 unified diff | Download patch
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 2968 matching lines...) Expand 10 before | Expand all | Expand 10 after
2979 AddChildBeforeDescendant(new_child, before_child); 2979 AddChildBeforeDescendant(new_child, before_child);
2980 return; 2980 return;
2981 } 2981 }
2982 2982
2983 bool made_boxes_non_inline = false; 2983 bool made_boxes_non_inline = false;
2984 2984
2985 // A block has to either have all of its children inline, or all of its 2985 // A block has to either have all of its children inline, or all of its
2986 // children as blocks. 2986 // children as blocks.
2987 // So, if our children are currently inline and a block child has to be 2987 // So, if our children are currently inline and a block child has to be
2988 // inserted, we move all our inline children into anonymous block boxes. 2988 // inserted, we move all our inline children into anonymous block boxes.
2989 bool child_is_block_level = 2989 bool child_is_block_level = !new_child->IsInline();
2990 !new_child->IsInline() && !new_child->IsFloatingOrOutOfFlowPositioned(); 2990
2991 // ** LayoutNG **
2992 // We want to use the block layout for out of flow positioned
2993 // objects when they go in front of inline blocks or if they are just
2994 // standalone objects.
2995 // Example 1:
2996 // <div id="zero"><div id="oof"></div></div>
2997 // Legacy Layout: #oof is in inline context.
2998 // LayoutNG: #oof is in block context.
2999 //
3000 // Example 2:
3001 // <div id=container><oof></oof>Hello!</div>
3002 // Legacy Layout: oof is in inline context.
3003 // LayoutNG: oof is in block context.
3004 //
3005 // Example 3:
3006 // <div id=container>Hello!<oof></oof></div>
3007 // Legacy Layout: oof is in inline context.
3008 // LayoutNG: oof is in inline context.
3009 bool layout_ng_enabled = RuntimeEnabledFeatures::layoutNGEnabled();
3010 if (new_child->IsFloatingOrOutOfFlowPositioned())
3011 child_is_block_level = layout_ng_enabled && !FirstChild();
3012
2991 if (ChildrenInline()) { 3013 if (ChildrenInline()) {
2992 if (child_is_block_level) { 3014 if (child_is_block_level) {
2993 // Wrap the inline content in anonymous blocks, to allow for the new block 3015 // Wrap the inline content in anonymous blocks, to allow for the new block
2994 // child to be inserted. 3016 // child to be inserted.
2995 MakeChildrenNonInline(before_child); 3017 MakeChildrenNonInline(before_child);
2996 made_boxes_non_inline = true; 3018 made_boxes_non_inline = true;
2997 3019
2998 if (before_child && before_child->Parent() != this) { 3020 if (before_child && before_child->Parent() != this) {
2999 before_child = before_child->Parent(); 3021 before_child = before_child->Parent();
3000 DCHECK(before_child->IsAnonymousBlock()); 3022 DCHECK(before_child->IsAnonymousBlock());
(...skipping 13 matching lines...) Expand all
3014 if (after_child && after_child->IsAnonymousBlock()) { 3036 if (after_child && after_child->IsAnonymousBlock()) {
3015 after_child->AddChild(new_child); 3037 after_child->AddChild(new_child);
3016 return; 3038 return;
3017 } 3039 }
3018 3040
3019 if (new_child->IsInline()) { 3041 if (new_child->IsInline()) {
3020 // No suitable existing anonymous box - create a new one. 3042 // No suitable existing anonymous box - create a new one.
3021 LayoutBlockFlow* new_block = ToLayoutBlockFlow(CreateAnonymousBlock()); 3043 LayoutBlockFlow* new_block = ToLayoutBlockFlow(CreateAnonymousBlock());
3022 LayoutBox::AddChild(new_block, before_child); 3044 LayoutBox::AddChild(new_block, before_child);
3023 // Reparent adjacent floating or out-of-flow siblings to the new box. 3045 // Reparent adjacent floating or out-of-flow siblings to the new box.
3024 new_block->ReparentPrecedingFloatingOrOutOfFlowSiblings(); 3046 if (!layout_ng_enabled)
3047 new_block->ReparentPrecedingFloatingOrOutOfFlowSiblings();
3025 new_block->AddChild(new_child); 3048 new_block->AddChild(new_child);
3026 new_block->ReparentSubsequentFloatingOrOutOfFlowSiblings(); 3049 new_block->ReparentSubsequentFloatingOrOutOfFlowSiblings();
3027 return; 3050 return;
3028 } 3051 }
3029 } 3052 }
3030 3053
3031 // Skip the LayoutBlock override, since that one deals with anonymous child 3054 // Skip the LayoutBlock override, since that one deals with anonymous child
3032 // insertion in a way that isn't sufficient for us, and can only cause trouble 3055 // insertion in a way that isn't sufficient for us, and can only cause trouble
3033 // at this point. 3056 // at this point.
3034 LayoutBox::AddChild(new_child, before_child); 3057 LayoutBox::AddChild(new_child, before_child);
(...skipping 1634 matching lines...) Expand 10 before | Expand all | Expand 10 after
4669 return LayoutBlock::DeprecatedInvalidatePaint(paint_invalidation_state); 4692 return LayoutBlock::DeprecatedInvalidatePaint(paint_invalidation_state);
4670 } 4693 }
4671 4694
4672 void LayoutBlockFlow::InvalidateDisplayItemClients( 4695 void LayoutBlockFlow::InvalidateDisplayItemClients(
4673 PaintInvalidationReason invalidation_reason) const { 4696 PaintInvalidationReason invalidation_reason) const {
4674 BlockFlowPaintInvalidator(*this).InvalidateDisplayItemClients( 4697 BlockFlowPaintInvalidator(*this).InvalidateDisplayItemClients(
4675 invalidation_reason); 4698 invalidation_reason);
4676 } 4699 }
4677 4700
4678 } // namespace blink 4701 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698