| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 const NGMarginStrut& value) { | 267 const NGMarginStrut& value) { |
| 261 return stream << value.ToString(); | 268 return stream << value.ToString(); |
| 262 } | 269 } |
| 263 | 270 |
| 264 // Struct to represent a simple edge that has start and end. | 271 // Struct to represent a simple edge that has start and end. |
| 265 struct NGEdge { | 272 struct NGEdge { |
| 266 LayoutUnit start; | 273 LayoutUnit start; |
| 267 LayoutUnit end; | 274 LayoutUnit end; |
| 268 }; | 275 }; |
| 269 | 276 |
| 277 // Represents static position of an out of flow descendant. |
| 278 struct CORE_EXPORT NGStaticPosition { |
| 279 enum Type { kTopLeft, kTopRight, kBottomLeft, kBottomRight }; |
| 280 |
| 281 Type type; // Logical corner that corresponds to physical top left. |
| 282 NGPhysicalOffset offset; |
| 283 |
| 284 // Creates a position with proper type wrt writing mode and direction. |
| 285 static NGStaticPosition Create(NGWritingMode, |
| 286 TextDirection, |
| 287 NGPhysicalOffset); |
| 288 }; |
| 289 |
| 270 } // namespace blink | 290 } // namespace blink |
| 271 | 291 |
| 272 #endif // NGUnits_h | 292 #endif // NGUnits_h |
| OLD | NEW |