| 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 NGConstraintSpace; |
| 17 |
| 16 class NGInlineNode; | 18 class NGInlineNode; |
| 17 | 19 |
| 18 // The result of measuring NGInlineItem. | 20 // The result of measuring NGInlineItem. |
| 19 // | 21 // |
| 20 // This is a transient context object only while building line boxes. | 22 // This is a transient context object only while building line boxes. |
| 21 // Produced while determining the line break points, but these data are needed | 23 // Produced while determining the line break points, but these data are needed |
| 22 // to create line boxes. | 24 // to create line boxes. |
| 23 // | 25 // |
| 24 // NGLineBreaker produces, and NGInlineLayoutAlgorithm consumes. | 26 // NGLineBreaker produces, and NGInlineLayoutAlgorithm consumes. |
| 25 struct CORE_EXPORT NGInlineItemResult { | 27 struct CORE_EXPORT NGInlineItemResult { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 78 |
| 77 public: | 79 public: |
| 78 NGLineInfo() {} | 80 NGLineInfo() {} |
| 79 explicit NGLineInfo(size_t capacity) : results_(capacity) {} | 81 explicit NGLineInfo(size_t capacity) : results_(capacity) {} |
| 80 | 82 |
| 81 // The style to use for the line. | 83 // The style to use for the line. |
| 82 const ComputedStyle& LineStyle() const { | 84 const ComputedStyle& LineStyle() const { |
| 83 DCHECK(line_style_); | 85 DCHECK(line_style_); |
| 84 return *line_style_; | 86 return *line_style_; |
| 85 } | 87 } |
| 86 void SetLineStyle(const NGInlineNode&, bool is_first_line); | 88 void SetLineStyle(const NGInlineNode&, |
| 89 const NGConstraintSpace&, |
| 90 bool is_first_line, |
| 91 bool is_after_forced_break); |
| 87 | 92 |
| 88 // Use ::first-line style if true. | 93 // Use ::first-line style if true. |
| 89 // https://drafts.csswg.org/css-pseudo/#selectordef-first-line | 94 // https://drafts.csswg.org/css-pseudo/#selectordef-first-line |
| 90 bool IsFirstLine() const { return is_first_line_; } | 95 // This is false for the "first formatted line" if '::first-line' rule is not |
| 96 // used in the document. |
| 97 // https://www.w3.org/TR/CSS22/selector.html#first-formatted-line |
| 98 bool UseFirstLineStyle() const { return use_first_line_style_; } |
| 91 | 99 |
| 92 // The last line of a block, or the line ends with a forced line break. | 100 // The last line of a block, or the line ends with a forced line break. |
| 93 // https://drafts.csswg.org/css-text-3/#propdef-text-align-last | 101 // https://drafts.csswg.org/css-text-3/#propdef-text-align-last |
| 94 bool IsLastLine() const { return is_last_line_; } | 102 bool IsLastLine() const { return is_last_line_; } |
| 95 void SetIsLastLine(bool is_last_line) { is_last_line_ = is_last_line; } | 103 void SetIsLastLine(bool is_last_line) { is_last_line_ = is_last_line; } |
| 96 | 104 |
| 97 // NGInlineItemResults for this line. | 105 // NGInlineItemResults for this line. |
| 98 NGInlineItemResults& Results() { return results_; } | 106 NGInlineItemResults& Results() { return results_; } |
| 99 const NGInlineItemResults& Results() const { return results_; } | 107 const NGInlineItemResults& Results() const { return results_; } |
| 100 | 108 |
| 109 LayoutUnit TextIndent() const { return text_indent_; } |
| 110 |
| 101 LayoutUnit LineLeft() const { return line_left_; } | 111 LayoutUnit LineLeft() const { return line_left_; } |
| 102 LayoutUnit AvailableWidth() const { return available_width_; } | 112 LayoutUnit AvailableWidth() const { return available_width_; } |
| 103 LayoutUnit LineTop() const { return line_top_; } | 113 LayoutUnit LineTop() const { return line_top_; } |
| 104 void SetLineLocation(LayoutUnit line_left, | 114 void SetLineLocation(LayoutUnit line_left, |
| 105 LayoutUnit available_width, | 115 LayoutUnit available_width, |
| 106 LayoutUnit line_top); | 116 LayoutUnit line_top); |
| 107 | 117 |
| 108 private: | 118 private: |
| 109 const ComputedStyle* line_style_ = nullptr; | 119 const ComputedStyle* line_style_ = nullptr; |
| 110 NGInlineItemResults results_; | 120 NGInlineItemResults results_; |
| 121 |
| 111 LayoutUnit line_left_; | 122 LayoutUnit line_left_; |
| 112 LayoutUnit available_width_; | 123 LayoutUnit available_width_; |
| 113 LayoutUnit line_top_; | 124 LayoutUnit line_top_; |
| 114 bool is_first_line_ = false; | 125 LayoutUnit text_indent_; |
| 126 |
| 127 bool use_first_line_style_ = false; |
| 115 bool is_last_line_ = false; | 128 bool is_last_line_ = false; |
| 116 }; | 129 }; |
| 117 | 130 |
| 118 } // namespace blink | 131 } // namespace blink |
| 119 | 132 |
| 120 #endif // NGInlineItemResult_h | 133 #endif // NGInlineItemResult_h |
| OLD | NEW |