OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/inline/ng_text_fragment_builder.h" | 5 #include "core/layout/ng/inline/ng_text_fragment_builder.h" |
6 | 6 |
7 #include "core/layout/ng/inline/ng_inline_node.h" | 7 #include "core/layout/ng/inline/ng_inline_node.h" |
8 #include "core/layout/ng/inline/ng_physical_text_fragment.h" | 8 #include "core/layout/ng/inline/ng_physical_text_fragment.h" |
9 #include "core/layout/ng/ng_fragment.h" | 9 #include "core/layout/ng/ng_fragment.h" |
10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 NGTextFragmentBuilder::NGTextFragmentBuilder(NGInlineNode* node) | 14 NGTextFragmentBuilder::NGTextFragmentBuilder(NGInlineNode* node) |
15 : direction_(TextDirection::kLtr), node_(node) {} | 15 : direction_(TextDirection::kLtr), node_(node) {} |
16 | 16 |
17 NGTextFragmentBuilder& NGTextFragmentBuilder::SetDirection( | 17 NGTextFragmentBuilder& NGTextFragmentBuilder::SetDirection( |
18 TextDirection direction) { | 18 TextDirection direction) { |
19 direction_ = direction; | 19 direction_ = direction; |
20 return *this; | 20 return *this; |
21 } | 21 } |
22 | 22 |
23 NGTextFragmentBuilder& NGTextFragmentBuilder::SetInlineSize(LayoutUnit size) { | 23 NGTextFragmentBuilder& NGTextFragmentBuilder::SetSize( |
24 size_.inline_size = size; | 24 const NGLogicalSize& size) { |
| 25 size_ = size; |
25 return *this; | 26 return *this; |
26 } | 27 } |
27 | 28 |
28 NGTextFragmentBuilder& NGTextFragmentBuilder::SetBlockSize(LayoutUnit size) { | |
29 size_.block_size = size; | |
30 return *this; | |
31 } | |
32 | |
33 void NGTextFragmentBuilder::UniteMetrics(const NGLineHeightMetrics& metrics) { | 29 void NGTextFragmentBuilder::UniteMetrics(const NGLineHeightMetrics& metrics) { |
34 metrics_.Unite(metrics); | 30 metrics_.Unite(metrics); |
35 } | 31 } |
36 | 32 |
37 RefPtr<NGPhysicalTextFragment> NGTextFragmentBuilder::ToTextFragment( | 33 RefPtr<NGPhysicalTextFragment> NGTextFragmentBuilder::ToTextFragment( |
38 unsigned index, | 34 unsigned index, |
39 unsigned start_offset, | 35 unsigned start_offset, |
40 unsigned end_offset) { | 36 unsigned end_offset) { |
41 NGWritingMode writing_mode( | 37 NGWritingMode writing_mode( |
42 FromPlatformWritingMode(node_->Style().GetWritingMode())); | 38 FromPlatformWritingMode(node_->Style().GetWritingMode())); |
43 return AdoptRef(new NGPhysicalTextFragment( | 39 return AdoptRef(new NGPhysicalTextFragment( |
44 node_->GetLayoutObject(), node_, index, start_offset, end_offset, | 40 node_->GetLayoutObject(), node_, index, start_offset, end_offset, |
45 size_.ConvertToPhysical(writing_mode))); | 41 size_.ConvertToPhysical(writing_mode))); |
46 } | 42 } |
47 | 43 |
48 } // namespace blink | 44 } // namespace blink |
OLD | NEW |