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_out_of_flow_layout_part.h" | 5 #include "core/layout/ng/ng_out_of_flow_layout_part.h" |
6 | 6 |
7 #include "core/layout/ng/ng_absolute_utils.h" | 7 #include "core/layout/ng/ng_absolute_utils.h" |
8 #include "core/layout/ng/ng_block_node.h" | 8 #include "core/layout/ng/ng_block_node.h" |
9 #include "core/layout/ng/ng_box_fragment.h" | 9 #include "core/layout/ng/ng_box_fragment.h" |
10 #include "core/layout/ng/ng_constraint_space_builder.h" | 10 #include "core/layout/ng/ng_constraint_space_builder.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 space_builder.SetTextDirection(container_style_.direction()); | 61 space_builder.SetTextDirection(container_style_.direction()); |
62 container_space_ = space_builder.ToConstraintSpace(); | 62 container_space_ = space_builder.ToConstraintSpace(); |
63 } | 63 } |
64 | 64 |
65 void NGOutOfFlowLayoutPart::Run() { | 65 void NGOutOfFlowLayoutPart::Run() { |
66 PersistentHeapLinkedHashSet<WeakMember<NGBlockNode>> out_of_flow_candidates; | 66 PersistentHeapLinkedHashSet<WeakMember<NGBlockNode>> out_of_flow_candidates; |
67 Vector<NGStaticPosition> out_of_flow_candidate_positions; | 67 Vector<NGStaticPosition> out_of_flow_candidate_positions; |
68 container_builder_->GetAndClearOutOfFlowDescendantCandidates( | 68 container_builder_->GetAndClearOutOfFlowDescendantCandidates( |
69 &out_of_flow_candidates, &out_of_flow_candidate_positions); | 69 &out_of_flow_candidates, &out_of_flow_candidate_positions); |
70 | 70 |
71 size_t position_index = 0; | 71 while (out_of_flow_candidates.size() > 0) { |
| 72 size_t position_index = 0; |
72 | 73 |
73 for (auto& descendant : out_of_flow_candidates) { | 74 for (auto& descendant : out_of_flow_candidates) { |
74 NGStaticPosition static_position = | 75 NGStaticPosition static_position = |
75 out_of_flow_candidate_positions[position_index++]; | 76 out_of_flow_candidate_positions[position_index++]; |
76 | 77 |
77 if (IsContainingBlockForAbsoluteDescendant(container_style_, | 78 if (IsContainingBlockForAbsoluteDescendant(container_style_, |
78 descendant->Style())) { | 79 descendant->Style())) { |
79 NGLogicalOffset offset; | 80 NGLogicalOffset offset; |
80 RefPtr<NGPhysicalFragment> physical_fragment = | 81 RefPtr<NGPhysicalFragment> physical_fragment = |
81 LayoutDescendant(*descendant, static_position, &offset); | 82 LayoutDescendant(*descendant, static_position, &offset); |
82 // TODO(atotic) Need to adjust size of overflow rect per spec. | 83 // TODO(atotic) Need to adjust size of overflow rect per spec. |
83 container_builder_->AddChild(std::move(physical_fragment), offset); | 84 container_builder_->AddChild(std::move(physical_fragment), offset); |
84 } else { | 85 } else { |
85 container_builder_->AddOutOfFlowDescendant(descendant, static_position); | 86 container_builder_->AddOutOfFlowDescendant(descendant, static_position); |
| 87 } |
86 } | 88 } |
| 89 // Sweep any descendants that might have been added. |
| 90 // This happens when an absolute container has a fixed child. |
| 91 out_of_flow_candidates.clear(); |
| 92 out_of_flow_candidate_positions.clear(); |
| 93 container_builder_->GetAndClearOutOfFlowDescendantCandidates( |
| 94 &out_of_flow_candidates, &out_of_flow_candidate_positions); |
87 } | 95 } |
88 } | 96 } |
89 | 97 |
90 RefPtr<NGPhysicalFragment> NGOutOfFlowLayoutPart::LayoutDescendant( | 98 RefPtr<NGPhysicalFragment> NGOutOfFlowLayoutPart::LayoutDescendant( |
91 NGBlockNode& descendant, | 99 NGBlockNode& descendant, |
92 NGStaticPosition static_position, | 100 NGStaticPosition static_position, |
93 NGLogicalOffset* offset) { | 101 NGLogicalOffset* offset) { |
94 // Adjust the static_position origin. The static_position coordinate origin is | 102 // Adjust the static_position origin. The static_position coordinate origin is |
95 // relative to the container's border box, ng_absolute_utils expects it to be | 103 // relative to the container's border box, ng_absolute_utils expects it to be |
96 // relative to the container's padding box. | 104 // relative to the container's padding box. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 if (block_estimate) | 177 if (block_estimate) |
170 builder.SetIsFixedSizeBlock(true); | 178 builder.SetIsFixedSizeBlock(true); |
171 builder.SetIsFixedSizeInline(true); | 179 builder.SetIsFixedSizeInline(true); |
172 builder.SetIsNewFormattingContext(true); | 180 builder.SetIsNewFormattingContext(true); |
173 NGConstraintSpace* space = builder.ToConstraintSpace(); | 181 NGConstraintSpace* space = builder.ToConstraintSpace(); |
174 | 182 |
175 return descendant.Layout(space); | 183 return descendant.Layout(space); |
176 } | 184 } |
177 | 185 |
178 } // namespace blink | 186 } // namespace blink |
OLD | NEW |