2 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #ifndef SVGAnimatedType_h
21 #define SVGAnimatedType_h
24 #include "FloatRect.h"
27 #include "SVGLength.h"
28 #include "SVGLengthList.h"
29 #include "SVGNumberList.h"
30 #include "SVGPointList.h"
31 #include "SVGPreserveAspectRatio.h"
32 #include "SVGPropertyInfo.h"
33 #include "SVGTransformList.h"
37 class SVGPathByteStream;
39 class SVGAnimatedType {
40 WTF_MAKE_FAST_ALLOCATED;
42 virtual ~SVGAnimatedType();
44 static PassOwnPtr<SVGAnimatedType> createAngleAndEnumeration(std::pair<SVGAngle, unsigned>*);
45 static PassOwnPtr<SVGAnimatedType> createBoolean(bool*);
46 static PassOwnPtr<SVGAnimatedType> createColor(Color*);
47 static PassOwnPtr<SVGAnimatedType> createEnumeration(unsigned*);
48 static PassOwnPtr<SVGAnimatedType> createInteger(int*);
49 static PassOwnPtr<SVGAnimatedType> createIntegerOptionalInteger(std::pair<int, int>*);
50 static PassOwnPtr<SVGAnimatedType> createLength(SVGLength*);
51 static PassOwnPtr<SVGAnimatedType> createLengthList(SVGLengthList*);
52 static PassOwnPtr<SVGAnimatedType> createNumber(float*);
53 static PassOwnPtr<SVGAnimatedType> createNumberList(SVGNumberList*);
54 static PassOwnPtr<SVGAnimatedType> createNumberOptionalNumber(std::pair<float, float>*);
55 static PassOwnPtr<SVGAnimatedType> createPath(std::unique_ptr<SVGPathByteStream>);
56 static PassOwnPtr<SVGAnimatedType> createPointList(SVGPointList*);
57 static PassOwnPtr<SVGAnimatedType> createPreserveAspectRatio(SVGPreserveAspectRatio*);
58 static PassOwnPtr<SVGAnimatedType> createRect(FloatRect*);
59 static PassOwnPtr<SVGAnimatedType> createString(String*);
60 static PassOwnPtr<SVGAnimatedType> createTransformList(SVGTransformList*);
61 static bool supportsAnimVal(AnimatedPropertyType);
63 AnimatedPropertyType type() const { return m_type; }
65 // Non-mutable accessors.
66 const std::pair<SVGAngle, unsigned>& angleAndEnumeration() const
68 ASSERT(m_type == AnimatedAngle);
69 return *m_data.angleAndEnumeration;
72 const bool& boolean() const
74 ASSERT(m_type == AnimatedBoolean);
75 return *m_data.boolean;
78 const Color& color() const
80 ASSERT(m_type == AnimatedColor);
84 const unsigned& enumeration() const
86 ASSERT(m_type == AnimatedEnumeration);
87 return *m_data.enumeration;
90 const int& integer() const
92 ASSERT(m_type == AnimatedInteger);
93 return *m_data.integer;
96 const pair<int, int>& integerOptionalInteger() const
98 ASSERT(m_type == AnimatedIntegerOptionalInteger);
99 return *m_data.integerOptionalInteger;
102 const SVGLength& length() const
104 ASSERT(m_type == AnimatedLength);
105 return *m_data.length;
108 const SVGLengthList& lengthList() const
110 ASSERT(m_type == AnimatedLengthList);
111 return *m_data.lengthList;
114 const float& number() const
116 ASSERT(m_type == AnimatedNumber);
117 return *m_data.number;
120 const SVGNumberList& numberList() const
122 ASSERT(m_type == AnimatedNumberList);
123 return *m_data.numberList;
126 const pair<float, float>& numberOptionalNumber() const
128 ASSERT(m_type == AnimatedNumberOptionalNumber);
129 return *m_data.numberOptionalNumber;
132 const SVGPathByteStream* path() const
134 ASSERT(m_type == AnimatedPath);
138 const SVGPointList& pointList() const
140 ASSERT(m_type == AnimatedPoints);
141 return *m_data.pointList;
144 const SVGPreserveAspectRatio& preserveAspectRatio() const
146 ASSERT(m_type == AnimatedPreserveAspectRatio);
147 return *m_data.preserveAspectRatio;
150 const FloatRect& rect() const
152 ASSERT(m_type == AnimatedRect);
156 const String& string() const
158 ASSERT(m_type == AnimatedString);
159 return *m_data.string;
162 const SVGTransformList& transformList() const
164 ASSERT(m_type == AnimatedTransformList);
165 return *m_data.transformList;
168 // Mutable accessors.
169 std::pair<SVGAngle, unsigned>& angleAndEnumeration()
171 ASSERT(m_type == AnimatedAngle);
172 return *m_data.angleAndEnumeration;
177 ASSERT(m_type == AnimatedBoolean);
178 return *m_data.boolean;
183 ASSERT(m_type == AnimatedColor);
184 return *m_data.color;
187 unsigned& enumeration()
189 ASSERT(m_type == AnimatedEnumeration);
190 return *m_data.enumeration;
195 ASSERT(m_type == AnimatedInteger);
196 return *m_data.integer;
199 pair<int, int>& integerOptionalInteger()
201 ASSERT(m_type == AnimatedIntegerOptionalInteger);
202 return *m_data.integerOptionalInteger;
207 ASSERT(m_type == AnimatedLength);
208 return *m_data.length;
211 SVGLengthList& lengthList()
213 ASSERT(m_type == AnimatedLengthList);
214 return *m_data.lengthList;
219 ASSERT(m_type == AnimatedNumber);
220 return *m_data.number;
223 SVGNumberList& numberList()
225 ASSERT(m_type == AnimatedNumberList);
226 return *m_data.numberList;
229 pair<float, float>& numberOptionalNumber()
231 ASSERT(m_type == AnimatedNumberOptionalNumber);
232 return *m_data.numberOptionalNumber;
235 SVGPathByteStream* path()
237 ASSERT(m_type == AnimatedPath);
241 SVGPointList& pointList()
243 ASSERT(m_type == AnimatedPoints);
244 return *m_data.pointList;
247 SVGPreserveAspectRatio& preserveAspectRatio()
249 ASSERT(m_type == AnimatedPreserveAspectRatio);
250 return *m_data.preserveAspectRatio;
255 ASSERT(m_type == AnimatedRect);
261 ASSERT(m_type == AnimatedString);
262 return *m_data.string;
265 SVGTransformList& transformList()
267 ASSERT(m_type == AnimatedTransformList);
268 return *m_data.transformList;
271 String valueAsString();
272 bool setValueAsString(const QualifiedName&, const String&);
275 SVGAnimatedType(AnimatedPropertyType);
277 AnimatedPropertyType m_type;
285 std::pair<SVGAngle, unsigned>* angleAndEnumeration;
288 unsigned* enumeration;
290 std::pair<int, int>* integerOptionalInteger;
292 SVGLengthList* lengthList;
294 SVGNumberList* numberList;
295 std::pair<float, float>* numberOptionalNumber;
296 SVGPathByteStream* path;
297 SVGPreserveAspectRatio* preserveAspectRatio;
298 SVGPointList* pointList;
301 SVGTransformList* transformList;
305 } // namespace WebCore
307 #endif // ENABLE(SVG)
308 #endif // SVGAnimatedType_h