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

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

Issue 2289353002: [layoutng] Add methods to compute border and padding (Closed)
Patch Set: better enum name Created 4 years, 3 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_length_utils_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 "platform/LayoutUnit.h" 8 #include "platform/LayoutUnit.h"
9 9
10 namespace blink { 10 namespace blink {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // This struct is used for storing margins, borders or padding of a box on all 54 // This struct is used for storing margins, borders or padding of a box on all
55 // four edges. 55 // four edges.
56 struct NGBoxStrut { 56 struct NGBoxStrut {
57 LayoutUnit inline_start; 57 LayoutUnit inline_start;
58 LayoutUnit inline_end; 58 LayoutUnit inline_end;
59 LayoutUnit block_start; 59 LayoutUnit block_start;
60 LayoutUnit block_end; 60 LayoutUnit block_end;
61 61
62 LayoutUnit InlineSum() const { return inline_start + inline_end; } 62 LayoutUnit InlineSum() const { return inline_start + inline_end; }
63 LayoutUnit BlockSum() const { return block_start + block_end; } 63 LayoutUnit BlockSum() const { return block_start + block_end; }
64
65 // The following two operators exist primarily to have an easy way to access
66 // the sum of border and padding.
67 NGBoxStrut& operator+=(const NGBoxStrut& other) {
68 inline_start += other.inline_start;
69 inline_end += other.inline_end;
70 block_start += other.block_start;
71 block_end += other.block_end;
72 return *this;
73 }
74
75 NGBoxStrut operator+(const NGBoxStrut& other) {
76 NGBoxStrut result(*this);
77 result += other;
78 return result;
79 }
64 }; 80 };
65 81
66 } // namespace blink 82 } // namespace blink
67 83
68 #endif // NGUnits_h 84 #endif // NGUnits_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_length_utils_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698