Chromium Code Reviews| Index: Source/core/css/CSSQuadValue.h |
| diff --git a/Source/core/css/CSSQuadValue.h b/Source/core/css/CSSQuadValue.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..df0802df5b105286a2cda53296a834bf26fbcf58 |
| --- /dev/null |
| +++ b/Source/core/css/CSSQuadValue.h |
| @@ -0,0 +1,89 @@ |
| +/* |
| + * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org) |
| + * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. 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. |
| + */ |
| + |
| +#ifndef CSSQuadValue_h |
| +#define CSSQuadValue_h |
| + |
| +#include "core/CoreExport.h" |
| +#include "core/css/CSSPrimitiveValue.h" |
| +#include "core/css/CSSValue.h" |
| +#include "wtf/RefPtr.h" |
| + |
| +namespace blink { |
| + |
| +class CORE_EXPORT CSSQuadValue : public CSSValue { |
| +public: |
| + static PassRefPtrWillBeRawPtr<CSSQuadValue> createQuad(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> top, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> right, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> bottom, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> left) |
|
Timothy Loh
2015/08/24 03:18:04
I'd rather an enum for the serialization strategy
sashab
2015/08/24 05:43:58
Done.
|
| + { |
| + return adoptRefWillBeNoop(new CSSQuadValue(top, right, bottom, left, false)); |
| + } |
| + |
| + static PassRefPtrWillBeRawPtr<CSSQuadValue> createRect(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> top, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> right, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> bottom, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> left) |
| + { |
| + return adoptRefWillBeNoop(new CSSQuadValue(top, right, bottom, left, true)); |
| + } |
| + |
| + CSSPrimitiveValue* top() const { return m_top.get(); } |
| + CSSPrimitiveValue* right() const { return m_right.get(); } |
| + CSSPrimitiveValue* bottom() const { return m_bottom.get(); } |
| + CSSPrimitiveValue* left() const { return m_left.get(); } |
| + |
| + bool isRect() { return m_serializeAsRect; } |
| + |
| + String customCSSText() const |
| + { |
| + return generateCSSString(top()->cssText(), right()->cssText(), bottom()->cssText(), left()->cssText(), m_serializeAsRect); |
| + } |
| + |
| + bool equals(const CSSQuadValue& other) const |
| + { |
| + return compareCSSValuePtr(m_top, other.m_top) |
| + && compareCSSValuePtr(m_right, other.m_right) |
| + && compareCSSValuePtr(m_left, other.m_left) |
| + && compareCSSValuePtr(m_bottom, other.m_bottom); |
| + } |
| + |
| + DECLARE_TRACE_AFTER_DISPATCH(); |
| + |
| +protected: |
| + CSSQuadValue(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> top, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> right, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> bottom, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> left, bool serializeAsRect) |
| + : CSSValue(QuadClass) |
| + , m_serializeAsRect(serializeAsRect) |
| + , m_top(top) |
| + , m_right(right) |
| + , m_bottom(bottom) |
| + , m_left(left) { } |
| + |
| +private: |
| + bool m_serializeAsRect; |
| + |
| + static String generateCSSString(const String& top, const String& right, const String& bottom, const String& left, bool serializeAsRect); |
| + |
| + RefPtrWillBeMember<CSSPrimitiveValue> m_top; |
| + RefPtrWillBeMember<CSSPrimitiveValue> m_right; |
| + RefPtrWillBeMember<CSSPrimitiveValue> m_bottom; |
| + RefPtrWillBeMember<CSSPrimitiveValue> m_left; |
| +}; |
| + |
| +DEFINE_CSS_VALUE_TYPE_CASTS(CSSQuadValue, isQuadValue()); |
| + |
| +} // namespace blink |
| + |
| +#endif // CSSQuadValue_h |