Changeset 71329 in webkit


Ignore:
Timestamp:
Nov 4, 2010 6:06:54 AM (13 years ago)
Author:
Nikolas Zimmermann
Message:

2010-11-04 Nikolas Zimmermann <nzimmermann@rim.com>

Reviewed by Andreas Kling.

Refactor SVGStringListPropertyTearOff/SVGListPropertyTearOff to use a common base class
https://bugs.webkit.org/show_bug.cgi?id=48990

Introduce SVGListProperty as common base class between static lists (SVGStringListPropertyTearOff) and dynamic lists (SVGListPropertyTearOff).
This is a preparation for the addition of the next static list type: SVGPointList.

  • GNUmakefile.am: Add new files to build.
  • WebCore.gypi: Ditto.
  • WebCore.pro: Ditto.
  • WebCore.vcproj/WebCore.vcproj: Ditto.
  • WebCore.xcodeproj/project.pbxproj: Ditto.
  • bindings/scripts/CodeGenerator.pm: s/SVGStringListPropertyTearOff/SVGStaticListPropertyTearOff/.
  • bindings/scripts/CodeGeneratorJS.pm: Ditto.
  • bindings/scripts/CodeGeneratorObjC.pm: Ditto.
  • bindings/scripts/CodeGeneratorV8.pm: Ditto.
  • svg/properties/SVGAnimatedListPropertyTearOff.h: Include SVGStaticListPropertyTearOff.h here, to avoid special dependencies in CodeGenerator*.pm
  • svg/properties/SVGListProperty.h: Added.
  • svg/properties/SVGListPropertyTearOff.h: Use SVGList API implementation from SVGListProperty base class.
  • svg/properties/SVGStaticListPropertyTearOff.h: Added. Use SVGList API implementation from SVGListProperty base class.
  • svg/properties/SVGStringListPropertyTearOff.h: Removed.
Location:
trunk/WebCore
Files:
2 added
1 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r71328 r71329  
     12010-11-04  Nikolas Zimmermann  <nzimmermann@rim.com>
     2
     3        Reviewed by Andreas Kling.
     4
     5        Refactor SVGStringListPropertyTearOff/SVGListPropertyTearOff to use a common base class
     6        https://bugs.webkit.org/show_bug.cgi?id=48990
     7
     8        Introduce SVGListProperty as common base class between static lists (SVGStringListPropertyTearOff) and dynamic lists (SVGListPropertyTearOff).
     9        This is a preparation for the addition of the next static list type: SVGPointList.
     10
     11        * GNUmakefile.am: Add new files to build.
     12        * WebCore.gypi: Ditto.
     13        * WebCore.pro: Ditto.
     14        * WebCore.vcproj/WebCore.vcproj: Ditto.
     15        * WebCore.xcodeproj/project.pbxproj: Ditto.
     16        * bindings/scripts/CodeGenerator.pm: s/SVGStringListPropertyTearOff/SVGStaticListPropertyTearOff/.
     17        * bindings/scripts/CodeGeneratorJS.pm: Ditto.
     18        * bindings/scripts/CodeGeneratorObjC.pm: Ditto.
     19        * bindings/scripts/CodeGeneratorV8.pm: Ditto.
     20        * svg/properties/SVGAnimatedListPropertyTearOff.h: Include SVGStaticListPropertyTearOff.h here, to avoid special dependencies in CodeGenerator*.pm
     21        * svg/properties/SVGListProperty.h: Added.
     22        * svg/properties/SVGListPropertyTearOff.h: Use SVGList API implementation from SVGListProperty base class.
     23        * svg/properties/SVGStaticListPropertyTearOff.h: Added. Use SVGList API implementation from SVGListProperty base class.
     24        * svg/properties/SVGStringListPropertyTearOff.h: Removed.
     25
    1262010-11-04  Ryosuke Niwa  <rniwa@webkit.org>
    227
  • trunk/WebCore/GNUmakefile.am

    r71313 r71329  
    30383038        WebCore/svg/properties/SVGAnimatedPropertyTearOff.h \
    30393039        WebCore/svg/properties/SVGAnimatedStaticPropertyTearOff.h \
     3040        WebCore/svg/properties/SVGListProperty.h \
    30403041        WebCore/svg/properties/SVGListPropertyTearOff.h \
    30413042        WebCore/svg/properties/SVGProperty.h \
    30423043        WebCore/svg/properties/SVGPropertyTearOff.h \
    30433044        WebCore/svg/properties/SVGPropertyTraits.h \
    3044         WebCore/svg/properties/SVGStringListPropertyTearOff.h \
     3045        WebCore/svg/properties/SVGStaticListPropertyTearOff.h \
    30453046        WebCore/svg/RadialGradientAttributes.h \
    30463047        WebCore/svg/SVGAElement.cpp \
  • trunk/WebCore/WebCore.gypi

    r71313 r71329  
    39623962            'svg/properties/SVGAnimatedPropertyTearOff.h',
    39633963            'svg/properties/SVGAnimatedStaticPropertyTearOff.h',
     3964            'svg/properties/SVGListProperty.h',
    39643965            'svg/properties/SVGListPropertyTearOff.h',
    39653966            'svg/properties/SVGProperty.h',
    39663967            'svg/properties/SVGPropertyTearOff.h',
    39673968            'svg/properties/SVGPropertyTraits.h',
    3968             'svg/properties/SVGStringListPropertyTearOff.h',
     3969            'svg/properties/SVGStaticListPropertyTearOff.h',
    39693970            'svg/ColorDistance.cpp',
    39703971            'svg/ColorDistance.h',
  • trunk/WebCore/WebCore.pro

    r71309 r71329  
    23652365    svg/properties/SVGAnimatedPropertyTearOff.h \
    23662366    svg/properties/SVGAnimatedStaticPropertyTearOff.h \
     2367    svg/properties/SVGListProperty.h \
    23672368    svg/properties/SVGListPropertyTearOff.h \
    23682369    svg/properties/SVGProperty.h \
    23692370    svg/properties/SVGPropertyTearOff.h \
    23702371    svg/properties/SVGPropertyTraits.h \
    2371     svg/properties/SVGStringListPropertyTearOff.h \
     2372    svg/properties/SVGStaticListPropertyTearOff.h \
    23722373    svg/SVGAElement.h \
    23732374    svg/SVGAltGlyphElement.h \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r71313 r71329  
    6273662736                                </File>
    6273762737                                <File
     62738                                        RelativePath="..\svg\properties\SVGListProperty.h"
     62739                                        >
     62740                                </File>
     62741                                <File
    6273862742                                        RelativePath="..\svg\properties\SVGListPropertyTearOff.h"
    6273962743                                        >
     
    6275262756                                </File>
    6275362757                                <File
    62754                                         RelativePath="..\svg\properties\SVGStringListPropertyTearOff.h"
     62758                                        RelativePath="..\svg\properties\SVGStaticListPropertyTearOff.h"
    6275562759                                        >
    6275662760                                </File>
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r71328 r71329  
    7171                080FAE1A0EEEBDA800AACDE9 /* WMLTemplateElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 080FAE180EEEBDA800AACDE9 /* WMLTemplateElement.cpp */; };
    7272                080FAE1B0EEEBDA800AACDE9 /* WMLTemplateElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 080FAE190EEEBDA800AACDE9 /* WMLTemplateElement.h */; };
     73                0810764412828556007C63BA /* SVGListProperty.h in Headers */ = {isa = PBXBuildFile; fileRef = 0810764312828556007C63BA /* SVGListProperty.h */; settings = {ATTRIBUTES = (Private, ); }; };
    7374                081093DB1255F0E700ED9D29 /* SVGTextLayoutAttributesBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 081093D91255F0E700ED9D29 /* SVGTextLayoutAttributesBuilder.cpp */; };
    7475                081093DC1255F0E700ED9D29 /* SVGTextLayoutAttributesBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 081093DA1255F0E700ED9D29 /* SVGTextLayoutAttributesBuilder.h */; };
     
    173174                08807B800ED709AB003F6975 /* WMLSetvarElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08807B740ED709AB003F6975 /* WMLSetvarElement.cpp */; };
    174175                08807B810ED709AB003F6975 /* WMLSetvarElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 08807B750ED709AB003F6975 /* WMLSetvarElement.h */; };
     176                0880F70E1282B46D00948505 /* SVGStaticListPropertyTearOff.h in Headers */ = {isa = PBXBuildFile; fileRef = 0880F70D1282B46D00948505 /* SVGStaticListPropertyTearOff.h */; settings = {ATTRIBUTES = (Private, ); }; };
    175177                08820BDE0EF5D381009099A8 /* WMLTableElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08820BDC0EF5D381009099A8 /* WMLTableElement.cpp */; };
    176178                08820BDF0EF5D381009099A8 /* WMLTableElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 08820BDD0EF5D381009099A8 /* WMLTableElement.h */; };
     
    245247                08E192540EDE0C3A0087B780 /* WMLErrorHandling.h in Headers */ = {isa = PBXBuildFile; fileRef = 08E192520EDE0C3A0087B780 /* WMLErrorHandling.h */; };
    246248                08E4FE460E2BD41400F4CAE0 /* JSSVGLengthCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08E4FE450E2BD41400F4CAE0 /* JSSVGLengthCustom.cpp */; };
    247                 08E58FF512801CF70045903D /* SVGStringListPropertyTearOff.h in Headers */ = {isa = PBXBuildFile; fileRef = 08E58FF412801CF70045903D /* SVGStringListPropertyTearOff.h */; settings = {ATTRIBUTES = (Private, ); }; };
    248249                08E6A2E80EEE035200AC1206 /* WMLPostfieldElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08E6A2E60EEE035200AC1206 /* WMLPostfieldElement.cpp */; };
    249250                08E6A2E90EEE035200AC1206 /* WMLPostfieldElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 08E6A2E70EEE035200AC1206 /* WMLPostfieldElement.h */; };
     
    61076108                080FAE180EEEBDA800AACDE9 /* WMLTemplateElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WMLTemplateElement.cpp; sourceTree = "<group>"; };
    61086109                080FAE190EEEBDA800AACDE9 /* WMLTemplateElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMLTemplateElement.h; sourceTree = "<group>"; };
     6110                0810764312828556007C63BA /* SVGListProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGListProperty.h; sourceTree = "<group>"; };
    61096111                081093D91255F0E700ED9D29 /* SVGTextLayoutAttributesBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGTextLayoutAttributesBuilder.cpp; sourceTree = "<group>"; };
    61106112                081093DA1255F0E700ED9D29 /* SVGTextLayoutAttributesBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGTextLayoutAttributesBuilder.h; sourceTree = "<group>"; };
     
    62076209                08807B740ED709AB003F6975 /* WMLSetvarElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WMLSetvarElement.cpp; sourceTree = "<group>"; };
    62086210                08807B750ED709AB003F6975 /* WMLSetvarElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMLSetvarElement.h; sourceTree = "<group>"; };
     6211                0880F70D1282B46D00948505 /* SVGStaticListPropertyTearOff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGStaticListPropertyTearOff.h; sourceTree = "<group>"; };
    62096212                08820BDC0EF5D381009099A8 /* WMLTableElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WMLTableElement.cpp; sourceTree = "<group>"; };
    62106213                08820BDD0EF5D381009099A8 /* WMLTableElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMLTableElement.h; sourceTree = "<group>"; };
     
    62666269                08E192520EDE0C3A0087B780 /* WMLErrorHandling.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMLErrorHandling.h; sourceTree = "<group>"; };
    62676270                08E4FE450E2BD41400F4CAE0 /* JSSVGLengthCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGLengthCustom.cpp; sourceTree = "<group>"; };
    6268                 08E58FF412801CF70045903D /* SVGStringListPropertyTearOff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGStringListPropertyTearOff.h; sourceTree = "<group>"; };
    62696271                08E6A2E60EEE035200AC1206 /* WMLPostfieldElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WMLPostfieldElement.cpp; sourceTree = "<group>"; };
    62706272                08E6A2E70EEE035200AC1206 /* WMLPostfieldElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMLPostfieldElement.h; sourceTree = "<group>"; };
     
    1177411776                                088A0DFF126EF1DB00978F7A /* SVGAnimatedPropertyTearOff.h */,
    1177511777                                08525E621278C00100A84778 /* SVGAnimatedStaticPropertyTearOff.h */,
     11778                                0810764312828556007C63BA /* SVGListProperty.h */,
    1177611779                                088A0E00126EF1DB00978F7A /* SVGListPropertyTearOff.h */,
    1177711780                                088A0E01126EF1DB00978F7A /* SVGProperty.h */,
    1177811781                                088A0E02126EF1DB00978F7A /* SVGPropertyTearOff.h */,
    1177911782                                088A0E03126EF1DB00978F7A /* SVGPropertyTraits.h */,
    11780                                 08E58FF412801CF70045903D /* SVGStringListPropertyTearOff.h */,
     11783                                0880F70D1282B46D00948505 /* SVGStaticListPropertyTearOff.h */,
    1178111784                        );
    1178211785                        path = properties;
     
    2094620949                                B2227A3C0D00BF220071B782 /* SVGLineElement.h in Headers */,
    2094720950                                B2227A3E0D00BF220071B782 /* SVGList.h in Headers */,
     20951                                0810764412828556007C63BA /* SVGListProperty.h in Headers */,
    2094820952                                088A0E09126EF1DB00978F7A /* SVGListPropertyTearOff.h in Headers */,
    2094920953                                B2227A3F0D00BF220071B782 /* SVGListTraits.h in Headers */,
     
    2101021014                                08DAB9C31103D9C1003E7ABA /* SVGShadowTreeElements.h in Headers */,
    2101121015                                E4AFD0100DAF335500F5F55C /* SVGSMILElement.h in Headers */,
     21016                                0880F70E1282B46D00948505 /* SVGStaticListPropertyTearOff.h in Headers */,
    2101221017                                B2227AA90D00BF220071B782 /* SVGStopElement.h in Headers */,
    2101321018                                B2227AAC0D00BF220071B782 /* SVGStringList.h in Headers */,
    21014                                 08E58FF512801CF70045903D /* SVGStringListPropertyTearOff.h in Headers */,
    2101521019                                B2227AAF0D00BF220071B782 /* SVGStylable.h in Headers */,
    2101621020                                B2227AB20D00BF220071B782 /* SVGStyledElement.h in Headers */,
  • trunk/WebCore/bindings/scripts/CodeGenerator.pm

    r71227 r71329  
    8686    "SVGPreserveAspectRatio" => "SVGPropertyTearOff<SVGPreserveAspectRatio>",
    8787    "SVGRect" => "SVGPropertyTearOff<FloatRect>",
    88     "SVGStringList" => "SVGStringListPropertyTearOff"
     88    "SVGStringList" => "SVGStaticListPropertyTearOff<SVGStringList>"
    8989);
    9090
     
    399399    } elsif ($svgNativeType =~ /SVGListPropertyTearOff/) {
    400400        $svgNativeType =~ s/SVGListPropertyTearOff<//;
    401     }
     401    } elsif ($svgNativeType =~ /SVGStaticListPropertyTearOff/) {
     402        $svgNativeType =~ s/SVGStaticListPropertyTearOff<//;
     403    }
     404
    402405    $svgNativeType =~ s/>//;
    403406    return $svgNativeType;
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r71227 r71329  
    25032503        $headerIncludes{"$svgWrappedNativeType.h"} = 1;
    25042504        $headerIncludes{"SVGAnimatedPropertyTearOff.h"} = 1;
    2505     } elsif ($svgNativeType =~ /SVGListPropertyTearOff/) {
     2505    } elsif ($svgNativeType =~ /SVGListPropertyTearOff/ or $svgNativeType =~ /SVGStaticListPropertyTearOff/) {
    25062506        $svgListPropertyType = $svgWrappedNativeType;
    25072507        $headerIncludes{"$svgWrappedNativeType.h"} = 1;
    25082508        $headerIncludes{"SVGAnimatedListPropertyTearOff.h"} = 1;
    2509     } elsif ($svgNativeType =~ /SVGStringListPropertyTearOff/) {
    2510         $svgListPropertyType = "SVGStringList";
    2511         $headerIncludes{"$svgWrappedNativeType.h"} = 1;
    25122509    }
    25132510
     
    26842681    } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($type) and not $implClassName =~ /List$/) {
    26852682        my $tearOffType = $codeGenerator->GetSVGTypeNeedingTearOff($type);
    2686         if ($tearOffType eq "SVGStringListPropertyTearOff") {
     2683        if ($tearOffType =~ /SVGStaticListPropertyTearOff/) {
    26872684            my $extraImp = "GetOwnerElementForType<$implClassName, IsDerivedFromSVGElement<$implClassName>::value>::ownerElement(imp), ";
    2688             $value = $codeGenerator->GetSVGTypeNeedingTearOff($type) . "::create($extraImp$value)";
     2685            $value = "${tearOffType}::create($extraImp$value)";
    26892686        } else {
    2690             $value = $codeGenerator->GetSVGTypeNeedingTearOff($type) . "::create($value)";
     2687            $value = "${tearOffType}::create($value)";
    26912688        }
    26922689    }
  • trunk/WebCore/bindings/scripts/CodeGeneratorObjC.pm

    r71227 r71329  
    688688            $svgPropertyType =~ s/</\<WebCore::/;
    689689        }
    690     } elsif ($svgNativeType =~ /SVGListPropertyTearOff/) {
     690    } elsif ($svgNativeType =~ /SVGListPropertyTearOff/ or $svgNativeType =~ /SVGStaticListPropertyTearOff/) {
    691691        $svgListPropertyType = "WebCore::$svgWrappedNativeType";
    692692        $svgListPropertyType =~ s/</\<WebCore::/;
    693     } elsif ($svgNativeType =~ /SVGStringListPropertyTearOff/) {
    694         $svgListPropertyType = "WebCore::SVGStringList";
    695693    }
    696694
     
    10271025        push(@internalHeaderContent, "\n#import <WebCore/$className.h>\n\n");
    10281026        push(@internalHeaderContent, "#import <WebCore/SVGAnimatedPropertyTearOff.h>\n\n") if $svgPropertyType;
    1029         if ($svgListPropertyType) {
    1030             if ($svgListPropertyType eq "WebCore::SVGStringList") {
    1031                 push(@internalHeaderContent, "#import <WebCore/SVGStringListPropertyTearOff.h>\n\n");
    1032             } else {
    1033                 push(@internalHeaderContent, "#import <WebCore/SVGAnimatedListPropertyTearOff.h>\n\n");
    1034             }
    1035         }
     1027        push(@internalHeaderContent, "#import <WebCore/SVGAnimatedListPropertyTearOff.h>\n\n") if $svgListPropertyType;
    10361028        push(@internalHeaderContent, $interfaceAvailabilityVersionCheck) if length $interfaceAvailabilityVersion;
    10371029
     
    13281320                if ($codeGenerator->IsSVGTypeNeedingTearOff($attribute->signature->type) and not $implClassName =~ /List$/) {
    13291321                    my $idlTypeWithNamespace = GetSVGTypeWithNamespace($attribute->signature->type);
    1330                     if ($idlTypeWithNamespace eq "WebCore::SVGStringListPropertyTearOff") {
     1322                    if ($idlTypeWithNamespace =~ /SVGStaticListPropertyTearOff/) {
    13311323                        my $extraImp = "WebCore::GetOwnerElementForType<$implClassNameWithNamespace, WebCore::IsDerivedFromSVGElement<$implClassNameWithNamespace>::value>::ownerElement(IMPL), ";
    13321324                        $getterContentHead = "kit(WTF::getPtr(${idlTypeWithNamespace}::create($extraImp$getterContentHead";
  • trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r71232 r71329  
    224224        $svgPropertyType = $svgWrappedNativeType;
    225225        $implIncludes{"SVGAnimatedPropertyTearOff.h"} = 1;
    226     } elsif ($svgNativeType =~ /SVGListPropertyTearOff/) {
     226    } elsif ($svgNativeType =~ /SVGListPropertyTearOff/ or $svgNativeType =~ /SVGStaticListPropertyTearOff/) {
    227227        $svgListPropertyType = $svgWrappedNativeType;
    228228        $implIncludes{"SVGAnimatedListPropertyTearOff.h"} = 1;
    229     } elsif ($svgNativeType =~ /SVGStringListPropertyTearOff/) {
    230         $svgListPropertyType = "SVGStringList";
    231         $implIncludes{"$svgWrappedNativeType.h"} = 1;
    232229    }
    233230
     
    276273    push(@headerContent, "\ntemplate<typename PropertyType> class SVGPropertyTearOff;\n") if $svgPropertyType;
    277274    if ($svgListPropertyType) {
    278         if ($svgListPropertyType eq "SVGStringList") {
    279             push(@headerContent, "\nclass SVGStringListPropertyTearOff;\n");
     275        if ($svgListPropertyType =~ /SVGStaticListPropertyTearOff/) {
     276            push(@headerContent, "\ntemplate<typename PropertyType> class SVGStaticListPropertyTearOff;\n");
    280277        } else {
    281278            push(@headerContent, "\ntemplate<typename PropertyType> class SVGListPropertyTearOff;\n");
     
    753750    } elsif ($svgNativeType) {
    754751        my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($implClassName);
    755         if ($svgWrappedNativeType =~ /List$/ or $implClassName eq "SVGStringList") {
     752        if ($svgWrappedNativeType =~ /List$/) {
    756753            push(@implContentDecls, <<END);
    757754    $svgNativeType* imp = V8${implClassName}::toNative(info.Holder());
     
    932929        $implIncludes{"V8$attrType.h"} = 1;
    933930        my $tearOffType = $codeGenerator->GetSVGTypeNeedingTearOff($attrType);
    934         if ($tearOffType eq "SVGStringListPropertyTearOff") {
    935             $implIncludes{"SVGStringListPropertyTearOff.h"} = 1;
     931        if ($tearOffType =~ /SVGStaticListPropertyTearOff/) {
    936932            my $extraImp = "GetOwnerElementForType<$implClassName, IsDerivedFromSVGElement<$implClassName>::value>::ownerElement(imp), ";
    937933            push(@implContentDecls, "    return toV8(WTF::getPtr(${tearOffType}::create($extraImp$result)));\n");
  • trunk/WebCore/svg/properties/SVGAnimatedListPropertyTearOff.h

    r71236 r71329  
    2424#include "SVGAnimatedProperty.h"
    2525#include "SVGListPropertyTearOff.h"
     26#include "SVGStaticListPropertyTearOff.h"
    2627
    2728namespace WebCore {
  • trunk/WebCore/svg/properties/SVGListPropertyTearOff.h

    r71240 r71329  
    2222
    2323#if ENABLE(SVG)
    24 #include "ExceptionCode.h"
    25 #include "SVGAnimatedProperty.h"
    26 #include "SVGPropertyTearOff.h"
    27 #include "SVGPropertyTraits.h"
     24#include "SVGListProperty.h"
    2825
    2926namespace WebCore {
    3027
    3128template<typename PropertyType>
    32 class SVGAnimatedListPropertyTearOff;
    33 
    34 template<typename PropertyType>
    35 class SVGListPropertyTearOff : public SVGProperty {
     29class SVGListPropertyTearOff : public SVGListProperty<PropertyType> {
    3630public:
    37     typedef SVGListPropertyTearOff<PropertyType> Self;
     31    typedef SVGListProperty<PropertyType> Base;
    3832
    3933    typedef typename SVGPropertyTraits<PropertyType>::ListItemType ListItemType;
     
    4337    typedef typename SVGAnimatedListPropertyTearOff<PropertyType>::ListWrapperCache ListWrapperCache;
    4438
    45     static PassRefPtr<Self> create(AnimatedListPropertyTearOff* animatedProperty, SVGPropertyRole role)
     39    static PassRefPtr<SVGListPropertyTearOff<PropertyType> > create(AnimatedListPropertyTearOff* animatedProperty, SVGPropertyRole role)
    4640    {
    4741        ASSERT(animatedProperty);
    48         return adoptRef(new Self(animatedProperty, role));
     42        return adoptRef(new SVGListPropertyTearOff<PropertyType>(animatedProperty, role));
    4943    }
    5044
     
    7872    void clear(ExceptionCode& ec)
    7973    {
    80         if (m_role == AnimValRole) {
    81             ec = NO_MODIFICATION_ALLOWED_ERR;
    82             return;
    83         }
    84 
    85         m_animatedProperty->detachListWrappers(0);
    86         m_animatedProperty->values().clear();
     74        Base::clearValuesAndWrappers(m_animatedProperty.get(), ec);
    8775    }
    8876
    8977    unsigned numberOfItems() const
    9078    {
    91         return m_animatedProperty->values().size();
     79        return Base::numberOfItemsValuesAndWrappers(m_animatedProperty.get());
    9280    }
    9381
    9482    PassListItemTearOff initialize(PassListItemTearOff passNewItem, ExceptionCode& ec)
    9583    {
    96         if (m_role == AnimValRole) {
    97             ec = NO_MODIFICATION_ALLOWED_ERR;
    98             return 0;
    99         }
    100 
    101         // Not specified, but FF/Opera do it this way, and it's just sane.
    102         if (!passNewItem) {
    103             ec = TYPE_MISMATCH_ERR;
    104             return 0;
    105         }
    106 
    107         PropertyType& values = m_animatedProperty->values();
    108         ListWrapperCache& wrappers = m_animatedProperty->wrappers();
    109 
    110         RefPtr<ListItemTearOff> newItem = passNewItem;
    111         ASSERT(values.size() == wrappers.size());
    112 
    113         // Spec: If the inserted item is already in a list, it is removed from its previous list before it is inserted into this list.
    114         processIncomingListItem(newItem, 0);
    115 
    116         // Spec: Clears all existing current items from the list and re-initializes the list to hold the single item specified by the parameter.
    117         m_animatedProperty->detachListWrappers(0);
    118         values.clear();
    119 
    120         values.append(newItem->propertyReference());
    121         wrappers.append(newItem);
    122 
    123         commitChange();
    124         return newItem.release();
     84        return Base::initializeValuesAndWrappers(m_animatedProperty.get(), passNewItem, ec);
    12585    }
    12686
    12787    PassListItemTearOff getItem(unsigned index, ExceptionCode& ec)
    12888    {
    129         PropertyType& values = m_animatedProperty->values();
    130         if (index >= values.size()) {
    131             ec = INDEX_SIZE_ERR;
    132             return 0;
    133         }
    134 
    135         ListWrapperCache& wrappers = m_animatedProperty->wrappers();
    136 
    137         // Spec: Returns the specified item from the list. The returned item is the item itself and not a copy.
    138         // Any changes made to the item are immediately reflected in the list.
    139         ASSERT(values.size() == wrappers.size());
    140         RefPtr<ListItemTearOff> wrapper = wrappers.at(index);
    141         if (!wrapper) {
    142             // Create new wrapper, which is allowed to directly modify the item in the list, w/o copying and cache the wrapper in our map.
    143             // It is also associated with our animated property, so it can notify the SVG Element which holds the SVGAnimated*List
    144             // that it has been modified (and thus can call svgAttributeChanged(associatedAttributeName)).
    145             wrapper = ListItemTearOff::create(m_animatedProperty.get(), UndefinedRole, values.at(index));
    146             wrappers.at(index) = wrapper;
    147         }
    148 
    149         return wrapper.release();
     89        return Base::getItemValuesAndWrappers(m_animatedProperty.get(), index, ec);
    15090    }
    15191
    15292    PassListItemTearOff insertItemBefore(PassListItemTearOff passNewItem, unsigned index, ExceptionCode& ec)
    15393    {
    154         if (m_role == AnimValRole) {
    155             ec = NO_MODIFICATION_ALLOWED_ERR;
    156             return 0;
    157         }
    158 
    159         // Not specified, but FF/Opera do it this way, and it's just sane.
    160         if (!passNewItem) {
    161             ec = TYPE_MISMATCH_ERR;
    162             return 0;
    163         }
    164 
    165         PropertyType& values = m_animatedProperty->values();
    166         ListWrapperCache& wrappers = m_animatedProperty->wrappers();
    167 
    168         // Spec: If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list.
    169         if (index > values.size())
    170              index = values.size();
    171 
    172         RefPtr<ListItemTearOff> newItem = passNewItem;
    173         ASSERT(values.size() == wrappers.size());
    174 
    175         // Spec: If newItem is already in a list, it is removed from its previous list before it is inserted into this list.
    176         processIncomingListItem(newItem, &index);
    177 
    178         // Spec: Inserts a new item into the list at the specified position. The index of the item before which the new item is to be
    179         // inserted. The first item is number 0. If the index is equal to 0, then the new item is inserted at the front of the list.
    180         values.insert(index, newItem->propertyReference());
    181 
    182         // Store new wrapper at position 'index', change its underlying value, so mutations of newItem, directly affect the item in the list.
    183         wrappers.insert(index, newItem);
    184 
    185         commitChange();
    186         return newItem.release();
     94        return Base::insertItemBeforeValuesAndWrappers(m_animatedProperty.get(), passNewItem, index, ec);
    18795    }
    18896
    18997    PassListItemTearOff replaceItem(PassListItemTearOff passNewItem, unsigned index, ExceptionCode& ec)
    19098    {
    191         if (m_role == AnimValRole) {
    192             ec = NO_MODIFICATION_ALLOWED_ERR;
    193             return 0;
    194         }
    195 
    196         PropertyType& values = m_animatedProperty->values();
    197         if (index >= values.size()) {
    198             ec = INDEX_SIZE_ERR;
    199             return 0;
    200         }
    201 
    202         // Not specified, but FF/Opera do it this way, and it's just sane.
    203         if (!passNewItem) {
    204             ec = TYPE_MISMATCH_ERR;
    205             return 0;
    206         }
    207 
    208         ListWrapperCache& wrappers = m_animatedProperty->wrappers();
    209         ASSERT(values.size() == wrappers.size());
    210         RefPtr<ListItemTearOff> newItem = passNewItem;
    211 
    212         // Spec: If newItem is already in a list, it is removed from its previous list before it is inserted into this list.
    213         // Spec: If the item is already in this list, note that the index of the item to replace is before the removal of the item.
    214         processIncomingListItem(newItem, &index);
    215 
    216         // Detach the existing wrapper.
    217         RefPtr<ListItemTearOff>& oldItem = wrappers.at(index);
    218         if (oldItem)
    219             oldItem->detachWrapper();
    220 
    221         // Update the value and the wrapper at the desired position 'index'.
    222         values.at(index) = newItem->propertyReference();
    223         wrappers.at(index) = newItem;
    224 
    225         commitChange();
    226         return newItem.release();
     99        return Base::replaceItemValuesAndWrappers(m_animatedProperty.get(), passNewItem, index, ec);
    227100    }
    228101
    229102    PassListItemTearOff removeItem(unsigned index, ExceptionCode& ec)
    230103    {
    231         if (m_role == AnimValRole) {
    232             ec = NO_MODIFICATION_ALLOWED_ERR;
    233             return 0;
    234         }
    235 
    236         PropertyType& values = m_animatedProperty->values();
    237         if (index >= values.size()) {
    238             ec = INDEX_SIZE_ERR;
    239             return 0;
    240         }
    241 
    242         ListWrapperCache& wrappers = m_animatedProperty->wrappers();
    243         ASSERT(values.size() == wrappers.size());
    244 
    245         // Detach the existing wrapper.
    246         RefPtr<ListItemTearOff>& oldItem = wrappers.at(index);
    247         if (oldItem) {
    248             oldItem->detachWrapper();
    249             wrappers.remove(index);
    250         }
    251 
    252         values.remove(index);
    253 
    254         commitChange();
    255         return oldItem.release();
     104        return Base::removeItemValuesAndWrappers(m_animatedProperty.get(), index, ec);
    256105    }
    257106
    258107    PassListItemTearOff appendItem(PassListItemTearOff passNewItem, ExceptionCode& ec)
    259108    {
    260         if (m_role == AnimValRole) {
    261             ec = NO_MODIFICATION_ALLOWED_ERR;
    262             return 0;
    263         }
    264 
    265         // Not specified, but FF/Opera do it this way, and it's just sane.
    266         if (!passNewItem) {
    267             ec = TYPE_MISMATCH_ERR;
    268             return 0;
    269         }
    270 
    271         PropertyType& values = m_animatedProperty->values();
    272         ListWrapperCache& wrappers = m_animatedProperty->wrappers();
    273 
    274         RefPtr<ListItemTearOff> newItem = passNewItem;
    275         ASSERT(values.size() == wrappers.size());
    276 
    277         // Spec: If newItem is already in a list, it is removed from its previous list before it is inserted into this list.
    278         processIncomingListItem(newItem, 0);
    279 
    280         // Append the value and wrapper at the end of the list.
    281         values.append(newItem->propertyReference());
    282         wrappers.append(newItem);
    283 
    284         commitChange();
    285         return newItem.release();
     109        return Base::appendItemValuesAndWrappers(m_animatedProperty.get(), passNewItem, ec);
    286110    }
    287111
    288112private:
    289113    SVGListPropertyTearOff(AnimatedListPropertyTearOff* animatedProperty, SVGPropertyRole role)
    290         : m_animatedProperty(animatedProperty)
    291         , m_role(role)
     114        : SVGListProperty<PropertyType>(role)
     115        , m_animatedProperty(animatedProperty)
    292116    {
    293         ASSERT(animatedProperty);
    294         ASSERT(role != UndefinedRole);
    295117    }
    296118
    297     void commitChange()
     119    virtual void commitChange()
    298120    {
    299121        PropertyType& values = m_animatedProperty->values();
     
    314136    }
    315137
    316     void processIncomingListItem(RefPtr<ListItemTearOff>& newItem, unsigned* indexToModify)
     138    virtual void processIncomingListItemValue(const ListItemType&, unsigned*)
     139    {
     140        ASSERT_NOT_REACHED();
     141    }
     142
     143    virtual void processIncomingListItemWrapper(RefPtr<ListItemTearOff>& newItem, unsigned* indexToModify)
    317144    {
    318145        SVGAnimatedProperty* animatedPropertyOfItem = newItem->animatedProperty();
     
    338165        // 'newItem' is already living in another list. If it's not our list, synchronize the other lists wrappers after the removal.
    339166        bool livesInOtherList = animatedPropertyOfItem != m_animatedProperty;
    340         int removedIndex = static_cast<SVGAnimatedListPropertyTearOff<PropertyType>*>(animatedPropertyOfItem)->removeItemFromList(newItem.get(), livesInOtherList);
     167        int removedIndex = static_cast<AnimatedListPropertyTearOff*>(animatedPropertyOfItem)->removeItemFromList(newItem.get(), livesInOtherList);
    341168        ASSERT(removedIndex != -1);
    342169
     
    357184    // For example (text.x.baseVal): m_animatedProperty points to the 'x' SVGAnimatedLengthList object
    358185    RefPtr<AnimatedListPropertyTearOff> m_animatedProperty;
    359 
    360     // The role of this property (baseVal or animVal)
    361     SVGPropertyRole m_role;
    362186};
    363187
Note: See TracChangeset for help on using the changeset viewer.