| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (c) 2013, Opera Software ASA. All rights reserved. | 2 Copyright (c) 2013, Opera Software ASA. All rights reserved. |
| 3 | 3 |
| 4 This library is free software; you can redistribute it and/or | 4 This library is free software; you can redistribute it and/or |
| 5 modify it under the terms of the GNU Library General Public | 5 modify it under the terms of the GNU Library General Public |
| 6 License as published by the Free Software Foundation; either | 6 License as published by the Free Software Foundation; either |
| 7 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. |
| 8 | 8 |
| 9 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, |
| 10 but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 Library General Public License for more details. | 12 Library General Public License for more details. |
| 13 | 13 |
| 14 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 |
| 15 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 |
| 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 Boston, MA 02110-1301, USA. | 17 Boston, MA 02110-1301, USA. |
| 18 */ | 18 */ |
| 19 | 19 |
| 20 #ifndef LengthOrNumberBox_h | 20 #ifndef LengthOrNumberBox_h |
| 21 #define LengthOrNumberBox_h | 21 #define LengthOrNumberBox_h |
| 22 | 22 |
| 23 #include "platform/LengthBox.h" | |
| 24 #include "platform/LengthOrNumber.h" | 23 #include "platform/LengthOrNumber.h" |
| 25 | 24 |
| 26 namespace WebCore { | 25 namespace WebCore { |
| 27 | 26 |
| 28 class PLATFORM_EXPORT LengthOrNumberBox { | 27 class PLATFORM_EXPORT LengthOrNumberBox { |
| 29 public: | 28 public: |
| 30 LengthOrNumberBox() | 29 LengthOrNumberBox() |
| 31 { | 30 { |
| 32 } | 31 } |
| 33 | 32 |
| 34 LengthOrNumberBox(Length t, Length r, Length b, Length l) | 33 LengthOrNumberBox(Length t, Length r, Length b, Length l) |
| 35 : m_left(LengthOrNumber(l)) | 34 : m_left(LengthOrNumber(l)) |
| 36 , m_right(LengthOrNumber(r)) | 35 , m_right(LengthOrNumber(r)) |
| 37 , m_top(LengthOrNumber(t)) | 36 , m_top(LengthOrNumber(t)) |
| 38 , m_bottom(LengthOrNumber(b)) | 37 , m_bottom(LengthOrNumber(b)) |
| 39 { | 38 { |
| 40 } | 39 } |
| 41 | 40 |
| 42 LengthOrNumberBox(double t, double r, double b, double l) | 41 LengthOrNumberBox(double t, double r, double b, double l) |
| 43 : m_left(LengthOrNumber(l)) | 42 : m_left(LengthOrNumber(l)) |
| 44 , m_right(LengthOrNumber(r)) | 43 , m_right(LengthOrNumber(r)) |
| 45 , m_top(LengthOrNumber(t)) | 44 , m_top(LengthOrNumber(t)) |
| 46 , m_bottom(LengthOrNumber(b)) | 45 , m_bottom(LengthOrNumber(b)) |
| 47 { | 46 { |
| 48 } | 47 } |
| 49 | 48 |
| 50 explicit LengthOrNumberBox(LengthBox lengthBox) : | 49 LengthOrNumberBox(LengthOrNumber t, LengthOrNumber r, LengthOrNumber b, Leng
thOrNumber l) |
| 51 m_left(lengthBox.m_left), | 50 : m_left(l) |
| 52 m_right(lengthBox.m_right), | 51 , m_right(r) |
| 53 m_top(lengthBox.m_top), | 52 , m_top(t) |
| 54 m_bottom(lengthBox.m_bottom) | 53 , m_bottom(b) |
| 55 { | 54 { |
| 56 } | 55 } |
| 57 | 56 |
| 58 LengthOrNumber left() const { return m_left; } | 57 LengthOrNumber left() const { return m_left; } |
| 59 LengthOrNumber right() const { return m_right; } | 58 LengthOrNumber right() const { return m_right; } |
| 60 LengthOrNumber top() const { return m_top; } | 59 LengthOrNumber top() const { return m_top; } |
| 61 LengthOrNumber bottom() const { return m_bottom; } | 60 LengthOrNumber bottom() const { return m_bottom; } |
| 62 | 61 |
| 63 void setLeft(const LengthOrNumber& o) { m_left = o; } | 62 void setLeft(const LengthOrNumber& o) { m_left = o; } |
| 64 void setRight(const LengthOrNumber& o) { m_right = o; } | 63 void setRight(const LengthOrNumber& o) { m_right = o; } |
| 65 void setTop(const LengthOrNumber& o) { m_top = o; } | 64 void setTop(const LengthOrNumber& o) { m_top = o; } |
| 66 void setBottom(const LengthOrNumber& o) { m_bottom = o; } | 65 void setBottom(const LengthOrNumber& o) { m_bottom = o; } |
| 67 | 66 |
| 68 bool operator==(const LengthOrNumberBox& o) const | 67 bool operator==(const LengthOrNumberBox& o) const |
| 69 { | 68 { |
| 70 return m_left == o.m_left && m_right == o.m_right && m_top == o.m_top &&
m_bottom == o.m_bottom; | 69 return m_left == o.m_left && m_right == o.m_right && m_top == o.m_top &&
m_bottom == o.m_bottom; |
| 71 } | 70 } |
| 72 | 71 |
| 73 bool operator!=(const LengthOrNumberBox& o) const | 72 bool operator!=(const LengthOrNumberBox& o) const |
| 74 { | 73 { |
| 75 return !(*this == o); | 74 return !(*this == o); |
| 76 } | 75 } |
| 77 | 76 |
| 78 bool nonZero() const | 77 bool nonZero() const |
| 79 { | 78 { |
| 80 return !(m_left.isZero() && m_right.isZero() && m_top.isZero() && m_bott
om.isZero()); | 79 return !(m_left.isZero() && m_right.isZero() && m_top.isZero() && m_bott
om.isZero()); |
| 81 } | 80 } |
| 82 | 81 |
| 83 LengthBox lengthBox() const | |
| 84 { | |
| 85 return LengthBox(m_top.unifiedLength(), m_right.unifiedLength(), | |
| 86 m_bottom.unifiedLength(), m_left.unifiedLength()); | |
| 87 } | |
| 88 | |
| 89 private: | 82 private: |
| 90 LengthOrNumber m_left; | 83 LengthOrNumber m_left; |
| 91 LengthOrNumber m_right; | 84 LengthOrNumber m_right; |
| 92 LengthOrNumber m_top; | 85 LengthOrNumber m_top; |
| 93 LengthOrNumber m_bottom; | 86 LengthOrNumber m_bottom; |
| 94 }; | 87 }; |
| 95 | 88 |
| 96 } // namespace WebCore | 89 } // namespace WebCore |
| 97 | 90 |
| 98 #endif // LengthOrNumberBox_h | 91 #endif // LengthOrNumberBox_h |
| 99 | 92 |
| 100 | 93 |
| OLD | NEW |