| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 struct NGPhysicalLocation { | 85 struct NGPhysicalLocation { |
| 86 LayoutUnit left; | 86 LayoutUnit left; |
| 87 LayoutUnit top; | 87 LayoutUnit top; |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 struct NGPhysicalRect { | 90 struct NGPhysicalRect { |
| 91 NGPhysicalOffset offset; | 91 NGPhysicalOffset offset; |
| 92 NGPhysicalSize size; | 92 NGPhysicalSize size; |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 // TODO(glebl): move to a separate file in layout/ng/units. | |
| 96 struct CORE_EXPORT NGLogicalRect { | 95 struct CORE_EXPORT NGLogicalRect { |
| 97 NGLogicalRect() {} | 96 NGLogicalRect() {} |
| 98 NGLogicalRect(LayoutUnit inline_offset, | 97 NGLogicalRect(LayoutUnit inline_offset, |
| 99 LayoutUnit block_offset, | 98 LayoutUnit block_offset, |
| 100 LayoutUnit inline_size, | 99 LayoutUnit inline_size, |
| 101 LayoutUnit block_size) | 100 LayoutUnit block_size) |
| 102 : offset(inline_offset, block_offset), size(inline_size, block_size) {} | 101 : offset(inline_offset, block_offset), size(inline_size, block_size) {} |
| 103 | 102 |
| 104 bool IsEmpty() const; | 103 bool IsEmpty() const; |
| 105 | |
| 106 // Whether this rectangle is contained by the provided rectangle. | |
| 107 bool IsContained(const NGLogicalRect& other) const; | |
| 108 | |
| 109 String ToString() const; | 104 String ToString() const; |
| 110 bool operator==(const NGLogicalRect& other) const; | 105 bool operator==(const NGLogicalRect& other) const; |
| 111 | 106 |
| 112 // Getters | |
| 113 LayoutUnit InlineStartOffset() const { return offset.inline_offset; } | |
| 114 | |
| 115 LayoutUnit InlineEndOffset() const { | |
| 116 return offset.inline_offset + size.inline_size; | |
| 117 } | |
| 118 | |
| 119 LayoutUnit BlockStartOffset() const { return offset.block_offset; } | |
| 120 | |
| 121 LayoutUnit BlockEndOffset() const { | |
| 122 return offset.block_offset + size.block_size; | |
| 123 } | |
| 124 | |
| 125 LayoutUnit BlockSize() const { return size.block_size; } | |
| 126 | |
| 127 LayoutUnit InlineSize() const { return size.inline_size; } | |
| 128 | |
| 129 NGLogicalOffset offset; | 107 NGLogicalOffset offset; |
| 130 NGLogicalSize size; | 108 NGLogicalSize size; |
| 131 }; | 109 }; |
| 132 | 110 |
| 133 inline std::ostream& operator<<(std::ostream& stream, | 111 inline std::ostream& operator<<(std::ostream& stream, |
| 134 const NGLogicalRect& value) { | 112 const NGLogicalRect& value) { |
| 135 return stream << value.ToString(); | 113 return stream << value.ToString(); |
| 136 } | 114 } |
| 137 | 115 |
| 138 struct NGPixelSnappedPhysicalRect { | 116 struct NGPixelSnappedPhysicalRect { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 191 |
| 214 // Struct to represent a simple edge that has start and end. | 192 // Struct to represent a simple edge that has start and end. |
| 215 struct NGEdge { | 193 struct NGEdge { |
| 216 LayoutUnit start; | 194 LayoutUnit start; |
| 217 LayoutUnit end; | 195 LayoutUnit end; |
| 218 }; | 196 }; |
| 219 | 197 |
| 220 } // namespace blink | 198 } // namespace blink |
| 221 | 199 |
| 222 #endif // NGUnits_h | 200 #endif // NGUnits_h |
| OLD | NEW |