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