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.
21 #include "core/svg/SVGAnimatedType.h"
23 #include "bindings/v8/ExceptionState.h"
24 #include "core/svg/SVGParserUtilities.h"
25 #include "core/svg/SVGPathByteStream.h"
29 SVGAnimatedType::SVGAnimatedType(AnimatedPropertyType type)
34 SVGAnimatedType::~SVGAnimatedType()
38 delete m_data.angleAndEnumeration;
40 case AnimatedEnumeration:
41 delete m_data.enumeration;
46 case AnimatedTransformList:
47 delete m_data.transformList;
49 // Below properties are migrated to new property implementation.
53 case AnimatedIntegerOptionalInteger:
55 case AnimatedNumberList:
56 case AnimatedNumberOptionalNumber:
58 case AnimatedLengthList:
60 case AnimatedPreserveAspectRatio:
63 case AnimatedStringList:
67 // There is no SVGAnimatedPoint
78 PassOwnPtr<SVGAnimatedType> SVGAnimatedType::createAngleAndEnumeration(std::pair<SVGAngle, unsigned>* angleAndEnumeration)
80 ASSERT(angleAndEnumeration);
81 OwnPtr<SVGAnimatedType> animatedType = adoptPtr(new SVGAnimatedType(AnimatedAngle));
82 animatedType->m_data.angleAndEnumeration = angleAndEnumeration;
83 return animatedType.release();
86 PassOwnPtr<SVGAnimatedType> SVGAnimatedType::createEnumeration(unsigned* enumeration)
89 OwnPtr<SVGAnimatedType> animatedType = adoptPtr(new SVGAnimatedType(AnimatedEnumeration));
90 animatedType->m_data.enumeration = enumeration;
91 return animatedType.release();
94 PassOwnPtr<SVGAnimatedType> SVGAnimatedType::createPath(PassOwnPtr<SVGPathByteStream> path)
97 OwnPtr<SVGAnimatedType> animatedType = adoptPtr(new SVGAnimatedType(AnimatedPath));
98 animatedType->m_data.path = path.leakPtr();
99 return animatedType.release();
102 PassOwnPtr<SVGAnimatedType> SVGAnimatedType::createTransformList(SVGTransformList* transformList)
104 ASSERT(transformList);
105 OwnPtr<SVGAnimatedType> animatedType = adoptPtr(new SVGAnimatedType(AnimatedTransformList));
106 animatedType->m_data.transformList = transformList;
107 return animatedType.release();
110 PassOwnPtr<SVGAnimatedType> SVGAnimatedType::createNewProperty(PassRefPtr<NewSVGPropertyBase> newProperty)
113 OwnPtr<SVGAnimatedType> animatedType = adoptPtr(new SVGAnimatedType(newProperty->type()));
114 animatedType->m_newProperty = newProperty;
115 return animatedType.release();
118 String SVGAnimatedType::valueAsString()
121 // Below properties have migrated to new property implementation.
124 case AnimatedNumberList:
125 case AnimatedNumberOptionalNumber:
127 case AnimatedLengthList:
129 case AnimatedPreserveAspectRatio:
132 case AnimatedStringList:
133 return m_newProperty->valueAsString();
135 // These types don't appear in the table in SVGElement::cssPropertyToTypeMap() and thus don't need valueAsString() support.
137 case AnimatedBoolean:
138 case AnimatedEnumeration:
139 case AnimatedInteger:
140 case AnimatedIntegerOptionalInteger:
143 case AnimatedTransformList:
144 case AnimatedUnknown:
145 // Only SVG DOM animations use these property types - that means valueAsString() is never used for those.
146 ASSERT_NOT_REACHED();
149 ASSERT_NOT_REACHED();
153 bool SVGAnimatedType::setValueAsString(const QualifiedName& attrName, const String& value)
156 // Below properties have migrated to new property implementation.
159 case AnimatedNumberList:
160 case AnimatedNumberOptionalNumber:
162 case AnimatedLengthList:
164 case AnimatedPreserveAspectRatio:
167 case AnimatedStringList:
168 // Always use createForAnimation call path for these implementations.
171 // These types don't appear in the table in SVGElement::cssPropertyToTypeMap() and thus don't need setValueAsString() support.
173 case AnimatedBoolean:
174 case AnimatedEnumeration:
175 case AnimatedInteger:
176 case AnimatedIntegerOptionalInteger:
179 case AnimatedTransformList:
180 case AnimatedUnknown:
181 // Only SVG DOM animations use these property types - that means setValueAsString() is never used for those.
182 ASSERT_NOT_REACHED();
188 bool SVGAnimatedType::supportsAnimVal(AnimatedPropertyType type)
190 // AnimatedColor is only used for CSS property animations.
191 return type != AnimatedUnknown && type != AnimatedColor;
194 } // namespace WebCore