Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_units.h

Issue 2641253002: Rewrite LayoutNG margin collapsing/floats unit tests (Closed)
Patch Set: fix comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 26 matching lines...) Expand all
37 37
38 LayoutUnit inline_size; 38 LayoutUnit inline_size;
39 LayoutUnit block_size; 39 LayoutUnit block_size;
40 40
41 NGPhysicalSize ConvertToPhysical(NGWritingMode mode) const; 41 NGPhysicalSize ConvertToPhysical(NGWritingMode mode) const;
42 bool operator==(const NGLogicalSize& other) const; 42 bool operator==(const NGLogicalSize& other) const;
43 43
44 bool IsEmpty() const { 44 bool IsEmpty() const {
45 return inline_size == LayoutUnit() || block_size == LayoutUnit(); 45 return inline_size == LayoutUnit() || block_size == LayoutUnit();
46 } 46 }
47
48 private:
49 friend class NGBlockLayoutAlgorithmTest;
50 // Used in tests.
51 NGLogicalSize(int inline_size, int block_size)
52 : inline_size(LayoutUnit(inline_size)),
53 block_size(LayoutUnit(block_size)) {}
54 }; 47 };
55 48
56 inline std::ostream& operator<<(std::ostream& stream, 49 inline std::ostream& operator<<(std::ostream& stream,
57 const NGLogicalSize& value) { 50 const NGLogicalSize& value) {
58 return stream << value.inline_size << "x" << value.block_size; 51 return stream << value.inline_size << "x" << value.block_size;
59 } 52 }
60 53
61 // NGLogicalOffset is the position of a rect (typically a fragment) relative to 54 // NGLogicalOffset is the position of a rect (typically a fragment) relative to
62 // its parent rect in the logical coordinate system. 55 // its parent rect in the logical coordinate system.
63 struct NGLogicalOffset { 56 struct NGLogicalOffset {
(...skipping 25 matching lines...) Expand all
89 NGLogicalOffset operator-(const NGLogicalOffset& other) const; 82 NGLogicalOffset operator-(const NGLogicalOffset& other) const;
90 NGLogicalOffset& operator-=(const NGLogicalOffset& other); 83 NGLogicalOffset& operator-=(const NGLogicalOffset& other);
91 84
92 bool operator>(const NGLogicalOffset& other) const; 85 bool operator>(const NGLogicalOffset& other) const;
93 bool operator>=(const NGLogicalOffset& other) const; 86 bool operator>=(const NGLogicalOffset& other) const;
94 87
95 bool operator<(const NGLogicalOffset& other) const; 88 bool operator<(const NGLogicalOffset& other) const;
96 bool operator<=(const NGLogicalOffset& other) const; 89 bool operator<=(const NGLogicalOffset& other) const;
97 90
98 String ToString() const; 91 String ToString() const;
99
100 private:
101 friend class NGBlockLayoutAlgorithmTest;
102 // Used in tests.
103 NGLogicalOffset(int inline_offset, int block_offset)
104 : inline_offset(LayoutUnit(inline_offset)),
105 block_offset(LayoutUnit(block_offset)) {}
106 }; 92 };
107 93
108 CORE_EXPORT inline std::ostream& operator<<(std::ostream& os, 94 CORE_EXPORT inline std::ostream& operator<<(std::ostream& os,
109 const NGLogicalOffset& value) { 95 const NGLogicalOffset& value) {
110 return os << value.ToString(); 96 return os << value.ToString();
111 } 97 }
112 98
113 // NGPhysicalOffset is the position of a rect (typically a fragment) relative to 99 // NGPhysicalOffset is the position of a rect (typically a fragment) relative to
114 // its parent rect in the physical coordinate system. 100 // its parent rect in the physical coordinate system.
115 struct NGPhysicalOffset { 101 struct NGPhysicalOffset {
116 NGPhysicalOffset() {} 102 NGPhysicalOffset() {}
117 NGPhysicalOffset(LayoutUnit left, LayoutUnit top) : left(left), top(top) {} 103 NGPhysicalOffset(LayoutUnit left, LayoutUnit top) : left(left), top(top) {}
118 104
119 LayoutUnit left; 105 LayoutUnit left;
120 LayoutUnit top; 106 LayoutUnit top;
121 107
122 NGPhysicalOffset operator+(const NGPhysicalOffset& other) const; 108 NGPhysicalOffset operator+(const NGPhysicalOffset& other) const;
123 NGPhysicalOffset& operator+=(const NGPhysicalOffset& other); 109 NGPhysicalOffset& operator+=(const NGPhysicalOffset& other);
124 110
125 NGPhysicalOffset operator-(const NGPhysicalOffset& other) const; 111 NGPhysicalOffset operator-(const NGPhysicalOffset& other) const;
126 NGPhysicalOffset& operator-=(const NGPhysicalOffset& other); 112 NGPhysicalOffset& operator-=(const NGPhysicalOffset& other);
127 113
128 String ToString() const { 114 String ToString() const {
129 return String::format("%dx%d", left.toInt(), top.toInt()); 115 return String::format("%dx%d", left.toInt(), top.toInt());
130 } 116 }
131 }; 117 };
132 118
133 struct NGPhysicalSize { 119 struct CORE_EXPORT NGPhysicalSize {
134 NGPhysicalSize() {} 120 NGPhysicalSize() {}
135 NGPhysicalSize(LayoutUnit width, LayoutUnit height) 121 NGPhysicalSize(LayoutUnit width, LayoutUnit height)
136 : width(width), height(height) {} 122 : width(width), height(height) {}
137 123
138 LayoutUnit width; 124 LayoutUnit width;
139 LayoutUnit height; 125 LayoutUnit height;
140 126
141 NGLogicalSize ConvertToLogical(NGWritingMode mode) const; 127 NGLogicalSize ConvertToLogical(NGWritingMode mode) const;
142 128
143 bool operator==(const NGPhysicalSize& other) const; 129 bool operator==(const NGPhysicalSize& other) const;
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 if (position_matches) 401 if (position_matches)
416 return position; 402 return position;
417 else 403 else
418 return container_size - position - length - margin_start - margin_end; 404 return container_size - position - length - margin_start - margin_end;
419 } 405 }
420 }; 406 };
421 407
422 } // namespace blink 408 } // namespace blink
423 409
424 #endif // NGUnits_h 410 #endif // NGUnits_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698