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 NGInlineItemResult_h | 5 #ifndef NGInlineItemResult_h |
6 #define NGInlineItemResult_h | 6 #define NGInlineItemResult_h |
7 | 7 |
8 #include "core/layout/ng/geometry/ng_box_strut.h" | 8 #include "core/layout/ng/geometry/ng_box_strut.h" |
9 #include "core/layout/ng/ng_layout_result.h" | 9 #include "core/layout/ng/ng_layout_result.h" |
10 #include "platform/LayoutUnit.h" | 10 #include "platform/LayoutUnit.h" |
11 #include "platform/fonts/shaping/ShapeResult.h" | 11 #include "platform/fonts/shaping/ShapeResult.h" |
12 #include "platform/wtf/Allocator.h" | 12 #include "platform/wtf/Allocator.h" |
13 | 13 |
14 namespace blink { | 14 namespace blink { |
15 | 15 |
| 16 class NGInlineNode; |
| 17 |
16 // The result of measuring NGInlineItem. | 18 // The result of measuring NGInlineItem. |
17 // | 19 // |
18 // This is a transient context object only while building line boxes. | 20 // This is a transient context object only while building line boxes. |
19 // Produced while determining the line break points, but these data are needed | 21 // Produced while determining the line break points, but these data are needed |
20 // to create line boxes. | 22 // to create line boxes. |
21 // | 23 // |
22 // NGLineBreaker produces, and NGInlineLayoutAlgorithm consumes. | 24 // NGLineBreaker produces, and NGInlineLayoutAlgorithm consumes. |
23 struct CORE_EXPORT NGInlineItemResult { | 25 struct CORE_EXPORT NGInlineItemResult { |
24 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 26 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
25 | 27 |
(...skipping 28 matching lines...) Expand all Loading... |
54 // Used only during line breaking. | 56 // Used only during line breaking. |
55 unsigned prohibit_break_after : 1; | 57 unsigned prohibit_break_after : 1; |
56 | 58 |
57 NGInlineItemResult(); | 59 NGInlineItemResult(); |
58 NGInlineItemResult(unsigned index, unsigned start, unsigned end); | 60 NGInlineItemResult(unsigned index, unsigned start, unsigned end); |
59 }; | 61 }; |
60 | 62 |
61 // Represents a set of NGInlineItemResult that form a line box. | 63 // Represents a set of NGInlineItemResult that form a line box. |
62 using NGInlineItemResults = Vector<NGInlineItemResult, 32>; | 64 using NGInlineItemResults = Vector<NGInlineItemResult, 32>; |
63 | 65 |
| 66 // Represents a line to build. |
| 67 // |
| 68 // This is a transient context object only while building line boxes. |
| 69 // |
| 70 // NGLineBreaker produces, and NGInlineLayoutAlgorithm consumes. |
| 71 class CORE_EXPORT NGLineInfo { |
| 72 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 73 |
| 74 public: |
| 75 NGLineInfo() {} |
| 76 explicit NGLineInfo(size_t capacity) : results_(capacity) {} |
| 77 |
| 78 // The style to use for the line. |
| 79 const ComputedStyle& LineStyle() const { |
| 80 DCHECK(line_style_); |
| 81 return *line_style_; |
| 82 } |
| 83 void SetLineStyle(const NGInlineNode&, bool is_first_line); |
| 84 |
| 85 // Use ::first-line style if true. |
| 86 // https://drafts.csswg.org/css-pseudo/#selectordef-first-line |
| 87 bool IsFirstLine() const { return is_first_line_; } |
| 88 |
| 89 // The last line of a block, or the line ends with a forced line break. |
| 90 // https://drafts.csswg.org/css-text-3/#propdef-text-align-last |
| 91 bool IsLastLine() const { return is_last_line_; } |
| 92 void SetIsLastLine(bool is_last_line) { is_last_line_ = is_last_line; } |
| 93 |
| 94 // NGInlineItemResults for this line. |
| 95 NGInlineItemResults& Results() { return results_; } |
| 96 |
| 97 private: |
| 98 const ComputedStyle* line_style_ = nullptr; |
| 99 NGInlineItemResults results_; |
| 100 bool is_first_line_ = false; |
| 101 bool is_last_line_ = false; |
| 102 }; |
| 103 |
64 } // namespace blink | 104 } // namespace blink |
65 | 105 |
66 #endif // NGInlineItemResult_h | 106 #endif // NGInlineItemResult_h |
OLD | NEW |