| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CSSCustomPropertyDeclaration_h | 5 #ifndef CSSCustomPropertyDeclaration_h |
| 6 #define CSSCustomPropertyDeclaration_h | 6 #define CSSCustomPropertyDeclaration_h |
| 7 | 7 |
| 8 #include "core/css/CSSValue.h" | 8 #include "core/css/CSSValue.h" |
| 9 #include "core/css/CSSVariableData.h" | 9 #include "core/css/CSSVariableData.h" |
| 10 #include "wtf/RefPtr.h" | 10 #include "wtf/RefPtr.h" |
| 11 #include "wtf/text/AtomicString.h" | 11 #include "wtf/text/AtomicString.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 class CSSCustomPropertyDeclaration : public CSSValue { | 15 class CSSCustomPropertyDeclaration : public CSSValue { |
| 16 public: | 16 public: |
| 17 static CSSCustomPropertyDeclaration* create(const AtomicString& name, PassRe
fPtr<CSSVariableData> value) | 17 static CSSCustomPropertyDeclaration* create(const AtomicString& name, PassRe
fPtr<CSSVariableData> value) |
| 18 { | 18 { |
| 19 return new CSSCustomPropertyDeclaration(name, std::move(value)); | 19 return new CSSCustomPropertyDeclaration(name, std::move(value)); |
| 20 } | 20 } |
| 21 | 21 |
| 22 static CSSCustomPropertyDeclaration* create(const AtomicString& name, CSSVal
ueID id) | 22 static CSSCustomPropertyDeclaration* create(const AtomicString& name, CSSVal
ueID id) |
| 23 { | 23 { |
| 24 return new CSSCustomPropertyDeclaration(name, id); | 24 return new CSSCustomPropertyDeclaration(name, id); |
| 25 } | 25 } |
| 26 | 26 |
| 27 const AtomicString& name() const { return m_name; } | 27 const AtomicString& name() const { return m_name; } |
| 28 CSSVariableData* value() const { return m_value.get(); } | 28 CSSVariableData* value() const { return m_value.get(); } |
| 29 CSSValueID id() const { return m_valueId; } | 29 |
| 30 bool isInherit(bool isInheritedProperty) const { return m_valueId == CSSValu
eInherit || (isInheritedProperty && m_valueId == CSSValueUnset); } |
| 31 bool isInitial(bool isInheritedProperty) const { return m_valueId == CSSValu
eInitial || (!isInheritedProperty && m_valueId == CSSValueUnset); } |
| 32 |
| 30 String customCSSText() const; | 33 String customCSSText() const; |
| 31 | 34 |
| 32 bool equals(const CSSCustomPropertyDeclaration& other) const { return this =
= &other; } | 35 bool equals(const CSSCustomPropertyDeclaration& other) const { return this =
= &other; } |
| 33 | 36 |
| 34 DECLARE_TRACE_AFTER_DISPATCH(); | 37 DECLARE_TRACE_AFTER_DISPATCH(); |
| 35 private: | 38 private: |
| 36 CSSCustomPropertyDeclaration(const AtomicString& name, CSSValueID id) | 39 CSSCustomPropertyDeclaration(const AtomicString& name, CSSValueID id) |
| 37 : CSSValue(CustomPropertyDeclarationClass) | 40 : CSSValue(CustomPropertyDeclarationClass) |
| 38 , m_name(name) | 41 , m_name(name) |
| 39 , m_value(nullptr) | 42 , m_value(nullptr) |
| 40 , m_valueId(id) | 43 , m_valueId(id) |
| 41 { | 44 { |
| 42 ASSERT(id == CSSValueInherit || id == CSSValueInitial || id == CSSValueU
nset); | 45 ASSERT(id == CSSValueInherit || id == CSSValueInitial || id == CSSValueU
nset); |
| 43 } | 46 } |
| 44 | 47 |
| 45 CSSCustomPropertyDeclaration(const AtomicString& name, PassRefPtr<CSSVariabl
eData> value) | 48 CSSCustomPropertyDeclaration(const AtomicString& name, PassRefPtr<CSSVariabl
eData> value) |
| 46 : CSSValue(CustomPropertyDeclarationClass) | 49 : CSSValue(CustomPropertyDeclarationClass) |
| 47 , m_name(name) | 50 , m_name(name) |
| 48 , m_value(value) | 51 , m_value(value) |
| 49 , m_valueId(CSSValueInternalVariableValue) | 52 , m_valueId(CSSValueInvalid) |
| 50 { | 53 { |
| 51 } | 54 } |
| 52 | 55 |
| 53 const AtomicString m_name; | 56 const AtomicString m_name; |
| 54 RefPtr<CSSVariableData> m_value; | 57 RefPtr<CSSVariableData> m_value; |
| 55 CSSValueID m_valueId; | 58 CSSValueID m_valueId; |
| 56 }; | 59 }; |
| 57 | 60 |
| 58 DEFINE_CSS_VALUE_TYPE_CASTS(CSSCustomPropertyDeclaration, isCustomPropertyDeclar
ation()); | 61 DEFINE_CSS_VALUE_TYPE_CASTS(CSSCustomPropertyDeclaration, isCustomPropertyDeclar
ation()); |
| 59 | 62 |
| 60 } // namespace blink | 63 } // namespace blink |
| 61 | 64 |
| 62 #endif // CSSCustomPropertyDeclaration_h | 65 #endif // CSSCustomPropertyDeclaration_h |
| OLD | NEW |