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_writing_mode.h" | 9 #include "core/layout/ng/ng_writing_mode.h" |
10 #include "platform/LayoutUnit.h" | 10 #include "platform/LayoutUnit.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 struct NGLogicalOffset { | 50 struct NGLogicalOffset { |
51 NGLogicalOffset() {} | 51 NGLogicalOffset() {} |
52 NGLogicalOffset(LayoutUnit inline_offset, LayoutUnit block_offset) | 52 NGLogicalOffset(LayoutUnit inline_offset, LayoutUnit block_offset) |
53 : inline_offset(inline_offset), block_offset(block_offset) {} | 53 : inline_offset(inline_offset), block_offset(block_offset) {} |
54 | 54 |
55 LayoutUnit inline_offset; | 55 LayoutUnit inline_offset; |
56 LayoutUnit block_offset; | 56 LayoutUnit block_offset; |
57 | 57 |
58 // Converts a logical offset to a physical offset. See: | 58 // Converts a logical offset to a physical offset. See: |
59 // https://drafts.csswg.org/css-writing-modes-3/#logical-to-physical | 59 // https://drafts.csswg.org/css-writing-modes-3/#logical-to-physical |
| 60 // PhysicalOffset will be the physical top left point of the rectangle |
| 61 // described by offset + inner_size. Setting inner_size to 0,0 will return |
| 62 // the same point. |
60 // @param outer_size the size of the rect (typically a fragment). | 63 // @param outer_size the size of the rect (typically a fragment). |
61 // @param inner_size the size of the inner rect (typically a child fragment). | 64 // @param inner_size the size of the inner rect (typically a child fragment). |
62 CORE_EXPORT NGPhysicalOffset | 65 CORE_EXPORT NGPhysicalOffset |
63 ConvertToPhysical(NGWritingMode, | 66 ConvertToPhysical(NGWritingMode, |
64 TextDirection, | 67 TextDirection, |
65 NGPhysicalSize outer_size, | 68 NGPhysicalSize outer_size, |
66 NGPhysicalSize inner_size) const; | 69 NGPhysicalSize inner_size) const; |
| 70 |
67 bool operator==(const NGLogicalOffset& other) const; | 71 bool operator==(const NGLogicalOffset& other) const; |
68 | 72 |
69 NGLogicalOffset operator+(const NGLogicalOffset& other) const; | 73 NGLogicalOffset operator+(const NGLogicalOffset& other) const; |
70 | 74 |
71 NGLogicalOffset& operator+=(const NGLogicalOffset& other); | 75 NGLogicalOffset& operator+=(const NGLogicalOffset& other); |
72 | 76 |
73 bool operator>(const NGLogicalOffset& other) const; | 77 bool operator>(const NGLogicalOffset& other) const; |
74 bool operator>=(const NGLogicalOffset& other) const; | 78 bool operator>=(const NGLogicalOffset& other) const; |
75 | 79 |
76 bool operator<(const NGLogicalOffset& other) const; | 80 bool operator<(const NGLogicalOffset& other) const; |
77 bool operator<=(const NGLogicalOffset& other) const; | 81 bool operator<=(const NGLogicalOffset& other) const; |
78 | 82 |
79 String ToString() const; | 83 String ToString() const; |
80 }; | 84 }; |
81 | 85 |
82 CORE_EXPORT inline std::ostream& operator<<(std::ostream& os, | 86 CORE_EXPORT inline std::ostream& operator<<(std::ostream& os, |
83 const NGLogicalOffset& value) { | 87 const NGLogicalOffset& value) { |
84 return os << value.ToString(); | 88 return os << value.ToString(); |
85 } | 89 } |
86 | 90 |
87 // NGPhysicalOffset is the position of a rect (typically a fragment) relative to | 91 // NGPhysicalOffset is the position of a rect (typically a fragment) relative to |
88 // its parent rect in the physical coordinate system. | 92 // its parent rect in the physical coordinate system. |
89 struct NGPhysicalOffset { | 93 struct NGPhysicalOffset { |
90 NGPhysicalOffset() {} | 94 NGPhysicalOffset() {} |
91 NGPhysicalOffset(LayoutUnit left, LayoutUnit top) : left(left), top(top) {} | 95 NGPhysicalOffset(LayoutUnit left, LayoutUnit top) : left(left), top(top) {} |
92 | 96 |
93 LayoutUnit left; | 97 LayoutUnit left; |
94 LayoutUnit top; | 98 LayoutUnit top; |
| 99 |
| 100 NGPhysicalOffset operator+(const NGPhysicalOffset& other) const; |
| 101 NGPhysicalOffset& operator+=(const NGPhysicalOffset& other); |
95 }; | 102 }; |
96 | 103 |
97 struct NGPhysicalSize { | 104 struct NGPhysicalSize { |
98 NGPhysicalSize() {} | 105 NGPhysicalSize() {} |
99 NGPhysicalSize(LayoutUnit width, LayoutUnit height) | 106 NGPhysicalSize(LayoutUnit width, LayoutUnit height) |
100 : width(width), height(height) {} | 107 : width(width), height(height) {} |
101 | 108 |
102 LayoutUnit width; | 109 LayoutUnit width; |
103 LayoutUnit height; | 110 LayoutUnit height; |
104 | 111 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 const NGMarginStrut& value) { | 286 const NGMarginStrut& value) { |
280 return stream << value.ToString(); | 287 return stream << value.ToString(); |
281 } | 288 } |
282 | 289 |
283 // Struct to represent a simple edge that has start and end. | 290 // Struct to represent a simple edge that has start and end. |
284 struct NGEdge { | 291 struct NGEdge { |
285 LayoutUnit start; | 292 LayoutUnit start; |
286 LayoutUnit end; | 293 LayoutUnit end; |
287 }; | 294 }; |
288 | 295 |
| 296 // Represents static position of an out of flow descendant. |
| 297 struct CORE_EXPORT NGStaticPosition { |
| 298 enum Type { kTopLeft, kTopRight, kBottomLeft, kBottomRight }; |
| 299 |
| 300 Type type; // Logical corner that corresponds to physical top left. |
| 301 NGPhysicalOffset offset; |
| 302 |
| 303 // Creates a position with proper type wrt writing mode and direction. |
| 304 static NGStaticPosition Create(NGWritingMode, |
| 305 TextDirection, |
| 306 NGPhysicalOffset); |
| 307 }; |
| 308 |
289 } // namespace blink | 309 } // namespace blink |
290 | 310 |
291 #endif // NGUnits_h | 311 #endif // NGUnits_h |
OLD | NEW |