OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde
.org> | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde
.org> |
3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> |
4 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 12 matching lines...) Expand all Loading... |
23 #define SVGAnimatedPropertyMacros_h | 23 #define SVGAnimatedPropertyMacros_h |
24 | 24 |
25 #include "core/dom/Element.h" | 25 #include "core/dom/Element.h" |
26 #include "core/svg/properties/SVGAnimatedProperty.h" | 26 #include "core/svg/properties/SVGAnimatedProperty.h" |
27 #include "core/svg/properties/SVGAttributeToPropertyMap.h" | 27 #include "core/svg/properties/SVGAttributeToPropertyMap.h" |
28 #include "core/svg/properties/SVGPropertyTraits.h" | 28 #include "core/svg/properties/SVGPropertyTraits.h" |
29 #include "wtf/StdLibExtras.h" | 29 #include "wtf/StdLibExtras.h" |
30 | 30 |
31 namespace WebCore { | 31 namespace WebCore { |
32 | 32 |
33 // SVGSynchronizableAnimatedProperty implementation | |
34 template<typename PropertyType> | |
35 struct SVGSynchronizableAnimatedProperty { | |
36 SVGSynchronizableAnimatedProperty() | |
37 : value(SVGPropertyTraits<PropertyType>::initialValue()) | |
38 , shouldSynchronize(false) | |
39 { | |
40 } | |
41 | |
42 template<typename ConstructorParameter1> | |
43 SVGSynchronizableAnimatedProperty(const ConstructorParameter1& value1) | |
44 : value(value1) | |
45 , shouldSynchronize(false) | |
46 { | |
47 } | |
48 | |
49 template<typename ConstructorParameter1, typename ConstructorParameter2> | |
50 SVGSynchronizableAnimatedProperty(const ConstructorParameter1& value1, const
ConstructorParameter2& value2) | |
51 : value(value1, value2) | |
52 , shouldSynchronize(false) | |
53 { | |
54 } | |
55 | |
56 void synchronize(Element* ownerElement, const QualifiedName& attrName, const
AtomicString& value) | |
57 { | |
58 ownerElement->setSynchronizedLazyAttribute(attrName, value); | |
59 } | |
60 | |
61 PropertyType value; | |
62 bool shouldSynchronize : 1; | |
63 }; | |
64 | |
65 // Property registration helpers | 33 // Property registration helpers |
66 #define BEGIN_REGISTER_ANIMATED_PROPERTIES(OwnerType) \ | 34 #define BEGIN_REGISTER_ANIMATED_PROPERTIES(OwnerType) |
67 SVGAttributeToPropertyMap& OwnerType::attributeToPropertyMap() \ | 35 #define REGISTER_LOCAL_ANIMATED_PROPERTY(LowerProperty) |
68 { \ | 36 #define REGISTER_PARENT_ANIMATED_PROPERTIES(ClassName) |
69 DEFINE_STATIC_LOCAL(SVGAttributeToPropertyMap, s_attributeToPropertyMap, ())
; \ | 37 #define END_REGISTER_ANIMATED_PROPERTIES |
70 return s_attributeToPropertyMap; \ | |
71 } \ | |
72 \ | |
73 SVGAttributeToPropertyMap& OwnerType::localAttributeToPropertyMap() const \ | |
74 { \ | |
75 return attributeToPropertyMap(); \ | |
76 } \ | |
77 \ | |
78 void OwnerType::registerAnimatedPropertiesFor##OwnerType() \ | |
79 { \ | |
80 OwnerType::m_cleanupAnimatedPropertiesCaller.setOwner(this); \ | |
81 SVGAttributeToPropertyMap& map = OwnerType::attributeToPropertyMap(); \ | |
82 if (!map.isEmpty()) \ | |
83 return; \ | |
84 typedef OwnerType UseOwnerType; | |
85 | |
86 #define REGISTER_LOCAL_ANIMATED_PROPERTY(LowerProperty) \ | |
87 map.addProperty(UseOwnerType::LowerProperty##PropertyInfo()); | |
88 | |
89 #define REGISTER_PARENT_ANIMATED_PROPERTIES(ClassName) \ | |
90 map.addProperties(ClassName::attributeToPropertyMap()); \ | |
91 | |
92 #define END_REGISTER_ANIMATED_PROPERTIES } | |
93 | 38 |
94 // Property declaration helpers (used in SVG*.h files) | 39 // Property declaration helpers (used in SVG*.h files) |
95 #define BEGIN_DECLARE_ANIMATED_PROPERTIES(OwnerType) \ | 40 #define BEGIN_DECLARE_ANIMATED_PROPERTIES(OwnerType) |
96 public: \ | 41 #define DECLARE_ANIMATED_PROPERTY(TearOffType, PropertyType, UpperProperty, Lowe
rProperty) |
97 static SVGAttributeToPropertyMap& attributeToPropertyMap(); \ | 42 #define END_DECLARE_ANIMATED_PROPERTIES |
98 virtual SVGAttributeToPropertyMap& localAttributeToPropertyMap() const; \ | |
99 void registerAnimatedPropertiesFor##OwnerType(); \ | |
100 typedef OwnerType UseOwnerType; | |
101 | |
102 #define DECLARE_ANIMATED_PROPERTY(TearOffType, PropertyType, UpperProperty, Lowe
rProperty) \ | |
103 public: \ | |
104 static const SVGPropertyInfo* LowerProperty##PropertyInfo(); \ | |
105 bool LowerProperty##Specified() const; \ | |
106 PropertyType& LowerProperty##CurrentValue() const; \ | |
107 PropertyType& LowerProperty##BaseValue() const; \ | |
108 void set##UpperProperty##BaseValue(const PropertyType& type); \ | |
109 PassRefPtr<TearOffType> LowerProperty(); \ | |
110 \ | |
111 private: \ | |
112 void synchronize##UpperProperty(); \ | |
113 static PassRefPtr<SVGAnimatedProperty> lookupOrCreate##UpperProperty##Wrappe
r(SVGElement* maskedOwnerType); \ | |
114 static void synchronize##UpperProperty(SVGElement* maskedOwnerType); \ | |
115 \ | |
116 mutable SVGSynchronizableAnimatedProperty<PropertyType> m_##LowerProperty; | |
117 | |
118 #define END_DECLARE_ANIMATED_PROPERTIES \ | |
119 CleanUpAnimatedPropertiesCaller m_cleanupAnimatedPropertiesCaller; | |
120 | 43 |
121 } | 44 } |
122 | 45 |
123 #endif // SVGAnimatedPropertyMacros_h | 46 #endif // SVGAnimatedPropertyMacros_h |
OLD | NEW |