| 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 PropertyHandle_h | 5 #ifndef PropertyHandle_h |
| 6 #define PropertyHandle_h | 6 #define PropertyHandle_h |
| 7 | 7 |
| 8 #include "core/CSSPropertyNames.h" | 8 #include "core/CSSPropertyNames.h" |
| 9 #include "core/CoreExport.h" | 9 #include "core/CoreExport.h" |
| 10 #include "core/dom/QualifiedName.h" | 10 #include "core/dom/QualifiedName.h" |
| 11 #include "wtf/Allocator.h" | 11 #include "wtf/Allocator.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 // Represents the property of a PropertySpecificKeyframe. | 15 // Represents the property of a PropertySpecificKeyframe. |
| 16 class CORE_EXPORT PropertyHandle { | 16 class CORE_EXPORT PropertyHandle { |
| 17 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 17 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 18 public: | 18 public: |
| 19 explicit PropertyHandle(CSSPropertyID property, bool isPresentationAttribute
= false) | 19 explicit PropertyHandle(CSSPropertyID property, bool isPresentationAttribute
= false) |
| 20 : m_handleType(isPresentationAttribute ? HandlePresentationAttribute : H
andleCSSProperty) | 20 : m_handleType(isPresentationAttribute ? HandlePresentationAttribute : H
andleCSSProperty) |
| 21 , m_cssProperty(property) | 21 , m_cssProperty(property) |
| 22 { | 22 { |
| 23 DCHECK_NE(property, CSSPropertyInvalid); | 23 DCHECK_NE(property, CSSPropertyInvalid); |
| 24 DCHECK_NE(property, CSSPropertyVariable); |
| 25 } |
| 26 |
| 27 explicit PropertyHandle(const AtomicString& propertyName) |
| 28 : m_handleType(HandleCSSCustomProperty) |
| 29 , m_propertyName(propertyName.impl()) |
| 30 { |
| 24 } | 31 } |
| 25 | 32 |
| 26 explicit PropertyHandle(const QualifiedName& attributeName) | 33 explicit PropertyHandle(const QualifiedName& attributeName) |
| 27 : m_handleType(HandleSVGAttribute) | 34 : m_handleType(HandleSVGAttribute) |
| 28 , m_svgAttribute(&attributeName) | 35 , m_svgAttribute(&attributeName) |
| 29 { | 36 { |
| 30 } | 37 } |
| 31 | 38 |
| 32 bool operator==(const PropertyHandle&) const; | 39 bool operator==(const PropertyHandle&) const; |
| 33 bool operator!=(const PropertyHandle& other) const { return !(*this == other
); } | 40 bool operator!=(const PropertyHandle& other) const { return !(*this == other
); } |
| 34 | 41 |
| 35 unsigned hash() const; | 42 unsigned hash() const; |
| 36 | 43 |
| 37 bool isCSSProperty() const { return m_handleType == HandleCSSProperty; } | 44 bool isCSSProperty() const { return m_handleType == HandleCSSProperty || isC
SSCustomProperty(); } |
| 38 CSSPropertyID cssProperty() const { DCHECK(isCSSProperty()); return m_cssPro
perty; } | 45 CSSPropertyID cssProperty() const { DCHECK(isCSSProperty()); return m_handle
Type == HandleCSSProperty ? m_cssProperty : CSSPropertyVariable; } |
| 46 |
| 47 bool isCSSCustomProperty() const { return m_handleType == HandleCSSCustomPro
perty; } |
| 48 AtomicString customPropertyName() const { DCHECK(isCSSCustomProperty()); ret
urn AtomicString(m_propertyName); } |
| 39 | 49 |
| 40 bool isPresentationAttribute() const { return m_handleType == HandlePresenta
tionAttribute; } | 50 bool isPresentationAttribute() const { return m_handleType == HandlePresenta
tionAttribute; } |
| 41 CSSPropertyID presentationAttribute() const { DCHECK(isPresentationAttribute
()); return m_cssProperty; } | 51 CSSPropertyID presentationAttribute() const { DCHECK(isPresentationAttribute
()); return m_cssProperty; } |
| 42 | 52 |
| 43 bool isSVGAttribute() const { return m_handleType == HandleSVGAttribute; } | 53 bool isSVGAttribute() const { return m_handleType == HandleSVGAttribute; } |
| 44 const QualifiedName& svgAttribute() const { DCHECK(isSVGAttribute()); return
*m_svgAttribute; } | 54 const QualifiedName& svgAttribute() const { DCHECK(isSVGAttribute()); return
*m_svgAttribute; } |
| 45 | 55 |
| 46 private: | 56 private: |
| 47 enum HandleType { | 57 enum HandleType { |
| 48 HandleEmptyValueForHashTraits, | 58 HandleEmptyValueForHashTraits, |
| 49 HandleDeletedValueForHashTraits, | 59 HandleDeletedValueForHashTraits, |
| 50 HandleCSSProperty, | 60 HandleCSSProperty, |
| 61 HandleCSSCustomProperty, |
| 51 HandlePresentationAttribute, | 62 HandlePresentationAttribute, |
| 52 HandleSVGAttribute, | 63 HandleSVGAttribute, |
| 53 }; | 64 }; |
| 54 | 65 |
| 55 explicit PropertyHandle(HandleType handleType) | 66 explicit PropertyHandle(HandleType handleType) |
| 56 : m_handleType(handleType) | 67 : m_handleType(handleType) |
| 57 , m_svgAttribute(nullptr) | 68 , m_svgAttribute(nullptr) |
| 58 { | 69 { |
| 59 } | 70 } |
| 60 | 71 |
| 61 static PropertyHandle emptyValueForHashTraits() { return PropertyHandle(Hand
leEmptyValueForHashTraits); } | 72 static PropertyHandle emptyValueForHashTraits() { return PropertyHandle(Hand
leEmptyValueForHashTraits); } |
| 62 | 73 |
| 63 static PropertyHandle deletedValueForHashTraits() { return PropertyHandle(Ha
ndleDeletedValueForHashTraits); } | 74 static PropertyHandle deletedValueForHashTraits() { return PropertyHandle(Ha
ndleDeletedValueForHashTraits); } |
| 64 | 75 |
| 65 bool isDeletedValueForHashTraits() { return m_handleType == HandleDeletedVal
ueForHashTraits; } | 76 bool isDeletedValueForHashTraits() { return m_handleType == HandleDeletedVal
ueForHashTraits; } |
| 66 | 77 |
| 67 HandleType m_handleType; | 78 HandleType m_handleType; |
| 68 union { | 79 union { |
| 69 CSSPropertyID m_cssProperty; | 80 CSSPropertyID m_cssProperty; |
| 70 const QualifiedName* m_svgAttribute; | 81 const QualifiedName* m_svgAttribute; |
| 82 StringImpl* m_propertyName; |
| 71 }; | 83 }; |
| 72 | 84 |
| 73 friend struct ::WTF::HashTraits<blink::PropertyHandle>; | 85 friend struct ::WTF::HashTraits<blink::PropertyHandle>; |
| 74 }; | 86 }; |
| 75 | 87 |
| 76 } // namespace blink | 88 } // namespace blink |
| 77 | 89 |
| 78 namespace WTF { | 90 namespace WTF { |
| 79 | 91 |
| 80 template<> struct DefaultHash<blink::PropertyHandle> { | 92 template<> struct DefaultHash<blink::PropertyHandle> { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 101 | 113 |
| 102 static blink::PropertyHandle emptyValue() | 114 static blink::PropertyHandle emptyValue() |
| 103 { | 115 { |
| 104 return blink::PropertyHandle::emptyValueForHashTraits(); | 116 return blink::PropertyHandle::emptyValueForHashTraits(); |
| 105 } | 117 } |
| 106 }; | 118 }; |
| 107 | 119 |
| 108 } // namespace WTF | 120 } // namespace WTF |
| 109 | 121 |
| 110 #endif // PropertyHandle_h | 122 #endif // PropertyHandle_h |
| OLD | NEW |