| 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/ng_line_box_fragment_builder.h" | 5 #include "core/layout/ng/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/ng_fragment.h" | 8 #include "core/layout/ng/ng_fragment.h" |
| 9 #include "core/layout/ng/ng_inline_break_token.h" |
| 9 #include "core/layout/ng/ng_inline_node.h" | 10 #include "core/layout/ng/ng_inline_node.h" |
| 10 #include "core/layout/ng/ng_physical_line_box_fragment.h" | 11 #include "core/layout/ng/ng_physical_line_box_fragment.h" |
| 11 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
| 12 | 13 |
| 13 namespace blink { | 14 namespace blink { |
| 14 | 15 |
| 15 NGLineBoxFragmentBuilder::NGLineBoxFragmentBuilder(NGInlineNode* node) | 16 NGLineBoxFragmentBuilder::NGLineBoxFragmentBuilder(NGInlineNode* node) |
| 16 : direction_(TextDirection::kLtr), node_(node) {} | 17 : direction_(TextDirection::kLtr), node_(node) {} |
| 17 | 18 |
| 18 NGLineBoxFragmentBuilder& NGLineBoxFragmentBuilder::SetDirection( | 19 NGLineBoxFragmentBuilder& NGLineBoxFragmentBuilder::SetDirection( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 39 void NGLineBoxFragmentBuilder::MoveChildrenInBlockDirection(LayoutUnit delta) { | 40 void NGLineBoxFragmentBuilder::MoveChildrenInBlockDirection(LayoutUnit delta) { |
| 40 for (auto& offset : offsets_) | 41 for (auto& offset : offsets_) |
| 41 offset.block_offset += delta; | 42 offset.block_offset += delta; |
| 42 } | 43 } |
| 43 | 44 |
| 44 void NGLineBoxFragmentBuilder::UniteMetrics( | 45 void NGLineBoxFragmentBuilder::UniteMetrics( |
| 45 const NGLineHeightMetrics& metrics) { | 46 const NGLineHeightMetrics& metrics) { |
| 46 metrics_.Unite(metrics); | 47 metrics_.Unite(metrics); |
| 47 } | 48 } |
| 48 | 49 |
| 50 void NGLineBoxFragmentBuilder::SetBreakToken( |
| 51 RefPtr<NGInlineBreakToken> break_token) { |
| 52 break_token_ = std::move(break_token); |
| 53 } |
| 54 |
| 49 RefPtr<NGPhysicalLineBoxFragment> | 55 RefPtr<NGPhysicalLineBoxFragment> |
| 50 NGLineBoxFragmentBuilder::ToLineBoxFragment() { | 56 NGLineBoxFragmentBuilder::ToLineBoxFragment() { |
| 51 DCHECK_EQ(offsets_.size(), children_.size()); | 57 DCHECK_EQ(offsets_.size(), children_.size()); |
| 52 | 58 |
| 53 NGWritingMode writing_mode( | 59 NGWritingMode writing_mode( |
| 54 FromPlatformWritingMode(node_->BlockStyle()->getWritingMode())); | 60 FromPlatformWritingMode(node_->BlockStyle()->getWritingMode())); |
| 55 NGPhysicalSize physical_size = | 61 NGPhysicalSize physical_size = |
| 56 NGLogicalSize(inline_size_, Metrics().LineHeight()) | 62 NGLogicalSize(inline_size_, Metrics().LineHeight()) |
| 57 .ConvertToPhysical(writing_mode); | 63 .ConvertToPhysical(writing_mode); |
| 58 | 64 |
| 59 for (size_t i = 0; i < children_.size(); ++i) { | 65 for (size_t i = 0; i < children_.size(); ++i) { |
| 60 NGPhysicalFragment* child = children_[i].get(); | 66 NGPhysicalFragment* child = children_[i].get(); |
| 61 child->SetOffset(offsets_[i].ConvertToPhysical( | 67 child->SetOffset(offsets_[i].ConvertToPhysical( |
| 62 writing_mode, direction_, physical_size, child->Size())); | 68 writing_mode, direction_, physical_size, child->Size())); |
| 63 } | 69 } |
| 64 | 70 |
| 65 // TODO(kojii): Implement BreakToken. | 71 return adoptRef(new NGPhysicalLineBoxFragment( |
| 66 return adoptRef(new NGPhysicalLineBoxFragment(physical_size, children_, | 72 physical_size, children_, metrics_, |
| 67 metrics_, nullptr)); | 73 break_token_ ? std::move(break_token_) |
| 74 : NGInlineBreakToken::create(node_))); |
| 68 } | 75 } |
| 69 | 76 |
| 70 } // namespace blink | 77 } // namespace blink |
| OLD | NEW |