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 NGInlineNode_h | 5 #ifndef NGInlineNode_h |
6 #define NGInlineNode_h | 6 #define NGInlineNode_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/layout/LayoutBlockFlow.h" | 9 #include "core/layout/LayoutBlockFlow.h" |
10 #include "core/layout/ng/ng_layout_input_node.h" | 10 #include "core/layout/ng/ng_layout_input_node.h" |
| 11 #include "core/layout/ng/ng_layout_result.h" |
11 #include "platform/fonts/FontFallbackPriority.h" | 12 #include "platform/fonts/FontFallbackPriority.h" |
12 #include "platform/fonts/shaping/ShapeResult.h" | 13 #include "platform/fonts/shaping/ShapeResult.h" |
13 #include "platform/heap/Handle.h" | 14 #include "platform/heap/Handle.h" |
14 #include "platform/text/TextDirection.h" | 15 #include "platform/text/TextDirection.h" |
15 #include "wtf/text/WTFString.h" | 16 #include "wtf/text/WTFString.h" |
16 | 17 |
17 #include <unicode/ubidi.h> | 18 #include <unicode/ubidi.h> |
18 #include <unicode/uscript.h> | 19 #include <unicode/uscript.h> |
19 | 20 |
20 namespace blink { | 21 namespace blink { |
21 | 22 |
22 class ComputedStyle; | 23 class ComputedStyle; |
23 class LayoutBlockFlow; | 24 class LayoutBlockFlow; |
24 class LayoutObject; | 25 class LayoutObject; |
25 class LayoutUnit; | 26 class LayoutUnit; |
26 struct MinMaxContentSize; | 27 struct MinMaxContentSize; |
27 class NGConstraintSpace; | 28 class NGConstraintSpace; |
28 class NGLayoutInlineItem; | 29 class NGLayoutInlineItem; |
29 class NGLayoutInlineItemRange; | 30 class NGLayoutInlineItemRange; |
30 class NGLayoutInlineItemsBuilder; | 31 class NGLayoutInlineItemsBuilder; |
31 class NGLayoutResult; | |
32 class NGLineBuilder; | 32 class NGLineBuilder; |
33 | 33 |
34 // Represents an anonymous block box to be laid out, that contains consecutive | 34 // Represents an anonymous block box to be laid out, that contains consecutive |
35 // inline nodes and their descendants. | 35 // inline nodes and their descendants. |
36 class CORE_EXPORT NGInlineNode : public NGLayoutInputNode { | 36 class CORE_EXPORT NGInlineNode : public NGLayoutInputNode { |
37 public: | 37 public: |
38 NGInlineNode(LayoutObject* start_inline, LayoutBlockFlow*); | 38 NGInlineNode(LayoutObject* start_inline, LayoutBlockFlow*); |
39 ~NGInlineNode() override; | 39 ~NGInlineNode() override; |
40 | 40 |
41 LayoutBlockFlow* GetLayoutBlockFlow() const { return block_; } | 41 LayoutBlockFlow* GetLayoutBlockFlow() const { return block_; } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // calling the Layout method. | 78 // calling the Layout method. |
79 void PrepareLayout(); | 79 void PrepareLayout(); |
80 bool IsPrepareLayoutFinished() const { return !text_content_.isNull(); } | 80 bool IsPrepareLayoutFinished() const { return !text_content_.isNull(); } |
81 | 81 |
82 void CollectInlines(LayoutObject* start, LayoutBlockFlow*); | 82 void CollectInlines(LayoutObject* start, LayoutBlockFlow*); |
83 LayoutObject* CollectInlines(LayoutObject* start, | 83 LayoutObject* CollectInlines(LayoutObject* start, |
84 LayoutBlockFlow*, | 84 LayoutBlockFlow*, |
85 NGLayoutInlineItemsBuilder*); | 85 NGLayoutInlineItemsBuilder*); |
86 void SegmentText(); | 86 void SegmentText(); |
87 void ShapeText(); | 87 void ShapeText(); |
| 88 void LayoutAtomicInlines(const NGConstraintSpace&); |
88 | 89 |
89 LayoutObject* start_inline_; | 90 LayoutObject* start_inline_; |
90 LayoutBlockFlow* block_; | 91 LayoutBlockFlow* block_; |
91 Member<NGLayoutInputNode> next_sibling_; | 92 Member<NGLayoutInputNode> next_sibling_; |
92 | 93 |
93 // Text content for all inline items represented by a single NGInlineNode | 94 // Text content for all inline items represented by a single NGInlineNode |
94 // instance. Encoded either as UTF-16 or latin-1 depending on content. | 95 // instance. Encoded either as UTF-16 or latin-1 depending on content. |
95 String text_content_; | 96 String text_content_; |
96 Vector<NGLayoutInlineItem> items_; | 97 Vector<NGLayoutInlineItem> items_; |
97 | 98 |
98 // TODO(kojii): This should move to somewhere else when we move PrepareLayout | 99 unsigned has_atomic_inlines_ : 1; |
99 // to the correct place. | 100 unsigned is_bidi_enabled_ : 1; |
100 bool is_bidi_enabled_ = false; | |
101 }; | 101 }; |
102 | 102 |
103 // Class representing a single text node or styled inline element with text | 103 // Class representing a single text node or styled inline element with text |
104 // content segmented by style, text direction, sideways rotation, font fallback | 104 // content segmented by style, text direction, sideways rotation, font fallback |
105 // priority (text, symbol, emoji, etc) and script (but not by font). | 105 // priority (text, symbol, emoji, etc) and script (but not by font). |
106 // In this representation TextNodes are merged up into their parent inline | 106 // In this representation TextNodes are merged up into their parent inline |
107 // element where possible. | 107 // element where possible. |
108 class NGLayoutInlineItem { | 108 class NGLayoutInlineItem { |
109 public: | 109 public: |
110 NGLayoutInlineItem(unsigned start, | 110 NGLayoutInlineItem(unsigned start, |
(...skipping 13 matching lines...) Expand all Loading... |
124 | 124 |
125 unsigned StartOffset() const { return start_offset_; } | 125 unsigned StartOffset() const { return start_offset_; } |
126 unsigned EndOffset() const { return end_offset_; } | 126 unsigned EndOffset() const { return end_offset_; } |
127 TextDirection Direction() const { | 127 TextDirection Direction() const { |
128 return bidi_level_ & 1 ? TextDirection::kRtl : TextDirection::kLtr; | 128 return bidi_level_ & 1 ? TextDirection::kRtl : TextDirection::kLtr; |
129 } | 129 } |
130 UBiDiLevel BidiLevel() const { return bidi_level_; } | 130 UBiDiLevel BidiLevel() const { return bidi_level_; } |
131 UScriptCode Script() const { return script_; } | 131 UScriptCode Script() const { return script_; } |
132 const ComputedStyle* Style() const { return style_; } | 132 const ComputedStyle* Style() const { return style_; } |
133 LayoutObject* GetLayoutObject() const { return layout_object_; } | 133 LayoutObject* GetLayoutObject() const { return layout_object_; } |
| 134 const NGLayoutResult* GetLayoutResult() const { return layout_result_.get(); } |
134 | 135 |
135 void SetEndOffset(unsigned); | 136 void SetEndOffset(unsigned); |
136 | 137 |
137 LayoutUnit InlineSize() const; | 138 LayoutUnit InlineSize() const; |
138 LayoutUnit InlineSize(unsigned start, unsigned end) const; | 139 LayoutUnit InlineSize(unsigned start, unsigned end) const; |
139 | 140 |
140 void GetFallbackFonts(HashSet<const SimpleFontData*>*, | 141 void GetFallbackFonts(HashSet<const SimpleFontData*>*, |
141 unsigned start, | 142 unsigned start, |
142 unsigned end) const; | 143 unsigned end) const; |
143 | 144 |
(...skipping 11 matching lines...) Expand all Loading... |
155 private: | 156 private: |
156 unsigned start_offset_; | 157 unsigned start_offset_; |
157 unsigned end_offset_; | 158 unsigned end_offset_; |
158 UBiDiLevel bidi_level_; | 159 UBiDiLevel bidi_level_; |
159 UScriptCode script_; | 160 UScriptCode script_; |
160 FontFallbackPriority fallback_priority_; | 161 FontFallbackPriority fallback_priority_; |
161 bool rotate_sideways_; | 162 bool rotate_sideways_; |
162 const ComputedStyle* style_; | 163 const ComputedStyle* style_; |
163 RefPtr<const ShapeResult> shape_result_; | 164 RefPtr<const ShapeResult> shape_result_; |
164 LayoutObject* layout_object_; | 165 LayoutObject* layout_object_; |
| 166 RefPtr<const NGLayoutResult> layout_result_; |
165 | 167 |
166 friend class NGInlineNode; | 168 friend class NGInlineNode; |
167 }; | 169 }; |
168 | 170 |
169 inline void NGLayoutInlineItem::AssertOffset(unsigned offset) const { | 171 inline void NGLayoutInlineItem::AssertOffset(unsigned offset) const { |
170 DCHECK(offset >= start_offset_ && offset < end_offset_); | 172 DCHECK(offset >= start_offset_ && offset < end_offset_); |
171 } | 173 } |
172 | 174 |
173 inline void NGLayoutInlineItem::AssertEndOffset(unsigned offset) const { | 175 inline void NGLayoutInlineItem::AssertEndOffset(unsigned offset) const { |
174 DCHECK(offset >= start_offset_ && offset <= end_offset_); | 176 DCHECK(offset >= start_offset_ && offset <= end_offset_); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 225 |
224 private: | 226 private: |
225 NGLayoutInlineItem* start_item_; | 227 NGLayoutInlineItem* start_item_; |
226 unsigned size_; | 228 unsigned size_; |
227 unsigned start_index_; | 229 unsigned start_index_; |
228 }; | 230 }; |
229 | 231 |
230 } // namespace blink | 232 } // namespace blink |
231 | 233 |
232 #endif // NGInlineNode_h | 234 #endif // NGInlineNode_h |
OLD | NEW |