| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/svg/SVGAnimatedNewPropertyAnimator.h" | 32 #include "core/svg/SVGAnimatedNewPropertyAnimator.h" |
| 33 | 33 |
| 34 #include "core/svg/SVGAnimateTransformElement.h" |
| 34 #include "core/svg/SVGAnimatedColor.h" | 35 #include "core/svg/SVGAnimatedColor.h" |
| 35 #include "core/svg/SVGAnimationElement.h" | 36 #include "core/svg/SVGAnimationElement.h" |
| 37 #include "core/svg/SVGColor.h" |
| 36 #include "core/svg/SVGElementInstance.h" | 38 #include "core/svg/SVGElementInstance.h" |
| 37 #include "core/svg/SVGLength.h" | 39 #include "core/svg/SVGLength.h" |
| 38 #include "core/svg/SVGLengthList.h" | 40 #include "core/svg/SVGLengthList.h" |
| 39 #include "core/svg/SVGNumber.h" | 41 #include "core/svg/SVGNumber.h" |
| 40 #include "core/svg/SVGPointList.h" | 42 #include "core/svg/SVGPointList.h" |
| 41 #include "core/svg/SVGString.h" | 43 #include "core/svg/SVGString.h" |
| 44 #include "core/svg/SVGTransformList.h" |
| 42 | 45 |
| 43 namespace WebCore { | 46 namespace WebCore { |
| 44 | 47 |
| 45 SVGAnimatedNewPropertyAnimator::SVGAnimatedNewPropertyAnimator(AnimatedPropertyT
ype type, SVGAnimationElement* animationElement, SVGElement* contextElement) | 48 SVGAnimatedNewPropertyAnimator::SVGAnimatedNewPropertyAnimator(AnimatedPropertyT
ype type, SVGAnimationElement* animationElement, SVGElement* contextElement) |
| 46 : SVGAnimatedTypeAnimator(type, animationElement, contextElement) | 49 : SVGAnimatedTypeAnimator(type, animationElement, contextElement) |
| 47 { | 50 { |
| 48 ASSERT(m_animationElement); | 51 ASSERT(m_animationElement); |
| 49 ASSERT(m_contextElement); | 52 ASSERT(m_contextElement); |
| 50 | 53 |
| 51 const QualifiedName& attributeName = m_animationElement->attributeName(); | 54 const QualifiedName& attributeName = m_animationElement->attributeName(); |
| 52 m_animatedProperty = m_contextElement->propertyFromAttribute(attributeName); | 55 m_animatedProperty = m_contextElement->propertyFromAttribute(attributeName); |
| 53 if (m_animatedProperty) | 56 if (m_animatedProperty) |
| 54 ASSERT(m_animatedProperty->type() == m_type); | 57 ASSERT(m_animatedProperty->type() == m_type); |
| 55 } | 58 } |
| 56 | 59 |
| 57 SVGAnimatedNewPropertyAnimator::~SVGAnimatedNewPropertyAnimator() | 60 SVGAnimatedNewPropertyAnimator::~SVGAnimatedNewPropertyAnimator() |
| 58 { | 61 { |
| 59 } | 62 } |
| 60 | 63 |
| 61 PassRefPtr<NewSVGPropertyBase> SVGAnimatedNewPropertyAnimator::createPropertyFor
Animation(const String& value) | 64 PassRefPtr<NewSVGPropertyBase> SVGAnimatedNewPropertyAnimator::createPropertyFor
Animation(const String& value) |
| 62 { | 65 { |
| 63 if (isAnimatingSVGDom()) { | 66 if (isAnimatingSVGDom()) { |
| 67 // SVG DOM animVal animation code-path. |
| 68 |
| 69 if (m_type == AnimatedTransformList) { |
| 70 // TransformList must be animated via <animateTransform>, |
| 71 // and its {from,by,to} attribute values needs to be parsed w.r.t. i
ts "type" attribute. |
| 72 // Spec: http://www.w3.org/TR/SVG/single-page.html#animate-AnimateTr
ansformElement |
| 73 ASSERT(m_animationElement); |
| 74 SVGTransformType transformType = toSVGAnimateTransformElement(m_anim
ationElement)->transformType(); |
| 75 return SVGTransformList::create(transformType, value); |
| 76 } |
| 77 |
| 64 ASSERT(m_animatedProperty); | 78 ASSERT(m_animatedProperty); |
| 65 | |
| 66 // SVG DOM animVal animation code-path. | |
| 67 return m_animatedProperty->currentValueBase()->cloneForAnimation(value); | 79 return m_animatedProperty->currentValueBase()->cloneForAnimation(value); |
| 68 } | 80 } |
| 69 | 81 |
| 70 ASSERT(isAnimatingCSSProperty()); | 82 ASSERT(isAnimatingCSSProperty()); |
| 71 | 83 |
| 72 // CSS properties animation code-path. | 84 // CSS properties animation code-path. |
| 73 // Create a basic instance of the corresponding SVG property. | 85 // Create a basic instance of the corresponding SVG property. |
| 74 // The instance will not have full context info. (e.g. SVGLengthMode) | 86 // The instance will not have full context info. (e.g. SVGLengthMode) |
| 75 | 87 |
| 76 switch (m_type) { | 88 switch (m_type) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 97 return property.release(); | 109 return property.release(); |
| 98 } | 110 } |
| 99 | 111 |
| 100 // These types don't appear in the table in SVGElement::cssPropertyToTypeMap
() and thus don't need support. | 112 // These types don't appear in the table in SVGElement::cssPropertyToTypeMap
() and thus don't need support. |
| 101 case AnimatedBoolean: | 113 case AnimatedBoolean: |
| 102 case AnimatedNumberList: | 114 case AnimatedNumberList: |
| 103 case AnimatedNumberOptionalNumber: | 115 case AnimatedNumberOptionalNumber: |
| 104 case AnimatedPoint: | 116 case AnimatedPoint: |
| 105 case AnimatedPoints: | 117 case AnimatedPoints: |
| 106 case AnimatedRect: | 118 case AnimatedRect: |
| 119 case AnimatedTransform: |
| 120 case AnimatedTransformList: |
| 107 ASSERT_NOT_REACHED(); | 121 ASSERT_NOT_REACHED(); |
| 108 | 122 |
| 109 // These properties are not yet migrated to NewProperty implementation. see
http://crbug.com/308818 | 123 // These properties are not yet migrated to NewProperty implementation. see
http://crbug.com/308818 |
| 110 case AnimatedAngle: | 124 case AnimatedAngle: |
| 111 case AnimatedEnumeration: | 125 case AnimatedEnumeration: |
| 112 case AnimatedInteger: | 126 case AnimatedInteger: |
| 113 case AnimatedIntegerOptionalInteger: | 127 case AnimatedIntegerOptionalInteger: |
| 114 case AnimatedPath: | 128 case AnimatedPath: |
| 115 case AnimatedPreserveAspectRatio: | 129 case AnimatedPreserveAspectRatio: |
| 116 case AnimatedStringList: | 130 case AnimatedStringList: |
| 117 case AnimatedTransformList: | |
| 118 ASSERT_NOT_REACHED(); | 131 ASSERT_NOT_REACHED(); |
| 119 | 132 |
| 120 case AnimatedUnknown: | 133 case AnimatedUnknown: |
| 121 ASSERT_NOT_REACHED(); | 134 ASSERT_NOT_REACHED(); |
| 122 }; | 135 }; |
| 123 | 136 |
| 124 ASSERT_NOT_REACHED(); | 137 ASSERT_NOT_REACHED(); |
| 125 return 0; | 138 return 0; |
| 126 } | 139 } |
| 127 | 140 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 float SVGAnimatedNewPropertyAnimator::calculateDistance(const String& fromString
, const String& toString) | 264 float SVGAnimatedNewPropertyAnimator::calculateDistance(const String& fromString
, const String& toString) |
| 252 { | 265 { |
| 253 ASSERT(m_animationElement); | 266 ASSERT(m_animationElement); |
| 254 ASSERT(m_contextElement); | 267 ASSERT(m_contextElement); |
| 255 RefPtr<NewSVGPropertyBase> fromValue = createPropertyForAnimation(fromString
); | 268 RefPtr<NewSVGPropertyBase> fromValue = createPropertyForAnimation(fromString
); |
| 256 RefPtr<NewSVGPropertyBase> toValue = createPropertyForAnimation(toString); | 269 RefPtr<NewSVGPropertyBase> toValue = createPropertyForAnimation(toString); |
| 257 return fromValue->calculateDistance(toValue, m_contextElement); | 270 return fromValue->calculateDistance(toValue, m_contextElement); |
| 258 } | 271 } |
| 259 | 272 |
| 260 } // namespace WebCore | 273 } // namespace WebCore |
| OLD | NEW |