Chromium Code Reviews| Index: Source/platform/LengthOrNumber.h |
| diff --git a/Source/platform/LengthSize.h b/Source/platform/LengthOrNumber.h |
| similarity index 50% |
| copy from Source/platform/LengthSize.h |
| copy to Source/platform/LengthOrNumber.h |
| index b0a1019183f3d0c2b70abbbe2c87e5cf66b78615..2d9b378aba79279bb3ad447a62263f94958f6a45 100644 |
| --- a/Source/platform/LengthSize.h |
| +++ b/Source/platform/LengthOrNumber.h |
| @@ -1,6 +1,5 @@ |
| /* |
| - Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| - Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
| + 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 |
| @@ -18,41 +17,53 @@ |
| Boston, MA 02110-1301, USA. |
| */ |
|
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.
|
| -#ifndef LengthSize_h |
| -#define LengthSize_h |
| +#ifndef LengthOrNumber_h |
| +#define LengthOrNumber_h |
| #include "platform/Length.h" |
| namespace WebCore { |
| -struct LengthSize { |
| +class PLATFORM_EXPORT LengthOrNumber { |
| public: |
| - LengthSize() |
| + LengthOrNumber() |
| { |
| } |
| - LengthSize(Length width, Length height) |
| - : m_width(width) |
| - , m_height(height) |
| + LengthOrNumber(double number) |
| + : m_length(number, Relative) |
| { |
| } |
| - bool operator==(const LengthSize& o) const |
| + explicit LengthOrNumber(const Length& length) |
| + : m_length(length) |
| { |
| - return m_width == o.m_width && m_height == o.m_height; |
| } |
| - void setWidth(Length width) { m_width = width; } |
| - Length width() const { return m_width; } |
| + bool isNumber() const { return m_length.isRelative(); } |
| + bool isLength() const { return !isNumber(); } |
| - void setHeight(Length height) { m_height = height; } |
| - Length height() const { return m_height; } |
| + const Length& length() const { ASSERT(isLength()); return m_length; } |
| + Length& length() { ASSERT(isLength()); return m_length; } |
| + |
| + double number() const { ASSERT(isNumber()); return m_length.value(); } |
| + |
| + 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().
|
| + |
| + bool operator==(const LengthOrNumber& o) const |
| + { |
| + return m_length == o.m_length; |
| + } |
| + |
| + bool isZero() const |
| + { |
| + return m_length.isZero(); |
| + } |
| private: |
| - Length m_width; |
| - Length m_height; |
| + Length m_length; |
| }; |
| } // namespace WebCore |
| -#endif // LengthSize_h |
| +#endif // LengthOrNumber_h |