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 NGUnits_h | 5 #ifndef NGUnits_h |
6 #define NGUnits_h | 6 #define NGUnits_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/layout/ng/ng_direction.h" | 9 #include "core/layout/ng/ng_direction.h" |
10 #include "core/layout/ng/ng_writing_mode.h" | 10 #include "core/layout/ng/ng_writing_mode.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // four edges. | 103 // four edges. |
104 struct NGBoxStrut { | 104 struct NGBoxStrut { |
105 LayoutUnit inline_start; | 105 LayoutUnit inline_start; |
106 LayoutUnit inline_end; | 106 LayoutUnit inline_end; |
107 LayoutUnit block_start; | 107 LayoutUnit block_start; |
108 LayoutUnit block_end; | 108 LayoutUnit block_end; |
109 | 109 |
110 LayoutUnit InlineSum() const { return inline_start + inline_end; } | 110 LayoutUnit InlineSum() const { return inline_start + inline_end; } |
111 LayoutUnit BlockSum() const { return block_start + block_end; } | 111 LayoutUnit BlockSum() const { return block_start + block_end; } |
112 | 112 |
| 113 bool IsEmpty() const; |
| 114 |
113 // The following two operators exist primarily to have an easy way to access | 115 // The following two operators exist primarily to have an easy way to access |
114 // the sum of border and padding. | 116 // the sum of border and padding. |
115 NGBoxStrut& operator+=(const NGBoxStrut& other) { | 117 NGBoxStrut& operator+=(const NGBoxStrut& other) { |
116 inline_start += other.inline_start; | 118 inline_start += other.inline_start; |
117 inline_end += other.inline_end; | 119 inline_end += other.inline_end; |
118 block_start += other.block_start; | 120 block_start += other.block_start; |
119 block_end += other.block_end; | 121 block_end += other.block_end; |
120 return *this; | 122 return *this; |
121 } | 123 } |
122 | 124 |
123 NGBoxStrut operator+(const NGBoxStrut& other) { | 125 NGBoxStrut operator+(const NGBoxStrut& other) { |
124 NGBoxStrut result(*this); | 126 NGBoxStrut result(*this); |
125 result += other; | 127 result += other; |
126 return result; | 128 return result; |
127 } | 129 } |
| 130 |
| 131 bool operator==(const NGBoxStrut& other) const; |
128 }; | 132 }; |
129 | 133 |
130 // This struct is used for the margin collapsing calculation. | 134 // This struct is used for the margin collapsing calculation. |
131 struct CORE_EXPORT NGMarginStrut { | 135 struct CORE_EXPORT NGMarginStrut { |
132 LayoutUnit margin_block_start; | 136 LayoutUnit margin_block_start; |
133 LayoutUnit margin_block_end; | 137 LayoutUnit margin_block_end; |
134 | 138 |
135 LayoutUnit negative_margin_block_start; | 139 LayoutUnit negative_margin_block_start; |
136 LayoutUnit negative_margin_block_end; | 140 LayoutUnit negative_margin_block_end; |
137 | 141 |
138 void AppendMarginBlockStart(const LayoutUnit& value); | 142 void AppendMarginBlockStart(const LayoutUnit& value); |
139 void AppendMarginBlockEnd(const LayoutUnit& value); | 143 void AppendMarginBlockEnd(const LayoutUnit& value); |
140 void SetMarginBlockStart(const LayoutUnit& value); | 144 void SetMarginBlockStart(const LayoutUnit& value); |
141 void SetMarginBlockEnd(const LayoutUnit& value); | 145 void SetMarginBlockEnd(const LayoutUnit& value); |
142 | 146 |
143 String ToString() const; | 147 String ToString() const; |
144 | 148 |
145 bool operator==(const NGMarginStrut& other) const; | 149 bool operator==(const NGMarginStrut& other) const; |
146 }; | 150 }; |
147 | 151 |
148 inline std::ostream& operator<<(std::ostream& stream, | 152 inline std::ostream& operator<<(std::ostream& stream, |
149 const NGMarginStrut& value) { | 153 const NGMarginStrut& value) { |
150 return stream << value.ToString(); | 154 return stream << value.ToString(); |
151 } | 155 } |
152 | 156 |
153 } // namespace blink | 157 } // namespace blink |
154 | 158 |
155 #endif // NGUnits_h | 159 #endif // NGUnits_h |
OLD | NEW |