| 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 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> |
| 4 * Copyright (C) 2008 Apple Inc. All rights reserved. | 4 * Copyright (C) 2008 Apple Inc. All rights reserved. |
| 5 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 5 * Copyright (C) Research In Motion Limited 2011. 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. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 } // unnamed namespace | 99 } // unnamed namespace |
| 100 | 100 |
| 101 SVGAnimateElement::SVGAnimateElement(const QualifiedName& tagName, | 101 SVGAnimateElement::SVGAnimateElement(const QualifiedName& tagName, |
| 102 Document& document) | 102 Document& document) |
| 103 : SVGAnimationElement(tagName, document), | 103 : SVGAnimationElement(tagName, document), |
| 104 m_type(AnimatedUnknown), | 104 m_type(AnimatedUnknown), |
| 105 m_cssPropertyId(CSSPropertyInvalid), | 105 m_cssPropertyId(CSSPropertyInvalid), |
| 106 m_fromPropertyValueType(RegularPropertyValue), | 106 m_fromPropertyValueType(RegularPropertyValue), |
| 107 m_toPropertyValueType(RegularPropertyValue), | 107 m_toPropertyValueType(RegularPropertyValue), |
| 108 m_attributeType(AttributeTypeAuto), | 108 m_attributeType(AttributeTypeAuto) {} |
| 109 m_hasInvalidCSSAttributeType(false) {} | |
| 110 | 109 |
| 111 SVGAnimateElement* SVGAnimateElement::create(Document& document) { | 110 SVGAnimateElement* SVGAnimateElement::create(Document& document) { |
| 112 return new SVGAnimateElement(SVGNames::animateTag, document); | 111 return new SVGAnimateElement(SVGNames::animateTag, document); |
| 113 } | 112 } |
| 114 | 113 |
| 115 SVGAnimateElement::~SVGAnimateElement() {} | 114 SVGAnimateElement::~SVGAnimateElement() {} |
| 116 | 115 |
| 117 bool SVGAnimateElement::isSVGAnimationAttributeSettingJavaScriptURL( | 116 bool SVGAnimateElement::isSVGAnimationAttributeSettingJavaScriptURL( |
| 118 const Attribute& attribute) const { | 117 const Attribute& attribute) const { |
| 119 if ((attribute.name() == SVGNames::fromAttr || | 118 if ((attribute.name() == SVGNames::fromAttr || |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 AnimatedPropertyType SVGAnimateElement::animatedPropertyType() { | 206 AnimatedPropertyType SVGAnimateElement::animatedPropertyType() { |
| 208 if (!targetElement()) | 207 if (!targetElement()) |
| 209 return AnimatedUnknown; | 208 return AnimatedUnknown; |
| 210 resolveTargetProperty(); | 209 resolveTargetProperty(); |
| 211 return m_type; | 210 return m_type; |
| 212 } | 211 } |
| 213 | 212 |
| 214 bool SVGAnimateElement::hasValidTarget() { | 213 bool SVGAnimateElement::hasValidTarget() { |
| 215 if (!SVGAnimationElement::hasValidTarget()) | 214 if (!SVGAnimationElement::hasValidTarget()) |
| 216 return false; | 215 return false; |
| 217 if (!hasValidAttributeName()) | 216 if (attributeName() == anyQName()) |
| 218 return false; | 217 return false; |
| 219 resolveTargetProperty(); | 218 resolveTargetProperty(); |
| 220 return m_type != AnimatedUnknown && !m_hasInvalidCSSAttributeType; | 219 if (m_type == AnimatedUnknown) |
| 221 } | 220 return false; |
| 222 | 221 // Always animate CSS properties using the ApplyCSSAnimation code path, |
| 223 bool SVGAnimateElement::hasValidAttributeName() const { | 222 // regardless of the attributeType value. |
| 224 return attributeName() != anyQName(); | 223 // If attributeType="CSS" and attributeName doesn't point to a CSS property, |
| 224 // ignore the animation. |
| 225 return isTargetAttributeCSSProperty(*targetElement(), attributeName()) || |
| 226 getAttributeType() != AttributeTypeCSS; |
| 225 } | 227 } |
| 226 | 228 |
| 227 bool SVGAnimateElement::shouldApplyAnimation( | 229 bool SVGAnimateElement::shouldApplyAnimation( |
| 228 const SVGElement& targetElement, | 230 const SVGElement& targetElement, |
| 229 const QualifiedName& attributeName) { | 231 const QualifiedName& attributeName) { |
| 230 if (!hasValidTarget() || !targetElement.parentNode()) | 232 return targetElement.parentNode() && hasValidTarget(); |
| 231 return false; | |
| 232 | |
| 233 // Always animate CSS properties using the ApplyCSSAnimation code path, | |
| 234 // regardless of the attributeType value. | |
| 235 if (isTargetAttributeCSSProperty(targetElement, attributeName)) | |
| 236 return true; | |
| 237 | |
| 238 // If attributeType="CSS" and attributeName doesn't point to a CSS property, | |
| 239 // ignore the animation. | |
| 240 return getAttributeType() != AttributeTypeCSS; | |
| 241 } | 233 } |
| 242 | 234 |
| 243 SVGPropertyBase* SVGAnimateElement::createPropertyForAttributeAnimation( | 235 SVGPropertyBase* SVGAnimateElement::createPropertyForAttributeAnimation( |
| 244 const String& value) const { | 236 const String& value) const { |
| 245 // SVG DOM animVal animation code-path. | 237 // SVG DOM animVal animation code-path. |
| 246 // TransformList must be animated via <animateTransform>, and its | 238 // TransformList must be animated via <animateTransform>, and its |
| 247 // {from,by,to} attribute values needs to be parsed w.r.t. its "type" | 239 // {from,by,to} attribute values needs to be parsed w.r.t. its "type" |
| 248 // attribute. Spec: | 240 // attribute. Spec: |
| 249 // http://www.w3.org/TR/SVG/single-page.html#animate-AnimateTransformElement | 241 // http://www.w3.org/TR/SVG/single-page.html#animate-AnimateTransformElement |
| 250 DCHECK_NE(m_type, AnimatedTransformList); | 242 DCHECK_NE(m_type, AnimatedTransformList); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 float SVGAnimateElement::calculateDistance(const String& fromString, | 542 float SVGAnimateElement::calculateDistance(const String& fromString, |
| 551 const String& toString) { | 543 const String& toString) { |
| 552 DCHECK(targetElement()); | 544 DCHECK(targetElement()); |
| 553 // FIXME: A return value of float is not enough to support paced animations on | 545 // FIXME: A return value of float is not enough to support paced animations on |
| 554 // lists. | 546 // lists. |
| 555 SVGPropertyBase* fromValue = createPropertyForAnimation(fromString); | 547 SVGPropertyBase* fromValue = createPropertyForAnimation(fromString); |
| 556 SVGPropertyBase* toValue = createPropertyForAnimation(toString); | 548 SVGPropertyBase* toValue = createPropertyForAnimation(toString); |
| 557 return fromValue->calculateDistance(toValue, targetElement()); | 549 return fromValue->calculateDistance(toValue, targetElement()); |
| 558 } | 550 } |
| 559 | 551 |
| 560 void SVGAnimateElement::setTargetElement(SVGElement* target) { | 552 void SVGAnimateElement::willChangeAnimationTarget() { |
| 561 SVGAnimationElement::setTargetElement(target); | 553 SVGAnimationElement::willChangeAnimationTarget(); |
| 562 checkInvalidCSSAttributeType(); | 554 if (targetElement()) |
| 555 clearAnimatedType(); |
| 556 } |
| 557 |
| 558 void SVGAnimateElement::didChangeAnimationTarget() { |
| 559 SVGAnimationElement::didChangeAnimationTarget(); |
| 563 resetAnimatedPropertyType(); | 560 resetAnimatedPropertyType(); |
| 564 } | 561 } |
| 565 | 562 |
| 566 void SVGAnimateElement::setAttributeName(const QualifiedName& attributeName) { | 563 void SVGAnimateElement::setAttributeName(const QualifiedName& attributeName) { |
| 567 unscheduleIfScheduled(); | 564 willChangeAnimationTarget(); |
| 568 if (targetElement()) | |
| 569 clearAnimatedType(); | |
| 570 m_attributeName = attributeName; | 565 m_attributeName = attributeName; |
| 571 schedule(); | 566 didChangeAnimationTarget(); |
| 572 checkInvalidCSSAttributeType(); | |
| 573 resetAnimatedPropertyType(); | |
| 574 } | 567 } |
| 575 | 568 |
| 576 void SVGAnimateElement::setAttributeType(const AtomicString& attributeType) { | 569 void SVGAnimateElement::setAttributeType(const AtomicString& attributeType) { |
| 570 willChangeAnimationTarget(); |
| 577 if (attributeType == "CSS") | 571 if (attributeType == "CSS") |
| 578 m_attributeType = AttributeTypeCSS; | 572 m_attributeType = AttributeTypeCSS; |
| 579 else if (attributeType == "XML") | 573 else if (attributeType == "XML") |
| 580 m_attributeType = AttributeTypeXML; | 574 m_attributeType = AttributeTypeXML; |
| 581 else | 575 else |
| 582 m_attributeType = AttributeTypeAuto; | 576 m_attributeType = AttributeTypeAuto; |
| 583 checkInvalidCSSAttributeType(); | 577 didChangeAnimationTarget(); |
| 584 } | |
| 585 | |
| 586 void SVGAnimateElement::checkInvalidCSSAttributeType() { | |
| 587 bool hasInvalidCSSAttributeType = | |
| 588 targetElement() && hasValidAttributeName() && | |
| 589 getAttributeType() == AttributeTypeCSS && | |
| 590 !isTargetAttributeCSSProperty(*targetElement(), attributeName()); | |
| 591 | |
| 592 if (hasInvalidCSSAttributeType != m_hasInvalidCSSAttributeType) { | |
| 593 if (hasInvalidCSSAttributeType) | |
| 594 unscheduleIfScheduled(); | |
| 595 | |
| 596 m_hasInvalidCSSAttributeType = hasInvalidCSSAttributeType; | |
| 597 | |
| 598 if (!hasInvalidCSSAttributeType) | |
| 599 schedule(); | |
| 600 } | |
| 601 | |
| 602 // Clear values that may depend on the previous target. | |
| 603 if (targetElement()) | |
| 604 clearAnimatedType(); | |
| 605 } | 578 } |
| 606 | 579 |
| 607 void SVGAnimateElement::resetAnimatedPropertyType() { | 580 void SVGAnimateElement::resetAnimatedPropertyType() { |
| 608 DCHECK(!m_animatedValue); | 581 DCHECK(!m_animatedValue); |
| 609 m_fromProperty.clear(); | 582 m_fromProperty.clear(); |
| 610 m_toProperty.clear(); | 583 m_toProperty.clear(); |
| 611 m_toAtEndOfDurationProperty.clear(); | 584 m_toAtEndOfDurationProperty.clear(); |
| 612 clearTargetProperty(); | 585 clearTargetProperty(); |
| 613 } | 586 } |
| 614 | 587 |
| 615 DEFINE_TRACE(SVGAnimateElement) { | 588 DEFINE_TRACE(SVGAnimateElement) { |
| 616 visitor->trace(m_fromProperty); | 589 visitor->trace(m_fromProperty); |
| 617 visitor->trace(m_toProperty); | 590 visitor->trace(m_toProperty); |
| 618 visitor->trace(m_toAtEndOfDurationProperty); | 591 visitor->trace(m_toAtEndOfDurationProperty); |
| 619 visitor->trace(m_animatedValue); | 592 visitor->trace(m_animatedValue); |
| 620 visitor->trace(m_targetProperty); | 593 visitor->trace(m_targetProperty); |
| 621 SVGAnimationElement::trace(visitor); | 594 SVGAnimationElement::trace(visitor); |
| 622 } | 595 } |
| 623 | 596 |
| 624 } // namespace blink | 597 } // namespace blink |
| OLD | NEW |