OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef NGBoxStrut_h | |
6 #define NGBoxStrut_h | |
7 | |
8 #include "core/layout/ng/ng_writing_mode.h" | |
9 #include "platform/LayoutUnit.h" | |
10 #include "platform/text/TextDirection.h" | |
11 | |
12 namespace blink { | |
13 | |
14 // This struct is used for storing margins, borders or padding of a box on all | |
15 // four edges. | |
16 struct NGBoxStrut { | |
17 NGBoxStrut() {} | |
18 NGBoxStrut(LayoutUnit inline_start, | |
19 LayoutUnit inline_end, | |
20 LayoutUnit block_start, | |
21 LayoutUnit block_end) | |
22 : inline_start(inline_start), | |
23 inline_end(inline_end), | |
24 block_start(block_start), | |
25 block_end(block_end) {} | |
26 | |
27 LayoutUnit InlineSum() const { return inline_start + inline_end; } | |
28 LayoutUnit BlockSum() const { return block_start + block_end; } | |
29 | |
30 bool IsEmpty() const; | |
31 | |
32 // The following two operators exist primarily to have an easy way to access | |
33 // the sum of border and padding. | |
34 NGBoxStrut& operator+=(const NGBoxStrut& other) { | |
35 inline_start += other.inline_start; | |
36 inline_end += other.inline_end; | |
37 block_start += other.block_start; | |
38 block_end += other.block_end; | |
39 return *this; | |
40 } | |
41 | |
42 NGBoxStrut operator+(const NGBoxStrut& other) { | |
43 NGBoxStrut result(*this); | |
44 result += other; | |
45 return result; | |
46 } | |
47 | |
48 bool operator==(const NGBoxStrut& other) const; | |
49 | |
50 String ToString() const; | |
51 | |
52 LayoutUnit inline_start; | |
53 LayoutUnit inline_end; | |
54 LayoutUnit block_start; | |
55 LayoutUnit block_end; | |
56 }; | |
57 | |
58 std::ostream& operator<<(std::ostream&, const NGBoxStrut&); | |
59 | |
60 // Struct to store physical dimensions, independent of writing mode and | |
61 // direction. | |
62 // See https://drafts.csswg.org/css-writing-modes-3/#abstract-box | |
63 struct NGPhysicalBoxStrut { | |
64 LayoutUnit left; | |
65 LayoutUnit right; | |
66 LayoutUnit top; | |
67 LayoutUnit bottom; | |
68 NGBoxStrut ConvertToLogical(NGWritingMode, TextDirection) const; | |
69 }; | |
70 | |
71 } // namespace blink | |
72 | |
73 #endif // NGBoxStrut_h | |
OLD | NEW |