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

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

Issue 2721613003: [LayoutNG] Move remaining ng_units structs to their own files (Closed)
Patch Set: Rebase w/HEAD Created 3 years, 9 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
OLDNEW
(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/CoreExport.h"
9 #include "core/layout/ng/ng_writing_mode.h"
mstensho (USE GERRIT) 2017/02/28 12:19:47 Random thought (not something you necessarily need
eae 2017/02/28 12:26:34 Ideally long term (post NG) all of these files sho
mstensho (USE GERRIT) 2017/02/28 12:31:28 Acknowledged. Makes sense. Thanks.
10 #include "platform/LayoutUnit.h"
11 #include "platform/text/TextDirection.h"
12
13 namespace blink {
14
15 struct NGBoxStrut;
16
17 // Struct to store physical dimensions, independent of writing mode and
18 // direction.
19 // See https://drafts.csswg.org/css-writing-modes-3/#abstract-box
20 struct CORE_EXPORT NGPhysicalBoxStrut {
21 LayoutUnit left;
22 LayoutUnit right;
23 LayoutUnit top;
24 LayoutUnit bottom;
25 NGBoxStrut ConvertToLogical(NGWritingMode, TextDirection) const;
26 };
27
28 // This struct is used for storing margins, borders or padding of a box on all
29 // four edges.
30 struct CORE_EXPORT NGBoxStrut {
31 LayoutUnit inline_start;
32 LayoutUnit inline_end;
33 LayoutUnit block_start;
34 LayoutUnit block_end;
35
36 LayoutUnit InlineSum() const { return inline_start + inline_end; }
37 LayoutUnit BlockSum() const { return block_start + block_end; }
38
39 bool IsEmpty() const;
40
41 // The following two operators exist primarily to have an easy way to access
42 // the sum of border and padding.
43 NGBoxStrut& operator+=(const NGBoxStrut& other) {
44 inline_start += other.inline_start;
45 inline_end += other.inline_end;
46 block_start += other.block_start;
47 block_end += other.block_end;
48 return *this;
49 }
50
51 NGBoxStrut operator+(const NGBoxStrut& other) {
52 NGBoxStrut result(*this);
53 result += other;
54 return result;
55 }
56
57 bool operator==(const NGBoxStrut& other) const;
58
59 String ToString() const;
60 };
61
62 CORE_EXPORT std::ostream& operator<<(std::ostream&, const NGBoxStrut&);
63
64 } // namespace blink
65
66 #endif // NGBoxStrut_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698