| 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 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> | 6 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> |
| 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 String SVGAnimationElement::byValue() const | 329 String SVGAnimationElement::byValue() const |
| 330 { | 330 { |
| 331 return fastGetAttribute(SVGNames::byAttr); | 331 return fastGetAttribute(SVGNames::byAttr); |
| 332 } | 332 } |
| 333 | 333 |
| 334 String SVGAnimationElement::fromValue() const | 334 String SVGAnimationElement::fromValue() const |
| 335 { | 335 { |
| 336 return fastGetAttribute(SVGNames::fromAttr); | 336 return fastGetAttribute(SVGNames::fromAttr); |
| 337 } | 337 } |
| 338 | 338 |
| 339 bool SVGAnimationElement::isAdditive() const | 339 bool SVGAnimationElement::isAdditive() |
| 340 { | 340 { |
| 341 DEFINE_STATIC_LOCAL(const AtomicString, sum, ("sum", AtomicString::Construct
FromLiteral)); | 341 DEFINE_STATIC_LOCAL(const AtomicString, sum, ("sum", AtomicString::Construct
FromLiteral)); |
| 342 const AtomicString& value = fastGetAttribute(SVGNames::additiveAttr); | 342 const AtomicString& value = fastGetAttribute(SVGNames::additiveAttr); |
| 343 return value == sum || animationMode() == ByAnimation; | 343 return value == sum || animationMode() == ByAnimation; |
| 344 } | 344 } |
| 345 | 345 |
| 346 bool SVGAnimationElement::isAccumulated() const | 346 bool SVGAnimationElement::isAccumulated() const |
| 347 { | 347 { |
| 348 DEFINE_STATIC_LOCAL(const AtomicString, sum, ("sum", AtomicString::Construct
FromLiteral)); | 348 DEFINE_STATIC_LOCAL(const AtomicString, sum, ("sum", AtomicString::Construct
FromLiteral)); |
| 349 const AtomicString& value = fastGetAttribute(SVGNames::accumulateAttr); | 349 const AtomicString& value = fastGetAttribute(SVGNames::accumulateAttr); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 { | 479 { |
| 480 ASSERT(!m_keyPoints.isEmpty()); | 480 ASSERT(!m_keyPoints.isEmpty()); |
| 481 ASSERT(m_keyPoints.size() == m_keyTimes.size()); | 481 ASSERT(m_keyPoints.size() == m_keyTimes.size()); |
| 482 ASSERT(calcMode() != CalcModePaced); | 482 ASSERT(calcMode() != CalcModePaced); |
| 483 effectivePercent = calculatePercentFromKeyPoints(percent); | 483 effectivePercent = calculatePercentFromKeyPoints(percent); |
| 484 unsigned index = effectivePercent == 1 ? m_values.size() - 2 : static_cast<u
nsigned>(effectivePercent * (m_values.size() - 1)); | 484 unsigned index = effectivePercent == 1 ? m_values.size() - 2 : static_cast<u
nsigned>(effectivePercent * (m_values.size() - 1)); |
| 485 from = m_values[index]; | 485 from = m_values[index]; |
| 486 to = m_values[index + 1]; | 486 to = m_values[index + 1]; |
| 487 } | 487 } |
| 488 | 488 |
| 489 AnimatedPropertyType SVGAnimationElement::determineAnimatedPropertyType() const | |
| 490 { | |
| 491 if (!targetElement()) | |
| 492 return AnimatedString; | |
| 493 | |
| 494 RefPtr<SVGAnimatedPropertyBase> property = targetElement()->propertyFromAttr
ibute(attributeName()); | |
| 495 if (property) { | |
| 496 AnimatedPropertyType propertyType = property->type(); | |
| 497 | |
| 498 // Only <animatedTransform> is allowed to animate AnimatedTransformList. | |
| 499 // http://www.w3.org/TR/SVG/animate.html#AnimationAttributesAndPropertie
s | |
| 500 if (propertyType == AnimatedTransformList && !isSVGAnimateTransformEleme
nt(*this)) | |
| 501 return AnimatedUnknown; | |
| 502 | |
| 503 return propertyType; | |
| 504 } | |
| 505 | |
| 506 return SVGElement::animatedPropertyTypeForCSSAttribute(attributeName()); | |
| 507 } | |
| 508 | |
| 509 void SVGAnimationElement::currentValuesForValuesAnimation(float percent, float&
effectivePercent, String& from, String& to) | 489 void SVGAnimationElement::currentValuesForValuesAnimation(float percent, float&
effectivePercent, String& from, String& to) |
| 510 { | 490 { |
| 511 unsigned valuesCount = m_values.size(); | 491 unsigned valuesCount = m_values.size(); |
| 512 ASSERT(m_animationValid); | 492 ASSERT(m_animationValid); |
| 513 ASSERT(valuesCount >= 1); | 493 ASSERT(valuesCount >= 1); |
| 514 | 494 |
| 515 if (percent == 1 || valuesCount == 1) { | 495 if (percent == 1 || valuesCount == 1) { |
| 516 from = m_values[valuesCount - 1]; | 496 from = m_values[valuesCount - 1]; |
| 517 to = m_values[valuesCount - 1]; | 497 to = m_values[valuesCount - 1]; |
| 518 effectivePercent = 1; | 498 effectivePercent = 1; |
| 519 return; | 499 return; |
| 520 } | 500 } |
| 521 | 501 |
| 522 CalcMode calcMode = this->calcMode(); | 502 CalcMode calcMode = this->calcMode(); |
| 523 if (hasTagName(SVGNames::animateTag)) { | 503 if (isSVGAnimateElement(*this)) { |
| 524 AnimatedPropertyType attributeType = determineAnimatedPropertyType(); | 504 SVGAnimateElement& animateElement = toSVGAnimateElement(*this); |
| 525 // Fall back to discrete animations for Strings. | 505 if (!animateElement.animatedPropertyTypeSupportsAddition()) { |
| 526 if (attributeType == AnimatedBoolean | 506 ASSERT(animateElement.animatedPropertyType() != AnimatedTransformLis
t || isSVGAnimateTransformElement(*this)); |
| 527 || attributeType == AnimatedEnumeration | 507 ASSERT(animateElement.animatedPropertyType() != AnimatedUnknown); |
| 528 || attributeType == AnimatedPreserveAspectRatio | |
| 529 || attributeType == AnimatedString) | |
| 530 calcMode = CalcModeDiscrete; | 508 calcMode = CalcModeDiscrete; |
| 509 } |
| 531 } | 510 } |
| 532 if (!m_keyPoints.isEmpty() && calcMode != CalcModePaced) | 511 if (!m_keyPoints.isEmpty() && calcMode != CalcModePaced) |
| 533 return currentValuesFromKeyPoints(percent, effectivePercent, from, to); | 512 return currentValuesFromKeyPoints(percent, effectivePercent, from, to); |
| 534 | 513 |
| 535 unsigned keyTimesCount = m_keyTimes.size(); | 514 unsigned keyTimesCount = m_keyTimes.size(); |
| 536 ASSERT(!keyTimesCount || valuesCount == keyTimesCount); | 515 ASSERT(!keyTimesCount || valuesCount == keyTimesCount); |
| 537 ASSERT(!keyTimesCount || (keyTimesCount > 1 && !m_keyTimes[0])); | 516 ASSERT(!keyTimesCount || (keyTimesCount > 1 && !m_keyTimes[0])); |
| 538 | 517 |
| 539 unsigned index = calculateKeyTimesIndex(percent); | 518 unsigned index = calculateKeyTimesIndex(percent); |
| 540 if (calcMode == CalcModeDiscrete) { | 519 if (calcMode == CalcModeDiscrete) { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 SVGSMILElement::setAttributeName(attributeName); | 688 SVGSMILElement::setAttributeName(attributeName); |
| 710 checkInvalidCSSAttributeType(targetElement()); | 689 checkInvalidCSSAttributeType(targetElement()); |
| 711 } | 690 } |
| 712 | 691 |
| 713 void SVGAnimationElement::checkInvalidCSSAttributeType(SVGElement* target) | 692 void SVGAnimationElement::checkInvalidCSSAttributeType(SVGElement* target) |
| 714 { | 693 { |
| 715 m_hasInvalidCSSAttributeType = target && hasValidAttributeName() && attribut
eType() == AttributeTypeCSS && !isTargetAttributeCSSProperty(target, attributeNa
me()); | 694 m_hasInvalidCSSAttributeType = target && hasValidAttributeName() && attribut
eType() == AttributeTypeCSS && !isTargetAttributeCSSProperty(target, attributeNa
me()); |
| 716 } | 695 } |
| 717 | 696 |
| 718 } | 697 } |
| OLD | NEW |