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

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

Issue 2489953006: Utility routines for ng_units (Closed)
Patch Set: Added missing CORE_EXPORT 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_writing_mode.h" 9 #include "core/layout/ng/ng_writing_mode.h"
10 #include "platform/LayoutUnit.h" 10 #include "platform/LayoutUnit.h"
11 #include "platform/text/TextDirection.h" 11 #include "platform/text/TextDirection.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 struct NGBoxStrut;
19 20
20 struct MinAndMaxContentSizes { 21 struct MinAndMaxContentSizes {
21 LayoutUnit min_content; 22 LayoutUnit min_content;
22 LayoutUnit max_content; 23 LayoutUnit max_content;
24 LayoutUnit ShrinkToFit(LayoutUnit available_size) const;
23 }; 25 };
24 26
25 struct NGLogicalSize { 27 struct NGLogicalSize {
26 NGLogicalSize() {} 28 NGLogicalSize() {}
27 NGLogicalSize(LayoutUnit inline_size, LayoutUnit block_size) 29 NGLogicalSize(LayoutUnit inline_size, LayoutUnit block_size)
28 : inline_size(inline_size), block_size(block_size) {} 30 : inline_size(inline_size), block_size(block_size) {}
29 31
30 LayoutUnit inline_size; 32 LayoutUnit inline_size;
31 LayoutUnit block_size; 33 LayoutUnit block_size;
32 34
33 NGPhysicalSize ConvertToPhysical(NGWritingMode mode) const; 35 NGPhysicalSize ConvertToPhysical(NGWritingMode mode) const;
34 bool operator==(const NGLogicalSize& other) const; 36 bool operator==(const NGLogicalSize& other) const;
35 37
36 bool IsEmpty() const { 38 bool IsEmpty() const {
37 return inline_size == LayoutUnit() || block_size == LayoutUnit(); 39 return inline_size == LayoutUnit() || block_size == LayoutUnit();
38 } 40 }
39 }; 41 };
40 42
43 inline std::ostream& operator<<(std::ostream& stream,
44 const NGLogicalSize& value) {
45 return stream << value.inline_size << "x" << value.block_size;
46 }
47
41 // NGLogicalOffset is the position of a rect (typically a fragment) relative to 48 // NGLogicalOffset is the position of a rect (typically a fragment) relative to
42 // its parent rect in the logical coordinate system. 49 // its parent rect in the logical coordinate system.
43 struct NGLogicalOffset { 50 struct NGLogicalOffset {
44 NGLogicalOffset() {} 51 NGLogicalOffset() {}
45 NGLogicalOffset(LayoutUnit inline_offset, LayoutUnit block_offset) 52 NGLogicalOffset(LayoutUnit inline_offset, LayoutUnit block_offset)
46 : inline_offset(inline_offset), block_offset(block_offset) {} 53 : inline_offset(inline_offset), block_offset(block_offset) {}
47 54
48 LayoutUnit inline_offset; 55 LayoutUnit inline_offset;
49 LayoutUnit block_offset; 56 LayoutUnit block_offset;
50 57
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 struct NGPixelSnappedPhysicalRect { 167 struct NGPixelSnappedPhysicalRect {
161 int top; 168 int top;
162 int left; 169 int left;
163 int width; 170 int width;
164 int height; 171 int height;
165 }; 172 };
166 173
167 // Struct to store physical dimensions, independent of writing mode and 174 // Struct to store physical dimensions, independent of writing mode and
168 // direction. 175 // direction.
169 // See https://drafts.csswg.org/css-writing-modes-3/#abstract-box 176 // See https://drafts.csswg.org/css-writing-modes-3/#abstract-box
170 struct NGPhysicalBoxStrut { 177 struct CORE_EXPORT NGPhysicalBoxStrut {
171 LayoutUnit left; 178 LayoutUnit left;
172 LayoutUnit right; 179 LayoutUnit right;
173 LayoutUnit top; 180 LayoutUnit top;
174 LayoutUnit bottom; 181 LayoutUnit bottom;
182 NGBoxStrut ConvertToLogical(NGWritingMode, TextDirection) const;
175 }; 183 };
176 184
177 // This struct is used for storing margins, borders or padding of a box on all 185 // This struct is used for storing margins, borders or padding of a box on all
178 // four edges. 186 // four edges.
179 struct NGBoxStrut { 187 struct CORE_EXPORT NGBoxStrut {
180 LayoutUnit inline_start; 188 LayoutUnit inline_start;
181 LayoutUnit inline_end; 189 LayoutUnit inline_end;
182 LayoutUnit block_start; 190 LayoutUnit block_start;
183 LayoutUnit block_end; 191 LayoutUnit block_end;
184 192
185 LayoutUnit InlineSum() const { return inline_start + inline_end; } 193 LayoutUnit InlineSum() const { return inline_start + inline_end; }
186 LayoutUnit BlockSum() const { return block_start + block_end; } 194 LayoutUnit BlockSum() const { return block_start + block_end; }
187 195
188 bool IsEmpty() const; 196 bool IsEmpty() const;
189 197
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 243
236 // Struct to represent a simple edge that has start and end. 244 // Struct to represent a simple edge that has start and end.
237 struct NGEdge { 245 struct NGEdge {
238 LayoutUnit start; 246 LayoutUnit start;
239 LayoutUnit end; 247 LayoutUnit end;
240 }; 248 };
241 249
242 } // namespace blink 250 } // namespace blink
243 251
244 #endif // NGUnits_h 252 #endif // NGUnits_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_length_utils.cc ('k') | third_party/WebKit/Source/core/layout/ng/ng_units.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698