| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "platform/heap/Handle.h" | 37 #include "platform/heap/Handle.h" |
| 38 #include "wtf/RefCounted.h" | 38 #include "wtf/RefCounted.h" |
| 39 | 39 |
| 40 namespace blink { | 40 namespace blink { |
| 41 | 41 |
| 42 enum PropertyIsAnimValType { | 42 enum PropertyIsAnimValType { |
| 43 PropertyIsNotAnimVal, | 43 PropertyIsNotAnimVal, |
| 44 PropertyIsAnimVal | 44 PropertyIsAnimVal |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 class SVGPropertyTearOffBase : public RefCountedWillBeGarbageCollectedFinalized<
SVGPropertyTearOffBase> { | 47 class SVGPropertyTearOffBase : public GarbageCollectedFinalized<SVGPropertyTearO
ffBase> { |
| 48 public: | 48 public: |
| 49 virtual ~SVGPropertyTearOffBase() { } | 49 virtual ~SVGPropertyTearOffBase() { } |
| 50 | 50 |
| 51 PropertyIsAnimValType propertyIsAnimVal() const | 51 PropertyIsAnimValType propertyIsAnimVal() const |
| 52 { | 52 { |
| 53 return m_propertyIsAnimVal; | 53 return m_propertyIsAnimVal; |
| 54 } | 54 } |
| 55 | 55 |
| 56 bool isAnimVal() const | 56 bool isAnimVal() const |
| 57 { | 57 { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 , m_propertyIsAnimVal(propertyIsAnimVal) | 106 , m_propertyIsAnimVal(propertyIsAnimVal) |
| 107 , m_isReadOnlyProperty(false) | 107 , m_isReadOnlyProperty(false) |
| 108 , m_attributeName(attributeName) | 108 , m_attributeName(attributeName) |
| 109 { | 109 { |
| 110 } | 110 } |
| 111 | 111 |
| 112 private: | 112 private: |
| 113 // This raw pointer is safe since the SVG element is guaranteed to be kept | 113 // This raw pointer is safe since the SVG element is guaranteed to be kept |
| 114 // alive by a V8 wrapper. | 114 // alive by a V8 wrapper. |
| 115 // See http://crbug.com/528275 for the detail. | 115 // See http://crbug.com/528275 for the detail. |
| 116 RawPtrWillBeUntracedMember<SVGElement> m_contextElement; | 116 UntracedMember<SVGElement> m_contextElement; |
| 117 | 117 |
| 118 PropertyIsAnimValType m_propertyIsAnimVal; | 118 PropertyIsAnimValType m_propertyIsAnimVal; |
| 119 bool m_isReadOnlyProperty; | 119 bool m_isReadOnlyProperty; |
| 120 QualifiedName m_attributeName; | 120 QualifiedName m_attributeName; |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 template <typename Property> | 123 template <typename Property> |
| 124 class SVGPropertyTearOff : public SVGPropertyTearOffBase { | 124 class SVGPropertyTearOff : public SVGPropertyTearOffBase { |
| 125 public: | 125 public: |
| 126 Property* target() | 126 Property* target() |
| 127 { | 127 { |
| 128 if (isAnimVal()) | 128 if (isAnimVal()) |
| 129 contextElement()->ensureAttributeAnimValUpdated(); | 129 contextElement()->ensureAttributeAnimValUpdated(); |
| 130 | 130 |
| 131 return m_target.get(); | 131 return m_target.get(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void setTarget(PassRefPtrWillBeRawPtr<Property> target) | 134 void setTarget(RawPtr<Property> target) |
| 135 { | 135 { |
| 136 m_target = target; | 136 m_target = target; |
| 137 } | 137 } |
| 138 | 138 |
| 139 AnimatedPropertyType type() const override | 139 AnimatedPropertyType type() const override |
| 140 { | 140 { |
| 141 return Property::classType(); | 141 return Property::classType(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 DEFINE_INLINE_VIRTUAL_TRACE() | 144 DEFINE_INLINE_VIRTUAL_TRACE() |
| 145 { | 145 { |
| 146 visitor->trace(m_target); | 146 visitor->trace(m_target); |
| 147 SVGPropertyTearOffBase::trace(visitor); | 147 SVGPropertyTearOffBase::trace(visitor); |
| 148 } | 148 } |
| 149 | 149 |
| 150 protected: | 150 protected: |
| 151 SVGPropertyTearOff(PassRefPtrWillBeRawPtr<Property> target, SVGElement* cont
extElement, PropertyIsAnimValType propertyIsAnimVal, const QualifiedName& attrib
uteName = QualifiedName::null()) | 151 SVGPropertyTearOff(RawPtr<Property> target, SVGElement* contextElement, Prop
ertyIsAnimValType propertyIsAnimVal, const QualifiedName& attributeName = Qualif
iedName::null()) |
| 152 : SVGPropertyTearOffBase(contextElement, propertyIsAnimVal, attributeNam
e) | 152 : SVGPropertyTearOffBase(contextElement, propertyIsAnimVal, attributeNam
e) |
| 153 , m_target(target) | 153 , m_target(target) |
| 154 { | 154 { |
| 155 ASSERT(m_target); | 155 ASSERT(m_target); |
| 156 } | 156 } |
| 157 | 157 |
| 158 private: | 158 private: |
| 159 RefPtrWillBeMember<Property> m_target; | 159 Member<Property> m_target; |
| 160 }; | 160 }; |
| 161 | 161 |
| 162 } // namespace blink | 162 } // namespace blink |
| 163 | 163 |
| 164 #endif // SVGPropertyTearOff_h | 164 #endif // SVGPropertyTearOff_h |
| OLD | NEW |