OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
5 * Copyright (C) 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2008 Apple Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
11 * | 11 * |
12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
21 */ | 21 */ |
22 | 22 |
23 #include "core/svg/SVGAnimateTransformElement.h" | 23 #include "core/svg/SVGAnimateTransformElement.h" |
24 | 24 |
25 #include "core/SVGNames.h" | 25 #include "core/SVGNames.h" |
26 #include "core/svg/SVGTransformList.h" | 26 #include "core/svg/SVGTransformList.h" |
| 27 #include "core/svg/properties/SVGAnimatedProperty.h" |
27 | 28 |
28 namespace blink { | 29 namespace blink { |
29 | 30 |
30 inline SVGAnimateTransformElement::SVGAnimateTransformElement( | 31 inline SVGAnimateTransformElement::SVGAnimateTransformElement( |
31 Document& document) | 32 Document& document) |
32 : SVGAnimateElement(SVGNames::animateTransformTag, document), | 33 : SVGAnimateElement(SVGNames::animateTransformTag, document), |
33 m_type(kSvgTransformUnknown) {} | 34 m_transformType(kSvgTransformUnknown) {} |
34 | 35 |
35 DEFINE_NODE_FACTORY(SVGAnimateTransformElement) | 36 DEFINE_NODE_FACTORY(SVGAnimateTransformElement) |
36 | 37 |
37 bool SVGAnimateTransformElement::hasValidAttributeType() { | 38 bool SVGAnimateTransformElement::hasValidAttributeType() { |
38 SVGElement* targetElement = this->targetElement(); | 39 SVGElement* targetElement = this->targetElement(); |
39 if (!targetElement) | 40 if (!targetElement) |
40 return false; | 41 return false; |
41 | 42 |
42 if (getAttributeType() == AttributeTypeCSS) | 43 if (getAttributeType() == AttributeTypeCSS) |
43 return false; | 44 return false; |
44 | 45 |
45 return animatedPropertyType() == AnimatedTransformList; | 46 return animatedPropertyType() == AnimatedTransformList; |
46 } | 47 } |
47 | 48 |
| 49 void SVGAnimateTransformElement::resolveTargetProperty() { |
| 50 DCHECK(targetElement()); |
| 51 m_targetProperty = targetElement()->propertyFromAttribute(attributeName()); |
| 52 m_type = m_targetProperty ? m_targetProperty->type() : AnimatedUnknown; |
| 53 // <animateTransform> only animates AnimatedTransformList. |
| 54 // http://www.w3.org/TR/SVG/animate.html#AnimationAttributesAndProperties |
| 55 if (m_type != AnimatedTransformList) |
| 56 m_type = AnimatedUnknown; |
| 57 // Because of the syntactic mismatch between the CSS and SVGProperty |
| 58 // representations, disallow CSS animations of transforms. Support for that |
| 59 // is better added to the <animate> element since the <animateTransform> |
| 60 // element is deprecated and quirky. (We also reject this case via |
| 61 // hasValidAttributeType above.) |
| 62 m_cssPropertyId = CSSPropertyInvalid; |
| 63 } |
| 64 |
| 65 SVGPropertyBase* SVGAnimateTransformElement::createPropertyForAnimation( |
| 66 const String& value) const { |
| 67 DCHECK(isAnimatingSVGDom()); |
| 68 return SVGTransformList::create(m_transformType, value); |
| 69 } |
| 70 |
48 void SVGAnimateTransformElement::parseAttribute(const QualifiedName& name, | 71 void SVGAnimateTransformElement::parseAttribute(const QualifiedName& name, |
49 const AtomicString& oldValue, | 72 const AtomicString& oldValue, |
50 const AtomicString& value) { | 73 const AtomicString& value) { |
51 if (name == SVGNames::typeAttr) { | 74 if (name == SVGNames::typeAttr) { |
52 m_type = parseTransformType(value); | 75 m_transformType = parseTransformType(value); |
53 if (m_type == kSvgTransformMatrix) | 76 if (m_transformType == kSvgTransformMatrix) |
54 m_type = kSvgTransformUnknown; | 77 m_transformType = kSvgTransformUnknown; |
55 return; | 78 return; |
56 } | 79 } |
57 | 80 |
58 SVGAnimateElement::parseAttribute(name, oldValue, value); | 81 SVGAnimateElement::parseAttribute(name, oldValue, value); |
59 } | 82 } |
60 | 83 |
61 } // namespace blink | 84 } // namespace blink |
OLD | NEW |