Changeset 89220 in webkit


Ignore:
Timestamp:
Jun 19, 2011, 1:11:24 PM (14 years ago)
Author:
krit@webkit.org
Message:

2011-06-19 Dirk Schulze <krit@webkit.org>

Reviewed by Nikolas Zimmermann.

SVGAnimatorFactory does not support SVGNumber
https://bugs.webkit.org/show_bug.cgi?id=62938

Follow up of "SVGAnimation should use direct unit animation for SVGLength": https://bugs.webkit.org/show_bug.cgi?id=61368
This patch continues the conversion to the new concept of SVGAnimatorFactory with SVGNumber. With the new animator for the
With the new animator for SVGNumber we also support the scientific notation, and everything else that's supported by
the SVGNumber parsing, removing the SVGAnimate* specific number parsing functionality.

Moving the content of SVGAnimatedType header into its own cpp.


Changed behavior of parseNumberFromString(). It checks if the String simply consits of a number now. parseNumberFromString()
is using genericParseNumber() for parsing numbers. But this method just stops at the first char that does not belong to a number and
returns true. I added a check if the current char pointer is at the last char of the String and return false if not.

Tests: svg/animations/svgnumber-animation-1.html

svg/animations/svgnumber-animation-2.html
svg/animations/svgnumber-animation-3.html

  • CMakeLists.txt: Added new files to build system.
  • GNUmakefile.list.am: Ditto.
  • WebCore.gypi: Ditto.
  • WebCore.pro: Ditto.
  • WebCore.xcodeproj/project.pbxproj: Ditto.
  • svg/SVGAllInOne.cpp: Ditto.
  • svg/SVGAnimateElement.cpp: Use SVGAnimatedNumberAnimator for animations of SVGNumbers. (WebCore::SVGAnimateElement::SVGAnimateElement): (WebCore::SVGAnimateElement::calculateAnimatedValue): (WebCore::SVGAnimateElement::calculateFromAndToValues): (WebCore::SVGAnimateElement::calculateFromAndByValues): (WebCore::SVGAnimateElement::resetToBaseValue): (WebCore::SVGAnimateElement::applyResultsToTarget): (WebCore::SVGAnimateElement::calculateDistance):
  • svg/SVGAnimateElement.h: Remove floats for value storage. This is done by SVGAnimatedTypes now.
  • svg/SVGAnimatedNumber.cpp: Added. Animator for SVGNumbers. (WebCore::SVGAnimatedNumberAnimator::SVGAnimatedNumberAnimator): (WebCore::SVGAnimatedNumberAnimator::constructFromString): (WebCore::SVGAnimatedNumberAnimator::calculateFromAndToValues): (WebCore::SVGAnimatedNumberAnimator::calculateFromAndByValues): (WebCore::SVGAnimatedNumberAnimator::calculateAnimatedValue): (WebCore::SVGAnimatedNumberAnimator::calculateDistance):
  • svg/SVGAnimatedNumber.h: (WebCore::SVGAnimatedNumberAnimator::~SVGAnimatedNumberAnimator):
  • svg/SVGAnimatedType.cpp: Added. Moved content from header to cpp. (WebCore::SVGAnimatedType::SVGAnimatedType): (WebCore::SVGAnimatedType::~SVGAnimatedType): (WebCore::SVGAnimatedType::createAngle): (WebCore::SVGAnimatedType::createLength): (WebCore::SVGAnimatedType::createNumber): (WebCore::SVGAnimatedType::angle): (WebCore::SVGAnimatedType::length): (WebCore::SVGAnimatedType::number): (WebCore::SVGAnimatedType::valueAsString): (WebCore::SVGAnimatedType::setValueAsString):
  • svg/SVGAnimatedType.h: Removed method create(). Allways call type specific create funtcions.
  • svg/SVGAnimatorFactory.h: (WebCore::SVGAnimatorFactory::create):
  • svg/SVGParserUtilities.cpp: (WebCore::parseNumberFromString): Check if String simply consits of a number. Return false otherwise.

2011-06-19 Dirk Schulze <krit@webkit.org>

Reviewed by Nikolas Zimmermann.

SVGAnimatorFactory does not support SVGNumber
https://bugs.webkit.org/show_bug.cgi?id=62938


Added new tests to check behavior on SVGNumber animation.

  • svg/animations/script-tests/svgnumber-animation-1.js: Added. (sample1): (sample2): (sample3): (executeTest):
  • svg/animations/script-tests/svgnumber-animation-2.js: Added. (sample1): (sample2): (sample3): (executeTest):
  • svg/animations/script-tests/svgnumber-animation-3.js: Added. (sample1): (sample2): (sample3): (executeTest):
  • svg/animations/svgnumber-animation-1-expected.txt: Added.
  • svg/animations/svgnumber-animation-1.html: Added.
  • svg/animations/svgnumber-animation-2-expected.txt: Added.
  • svg/animations/svgnumber-animation-2.html: Added.
  • svg/animations/svgnumber-animation-3-expected.txt: Added.
  • svg/animations/svgnumber-animation-3.html: Added.
Location:
trunk
Files:
11 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r89218 r89220  
     12011-06-19  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Nikolas Zimmermann.
     4
     5        SVGAnimatorFactory does not support SVGNumber
     6        https://bugs.webkit.org/show_bug.cgi?id=62938
     7       
     8        Added new tests to check behavior on SVGNumber animation.
     9
     10        * svg/animations/script-tests/svgnumber-animation-1.js: Added.
     11        (sample1):
     12        (sample2):
     13        (sample3):
     14        (executeTest):
     15        * svg/animations/script-tests/svgnumber-animation-2.js: Added.
     16        (sample1):
     17        (sample2):
     18        (sample3):
     19        (executeTest):
     20        * svg/animations/script-tests/svgnumber-animation-3.js: Added.
     21        (sample1):
     22        (sample2):
     23        (sample3):
     24        (executeTest):
     25        * svg/animations/svgnumber-animation-1-expected.txt: Added.
     26        * svg/animations/svgnumber-animation-1.html: Added.
     27        * svg/animations/svgnumber-animation-2-expected.txt: Added.
     28        * svg/animations/svgnumber-animation-2.html: Added.
     29        * svg/animations/svgnumber-animation-3-expected.txt: Added.
     30        * svg/animations/svgnumber-animation-3.html: Added.
     31
    1322011-06-19  Stephen White  <senorblanco@chromium.org>
    233
  • trunk/Source/WebCore/CMakeLists.txt

    r89216 r89220  
    16561656        svg/SVGAnimatedAngle.cpp
    16571657        svg/SVGAnimatedLength.cpp
     1658        svg/SVGAnimatedNumber.cpp
     1659        svg/SVGAnimatedType.cpp
    16581660        svg/SVGAnimateElement.cpp
    16591661        svg/SVGAnimateMotionElement.cpp
  • trunk/Source/WebCore/ChangeLog

    r89216 r89220  
     12011-06-19  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Nikolas Zimmermann.
     4
     5        SVGAnimatorFactory does not support SVGNumber
     6        https://bugs.webkit.org/show_bug.cgi?id=62938
     7
     8        Follow up of "SVGAnimation should use direct unit animation for SVGLength": https://bugs.webkit.org/show_bug.cgi?id=61368
     9        This patch continues the conversion to the new concept of SVGAnimatorFactory with SVGNumber. With the new animator for the
     10        With the new animator for SVGNumber we also support the scientific notation, and everything else that's supported by
     11        the SVGNumber parsing, removing the SVGAnimate* specific number parsing functionality.
     12
     13        Moving the content of SVGAnimatedType header into its own cpp.
     14       
     15        Changed behavior of parseNumberFromString(). It checks if the String simply consits of a number now. parseNumberFromString()
     16        is using genericParseNumber() for parsing numbers. But this method just stops at the first char that does not belong to a number and
     17        returns true. I added a check if the current char pointer is at the last char of the String and return false if not.
     18
     19        Tests: svg/animations/svgnumber-animation-1.html
     20               svg/animations/svgnumber-animation-2.html
     21               svg/animations/svgnumber-animation-3.html
     22
     23        * CMakeLists.txt: Added new files to build system.
     24        * GNUmakefile.list.am: Ditto.
     25        * WebCore.gypi: Ditto.
     26        * WebCore.pro: Ditto.
     27        * WebCore.xcodeproj/project.pbxproj: Ditto.
     28        * svg/SVGAllInOne.cpp: Ditto.
     29        * svg/SVGAnimateElement.cpp: Use SVGAnimatedNumberAnimator for animations of SVGNumbers.
     30        (WebCore::SVGAnimateElement::SVGAnimateElement):
     31        (WebCore::SVGAnimateElement::calculateAnimatedValue):
     32        (WebCore::SVGAnimateElement::calculateFromAndToValues):
     33        (WebCore::SVGAnimateElement::calculateFromAndByValues):
     34        (WebCore::SVGAnimateElement::resetToBaseValue):
     35        (WebCore::SVGAnimateElement::applyResultsToTarget):
     36        (WebCore::SVGAnimateElement::calculateDistance):
     37        * svg/SVGAnimateElement.h: Remove floats for value storage. This is done by SVGAnimatedTypes now.
     38        * svg/SVGAnimatedNumber.cpp: Added. Animator for SVGNumbers.
     39        (WebCore::SVGAnimatedNumberAnimator::SVGAnimatedNumberAnimator):
     40        (WebCore::SVGAnimatedNumberAnimator::constructFromString):
     41        (WebCore::SVGAnimatedNumberAnimator::calculateFromAndToValues):
     42        (WebCore::SVGAnimatedNumberAnimator::calculateFromAndByValues):
     43        (WebCore::SVGAnimatedNumberAnimator::calculateAnimatedValue):
     44        (WebCore::SVGAnimatedNumberAnimator::calculateDistance):
     45        * svg/SVGAnimatedNumber.h:
     46        (WebCore::SVGAnimatedNumberAnimator::~SVGAnimatedNumberAnimator):
     47        * svg/SVGAnimatedType.cpp: Added. Moved content from header to cpp.
     48        (WebCore::SVGAnimatedType::SVGAnimatedType):
     49        (WebCore::SVGAnimatedType::~SVGAnimatedType):
     50        (WebCore::SVGAnimatedType::createAngle):
     51        (WebCore::SVGAnimatedType::createLength):
     52        (WebCore::SVGAnimatedType::createNumber):
     53        (WebCore::SVGAnimatedType::angle):
     54        (WebCore::SVGAnimatedType::length):
     55        (WebCore::SVGAnimatedType::number):
     56        (WebCore::SVGAnimatedType::valueAsString):
     57        (WebCore::SVGAnimatedType::setValueAsString):
     58        * svg/SVGAnimatedType.h: Removed method create(). Allways call type specific create funtcions.
     59        * svg/SVGAnimatorFactory.h:
     60        (WebCore::SVGAnimatorFactory::create):
     61        * svg/SVGParserUtilities.cpp:
     62        (WebCore::parseNumberFromString): Check if String simply consits of a number. Return false otherwise.
     63
    1642011-06-18  Dimitri Glazkov  <dglazkov@chromium.org>
    265
  • trunk/Source/WebCore/GNUmakefile.list.am

    r89216 r89220  
    33463346        Source/WebCore/svg/SVGAnimatedLength.h \
    33473347        Source/WebCore/svg/SVGAnimatedLengthList.h \
     3348        Source/WebCore/svg/SVGAnimatedNumber.cpp \
    33483349        Source/WebCore/svg/SVGAnimatedNumber.h \
    33493350        Source/WebCore/svg/SVGAnimatedNumberList.h \
     
    33523353        Source/WebCore/svg/SVGAnimatedString.h \
    33533354        Source/WebCore/svg/SVGAnimatedTransformList.h \
     3355        Source/WebCore/svg/SVGAnimatedType.cpp \
    33543356        Source/WebCore/svg/SVGAnimatedType.h \
    33553357        Source/WebCore/svg/SVGAnimatedTypeAnimator.h \
  • trunk/Source/WebCore/WebCore.gypi

    r89216 r89220  
    57095709            'svg/SVGAnimatedAngle.cpp',
    57105710            'svg/SVGAnimatedLength.cpp',
     5711            'svg/SVGAnimatedNumber.cpp',
     5712            'svg/SVGAnimatedType.cpp',
    57115713            'svg/SVGAnimateElement.cpp',
    57125714            'svg/SVGAnimateElement.h',
  • trunk/Source/WebCore/WebCore.pro

    r89216 r89220  
    32963296              svg/SVGAnimatedAngle.cpp \
    32973297              svg/SVGAnimatedLength.cpp \
     3298              svg/SVGAnimatedNumber.cpp \
     3299              svg/SVGAnimatedType.cpp \
    32983300              svg/SVGAnimateElement.cpp \
    32993301              svg/SVGAnimateMotionElement.cpp \
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r89216 r89220  
    995995                439D334413A6911C00C20F4F /* SVGAnimatedTypeAnimator.h in Headers */ = {isa = PBXBuildFile; fileRef = 439D334113A6911C00C20F4F /* SVGAnimatedTypeAnimator.h */; };
    996996                439D334513A6911C00C20F4F /* SVGAnimatorFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 439D334213A6911C00C20F4F /* SVGAnimatorFactory.h */; };
     997                43A0F0B113AC7D6D00A5F0A7 /* SVGAnimatedNumber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43A0F0B013AC7D6D00A5F0A7 /* SVGAnimatedNumber.cpp */; };
     998                43A0F0B613ACCCFF00A5F0A7 /* SVGAnimatedType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43A0F0B513ACCCFF00A5F0A7 /* SVGAnimatedType.cpp */; };
    997999                43C092BC12D9E4EE00A989C3 /* RenderSVGForeignObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 43C092BA12D9E4EE00A989C3 /* RenderSVGForeignObject.h */; };
    9981000                4415292E0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4415292C0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    74607462                439D334113A6911C00C20F4F /* SVGAnimatedTypeAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedTypeAnimator.h; sourceTree = "<group>"; };
    74617463                439D334213A6911C00C20F4F /* SVGAnimatorFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatorFactory.h; sourceTree = "<group>"; };
     7464                43A0F0B013AC7D6D00A5F0A7 /* SVGAnimatedNumber.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedNumber.cpp; sourceTree = "<group>"; };
     7465                43A0F0B513ACCCFF00A5F0A7 /* SVGAnimatedType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedType.cpp; sourceTree = "<group>"; };
    74627466                43C092B912D9E4EE00A989C3 /* RenderSVGForeignObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGForeignObject.cpp; sourceTree = "<group>"; };
    74637467                43C092BA12D9E4EE00A989C3 /* RenderSVGForeignObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGForeignObject.h; sourceTree = "<group>"; };
     
    1735717361                                089021AC126EF5E90092D5EA /* SVGAnimatedLengthList.h */,
    1735817362                                B22277EB0D00BF1F0071B782 /* SVGAnimatedLengthList.idl */,
     17363                                43A0F0B013AC7D6D00A5F0A7 /* SVGAnimatedNumber.cpp */,
    1735917364                                08B35B12127B6A7C005314DD /* SVGAnimatedNumber.h */,
    1736017365                                B22277EC0D00BF1F0071B782 /* SVGAnimatedNumber.idl */,
     
    1736917374                                08250938128BD4D800E2ED8E /* SVGAnimatedTransformList.h */,
    1737017375                                B22277F80D00BF1F0071B782 /* SVGAnimatedTransformList.idl */,
     17376                                43A0F0B513ACCCFF00A5F0A7 /* SVGAnimatedType.cpp */,
    1737117377                                439D334013A6911C00C20F4F /* SVGAnimatedType.h */,
    1737217378                                439D334113A6911C00C20F4F /* SVGAnimatedTypeAnimator.h */,
     
    2574225748                                B1AD4E7B13A12A7200846B27 /* CueParser.cpp in Sources */,
    2574325749                                4362C7B913AC6F1A00344BEB /* SVGAnimatedAngle.cpp in Sources */,
     25750                                43A0F0B113AC7D6D00A5F0A7 /* SVGAnimatedNumber.cpp in Sources */,
     25751                                43A0F0B613ACCCFF00A5F0A7 /* SVGAnimatedType.cpp in Sources */,
    2574425752                        );
    2574525753                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/WebCore/svg/SVGAllInOne.cpp

    r89187 r89220  
    3333#include "SVGAnimatedAngle.cpp"
    3434#include "SVGAnimatedLength.cpp"
     35#include "SVGAnimatedNumber.cpp"
     36#include "SVGAnimatedType.cpp"
    3537#include "SVGAnimateElement.cpp"
    3638#include "SVGAnimateMotionElement.cpp"
  • trunk/Source/WebCore/svg/SVGAnimateElement.cpp

    r89187 r89220  
    3030#include "CSSPropertyNames.h"
    3131#include "ColorDistance.h"
    32 #include "FloatConversion.h"
    3332#include "QualifiedName.h"
    3433#include "RenderObject.h"
     
    4948    : SVGAnimationElement(tagName, document)
    5049    , m_animatedAttributeType(AnimatedString)
    51     , m_fromNumber(0)
    52     , m_toNumber(0)
    53     , m_animatedNumber(numeric_limits<float>::infinity())
    5450    , m_animatedPathPointer(0)
    5551{
     
    170166        return;
    171167    switch (m_animatedAttributeType) {
    172     case AnimatedNumber: {
    173         // To animation uses contributions from the lower priority animations as the base value.
    174         if (animationMode == ToAnimation)
    175             m_fromNumber = results->m_animatedNumber;
    176        
    177         // Replace 'currentColor' / 'inherit' by their computed property values.
    178         if (m_fromPropertyValueType == InheritValue) {
    179             String fromNumberString;
    180             adjustForInheritance(targetElement, attributeName(), fromNumberString);
    181             if (!parseNumberFromString(fromNumberString, m_fromNumber, false))
    182                 return;
    183         }
    184         if (m_toPropertyValueType == InheritValue) {
    185             String toNumberString;
    186             adjustForInheritance(targetElement, attributeName(), toNumberString);
    187             if (!parseNumberFromString(toNumberString, m_toNumber, false))
    188                 return;
    189         }
    190 
    191         float number;
    192         if (calcMode() == CalcModeDiscrete)
    193             number = isInFirstHalfOfAnimation ? m_fromNumber : m_toNumber;
    194         else
    195             number = (m_toNumber - m_fromNumber) * percentage + m_fromNumber;
    196 
    197         // FIXME: This is not correct for values animation.
    198         if (isAccumulated() && repeat)
    199             number += m_toNumber * repeat;
    200         if (isAdditive() && animationMode != ToAnimation)
    201             results->m_animatedNumber += number;
    202         else
    203             results->m_animatedNumber = number;
    204         return;
    205     }
    206168    case AnimatedColor: {
    207169        if (animationMode == ToAnimation)
     
    288250    }
    289251    case AnimatedAngle:
    290     case AnimatedLength: {
     252    case AnimatedLength:
     253    case AnimatedNumber: {
    291254        ASSERT(m_animator);
    292255        ASSERT(results->m_animatedType);
     
    358321        break;
    359322    }
    360     case AnimatedNumber: {
    361         if (parseNumberFromString(toString, m_toNumber, false)) {
    362             // For to-animations the from number is calculated later
    363             if (animationMode() == ToAnimation || parseNumberFromString(fromString, m_fromNumber, false))
    364                 return true;
    365         }
    366         break;
    367     }
    368323    case AnimatedPath: {
    369324        SVGPathParserFactory* factory = SVGPathParserFactory::self();
     
    388343    case AnimatedAngle:
    389344    case AnimatedLength:
     345    case AnimatedNumber:
    390346        ensureAnimator()->calculateFromAndToValues(m_fromType, m_toType, fromString, toString);
    391347        return true;
     
    429385    case AnimatedAngle:
    430386    case AnimatedLength:
     387    case AnimatedNumber:
    431388        ensureAnimator()->calculateFromAndByValues(m_fromType, m_toType, fromString, byString);
    432389        return true;
    433390    default:
    434         m_fromNumber = 0;
    435         if (!fromString.isEmpty() && !parseNumberFromString(fromString, m_fromNumber, false))
    436             return false;
    437         if (!parseNumberFromString(byString, m_toNumber, false))
    438             return false;
    439         m_toNumber += m_fromNumber;
     391        break;
    440392    }
    441393    return true;
     
    457409        }
    458410        break;
    459     case AnimatedNumber:
    460         if (baseString.isEmpty()) {
    461             m_animatedNumber = 0;
    462             return;
    463         }
    464         if (parseNumberFromString(baseString, m_animatedNumber, false))
    465             return;
    466         break;
    467411    case AnimatedPath: {
    468412        m_animatedPath.clear();
     
    476420        return;
    477421    case AnimatedAngle:
    478     case AnimatedLength: {
     422    case AnimatedLength:
     423    case AnimatedNumber: {
    479424        if (!m_animatedType)
    480425            m_animatedType = ensureAnimator()->constructFromString(baseString);
     
    495440    case AnimatedColor:
    496441        valueToApply = m_animatedColor.serialized();
    497         break;
    498     case AnimatedNumber:
    499         valueToApply = String::number(m_animatedNumber);
    500442        break;
    501443    case AnimatedPath: {
     
    517459    case AnimatedAngle:
    518460    case AnimatedLength:
     461    case AnimatedNumber:
    519462        valueToApply = m_animatedType->valueAsString();
    520463        break;
     
    527470float SVGAnimateElement::calculateDistance(const String& fromString, const String& toString)
    528471{
     472    // FIXME: A return value of float is not enough to support paced animations on lists.
    529473    SVGElement* targetElement = this->targetElement();
    530474    if (!targetElement)
    531475        return -1;
    532476    m_animatedAttributeType = determineAnimatedAttributeType(targetElement);
    533     if (m_animatedAttributeType == AnimatedNumber) {
    534         float from;
    535         float to;
    536         if (!parseNumberFromString(fromString, from, false))
    537             return -1;
    538         if (!parseNumberFromString(toString, to, false))
    539             return -1;
    540         return fabs(to - from);
    541     }
    542     if (m_animatedAttributeType == AnimatedColor) {
     477    switch (m_animatedAttributeType) {
     478    case AnimatedColor: {
    543479        Color from = SVGColor::colorFromRGBColorString(fromString);
    544480        if (!from.isValid())
     
    549485        return ColorDistance(from, to).distance();
    550486    }
    551     if (m_animatedAttributeType == AnimatedAngle || m_animatedAttributeType == AnimatedLength)
     487    case AnimatedAngle:
     488    case AnimatedLength:
     489    case AnimatedNumber:
    552490        return ensureAnimator()->calculateDistance(this, fromString, toString);
     491    default:
     492        break;
     493    }
    553494    return -1;
    554495}
  • trunk/Source/WebCore/svg/SVGAnimateElement.h

    r89187 r89220  
    7373    AnimatedPropertyValueType m_fromPropertyValueType;
    7474    AnimatedPropertyValueType m_toPropertyValueType;
    75     float m_fromNumber;
    76     float m_toNumber;
    77     float m_animatedNumber;
    7875    Color m_fromColor;
    7976    Color m_toColor;
  • trunk/Source/WebCore/svg/SVGAnimatedNumber.h

    r74472 r89220  
    2222
    2323#if ENABLE(SVG)
     24#include "SVGAnimateElement.h"
    2425#include "SVGAnimatedPropertyMacros.h"
    2526#include "SVGAnimatedStaticPropertyTearOff.h"
     
    3940DEFINE_ANIMATED_PROPERTY(OwnerType, DOMAttribute, SVGDOMAttributeIdentifier, SVGAnimatedNumber, float, UpperProperty, LowerProperty)
    4041
     42#if ENABLE(SVG_ANIMATION)
     43class SVGAnimatedNumberAnimator : public SVGAnimatedTypeAnimator {
     44   
     45public:
     46    SVGAnimatedNumberAnimator(SVGElement*, const QualifiedName&);
     47    virtual ~SVGAnimatedNumberAnimator() { }
     48   
     49    virtual PassOwnPtr<SVGAnimatedType> constructFromString(const String&);
     50   
     51    virtual void calculateFromAndToValues(OwnPtr<SVGAnimatedType>& fromValue, OwnPtr<SVGAnimatedType>& toValue, const String& fromString, const String& toString);
     52    virtual void calculateFromAndByValues(OwnPtr<SVGAnimatedType>& fromValue, OwnPtr<SVGAnimatedType>& toValue, const String& fromString, const String& byString);
     53    virtual void calculateAnimatedValue(SVGSMILElement*, float percentage, unsigned repeatCount,
     54                                        OwnPtr<SVGAnimatedType>& fromValue, OwnPtr<SVGAnimatedType>& toValue, OwnPtr<SVGAnimatedType>& animatedValue,
     55                                        bool fromPropertyInherits, bool toPropertyInherits);
     56    virtual float calculateDistance(SVGSMILElement*, const String& fromString, const String& toString);
     57};
    4158} // namespace WebCore
    4259
     60#endif // ENABLE(SVG_ANIMATION)
    4361#endif // ENABLE(SVG)
    4462#endif
  • trunk/Source/WebCore/svg/SVGAnimatedType.h

    r89187 r89220  
    2222
    2323#if ENABLE(SVG) && ENABLE(SVG_ANIMATION)
    24 #include "SVGAngle.h"
    2524#include "SVGElement.h"
    26 #include "SVGLength.h"
    2725
    2826namespace WebCore {
     27
     28class SVGAngle;
     29class SVGLength;
    2930
    3031class SVGAnimatedType {
    3132    WTF_MAKE_FAST_ALLOCATED;
    3233public:
    33     static PassOwnPtr<SVGAnimatedType> create(AnimatedAttributeType type)
    34     {
    35         return adoptPtr(new SVGAnimatedType(type));
    36     }
     34    virtual ~SVGAnimatedType();
    3735
    38     static PassOwnPtr<SVGAnimatedType> createAngle(SVGAngle* angle)
    39     {
    40         ASSERT(angle);
    41         OwnPtr<SVGAnimatedType> animatedType = create(AnimatedAngle);
    42         animatedType->m_data.angle = angle;
    43         return animatedType.release();
    44     }
    45 
    46     static PassOwnPtr<SVGAnimatedType> createLength(SVGLength* length)
    47     {
    48         ASSERT(length);
    49         OwnPtr<SVGAnimatedType> animatedType = create(AnimatedLength);
    50         animatedType->m_data.length = length;
    51         return animatedType.release();
    52     }
    53 
    54     virtual ~SVGAnimatedType()
    55     {
    56         switch (m_type) {
    57         case AnimatedAngle:
    58             delete m_data.angle;
    59             break;
    60         case AnimatedLength:
    61             delete m_data.length;
    62             break;
    63         default:
    64             ASSERT_NOT_REACHED();
    65             break;
    66         }
    67     }
     36    static PassOwnPtr<SVGAnimatedType> createAngle(SVGAngle*);
     37    static PassOwnPtr<SVGAnimatedType> createLength(SVGLength*);
     38    static PassOwnPtr<SVGAnimatedType> createNumber(float*);
    6839   
    6940    AnimatedAttributeType type() const { return m_type; }
    7041
    71     SVGAngle& angle()
    72     {
    73         ASSERT(m_type == AnimatedAngle);
    74         return *m_data.angle;
    75     }
     42    SVGAngle& angle();
     43    SVGLength& length();
     44    float& number();
    7645
    77     SVGLength& length()
    78     {
    79         ASSERT(m_type == AnimatedLength);
    80         return *m_data.length;
    81     }
    82    
    83     String valueAsString()
    84     {
    85         switch (m_type) {
    86         case AnimatedAngle:
    87             ASSERT(m_data.angle);
    88             return m_data.angle->valueAsString();
    89         case AnimatedLength:
    90             ASSERT(m_data.length);
    91             return m_data.length->valueAsString();
    92         default:
    93             break;
    94         }
    95         ASSERT_NOT_REACHED();
    96         return String();
    97     }
    98    
    99     bool setValueAsString(const QualifiedName& attrName, const String& value)
    100     {
    101         ExceptionCode ec = 0;
    102         switch (m_type) {
    103         case AnimatedAngle:
    104             ASSERT(m_data.angle);
    105             m_data.angle->setValueAsString(value, ec);
    106             break;
    107         case AnimatedLength:
    108             ASSERT(m_data.length);
    109             m_data.length->setValueAsString(value, SVGLength::lengthModeForAnimatedLengthAttribute(attrName), ec);
    110             break;
    111         default:
    112             ASSERT_NOT_REACHED();
    113             break;
    114         }
    115         return !ec;
    116     }
     46    String valueAsString();
     47    bool setValueAsString(const QualifiedName&, const String&);
    11748   
    11849private:
    119     SVGAnimatedType(AnimatedAttributeType type)
    120         : m_type(type)
    121     {
    122     }
     50    SVGAnimatedType(AnimatedAttributeType);
    12351   
    12452    AnimatedAttributeType m_type;
     
    13361        SVGAngle* angle;
    13462        SVGLength* length;
     63        float* number;
    13564    } m_data;
    13665};
  • trunk/Source/WebCore/svg/SVGAnimatorFactory.h

    r89187 r89220  
    2424#include "SVGAnimatedAngle.h"
    2525#include "SVGAnimatedLength.h"
     26#include "SVGAnimatedNumber.h"
    2627
    2728namespace WebCore {
     
    3738        case AnimatedLength:
    3839            return adoptPtr(new SVGAnimatedLengthAnimator(contextElement, attributeName));
     40        case AnimatedNumber:
     41            return adoptPtr(new SVGAnimatedNumberAnimator(contextElement, attributeName));
    3942        default:
    4043            ASSERT_NOT_REACHED();
  • trunk/Source/WebCore/svg/SVGParserUtilities.cpp

    r89187 r89220  
    152152    const UChar* ptr = string.characters();
    153153    const UChar* end = ptr + string.length();
    154     return genericParseNumber(ptr, end, number, skip);
     154    return genericParseNumber(ptr, end, number, skip) && ptr == end;
    155155}
    156156
Note: See TracChangeset for help on using the changeset viewer.