Chromium Code Reviews| 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) { | |
|
haraken
2014/02/11 17:00:21
Would you add a comment about why we need to treat
kouhei (in TOK)
2014/02/12 01:57:49
Done.
| |
| 70 ASSERT(m_animationElement); | |
| 71 SVGTransformType transformType = toSVGAnimateTransformElement(m_anim ationElement)->transformType(); | |
| 72 return SVGTransformList::create(transformType, value); | |
| 73 } | |
| 74 | |
| 64 ASSERT(m_animatedProperty); | 75 ASSERT(m_animatedProperty); |
| 65 | |
| 66 // SVG DOM animVal animation code-path. | |
| 67 return m_animatedProperty->currentValueBase()->cloneForAnimation(value); | 76 return m_animatedProperty->currentValueBase()->cloneForAnimation(value); |
| 68 } | 77 } |
| 69 | 78 |
| 70 ASSERT(isAnimatingCSSProperty()); | 79 ASSERT(isAnimatingCSSProperty()); |
| 71 | 80 |
| 72 // CSS properties animation code-path. | 81 // CSS properties animation code-path. |
| 73 // Create a basic instance of the corresponding SVG property. | 82 // Create a basic instance of the corresponding SVG property. |
| 74 // The instance will not have full context info. (e.g. SVGLengthMode) | 83 // The instance will not have full context info. (e.g. SVGLengthMode) |
| 75 | 84 |
| 76 switch (m_type) { | 85 switch (m_type) { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 92 return property.release(); | 101 return property.release(); |
| 93 } | 102 } |
| 94 case AnimatedString: { | 103 case AnimatedString: { |
| 95 RefPtr<SVGString> property = SVGString::create(); | 104 RefPtr<SVGString> property = SVGString::create(); |
| 96 property->setValueAsString(value, IGNORE_EXCEPTION); | 105 property->setValueAsString(value, IGNORE_EXCEPTION); |
| 97 return property.release(); | 106 return property.release(); |
| 98 } | 107 } |
| 99 | 108 |
| 100 // These types don't appear in the table in SVGElement::cssPropertyToTypeMap () and thus don't need support. | 109 // These types don't appear in the table in SVGElement::cssPropertyToTypeMap () and thus don't need support. |
| 101 case AnimatedBoolean: | 110 case AnimatedBoolean: |
| 111 case AnimatedMatrix: | |
| 102 case AnimatedNumberList: | 112 case AnimatedNumberList: |
| 103 case AnimatedNumberOptionalNumber: | 113 case AnimatedNumberOptionalNumber: |
| 104 case AnimatedPoint: | 114 case AnimatedPoint: |
| 105 case AnimatedPoints: | 115 case AnimatedPoints: |
| 106 case AnimatedRect: | 116 case AnimatedRect: |
| 117 case AnimatedTransform: | |
| 118 case AnimatedTransformList: | |
| 107 ASSERT_NOT_REACHED(); | 119 ASSERT_NOT_REACHED(); |
| 108 | 120 |
| 109 // These properties are not yet migrated to NewProperty implementation. see http://crbug.com/308818 | 121 // These properties are not yet migrated to NewProperty implementation. see http://crbug.com/308818 |
| 110 case AnimatedAngle: | 122 case AnimatedAngle: |
| 111 case AnimatedEnumeration: | 123 case AnimatedEnumeration: |
| 112 case AnimatedInteger: | 124 case AnimatedInteger: |
| 113 case AnimatedIntegerOptionalInteger: | 125 case AnimatedIntegerOptionalInteger: |
| 114 case AnimatedPath: | 126 case AnimatedPath: |
| 115 case AnimatedPreserveAspectRatio: | 127 case AnimatedPreserveAspectRatio: |
| 116 case AnimatedStringList: | 128 case AnimatedStringList: |
| 117 case AnimatedTransformList: | |
| 118 ASSERT_NOT_REACHED(); | 129 ASSERT_NOT_REACHED(); |
| 119 | 130 |
| 120 case AnimatedUnknown: | 131 case AnimatedUnknown: |
| 121 ASSERT_NOT_REACHED(); | 132 ASSERT_NOT_REACHED(); |
| 122 }; | 133 }; |
| 123 | 134 |
| 124 ASSERT_NOT_REACHED(); | 135 ASSERT_NOT_REACHED(); |
| 125 return 0; | 136 return 0; |
| 126 } | 137 } |
| 127 | 138 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 153 for (; it != itEnd; ++it) { | 164 for (; it != itEnd; ++it) { |
| 154 RefPtr<NewSVGAnimatedPropertyBase> animatedProperty = it->element->prope rtyFromAttribute(attributeName); | 165 RefPtr<NewSVGAnimatedPropertyBase> animatedProperty = it->element->prope rtyFromAttribute(attributeName); |
| 155 animatedProperty->setAnimatedValue(value); | 166 animatedProperty->setAnimatedValue(value); |
| 156 } | 167 } |
| 157 } | 168 } |
| 158 | 169 |
| 159 } | 170 } |
| 160 | 171 |
| 161 PassRefPtr<NewSVGPropertyBase> SVGAnimatedNewPropertyAnimator::resetAnimation(co nst SVGElementAnimatedPropertyList& list) | 172 PassRefPtr<NewSVGPropertyBase> SVGAnimatedNewPropertyAnimator::resetAnimation(co nst SVGElementAnimatedPropertyList& list) |
| 162 { | 173 { |
| 174 ASSERT(m_animationElement); | |
| 163 ASSERT(isAnimatingSVGDom()); | 175 ASSERT(isAnimatingSVGDom()); |
| 164 RefPtr<NewSVGPropertyBase> animatedValue = m_animatedProperty->createAnimate dValue(); | 176 RefPtr<NewSVGPropertyBase> animatedValue = m_animatedProperty->createAnimate dValue(m_animationElement); |
| 165 ASSERT(animatedValue->type() == m_type); | 177 ASSERT(animatedValue->type() == m_type); |
| 166 setAnimatedValueOnAllTargetProperties(list, m_animatedProperty->attributeNam e(), animatedValue); | 178 setAnimatedValueOnAllTargetProperties(list, m_animatedProperty->attributeNam e(), animatedValue); |
| 167 | 179 |
| 168 return animatedValue.release(); | 180 return animatedValue.release(); |
| 169 } | 181 } |
| 170 | 182 |
| 171 PassOwnPtr<SVGAnimatedType> SVGAnimatedNewPropertyAnimator::startAnimValAnimatio n(const SVGElementAnimatedPropertyList& list) | 183 PassOwnPtr<SVGAnimatedType> SVGAnimatedNewPropertyAnimator::startAnimValAnimatio n(const SVGElementAnimatedPropertyList& list) |
| 172 { | 184 { |
| 173 ASSERT(isAnimatingSVGDom()); | 185 ASSERT(isAnimatingSVGDom()); |
| 174 SVGElementInstance::InstanceUpdateBlocker blocker(m_contextElement); | 186 SVGElementInstance::InstanceUpdateBlocker blocker(m_contextElement); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 float SVGAnimatedNewPropertyAnimator::calculateDistance(const String& fromString , const String& toString) | 263 float SVGAnimatedNewPropertyAnimator::calculateDistance(const String& fromString , const String& toString) |
| 252 { | 264 { |
| 253 ASSERT(m_animationElement); | 265 ASSERT(m_animationElement); |
| 254 ASSERT(m_contextElement); | 266 ASSERT(m_contextElement); |
| 255 RefPtr<NewSVGPropertyBase> fromValue = createPropertyForAnimation(fromString ); | 267 RefPtr<NewSVGPropertyBase> fromValue = createPropertyForAnimation(fromString ); |
| 256 RefPtr<NewSVGPropertyBase> toValue = createPropertyForAnimation(toString); | 268 RefPtr<NewSVGPropertyBase> toValue = createPropertyForAnimation(toString); |
| 257 return fromValue->calculateDistance(toValue, m_contextElement); | 269 return fromValue->calculateDistance(toValue, m_contextElement); |
| 258 } | 270 } |
| 259 | 271 |
| 260 } // namespace WebCore | 272 } // namespace WebCore |
| OLD | NEW |