Chromium Code Reviews| Index: Source/platform/LengthOrNumberBox.h |
| diff --git a/Source/platform/LengthOrNumberBox.h b/Source/platform/LengthOrNumberBox.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6fec9d1b882d59743559567a14309b203ad06832 |
| --- /dev/null |
| +++ b/Source/platform/LengthOrNumberBox.h |
| @@ -0,0 +1,100 @@ |
| +/* |
| + Copyright (c) 2013, Opera Software ASA. All rights reserved. |
| + |
| + This library is free software; you can redistribute it and/or |
| + modify it under the terms of the GNU Library General Public |
| + License as published by the Free Software Foundation; either |
| + version 2 of the License, or (at your option) any later version. |
| + |
| + This library is distributed in the hope that it will be useful, |
| + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| + Library General Public License for more details. |
| + |
| + You should have received a copy of the GNU Library General Public License |
| + along with this library; see the file COPYING.LIB. If not, write to |
| + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| + Boston, MA 02110-1301, USA. |
| +*/ |
|
Julien - ping for review
2013/11/01 18:27:11
Same comment about the license.
davve
2013/11/04 12:42:54
OK.
|
| + |
| +#ifndef LengthOrNumberBox_h |
| +#define LengthOrNumberBox_h |
| + |
| +#include "platform/LengthBox.h" |
| +#include "platform/LengthOrNumber.h" |
| + |
| +namespace WebCore { |
| + |
| +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
|
| +public: |
| + LengthOrNumberBox() |
| + { |
| + } |
| + |
| + LengthOrNumberBox(Length t, Length r, Length b, Length l) |
| + : m_left(LengthOrNumber(l)) |
| + , m_right(LengthOrNumber(r)) |
| + , m_top(LengthOrNumber(t)) |
| + , m_bottom(LengthOrNumber(b)) |
| + { |
| + } |
| + |
| + LengthOrNumberBox(double t, double r, double b, double l) |
| + : m_left(LengthOrNumber(l)) |
| + , m_right(LengthOrNumber(r)) |
| + , m_top(LengthOrNumber(t)) |
| + , m_bottom(LengthOrNumber(b)) |
| + { |
| + } |
| + |
| + 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.
|
| + m_left(lengthBox.m_left), |
| + m_right(lengthBox.m_right), |
| + m_top(lengthBox.m_top), |
| + m_bottom(lengthBox.m_bottom) |
| + { |
| + } |
| + |
| + 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.
|
| + LengthOrNumber right() const { return m_right; } |
| + LengthOrNumber top() const { return m_top; } |
| + LengthOrNumber bottom() const { return m_bottom; } |
| + |
| + 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.
|
| + void setRight(const LengthOrNumber& o) { m_right = o; } |
| + void setTop(const LengthOrNumber& o) { m_top = o; } |
| + void setBottom(const LengthOrNumber& o) { m_bottom = o; } |
| + |
| + 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|)
|
| + { |
| + return m_left == o.m_left && m_right == o.m_right && m_top == o.m_top && m_bottom == o.m_bottom; |
| + } |
| + |
| + bool operator!=(const LengthOrNumberBox& o) const |
| + { |
| + return !(*this == o); |
| + } |
| + |
| + bool nonZero() const |
| + { |
| + return !(m_left.isZero() && m_right.isZero() && m_top.isZero() && m_bottom.isZero()); |
| + } |
| + |
| + 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.
|
| + { |
| + return LengthBox(m_top.unifiedLength(), m_right.unifiedLength(), |
| + m_bottom.unifiedLength(), m_left.unifiedLength()); |
| + } |
| + |
| +private: |
| + LengthOrNumber m_left; |
| + LengthOrNumber m_right; |
| + LengthOrNumber m_top; |
| + LengthOrNumber m_bottom; |
| +}; |
| + |
| +} // namespace WebCore |
| + |
| +#endif // LengthOrNumberBox_h |
| + |
| + |
|
Julien - ping for review
2013/11/01 18:27:11
Trailing empty lines.
davve
2013/11/04 12:42:54
Thanks.
|