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

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

Issue 2472583006: Add support of leader_point in NGLayoutOpportunityIterator. (Closed)
Patch Set: Update ToLeaderExclusion Created 4 years, 1 month 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
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_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"
11 #include "platform/LayoutUnit.h" 11 #include "platform/LayoutUnit.h"
12 #include "wtf/text/WTFString.h" 12 #include "wtf/text/WTFString.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 class LayoutUnit; 16 class LayoutUnit;
17 struct NGPhysicalOffset; 17 struct NGPhysicalOffset;
18 struct NGPhysicalSize; 18 struct NGPhysicalSize;
19 19
20 struct NGLogicalSize { 20 struct NGLogicalSize {
21 NGLogicalSize() {} 21 NGLogicalSize() {}
22 NGLogicalSize(LayoutUnit inline_size, LayoutUnit block_size) 22 NGLogicalSize(LayoutUnit inline_size, LayoutUnit block_size)
23 : inline_size(inline_size), block_size(block_size) {} 23 : inline_size(inline_size), block_size(block_size) {}
24 24
25 LayoutUnit inline_size; 25 LayoutUnit inline_size;
26 LayoutUnit block_size; 26 LayoutUnit block_size;
27 27
28 NGPhysicalSize ConvertToPhysical(NGWritingMode mode) const; 28 NGPhysicalSize ConvertToPhysical(NGWritingMode mode) const;
29 bool operator==(const NGLogicalSize& other) const; 29 bool operator==(const NGLogicalSize& other) const;
30
31 bool IsEmpty() const {
32 return inline_size == LayoutUnit(0) || block_size == LayoutUnit(0);
cbiesinger 2016/11/03 15:00:40 Use LayoutUnit() instead of LayoutUnit(0) Also, I
Gleb Lanbin 2016/11/03 16:13:04 Done.
33 }
30 }; 34 };
31 35
32 // NGLogicalOffset is the position of a rect (typically a fragment) relative to 36 // NGLogicalOffset is the position of a rect (typically a fragment) relative to
33 // its parent rect in the logical coordinate system. 37 // its parent rect in the logical coordinate system.
34 struct NGLogicalOffset { 38 struct NGLogicalOffset {
35 NGLogicalOffset() {} 39 NGLogicalOffset() {}
36 NGLogicalOffset(LayoutUnit inline_offset, LayoutUnit block_offset) 40 NGLogicalOffset(LayoutUnit inline_offset, LayoutUnit block_offset)
37 : inline_offset(inline_offset), block_offset(block_offset) {} 41 : inline_offset(inline_offset), block_offset(block_offset) {}
38 42
39 LayoutUnit inline_offset; 43 LayoutUnit inline_offset;
40 LayoutUnit block_offset; 44 LayoutUnit block_offset;
41 45
42 // Converts a logical offset to a physical offset. See: 46 // Converts a logical offset to a physical offset. See:
43 // https://drafts.csswg.org/css-writing-modes-3/#logical-to-physical 47 // https://drafts.csswg.org/css-writing-modes-3/#logical-to-physical
44 // @param container_size the size of the rect (typically a fragment). 48 // @param container_size the size of the rect (typically a fragment).
45 // @param inner_size the size of the inner rect (typically a child fragment). 49 // @param inner_size the size of the inner rect (typically a child fragment).
46 CORE_EXPORT NGPhysicalOffset 50 CORE_EXPORT NGPhysicalOffset
47 ConvertToPhysical(NGWritingMode mode, 51 ConvertToPhysical(NGWritingMode mode,
48 NGDirection direction, 52 NGDirection direction,
49 NGPhysicalSize container_size, 53 NGPhysicalSize container_size,
50 NGPhysicalSize inner_size) const; 54 NGPhysicalSize inner_size) const;
51 bool operator==(const NGLogicalOffset& other) const; 55 bool operator==(const NGLogicalOffset& other) const;
52 56
53 NGLogicalOffset operator+(const NGLogicalOffset& other) const; 57 NGLogicalOffset operator+(const NGLogicalOffset& other) const;
54 58
55 NGLogicalOffset& operator+=(const NGLogicalOffset& other); 59 NGLogicalOffset& operator+=(const NGLogicalOffset& other);
60
61 bool operator>(const NGLogicalOffset& other) const;
62 bool operator>=(const NGLogicalOffset& other) const;
63
64 bool operator<(const NGLogicalOffset& other) const;
65 bool operator<=(const NGLogicalOffset& other) const;
66
67 String ToString() const;
56 }; 68 };
57 69
70 CORE_EXPORT inline std::ostream& operator<<(std::ostream& os,
71 const NGLogicalOffset& value) {
72 return os << value.ToString();
73 }
74
58 // NGPhysicalOffset is the position of a rect (typically a fragment) relative to 75 // NGPhysicalOffset is the position of a rect (typically a fragment) relative to
59 // its parent rect in the physical coordinate system. 76 // its parent rect in the physical coordinate system.
60 struct NGPhysicalOffset { 77 struct NGPhysicalOffset {
61 NGPhysicalOffset() {} 78 NGPhysicalOffset() {}
62 NGPhysicalOffset(LayoutUnit left, LayoutUnit top) : left(left), top(top) {} 79 NGPhysicalOffset(LayoutUnit left, LayoutUnit top) : left(left), top(top) {}
63 80
64 LayoutUnit left; 81 LayoutUnit left;
65 LayoutUnit top; 82 LayoutUnit top;
66 }; 83 };
67 84
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 230
214 // Struct to represent a simple edge that has start and end. 231 // Struct to represent a simple edge that has start and end.
215 struct NGEdge { 232 struct NGEdge {
216 LayoutUnit start; 233 LayoutUnit start;
217 LayoutUnit end; 234 LayoutUnit end;
218 }; 235 };
219 236
220 } // namespace blink 237 } // namespace blink
221 238
222 #endif // NGUnits_h 239 #endif // NGUnits_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698