| 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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 { | 481 { |
| 482 ASSERT(!m_keyPoints.isEmpty()); | 482 ASSERT(!m_keyPoints.isEmpty()); |
| 483 ASSERT(m_keyPoints.size() == m_keyTimes.size()); | 483 ASSERT(m_keyPoints.size() == m_keyTimes.size()); |
| 484 ASSERT(calcMode() != CalcModePaced); | 484 ASSERT(calcMode() != CalcModePaced); |
| 485 effectivePercent = calculatePercentFromKeyPoints(percent); | 485 effectivePercent = calculatePercentFromKeyPoints(percent); |
| 486 unsigned index = effectivePercent == 1 ? m_values.size() - 2 : static_cast<u
nsigned>(effectivePercent * (m_values.size() - 1)); | 486 unsigned index = effectivePercent == 1 ? m_values.size() - 2 : static_cast<u
nsigned>(effectivePercent * (m_values.size() - 1)); |
| 487 from = m_values[index]; | 487 from = m_values[index]; |
| 488 to = m_values[index + 1]; | 488 to = m_values[index + 1]; |
| 489 } | 489 } |
| 490 | 490 |
| 491 AnimatedPropertyType SVGAnimationElement::determineAnimatedPropertyType() const |
| 492 { |
| 493 if (!targetElement()) |
| 494 return AnimatedString; |
| 495 |
| 496 RefPtr<NewSVGAnimatedPropertyBase> property = targetElement()->propertyFromA
ttribute(attributeName()); |
| 497 if (property) { |
| 498 AnimatedPropertyType propertyType = property->type(); |
| 499 |
| 500 // Only <animatedTransform> is allowed to animate AnimatedTransformList. |
| 501 // http://www.w3.org/TR/SVG/animate.html#AnimationAttributesAndPropertie
s |
| 502 if (propertyType == AnimatedTransformList && !hasTagName(SVGNames::anima
teTransformTag)) |
| 503 return AnimatedUnknown; |
| 504 |
| 505 return propertyType; |
| 506 } |
| 507 |
| 508 return SVGElement::animatedPropertyTypeForCSSAttribute(attributeName()); |
| 509 } |
| 510 |
| 491 void SVGAnimationElement::currentValuesForValuesAnimation(float percent, float&
effectivePercent, String& from, String& to) | 511 void SVGAnimationElement::currentValuesForValuesAnimation(float percent, float&
effectivePercent, String& from, String& to) |
| 492 { | 512 { |
| 493 unsigned valuesCount = m_values.size(); | 513 unsigned valuesCount = m_values.size(); |
| 494 ASSERT(m_animationValid); | 514 ASSERT(m_animationValid); |
| 495 ASSERT(valuesCount >= 1); | 515 ASSERT(valuesCount >= 1); |
| 496 | 516 |
| 497 if (percent == 1 || valuesCount == 1) { | 517 if (percent == 1 || valuesCount == 1) { |
| 498 from = m_values[valuesCount - 1]; | 518 from = m_values[valuesCount - 1]; |
| 499 to = m_values[valuesCount - 1]; | 519 to = m_values[valuesCount - 1]; |
| 500 effectivePercent = 1; | 520 effectivePercent = 1; |
| 501 return; | 521 return; |
| 502 } | 522 } |
| 503 | 523 |
| 504 CalcMode calcMode = this->calcMode(); | 524 CalcMode calcMode = this->calcMode(); |
| 505 if (hasTagName(SVGNames::animateTag)) { | 525 if (hasTagName(SVGNames::animateTag)) { |
| 506 AnimatedPropertyType attributeType = toSVGAnimateElement(this)->determin
eAnimatedPropertyType(targetElement()); | 526 AnimatedPropertyType attributeType = determineAnimatedPropertyType(); |
| 507 // Fall back to discrete animations for Strings. | 527 // Fall back to discrete animations for Strings. |
| 508 if (attributeType == AnimatedBoolean | 528 if (attributeType == AnimatedBoolean |
| 509 || attributeType == AnimatedEnumeration | 529 || attributeType == AnimatedEnumeration |
| 510 || attributeType == AnimatedPreserveAspectRatio | 530 || attributeType == AnimatedPreserveAspectRatio |
| 511 || attributeType == AnimatedString) | 531 || attributeType == AnimatedString) |
| 512 calcMode = CalcModeDiscrete; | 532 calcMode = CalcModeDiscrete; |
| 513 } | 533 } |
| 514 if (!m_keyPoints.isEmpty() && calcMode != CalcModePaced) | 534 if (!m_keyPoints.isEmpty() && calcMode != CalcModePaced) |
| 515 return currentValuesFromKeyPoints(percent, effectivePercent, from, to); | 535 return currentValuesFromKeyPoints(percent, effectivePercent, from, to); |
| 516 | 536 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 SVGSMILElement::setAttributeName(attributeName); | 711 SVGSMILElement::setAttributeName(attributeName); |
| 692 checkInvalidCSSAttributeType(targetElement()); | 712 checkInvalidCSSAttributeType(targetElement()); |
| 693 } | 713 } |
| 694 | 714 |
| 695 void SVGAnimationElement::checkInvalidCSSAttributeType(SVGElement* target) | 715 void SVGAnimationElement::checkInvalidCSSAttributeType(SVGElement* target) |
| 696 { | 716 { |
| 697 m_hasInvalidCSSAttributeType = target && hasValidAttributeName() && attribut
eType() == AttributeTypeCSS && !isTargetAttributeCSSProperty(target, attributeNa
me()); | 717 m_hasInvalidCSSAttributeType = target && hasValidAttributeName() && attribut
eType() == AttributeTypeCSS && !isTargetAttributeCSSProperty(target, attributeNa
me()); |
| 698 } | 718 } |
| 699 | 719 |
| 700 } | 720 } |
| OLD | NEW |