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_break_token.h" | 7 #include "core/layout/ng/ng_block_break_token.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_break_token.h" | 9 #include "core/layout/ng/ng_break_token.h" |
10 #include "core/layout/ng/ng_fragment.h" | 10 #include "core/layout/ng/ng_fragment.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 did_break_ |= child->IsBox() && !child->BreakToken()->IsFinished(); | 84 did_break_ |= child->IsBox() && !child->BreakToken()->IsFinished(); |
85 | 85 |
86 child_break_tokens_.push_back(child->BreakToken()); | 86 child_break_tokens_.push_back(child->BreakToken()); |
87 children_.push_back(std::move(child)); | 87 children_.push_back(std::move(child)); |
88 offsets_.push_back(child_offset); | 88 offsets_.push_back(child_offset); |
89 | 89 |
90 return *this; | 90 return *this; |
91 } | 91 } |
92 | 92 |
93 NGFragmentBuilder& NGFragmentBuilder::AddFloatingObject( | 93 NGFragmentBuilder& NGFragmentBuilder::AddFloatingObject( |
94 NGFloatingObject* floating_object, | 94 RefPtr<NGFloatingObject> floating_object, |
95 const NGLogicalOffset& floating_object_offset) { | 95 const NGLogicalOffset& floating_object_offset) { |
96 positioned_floats_.push_back(floating_object); | 96 positioned_floats_.push_back(floating_object); |
97 floating_object_offsets_.push_back(floating_object_offset); | 97 floating_object_offsets_.push_back(floating_object_offset); |
98 return *this; | 98 return *this; |
99 } | 99 } |
100 | 100 |
101 NGFragmentBuilder& NGFragmentBuilder::SetBfcOffset( | 101 NGFragmentBuilder& NGFragmentBuilder::SetBfcOffset( |
102 const NGLogicalOffset& offset) { | 102 const NGLogicalOffset& offset) { |
103 bfc_offset_ = offset; | 103 bfc_offset_ = offset; |
104 return *this; | 104 return *this; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 DCHECK_EQ(offsets_.size(), children_.size()); | 166 DCHECK_EQ(offsets_.size(), children_.size()); |
167 | 167 |
168 NGPhysicalSize physical_size = size_.ConvertToPhysical(writing_mode_); | 168 NGPhysicalSize physical_size = size_.ConvertToPhysical(writing_mode_); |
169 | 169 |
170 for (size_t i = 0; i < children_.size(); ++i) { | 170 for (size_t i = 0; i < children_.size(); ++i) { |
171 NGPhysicalFragment* child = children_[i].get(); | 171 NGPhysicalFragment* child = children_[i].get(); |
172 child->SetOffset(offsets_[i].ConvertToPhysical( | 172 child->SetOffset(offsets_[i].ConvertToPhysical( |
173 writing_mode_, direction_, physical_size, child->Size())); | 173 writing_mode_, direction_, physical_size, child->Size())); |
174 } | 174 } |
175 | 175 |
176 Vector<Persistent<NGFloatingObject>> positioned_floats; | 176 Vector<RefPtr<NGFloatingObject>> positioned_floats; |
ikilpatrick
2017/03/15 22:45:40
not sure why this exists? :)
Gleb Lanbin
2017/03/15 23:24:25
Done.
| |
177 positioned_floats.reserveCapacity(positioned_floats_.size()); | 177 positioned_floats.reserveCapacity(positioned_floats_.size()); |
178 | 178 |
179 RefPtr<NGBreakToken> break_token; | 179 RefPtr<NGBreakToken> break_token; |
180 if (did_break_) { | 180 if (did_break_) { |
181 break_token = NGBlockBreakToken::create( | 181 break_token = NGBlockBreakToken::create( |
182 toNGBlockNode(node_.get()), used_block_size_, child_break_tokens_); | 182 toNGBlockNode(node_.get()), used_block_size_, child_break_tokens_); |
183 } else { | 183 } else { |
184 break_token = NGBlockBreakToken::create(node_.get()); | 184 break_token = NGBlockBreakToken::create(node_.get()); |
185 } | 185 } |
186 | 186 |
187 for (size_t i = 0; i < positioned_floats_.size(); ++i) { | 187 for (size_t i = 0; i < positioned_floats_.size(); ++i) { |
188 Persistent<NGFloatingObject>& floating_object = positioned_floats_[i]; | 188 RefPtr<NGFloatingObject>& floating_object = positioned_floats_[i]; |
189 NGPhysicalFragment* floating_fragment = floating_object->fragment.get(); | 189 NGPhysicalFragment* floating_fragment = floating_object->fragment.get(); |
190 floating_fragment->SetOffset(floating_object_offsets_[i].ConvertToPhysical( | 190 floating_fragment->SetOffset(floating_object_offsets_[i].ConvertToPhysical( |
191 writing_mode_, direction_, physical_size, floating_fragment->Size())); | 191 writing_mode_, direction_, physical_size, floating_fragment->Size())); |
192 positioned_floats.push_back(floating_object); | 192 positioned_floats.push_back(floating_object); |
193 } | 193 } |
194 | 194 |
195 RefPtr<NGPhysicalBoxFragment> fragment = adoptRef(new NGPhysicalBoxFragment( | 195 RefPtr<NGPhysicalBoxFragment> fragment = adoptRef(new NGPhysicalBoxFragment( |
196 node_->GetLayoutObject(), physical_size, | 196 node_->GetLayoutObject(), physical_size, |
197 overflow_.ConvertToPhysical(writing_mode_), children_, positioned_floats_, | 197 overflow_.ConvertToPhysical(writing_mode_), children_, positioned_floats_, |
198 bfc_offset_, end_margin_strut_, std::move(break_token))); | 198 bfc_offset_, end_margin_strut_, std::move(break_token))); |
199 | 199 |
200 return adoptRef( | 200 return adoptRef( |
201 new NGLayoutResult(std::move(fragment), out_of_flow_descendants_, | 201 new NGLayoutResult(std::move(fragment), out_of_flow_descendants_, |
202 out_of_flow_positions_, unpositioned_floats_)); | 202 out_of_flow_positions_, unpositioned_floats_)); |
203 } | 203 } |
204 | 204 |
205 RefPtr<NGPhysicalTextFragment> NGFragmentBuilder::ToTextFragment( | 205 RefPtr<NGPhysicalTextFragment> NGFragmentBuilder::ToTextFragment( |
206 unsigned index, | 206 unsigned index, |
207 unsigned start_offset, | 207 unsigned start_offset, |
208 unsigned end_offset) { | 208 unsigned end_offset) { |
209 DCHECK_EQ(type_, NGPhysicalFragment::kFragmentText); | 209 DCHECK_EQ(type_, NGPhysicalFragment::kFragmentText); |
210 DCHECK(children_.isEmpty()); | 210 DCHECK(children_.isEmpty()); |
211 DCHECK(offsets_.isEmpty()); | 211 DCHECK(offsets_.isEmpty()); |
212 | 212 |
213 Vector<Persistent<NGFloatingObject>> empty_unpositioned_floats; | |
214 Vector<Persistent<NGFloatingObject>> empty_positioned_floats; | |
215 | |
216 return adoptRef(new NGPhysicalTextFragment( | 213 return adoptRef(new NGPhysicalTextFragment( |
217 node_->GetLayoutObject(), toNGInlineNode(node_), index, start_offset, | 214 node_->GetLayoutObject(), toNGInlineNode(node_), index, start_offset, |
218 end_offset, size_.ConvertToPhysical(writing_mode_), | 215 end_offset, size_.ConvertToPhysical(writing_mode_), |
219 overflow_.ConvertToPhysical(writing_mode_))); | 216 overflow_.ConvertToPhysical(writing_mode_))); |
220 } | 217 } |
221 | 218 |
222 } // namespace blink | 219 } // namespace blink |
OLD | NEW |