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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 // its parent rect in the physical coordinate system. | 92 // its parent rect in the physical coordinate system. |
93 struct NGPhysicalOffset { | 93 struct NGPhysicalOffset { |
94 NGPhysicalOffset() {} | 94 NGPhysicalOffset() {} |
95 NGPhysicalOffset(LayoutUnit left, LayoutUnit top) : left(left), top(top) {} | 95 NGPhysicalOffset(LayoutUnit left, LayoutUnit top) : left(left), top(top) {} |
96 | 96 |
97 LayoutUnit left; | 97 LayoutUnit left; |
98 LayoutUnit top; | 98 LayoutUnit top; |
99 | 99 |
100 NGPhysicalOffset operator+(const NGPhysicalOffset& other) const; | 100 NGPhysicalOffset operator+(const NGPhysicalOffset& other) const; |
101 NGPhysicalOffset& operator+=(const NGPhysicalOffset& other); | 101 NGPhysicalOffset& operator+=(const NGPhysicalOffset& other); |
102 NGPhysicalOffset operator-(const NGPhysicalOffset& other) const; | |
103 NGPhysicalOffset& operator-=(const NGPhysicalOffset& other); | |
102 }; | 104 }; |
103 | 105 |
104 struct NGPhysicalSize { | 106 struct NGPhysicalSize { |
105 NGPhysicalSize() {} | 107 NGPhysicalSize() {} |
106 NGPhysicalSize(LayoutUnit width, LayoutUnit height) | 108 NGPhysicalSize(LayoutUnit width, LayoutUnit height) |
107 : width(width), height(height) {} | 109 : width(width), height(height) {} |
108 | 110 |
109 LayoutUnit width; | 111 LayoutUnit width; |
110 LayoutUnit height; | 112 LayoutUnit height; |
111 | 113 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 struct CORE_EXPORT NGStaticPosition { | 299 struct CORE_EXPORT NGStaticPosition { |
298 enum Type { kTopLeft, kTopRight, kBottomLeft, kBottomRight }; | 300 enum Type { kTopLeft, kTopRight, kBottomLeft, kBottomRight }; |
299 | 301 |
300 Type type; // Logical corner that corresponds to physical top left. | 302 Type type; // Logical corner that corresponds to physical top left. |
301 NGPhysicalOffset offset; | 303 NGPhysicalOffset offset; |
302 | 304 |
303 // Creates a position with proper type wrt writing mode and direction. | 305 // Creates a position with proper type wrt writing mode and direction. |
304 static NGStaticPosition Create(NGWritingMode, | 306 static NGStaticPosition Create(NGWritingMode, |
305 TextDirection, | 307 TextDirection, |
306 NGPhysicalOffset); | 308 NGPhysicalOffset); |
307 | |
cbiesinger
2016/12/21 21:38:50
Why did you delete this line?
atotic
2016/12/28 19:36:46
done. Probably a merge conflict artifact.
| |
308 // Left/Right/TopPosition functions map static position to | 309 // Left/Right/TopPosition functions map static position to |
309 // left/right/top edge wrt container space. | 310 // left/right/top edge wrt container space. |
310 // The function arguments are required to solve the equation: | 311 // The function arguments are required to solve the equation: |
311 // contaner_size = left + margin_left + width + margin_right + right | 312 // contaner_size = left + margin_left + width + margin_right + right |
312 LayoutUnit LeftPosition(LayoutUnit container_size, | 313 LayoutUnit LeftPosition(LayoutUnit container_size, |
313 LayoutUnit width, | 314 LayoutUnit width, |
314 LayoutUnit margin_left, | 315 LayoutUnit margin_left, |
315 LayoutUnit margin_right) const { | 316 LayoutUnit margin_right) const { |
316 return GenericPosition(HasLeft(), offset.left, container_size, width, | 317 return GenericPosition(HasLeft(), offset.left, container_size, width, |
317 margin_left, margin_right); | 318 margin_left, margin_right); |
(...skipping 29 matching lines...) Expand all Loading... | |
347 if (position_matches) | 348 if (position_matches) |
348 return position; | 349 return position; |
349 else | 350 else |
350 return container_size - position - length - margin_start - margin_end; | 351 return container_size - position - length - margin_start - margin_end; |
351 } | 352 } |
352 }; | 353 }; |
353 | 354 |
354 } // namespace blink | 355 } // namespace blink |
355 | 356 |
356 #endif // NGUnits_h | 357 #endif // NGUnits_h |
OLD | NEW |