OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 NGLayoutInlineItemsBuilder_h | 5 #ifndef NGLayoutInlineItemsBuilder_h |
6 #define NGLayoutInlineItemsBuilder_h | 6 #define NGLayoutInlineItemsBuilder_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "wtf/Allocator.h" | 9 #include "wtf/Allocator.h" |
10 #include "wtf/Vector.h" | 10 #include "wtf/Vector.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 void Append(const String&, const ComputedStyle*, LayoutObject* = nullptr); | 54 void Append(const String&, const ComputedStyle*, LayoutObject* = nullptr); |
55 | 55 |
56 // Append a character. | 56 // Append a character. |
57 // Currently this function is for adding control characters such as | 57 // Currently this function is for adding control characters such as |
58 // objectReplacementCharacter, and does not support all space collapsing logic | 58 // objectReplacementCharacter, and does not support all space collapsing logic |
59 // as its String version does. | 59 // as its String version does. |
60 // See the String version for using nullptr for ComputedStyle and | 60 // See the String version for using nullptr for ComputedStyle and |
61 // LayoutObject. | 61 // LayoutObject. |
62 void Append(UChar, const ComputedStyle* = nullptr, LayoutObject* = nullptr); | 62 void Append(UChar, const ComputedStyle* = nullptr, LayoutObject* = nullptr); |
63 | 63 |
64 // Append a character. | 64 // Append a Bidi control character, for LTR or RTL depends on the style. |
65 // The character is opaque to space collapsing that spaces before this | |
66 // character and after this character can collapse as if this character does | |
67 // not exist. | |
68 void AppendAsOpaqueToSpaceCollapsing(UChar); | |
69 void AppendBidiControl(const ComputedStyle*, UChar ltr, UChar rtl); | 65 void AppendBidiControl(const ComputedStyle*, UChar ltr, UChar rtl); |
70 | 66 |
71 void EnterBlock(const ComputedStyle*); | 67 void EnterBlock(const ComputedStyle*); |
72 void ExitBlock(); | 68 void ExitBlock(); |
73 void EnterInline(LayoutObject*); | 69 void EnterInline(LayoutObject*); |
74 void ExitInline(LayoutObject*); | 70 void ExitInline(LayoutObject*); |
75 | 71 |
76 private: | 72 private: |
77 Vector<NGLayoutInlineItem>* items_; | 73 Vector<NGLayoutInlineItem>* items_; |
78 StringBuilder text_; | 74 StringBuilder text_; |
79 | 75 |
80 typedef struct OnExitNode { | 76 typedef struct OnExitNode { |
81 LayoutObject* node; | 77 LayoutObject* node; |
82 UChar character; | 78 UChar character; |
83 } OnExitNode; | 79 } OnExitNode; |
84 Vector<OnExitNode> exits_; | 80 Vector<OnExitNode> exits_; |
85 | 81 |
86 bool is_last_collapsible_space_ = true; | 82 enum class CollapsibleSpace { None, Space, Newline }; |
87 bool has_pending_newline_ = false; | 83 |
| 84 CollapsibleSpace last_collapsible_space_ = CollapsibleSpace::Space; |
88 bool is_svgtext_ = false; | 85 bool is_svgtext_ = false; |
89 bool has_bidi_controls_ = false; | 86 bool has_bidi_controls_ = false; |
90 | 87 |
91 // Because newlines may be removed depends on following characters, newlines | 88 // Because newlines may be removed depends on following characters, newlines |
92 // at the end of input string is not added to |text_| but instead | 89 // at the end of input string is not added to |text_| but instead |
93 // |has_pending_newline_| flag is set. | 90 // |has_pending_newline_| flag is set. |
94 // This function determines whether to add the newline or ignore. | 91 // This function determines whether to add the newline or ignore. |
95 void ProcessPendingNewline(const String&, const ComputedStyle*); | 92 void ProcessPendingNewline(const String&, const ComputedStyle*); |
96 | 93 |
97 // Removes the collapsible space at the end of |text_| if exists. | 94 // Removes the collapsible space at the end of |text_| if exists. |
| 95 void RemoveTrailingCollapsibleSpaceIfExists(unsigned*); |
98 void RemoveTrailingCollapsibleSpace(unsigned*); | 96 void RemoveTrailingCollapsibleSpace(unsigned*); |
99 | 97 |
| 98 void RemoveTrailingCollapsibleNewlineIfNeeded(unsigned*, |
| 99 const String&, |
| 100 unsigned, |
| 101 const ComputedStyle*); |
| 102 |
100 void Enter(LayoutObject*, UChar); | 103 void Enter(LayoutObject*, UChar); |
101 void Exit(LayoutObject*); | 104 void Exit(LayoutObject*); |
102 }; | 105 }; |
103 | 106 |
104 } // namespace blink | 107 } // namespace blink |
105 | 108 |
106 #endif // NGLayoutInlineItemsBuilder_h | 109 #endif // NGLayoutInlineItemsBuilder_h |
OLD | NEW |