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 | 6 |
7 #include "core/layout/ng/ng_block_node.h" | 7 #include "core/layout/ng/ng_block_node.h" |
8 #include "core/layout/ng/ng_break_token.h" | 8 #include "core/layout/ng/ng_break_token.h" |
9 #include "core/layout/ng/ng_fragment.h" | 9 #include "core/layout/ng/ng_fragment.h" |
10 #include "core/layout/ng/ng_physical_box_fragment.h" | 10 #include "core/layout/ng/ng_physical_box_fragment.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 73 } |
74 | 74 |
75 NGFragmentBuilder& NGFragmentBuilder::AddFloatingObject( | 75 NGFragmentBuilder& NGFragmentBuilder::AddFloatingObject( |
76 NGFloatingObject* floating_object, | 76 NGFloatingObject* floating_object, |
77 const NGLogicalOffset& floating_object_offset) { | 77 const NGLogicalOffset& floating_object_offset) { |
78 positioned_floats_.push_back(floating_object); | 78 positioned_floats_.push_back(floating_object); |
79 floating_object_offsets_.push_back(floating_object_offset); | 79 floating_object_offsets_.push_back(floating_object_offset); |
80 return *this; | 80 return *this; |
81 } | 81 } |
82 | 82 |
| 83 NGFragmentBuilder& NGFragmentBuilder::SetBfcOffset( |
| 84 const NGLogicalOffset& offset) { |
| 85 bfc_offset_ = offset; |
| 86 return *this; |
| 87 } |
| 88 |
83 NGFragmentBuilder& NGFragmentBuilder::AddOutOfFlowChildCandidate( | 89 NGFragmentBuilder& NGFragmentBuilder::AddOutOfFlowChildCandidate( |
84 NGBlockNode* child, | 90 NGBlockNode* child, |
85 NGLogicalOffset child_offset) { | 91 NGLogicalOffset child_offset) { |
86 out_of_flow_descendant_candidates_.add(child); | 92 out_of_flow_descendant_candidates_.add(child); |
87 NGStaticPosition child_position = | 93 NGStaticPosition child_position = |
88 NGStaticPosition::Create(writing_mode_, direction_, NGPhysicalOffset()); | 94 NGStaticPosition::Create(writing_mode_, direction_, NGPhysicalOffset()); |
89 out_of_flow_candidate_placements_.push_back( | 95 out_of_flow_candidate_placements_.push_back( |
90 OutOfFlowPlacement{child_offset, child_position}); | 96 OutOfFlowPlacement{child_offset, child_position}); |
91 child->SaveStaticOffsetForLegacy(child_offset); | 97 child->SaveStaticOffsetForLegacy(child_offset); |
92 return *this; | 98 return *this; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 135 } |
130 | 136 |
131 NGFragmentBuilder& NGFragmentBuilder::AddOutOfFlowDescendant( | 137 NGFragmentBuilder& NGFragmentBuilder::AddOutOfFlowDescendant( |
132 NGBlockNode* descendant, | 138 NGBlockNode* descendant, |
133 const NGStaticPosition& position) { | 139 const NGStaticPosition& position) { |
134 out_of_flow_descendants_.add(descendant); | 140 out_of_flow_descendants_.add(descendant); |
135 out_of_flow_positions_.push_back(position); | 141 out_of_flow_positions_.push_back(position); |
136 return *this; | 142 return *this; |
137 } | 143 } |
138 | 144 |
139 NGFragmentBuilder& NGFragmentBuilder::SetMarginStrutBlockStart( | |
140 const NGDeprecatedMarginStrut& from) { | |
141 margin_strut_.margin_block_start = from.margin_block_start; | |
142 margin_strut_.negative_margin_block_start = from.negative_margin_block_start; | |
143 return *this; | |
144 } | |
145 | |
146 NGFragmentBuilder& NGFragmentBuilder::SetMarginStrutBlockEnd( | |
147 const NGDeprecatedMarginStrut& from) { | |
148 margin_strut_.margin_block_end = from.margin_block_end; | |
149 margin_strut_.negative_margin_block_end = from.negative_margin_block_end; | |
150 return *this; | |
151 } | |
152 | |
153 NGPhysicalBoxFragment* NGFragmentBuilder::ToBoxFragment() { | 145 NGPhysicalBoxFragment* NGFragmentBuilder::ToBoxFragment() { |
154 // TODO(layout-ng): Support text fragments | 146 // TODO(layout-ng): Support text fragments |
155 DCHECK_EQ(type_, NGPhysicalFragment::kFragmentBox); | 147 DCHECK_EQ(type_, NGPhysicalFragment::kFragmentBox); |
156 DCHECK_EQ(offsets_.size(), children_.size()); | 148 DCHECK_EQ(offsets_.size(), children_.size()); |
157 | 149 |
158 auto* break_token = break_token_.get(); | 150 auto* break_token = break_token_.get(); |
159 break_token_ = nullptr; | 151 break_token_ = nullptr; |
160 | 152 |
161 NGPhysicalSize physical_size = size_.ConvertToPhysical(writing_mode_); | 153 NGPhysicalSize physical_size = size_.ConvertToPhysical(writing_mode_); |
162 HeapVector<Member<NGPhysicalFragment>> children; | 154 HeapVector<Member<NGPhysicalFragment>> children; |
(...skipping 12 matching lines...) Expand all Loading... |
175 for (size_t i = 0; i < positioned_floats_.size(); ++i) { | 167 for (size_t i = 0; i < positioned_floats_.size(); ++i) { |
176 Member<NGFloatingObject>& floating_object = positioned_floats_[i]; | 168 Member<NGFloatingObject>& floating_object = positioned_floats_[i]; |
177 NGPhysicalFragment* floating_fragment = floating_object->fragment; | 169 NGPhysicalFragment* floating_fragment = floating_object->fragment; |
178 floating_fragment->SetOffset(floating_object_offsets_[i].ConvertToPhysical( | 170 floating_fragment->SetOffset(floating_object_offsets_[i].ConvertToPhysical( |
179 writing_mode_, direction_, physical_size, floating_fragment->Size())); | 171 writing_mode_, direction_, physical_size, floating_fragment->Size())); |
180 positioned_floats.push_back(floating_object); | 172 positioned_floats.push_back(floating_object); |
181 } | 173 } |
182 | 174 |
183 return new NGPhysicalBoxFragment( | 175 return new NGPhysicalBoxFragment( |
184 layout_object_, physical_size, overflow_.ConvertToPhysical(writing_mode_), | 176 layout_object_, physical_size, overflow_.ConvertToPhysical(writing_mode_), |
185 children, out_of_flow_descendants_, out_of_flow_positions_, margin_strut_, | 177 children, out_of_flow_descendants_, out_of_flow_positions_, |
186 unpositioned_floats_, positioned_floats_, break_token); | 178 unpositioned_floats_, positioned_floats_, bfc_offset_, end_margin_strut_, |
| 179 break_token); |
187 } | 180 } |
188 | 181 |
189 NGPhysicalTextFragment* NGFragmentBuilder::ToTextFragment(NGInlineNode* node, | 182 NGPhysicalTextFragment* NGFragmentBuilder::ToTextFragment(NGInlineNode* node, |
190 unsigned start_index, | 183 unsigned start_index, |
191 unsigned end_index) { | 184 unsigned end_index) { |
192 DCHECK_EQ(type_, NGPhysicalFragment::kFragmentText); | 185 DCHECK_EQ(type_, NGPhysicalFragment::kFragmentText); |
193 DCHECK(children_.isEmpty()); | 186 DCHECK(children_.isEmpty()); |
194 DCHECK(offsets_.isEmpty()); | 187 DCHECK(offsets_.isEmpty()); |
195 | 188 |
196 HeapVector<Member<NGFloatingObject>> empty_unpositioned_floats; | 189 HeapVector<Member<NGFloatingObject>> empty_unpositioned_floats; |
(...skipping 10 matching lines...) Expand all Loading... |
207 DEFINE_TRACE(NGFragmentBuilder) { | 200 DEFINE_TRACE(NGFragmentBuilder) { |
208 visitor->trace(children_); | 201 visitor->trace(children_); |
209 visitor->trace(out_of_flow_descendant_candidates_); | 202 visitor->trace(out_of_flow_descendant_candidates_); |
210 visitor->trace(out_of_flow_descendants_); | 203 visitor->trace(out_of_flow_descendants_); |
211 visitor->trace(positioned_floats_); | 204 visitor->trace(positioned_floats_); |
212 visitor->trace(unpositioned_floats_); | 205 visitor->trace(unpositioned_floats_); |
213 visitor->trace(break_token_); | 206 visitor->trace(break_token_); |
214 } | 207 } |
215 | 208 |
216 } // namespace blink | 209 } // namespace blink |
OLD | NEW |