Changeset 89187 in webkit


Ignore:
Timestamp:
Jun 17, 2011 10:30:53 PM (13 years ago)
Author:
krit@webkit.org
Message:

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

Reviewed by Rob Buis.

SVGAnimation should use direct unit animation for SVGAngle
https://bugs.webkit.org/show_bug.cgi?id=62807

Tests animation of SVGAngle with different units.

  • svg/animations/script-tests/svgangle-animation-deg-to-grad.js: Added. (sample1): (sample2): (sample3): (executeTest):
  • svg/animations/script-tests/svgangle-animation-deg-to-rad.js: Added. (sample1): (sample2): (sample3): (executeTest):
  • svg/animations/script-tests/svgangle-animation-grad-to-deg.js: Added. (sample1): (sample2): (sample3): (executeTest):
  • svg/animations/script-tests/svgangle-animation-grad-to-rad.js: Added. (sample1): (sample2): (sample3): (executeTest):
  • svg/animations/script-tests/svgangle-animation-rad-to-deg.js: Added. (sample1): (sample2): (sample3): (executeTest):
  • svg/animations/script-tests/svgangle-animation-rad-to-grad.js: Added. (sample1): (sample2): (sample3): (executeTest):
  • svg/animations/svgangle-animation-deg-to-grad-expected.txt: Added.
  • svg/animations/svgangle-animation-deg-to-grad.html: Added.
  • svg/animations/svgangle-animation-deg-to-rad-expected.txt: Added.
  • svg/animations/svgangle-animation-deg-to-rad.html: Added.
  • svg/animations/svgangle-animation-grad-to-deg-expected.txt: Added.
  • svg/animations/svgangle-animation-grad-to-deg.html: Added.
  • svg/animations/svgangle-animation-grad-to-rad-expected.txt: Added.
  • svg/animations/svgangle-animation-grad-to-rad.html: Added.
  • svg/animations/svgangle-animation-rad-to-deg-expected.txt: Added.
  • svg/animations/svgangle-animation-rad-to-deg.html: Added.
  • svg/animations/svgangle-animation-rad-to-grad-expected.txt: Added.
  • svg/animations/svgangle-animation-rad-to-grad.html: Added.

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

Reviewed by Rob Buis.

SVGAnimation should use direct unit animation for SVGAngle
https://bugs.webkit.org/show_bug.cgi?id=62807

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 SVGAngle. We can animate the SVG primitive datatype SVGAngle
with different unit types now.
Removed number and unit parser from SVGAnimateElement. This is not needed anymore.

Tests: svg/animations/svgangle-animation-deg-to-grad.html

svg/animations/svgangle-animation-deg-to-rad.html
svg/animations/svgangle-animation-grad-to-deg.html
svg/animations/svgangle-animation-grad-to-rad.html
svg/animations/svgangle-animation-rad-to-deg.html
svg/animations/svgangle-animation-rad-to-grad.html

  • CMakeLists.txt: Added SVGAnimatedAngle.cpp.
  • GNUmakefile.list.am: Ditto.
  • WebCore.gypi: Ditto.
  • WebCore.pro: Ditto.
  • WebCore.xcodeproj/project.pbxproj: Ditto.
  • svg/SVGAllInOne.cpp: Ditto.
  • svg/SVGAnimateElement.cpp: Make use of SVGAnimator for AnimatedAngle. (WebCore::SVGAnimateElement::SVGAnimateElement): (WebCore::SVGAnimateElement::determineAnimatedAttributeType): Ditto. (WebCore::SVGAnimateElement::calculateAnimatedValue): Ditto. (WebCore::SVGAnimateElement::calculateFromAndToValues): Ditto. (WebCore::SVGAnimateElement::calculateFromAndByValues): Ditto. (WebCore::SVGAnimateElement::resetToBaseValue): Ditto. (WebCore::SVGAnimateElement::applyResultsToTarget): Ditto. (WebCore::SVGAnimateElement::calculateDistance): Ditto.
  • svg/SVGAnimateElement.h:
  • svg/SVGAnimatedAngle.cpp: Added. Added SVGAnimatedAngleAnimator for animation of SVGAngles. (WebCore::SVGAnimatedAngleAnimator::SVGAnimatedAngleAnimator): (WebCore::sharedSVGAngle): (WebCore::SVGAnimatedAngleAnimator::constructFromString): (WebCore::SVGAnimatedAngleAnimator::calculateFromAndToValues): (WebCore::SVGAnimatedAngleAnimator::calculateFromAndByValues): (WebCore::SVGAnimatedAngleAnimator::calculateAnimatedValue): (WebCore::SVGAnimatedAngleAnimator::calculateDistance):
  • svg/SVGAnimatedAngle.h: (WebCore::SVGAnimatedAngleAnimator::~SVGAnimatedAngleAnimator):
  • svg/SVGAnimatedLength.cpp: (WebCore::sharedSVGLength): Use an ExceptionCode for SVGLength::setValueAsString.
  • svg/SVGAnimatedType.h: (WebCore::SVGAnimatedType::create): (WebCore::SVGAnimatedType::createAngle): (WebCore::SVGAnimatedType::createLength): (WebCore::SVGAnimatedType::~SVGAnimatedType): (WebCore::SVGAnimatedType::angle): (WebCore::SVGAnimatedType::valueAsString): (WebCore::SVGAnimatedType::setValueAsString): (WebCore::SVGAnimatedType::SVGAnimatedType):
  • svg/SVGAnimatorFactory.h: (WebCore::SVGAnimatorFactory::create):
  • svg/SVGLength.cpp: (WebCore::SVGLength::setValueAsString): Added an ExceptionCode for consistency reasons and as preparation for future error handling.
  • svg/SVGLength.h:
  • svg/SVGParserUtilities.cpp: (WebCore::parseNumberFromString): Added number parser for String objects.
  • svg/SVGParserUtilities.h:
Location:
trunk
Files:
19 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r89183 r89187  
     12011-06-17  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Rob Buis.
     4
     5        SVGAnimation should use direct unit animation for SVGAngle
     6        https://bugs.webkit.org/show_bug.cgi?id=62807
     7
     8        Tests animation of SVGAngle with different units.
     9
     10        * svg/animations/script-tests/svgangle-animation-deg-to-grad.js: Added.
     11        (sample1):
     12        (sample2):
     13        (sample3):
     14        (executeTest):
     15        * svg/animations/script-tests/svgangle-animation-deg-to-rad.js: Added.
     16        (sample1):
     17        (sample2):
     18        (sample3):
     19        (executeTest):
     20        * svg/animations/script-tests/svgangle-animation-grad-to-deg.js: Added.
     21        (sample1):
     22        (sample2):
     23        (sample3):
     24        (executeTest):
     25        * svg/animations/script-tests/svgangle-animation-grad-to-rad.js: Added.
     26        (sample1):
     27        (sample2):
     28        (sample3):
     29        (executeTest):
     30        * svg/animations/script-tests/svgangle-animation-rad-to-deg.js: Added.
     31        (sample1):
     32        (sample2):
     33        (sample3):
     34        (executeTest):
     35        * svg/animations/script-tests/svgangle-animation-rad-to-grad.js: Added.
     36        (sample1):
     37        (sample2):
     38        (sample3):
     39        (executeTest):
     40        * svg/animations/svgangle-animation-deg-to-grad-expected.txt: Added.
     41        * svg/animations/svgangle-animation-deg-to-grad.html: Added.
     42        * svg/animations/svgangle-animation-deg-to-rad-expected.txt: Added.
     43        * svg/animations/svgangle-animation-deg-to-rad.html: Added.
     44        * svg/animations/svgangle-animation-grad-to-deg-expected.txt: Added.
     45        * svg/animations/svgangle-animation-grad-to-deg.html: Added.
     46        * svg/animations/svgangle-animation-grad-to-rad-expected.txt: Added.
     47        * svg/animations/svgangle-animation-grad-to-rad.html: Added.
     48        * svg/animations/svgangle-animation-rad-to-deg-expected.txt: Added.
     49        * svg/animations/svgangle-animation-rad-to-deg.html: Added.
     50        * svg/animations/svgangle-animation-rad-to-grad-expected.txt: Added.
     51        * svg/animations/svgangle-animation-rad-to-grad.html: Added.
     52
    1532011-06-17  Julien Chaffraix  <jchaffraix@webkit.org>
    254
  • trunk/Source/WebCore/CMakeLists.txt

    r89186 r89187  
    16531653        svg/SVGAngle.cpp
    16541654        svg/SVGAnimateColorElement.cpp
     1655        svg/SVGAnimatedAngle.cpp
    16551656        svg/SVGAnimatedLength.cpp
    16561657        svg/SVGAnimateElement.cpp
  • trunk/Source/WebCore/ChangeLog

    r89186 r89187  
     12011-06-17  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Rob Buis.
     4
     5        SVGAnimation should use direct unit animation for SVGAngle
     6        https://bugs.webkit.org/show_bug.cgi?id=62807
     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 SVGAngle. We can animate the SVG primitive datatype SVGAngle
     10        with different unit types now.
     11        Removed number and unit parser from SVGAnimateElement. This is not needed anymore.
     12
     13        Tests: svg/animations/svgangle-animation-deg-to-grad.html
     14               svg/animations/svgangle-animation-deg-to-rad.html
     15               svg/animations/svgangle-animation-grad-to-deg.html
     16               svg/animations/svgangle-animation-grad-to-rad.html
     17               svg/animations/svgangle-animation-rad-to-deg.html
     18               svg/animations/svgangle-animation-rad-to-grad.html
     19
     20        * CMakeLists.txt: Added SVGAnimatedAngle.cpp.
     21        * GNUmakefile.list.am: Ditto.
     22        * WebCore.gypi: Ditto.
     23        * WebCore.pro: Ditto.
     24        * WebCore.xcodeproj/project.pbxproj: Ditto.
     25        * svg/SVGAllInOne.cpp: Ditto.
     26        * svg/SVGAnimateElement.cpp: Make use of SVGAnimator for AnimatedAngle.
     27        (WebCore::SVGAnimateElement::SVGAnimateElement):
     28        (WebCore::SVGAnimateElement::determineAnimatedAttributeType): Ditto.
     29        (WebCore::SVGAnimateElement::calculateAnimatedValue): Ditto.
     30        (WebCore::SVGAnimateElement::calculateFromAndToValues): Ditto.
     31        (WebCore::SVGAnimateElement::calculateFromAndByValues): Ditto.
     32        (WebCore::SVGAnimateElement::resetToBaseValue): Ditto.
     33        (WebCore::SVGAnimateElement::applyResultsToTarget): Ditto.
     34        (WebCore::SVGAnimateElement::calculateDistance): Ditto.
     35        * svg/SVGAnimateElement.h:
     36        * svg/SVGAnimatedAngle.cpp: Added. Added SVGAnimatedAngleAnimator for animation of SVGAngles.
     37        (WebCore::SVGAnimatedAngleAnimator::SVGAnimatedAngleAnimator):
     38        (WebCore::sharedSVGAngle):
     39        (WebCore::SVGAnimatedAngleAnimator::constructFromString):
     40        (WebCore::SVGAnimatedAngleAnimator::calculateFromAndToValues):
     41        (WebCore::SVGAnimatedAngleAnimator::calculateFromAndByValues):
     42        (WebCore::SVGAnimatedAngleAnimator::calculateAnimatedValue):
     43        (WebCore::SVGAnimatedAngleAnimator::calculateDistance):
     44        * svg/SVGAnimatedAngle.h:
     45        (WebCore::SVGAnimatedAngleAnimator::~SVGAnimatedAngleAnimator):
     46        * svg/SVGAnimatedLength.cpp:
     47        (WebCore::sharedSVGLength): Use an ExceptionCode for SVGLength::setValueAsString.
     48        * svg/SVGAnimatedType.h:
     49        (WebCore::SVGAnimatedType::create):
     50        (WebCore::SVGAnimatedType::createAngle):
     51        (WebCore::SVGAnimatedType::createLength):
     52        (WebCore::SVGAnimatedType::~SVGAnimatedType):
     53        (WebCore::SVGAnimatedType::angle):
     54        (WebCore::SVGAnimatedType::valueAsString):
     55        (WebCore::SVGAnimatedType::setValueAsString):
     56        (WebCore::SVGAnimatedType::SVGAnimatedType):
     57        * svg/SVGAnimatorFactory.h:
     58        (WebCore::SVGAnimatorFactory::create):
     59        * svg/SVGLength.cpp:
     60        (WebCore::SVGLength::setValueAsString): Added an ExceptionCode for consistency reasons and as preparation for future error handling.
     61        * svg/SVGLength.h:
     62        * svg/SVGParserUtilities.cpp:
     63        (WebCore::parseNumberFromString): Added number parser for String objects.
     64        * svg/SVGParserUtilities.h:
     65
    1662011-06-17  Anna Cavender  <annacc@chromium.org>
    267
  • trunk/Source/WebCore/GNUmakefile.list.am

    r89146 r89187  
    33363336        Source/WebCore/svg/SVGAnimateColorElement.cpp \
    33373337        Source/WebCore/svg/SVGAnimateColorElement.h \
     3338        Source/WebCore/svg/SVGAnimatedAngle.cpp \
    33383339        Source/WebCore/svg/SVGAnimatedAngle.h \
    33393340        Source/WebCore/svg/SVGAnimatedBoolean.h \
  • trunk/Source/WebCore/WebCore.gypi

    r89186 r89187  
    57055705            'svg/SVGAnimateColorElement.cpp',
    57065706            'svg/SVGAnimateColorElement.h',
     5707            'svg/SVGAnimatedAngle.cpp',
    57075708            'svg/SVGAnimatedLength.cpp',
    57085709            'svg/SVGAnimateElement.cpp',
  • trunk/Source/WebCore/WebCore.pro

    r89186 r89187  
    32933293              svg/SVGAngle.cpp \
    32943294              svg/SVGAnimateColorElement.cpp \
     3295              svg/SVGAnimatedAngle.cpp \
    32953296              svg/SVGAnimatedLength.cpp \
    32963297              svg/SVGAnimateElement.cpp \
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r89186 r89187  
    937937                4358E8851360A33B00E4748C /* SVGFEDropShadowElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4358E8821360A33B00E4748C /* SVGFEDropShadowElement.cpp */; };
    938938                4358E8861360A33B00E4748C /* SVGFEDropShadowElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4358E8831360A33B00E4748C /* SVGFEDropShadowElement.h */; };
     939                4362C7B913AC6F1A00344BEB /* SVGAnimatedAngle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4362C7B813AC6F1A00344BEB /* SVGAnimatedAngle.cpp */; };
    939940                436708C112D9CA4B00044234 /* RenderSVGBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = 4367088212D9CA4A00044234 /* RenderSVGBlock.h */; };
    940941                436708C312D9CA4B00044234 /* RenderSVGContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4367088412D9CA4A00044234 /* RenderSVGContainer.h */; };
     
    73697370                4358E8831360A33B00E4748C /* SVGFEDropShadowElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGFEDropShadowElement.h; sourceTree = "<group>"; };
    73707371                4358E8841360A33B00E4748C /* SVGFEDropShadowElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SVGFEDropShadowElement.idl; sourceTree = "<group>"; };
     7372                4362C7B813AC6F1A00344BEB /* SVGAnimatedAngle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedAngle.cpp; sourceTree = "<group>"; };
    73717373                4367088112D9CA4A00044234 /* RenderSVGBlock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGBlock.cpp; sourceTree = "<group>"; };
    73727374                4367088212D9CA4A00044234 /* RenderSVGBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGBlock.h; sourceTree = "<group>"; };
     
    1733717339                                B22277E40D00BF1F0071B782 /* SVGAnimateColorElement.h */,
    1733817340                                B22277E50D00BF1F0071B782 /* SVGAnimateColorElement.idl */,
     17341                                4362C7B813AC6F1A00344BEB /* SVGAnimatedAngle.cpp */,
    1733917342                                087B84951272CEC700A14417 /* SVGAnimatedAngle.h */,
    1734017343                                B22277E60D00BF1F0071B782 /* SVGAnimatedAngle.idl */,
     
    2573025733                                B1AD4E7313A12A4600846B27 /* CueLoader.cpp in Sources */,
    2573125734                                B1AD4E7B13A12A7200846B27 /* CueParser.cpp in Sources */,
     25735                                4362C7B913AC6F1A00344BEB /* SVGAnimatedAngle.cpp in Sources */,
    2573225736                        );
    2573325737                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/WebCore/svg/SVGAllInOne.cpp

    r88663 r89187  
    3131#include "SVGAngle.cpp"
    3232#include "SVGAnimateColorElement.cpp"
     33#include "SVGAnimatedAngle.cpp"
    3334#include "SVGAnimatedLength.cpp"
    3435#include "SVGAnimateElement.cpp"
  • trunk/Source/WebCore/svg/SVGAnimateElement.cpp

    r88663 r89187  
    5151    , m_fromNumber(0)
    5252    , m_toNumber(0)
    53     , m_animatedNumber(numeric_limits<double>::infinity())
     53    , m_animatedNumber(numeric_limits<float>::infinity())
    5454    , m_animatedPathPointer(0)
    5555{
     
    6464SVGAnimateElement::~SVGAnimateElement()
    6565{
    66 }
    67 
    68 static bool parseNumberValueAndUnit(const String& in, double& value, String& unit)
    69 {
    70     // FIXME: These are from top of my head, figure out all property types that can be animated as numbers.
    71     unsigned unitLength = 0;
    72     String parse = in.stripWhiteSpace();
    73     if (parse.endsWith("%"))
    74         unitLength = 1;
    75     else if (parse.endsWith("deg") || parse.endsWith("rad"))
    76         unitLength = 3;
    77     else if (parse.endsWith("grad"))
    78         unitLength = 4;
    79     String newUnit = parse.right(unitLength);
    80     String number = parse.left(parse.length() - unitLength);
    81     if ((!unit.isEmpty() && newUnit != unit) || number.isEmpty())
    82         return false;
    83     UChar last = number[number.length() - 1];
    84     if (last < '0' || last > '9')
    85         return false;
    86     unit = newUnit;
    87     bool ok;
    88     value = number.toDouble(&ok);
    89     return ok;
    9066}
    9167
     
    141117    // support continuous animations.
    142118    switch (type) {
     119    case AnimatedAngle:
     120        return AnimatedAngle;
    143121    case AnimatedBoolean:
    144122    case AnimatedEnumeration:
     
    152130    case AnimatedLength:
    153131        return AnimatedLength;
    154     case AnimatedAngle:
    155132    case AnimatedInteger:
    156133    case AnimatedNumber:
     
    202179            String fromNumberString;
    203180            adjustForInheritance(targetElement, attributeName(), fromNumberString);
    204             if (!parseNumberValueAndUnit(fromNumberString, m_fromNumber, m_numberUnit))
     181            if (!parseNumberFromString(fromNumberString, m_fromNumber, false))
    205182                return;
    206183        }
     
    208185            String toNumberString;
    209186            adjustForInheritance(targetElement, attributeName(), toNumberString);
    210             if (!parseNumberValueAndUnit(toNumberString, m_toNumber, m_numberUnit))
     187            if (!parseNumberFromString(toNumberString, m_toNumber, false))
    211188                return;
    212189        }
    213190
    214         double number;
     191        float number;
    215192        if (calcMode() == CalcModeDiscrete)
    216193            number = isInFirstHalfOfAnimation ? m_fromNumber : m_toNumber;
     
    310287        return;
    311288    }
     289    case AnimatedAngle:
    312290    case AnimatedLength: {
    313291        ASSERT(m_animator);
     
    381359    }
    382360    case AnimatedNumber: {
    383         m_numberUnit = String();
    384         if (parseNumberValueAndUnit(toString, m_toNumber, m_numberUnit)) {
     361        if (parseNumberFromString(toString, m_toNumber, false)) {
    385362            // For to-animations the from number is calculated later
    386             if (animationMode() == ToAnimation || parseNumberValueAndUnit(fromString, m_fromNumber, m_numberUnit))
     363            if (animationMode() == ToAnimation || parseNumberFromString(fromString, m_fromNumber, false))
    387364                return true;
    388365        }
     
    409386        break;
    410387    }
    411     case AnimatedLength: {
     388    case AnimatedAngle:
     389    case AnimatedLength:
    412390        ensureAnimator()->calculateFromAndToValues(m_fromType, m_toType, fromString, toString);
    413391        return true;
    414     }
    415392    default:
    416393        break;
     
    450427        return true;
    451428    }
    452     case AnimatedLength: {
     429    case AnimatedAngle:
     430    case AnimatedLength:
    453431        ensureAnimator()->calculateFromAndByValues(m_fromType, m_toType, fromString, byString);
    454432        return true;
    455 
    456     }
    457433    default:
    458         m_numberUnit = String();
    459434        m_fromNumber = 0;
    460         if (!fromString.isEmpty() && !parseNumberValueAndUnit(fromString, m_fromNumber, m_numberUnit))
     435        if (!fromString.isEmpty() && !parseNumberFromString(fromString, m_fromNumber, false))
    461436            return false;
    462         if (!parseNumberValueAndUnit(byString, m_toNumber, m_numberUnit))
     437        if (!parseNumberFromString(byString, m_toNumber, false))
    463438            return false;
    464439        m_toNumber += m_fromNumber;
     
    485460        if (baseString.isEmpty()) {
    486461            m_animatedNumber = 0;
    487             m_numberUnit = String();
    488462            return;
    489463        }
    490         if (parseNumberValueAndUnit(baseString, m_animatedNumber, m_numberUnit))
     464        if (parseNumberFromString(baseString, m_animatedNumber, false))
    491465            return;
    492466        break;
     
    501475        m_animatedPoints.clear();
    502476        return;
     477    case AnimatedAngle:
    503478    case AnimatedLength: {
    504         m_animatedType = ensureAnimator()->constructFromString(baseString);
     479        if (!m_animatedType)
     480            m_animatedType = ensureAnimator()->constructFromString(baseString);
     481        else
     482            m_animatedType->setValueAsString(attributeName(), baseString);
    505483        return;
    506484    }
     
    514492{
    515493    String valueToApply;
    516     if (m_animatedAttributeType == AnimatedColor)
     494    switch (m_animatedAttributeType) {
     495    case AnimatedColor:
    517496        valueToApply = m_animatedColor.serialized();
    518     else if (m_animatedAttributeType == AnimatedNumber)
    519         valueToApply = String::number(m_animatedNumber) + m_numberUnit;
    520     else if (m_animatedAttributeType == AnimatedPath) {
     497        break;
     498    case AnimatedNumber:
     499        valueToApply = String::number(m_animatedNumber);
     500        break;
     501    case AnimatedPath: {
    521502        if (!m_animatedPathPointer || m_animatedPathPointer->isEmpty())
    522503            valueToApply = m_animatedString;
     
    529510            factory->buildStringFromByteStream(m_animatedPathPointer, valueToApply, UnalteredParsing);
    530511        }
    531     } else if (m_animatedAttributeType == AnimatedPoints)
     512        break;
     513    }
     514    case AnimatedPoints:
    532515        valueToApply = m_animatedPoints.isEmpty() ? m_animatedString : m_animatedPoints.valueAsString();
    533     else if (m_animatedAttributeType == AnimatedLength)
    534         valueToApply = m_animatedType->length().valueAsString();
    535     else
     516        break;
     517    case AnimatedAngle:
     518    case AnimatedLength:
     519        valueToApply = m_animatedType->valueAsString();
     520        break;
     521    default:
    536522        valueToApply = m_animatedString;
    537    
     523    }
    538524    setTargetAttributeAnimatedValue(valueToApply);
    539525}
     
    546532    m_animatedAttributeType = determineAnimatedAttributeType(targetElement);
    547533    if (m_animatedAttributeType == AnimatedNumber) {
    548         double from;
    549         double to;
    550         String unit;
    551         if (!parseNumberValueAndUnit(fromString, from, unit))
     534        float from;
     535        float to;
     536        if (!parseNumberFromString(fromString, from, false))
    552537            return -1;
    553         if (!parseNumberValueAndUnit(toString, to, unit))
     538        if (!parseNumberFromString(toString, to, false))
    554539            return -1;
    555         return narrowPrecisionToFloat(fabs(to - from));
     540        return fabs(to - from);
    556541    }
    557542    if (m_animatedAttributeType == AnimatedColor) {
     
    564549        return ColorDistance(from, to).distance();
    565550    }
    566     if (m_animatedAttributeType == AnimatedLength)
     551    if (m_animatedAttributeType == AnimatedAngle || m_animatedAttributeType == AnimatedLength)
    567552        return ensureAnimator()->calculateDistance(this, fromString, toString);
    568553    return -1;
  • trunk/Source/WebCore/svg/SVGAnimateElement.h

    r88663 r89187  
    7373    AnimatedPropertyValueType m_fromPropertyValueType;
    7474    AnimatedPropertyValueType m_toPropertyValueType;
    75     double m_fromNumber;
    76     double m_toNumber;
    77     double m_animatedNumber;
    78     String m_numberUnit;
     75    float m_fromNumber;
     76    float m_toNumber;
     77    float m_animatedNumber;
    7978    Color m_fromColor;
    8079    Color m_toColor;
  • trunk/Source/WebCore/svg/SVGAnimatedAngle.h

    r73254 r89187  
    2323#if ENABLE(SVG)
    2424#include "SVGAngle.h"
     25#include "SVGAnimateElement.h"
    2526#include "SVGAnimatedPropertyTearOff.h"
    2627
     
    3637DEFINE_ANIMATED_PROPERTY(OwnerType, DOMAttribute, SVGDOMAttributeIdentifier, SVGAnimatedAngle, SVGAngle, UpperProperty, LowerProperty)
    3738
     39#if ENABLE(SVG_ANIMATION)
     40class SVGAnimatedAngleAnimator : public SVGAnimatedTypeAnimator {
     41   
     42public:
     43    SVGAnimatedAngleAnimator(SVGElement* contextElement, const QualifiedName&);
     44    virtual ~SVGAnimatedAngleAnimator() { }
     45   
     46    virtual PassOwnPtr<SVGAnimatedType> constructFromString(const String&);
     47   
     48    virtual void calculateFromAndToValues(OwnPtr<SVGAnimatedType>& fromValue, OwnPtr<SVGAnimatedType>& toValue, const String& fromString, const String& toString);
     49    virtual void calculateFromAndByValues(OwnPtr<SVGAnimatedType>& fromValue, OwnPtr<SVGAnimatedType>& toValue, const String& fromString, const String& byString);
     50    virtual void calculateAnimatedValue(SVGSMILElement*, float percentage, unsigned repeatCount,
     51                                        OwnPtr<SVGAnimatedType>& fromValue, OwnPtr<SVGAnimatedType>& toValue, OwnPtr<SVGAnimatedType>& animatedValue,
     52                                        bool fromPropertyInherits, bool toPropertyInherits);
     53    virtual float calculateDistance(SVGSMILElement*, const String& fromString, const String& toString);
     54};
    3855} // namespace WebCore
    3956
     57#endif // ENABLE(SVG_ANIMATION)
    4058#endif // ENABLE(SVG)
    4159#endif
  • trunk/Source/WebCore/svg/SVGAnimatedLength.cpp

    r88663 r89187  
    3434{
    3535    DEFINE_STATIC_LOCAL(SVGLength, sharedLength, ());
    36     sharedLength.setValueAsString(valueAsString, mode);
     36    ExceptionCode ec = 0;
     37    sharedLength.setValueAsString(valueAsString, mode, ec);
     38    ASSERT(!ec);
    3739    return sharedLength;
    3840}
  • trunk/Source/WebCore/svg/SVGAnimatedType.h

    r88663 r89187  
    2222
    2323#if ENABLE(SVG) && ENABLE(SVG_ANIMATION)
    24 #include "SVGAnimateElement.h"
     24#include "SVGAngle.h"
    2525#include "SVGElement.h"
    2626#include "SVGLength.h"
     
    3131    WTF_MAKE_FAST_ALLOCATED;
    3232public:
     33    static PassOwnPtr<SVGAnimatedType> create(AnimatedAttributeType type)
     34    {
     35        return adoptPtr(new SVGAnimatedType(type));
     36    }
     37
     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
    3346    static PassOwnPtr<SVGAnimatedType> createLength(SVGLength* length)
    3447    {
    35         return adoptPtr(new SVGAnimatedType(AnimatedLength, length));
     48        ASSERT(length);
     49        OwnPtr<SVGAnimatedType> animatedType = create(AnimatedLength);
     50        animatedType->m_data.length = length;
     51        return animatedType.release();
    3652    }
    3753
    3854    virtual ~SVGAnimatedType()
    3955    {
    40         ASSERT(m_type == AnimatedLength);
    41         delete m_data.length;
     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        }
    4267    }
    4368   
    4469    AnimatedAttributeType type() const { return m_type; }
    45    
     70
     71    SVGAngle& angle()
     72    {
     73        ASSERT(m_type == AnimatedAngle);
     74        return *m_data.angle;
     75    }
     76
    4677    SVGLength& length()
    4778    {
     
    5081    }
    5182   
     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    }
     117   
    52118private:
    53     SVGAnimatedType(AnimatedAttributeType type, SVGLength* length)
     119    SVGAnimatedType(AnimatedAttributeType type)
    54120        : m_type(type)
    55121    {
    56         m_data.length = length;
    57122    }
    58123   
     
    66131       
    67132        // FIXME: More SVG primitive types need to be added step by step.
     133        SVGAngle* angle;
    68134        SVGLength* length;
    69135    } m_data;
  • trunk/Source/WebCore/svg/SVGAnimatorFactory.h

    r88663 r89187  
    2222
    2323#if ENABLE(SVG) && ENABLE(SVG_ANIMATION)
     24#include "SVGAnimatedAngle.h"
    2425#include "SVGAnimatedLength.h"
    2526
     
    3233        // FIXME: Add animation support for all SVG units.
    3334        switch (attributeType) {
     35        case AnimatedAngle:
     36            return adoptPtr(new SVGAnimatedAngleAnimator(contextElement, attributeName));
    3437        case AnimatedLength:
    3538            return adoptPtr(new SVGAnimatedLengthAnimator(contextElement, attributeName));
  • trunk/Source/WebCore/svg/SVGLength.cpp

    r88663 r89187  
    133133}
    134134   
    135 void SVGLength::setValueAsString(const String& valueAsString, SVGLengthMode mode)
     135void SVGLength::setValueAsString(const String& valueAsString, SVGLengthMode mode, ExceptionCode& ec)
    136136{
    137137    m_valueInSpecifiedUnits = 0;
    138138    m_unit = storeUnit(mode, LengthTypeNumber);
    139     ExceptionCode ec = 0;
    140139    setValueAsString(valueAsString, ec);
    141     ASSERT(!ec);
    142140}
    143141
  • trunk/Source/WebCore/svg/SVGLength.h

    r88663 r89187  
    8989    String valueAsString() const;
    9090    void setValueAsString(const String&, ExceptionCode&);
    91     void setValueAsString(const String&, SVGLengthMode);
     91    void setValueAsString(const String&, SVGLengthMode, ExceptionCode&);
    9292   
    9393    void newValueSpecifiedUnits(unsigned short, float valueInSpecifiedUnits, ExceptionCode&);
  • trunk/Source/WebCore/svg/SVGParserUtilities.cpp

    r74493 r89187  
    148148}
    149149
     150bool parseNumberFromString(const String& string, float& number, bool skip)
     151{
     152    const UChar* ptr = string.characters();
     153    const UChar* end = ptr + string.length();
     154    return genericParseNumber(ptr, end, number, skip);
     155}
     156
    150157// only used to parse largeArcFlag and sweepFlag which must be a "0" or "1"
    151158// and might not have any whitespace/comma after it
  • trunk/Source/WebCore/svg/SVGParserUtilities.h

    r74493 r89187  
    3434
    3535bool parseNumber(const UChar*& ptr, const UChar* end, float& number, bool skip = true);
     36bool parseNumberFromString(const String&, float& number, bool skip = true);
    3637bool parseNumberOptionalNumber(const String& s, float& h, float& v);
    3738bool parseArcFlag(const UChar*& ptr, const UChar* end, bool& flag);
Note: See TracChangeset for help on using the changeset viewer.