| 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 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 #include "core/svg/SVGAnimationElement.h" | 27 #include "core/svg/SVGAnimationElement.h" |
| 28 | 28 |
| 29 #include "CSSPropertyNames.h" | 29 #include "CSSPropertyNames.h" |
| 30 #include "SVGNames.h" | 30 #include "SVGNames.h" |
| 31 #include "core/css/CSSComputedStyleDeclaration.h" | 31 #include "core/css/CSSComputedStyleDeclaration.h" |
| 32 #include "core/css/CSSParser.h" | 32 #include "core/css/CSSParser.h" |
| 33 #include "core/page/UseCounter.h" | 33 #include "core/page/UseCounter.h" |
| 34 #include "core/platform/FloatConversion.h" | 34 #include "core/platform/FloatConversion.h" |
| 35 #include "core/svg/SVGAnimateElement.h" | 35 #include "core/svg/SVGAnimateElement.h" |
| 36 #include "core/svg/SVGElement.h" |
| 36 #include "core/svg/SVGParserUtilities.h" | 37 #include "core/svg/SVGParserUtilities.h" |
| 37 #include "core/svg/SVGStyledElement.h" | |
| 38 #include "wtf/MathExtras.h" | 38 #include "wtf/MathExtras.h" |
| 39 | 39 |
| 40 namespace WebCore { | 40 namespace WebCore { |
| 41 | 41 |
| 42 // Animated property definitions | 42 // Animated property definitions |
| 43 DEFINE_ANIMATED_BOOLEAN(SVGAnimationElement, SVGNames::externalResourcesRequired
Attr, ExternalResourcesRequired, externalResourcesRequired) | 43 DEFINE_ANIMATED_BOOLEAN(SVGAnimationElement, SVGNames::externalResourcesRequired
Attr, ExternalResourcesRequired, externalResourcesRequired) |
| 44 | 44 |
| 45 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGAnimationElement) | 45 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGAnimationElement) |
| 46 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) | 46 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) |
| 47 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTests) | 47 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTests) |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 bool SVGAnimationElement::isAccumulated() const | 355 bool SVGAnimationElement::isAccumulated() const |
| 356 { | 356 { |
| 357 DEFINE_STATIC_LOCAL(const AtomicString, sum, ("sum", AtomicString::Construct
FromLiteral)); | 357 DEFINE_STATIC_LOCAL(const AtomicString, sum, ("sum", AtomicString::Construct
FromLiteral)); |
| 358 const AtomicString& value = fastGetAttribute(SVGNames::accumulateAttr); | 358 const AtomicString& value = fastGetAttribute(SVGNames::accumulateAttr); |
| 359 return value == sum && animationMode() != ToAnimation; | 359 return value == sum && animationMode() != ToAnimation; |
| 360 } | 360 } |
| 361 | 361 |
| 362 bool SVGAnimationElement::isTargetAttributeCSSProperty(SVGElement* targetElement
, const QualifiedName& attributeName) | 362 bool SVGAnimationElement::isTargetAttributeCSSProperty(SVGElement* targetElement
, const QualifiedName& attributeName) |
| 363 { | 363 { |
| 364 ASSERT(targetElement); | 364 ASSERT(targetElement); |
| 365 if (!targetElement->isSVGStyledElement()) | |
| 366 return false; | |
| 367 | 365 |
| 368 return SVGStyledElement::isAnimatableCSSProperty(attributeName); | 366 return SVGElement::isAnimatableCSSProperty(attributeName); |
| 369 } | 367 } |
| 370 | 368 |
| 371 SVGAnimationElement::ShouldApplyAnimation SVGAnimationElement::shouldApplyAnimat
ion(SVGElement* targetElement, const QualifiedName& attributeName) | 369 SVGAnimationElement::ShouldApplyAnimation SVGAnimationElement::shouldApplyAnimat
ion(SVGElement* targetElement, const QualifiedName& attributeName) |
| 372 { | 370 { |
| 373 if (!hasValidAttributeType() || !targetElement || attributeName == anyQName(
)) | 371 if (!hasValidAttributeType() || !targetElement || attributeName == anyQName(
)) |
| 374 return DontApplyAnimation; | 372 return DontApplyAnimation; |
| 375 | 373 |
| 376 // Always animate CSS properties, using the ApplyCSSAnimation code path, reg
ardless of the attributeType value. | 374 // Always animate CSS properties, using the ApplyCSSAnimation code path, reg
ardless of the attributeType value. |
| 377 if (isTargetAttributeCSSProperty(targetElement, attributeName)) | 375 if (isTargetAttributeCSSProperty(targetElement, attributeName)) |
| 378 return ApplyCSSAnimation; | 376 return ApplyCSSAnimation; |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 effectivePercent = calculatePercentForFromTo(percent); | 634 effectivePercent = calculatePercentForFromTo(percent); |
| 637 else | 635 else |
| 638 effectivePercent = percent; | 636 effectivePercent = percent; |
| 639 | 637 |
| 640 calculateAnimatedValue(effectivePercent, repeatCount, resultElement); | 638 calculateAnimatedValue(effectivePercent, repeatCount, resultElement); |
| 641 } | 639 } |
| 642 | 640 |
| 643 void SVGAnimationElement::computeCSSPropertyValue(SVGElement* element, CSSProper
tyID id, String& value) | 641 void SVGAnimationElement::computeCSSPropertyValue(SVGElement* element, CSSProper
tyID id, String& value) |
| 644 { | 642 { |
| 645 ASSERT(element); | 643 ASSERT(element); |
| 646 ASSERT(element->isSVGStyledElement()); | |
| 647 | 644 |
| 648 // Don't include any properties resulting from CSS Transitions/Animations or
SMIL animations, as we want to retrieve the "base value". | 645 // Don't include any properties resulting from CSS Transitions/Animations or
SMIL animations, as we want to retrieve the "base value". |
| 649 element->setUseOverrideComputedStyle(true); | 646 element->setUseOverrideComputedStyle(true); |
| 650 value = CSSComputedStyleDeclaration::create(element)->getPropertyValue(id); | 647 value = CSSComputedStyleDeclaration::create(element)->getPropertyValue(id); |
| 651 element->setUseOverrideComputedStyle(false); | 648 element->setUseOverrideComputedStyle(false); |
| 652 } | 649 } |
| 653 | 650 |
| 654 void SVGAnimationElement::adjustForInheritance(SVGElement* targetElement, const
QualifiedName& attributeName, String& value) | 651 void SVGAnimationElement::adjustForInheritance(SVGElement* targetElement, const
QualifiedName& attributeName, String& value) |
| 655 { | 652 { |
| 656 // FIXME: At the moment the computed style gets returned as a String and nee
ds to get parsed again. | 653 // FIXME: At the moment the computed style gets returned as a String and nee
ds to get parsed again. |
| 657 // In the future we might want to work with the value type directly to avoid
the String parsing. | 654 // In the future we might want to work with the value type directly to avoid
the String parsing. |
| 658 ASSERT(targetElement); | 655 ASSERT(targetElement); |
| 659 | 656 |
| 660 Element* parent = targetElement->parentElement(); | 657 Element* parent = targetElement->parentElement(); |
| 661 if (!parent || !parent->isSVGElement()) | 658 if (!parent || !parent->isSVGElement()) |
| 662 return; | 659 return; |
| 663 | 660 |
| 664 SVGElement* svgParent = toSVGElement(parent); | 661 SVGElement* svgParent = toSVGElement(parent); |
| 665 if (!svgParent->isSVGStyledElement()) | |
| 666 return; | |
| 667 computeCSSPropertyValue(svgParent, cssPropertyID(attributeName.localName()),
value); | 662 computeCSSPropertyValue(svgParent, cssPropertyID(attributeName.localName()),
value); |
| 668 } | 663 } |
| 669 | 664 |
| 670 static bool inheritsFromProperty(SVGElement* targetElement, const QualifiedName&
attributeName, const String& value) | 665 static bool inheritsFromProperty(SVGElement* targetElement, const QualifiedName&
attributeName, const String& value) |
| 671 { | 666 { |
| 672 ASSERT(targetElement); | 667 ASSERT(targetElement); |
| 673 DEFINE_STATIC_LOCAL(const AtomicString, inherit, ("inherit", AtomicString::C
onstructFromLiteral)); | 668 DEFINE_STATIC_LOCAL(const AtomicString, inherit, ("inherit", AtomicString::C
onstructFromLiteral)); |
| 674 | 669 |
| 675 if (value.isEmpty() || value != inherit || !targetElement->isSVGStyledElemen
t()) | 670 if (value.isEmpty() || value != inherit) |
| 676 return false; | 671 return false; |
| 677 return SVGStyledElement::isAnimatableCSSProperty(attributeName); | 672 return SVGElement::isAnimatableCSSProperty(attributeName); |
| 678 } | 673 } |
| 679 | 674 |
| 680 void SVGAnimationElement::determinePropertyValueTypes(const String& from, const
String& to) | 675 void SVGAnimationElement::determinePropertyValueTypes(const String& from, const
String& to) |
| 681 { | 676 { |
| 682 SVGElement* targetElement = this->targetElement(); | 677 SVGElement* targetElement = this->targetElement(); |
| 683 ASSERT(targetElement); | 678 ASSERT(targetElement); |
| 684 | 679 |
| 685 const QualifiedName& attributeName = this->attributeName(); | 680 const QualifiedName& attributeName = this->attributeName(); |
| 686 if (inheritsFromProperty(targetElement, attributeName, from)) | 681 if (inheritsFromProperty(targetElement, attributeName, from)) |
| 687 m_fromPropertyValueType = InheritValue; | 682 m_fromPropertyValueType = InheritValue; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 700 SVGSMILElement::setAttributeName(attributeName); | 695 SVGSMILElement::setAttributeName(attributeName); |
| 701 checkInvalidCSSAttributeType(targetElement()); | 696 checkInvalidCSSAttributeType(targetElement()); |
| 702 } | 697 } |
| 703 | 698 |
| 704 void SVGAnimationElement::checkInvalidCSSAttributeType(SVGElement* target) | 699 void SVGAnimationElement::checkInvalidCSSAttributeType(SVGElement* target) |
| 705 { | 700 { |
| 706 m_hasInvalidCSSAttributeType = target && hasValidAttributeName() && attribut
eType() == AttributeTypeCSS && !isTargetAttributeCSSProperty(target, attributeNa
me()); | 701 m_hasInvalidCSSAttributeType = target && hasValidAttributeName() && attribut
eType() == AttributeTypeCSS && !isTargetAttributeCSSProperty(target, attributeNa
me()); |
| 707 } | 702 } |
| 708 | 703 |
| 709 } | 704 } |
| OLD | NEW |