| 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_line_box_fragment_builder.h" | 5 #include "core/layout/ng/inline/ng_line_box_fragment_builder.h" |
| 6 | 6 |
| 7 #include "core/layout/ng/geometry/ng_logical_size.h" | 7 #include "core/layout/ng/geometry/ng_logical_size.h" |
| 8 #include "core/layout/ng/inline/ng_inline_break_token.h" | 8 #include "core/layout/ng/inline/ng_inline_break_token.h" |
| 9 #include "core/layout/ng/inline/ng_inline_node.h" | 9 #include "core/layout/ng/inline/ng_inline_node.h" |
| 10 #include "core/layout/ng/inline/ng_physical_line_box_fragment.h" | 10 #include "core/layout/ng/inline/ng_physical_line_box_fragment.h" |
| 11 #include "core/layout/ng/ng_fragment.h" | 11 #include "core/layout/ng/ng_fragment.h" |
| 12 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 NGLineBoxFragmentBuilder::NGLineBoxFragmentBuilder( | 16 NGLineBoxFragmentBuilder::NGLineBoxFragmentBuilder(NGInlineNode* node) |
| 17 NGInlineNode* node, | 17 : direction_(TextDirection::kLtr), node_(node) {} |
| 18 const NGLineHeightMetrics& metrics) | |
| 19 : direction_(TextDirection::kLtr), node_(node), metrics_(metrics) {} | |
| 20 | 18 |
| 21 NGLineBoxFragmentBuilder& NGLineBoxFragmentBuilder::SetDirection( | 19 NGLineBoxFragmentBuilder& NGLineBoxFragmentBuilder::SetDirection( |
| 22 TextDirection direction) { | 20 TextDirection direction) { |
| 23 direction_ = direction; | 21 direction_ = direction; |
| 24 return *this; | 22 return *this; |
| 25 } | 23 } |
| 26 | 24 |
| 27 NGLineBoxFragmentBuilder& NGLineBoxFragmentBuilder::SetInlineSize( | 25 NGLineBoxFragmentBuilder& NGLineBoxFragmentBuilder::SetInlineSize( |
| 28 LayoutUnit size) { | 26 LayoutUnit size) { |
| 29 inline_size_ = size; | 27 inline_size_ = size; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 44 offset.block_offset += delta; | 42 offset.block_offset += delta; |
| 45 } | 43 } |
| 46 | 44 |
| 47 void NGLineBoxFragmentBuilder::MoveChildrenInBlockDirection(LayoutUnit delta, | 45 void NGLineBoxFragmentBuilder::MoveChildrenInBlockDirection(LayoutUnit delta, |
| 48 unsigned start, | 46 unsigned start, |
| 49 unsigned end) { | 47 unsigned end) { |
| 50 for (unsigned index = start; index < end; index++) | 48 for (unsigned index = start; index < end; index++) |
| 51 offsets_[index].block_offset += delta; | 49 offsets_[index].block_offset += delta; |
| 52 } | 50 } |
| 53 | 51 |
| 54 void NGLineBoxFragmentBuilder::UniteMetrics( | 52 void NGLineBoxFragmentBuilder::SetMetrics(const NGLineHeightMetrics& metrics) { |
| 55 const NGLineHeightMetrics& metrics) { | 53 metrics_ = metrics; |
| 56 metrics_.Unite(metrics); | |
| 57 } | 54 } |
| 58 | 55 |
| 59 void NGLineBoxFragmentBuilder::SetBreakToken( | 56 void NGLineBoxFragmentBuilder::SetBreakToken( |
| 60 RefPtr<NGInlineBreakToken> break_token) { | 57 RefPtr<NGInlineBreakToken> break_token) { |
| 61 break_token_ = std::move(break_token); | 58 break_token_ = std::move(break_token); |
| 62 } | 59 } |
| 63 | 60 |
| 64 RefPtr<NGPhysicalLineBoxFragment> | 61 RefPtr<NGPhysicalLineBoxFragment> |
| 65 NGLineBoxFragmentBuilder::ToLineBoxFragment() { | 62 NGLineBoxFragmentBuilder::ToLineBoxFragment() { |
| 66 DCHECK_EQ(offsets_.size(), children_.size()); | 63 DCHECK_EQ(offsets_.size(), children_.size()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 77 writing_mode, direction_, physical_size, child->Size())); | 74 writing_mode, direction_, physical_size, child->Size())); |
| 78 } | 75 } |
| 79 | 76 |
| 80 return AdoptRef(new NGPhysicalLineBoxFragment( | 77 return AdoptRef(new NGPhysicalLineBoxFragment( |
| 81 physical_size, children_, metrics_, | 78 physical_size, children_, metrics_, |
| 82 break_token_ ? std::move(break_token_) | 79 break_token_ ? std::move(break_token_) |
| 83 : NGInlineBreakToken::Create(node_))); | 80 : NGInlineBreakToken::Create(node_))); |
| 84 } | 81 } |
| 85 | 82 |
| 86 } // namespace blink | 83 } // namespace blink |
| OLD | NEW |