Changeset 89833 in webkit


Ignore:
Timestamp:
Jun 27, 2011 10:33:59 AM (13 years ago)
Author:
krit@webkit.org
Message:

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

Reviewed by Nikolas Zimmermann.

SVGAnimatedType should support SVGPreserveAspectRatio animation
https://bugs.webkit.org/show_bug.cgi?id=63456


Test for animation of SVGPreserveAspectRatio.

  • svg/animations/script-tests/svgPreserveAspectRatio-animation-1.js: Added. (sample1): (sample2): (sample3): (executeTest):
  • svg/animations/svgPreserveAspectRatio-animation-1-expected.txt: Added.
  • svg/animations/svgPreserveAspectRatio-animation-1.html: Added.

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

Reviewed by Nikolas Zimmermann.

SVGAnimatedType should support SVGPreserveAspectRatio animation
https://bugs.webkit.org/show_bug.cgi?id=63456


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 SVGAnimatedPreserveAspectRatio.


The new animator does not affect any behavior, since it was animated with SVGAnimatedString before. The new animator is still needed
to support animVal and baseVal later.

Test: svg/animations/svgPreserveAspectRatio-animation-1.html

  • CMakeLists.txt: Added new file.
  • GNUmakefile.list.am: Ditto.
  • WebCore.gypi: Ditto.
  • WebCore.pro: Ditto.
  • WebCore.xcodeproj/project.pbxproj: Ditto.
  • svg/SVGAllInOne.cpp: Ditto.
  • svg/SVGAnimateElement.cpp: Handle AnimatedPreserveAspectRatio. (WebCore::SVGAnimateElement::determineAnimatedAttributeType): (WebCore::SVGAnimateElement::calculateAnimatedValue): (WebCore::SVGAnimateElement::calculateFromAndToValues): (WebCore::SVGAnimateElement::calculateFromAndByValues): (WebCore::SVGAnimateElement::resetToBaseValue): (WebCore::SVGAnimateElement::applyResultsToTarget): (WebCore::SVGAnimateElement::calculateDistance):
  • svg/SVGAnimatedPreserveAspectRatio.cpp: Added. New animator for SVGAnimatedPreserveAspectRatio. (WebCore::SVGAnimatedPreserveAspectRatioAnimator::SVGAnimatedPreserveAspectRatioAnimator): (WebCore::SVGAnimatedPreserveAspectRatioAnimator::constructFromString): (WebCore::SVGAnimatedPreserveAspectRatioAnimator::calculateFromAndToValues): (WebCore::SVGAnimatedPreserveAspectRatioAnimator::calculateFromAndByValues): (WebCore::SVGAnimatedPreserveAspectRatioAnimator::calculateAnimatedValue): (WebCore::SVGAnimatedPreserveAspectRatioAnimator::calculateDistance):
  • svg/SVGAnimatedPreserveAspectRatio.h: (WebCore::SVGAnimatedPreserveAspectRatioAnimator::~SVGAnimatedPreserveAspectRatioAnimator):
  • svg/SVGAnimatedType.cpp: Support for SVGPreserveAspectRatio. (WebCore::SVGAnimatedType::~SVGAnimatedType): (WebCore::SVGAnimatedType::createPreserveAspectRatio): (WebCore::SVGAnimatedType::preserveAspectRatio): (WebCore::SVGAnimatedType::valueAsString): (WebCore::SVGAnimatedType::setValueAsString): (WebCore::SVGAnimatedType::setPreserveAspectRatioBaseValue):
  • svg/SVGAnimatedType.h:
  • svg/SVGAnimatorFactory.h: (WebCore::SVGAnimatorFactory::create):
Location:
trunk
Files:
4 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r89831 r89833  
     12011-06-27  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Nikolas Zimmermann.
     4
     5        SVGAnimatedType should support SVGPreserveAspectRatio animation
     6        https://bugs.webkit.org/show_bug.cgi?id=63456
     7       
     8        Test for animation of SVGPreserveAspectRatio.
     9
     10        * svg/animations/script-tests/svgPreserveAspectRatio-animation-1.js: Added.
     11        (sample1):
     12        (sample2):
     13        (sample3):
     14        (executeTest):
     15        * svg/animations/svgPreserveAspectRatio-animation-1-expected.txt: Added.
     16        * svg/animations/svgPreserveAspectRatio-animation-1.html: Added.
     17
    1182011-06-27  Ryosuke Niwa  <rniwa@webkit.org>
    219
  • trunk/LayoutTests/platform/mac-wk2/Skipped

    r89829 r89833  
    486486svg/animations/svgpointlist-animation-1.html
    487487svg/animations/svgpointlist-animation-2.html
     488svg/animations/svgPreserveAspectRatio-animation-1.html
    488489svg/animations/svgrect-animation-1.html
    489490svg/animations/svgrect-animation-2.html
  • trunk/Source/WebCore/CMakeLists.txt

    r89783 r89833  
    16661666        svg/SVGAnimatedPath.cpp
    16671667        svg/SVGAnimatedPointList.cpp
     1668        svg/SVGAnimatedPreserveAspectRatio.cpp
    16681669        svg/SVGAnimatedRect.cpp
    16691670        svg/SVGAnimatedString.cpp
  • trunk/Source/WebCore/ChangeLog

    r89832 r89833  
     12011-06-27  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Nikolas Zimmermann.
     4
     5        SVGAnimatedType should support SVGPreserveAspectRatio animation
     6        https://bugs.webkit.org/show_bug.cgi?id=63456
     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 SVGAnimatedPreserveAspectRatio.
     10       
     11        The new animator does not affect any behavior, since it was animated with SVGAnimatedString before. The new animator is still needed
     12        to support animVal and baseVal later.
     13
     14        Test: svg/animations/svgPreserveAspectRatio-animation-1.html
     15
     16        * CMakeLists.txt: Added new file.
     17        * GNUmakefile.list.am: Ditto.
     18        * WebCore.gypi: Ditto.
     19        * WebCore.pro: Ditto.
     20        * WebCore.xcodeproj/project.pbxproj: Ditto.
     21        * svg/SVGAllInOne.cpp: Ditto.
     22        * svg/SVGAnimateElement.cpp: Handle AnimatedPreserveAspectRatio.
     23        (WebCore::SVGAnimateElement::determineAnimatedAttributeType):
     24        (WebCore::SVGAnimateElement::calculateAnimatedValue):
     25        (WebCore::SVGAnimateElement::calculateFromAndToValues):
     26        (WebCore::SVGAnimateElement::calculateFromAndByValues):
     27        (WebCore::SVGAnimateElement::resetToBaseValue):
     28        (WebCore::SVGAnimateElement::applyResultsToTarget):
     29        (WebCore::SVGAnimateElement::calculateDistance):
     30        * svg/SVGAnimatedPreserveAspectRatio.cpp: Added. New animator for SVGAnimatedPreserveAspectRatio.
     31        (WebCore::SVGAnimatedPreserveAspectRatioAnimator::SVGAnimatedPreserveAspectRatioAnimator):
     32        (WebCore::SVGAnimatedPreserveAspectRatioAnimator::constructFromString):
     33        (WebCore::SVGAnimatedPreserveAspectRatioAnimator::calculateFromAndToValues):
     34        (WebCore::SVGAnimatedPreserveAspectRatioAnimator::calculateFromAndByValues):
     35        (WebCore::SVGAnimatedPreserveAspectRatioAnimator::calculateAnimatedValue):
     36        (WebCore::SVGAnimatedPreserveAspectRatioAnimator::calculateDistance):
     37        * svg/SVGAnimatedPreserveAspectRatio.h:
     38        (WebCore::SVGAnimatedPreserveAspectRatioAnimator::~SVGAnimatedPreserveAspectRatioAnimator):
     39        * svg/SVGAnimatedType.cpp: Support for SVGPreserveAspectRatio.
     40        (WebCore::SVGAnimatedType::~SVGAnimatedType):
     41        (WebCore::SVGAnimatedType::createPreserveAspectRatio):
     42        (WebCore::SVGAnimatedType::preserveAspectRatio):
     43        (WebCore::SVGAnimatedType::valueAsString):
     44        (WebCore::SVGAnimatedType::setValueAsString):
     45        (WebCore::SVGAnimatedType::setPreserveAspectRatioBaseValue):
     46        * svg/SVGAnimatedType.h:
     47        * svg/SVGAnimatorFactory.h:
     48        (WebCore::SVGAnimatorFactory::create):
     49
    1502011-06-27  Alexis Menard  <alexis.menard@openbossa.org>
    251
  • trunk/Source/WebCore/GNUmakefile.list.am

    r89828 r89833  
    34433443        Source/WebCore/svg/SVGAnimatedPointList.cpp \
    34443444        Source/WebCore/svg/SVGAnimatedPointList.h \
     3445        Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.cpp \
    34453446        Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.h \
    34463447        Source/WebCore/svg/SVGAnimatedRect.cpp \
  • trunk/Source/WebCore/WebCore.gypi

    r89832 r89833  
    57175717            'svg/SVGAnimatedPath.cpp',
    57185718            'svg/SVGAnimatedPointList.cpp',
     5719            'svg/SVGAnimatedPreserveAspectRatio.cpp',
    57195720            'svg/SVGAnimatedRect.cpp',
    57205721            'svg/SVGAnimatedString.cpp',
  • trunk/Source/WebCore/WebCore.pro

    r89832 r89833  
    33403340              svg/SVGAnimatedPath.cpp \
    33413341              svg/SVGAnimatedPointList.cpp \
     3342              svg/SVGAnimatedPreserveAspectRatio.cpp \
    33423343              svg/SVGAnimatedRect.cpp \
    33433344              svg/SVGAnimatedString.cpp \
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r89783 r89833  
    935935                431A2F9D13B6F2B0007791E4 /* SVGAnimatedNumberOptionalNumber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 431A2F9B13B6F2B0007791E4 /* SVGAnimatedNumberOptionalNumber.cpp */; };
    936936                431A2FD713B7707A007791E4 /* SVGAnimatedLengthList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 431A2FD613B7707A007791E4 /* SVGAnimatedLengthList.cpp */; };
     937                431A302113B89DCC007791E4 /* SVGAnimatedPreserveAspectRatio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 431A302013B89DCC007791E4 /* SVGAnimatedPreserveAspectRatio.cpp */; };
    937938                4331AC7813B6870000A9E5AE /* SVGAnimatedNumberList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4331AC7713B6870000A9E5AE /* SVGAnimatedNumberList.cpp */; };
    938939                4358E86A1360A21600E4748C /* DOMSVGFEDropShadowElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4358E8671360A21600E4748C /* DOMSVGFEDropShadowElement.h */; };
     
    73987399                431A2F9B13B6F2B0007791E4 /* SVGAnimatedNumberOptionalNumber.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedNumberOptionalNumber.cpp; sourceTree = "<group>"; };
    73997400                431A2FD613B7707A007791E4 /* SVGAnimatedLengthList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedLengthList.cpp; sourceTree = "<group>"; };
     7401                431A302013B89DCC007791E4 /* SVGAnimatedPreserveAspectRatio.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedPreserveAspectRatio.cpp; sourceTree = "<group>"; };
    74007402                4331AC7713B6870000A9E5AE /* SVGAnimatedNumberList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedNumberList.cpp; sourceTree = "<group>"; };
    74017403                4358E8671360A21600E4748C /* DOMSVGFEDropShadowElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMSVGFEDropShadowElement.h; sourceTree = "<group>"; };
     
    1742417426                                43B9336713B261B1004584BF /* SVGAnimatedPointList.h */,
    1742517427                                43B9336813B261B1004584BF /* SVGAnimatedPointList.cpp */,
     17428                                431A302013B89DCC007791E4 /* SVGAnimatedPreserveAspectRatio.cpp */,
    1742617429                                08FE0BC4127E2AC1000C4FB5 /* SVGAnimatedPreserveAspectRatio.h */,
    1742717430                                B22277F40D00BF1F0071B782 /* SVGAnimatedPreserveAspectRatio.idl */,
     
    2584425847                                431A2F9D13B6F2B0007791E4 /* SVGAnimatedNumberOptionalNumber.cpp in Sources */,
    2584525848                                431A2FD713B7707A007791E4 /* SVGAnimatedLengthList.cpp in Sources */,
     25849                                431A302113B89DCC007791E4 /* SVGAnimatedPreserveAspectRatio.cpp in Sources */,
    2584625850                        );
    2584725851                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/WebCore/svg/SVGAllInOne.cpp

    r89783 r89833  
    4040#include "SVGAnimatedPath.cpp"
    4141#include "SVGAnimatedPointList.cpp"
     42#include "SVGAnimatedPreserveAspectRatio.cpp"
    4243#include "SVGAnimatedRect.cpp"
    4344#include "SVGAnimatedString.cpp"
  • trunk/Source/WebCore/svg/SVGAnimateElement.cpp

    r89783 r89833  
    105105        return AnimatedUnknown;
    106106
    107     // FIXME: We need type specific animations in the future. Many animations marked as AnimatedString today will
    108     // support continuous animations.
     107    // FIXME: Animator for AnimatedBoolean and AnimatedEnumeration missing.
    109108    switch (type) {
    110109    case AnimatedAngle:
     
    112111    case AnimatedBoolean:
    113112    case AnimatedEnumeration:
    114     case AnimatedPreserveAspectRatio:
    115113    case AnimatedString:
    116114        return AnimatedString;
     
    132130    case AnimatedPoints:
    133131        return AnimatedPoints;
     132    case AnimatedPreserveAspectRatio:
     133        return AnimatedPreserveAspectRatio;
    134134    case AnimatedRect:
    135135        return AnimatedRect;
     
    172172    case AnimatedPath:
    173173    case AnimatedPoints:
     174    case AnimatedPreserveAspectRatio:
    174175    case AnimatedRect:
    175176    case AnimatedString: {
     
    240241    case AnimatedPath:
    241242    case AnimatedPoints:
     243    case AnimatedPreserveAspectRatio:
    242244    case AnimatedRect:
    243245    case AnimatedString:
     
    268270    case AnimatedNumberOptionalNumber:
    269271    case AnimatedPoints:
     272    case AnimatedPreserveAspectRatio:
    270273    case AnimatedRect:
    271274    case AnimatedString:
     
    297300    case AnimatedPath:
    298301    case AnimatedPoints:
     302    case AnimatedPreserveAspectRatio:
    299303    case AnimatedRect:
    300304    case AnimatedString: {
     
    324328    case AnimatedPath:
    325329    case AnimatedPoints:
     330    case AnimatedPreserveAspectRatio:
    326331    case AnimatedRect:
    327332    case AnimatedString:
     
    351356    case AnimatedPath:
    352357    case AnimatedPoints:
     358    case AnimatedPreserveAspectRatio:
    353359    case AnimatedRect:
    354360    case AnimatedString:
  • trunk/Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.h

    r73254 r89833  
    2323#if ENABLE(SVG)
    2424#include "SVGAnimatedPropertyTearOff.h"
     25#include "SVGAnimatedTypeAnimator.h"
    2526#include "SVGPreserveAspectRatio.h"
    2627
     
    3637DEFINE_ANIMATED_PROPERTY(OwnerType, DOMAttribute, DOMAttribute.localName(), SVGAnimatedPreserveAspectRatio, SVGPreserveAspectRatio, UpperProperty, LowerProperty)
    3738
     39   
     40#if ENABLE(SVG_ANIMATION)
     41class SVGAnimationElement;
     42
     43class SVGAnimatedPreserveAspectRatioAnimator : public SVGAnimatedTypeAnimator {
     44   
     45public:
     46    SVGAnimatedPreserveAspectRatioAnimator(SVGAnimationElement*, SVGElement*);
     47    virtual ~SVGAnimatedPreserveAspectRatioAnimator() { }
     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(float percentage, unsigned repeatCount,
     54                                        OwnPtr<SVGAnimatedType>& fromValue, OwnPtr<SVGAnimatedType>& toValue, OwnPtr<SVGAnimatedType>& animatedValue);
     55    virtual float calculateDistance(const String& fromString, const String& toString);
     56};
     57#endif // ENABLE(SVG_ANIMATION)
     58
    3859} // namespace WebCore
    3960
  • trunk/Source/WebCore/svg/SVGAnimatedType.cpp

    r89783 r89833  
    3232#include "SVGPathParserFactory.h"
    3333#include "SVGPointList.h"
     34#include "SVGPreserveAspectRatio.h"
    3435
    3536using namespace std;
     
    7273        delete m_data.pointList;
    7374        break;
     75    case AnimatedPreserveAspectRatio:
     76        delete m_data.preserveAspectRatio;
     77        break;
    7478    case AnimatedRect:
    7579        delete m_data.rect;
     
    156160}
    157161
     162PassOwnPtr<SVGAnimatedType> SVGAnimatedType::createPreserveAspectRatio(SVGPreserveAspectRatio* preserveAspectRatio)
     163{
     164    ASSERT(preserveAspectRatio);
     165    OwnPtr<SVGAnimatedType> animatedType = adoptPtr(new SVGAnimatedType(AnimatedPreserveAspectRatio));
     166    animatedType->m_data.preserveAspectRatio = preserveAspectRatio;
     167    return animatedType.release();
     168}
     169
    158170PassOwnPtr<SVGAnimatedType> SVGAnimatedType::createRect(FloatRect* rect)
    159171{
     
    224236    ASSERT(m_type == AnimatedPoints);
    225237    return *m_data.pointList;
     238}
     239
     240SVGPreserveAspectRatio& SVGAnimatedType::preserveAspectRatio()
     241{
     242    ASSERT(m_type == AnimatedPreserveAspectRatio);
     243    return *m_data.preserveAspectRatio;
    226244}
    227245
     
    271289        ASSERT(m_data.pointList);
    272290        return m_data.pointList->valueAsString();
     291    case AnimatedPreserveAspectRatio:
     292        ASSERT(m_data.preserveAspectRatio);
     293        return m_data.preserveAspectRatio->valueAsString();
    273294    case AnimatedRect:
    274295        ASSERT(m_data.rect);
     
    330351        pointsListFromSVGData(*m_data.pointList, value);
    331352        break;
     353    case AnimatedPreserveAspectRatio:
     354        ASSERT(m_data.preserveAspectRatio);
     355        SVGPreserveAspectRatio::parsePreserveAspectRatio(this, value);
     356        break;
    332357    case AnimatedRect:
    333358        ASSERT(m_data.rect);
     
    345370}
    346371
     372void SVGAnimatedType::setPreserveAspectRatioBaseValue(const SVGPreserveAspectRatio& preserveAspectRatio)
     373{
     374    ASSERT(m_type == AnimatedPreserveAspectRatio);
     375    *m_data.preserveAspectRatio = preserveAspectRatio;
     376}
     377
     378   
    347379} // namespace WebCore
    348380
  • trunk/Source/WebCore/svg/SVGAnimatedType.h

    r89786 r89833  
    3434class SVGPathByteStream;
    3535class SVGPointList;
     36class SVGPreserveAspectRatio;
    3637
    3738class SVGAnimatedType {
     
    4950    static PassOwnPtr<SVGAnimatedType> createPath(PassOwnPtr<SVGPathByteStream>);
    5051    static PassOwnPtr<SVGAnimatedType> createPointList(SVGPointList*);
     52    static PassOwnPtr<SVGAnimatedType> createPreserveAspectRatio(SVGPreserveAspectRatio*);
    5153    static PassOwnPtr<SVGAnimatedType> createRect(FloatRect*);
    5254    static PassOwnPtr<SVGAnimatedType> createString(String*);
     
    6365    SVGPathByteStream* path();
    6466    SVGPointList& pointList();
     67    SVGPreserveAspectRatio& preserveAspectRatio();
    6568    FloatRect& rect();
    6669    String& string();
     
    6871    String valueAsString();
    6972    bool setValueAsString(const QualifiedName&, const String&);
     73   
     74    // Used for parsing a String to a SVGPreserveAspectRatio object.
     75    void setPreserveAspectRatioBaseValue(const SVGPreserveAspectRatio&);
    7076
    7177private:
     
    8086        }
    8187
    82         // FIXME: More SVG primitive types need to be added step by step.
    8388        SVGAngle* angle;
    8489        Color* color;
     
    8994        std::pair<float, float>* numberOptionalNumber;
    9095        SVGPathByteStream* path;
     96        SVGPreserveAspectRatio* preserveAspectRatio;
    9197        SVGPointList* pointList;
    9298        FloatRect* rect;
  • trunk/Source/WebCore/svg/SVGAnimatorFactory.h

    r89783 r89833  
    3131#include "SVGAnimatedPath.h"
    3232#include "SVGAnimatedPointList.h"
     33#include "SVGAnimatedPreserveAspectRatio.h"
    3334#include "SVGAnimatedRect.h"
    3435#include "SVGAnimatedString.h"
     
    6566        case AnimatedPoints:
    6667            return adoptPtr(new SVGAnimatedPointListAnimator(animationElement, contextElement));
     68        case AnimatedPreserveAspectRatio:
     69            return adoptPtr(new SVGAnimatedPreserveAspectRatioAnimator(animationElement, contextElement));
    6770        case AnimatedRect:
    6871            return adoptPtr(new SVGAnimatedRectAnimator(animationElement, contextElement));
Note: See TracChangeset for help on using the changeset viewer.