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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 154 |
155 NGFragmentBuilder& NGFragmentBuilder::AddOutOfFlowDescendant( | 155 NGFragmentBuilder& NGFragmentBuilder::AddOutOfFlowDescendant( |
156 NGBlockNode* descendant, | 156 NGBlockNode* descendant, |
157 const NGStaticPosition& position) { | 157 const NGStaticPosition& position) { |
158 out_of_flow_descendants_.insert(descendant); | 158 out_of_flow_descendants_.insert(descendant); |
159 out_of_flow_positions_.push_back(position); | 159 out_of_flow_positions_.push_back(position); |
160 return *this; | 160 return *this; |
161 } | 161 } |
162 | 162 |
163 RefPtr<NGLayoutResult> NGFragmentBuilder::ToBoxFragment() { | 163 RefPtr<NGLayoutResult> NGFragmentBuilder::ToBoxFragment() { |
164 // TODO(layout-ng): Support text fragments | |
165 DCHECK_EQ(type_, NGPhysicalFragment::kFragmentBox); | 164 DCHECK_EQ(type_, NGPhysicalFragment::kFragmentBox); |
166 DCHECK_EQ(offsets_.size(), children_.size()); | 165 DCHECK_EQ(offsets_.size(), children_.size()); |
167 | 166 |
168 NGPhysicalSize physical_size = size_.ConvertToPhysical(writing_mode_); | 167 NGPhysicalSize physical_size = size_.ConvertToPhysical(writing_mode_); |
169 | 168 |
170 for (size_t i = 0; i < children_.size(); ++i) { | 169 for (size_t i = 0; i < children_.size(); ++i) { |
171 NGPhysicalFragment* child = children_[i].get(); | 170 NGPhysicalFragment* child = children_[i].get(); |
172 child->SetOffset(offsets_[i].ConvertToPhysical( | 171 child->SetOffset(offsets_[i].ConvertToPhysical( |
173 writing_mode_, direction_, physical_size, child->Size())); | 172 writing_mode_, direction_, physical_size, child->Size())); |
174 } | 173 } |
(...skipping 16 matching lines...) Expand all Loading... |
191 RefPtr<NGPhysicalBoxFragment> fragment = adoptRef(new NGPhysicalBoxFragment( | 190 RefPtr<NGPhysicalBoxFragment> fragment = adoptRef(new NGPhysicalBoxFragment( |
192 node_->GetLayoutObject(), physical_size, | 191 node_->GetLayoutObject(), physical_size, |
193 overflow_.ConvertToPhysical(writing_mode_), children_, positioned_floats_, | 192 overflow_.ConvertToPhysical(writing_mode_), children_, positioned_floats_, |
194 bfc_offset_, end_margin_strut_, std::move(break_token))); | 193 bfc_offset_, end_margin_strut_, std::move(break_token))); |
195 | 194 |
196 return adoptRef( | 195 return adoptRef( |
197 new NGLayoutResult(std::move(fragment), out_of_flow_descendants_, | 196 new NGLayoutResult(std::move(fragment), out_of_flow_descendants_, |
198 out_of_flow_positions_, unpositioned_floats_)); | 197 out_of_flow_positions_, unpositioned_floats_)); |
199 } | 198 } |
200 | 199 |
201 RefPtr<NGPhysicalTextFragment> NGFragmentBuilder::ToTextFragment( | |
202 unsigned index, | |
203 unsigned start_offset, | |
204 unsigned end_offset) { | |
205 DCHECK_EQ(type_, NGPhysicalFragment::kFragmentText); | |
206 DCHECK(children_.isEmpty()); | |
207 DCHECK(offsets_.isEmpty()); | |
208 | |
209 return adoptRef(new NGPhysicalTextFragment( | |
210 node_->GetLayoutObject(), toNGInlineNode(node_), index, start_offset, | |
211 end_offset, size_.ConvertToPhysical(writing_mode_), | |
212 overflow_.ConvertToPhysical(writing_mode_))); | |
213 } | |
214 | |
215 } // namespace blink | 200 } // namespace blink |
OLD | NEW |