Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: third_party/WebKit/Source/core/svg/properties/SVGAnimatedProperty.h

Issue 2537223006: Cleanup after removal of the SVGViewSpec interface (Closed)
Patch Set: SVGViewSpec& Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 G* * Redistributions in binary form must reproduce the above 10 G* * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef SVGAnimatedProperty_h 31 #ifndef SVGAnimatedProperty_h
32 #define SVGAnimatedProperty_h 32 #define SVGAnimatedProperty_h
33 33
34 #include "bindings/core/v8/ExceptionState.h"
35 #include "core/dom/ExceptionCode.h"
36 #include "core/svg/SVGParsingError.h" 34 #include "core/svg/SVGParsingError.h"
37 #include "core/svg/properties/SVGPropertyInfo.h" 35 #include "core/svg/properties/SVGPropertyInfo.h"
38 #include "core/svg/properties/SVGPropertyTearOff.h" 36 #include "core/svg/properties/SVGPropertyTearOff.h"
39 #include "platform/heap/Handle.h" 37 #include "platform/heap/Handle.h"
40 #include "wtf/Noncopyable.h" 38 #include "wtf/Noncopyable.h"
41 39
42 namespace blink { 40 namespace blink {
43 41
42 class ExceptionState;
44 class SVGElement; 43 class SVGElement;
45 44
46 class SVGAnimatedPropertyBase 45 class SVGAnimatedPropertyBase
47 : public GarbageCollectedFinalized<SVGAnimatedPropertyBase> { 46 : public GarbageCollectedFinalized<SVGAnimatedPropertyBase> {
48 WTF_MAKE_NONCOPYABLE(SVGAnimatedPropertyBase); 47 WTF_MAKE_NONCOPYABLE(SVGAnimatedPropertyBase);
49 48
50 public: 49 public:
51 virtual ~SVGAnimatedPropertyBase(); 50 virtual ~SVGAnimatedPropertyBase();
52 51
53 virtual SVGPropertyBase* currentValueBase() = 0; 52 virtual SVGPropertyBase* currentValueBase() = 0;
(...skipping 17 matching lines...) Expand all
71 const QualifiedName& attributeName() const { return m_attributeName; } 70 const QualifiedName& attributeName() const { return m_attributeName; }
72 71
73 CSSPropertyID cssPropertyId() const { 72 CSSPropertyID cssPropertyId() const {
74 return static_cast<CSSPropertyID>(m_cssPropertyId); 73 return static_cast<CSSPropertyID>(m_cssPropertyId);
75 } 74 }
76 75
77 bool hasPresentationAttributeMapping() const { 76 bool hasPresentationAttributeMapping() const {
78 return cssPropertyId() != CSSPropertyInvalid; 77 return cssPropertyId() != CSSPropertyInvalid;
79 } 78 }
80 79
81 bool isReadOnly() const { return m_isReadOnly; }
82
83 void setReadOnly() { m_isReadOnly = true; }
84
85 bool isSpecified() const; 80 bool isSpecified() const;
86 81
87 DEFINE_INLINE_VIRTUAL_TRACE() {} 82 DEFINE_INLINE_VIRTUAL_TRACE() {}
88 83
89 protected: 84 protected:
90 SVGAnimatedPropertyBase(AnimatedPropertyType, 85 SVGAnimatedPropertyBase(AnimatedPropertyType,
91 SVGElement*, 86 SVGElement*,
92 const QualifiedName& attributeName, 87 const QualifiedName& attributeName,
93 CSSPropertyID = CSSPropertyInvalid); 88 CSSPropertyID = CSSPropertyInvalid);
94 89
95 private: 90 private:
96 static_assert(NumberOfAnimatedPropertyTypes <= (1u << 5), 91 static_assert(NumberOfAnimatedPropertyTypes <= (1u << 5),
97 "enough bits for AnimatedPropertyType (m_type)"); 92 "enough bits for AnimatedPropertyType (m_type)");
98 static constexpr int kCssPropertyBits = 9; 93 static constexpr int kCssPropertyBits = 9;
99 static_assert((1u << kCssPropertyBits) - 1 >= lastCSSProperty, 94 static_assert((1u << kCssPropertyBits) - 1 >= lastCSSProperty,
100 "enough bits for CSS property ids"); 95 "enough bits for CSS property ids");
101 96
102 const unsigned m_type : 5; 97 const unsigned m_type : 5;
103 const unsigned m_cssPropertyId : kCssPropertyBits; 98 const unsigned m_cssPropertyId : kCssPropertyBits;
104 unsigned m_isReadOnly : 1;
105 99
106 // This raw pointer is safe since the SVG element is guaranteed to be kept 100 // This raw pointer is safe since the SVG element is guaranteed to be kept
107 // alive by a V8 wrapper. 101 // alive by a V8 wrapper.
108 // See http://crbug.com/528275 for the detail. 102 // See http://crbug.com/528275 for the detail.
109 UntracedMember<SVGElement> m_contextElement; 103 UntracedMember<SVGElement> m_contextElement;
110 104
111 const QualifiedName& m_attributeName; 105 const QualifiedName& m_attributeName;
112 }; 106 };
113 107
114 template <typename Property> 108 template <typename Property>
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 SVGAnimatedPropertyBase::synchronizeAttribute(); 184 SVGAnimatedPropertyBase::synchronizeAttribute();
191 m_baseValueUpdated = false; 185 m_baseValueUpdated = false;
192 } 186 }
193 187
194 // SVGAnimated* DOM Spec implementations: 188 // SVGAnimated* DOM Spec implementations:
195 189
196 // baseVal()/setBaseVal()/animVal() are only to be used from SVG DOM 190 // baseVal()/setBaseVal()/animVal() are only to be used from SVG DOM
197 // implementation. Use currentValue() from C++ code. 191 // implementation. Use currentValue() from C++ code.
198 PrimitiveType baseVal() { return this->baseValue()->value(); } 192 PrimitiveType baseVal() { return this->baseValue()->value(); }
199 193
200 void setBaseVal(PrimitiveType value, ExceptionState& exceptionState) { 194 void setBaseVal(PrimitiveType value, ExceptionState&) {
201 if (this->isReadOnly()) {
202 exceptionState.throwDOMException(NoModificationAllowedError,
203 "The attribute is read-only.");
204 return;
205 }
206
207 this->baseValue()->setValue(value); 195 this->baseValue()->setValue(value);
208 m_baseValueUpdated = true; 196 m_baseValueUpdated = true;
209 197
210 ASSERT(this->attributeName() != QualifiedName::null()); 198 ASSERT(this->attributeName() != QualifiedName::null());
211 this->contextElement()->invalidateSVGAttributes(); 199 this->contextElement()->invalidateSVGAttributes();
212 this->contextElement()->svgAttributeBaseValChanged(this->attributeName()); 200 this->contextElement()->svgAttributeBaseValChanged(this->attributeName());
213 } 201 }
214 202
215 PrimitiveType animVal() { 203 PrimitiveType animVal() {
216 this->contextElement()->ensureAttributeAnimValUpdated(); 204 this->contextElement()->ensureAttributeAnimValUpdated();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 255
268 // SVGAnimated* DOM Spec implementations: 256 // SVGAnimated* DOM Spec implementations:
269 257
270 // baseVal()/animVal() are only to be used from SVG DOM implementation. 258 // baseVal()/animVal() are only to be used from SVG DOM implementation.
271 // Use currentValue() from C++ code. 259 // Use currentValue() from C++ code.
272 virtual TearOffType* baseVal() { 260 virtual TearOffType* baseVal() {
273 if (!m_baseValTearOff) { 261 if (!m_baseValTearOff) {
274 m_baseValTearOff = 262 m_baseValTearOff =
275 TearOffType::create(this->baseValue(), this->contextElement(), 263 TearOffType::create(this->baseValue(), this->contextElement(),
276 PropertyIsNotAnimVal, this->attributeName()); 264 PropertyIsNotAnimVal, this->attributeName());
277 if (this->isReadOnly())
278 m_baseValTearOff->setIsReadOnlyProperty();
279 } 265 }
280 266 return m_baseValTearOff;
281 return m_baseValTearOff.get();
282 } 267 }
283 268
284 TearOffType* animVal() { 269 TearOffType* animVal() {
285 if (!m_animValTearOff) 270 if (!m_animValTearOff) {
286 m_animValTearOff = 271 m_animValTearOff =
287 TearOffType::create(this->currentValue(), this->contextElement(), 272 TearOffType::create(this->currentValue(), this->contextElement(),
288 PropertyIsAnimVal, this->attributeName()); 273 PropertyIsAnimVal, this->attributeName());
289 274 }
290 return m_animValTearOff.get(); 275 return m_animValTearOff;
291 } 276 }
292 277
293 DEFINE_INLINE_VIRTUAL_TRACE() { 278 DEFINE_INLINE_VIRTUAL_TRACE() {
294 visitor->trace(m_baseValTearOff); 279 visitor->trace(m_baseValTearOff);
295 visitor->trace(m_animValTearOff); 280 visitor->trace(m_animValTearOff);
296 SVGAnimatedPropertyCommon<Property>::trace(visitor); 281 SVGAnimatedPropertyCommon<Property>::trace(visitor);
297 } 282 }
298 283
299 protected: 284 protected:
300 SVGAnimatedProperty(SVGElement* contextElement, 285 SVGAnimatedProperty(SVGElement* contextElement,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 CSSPropertyID cssPropertyId = CSSPropertyInvalid) 335 CSSPropertyID cssPropertyId = CSSPropertyInvalid)
351 : SVGAnimatedPropertyCommon<Property>(contextElement, 336 : SVGAnimatedPropertyCommon<Property>(contextElement,
352 attributeName, 337 attributeName,
353 initialValue, 338 initialValue,
354 cssPropertyId) {} 339 cssPropertyId) {}
355 }; 340 };
356 341
357 } // namespace blink 342 } // namespace blink
358 343
359 #endif // SVGAnimatedProperty_h 344 #endif // SVGAnimatedProperty_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698