OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/layout/ng/ng_fragment_builder.h" | 5 #include "core/layout/ng/ng_fragment_builder.h" |
6 #include "core/layout/ng/ng_block_node.h" | 6 #include "core/layout/ng/ng_block_node.h" |
7 #include "core/style/ComputedStyle.h" | 7 #include "core/style/ComputedStyle.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 return *this; | 43 return *this; |
44 } | 44 } |
45 | 45 |
46 NGFragmentBuilder& NGFragmentBuilder::AddChild(NGFragmentBase* child, | 46 NGFragmentBuilder& NGFragmentBuilder::AddChild(NGFragmentBase* child, |
47 NGLogicalOffset child_offset) { | 47 NGLogicalOffset child_offset) { |
48 DCHECK_EQ(type_, NGPhysicalFragmentBase::kFragmentBox) | 48 DCHECK_EQ(type_, NGPhysicalFragmentBase::kFragmentBox) |
49 << "Only box fragments can have children"; | 49 << "Only box fragments can have children"; |
50 children_.append(child->PhysicalFragment()); | 50 children_.append(child->PhysicalFragment()); |
51 offsets_.append(child_offset); | 51 offsets_.append(child_offset); |
52 // Collect child's out of flow descendants. | 52 // Collect child's out of flow descendants. |
53 // TODO(atotic) All fragments can carry oof descendants. | 53 const NGPhysicalFragmentBase* physical_fragment = child->PhysicalFragment(); |
54 // Therefore, oof descendants should move from NGPhysicalFragment to | 54 const Vector<NGStaticPosition>& oof_positions = |
55 // NGPhysicalFragmentBase | 55 physical_fragment->OutOfFlowPositions(); |
56 if (child->PhysicalFragment()->Type() == | 56 size_t oof_index = 0; |
57 NGPhysicalFragmentBase::kFragmentBox) { | 57 for (auto& oof_node : physical_fragment->OutOfFlowDescendants()) { |
58 const NGPhysicalFragment* physical_child = | 58 NGStaticPosition oof_position = oof_positions[oof_index++]; |
59 static_cast<const NGPhysicalFragment*>(&*child->PhysicalFragment()); | 59 out_of_flow_descendant_candidates_.add(oof_node); |
60 const Vector<NGStaticPosition>& oof_positions = | 60 out_of_flow_candidate_placements_.append( |
61 physical_child->OutOfFlowPositions(); | 61 OutOfFlowPlacement{child_offset, oof_position}); |
62 size_t oof_index = 0; | |
63 for (auto& oof_node : physical_child->OutOfFlowDescendants()) { | |
64 NGStaticPosition oof_position = oof_positions[oof_index++]; | |
65 out_of_flow_descendant_candidates_.add(oof_node); | |
66 out_of_flow_candidate_placements_.append( | |
67 OutOfFlowPlacement{child_offset, oof_position}); | |
68 } | |
69 } | 62 } |
70 return *this; | 63 return *this; |
71 } | 64 } |
72 | 65 |
73 NGFragmentBuilder& NGFragmentBuilder::AddOutOfFlowChildCandidate( | 66 NGFragmentBuilder& NGFragmentBuilder::AddOutOfFlowChildCandidate( |
74 NGBlockNode* child, | 67 NGBlockNode* child, |
75 NGLogicalOffset child_offset) { | 68 NGLogicalOffset child_offset) { |
76 out_of_flow_descendant_candidates_.add(child); | 69 out_of_flow_descendant_candidates_.add(child); |
77 NGStaticPosition child_position = | 70 NGStaticPosition child_position = |
78 NGStaticPosition::Create(writing_mode_, direction_, NGPhysicalOffset()); | 71 NGStaticPosition::Create(writing_mode_, direction_, NGPhysicalOffset()); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 out_of_flow_descendants_, out_of_flow_positions_, margin_strut_); | 146 out_of_flow_descendants_, out_of_flow_positions_, margin_strut_); |
154 } | 147 } |
155 | 148 |
156 DEFINE_TRACE(NGFragmentBuilder) { | 149 DEFINE_TRACE(NGFragmentBuilder) { |
157 visitor->trace(children_); | 150 visitor->trace(children_); |
158 visitor->trace(out_of_flow_descendant_candidates_); | 151 visitor->trace(out_of_flow_descendant_candidates_); |
159 visitor->trace(out_of_flow_descendants_); | 152 visitor->trace(out_of_flow_descendants_); |
160 } | 153 } |
161 | 154 |
162 } // namespace blink | 155 } // namespace blink |
OLD | NEW |