Changeset 90219 in webkit


Ignore:
Timestamp:
Jul 1, 2011, 1:51:28 AM (14 years ago)
Author:
krit@webkit.org
Message:

2011-07-01 Dirk Schulze <krit@webkit.org>

Reviewed by Nikolas Zimmermann.

SVGAnimatedLengthListAnimator does not take additive="sum" into accout
https://bugs.webkit.org/show_bug.cgi?id=63705

Added support for additive animations to SVGAnimatedLengthListAnimator. Don't clear the animatedList if not
necessary.

SVGLength unit gets animated as well now. We used to take the unit of 'from' all the time.

Tests: svg/animations/svglength-animation-unitType.html

svg/animations/svglengthlist-animation-5.html

  • svg/SVGAnimatedLength.cpp: (WebCore::SVGAnimatedLengthAnimator::calculateAnimatedValue): Code clean-up and support for unit animation.
  • svg/SVGAnimatedLengthList.cpp: Add support for additive animations. (WebCore::SVGAnimatedLengthListAnimator::calculateAnimatedValue):
  • svg/SVGLength.cpp: (WebCore::SVGLength::SVGLength): (WebCore::SVGLength::setValue): New setValue that gets the LengthType and UnitType as argument for supporting animations of units as well.
  • svg/SVGLength.h:

2011-07-01 Dirk Schulze <krit@webkit.org>

Reviewed by Nikolas Zimmermann.

SVGAnimatedLengthListAnimator does not take additive="sum" into accout
https://bugs.webkit.org/show_bug.cgi?id=63705

Tests additive animations for SVGLengthLists as well as unit animations on SVGLength.

  • svg/animations/script-tests/svglength-animation-unitType.js: Added. (sample1): (sample2): (sample3): (executeTest):
  • svg/animations/script-tests/svglengthlist-animation-5.js: Added. (sample1): (sample2): (sample3): (executeTest):
  • svg/animations/svglength-animation-unitType-expected.txt: Added.
  • svg/animations/svglength-animation-unitType.html: Added.
  • svg/animations/svglengthlist-animation-5-expected.txt: Added.
  • svg/animations/svglengthlist-animation-5.html: Added.
Location:
trunk
Files:
6 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r90218 r90219  
     12011-07-01  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Nikolas Zimmermann.
     4
     5        SVGAnimatedLengthListAnimator does not take additive="sum" into accout
     6        https://bugs.webkit.org/show_bug.cgi?id=63705
     7
     8        Tests additive animations for SVGLengthLists as well as unit animations on SVGLength.
     9
     10        * svg/animations/script-tests/svglength-animation-unitType.js: Added.
     11        (sample1):
     12        (sample2):
     13        (sample3):
     14        (executeTest):
     15        * svg/animations/script-tests/svglengthlist-animation-5.js: Added.
     16        (sample1):
     17        (sample2):
     18        (sample3):
     19        (executeTest):
     20        * svg/animations/svglength-animation-unitType-expected.txt: Added.
     21        * svg/animations/svglength-animation-unitType.html: Added.
     22        * svg/animations/svglengthlist-animation-5-expected.txt: Added.
     23        * svg/animations/svglengthlist-animation-5.html: Added.
     24
    1252011-07-01  Dirk Schulze  <krit@webkit.org>
    226
  • trunk/LayoutTests/platform/wk2/Skipped

    r90218 r90219  
    473473svg/animations/svglength-animation-px-to-pt.html
    474474svg/animations/svglength-animation-px-to-px.html
     475svg/animations/svglength-animation-unitType.html
    475476svg/animations/svglength-animation-values.html
    476477svg/animations/svglengthlist-animation-1.html
     
    478479svg/animations/svglengthlist-animation-3.html
    479480svg/animations/svglengthlist-animation-4.html
     481svg/animations/svglengthlist-animation-5.html
    480482svg/animations/svgnumber-animation-1.html
    481483svg/animations/svgnumber-animation-2.html
  • trunk/Source/WebCore/ChangeLog

    r90218 r90219  
     12011-07-01  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Nikolas Zimmermann.
     4
     5        SVGAnimatedLengthListAnimator does not take additive="sum" into accout
     6        https://bugs.webkit.org/show_bug.cgi?id=63705
     7
     8        Added support for additive animations to SVGAnimatedLengthListAnimator. Don't clear the animatedList if not
     9        necessary.
     10
     11        SVGLength unit gets animated as well now. We used to take the unit of 'from' all the time.
     12
     13        Tests: svg/animations/svglength-animation-unitType.html
     14               svg/animations/svglengthlist-animation-5.html
     15
     16        * svg/SVGAnimatedLength.cpp:
     17        (WebCore::SVGAnimatedLengthAnimator::calculateAnimatedValue): Code clean-up and support for unit animation.
     18        * svg/SVGAnimatedLengthList.cpp: Add support for additive animations.
     19        (WebCore::SVGAnimatedLengthListAnimator::calculateAnimatedValue):
     20        * svg/SVGLength.cpp:
     21        (WebCore::SVGLength::SVGLength):
     22        (WebCore::SVGLength::setValue): New setValue that gets the LengthType and UnitType as argument for supporting animations of units as well.
     23        * svg/SVGLength.h:
     24
    1252011-07-01  Dirk Schulze  <krit@webkit.org>
    226
  • trunk/Source/WebCore/svg/SVGAnimatedLength.cpp

    r89587 r90219  
    2424
    2525#include "SVGAnimateElement.h"
     26#include "SVGAnimatedNumber.h"
    2627
    2728namespace WebCore {
     
    8081    ASSERT(m_animationElement);
    8182    ASSERT(m_contextElement);
     83
    8284    SVGAnimateElement* animationElement = static_cast<SVGAnimateElement*>(m_animationElement);
    83    
    8485    AnimationMode animationMode = animationElement->animationMode();
     86
    8587    // To animation uses contributions from the lower priority animations as the base value.
    86     // FIXME: Avoid string parsing.
     88    SVGLength& animatedSVGLength = animated->length();
     89    SVGLength& fromSVGLength = from->length();
    8790    if (animationMode == ToAnimation)
    88         from = constructFromString(animated->length().valueAsString());
     91        fromSVGLength = animatedSVGLength;
    8992   
    9093    // Replace 'inherit' by their computed property values.
    91     float number;
    92     float fromLength = from->length().value(m_contextElement);
    93     float toLength = to->length().value(m_contextElement);
    94    
     94    SVGLength& toSVGLength = to->length();
    9595    if (animationElement->fromPropertyValueType() == InheritValue) {
    9696        String fromLengthString;
    9797        animationElement->adjustForInheritance(m_contextElement, animationElement->attributeName(), fromLengthString);
    98         fromLength = sharedSVGLength(m_lengthMode, fromLengthString).value(m_contextElement);
     98        fromSVGLength = sharedSVGLength(m_lengthMode, fromLengthString);
    9999    }
    100100    if (animationElement->toPropertyValueType() == InheritValue) {
    101101        String toLengthString;
    102102        animationElement->adjustForInheritance(m_contextElement, animationElement->attributeName(), toLengthString);
    103         toLength = sharedSVGLength(m_lengthMode, toLengthString).value(m_contextElement);
     103        toSVGLength = sharedSVGLength(m_lengthMode, toLengthString);
    104104    }
    105105   
    106     if (animationElement->calcMode() == CalcModeDiscrete)
    107         number = percentage < 0.5f ? fromLength : toLength;
    108     else
    109         number = (toLength - fromLength) * percentage + fromLength;
    110    
    111     // FIXME: This is not correct for values animation.
    112     if (animationElement->isAccumulated() && repeatCount)
    113         number += toLength * repeatCount;
     106    float result = animatedSVGLength.value(m_contextElement);
     107    SVGLengthType unitType = percentage < 0.5 ? fromSVGLength.unitType() : toSVGLength.unitType();
     108    SVGAnimatedNumberAnimator::calculateAnimatedNumber(animationElement, percentage, repeatCount, result, fromSVGLength.value(m_contextElement), toSVGLength.value(m_contextElement));
     109
    114110    ExceptionCode ec = 0;
    115     SVGLength& animatedSVGLength = animated->length();
    116     if (animationElement->isAdditive() && animationMode != ToAnimation) {
    117         float animatedSVGLengthValue = animatedSVGLength.value(m_contextElement);
    118         animatedSVGLengthValue += number;
    119         animatedSVGLength.setValue(animatedSVGLengthValue, m_contextElement, ec);
    120     } else
    121         animatedSVGLength.setValue(number, m_contextElement, ec);
     111    animatedSVGLength.setValue(m_contextElement, result, m_lengthMode, unitType, ec);
    122112    ASSERT(!ec);
    123113}
  • trunk/Source/WebCore/svg/SVGAnimatedLengthList.cpp

    r89783 r90219  
    112112    }
    113113   
    114     animatedLengthList.clear();
     114    bool animatedListSizeEqual = itemsCount == animatedLengthList.size();
     115    if (!animatedListSizeEqual)
     116        animatedLengthList.clear();
     117    ExceptionCode ec = 0;
    115118    for (unsigned i = 0; i < itemsCount; ++i) {
    116         float result = 0;
     119        float result = animatedListSizeEqual ? animatedLengthList[i].value(m_contextElement) : 0;
    117120        SVGLengthType unitType = percentage < 0.5 ? fromLengthList[i].unitType() : toLengthList[i].unitType();
    118121        SVGAnimatedNumberAnimator::calculateAnimatedNumber(animationElement, percentage, repeatCount, result, fromLengthList[i].value(m_contextElement), toLengthList[i].value(m_contextElement));
    119         animatedLengthList.append(SVGLength(m_contextElement, result, m_lengthMode, unitType));
     122        if (!animatedListSizeEqual)
     123            animatedLengthList.append(SVGLength(m_contextElement, result, m_lengthMode, unitType));
     124        else {
     125            animatedLengthList[i].setValue(m_contextElement, result, m_lengthMode, unitType, ec);
     126            ASSERT(!ec);
     127        }
    120128    }
    121129}
  • trunk/Source/WebCore/svg/SVGLength.cpp

    r89783 r90219  
    142142}
    143143
     144SVGLength::SVGLength(const SVGLength& other)
     145    : m_valueInSpecifiedUnits(other.m_valueInSpecifiedUnits)
     146    , m_unit(other.m_unit)
     147{
     148}
     149
    144150void SVGLength::setValueAsString(const String& valueAsString, SVGLengthMode mode, ExceptionCode& ec)
    145151{
     
    147153    m_unit = storeUnit(mode, LengthTypeNumber);
    148154    setValueAsString(valueAsString, ec);
    149 }
    150 
    151 SVGLength::SVGLength(const SVGLength& other)
    152     : m_valueInSpecifiedUnits(other.m_valueInSpecifiedUnits)
    153     , m_unit(other.m_unit)
    154 {
    155155}
    156156
     
    207207    ASSERT_NOT_REACHED();
    208208    return 0;
     209}
     210
     211void SVGLength::setValue(const SVGElement* context, float value, SVGLengthMode mode, SVGLengthType unitType, ExceptionCode& ec)
     212{
     213    m_unit = storeUnit(mode, unitType);
     214    setValue(value, context, ec);
    209215}
    210216
  • trunk/Source/WebCore/svg/SVGLength.h

    r89783 r90219  
    8282    float value(const SVGElement* context, ExceptionCode&) const;
    8383    void setValue(float, const SVGElement* context, ExceptionCode&);
     84    void setValue(const SVGElement* context, float, SVGLengthMode, SVGLengthType, ExceptionCode&);
    8485
    8586    float valueInSpecifiedUnits() const { return m_valueInSpecifiedUnits; }
Note: See TracChangeset for help on using the changeset viewer.