| 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 #ifndef NGLineBoxFragmentBuilder_h | 5 #ifndef NGLineBoxFragmentBuilder_h |
| 6 #define NGLineBoxFragmentBuilder_h | 6 #define NGLineBoxFragmentBuilder_h |
| 7 | 7 |
| 8 #include "core/layout/ng/geometry/ng_logical_offset.h" | 8 #include "core/layout/ng/geometry/ng_logical_offset.h" |
| 9 #include "core/layout/ng/inline/ng_inline_break_token.h" | 9 #include "core/layout/ng/inline/ng_inline_break_token.h" |
| 10 #include "core/layout/ng/inline/ng_line_height_metrics.h" | 10 #include "core/layout/ng/inline/ng_line_height_metrics.h" |
| 11 #include "platform/wtf/Allocator.h" | 11 #include "platform/wtf/Allocator.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 class NGInlineNode; | 15 class NGInlineNode; |
| 16 class NGPhysicalFragment; | 16 class NGPhysicalFragment; |
| 17 class NGPhysicalLineBoxFragment; | 17 class NGPhysicalLineBoxFragment; |
| 18 | 18 |
| 19 class CORE_EXPORT NGLineBoxFragmentBuilder final { | 19 class CORE_EXPORT NGLineBoxFragmentBuilder final { |
| 20 STACK_ALLOCATED(); | 20 STACK_ALLOCATED(); |
| 21 | 21 |
| 22 public: | 22 public: |
| 23 NGLineBoxFragmentBuilder(NGInlineNode*, const NGLineHeightMetrics&); | 23 explicit NGLineBoxFragmentBuilder(NGInlineNode*); |
| 24 | 24 |
| 25 NGLineBoxFragmentBuilder& SetDirection(TextDirection); | 25 NGLineBoxFragmentBuilder& SetDirection(TextDirection); |
| 26 | 26 |
| 27 NGLineBoxFragmentBuilder& SetInlineSize(LayoutUnit); | 27 NGLineBoxFragmentBuilder& SetInlineSize(LayoutUnit); |
| 28 | 28 |
| 29 NGLineBoxFragmentBuilder& AddChild(RefPtr<NGPhysicalFragment>, | 29 NGLineBoxFragmentBuilder& AddChild(RefPtr<NGPhysicalFragment>, |
| 30 const NGLogicalOffset&); | 30 const NGLogicalOffset&); |
| 31 void MoveChildrenInBlockDirection(LayoutUnit); | 31 void MoveChildrenInBlockDirection(LayoutUnit); |
| 32 void MoveChildrenInBlockDirection(LayoutUnit, unsigned start, unsigned end); | 32 void MoveChildrenInBlockDirection(LayoutUnit, unsigned start, unsigned end); |
| 33 | 33 |
| 34 const Vector<RefPtr<NGPhysicalFragment>>& Children() const { | 34 const Vector<RefPtr<NGPhysicalFragment>>& Children() const { |
| 35 return children_; | 35 return children_; |
| 36 } | 36 } |
| 37 | 37 |
| 38 void UniteMetrics(const NGLineHeightMetrics&); | 38 void SetMetrics(const NGLineHeightMetrics&); |
| 39 const NGLineHeightMetrics& Metrics() const { return metrics_; } | 39 const NGLineHeightMetrics& Metrics() const { return metrics_; } |
| 40 | 40 |
| 41 // Set the break token for the fragment to build. | 41 // Set the break token for the fragment to build. |
| 42 // A finished break token will be attached if not set. | 42 // A finished break token will be attached if not set. |
| 43 void SetBreakToken(RefPtr<NGInlineBreakToken>); | 43 void SetBreakToken(RefPtr<NGInlineBreakToken>); |
| 44 | 44 |
| 45 // Creates the fragment. Can only be called once. | 45 // Creates the fragment. Can only be called once. |
| 46 RefPtr<NGPhysicalLineBoxFragment> ToLineBoxFragment(); | 46 RefPtr<NGPhysicalLineBoxFragment> ToLineBoxFragment(); |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 TextDirection direction_; | 49 TextDirection direction_; |
| 50 | 50 |
| 51 Persistent<NGInlineNode> node_; | 51 Persistent<NGInlineNode> node_; |
| 52 | 52 |
| 53 LayoutUnit inline_size_; | 53 LayoutUnit inline_size_; |
| 54 | 54 |
| 55 Vector<RefPtr<NGPhysicalFragment>> children_; | 55 Vector<RefPtr<NGPhysicalFragment>> children_; |
| 56 Vector<NGLogicalOffset> offsets_; | 56 Vector<NGLogicalOffset> offsets_; |
| 57 | 57 |
| 58 NGLineHeightMetrics metrics_; | 58 NGLineHeightMetrics metrics_; |
| 59 | 59 |
| 60 RefPtr<NGInlineBreakToken> break_token_; | 60 RefPtr<NGInlineBreakToken> break_token_; |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 } // namespace blink | 63 } // namespace blink |
| 64 | 64 |
| 65 #endif // NGLineBoxFragmentBuilder | 65 #endif // NGLineBoxFragmentBuilder |
| OLD | NEW |