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 NGLineBreaker_h | 5 #ifndef NGLineBreaker_h |
6 #define NGLineBreaker_h | 6 #define NGLineBreaker_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/layout/ng/inline/ng_inline_item_result.h" | 9 #include "core/layout/ng/inline/ng_inline_item_result.h" |
10 #include "core/layout/ng/inline/ng_inline_node.h" | 10 #include "core/layout/ng/inline/ng_inline_node.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 const NGConstraintSpace*, | 31 const NGConstraintSpace*, |
32 NGInlineBreakToken* = nullptr); | 32 NGInlineBreakToken* = nullptr); |
33 ~NGLineBreaker() {} | 33 ~NGLineBreaker() {} |
34 STACK_ALLOCATED(); | 34 STACK_ALLOCATED(); |
35 | 35 |
36 // Compute the next line break point and produces NGInlineItemResults for | 36 // Compute the next line break point and produces NGInlineItemResults for |
37 // the line. | 37 // the line. |
38 // TODO(kojii): NGInlineLayoutAlgorithm is needed because floats require | 38 // TODO(kojii): NGInlineLayoutAlgorithm is needed because floats require |
39 // not only constraint space but also container builder. Consider refactor | 39 // not only constraint space but also container builder. Consider refactor |
40 // not to require algorithm. | 40 // not to require algorithm. |
41 void NextLine(NGInlineItemResults*, NGInlineLayoutAlgorithm*); | 41 bool NextLine(NGLineInfo*, NGInlineLayoutAlgorithm*); |
42 | 42 |
43 // Create an NGInlineBreakToken for the last line returned by NextLine(). | 43 // Create an NGInlineBreakToken for the last line returned by NextLine(). |
44 RefPtr<NGInlineBreakToken> CreateBreakToken() const; | 44 RefPtr<NGInlineBreakToken> CreateBreakToken() const; |
45 | 45 |
46 private: | 46 private: |
47 void BreakLine(NGInlineItemResults*, NGInlineLayoutAlgorithm*); | 47 void BreakLine(NGLineInfo*, NGInlineLayoutAlgorithm*); |
48 | 48 |
49 enum class LineBreakState { | 49 enum class LineBreakState { |
50 // The current position is not breakable. | 50 // The current position is not breakable. |
51 kNotBreakable, | 51 kNotBreakable, |
52 // The current position is breakable. | 52 // The current position is breakable. |
53 kIsBreakable, | 53 kIsBreakable, |
54 // Break by including trailing items (CloseTag). | 54 // Break by including trailing items (CloseTag). |
55 kBreakAfterTrailings, | 55 kBreakAfterTrailings, |
56 // Break immediately. | 56 // Break immediately. |
57 kForcedBreak | 57 kForcedBreak |
58 }; | 58 }; |
59 | 59 |
60 LineBreakState HandleText(const NGInlineItem&, NGInlineItemResult*); | 60 LineBreakState HandleText(const NGInlineItem&, NGInlineItemResult*); |
61 void BreakText(NGInlineItemResult*, | 61 void BreakText(NGInlineItemResult*, |
62 const NGInlineItem&, | 62 const NGInlineItem&, |
63 LayoutUnit available_width); | 63 LayoutUnit available_width); |
64 | 64 |
65 LineBreakState HandleControlItem(const NGInlineItem&, NGInlineItemResult*); | 65 LineBreakState HandleControlItem(const NGInlineItem&, NGInlineItemResult*); |
66 LineBreakState HandleAtomicInline(const NGInlineItem&, NGInlineItemResult*); | 66 LineBreakState HandleAtomicInline(const NGInlineItem&, NGInlineItemResult*); |
67 void HandleFloat(const NGInlineItem&, | 67 void HandleFloat(const NGInlineItem&, |
68 NGInlineItemResults*, | 68 NGInlineItemResults*, |
69 NGInlineLayoutAlgorithm*); | 69 NGInlineLayoutAlgorithm*); |
70 | 70 |
71 void HandleOpenTag(const NGInlineItem&, NGInlineItemResult*); | 71 void HandleOpenTag(const NGInlineItem&, NGInlineItemResult*); |
72 void HandleCloseTag(const NGInlineItem&, NGInlineItemResult*); | 72 void HandleCloseTag(const NGInlineItem&, NGInlineItemResult*); |
73 | 73 |
74 void HandleOverflow(NGInlineItemResults*); | 74 void HandleOverflow(NGLineInfo*); |
75 void Rewind(NGInlineItemResults*, unsigned new_end); | 75 void Rewind(NGLineInfo*, unsigned new_end); |
76 | 76 |
77 void UpdateBreakIterator(const ComputedStyle&); | 77 void UpdateBreakIterator(const ComputedStyle&); |
78 | 78 |
79 void MoveToNextOf(const NGInlineItem&); | 79 void MoveToNextOf(const NGInlineItem&); |
80 void MoveToNextOf(const NGInlineItemResult&); | 80 void MoveToNextOf(const NGInlineItemResult&); |
81 void SkipCollapsibleWhitespaces(); | 81 void SkipCollapsibleWhitespaces(); |
82 | 82 |
83 NGInlineNode node_; | 83 NGInlineNode node_; |
84 const NGConstraintSpace* constraint_space_; | 84 const NGConstraintSpace* constraint_space_; |
85 const AtomicString locale_; | 85 const AtomicString locale_; |
86 unsigned item_index_; | 86 unsigned item_index_; |
87 unsigned offset_; | 87 unsigned offset_; |
88 LayoutUnit available_width_; | 88 LayoutUnit available_width_; |
89 LayoutUnit position_; | 89 LayoutUnit position_; |
90 LazyLineBreakIterator break_iterator_; | 90 LazyLineBreakIterator break_iterator_; |
91 HarfBuzzShaper shaper_; | 91 HarfBuzzShaper shaper_; |
92 | 92 |
93 unsigned auto_wrap_ : 1; | 93 unsigned auto_wrap_ : 1; |
94 }; | 94 }; |
95 | 95 |
96 } // namespace blink | 96 } // namespace blink |
97 | 97 |
98 #endif // NGLineBreaker_h | 98 #endif // NGLineBreaker_h |
OLD | NEW |