OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 2 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
3 * Copyright (C) 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2007 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2008 Apple Inc. All rights reserved. | 4 * Copyright (C) 2008 Apple Inc. 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 16 matching lines...) Expand all Loading... |
27 #include "core/svg/SVGMPathElement.h" | 27 #include "core/svg/SVGMPathElement.h" |
28 #include "core/svg/SVGParserUtilities.h" | 28 #include "core/svg/SVGParserUtilities.h" |
29 #include "core/svg/SVGPathElement.h" | 29 #include "core/svg/SVGPathElement.h" |
30 #include "core/svg/SVGPathUtilities.h" | 30 #include "core/svg/SVGPathUtilities.h" |
31 #include "platform/transforms/AffineTransform.h" | 31 #include "platform/transforms/AffineTransform.h" |
32 #include "wtf/MathExtras.h" | 32 #include "wtf/MathExtras.h" |
33 #include "wtf/StdLibExtras.h" | 33 #include "wtf/StdLibExtras.h" |
34 | 34 |
35 namespace blink { | 35 namespace blink { |
36 | 36 |
37 using namespace SVGNames; | 37 namespace { |
| 38 |
| 39 bool targetCanHaveMotionTransform(const SVGElement& target) { |
| 40 // We don't have a special attribute name to verify the animation type. Check |
| 41 // the element name instead. |
| 42 if (!target.isSVGGraphicsElement()) |
| 43 return false; |
| 44 // Spec: SVG 1.1 section 19.2.15 |
| 45 // FIXME: svgTag is missing. Needs to be checked, if transforming <svg> could |
| 46 // cause problems. |
| 47 return isSVGGElement(target) || isSVGDefsElement(target) || |
| 48 isSVGUseElement(target) || isSVGImageElement(target) || |
| 49 isSVGSwitchElement(target) || isSVGPathElement(target) || |
| 50 isSVGRectElement(target) || isSVGCircleElement(target) || |
| 51 isSVGEllipseElement(target) || isSVGLineElement(target) || |
| 52 isSVGPolylineElement(target) || isSVGPolygonElement(target) || |
| 53 isSVGTextElement(target) || isSVGClipPathElement(target) || |
| 54 isSVGMaskElement(target) || isSVGAElement(target) || |
| 55 isSVGForeignObjectElement(target); |
| 56 } |
| 57 } |
38 | 58 |
39 inline SVGAnimateMotionElement::SVGAnimateMotionElement(Document& document) | 59 inline SVGAnimateMotionElement::SVGAnimateMotionElement(Document& document) |
40 : SVGAnimationElement(animateMotionTag, document), | 60 : SVGAnimationElement(SVGNames::animateMotionTag, document), |
41 m_hasToPointAtEndOfDuration(false) { | 61 m_hasToPointAtEndOfDuration(false) { |
42 setCalcMode(CalcModePaced); | 62 setCalcMode(CalcModePaced); |
43 } | 63 } |
44 | 64 |
45 DEFINE_NODE_FACTORY(SVGAnimateMotionElement) | 65 DEFINE_NODE_FACTORY(SVGAnimateMotionElement) |
46 | 66 |
47 SVGAnimateMotionElement::~SVGAnimateMotionElement() {} | 67 SVGAnimateMotionElement::~SVGAnimateMotionElement() {} |
48 | 68 |
49 bool SVGAnimateMotionElement::hasValidAttributeType() { | 69 bool SVGAnimateMotionElement::hasValidTarget() { |
50 SVGElement* targetElement = this->targetElement(); | 70 return SVGAnimationElement::hasValidTarget() && |
51 if (!targetElement) | 71 targetCanHaveMotionTransform(*targetElement()); |
52 return false; | |
53 | |
54 // We don't have a special attribute name to verify the animation type. Check | |
55 // the element name instead. | |
56 if (!targetElement->isSVGGraphicsElement()) | |
57 return false; | |
58 // Spec: SVG 1.1 section 19.2.15 | |
59 // FIXME: svgTag is missing. Needs to be checked, if transforming <svg> could | |
60 // cause problems. | |
61 return ( | |
62 isSVGGElement(*targetElement) || isSVGDefsElement(*targetElement) || | |
63 isSVGUseElement(*targetElement) || isSVGImageElement(*targetElement) || | |
64 isSVGSwitchElement(*targetElement) || isSVGPathElement(*targetElement) || | |
65 isSVGRectElement(*targetElement) || isSVGCircleElement(*targetElement) || | |
66 isSVGEllipseElement(*targetElement) || isSVGLineElement(*targetElement) || | |
67 isSVGPolylineElement(*targetElement) || | |
68 isSVGPolygonElement(*targetElement) || isSVGTextElement(*targetElement) || | |
69 isSVGClipPathElement(*targetElement) || | |
70 isSVGMaskElement(*targetElement) || isSVGAElement(*targetElement) || | |
71 isSVGForeignObjectElement(*targetElement)); | |
72 } | |
73 | |
74 bool SVGAnimateMotionElement::hasValidAttributeName() { | |
75 // AnimateMotion does not use attributeName so it is always valid. | |
76 return true; | |
77 } | 72 } |
78 | 73 |
79 void SVGAnimateMotionElement::parseAttribute(const QualifiedName& name, | 74 void SVGAnimateMotionElement::parseAttribute(const QualifiedName& name, |
80 const AtomicString& oldValue, | 75 const AtomicString& oldValue, |
81 const AtomicString& value) { | 76 const AtomicString& value) { |
82 if (name == SVGNames::pathAttr) { | 77 if (name == SVGNames::pathAttr) { |
83 m_path = Path(); | 78 m_path = Path(); |
84 buildPathFromString(value, m_path); | 79 buildPathFromString(value, m_path); |
85 updateAnimationPath(); | 80 updateAnimationPath(); |
86 return; | 81 return; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 139 |
145 static bool parsePoint(const String& string, FloatPoint& point) { | 140 static bool parsePoint(const String& string, FloatPoint& point) { |
146 if (string.isEmpty()) | 141 if (string.isEmpty()) |
147 return false; | 142 return false; |
148 if (string.is8Bit()) | 143 if (string.is8Bit()) |
149 return parsePointInternal<LChar>(string, point); | 144 return parsePointInternal<LChar>(string, point); |
150 return parsePointInternal<UChar>(string, point); | 145 return parsePointInternal<UChar>(string, point); |
151 } | 146 } |
152 | 147 |
153 void SVGAnimateMotionElement::resetAnimatedType() { | 148 void SVGAnimateMotionElement::resetAnimatedType() { |
154 if (!hasValidAttributeType()) | |
155 return; | |
156 SVGElement* targetElement = this->targetElement(); | 149 SVGElement* targetElement = this->targetElement(); |
157 if (!targetElement) | 150 if (!targetElement || !targetCanHaveMotionTransform(*targetElement)) |
158 return; | 151 return; |
159 if (AffineTransform* transform = targetElement->animateMotionTransform()) | 152 if (AffineTransform* transform = targetElement->animateMotionTransform()) |
160 transform->makeIdentity(); | 153 transform->makeIdentity(); |
161 } | 154 } |
162 | 155 |
163 void SVGAnimateMotionElement::clearAnimatedType() { | 156 void SVGAnimateMotionElement::clearAnimatedType() { |
164 SVGElement* targetElement = this->targetElement(); | 157 SVGElement* targetElement = this->targetElement(); |
165 if (!targetElement) | 158 if (!targetElement) |
166 return; | 159 return; |
167 | 160 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 } | 297 } |
305 | 298 |
306 void SVGAnimateMotionElement::updateAnimationMode() { | 299 void SVGAnimateMotionElement::updateAnimationMode() { |
307 if (!m_animationPath.isEmpty()) | 300 if (!m_animationPath.isEmpty()) |
308 setAnimationMode(PathAnimation); | 301 setAnimationMode(PathAnimation); |
309 else | 302 else |
310 SVGAnimationElement::updateAnimationMode(); | 303 SVGAnimationElement::updateAnimationMode(); |
311 } | 304 } |
312 | 305 |
313 } // namespace blink | 306 } // namespace blink |
OLD | NEW |