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" |
11 #include "core/layout/ng/ng_physical_text_fragment.h" | 11 #include "core/layout/ng/ng_physical_text_fragment.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 // TODO(ikilpatrick): Make writing mode and direction be in the constructor. | 15 // TODO(ikilpatrick): Make writing mode and direction be in the constructor. |
16 NGFragmentBuilder::NGFragmentBuilder(NGPhysicalFragment::NGFragmentType type, | 16 NGFragmentBuilder::NGFragmentBuilder(NGPhysicalFragment::NGFragmentType type, |
17 LayoutObject* layout_object) | 17 NGLayoutInputNode* node) |
18 : type_(type), | 18 : type_(type), |
19 writing_mode_(kHorizontalTopBottom), | 19 writing_mode_(kHorizontalTopBottom), |
20 direction_(TextDirection::kLtr), | 20 direction_(TextDirection::kLtr), |
21 layout_object_(layout_object) {} | 21 node_(node) {} |
22 | 22 |
23 NGFragmentBuilder& NGFragmentBuilder::SetWritingMode( | 23 NGFragmentBuilder& NGFragmentBuilder::SetWritingMode( |
24 NGWritingMode writing_mode) { | 24 NGWritingMode writing_mode) { |
25 writing_mode_ = writing_mode; | 25 writing_mode_ = writing_mode; |
26 return *this; | 26 return *this; |
27 } | 27 } |
28 | 28 |
29 NGFragmentBuilder& NGFragmentBuilder::SetDirection(TextDirection direction) { | 29 NGFragmentBuilder& NGFragmentBuilder::SetDirection(TextDirection direction) { |
30 direction_ = direction; | 30 direction_ = direction; |
31 return *this; | 31 return *this; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 164 |
165 for (size_t i = 0; i < positioned_floats_.size(); ++i) { | 165 for (size_t i = 0; i < positioned_floats_.size(); ++i) { |
166 Persistent<NGFloatingObject>& floating_object = positioned_floats_[i]; | 166 Persistent<NGFloatingObject>& floating_object = positioned_floats_[i]; |
167 NGPhysicalFragment* floating_fragment = floating_object->fragment.get(); | 167 NGPhysicalFragment* floating_fragment = floating_object->fragment.get(); |
168 floating_fragment->SetOffset(floating_object_offsets_[i].ConvertToPhysical( | 168 floating_fragment->SetOffset(floating_object_offsets_[i].ConvertToPhysical( |
169 writing_mode_, direction_, physical_size, floating_fragment->Size())); | 169 writing_mode_, direction_, physical_size, floating_fragment->Size())); |
170 positioned_floats.push_back(floating_object); | 170 positioned_floats.push_back(floating_object); |
171 } | 171 } |
172 | 172 |
173 return adoptRef(new NGPhysicalBoxFragment( | 173 return adoptRef(new NGPhysicalBoxFragment( |
174 layout_object_, physical_size, overflow_.ConvertToPhysical(writing_mode_), | 174 node_->GetLayoutObject(), physical_size, |
175 children_, out_of_flow_descendants_, out_of_flow_positions_, | 175 overflow_.ConvertToPhysical(writing_mode_), children_, |
176 unpositioned_floats_, positioned_floats_, bfc_offset_, end_margin_strut_, | 176 out_of_flow_descendants_, out_of_flow_positions_, unpositioned_floats_, |
177 break_token)); | 177 positioned_floats_, bfc_offset_, end_margin_strut_, break_token)); |
178 } | 178 } |
179 | 179 |
180 RefPtr<NGPhysicalTextFragment> NGFragmentBuilder::ToTextFragment( | 180 RefPtr<NGPhysicalTextFragment> NGFragmentBuilder::ToTextFragment( |
181 NGInlineNode* node, | |
182 unsigned index, | 181 unsigned index, |
183 unsigned start_offset, | 182 unsigned start_offset, |
184 unsigned end_offset) { | 183 unsigned end_offset) { |
185 DCHECK_EQ(type_, NGPhysicalFragment::kFragmentText); | 184 DCHECK_EQ(type_, NGPhysicalFragment::kFragmentText); |
186 DCHECK(children_.isEmpty()); | 185 DCHECK(children_.isEmpty()); |
187 DCHECK(offsets_.isEmpty()); | 186 DCHECK(offsets_.isEmpty()); |
188 | 187 |
189 Vector<Persistent<NGFloatingObject>> empty_unpositioned_floats; | 188 Vector<Persistent<NGFloatingObject>> empty_unpositioned_floats; |
190 Vector<Persistent<NGFloatingObject>> empty_positioned_floats; | 189 Vector<Persistent<NGFloatingObject>> empty_positioned_floats; |
191 | 190 |
192 return adoptRef(new NGPhysicalTextFragment( | 191 return adoptRef(new NGPhysicalTextFragment( |
193 layout_object_, node, index, start_offset, end_offset, | 192 node_->GetLayoutObject(), toNGInlineNode(node_), index, start_offset, |
194 size_.ConvertToPhysical(writing_mode_), | 193 end_offset, size_.ConvertToPhysical(writing_mode_), |
195 overflow_.ConvertToPhysical(writing_mode_), out_of_flow_descendants_, | 194 overflow_.ConvertToPhysical(writing_mode_), out_of_flow_descendants_, |
196 out_of_flow_positions_, empty_unpositioned_floats, | 195 out_of_flow_positions_, empty_unpositioned_floats, |
197 empty_positioned_floats)); | 196 empty_positioned_floats)); |
198 } | 197 } |
199 | 198 |
200 } // namespace blink | 199 } // namespace blink |
OLD | NEW |