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 "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
10 #include "platform/wtf/text/AtomicString.h" | 11 #include "platform/wtf/text/AtomicString.h" |
11 | 12 |
12 namespace blink { | 13 namespace blink { |
13 | 14 |
| 15 class LazyLineBreakIterator; |
| 16 class NGInlineBreakToken; |
| 17 class NGInlineItem; |
| 18 class NGInlineNode; |
14 class NGInlineLayoutAlgorithm; | 19 class NGInlineLayoutAlgorithm; |
15 | 20 |
16 // Represents a line breaker. | 21 // Represents a line breaker. |
| 22 // |
| 23 // This class measures each NGInlineItem and determines items to form a line, |
| 24 // so that NGInlineLayoutAlgorithm can build a line box from the output. |
17 class CORE_EXPORT NGLineBreaker { | 25 class CORE_EXPORT NGLineBreaker { |
18 public: | 26 public: |
19 NGLineBreaker(const AtomicString locale) : locale_(locale) {} | 27 NGLineBreaker(NGInlineNode*, |
| 28 const NGConstraintSpace*, |
| 29 NGInlineBreakToken* = nullptr); |
20 ~NGLineBreaker() {} | 30 ~NGLineBreaker() {} |
21 STACK_ALLOCATED(); | 31 STACK_ALLOCATED(); |
22 | 32 |
23 void BreakLines(NGInlineLayoutAlgorithm*, const String&, unsigned); | 33 // Compute the next line break point and produces NGInlineItemResults for |
| 34 // the line. |
| 35 // TODO(kojii): NGInlineLayoutAlgorithm is needed because floats require |
| 36 // not only constraint space but also container builder. Consider refactor |
| 37 // not to require algorithm. |
| 38 void NextLine(NGInlineItemResults*, NGInlineLayoutAlgorithm*); |
| 39 |
| 40 // Create an NGInlineBreakToken for the last line returned by NextLine(). |
| 41 RefPtr<NGInlineBreakToken> CreateBreakToken() const; |
24 | 42 |
25 private: | 43 private: |
| 44 void BreakLine(NGInlineItemResults*, NGInlineLayoutAlgorithm*); |
| 45 |
| 46 void LayoutAtomicInline(const NGInlineItem&, NGInlineItemResult*); |
| 47 |
| 48 void HandleOverflow(NGInlineItemResults*, const LazyLineBreakIterator&); |
| 49 |
| 50 void SkipCollapsibleWhitespaces(); |
| 51 |
| 52 void AppendCloseTags(NGInlineItemResults*); |
| 53 |
| 54 Persistent<NGInlineNode> node_; |
| 55 const NGConstraintSpace* constraint_space_; |
26 const AtomicString locale_; | 56 const AtomicString locale_; |
| 57 unsigned item_index_; |
| 58 unsigned offset_; |
27 }; | 59 }; |
28 | 60 |
29 } // namespace blink | 61 } // namespace blink |
30 | 62 |
31 #endif // NGLineBreaker_h | 63 #endif // NGLineBreaker_h |
OLD | NEW |