Changeset 52373 in webkit


Ignore:
Timestamp:
Dec 18, 2009 8:34:57 PM (14 years ago)
Author:
Nikolas Zimmermann
Message:

2009-12-18 Nikolas Zimmermann <nzimmermann@rim.com>

Reviewed by Eric Seidel.

SVGAngle / SVGPreserveAspectRatio should be POD types
https://bugs.webkit.org/show_bug.cgi?id=32758

Convert SVGAngle / SVGPreserveAspectRatio to be non-refcounted types, just
like it has been done for SVGMatrix / SVGLength before.

This patch prepares removing the special DOMObjectWithSVGContext hack.
No change in functionality, thus no new tests.

Location:
trunk/WebCore
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r52372 r52373  
     12009-12-18  Nikolas Zimmermann  <nzimmermann@rim.com>
     2
     3        Reviewed by Eric Seidel.
     4
     5        SVGAngle / SVGPreserveAspectRatio should be POD types
     6        https://bugs.webkit.org/show_bug.cgi?id=32758
     7
     8        Convert SVGAngle / SVGPreserveAspectRatio to be non-refcounted types, just
     9        like it has been done for SVGMatrix / SVGLength before.
     10
     11        This patch prepares removing the special DOMObjectWithSVGContext hack.
     12        No change in functionality, thus no new tests.
     13
     14        * WebCore.xcodeproj/project.pbxproj: Add SVGNames.h to the 'Copy Generated Headers' phase, and set SVGAngle/SVGPreserveAspectRatio role to 'Private', so WebKit can access it.
     15        * bindings/scripts/CodeGenerator.pm: Recognize SVGAngle / SVGPreserveAspectRatio as new POD-types (similar to SVGLength)
     16        * bindings/scripts/CodeGeneratorJS.pm: Ditto.
     17        * bindings/scripts/CodeGeneratorV8.pm: Ditto.
     18        * bindings/v8/V8Index.h: Ditto.
     19        * rendering/RenderSVGImage.cpp: All following changes, modify SVGAngle/SVGPreserveAspectRatio access, as they are non-refcounted now.
     20        (WebCore::RenderSVGImage::adjustRectsForAspectRatio):
     21        (WebCore::RenderSVGImage::paint):
     22        * rendering/RenderSVGImage.h:
     23        * svg/SVGAngle.h:
     24        * svg/SVGAngle.idl:
     25        * svg/SVGAnimatedTemplate.h:
     26        (WebCore::):
     27        * svg/SVGFEImageElement.cpp:
     28        (WebCore::SVGFEImageElement::SVGFEImageElement):
     29        (WebCore::SVGFEImageElement::parseMappedAttribute):
     30        * svg/SVGFitToViewBox.cpp:
     31        (WebCore::SVGFitToViewBox::viewBoxToViewTransform):
     32        (WebCore::SVGFitToViewBox::parseMappedAttribute):
     33        * svg/SVGFitToViewBox.h:
     34        * svg/SVGImageElement.cpp:
     35        (WebCore::SVGImageElement::SVGImageElement):
     36        (WebCore::SVGImageElement::parseMappedAttribute):
     37        * svg/SVGMarkerElement.cpp:
     38        (WebCore::SVGMarkerElement::SVGMarkerElement):
     39        (WebCore::SVGMarkerElement::parseMappedAttribute):
     40        (WebCore::SVGMarkerElement::setOrientToAuto):
     41        (WebCore::SVGMarkerElement::setOrientToAngle):
     42        (WebCore::SVGMarkerElement::canvasResource):
     43        * svg/SVGMarkerElement.h:
     44        * svg/SVGPatternElement.cpp:
     45        (WebCore::SVGPatternElement::SVGPatternElement):
     46        * svg/SVGPreserveAspectRatio.cpp:
     47        (WebCore::SVGPreserveAspectRatio::parsePreserveAspectRatio):
     48        (WebCore::SVGPreserveAspectRatio::getCTM):
     49        * svg/SVGPreserveAspectRatio.h:
     50        (WebCore::SVGPreserveAspectRatio::parsePreserveAspectRatio):
     51        * svg/SVGPreserveAspectRatio.idl:
     52        * svg/SVGSVGElement.cpp:
     53        (WebCore::SVGSVGElement::SVGSVGElement):
     54        (WebCore::SVGSVGElement::createSVGAngle):
     55        (WebCore::SVGSVGElement::inheritViewAttributes):
     56        * svg/SVGSVGElement.h:
     57        * svg/SVGSymbolElement.cpp:
     58        (WebCore::SVGSymbolElement::SVGSymbolElement):
     59        * svg/SVGViewElement.cpp:
     60        (WebCore::SVGViewElement::SVGViewElement):
     61        * svg/SVGViewSpec.cpp:
     62        (WebCore::SVGViewSpec::SVGViewSpec):
     63        (WebCore::SVGViewSpec::setPreserveAspectRatioString):
     64        (WebCore::SVGViewSpec::parseViewSpec):
     65
    1662009-12-18  Dumitru Daniliuc  <dumi@chromium.org>
    267
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r52349 r52373  
    136136                08C4C51A0EF19A4000E4840F /* WMLImageLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08C4C5160EF19A4000E4840F /* WMLImageLoader.cpp */; };
    137137                08C4C51B0EF19A4000E4840F /* WMLImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 08C4C5170EF19A4000E4840F /* WMLImageLoader.h */; };
     138                08C7A2C710DC7462002D368B /* SVGNames.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 08C7A2C310DC7431002D368B /* SVGNames.h */; };
    138139                08C925190FCC7C4A00480DEC /* FilterEffect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08C925170FCC7C4A00480DEC /* FilterEffect.cpp */; };
    139140                08C9251A0FCC7C4A00480DEC /* FilterEffect.h in Headers */ = {isa = PBXBuildFile; fileRef = 08C925180FCC7C4A00480DEC /* FilterEffect.h */; };
     
    11451146                656581B209D14EE6000E61D7 /* UserAgentStyleSheets.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581AE09D14EE6000E61D7 /* UserAgentStyleSheets.h */; };
    11461147                656581FE09D1508D000E61D7 /* SVGElementFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581E709D1508D000E61D7 /* SVGElementFactory.h */; };
    1147                 6565820009D1508D000E61D7 /* SVGNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581E909D1508D000E61D7 /* SVGNames.h */; };
    11481148                6565820209D1508D000E61D7 /* XLinkNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581EB09D1508D000E61D7 /* XLinkNames.h */; };
    11491149                656D37320ADBA5DE00A4554D /* LoaderNSURLExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 656D371A0ADBA5DE00A4554D /* LoaderNSURLExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    33243324                B22279740D00BF220071B782 /* SVGAElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B22277DE0D00BF1F0071B782 /* SVGAElement.h */; };
    33253325                B22279760D00BF220071B782 /* SVGAngle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22277E00D00BF1F0071B782 /* SVGAngle.cpp */; };
    3326                 B22279770D00BF220071B782 /* SVGAngle.h in Headers */ = {isa = PBXBuildFile; fileRef = B22277E10D00BF1F0071B782 /* SVGAngle.h */; };
     3326                B22279770D00BF220071B782 /* SVGAngle.h in Headers */ = {isa = PBXBuildFile; fileRef = B22277E10D00BF1F0071B782 /* SVGAngle.h */; settings = {ATTRIBUTES = (Private, ); }; };
    33273327                B22279790D00BF220071B782 /* SVGAnimateColorElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22277E30D00BF1F0071B782 /* SVGAnimateColorElement.cpp */; };
    33283328                B222797A0D00BF220071B782 /* SVGAnimateColorElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B22277E40D00BF1F0071B782 /* SVGAnimateColorElement.h */; };
     
    35013501                B2227A940D00BF220071B782 /* SVGPolylineElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B22278FE0D00BF210071B782 /* SVGPolylineElement.h */; };
    35023502                B2227A960D00BF220071B782 /* SVGPreserveAspectRatio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22279000D00BF210071B782 /* SVGPreserveAspectRatio.cpp */; };
    3503                 B2227A970D00BF220071B782 /* SVGPreserveAspectRatio.h in Headers */ = {isa = PBXBuildFile; fileRef = B22279010D00BF210071B782 /* SVGPreserveAspectRatio.h */; };
     3503                B2227A970D00BF220071B782 /* SVGPreserveAspectRatio.h in Headers */ = {isa = PBXBuildFile; fileRef = B22279010D00BF210071B782 /* SVGPreserveAspectRatio.h */; settings = {ATTRIBUTES = (Private, ); }; };
    35043504                B2227A990D00BF220071B782 /* SVGRadialGradientElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22279030D00BF210071B782 /* SVGRadialGradientElement.cpp */; };
    35053505                B2227A9A0D00BF220071B782 /* SVGRadialGradientElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B22279040D00BF210071B782 /* SVGRadialGradientElement.h */; };
     
    48254825                        dstSubfolderSpec = 1;
    48264826                        files = (
     4827                                08C7A2C710DC7462002D368B /* SVGNames.h in Copy Generated Headers */,
    48274828                                1CCA732210ADD44A00FD440D /* DOMHTMLInputElementPrivate.h in Copy Generated Headers */,
    48284829                                5DF7F5C20F01F92A00526B4B /* CSSPropertyNames.h in Copy Generated Headers */,
     
    53375338                08C4C5160EF19A4000E4840F /* WMLImageLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WMLImageLoader.cpp; sourceTree = "<group>"; };
    53385339                08C4C5170EF19A4000E4840F /* WMLImageLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMLImageLoader.h; sourceTree = "<group>"; };
     5340                08C7A2C310DC7431002D368B /* SVGNames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SVGNames.h; path = SVGNames.h; sourceTree = SOURCE_ROOT; };
    53395341                08C925170FCC7C4A00480DEC /* FilterEffect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FilterEffect.cpp; path = filters/FilterEffect.cpp; sourceTree = "<group>"; };
    53405342                08C925180FCC7C4A00480DEC /* FilterEffect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FilterEffect.h; path = filters/FilterEffect.h; sourceTree = "<group>"; };
     
    1010210104                        isa = PBXGroup;
    1010310105                        children = (
     10106                                08C7A2C310DC7431002D368B /* SVGNames.h */,
    1010410107                                65C97AF208EA908800ACD273 /* config.h */,
    1010510108                                EDEC98020AED7E170059137F /* WebCorePrefix.h */,
     
    1797217975                                B2A1F2B10CEF0ABF00442F6A /* SVGMissingGlyphElement.h in Headers */,
    1797317976                                B2227A4E0D00BF220071B782 /* SVGMPathElement.h in Headers */,
    17974                                 6565820009D1508D000E61D7 /* SVGNames.h in Headers */,
    1797517977                                B2227A510D00BF220071B782 /* SVGNumberList.h in Headers */,
    1797617978                                B2227A540D00BF220071B782 /* SVGPaint.h in Headers */,
  • trunk/WebCore/bindings/scripts/CodeGenerator.pm

    r49424 r52373  
    4747
    4848my %podTypeHash = ("SVGNumber" => 1, "SVGTransform" => 1);
    49 my %podTypesWithWritablePropertiesHash = ("SVGLength" => 1, "SVGMatrix" => 1, "SVGPoint" => 1, "SVGRect" => 1);
     49my %podTypesWithWritablePropertiesHash = ("SVGAngle" => 1, "SVGLength" => 1, "SVGMatrix" => 1, "SVGPoint" => 1, "SVGPreserveAspectRatio" => 1, "SVGRect" => 1);
    5050my %stringTypeHash = ("DOMString" => 1, "AtomicString" => 1);
    5151
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r52082 r52373  
    18251825    "DOMString" => "const UString&",
    18261826    "NodeFilter" => "RefPtr<NodeFilter>",
     1827    "SVGAngle" => "SVGAngle",
    18271828    "SVGLength" => "SVGLength",
    18281829    "SVGMatrix" => "TransformationMatrix",
    18291830    "SVGNumber" => "float",
    18301831    "SVGPaintType" => "SVGPaint::SVGPaintType",
     1832    "SVGPreserveAspectRatio" => "SVGPreserveAspectRatio",
    18311833    "SVGPoint" => "FloatPoint",
    18321834    "SVGRect" => "FloatRect",
  • trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r52224 r52373  
    19101910    return 1 if $type eq "XPathResult";
    19111911
    1912     return 1 if $type eq "SVGAngle";
    19131912    return 1 if $type eq "SVGElementInstance";
    19141913    return 1 if $type eq "SVGElementInstanceList";
     
    19671966    return "SVGTransform" if $type eq "SVGTransform";
    19681967    return "SVGLength" if $type eq "SVGLength";
     1968    return "SVGAngle" if $type eq "SVGAngle";
    19691969    return "double" if $type eq "SVGNumber";
     1970    return "SVGPreserveAspectRatio" if $type eq "SVGPreserveAspectRatio";
    19701971    return "SVGPaint::SVGPaintType" if $type eq "SVGPaintType";
    19711972    return "DOMTimeStamp" if $type eq "DOMTimeStamp";
     
    20252026    "SQLResultSet" => 0,
    20262027    "Storage" => 0,
    2027     "SVGAngle" => 0,
     2028    "SVGAngle" => 1,
    20282029    "SVGElement" => 0,
    20292030    "SVGLength" => 1,
     
    20332034    "SVGPathSeg" => 0,
    20342035    "SVGPoint" => 1,
     2036    "SVGPreserveAspectRatio" => 1,
    20352037    "SVGRect" => 1,
    20362038    "SVGTransform" => 1,
     
    20652067    my $type = GetTypeFromSignature($signature);
    20662068
     2069    return 1 if $type eq "SVGAngle";
    20672070    return 1 if $type eq "SVGLength";
    20682071    return 1 if $type eq "SVGMatrix";
    20692072    return 1 if $type eq "SVGPoint";
     2073    return 1 if $type eq "SVGPreserveAspectRatio";
    20702074    return 1 if $type eq "SVGRect";
    20712075    return 1 if $type eq "SVGTransform";
     
    22372241    'DOMString' => 1,
    22382242    'CompareHow' => 1,
     2243    'SVGAngle' => 1,
    22392244    'SVGRect' => 1,
    22402245    'SVGPoint' => 1,
     2246    'SVGPreserveAspectRatio' => 1,
    22412247    'SVGMatrix' => 1,
    22422248    'SVGTransform' => 1,
  • trunk/WebCore/bindings/v8/V8Index.h

    r51901 r52373  
    518518// SVG_OBJECT_TYPES are svg non-node, non-pod types.
    519519#define SVG_OBJECT_TYPES(V)                                             \
    520     V(SVGANGLE, SVGAngle)                                               \
    521520    V(SVGANIMATEDANGLE, SVGAnimatedAngle)                               \
    522521    V(SVGANIMATEDBOOLEAN, SVGAnimatedBoolean)                           \
     
    560559    V(SVGPATHSEGMOVETOREL, SVGPathSegMovetoRel)                         \
    561560    V(SVGPOINTLIST, SVGPointList)                                       \
    562     V(SVGPRESERVEASPECTRATIO, SVGPreserveAspectRatio)                   \
    563561    V(SVGRENDERINGINTENT, SVGRenderingIntent)                           \
    564562    V(SVGSTRINGLIST, SVGStringList)                                     \
     
    569567// SVG POD types should list all types whose IDL has PODType declaration.
    570568#define SVG_POD_TYPES(V)                                                \
     569    V(SVGANGLE, SVGAngle)                                               \
    571570    V(SVGLENGTH, SVGLength)                                             \
     571    V(SVGPRESERVEASPECTRATIO, SVGPreserveAspectRatio)                   \
    572572    V(SVGTRANSFORM, SVGTransform)                                       \
    573573    V(SVGMATRIX, SVGMatrix)                                             \
     
    578578// POD types can have different implementation names, see CodeGenerateV8.pm.
    579579#define SVG_POD_NATIVE_TYPES(V)                                         \
     580    V(SVGANGLE, SVGAngle)                                               \
    580581    V(SVGLENGTH, SVGLength)                                             \
     582    V(SVGPRESERVEASPECTRATIO, SVGPreserveAspectRatio)                   \
    581583    V(SVGTRANSFORM, SVGTransform)                                       \
    582584    V(SVGMATRIX, TransformationMatrix)                                  \
  • trunk/WebCore/rendering/RenderSVGImage.cpp

    r51212 r52373  
    4848}
    4949
    50 void RenderSVGImage::adjustRectsForAspectRatio(FloatRect& destRect, FloatRect& srcRect, SVGPreserveAspectRatio* aspectRatio)
     50void RenderSVGImage::adjustRectsForAspectRatio(FloatRect& destRect, FloatRect& srcRect, const SVGPreserveAspectRatio& aspectRatio)
    5151{
    5252    float origDestWidth = destRect.width();
    5353    float origDestHeight = destRect.height();
    54     if (aspectRatio->meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_MEET) {
     54    if (aspectRatio.meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_MEET) {
    5555        float widthToHeightMultiplier = srcRect.height() / srcRect.width();
    5656        if (origDestHeight > (origDestWidth * widthToHeightMultiplier)) {
    5757            destRect.setHeight(origDestWidth * widthToHeightMultiplier);
    58             switch (aspectRatio->align()) {
     58            switch (aspectRatio.align()) {
    5959                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMID:
    6060                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID:
     
    7171        if (origDestWidth > (origDestHeight / widthToHeightMultiplier)) {
    7272            destRect.setWidth(origDestHeight / widthToHeightMultiplier);
    73             switch (aspectRatio->align()) {
     73            switch (aspectRatio.align()) {
    7474                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMIN:
    7575                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID:
     
    8484            }
    8585        }
    86     } else if (aspectRatio->meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_SLICE) {
     86    } else if (aspectRatio.meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_SLICE) {
    8787        float widthToHeightMultiplier = srcRect.height() / srcRect.width();
    8888        // if the destination height is less than the height of the image we'll be drawing
     
    9090            float destToSrcMultiplier = srcRect.width() / destRect.width();
    9191            srcRect.setHeight(destRect.height() * destToSrcMultiplier);
    92             switch (aspectRatio->align()) {
     92            switch (aspectRatio.align()) {
    9393                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMID:
    9494                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID:
     
    107107            float destToSrcMultiplier = srcRect.height() / destRect.height();
    108108            srcRect.setWidth(destRect.width() * destToSrcMultiplier);
    109             switch (aspectRatio->align()) {
     109            switch (aspectRatio.align()) {
    110110                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMIN:
    111111                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID:
     
    164164
    165165        SVGImageElement* imageElt = static_cast<SVGImageElement*>(node());
    166         if (imageElt->preserveAspectRatio()->align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
     166        if (imageElt->preserveAspectRatio().align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
    167167            adjustRectsForAspectRatio(destRect, srcRect, imageElt->preserveAspectRatio());
    168168
  • trunk/WebCore/rendering/RenderSVGImage.h

    r46815 r52373  
    2525
    2626#if ENABLE(SVG)
    27 
    28 #include "TransformationMatrix.h"
    2927#include "FloatRect.h"
    3028#include "RenderImage.h"
     29#include "SVGPreserveAspectRatio.h"
    3130#include "SVGRenderSupport.h"
     31#include "TransformationMatrix.h"
    3232
    3333namespace WebCore {
    3434
    3535    class SVGImageElement;
    36     class SVGPreserveAspectRatio;
    3736
    3837    class RenderSVGImage : public RenderImage, SVGRenderBase {
     
    5958
    6059        virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
    61         void adjustRectsForAspectRatio(FloatRect& destRect, FloatRect& srcRect, SVGPreserveAspectRatio*);
     60        void adjustRectsForAspectRatio(FloatRect& destRect, FloatRect& srcRect, const SVGPreserveAspectRatio&);
    6261       
    6362        virtual void layout();
  • trunk/WebCore/svg/SVGAngle.h

    r34536 r52373  
    3030    class SVGStyledElement;
    3131
    32     class SVGAngle : public RefCounted<SVGAngle> {
     32    class SVGAngle {
    3333    public:
    34         static PassRefPtr<SVGAngle> create()
    35         {
    36             return adoptRef(new SVGAngle);
    37         }
     34        SVGAngle();
    3835        virtual ~SVGAngle();
    39        
     36
    4037        enum SVGAngleType {
    4138            SVG_ANGLETYPE_UNKNOWN           = 0,
     
    6461
    6562    private:
    66         SVGAngle();
    67 
    6863        SVGAngleType m_unitType;
    6964        float m_value;
  • trunk/WebCore/svg/SVGAngle.idl

    r50583 r52373  
    2323module svg {
    2424
    25     interface [Conditional=SVG, GenerateConstructor] SVGAngle {
     25    interface [Conditional=SVG, GenerateConstructor, PODType=SVGAngle] SVGAngle {
    2626        // Angle Unit Types
    2727        const unsigned short SVG_ANGLETYPE_UNKNOWN     = 0;
  • trunk/WebCore/svg/SVGAnimatedTemplate.h

    r51125 r52373  
    2525#include "AtomicString.h"
    2626#include "FloatRect.h"
     27#include "SVGAngle.h"
    2728#include "SVGLength.h"
     29#include "SVGPreserveAspectRatio.h"
    2830#include <wtf/HashMap.h>
    2931
     
    204206
    205207    template<>
     208    struct SVGAnimatedTypeValue<SVGAngle> : Noncopyable {
     209        typedef SVGAngle StorableType;
     210        typedef SVGAngle DecoratedType;
     211
     212        static SVGAngle null() { return SVGAngle(); }
     213        static String toString(const SVGAngle& type) { return type.valueAsString(); }
     214    };
     215
     216    template<>
    206217    struct SVGAnimatedTypeValue<SVGLength> : Noncopyable {
    207218        typedef SVGLength StorableType;
     
    213224
    214225    template<>
     226    struct SVGAnimatedTypeValue<SVGPreserveAspectRatio> : Noncopyable {
     227        typedef SVGPreserveAspectRatio StorableType;
     228        typedef SVGPreserveAspectRatio DecoratedType;
     229
     230        static SVGPreserveAspectRatio null() { return SVGPreserveAspectRatio(); }
     231        static String toString(const SVGPreserveAspectRatio& type) { return type.valueAsString(); }
     232    };
     233
     234    template<>
    215235    struct SVGAnimatedTypeValue<float> : Noncopyable {
    216236        typedef float StorableType;
     
    240260
    241261    // Common type definitions, to ease IDL generation.
    242     typedef SVGAnimatedTemplate<SVGAngle*> SVGAnimatedAngle;
     262    typedef SVGAnimatedTemplate<SVGAngle> SVGAnimatedAngle;
    243263    typedef SVGAnimatedTemplate<bool> SVGAnimatedBoolean;
    244264    typedef SVGAnimatedTemplate<int> SVGAnimatedEnumeration;
     
    248268    typedef SVGAnimatedTemplate<float> SVGAnimatedNumber;
    249269    typedef SVGAnimatedTemplate<SVGNumberList*> SVGAnimatedNumberList;
    250     typedef SVGAnimatedTemplate<SVGPreserveAspectRatio*> SVGAnimatedPreserveAspectRatio;
     270    typedef SVGAnimatedTemplate<SVGPreserveAspectRatio> SVGAnimatedPreserveAspectRatio;
    251271    typedef SVGAnimatedTemplate<FloatRect> SVGAnimatedRect;
    252272    typedef SVGAnimatedTemplate<String> SVGAnimatedString;
  • trunk/WebCore/svg/SVGFEImageElement.cpp

    r50583 r52373  
    4141    , SVGLangSpace()
    4242    , SVGExternalResourcesRequired()
    43     , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())
     43    , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr)
    4444    , m_href(this, XLinkNames::hrefAttr)
    4545    , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false)
     
    5656{
    5757    const String& value = attr->value();
    58     if (attr->name() == SVGNames::preserveAspectRatioAttr) {
    59         const UChar* c = value.characters();
    60         const UChar* end = c + value.length();
    61         preserveAspectRatioBaseValue()->parsePreserveAspectRatio(c, end);
    62     } else {
     58    if (attr->name() == SVGNames::preserveAspectRatioAttr)
     59        SVGPreserveAspectRatio::parsePreserveAspectRatio(this, value);
     60    else {
    6361        if (SVGURIReference::parseMappedAttribute(attr)) {
    6462            if (!href().startsWith("#")) {
  • trunk/WebCore/svg/SVGFitToViewBox.cpp

    r49602 r52373  
    7878}
    7979
    80 TransformationMatrix SVGFitToViewBox::viewBoxToViewTransform(const FloatRect& viewBoxRect, SVGPreserveAspectRatio* preserveAspectRatio, float viewWidth, float viewHeight)
     80TransformationMatrix SVGFitToViewBox::viewBoxToViewTransform(const FloatRect& viewBoxRect, const SVGPreserveAspectRatio& preserveAspectRatio, float viewWidth, float viewHeight)
    8181{
    82     ASSERT(preserveAspectRatio);
    8382    if (!viewBoxRect.width() || !viewBoxRect.height())
    8483        return TransformationMatrix();
    8584
    86     return preserveAspectRatio->getCTM(viewBoxRect.x(), viewBoxRect.y(), viewBoxRect.width(), viewBoxRect.height(), 0, 0, viewWidth, viewHeight);
     85    return preserveAspectRatio.getCTM(viewBoxRect.x(), viewBoxRect.y(), viewBoxRect.width(), viewBoxRect.height(), 0, 0, viewWidth, viewHeight);
    8786}
    8887
     
    9796        return true;
    9897    } else if (attr->name() == SVGNames::preserveAspectRatioAttr) {
    99         const UChar* c = attr->value().characters();
    100         const UChar* end = c + attr->value().length();
    101         preserveAspectRatioBaseValue()->parsePreserveAspectRatio(c, end);
     98        SVGPreserveAspectRatio::parsePreserveAspectRatio(this, attr->value());
    10299        return true;
    103100    }
  • trunk/WebCore/svg/SVGFitToViewBox.h

    r49602 r52373  
    3838
    3939        bool parseViewBox(Document*, const UChar*& start, const UChar* end, float& x, float& y, float& w, float& h, bool validate = true);
    40         static TransformationMatrix viewBoxToViewTransform(const FloatRect& viewBoxRect, SVGPreserveAspectRatio*, float viewWidth, float viewHeight);
     40        static TransformationMatrix viewBoxToViewTransform(const FloatRect& viewBoxRect, const SVGPreserveAspectRatio&, float viewWidth, float viewHeight);
    4141
    4242        bool parseMappedAttribute(Document*, MappedAttribute*);
    4343        bool isKnownAttribute(const QualifiedName&);
    4444
    45     protected:
    46         virtual SVGAnimatedTypeValue<FloatRect>::DecoratedType viewBoxBaseValue() const = 0;
    47         virtual void setViewBoxBaseValue(SVGAnimatedTypeValue<FloatRect>::DecoratedType type) = 0;
    48 
    49         virtual SVGAnimatedTypeValue<SVGPreserveAspectRatio>::DecoratedType preserveAspectRatioBaseValue() const = 0;
     45        virtual void setViewBoxBaseValue(SVGAnimatedTypeValue<FloatRect>::DecoratedType) = 0;
     46        virtual void setPreserveAspectRatioBaseValue(SVGAnimatedTypeValue<SVGPreserveAspectRatio>::DecoratedType) = 0;
    5047    };
    5148
  • trunk/WebCore/svg/SVGImageElement.cpp

    r49306 r52373  
    4646    , m_width(this, SVGNames::widthAttr, LengthModeWidth)
    4747    , m_height(this, SVGNames::heightAttr, LengthModeHeight)
    48     , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())
     48    , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr)
    4949    , m_href(this, XLinkNames::hrefAttr)
    5050    , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false)
     
    6363    else if (attr->name() == SVGNames::yAttr)
    6464        setYBaseValue(SVGLength(LengthModeHeight, attr->value()));
    65     else if (attr->name() == SVGNames::preserveAspectRatioAttr) {
    66         const UChar* c = attr->value().characters();
    67         const UChar* end = c + attr->value().length();
    68         preserveAspectRatioBaseValue()->parsePreserveAspectRatio(c, end);
    69     } else if (attr->name() == SVGNames::widthAttr) {
     65    else if (attr->name() == SVGNames::preserveAspectRatioAttr)
     66        SVGPreserveAspectRatio::parsePreserveAspectRatio(this, attr->value());
     67    else if (attr->name() == SVGNames::widthAttr) {
    7068        setWidthBaseValue(SVGLength(LengthModeWidth, attr->value()));
    7169        addCSSProperty(attr, CSSPropertyWidth, attr->value());
  • trunk/WebCore/svg/SVGMarkerElement.cpp

    r49602 r52373  
    2727#include "PlatformString.h"
    2828#include "RenderSVGViewportContainer.h"
    29 #include "SVGAngle.h"
    3029#include "SVGFitToViewBox.h"
    3130#include "SVGLength.h"
     
    5049    , m_markerUnits(this, SVGNames::markerUnitsAttr, SVG_MARKERUNITS_STROKEWIDTH)
    5150    , m_orientType(this, SVGNames::orientAttr, SVG_MARKER_ORIENT_ANGLE)
    52     , m_orientAngle(this, SVGNames::orientAttr, SVGAngle::create())
     51    , m_orientAngle(this, SVGNames::orientAttr)
    5352    , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false)
    5453    , m_viewBox(this, SVGNames::viewBoxAttr)
    55     , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())
     54    , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr)
    5655{
    5756    // Spec: If the markerWidth/markerHeight attribute is not specified, the effect is as if a value of "3" were specified.
     
    8887        setMarkerHeightBaseValue(SVGLength(LengthModeHeight, attr->value()));
    8988    else if (attr->name() == SVGNames::orientAttr) {
    90         RefPtr<SVGAngle> angle = SVGAngle::create();
     89        SVGAngle angle;
    9190
    9291        if (attr->value() == "auto")
    9392            setOrientTypeBaseValue(SVG_MARKER_ORIENT_AUTO);
    9493        else {
    95             angle->setValueAsString(attr->value());
     94            angle.setValueAsString(attr->value());
    9695            setOrientTypeBaseValue(SVG_MARKER_ORIENT_ANGLE);
    9796        }
    9897
    99         setOrientAngleBaseValue(angle.get());
     98        setOrientAngleBaseValue(angle);
    10099    } else {
    101100        if (SVGLangSpace::parseMappedAttribute(attr))
     
    147146{
    148147    setOrientTypeBaseValue(SVG_MARKER_ORIENT_AUTO);
    149 
    150     RefPtr<SVGAngle> angle = SVGAngle::create();
    151     setOrientAngleBaseValue(angle.get());
     148    setOrientAngleBaseValue(SVGAngle());
    152149
    153150    if (!m_marker)
     
    160157}
    161158
    162 void SVGMarkerElement::setOrientToAngle(PassRefPtr<SVGAngle> angle)
     159void SVGMarkerElement::setOrientToAngle(const SVGAngle& angle)
    163160{
    164161    setOrientTypeBaseValue(SVG_MARKER_ORIENT_ANGLE);
    165     setOrientAngleBaseValue(angle.get());
     162    setOrientAngleBaseValue(angle);
    166163
    167164    if (!m_marker)
     
    181178    m_marker->setMarker(toRenderSVGViewportContainer(renderer()));
    182179
    183     if (orientType() == SVG_MARKER_ORIENT_ANGLE) {
    184         if (orientAngle())
    185             m_marker->setAngle(orientAngle()->value());
    186     } else
     180    if (orientType() == SVG_MARKER_ORIENT_ANGLE)
     181        m_marker->setAngle(orientAngle().value());
     182    else
    187183        m_marker->setAutoAngle();
    188184
  • trunk/WebCore/svg/SVGMarkerElement.h

    r49602 r52373  
    3434
    3535    class Document;
    36     class SVGAngle;
    3736
    3837    extern char SVGOrientTypeAttrIdentifier[];
     
    6261
    6362        void setOrientToAuto();
    64         void setOrientToAngle(PassRefPtr<SVGAngle>);
     63        void setOrientToAngle(const SVGAngle&);
    6564
    6665        virtual void parseMappedAttribute(MappedAttribute*);
  • trunk/WebCore/svg/SVGPatternElement.cpp

    r50583 r52373  
    6666    , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false)
    6767    , m_viewBox(this, SVGNames::viewBoxAttr)
    68     , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())
     68    , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr)
    6969{
    7070}
  • trunk/WebCore/svg/SVGPreserveAspectRatio.cpp

    r50675 r52373  
    6161}
    6262
    63 bool SVGPreserveAspectRatio::parsePreserveAspectRatio(const UChar*& currParam, const UChar* end, bool validate)
    64 {
    65     SVGPreserveAspectRatioType align = SVG_PRESERVEASPECTRATIO_NONE;
    66     SVGMeetOrSliceType meetOrSlice = SVG_MEETORSLICE_MEET;
    67     bool ret = false;
     63SVGPreserveAspectRatio SVGPreserveAspectRatio::parsePreserveAspectRatio(const UChar*& currParam, const UChar* end, bool validate, bool& result)
     64{
     65    SVGPreserveAspectRatio aspectRatio;
     66    aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_NONE;
     67    aspectRatio.m_meetOrSlice = SVG_MEETORSLICE_MEET;
     68    result = false;
    6869
    6970    if (!skipOptionalSpaces(currParam, end))
     
    9192                if (currParam[6] == 'i') {
    9293                    if (currParam[7] == 'n')
    93                         align = SVG_PRESERVEASPECTRATIO_XMINYMIN;
     94                        aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMINYMIN;
    9495                    else if (currParam[7] == 'd')
    95                         align = SVG_PRESERVEASPECTRATIO_XMINYMID;
     96                        aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMINYMID;
    9697                    else
    9798                        goto bail_out;
    9899                } else if (currParam[6] == 'a' && currParam[7] == 'x')
    99                      align = SVG_PRESERVEASPECTRATIO_XMINYMAX;
     100                     aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMINYMAX;
    100101                else
    101102                     goto bail_out;
     
    103104                if (currParam[6] == 'i') {
    104105                    if (currParam[7] == 'n')
    105                         align = SVG_PRESERVEASPECTRATIO_XMIDYMIN;
     106                        aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMIDYMIN;
    106107                    else if (currParam[7] == 'd')
    107                         align = SVG_PRESERVEASPECTRATIO_XMIDYMID;
     108                        aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMIDYMID;
    108109                    else
    109110                        goto bail_out;
    110111                } else if (currParam[6] == 'a' && currParam[7] == 'x')
    111                     align = SVG_PRESERVEASPECTRATIO_XMIDYMAX;
     112                    aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMIDYMAX;
    112113                else
    113114                    goto bail_out;
     
    117118            if (currParam[6] == 'i') {
    118119                if (currParam[7] == 'n')
    119                     align = SVG_PRESERVEASPECTRATIO_XMAXYMIN;
     120                    aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMAXYMIN;
    120121                else if (currParam[7] == 'd')
    121                     align = SVG_PRESERVEASPECTRATIO_XMAXYMID;
     122                    aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMAXYMID;
    122123                else
    123124                    goto bail_out;
    124125            } else if (currParam[6] == 'a' && currParam[7] == 'x')
    125                 align = SVG_PRESERVEASPECTRATIO_XMAXYMAX;
     126                aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMAXYMAX;
    126127            else
    127128                goto bail_out;
     
    142143                goto bail_out;
    143144            skipOptionalSpaces(currParam, end);
    144             if (align != SVG_PRESERVEASPECTRATIO_NONE)
    145                 meetOrSlice = SVG_MEETORSLICE_SLICE;   
     145            if (aspectRatio.m_align != SVG_PRESERVEASPECTRATIO_NONE)
     146                aspectRatio.m_meetOrSlice = SVG_MEETORSLICE_SLICE;   
    146147        }
    147148    }
     
    150151bail_out:
    151152        // FIXME: Should the two values be set to UNKNOWN instead?
    152         align = SVG_PRESERVEASPECTRATIO_NONE;
    153         meetOrSlice = SVG_MEETORSLICE_MEET;
     153        aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_NONE;
     154        aspectRatio.m_meetOrSlice = SVG_MEETORSLICE_MEET;
    154155    } else
    155         ret = true;
    156 
    157     if (m_align == align && m_meetOrSlice == meetOrSlice)
    158         return ret;
    159 
    160     m_align = align;
    161     m_meetOrSlice = meetOrSlice;
    162     return ret;
     156        result = true;
     157
     158    return aspectRatio;
    163159}
    164160
     
    166162                                               double logicWidth, double logicHeight,
    167163                                               double /*physX*/, double /*physY*/,
    168                                                double physWidth, double physHeight)
     164                                               double physWidth, double physHeight) const
    169165{
    170166    TransformationMatrix temp;
  • trunk/WebCore/svg/SVGPreserveAspectRatio.h

    r50583 r52373  
    2626#include "SVGNames.h"
    2727
    28 #include <wtf/RefCounted.h>
    29 
    3028namespace WebCore {
    3129
    3230    class String;
    3331    class TransformationMatrix;
    34     class SVGStyledElement;
    3532
    36     class SVGPreserveAspectRatio : public RefCounted<SVGPreserveAspectRatio> {
     33    class SVGPreserveAspectRatio {
    3734    public:
    38         static PassRefPtr<SVGPreserveAspectRatio> create() { return adoptRef(new SVGPreserveAspectRatio); }
    39 
    4035        enum SVGPreserveAspectRatioType {
    4136            SVG_PRESERVEASPECTRATIO_UNKNOWN     = 0,
     
    5853        };
    5954
     55        SVGPreserveAspectRatio();
    6056        virtual ~SVGPreserveAspectRatio();
    6157
     
    6965                               double logicWidth, double logicHeight,
    7066                               double physX, double physY,
    71                                double physWidth, double physHeight);
     67                               double physWidth, double physHeight) const;
    7268
    73         // Helper
    74         bool parsePreserveAspectRatio(const UChar*& currParam, const UChar* end, bool validate = true);
     69        template<class Consumer>
     70        static bool parsePreserveAspectRatio(Consumer* consumer, const String& value, bool validate = true)
     71        {
     72            bool result = false;
     73            const UChar* begin = value.characters();
     74            const UChar* end = begin + value.length();
     75            consumer->setPreserveAspectRatioBaseValue(parsePreserveAspectRatio(begin, end, validate, result));
     76            return result;
     77        }
     78
     79        // It's recommended to use the method above, only SVGViewSpec needs this parsing method
     80        static SVGPreserveAspectRatio parsePreserveAspectRatio(const UChar*& currParam, const UChar* end, bool validate, bool& result);
     81
    7582        String valueAsString() const;
    7683
     
    7885
    7986    private:
    80         SVGPreserveAspectRatio();
    81        
    8287        unsigned short m_align;
    8388        unsigned short m_meetOrSlice;
     
    8893#endif // ENABLE(SVG)
    8994#endif // SVGPreserveAspectRatio_h
    90 
  • trunk/WebCore/svg/SVGPreserveAspectRatio.idl

    r29672 r52373  
    2626module svg {
    2727
    28     interface [Conditional=SVG, GenerateConstructor] SVGPreserveAspectRatio {
     28    interface [Conditional=SVG, GenerateConstructor, PODType=SVGPreserveAspectRatio] SVGPreserveAspectRatio {
    2929        // Alignment Types
    3030        const unsigned short SVG_PRESERVEASPECTRATIO_UNKNOWN  = 0;
  • trunk/WebCore/svg/SVGSVGElement.cpp

    r49602 r52373  
    7070    , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false)
    7171    , m_viewBox(this, SVGNames::viewBoxAttr)
    72     , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())
     72    , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr)
    7373    , m_useCurrentView(false)
    7474    , m_timeContainer(SMILTimeContainer::create(this))
     
    375375}
    376376
    377 PassRefPtr<SVGAngle> SVGSVGElement::createSVGAngle()
    378 {
    379     return SVGAngle::create();
     377SVGAngle SVGSVGElement::createSVGAngle()
     378{
     379    return SVGAngle();
    380380}
    381381
     
    532532    else
    533533        currentView()->setViewBox(viewBox());
    534     if (viewElement->hasAttribute(SVGNames::preserveAspectRatioAttr)) {
    535         currentView()->preserveAspectRatio()->setAlign(viewElement->preserveAspectRatio()->align());
    536         currentView()->preserveAspectRatio()->setMeetOrSlice(viewElement->preserveAspectRatio()->meetOrSlice());
    537     } else {
    538         currentView()->preserveAspectRatio()->setAlign(preserveAspectRatio()->align());
    539         currentView()->preserveAspectRatio()->setMeetOrSlice(preserveAspectRatio()->meetOrSlice());
    540     }
     534
     535    SVGPreserveAspectRatio aspectRatio;
     536    if (viewElement->hasAttribute(SVGNames::preserveAspectRatioAttr))
     537        aspectRatio = viewElement->preserveAspectRatioBaseValue();
     538    else
     539        aspectRatio = preserveAspectRatioBaseValue();
     540    currentView()->setPreserveAspectRatioBaseValue(aspectRatio);
     541
    541542    if (viewElement->hasAttribute(SVGNames::zoomAndPanAttr))
    542543        currentView()->setZoomAndPan(viewElement->zoomAndPan());
  • trunk/WebCore/svg/SVGSVGElement.h

    r49602 r52373  
    106106        static float createSVGNumber();
    107107        static SVGLength createSVGLength();
    108         static PassRefPtr<SVGAngle> createSVGAngle();
     108        static SVGAngle createSVGAngle();
    109109        static FloatPoint createSVGPoint();
    110110        static TransformationMatrix createSVGMatrix();
  • trunk/WebCore/svg/SVGSymbolElement.cpp

    r50583 r52373  
    3535    , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false)
    3636    , m_viewBox(this, SVGNames::viewBoxAttr)
    37     , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())
     37    , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr)
    3838{
    3939}
  • trunk/WebCore/svg/SVGViewElement.cpp

    r50583 r52373  
    4141    , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false)
    4242    , m_viewBox(this, SVGNames::viewBoxAttr)
    43     , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())
     43    , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr)
    4444{
    4545}
  • trunk/WebCore/svg/SVGViewSpec.cpp

    r49745 r52373  
    3737    , m_contextElement(contextElement)
    3838    , m_viewBox(this, SVGNames::viewBoxAttr)
    39     , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())
     39    , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr)
    4040    , m_transform(SVGTransformList::create(SVGNames::transformAttr))
    4141{
     
    6363void SVGViewSpec::setPreserveAspectRatioString(const String& preserve)
    6464{
    65     const UChar* c = preserve.characters();
    66     const UChar* end = c + preserve.length();
    67     preserveAspectRatioBaseValue()->parsePreserveAspectRatio(c, end);
     65    SVGPreserveAspectRatio::parsePreserveAspectRatio(this, preserve);
    6866}
    6967
     
    142140                return false;
    143141            currViewSpec++;
    144             if (!preserveAspectRatioBaseValue()->parsePreserveAspectRatio(currViewSpec, end, false))
     142            bool result = false;
     143            setPreserveAspectRatioBaseValue(SVGPreserveAspectRatio::parsePreserveAspectRatio(currViewSpec, end, false, result));
     144            if (!result)
    145145                return false;
    146146            if (currViewSpec >= end || *currViewSpec != ')')
Note: See TracChangeset for help on using the changeset viewer.