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

Side by Side Diff: Source/platform/LengthOrNumberBox.h

Issue 55783002: Introduce BorderImageLength and BorderImageLengthBox (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 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
(Empty)
1 /*
2 Copyright (c) 2013, Opera Software ASA. All rights reserved.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18 */
Julien - ping for review 2013/11/01 18:27:11 Same comment about the license.
davve 2013/11/04 12:42:54 OK.
19
20 #ifndef LengthOrNumberBox_h
21 #define LengthOrNumberBox_h
22
23 #include "platform/LengthBox.h"
24 #include "platform/LengthOrNumber.h"
25
26 namespace WebCore {
27
28 class PLATFORM_EXPORT LengthOrNumberBox {
Julien - ping for review 2013/11/01 18:27:11 While the name describe what it is, I think it cou
davve 2013/11/04 09:55:37 Hm. If we rename the box, I think we should also r
29 public:
30 LengthOrNumberBox()
31 {
32 }
33
34 LengthOrNumberBox(Length t, Length r, Length b, Length l)
35 : m_left(LengthOrNumber(l))
36 , m_right(LengthOrNumber(r))
37 , m_top(LengthOrNumber(t))
38 , m_bottom(LengthOrNumber(b))
39 {
40 }
41
42 LengthOrNumberBox(double t, double r, double b, double l)
43 : m_left(LengthOrNumber(l))
44 , m_right(LengthOrNumber(r))
45 , m_top(LengthOrNumber(t))
46 , m_bottom(LengthOrNumber(b))
47 {
48 }
49
50 explicit LengthOrNumberBox(LengthBox lengthBox) :
Julien - ping for review 2013/11/01 18:27:11 Should we have a FIXME about removing this constru
davve 2013/11/04 12:42:54 OK.
51 m_left(lengthBox.m_left),
52 m_right(lengthBox.m_right),
53 m_top(lengthBox.m_top),
54 m_bottom(lengthBox.m_bottom)
55 {
56 }
57
58 LengthOrNumber left() const { return m_left; }
Julien - ping for review 2013/11/01 18:27:11 const LengthOrNumber& to avoid a copy if we want?
davve 2013/11/04 12:42:54 OK.
59 LengthOrNumber right() const { return m_right; }
60 LengthOrNumber top() const { return m_top; }
61 LengthOrNumber bottom() const { return m_bottom; }
62
63 void setLeft(const LengthOrNumber& o) { m_left = o; }
Julien - ping for review 2013/11/01 18:27:11 |o| is never a good name, let's use |left|...
davve 2013/11/04 12:42:54 OK.
64 void setRight(const LengthOrNumber& o) { m_right = o; }
65 void setTop(const LengthOrNumber& o) { m_top = o; }
66 void setBottom(const LengthOrNumber& o) { m_bottom = o; }
67
68 bool operator==(const LengthOrNumberBox& o) const
Julien - ping for review 2013/11/01 18:27:11 OK, I lied, |o| is fine here (though |other| would
davve 2013/11/04 12:42:54 :) OK. (I like |other|)
69 {
70 return m_left == o.m_left && m_right == o.m_right && m_top == o.m_top && m_bottom == o.m_bottom;
71 }
72
73 bool operator!=(const LengthOrNumberBox& o) const
74 {
75 return !(*this == o);
76 }
77
78 bool nonZero() const
79 {
80 return !(m_left.isZero() && m_right.isZero() && m_top.isZero() && m_bott om.isZero());
81 }
82
83 LengthBox lengthBox() const
Julien - ping for review 2013/11/01 18:27:11 Should we have a FIXME to remove this explicit con
davve 2013/11/04 12:42:54 OK on both points.
84 {
85 return LengthBox(m_top.unifiedLength(), m_right.unifiedLength(),
86 m_bottom.unifiedLength(), m_left.unifiedLength());
87 }
88
89 private:
90 LengthOrNumber m_left;
91 LengthOrNumber m_right;
92 LengthOrNumber m_top;
93 LengthOrNumber m_bottom;
94 };
95
96 } // namespace WebCore
97
98 #endif // LengthOrNumberBox_h
99
100
Julien - ping for review 2013/11/01 18:27:11 Trailing empty lines.
davve 2013/11/04 12:42:54 Thanks.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698