OLD | NEW |
---|---|
1 /* | 1 /* |
2 Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 Copyright (c) 2013, Opera Software ASA. All rights reserved. |
3 Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | |
4 | 3 |
5 This library is free software; you can redistribute it and/or | 4 This library is free software; you can redistribute it and/or |
6 modify it under the terms of the GNU Library General Public | 5 modify it under the terms of the GNU Library General Public |
7 License as published by the Free Software Foundation; either | 6 License as published by the Free Software Foundation; either |
8 version 2 of the License, or (at your option) any later version. | 7 version 2 of the License, or (at your option) any later version. |
9 | 8 |
10 This library is distributed in the hope that it will be useful, | 9 This library is distributed in the hope that it will be useful, |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 Library General Public License for more details. | 12 Library General Public License for more details. |
14 | 13 |
15 You should have received a copy of the GNU Library General Public License | 14 You should have received a copy of the GNU Library General Public License |
16 along with this library; see the file COPYING.LIB. If not, write to | 15 along with this library; see the file COPYING.LIB. If not, write to |
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 Boston, MA 02110-1301, USA. | 17 Boston, MA 02110-1301, USA. |
19 */ | 18 */ |
Julien - ping for review
2013/11/01 18:27:11
AFAICT Blink prefers a BSD license for new files u
davve
2013/11/04 12:42:54
OK.
| |
20 | 19 |
21 #ifndef LengthSize_h | 20 #ifndef LengthOrNumber_h |
22 #define LengthSize_h | 21 #define LengthOrNumber_h |
23 | 22 |
24 #include "platform/Length.h" | 23 #include "platform/Length.h" |
25 | 24 |
26 namespace WebCore { | 25 namespace WebCore { |
27 | 26 |
28 struct LengthSize { | 27 class PLATFORM_EXPORT LengthOrNumber { |
29 public: | 28 public: |
30 LengthSize() | 29 LengthOrNumber() |
31 { | 30 { |
32 } | 31 } |
33 | 32 |
34 LengthSize(Length width, Length height) | 33 LengthOrNumber(double number) |
35 : m_width(width) | 34 : m_length(number, Relative) |
36 , m_height(height) | |
37 { | 35 { |
38 } | 36 } |
39 | 37 |
40 bool operator==(const LengthSize& o) const | 38 explicit LengthOrNumber(const Length& length) |
39 : m_length(length) | |
41 { | 40 { |
42 return m_width == o.m_width && m_height == o.m_height; | |
43 } | 41 } |
44 | 42 |
45 void setWidth(Length width) { m_width = width; } | 43 bool isNumber() const { return m_length.isRelative(); } |
46 Length width() const { return m_width; } | 44 bool isLength() const { return !isNumber(); } |
47 | 45 |
48 void setHeight(Length height) { m_height = height; } | 46 const Length& length() const { ASSERT(isLength()); return m_length; } |
49 Length height() const { return m_height; } | 47 Length& length() { ASSERT(isLength()); return m_length; } |
48 | |
49 double number() const { ASSERT(isNumber()); return m_length.value(); } | |
50 | |
51 Length unifiedLength() const { return m_length; } | |
Julien - ping for review
2013/11/01 18:27:11
Ideally this shouldn't exist but we have to integr
davve
2013/11/04 12:42:54
Good idea. Renamed to deprecatedUnifiedLength().
| |
52 | |
53 bool operator==(const LengthOrNumber& o) const | |
54 { | |
55 return m_length == o.m_length; | |
56 } | |
57 | |
58 bool isZero() const | |
59 { | |
60 return m_length.isZero(); | |
61 } | |
50 | 62 |
51 private: | 63 private: |
52 Length m_width; | 64 Length m_length; |
53 Length m_height; | |
54 }; | 65 }; |
55 | 66 |
56 } // namespace WebCore | 67 } // namespace WebCore |
57 | 68 |
58 #endif // LengthSize_h | 69 #endif // LengthOrNumber_h |
OLD | NEW |