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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 class SVGPropertyTearOffBase | 45 class SVGPropertyTearOffBase |
46 : public GarbageCollectedFinalized<SVGPropertyTearOffBase> { | 46 : public GarbageCollectedFinalized<SVGPropertyTearOffBase> { |
47 public: | 47 public: |
48 virtual ~SVGPropertyTearOffBase() {} | 48 virtual ~SVGPropertyTearOffBase() {} |
49 | 49 |
50 PropertyIsAnimValType propertyIsAnimVal() const { | 50 PropertyIsAnimValType propertyIsAnimVal() const { |
51 return m_propertyIsAnimVal; | 51 return m_propertyIsAnimVal; |
52 } | 52 } |
53 | 53 |
54 bool isAnimVal() const { return m_propertyIsAnimVal == PropertyIsAnimVal; } | 54 bool isAnimVal() const { return m_propertyIsAnimVal == PropertyIsAnimVal; } |
55 | 55 bool isImmutable() const { return isAnimVal(); } |
56 bool isReadOnlyProperty() const { return m_isReadOnlyProperty; } | |
57 | |
58 void setIsReadOnlyProperty() { m_isReadOnlyProperty = true; } | |
59 | |
60 bool isImmutable() const { return isReadOnlyProperty() || isAnimVal(); } | |
61 | 56 |
62 virtual void commitChange(); | 57 virtual void commitChange(); |
63 | 58 |
64 SVGElement* contextElement() const { return m_contextElement; } | 59 SVGElement* contextElement() const { return m_contextElement; } |
65 | 60 |
66 const QualifiedName& attributeName() { return m_attributeName; } | 61 const QualifiedName& attributeName() { return m_attributeName; } |
67 | 62 |
68 void attachToSVGElementAttribute(SVGElement* contextElement, | 63 void attachToSVGElementAttribute(SVGElement* contextElement, |
69 const QualifiedName& attributeName) { | 64 const QualifiedName& attributeName) { |
70 ASSERT(!isImmutable()); | 65 ASSERT(!isImmutable()); |
71 ASSERT(contextElement); | 66 ASSERT(contextElement); |
72 ASSERT(attributeName != QualifiedName::null()); | 67 ASSERT(attributeName != QualifiedName::null()); |
73 m_contextElement = contextElement; | 68 m_contextElement = contextElement; |
74 m_attributeName = attributeName; | 69 m_attributeName = attributeName; |
75 } | 70 } |
76 | 71 |
77 virtual AnimatedPropertyType type() const = 0; | 72 virtual AnimatedPropertyType type() const = 0; |
78 | 73 |
79 DEFINE_INLINE_VIRTUAL_TRACE() {} | 74 DEFINE_INLINE_VIRTUAL_TRACE() {} |
80 | 75 |
81 static void throwReadOnly(ExceptionState&); | 76 static void throwReadOnly(ExceptionState&); |
82 | 77 |
83 protected: | 78 protected: |
84 SVGPropertyTearOffBase( | 79 SVGPropertyTearOffBase( |
85 SVGElement* contextElement, | 80 SVGElement* contextElement, |
86 PropertyIsAnimValType propertyIsAnimVal, | 81 PropertyIsAnimValType propertyIsAnimVal, |
87 const QualifiedName& attributeName = QualifiedName::null()) | 82 const QualifiedName& attributeName = QualifiedName::null()) |
88 : m_contextElement(contextElement), | 83 : m_contextElement(contextElement), |
89 m_propertyIsAnimVal(propertyIsAnimVal), | 84 m_propertyIsAnimVal(propertyIsAnimVal), |
90 m_isReadOnlyProperty(false), | |
91 m_attributeName(attributeName) {} | 85 m_attributeName(attributeName) {} |
92 | 86 |
93 private: | 87 private: |
94 // This raw pointer is safe since the SVG element is guaranteed to be kept | 88 // This raw pointer is safe since the SVG element is guaranteed to be kept |
95 // alive by a V8 wrapper. | 89 // alive by a V8 wrapper. |
96 // See http://crbug.com/528275 for the detail. | 90 // See http://crbug.com/528275 for the detail. |
97 UntracedMember<SVGElement> m_contextElement; | 91 UntracedMember<SVGElement> m_contextElement; |
98 | 92 |
99 PropertyIsAnimValType m_propertyIsAnimVal; | 93 PropertyIsAnimValType m_propertyIsAnimVal; |
100 bool m_isReadOnlyProperty; | |
101 QualifiedName m_attributeName; | 94 QualifiedName m_attributeName; |
102 }; | 95 }; |
103 | 96 |
104 template <typename Property> | 97 template <typename Property> |
105 class SVGPropertyTearOff : public SVGPropertyTearOffBase { | 98 class SVGPropertyTearOff : public SVGPropertyTearOffBase { |
106 public: | 99 public: |
107 Property* target() { | 100 Property* target() { |
108 if (isAnimVal()) | 101 if (isAnimVal()) |
109 contextElement()->ensureAttributeAnimValUpdated(); | 102 contextElement()->ensureAttributeAnimValUpdated(); |
110 | 103 |
(...skipping 21 matching lines...) Expand all Loading... |
132 ASSERT(m_target); | 125 ASSERT(m_target); |
133 } | 126 } |
134 | 127 |
135 private: | 128 private: |
136 Member<Property> m_target; | 129 Member<Property> m_target; |
137 }; | 130 }; |
138 | 131 |
139 } // namespace blink | 132 } // namespace blink |
140 | 133 |
141 #endif // SVGPropertyTearOff_h | 134 #endif // SVGPropertyTearOff_h |
OLD | NEW |