Changeset 71329 in webkit
- Timestamp:
- Nov 4, 2010 6:06:54 AM (13 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 added
- 1 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r71328 r71329 1 2010-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 1 26 2010-11-04 Ryosuke Niwa <rniwa@webkit.org> 2 27 -
trunk/WebCore/GNUmakefile.am
r71313 r71329 3038 3038 WebCore/svg/properties/SVGAnimatedPropertyTearOff.h \ 3039 3039 WebCore/svg/properties/SVGAnimatedStaticPropertyTearOff.h \ 3040 WebCore/svg/properties/SVGListProperty.h \ 3040 3041 WebCore/svg/properties/SVGListPropertyTearOff.h \ 3041 3042 WebCore/svg/properties/SVGProperty.h \ 3042 3043 WebCore/svg/properties/SVGPropertyTearOff.h \ 3043 3044 WebCore/svg/properties/SVGPropertyTraits.h \ 3044 WebCore/svg/properties/SVGSt ringListPropertyTearOff.h \3045 WebCore/svg/properties/SVGStaticListPropertyTearOff.h \ 3045 3046 WebCore/svg/RadialGradientAttributes.h \ 3046 3047 WebCore/svg/SVGAElement.cpp \ -
trunk/WebCore/WebCore.gypi
r71313 r71329 3962 3962 'svg/properties/SVGAnimatedPropertyTearOff.h', 3963 3963 'svg/properties/SVGAnimatedStaticPropertyTearOff.h', 3964 'svg/properties/SVGListProperty.h', 3964 3965 'svg/properties/SVGListPropertyTearOff.h', 3965 3966 'svg/properties/SVGProperty.h', 3966 3967 'svg/properties/SVGPropertyTearOff.h', 3967 3968 'svg/properties/SVGPropertyTraits.h', 3968 'svg/properties/SVGSt ringListPropertyTearOff.h',3969 'svg/properties/SVGStaticListPropertyTearOff.h', 3969 3970 'svg/ColorDistance.cpp', 3970 3971 'svg/ColorDistance.h', -
trunk/WebCore/WebCore.pro
r71309 r71329 2365 2365 svg/properties/SVGAnimatedPropertyTearOff.h \ 2366 2366 svg/properties/SVGAnimatedStaticPropertyTearOff.h \ 2367 svg/properties/SVGListProperty.h \ 2367 2368 svg/properties/SVGListPropertyTearOff.h \ 2368 2369 svg/properties/SVGProperty.h \ 2369 2370 svg/properties/SVGPropertyTearOff.h \ 2370 2371 svg/properties/SVGPropertyTraits.h \ 2371 svg/properties/SVGSt ringListPropertyTearOff.h \2372 svg/properties/SVGStaticListPropertyTearOff.h \ 2372 2373 svg/SVGAElement.h \ 2373 2374 svg/SVGAltGlyphElement.h \ -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r71313 r71329 62736 62736 </File> 62737 62737 <File 62738 RelativePath="..\svg\properties\SVGListProperty.h" 62739 > 62740 </File> 62741 <File 62738 62742 RelativePath="..\svg\properties\SVGListPropertyTearOff.h" 62739 62743 > … … 62752 62756 </File> 62753 62757 <File 62754 RelativePath="..\svg\properties\SVGSt ringListPropertyTearOff.h"62758 RelativePath="..\svg\properties\SVGStaticListPropertyTearOff.h" 62755 62759 > 62756 62760 </File> -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r71328 r71329 71 71 080FAE1A0EEEBDA800AACDE9 /* WMLTemplateElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 080FAE180EEEBDA800AACDE9 /* WMLTemplateElement.cpp */; }; 72 72 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, ); }; }; 73 74 081093DB1255F0E700ED9D29 /* SVGTextLayoutAttributesBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 081093D91255F0E700ED9D29 /* SVGTextLayoutAttributesBuilder.cpp */; }; 74 75 081093DC1255F0E700ED9D29 /* SVGTextLayoutAttributesBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 081093DA1255F0E700ED9D29 /* SVGTextLayoutAttributesBuilder.h */; }; … … 173 174 08807B800ED709AB003F6975 /* WMLSetvarElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08807B740ED709AB003F6975 /* WMLSetvarElement.cpp */; }; 174 175 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, ); }; }; 175 177 08820BDE0EF5D381009099A8 /* WMLTableElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08820BDC0EF5D381009099A8 /* WMLTableElement.cpp */; }; 176 178 08820BDF0EF5D381009099A8 /* WMLTableElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 08820BDD0EF5D381009099A8 /* WMLTableElement.h */; }; … … 245 247 08E192540EDE0C3A0087B780 /* WMLErrorHandling.h in Headers */ = {isa = PBXBuildFile; fileRef = 08E192520EDE0C3A0087B780 /* WMLErrorHandling.h */; }; 246 248 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, ); }; };248 249 08E6A2E80EEE035200AC1206 /* WMLPostfieldElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08E6A2E60EEE035200AC1206 /* WMLPostfieldElement.cpp */; }; 249 250 08E6A2E90EEE035200AC1206 /* WMLPostfieldElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 08E6A2E70EEE035200AC1206 /* WMLPostfieldElement.h */; }; … … 6107 6108 080FAE180EEEBDA800AACDE9 /* WMLTemplateElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WMLTemplateElement.cpp; sourceTree = "<group>"; }; 6108 6109 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>"; }; 6109 6111 081093D91255F0E700ED9D29 /* SVGTextLayoutAttributesBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGTextLayoutAttributesBuilder.cpp; sourceTree = "<group>"; }; 6110 6112 081093DA1255F0E700ED9D29 /* SVGTextLayoutAttributesBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGTextLayoutAttributesBuilder.h; sourceTree = "<group>"; }; … … 6207 6209 08807B740ED709AB003F6975 /* WMLSetvarElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WMLSetvarElement.cpp; sourceTree = "<group>"; }; 6208 6210 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>"; }; 6209 6212 08820BDC0EF5D381009099A8 /* WMLTableElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WMLTableElement.cpp; sourceTree = "<group>"; }; 6210 6213 08820BDD0EF5D381009099A8 /* WMLTableElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMLTableElement.h; sourceTree = "<group>"; }; … … 6266 6269 08E192520EDE0C3A0087B780 /* WMLErrorHandling.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMLErrorHandling.h; sourceTree = "<group>"; }; 6267 6270 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>"; };6269 6271 08E6A2E60EEE035200AC1206 /* WMLPostfieldElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WMLPostfieldElement.cpp; sourceTree = "<group>"; }; 6270 6272 08E6A2E70EEE035200AC1206 /* WMLPostfieldElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMLPostfieldElement.h; sourceTree = "<group>"; }; … … 11774 11776 088A0DFF126EF1DB00978F7A /* SVGAnimatedPropertyTearOff.h */, 11775 11777 08525E621278C00100A84778 /* SVGAnimatedStaticPropertyTearOff.h */, 11778 0810764312828556007C63BA /* SVGListProperty.h */, 11776 11779 088A0E00126EF1DB00978F7A /* SVGListPropertyTearOff.h */, 11777 11780 088A0E01126EF1DB00978F7A /* SVGProperty.h */, 11778 11781 088A0E02126EF1DB00978F7A /* SVGPropertyTearOff.h */, 11779 11782 088A0E03126EF1DB00978F7A /* SVGPropertyTraits.h */, 11780 08 E58FF412801CF70045903D /* SVGStringListPropertyTearOff.h */,11783 0880F70D1282B46D00948505 /* SVGStaticListPropertyTearOff.h */, 11781 11784 ); 11782 11785 path = properties; … … 20946 20949 B2227A3C0D00BF220071B782 /* SVGLineElement.h in Headers */, 20947 20950 B2227A3E0D00BF220071B782 /* SVGList.h in Headers */, 20951 0810764412828556007C63BA /* SVGListProperty.h in Headers */, 20948 20952 088A0E09126EF1DB00978F7A /* SVGListPropertyTearOff.h in Headers */, 20949 20953 B2227A3F0D00BF220071B782 /* SVGListTraits.h in Headers */, … … 21010 21014 08DAB9C31103D9C1003E7ABA /* SVGShadowTreeElements.h in Headers */, 21011 21015 E4AFD0100DAF335500F5F55C /* SVGSMILElement.h in Headers */, 21016 0880F70E1282B46D00948505 /* SVGStaticListPropertyTearOff.h in Headers */, 21012 21017 B2227AA90D00BF220071B782 /* SVGStopElement.h in Headers */, 21013 21018 B2227AAC0D00BF220071B782 /* SVGStringList.h in Headers */, 21014 08E58FF512801CF70045903D /* SVGStringListPropertyTearOff.h in Headers */,21015 21019 B2227AAF0D00BF220071B782 /* SVGStylable.h in Headers */, 21016 21020 B2227AB20D00BF220071B782 /* SVGStyledElement.h in Headers */, -
trunk/WebCore/bindings/scripts/CodeGenerator.pm
r71227 r71329 86 86 "SVGPreserveAspectRatio" => "SVGPropertyTearOff<SVGPreserveAspectRatio>", 87 87 "SVGRect" => "SVGPropertyTearOff<FloatRect>", 88 "SVGStringList" => "SVGSt ringListPropertyTearOff"88 "SVGStringList" => "SVGStaticListPropertyTearOff<SVGStringList>" 89 89 ); 90 90 … … 399 399 } elsif ($svgNativeType =~ /SVGListPropertyTearOff/) { 400 400 $svgNativeType =~ s/SVGListPropertyTearOff<//; 401 } 401 } elsif ($svgNativeType =~ /SVGStaticListPropertyTearOff/) { 402 $svgNativeType =~ s/SVGStaticListPropertyTearOff<//; 403 } 404 402 405 $svgNativeType =~ s/>//; 403 406 return $svgNativeType; -
trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm
r71227 r71329 2503 2503 $headerIncludes{"$svgWrappedNativeType.h"} = 1; 2504 2504 $headerIncludes{"SVGAnimatedPropertyTearOff.h"} = 1; 2505 } elsif ($svgNativeType =~ /SVGListPropertyTearOff/ ) {2505 } elsif ($svgNativeType =~ /SVGListPropertyTearOff/ or $svgNativeType =~ /SVGStaticListPropertyTearOff/) { 2506 2506 $svgListPropertyType = $svgWrappedNativeType; 2507 2507 $headerIncludes{"$svgWrappedNativeType.h"} = 1; 2508 2508 $headerIncludes{"SVGAnimatedListPropertyTearOff.h"} = 1; 2509 } elsif ($svgNativeType =~ /SVGStringListPropertyTearOff/) {2510 $svgListPropertyType = "SVGStringList";2511 $headerIncludes{"$svgWrappedNativeType.h"} = 1;2512 2509 } 2513 2510 … … 2684 2681 } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($type) and not $implClassName =~ /List$/) { 2685 2682 my $tearOffType = $codeGenerator->GetSVGTypeNeedingTearOff($type); 2686 if ($tearOffType eq "SVGStringListPropertyTearOff") {2683 if ($tearOffType =~ /SVGStaticListPropertyTearOff/) { 2687 2684 my $extraImp = "GetOwnerElementForType<$implClassName, IsDerivedFromSVGElement<$implClassName>::value>::ownerElement(imp), "; 2688 $value = $codeGenerator->GetSVGTypeNeedingTearOff($type) . "::create($extraImp$value)";2685 $value = "${tearOffType}::create($extraImp$value)"; 2689 2686 } else { 2690 $value = $codeGenerator->GetSVGTypeNeedingTearOff($type) . "::create($value)";2687 $value = "${tearOffType}::create($value)"; 2691 2688 } 2692 2689 } -
trunk/WebCore/bindings/scripts/CodeGeneratorObjC.pm
r71227 r71329 688 688 $svgPropertyType =~ s/</\<WebCore::/; 689 689 } 690 } elsif ($svgNativeType =~ /SVGListPropertyTearOff/ ) {690 } elsif ($svgNativeType =~ /SVGListPropertyTearOff/ or $svgNativeType =~ /SVGStaticListPropertyTearOff/) { 691 691 $svgListPropertyType = "WebCore::$svgWrappedNativeType"; 692 692 $svgListPropertyType =~ s/</\<WebCore::/; 693 } elsif ($svgNativeType =~ /SVGStringListPropertyTearOff/) {694 $svgListPropertyType = "WebCore::SVGStringList";695 693 } 696 694 … … 1027 1025 push(@internalHeaderContent, "\n#import <WebCore/$className.h>\n\n"); 1028 1026 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; 1036 1028 push(@internalHeaderContent, $interfaceAvailabilityVersionCheck) if length $interfaceAvailabilityVersion; 1037 1029 … … 1328 1320 if ($codeGenerator->IsSVGTypeNeedingTearOff($attribute->signature->type) and not $implClassName =~ /List$/) { 1329 1321 my $idlTypeWithNamespace = GetSVGTypeWithNamespace($attribute->signature->type); 1330 if ($idlTypeWithNamespace eq "WebCore::SVGStringListPropertyTearOff") {1322 if ($idlTypeWithNamespace =~ /SVGStaticListPropertyTearOff/) { 1331 1323 my $extraImp = "WebCore::GetOwnerElementForType<$implClassNameWithNamespace, WebCore::IsDerivedFromSVGElement<$implClassNameWithNamespace>::value>::ownerElement(IMPL), "; 1332 1324 $getterContentHead = "kit(WTF::getPtr(${idlTypeWithNamespace}::create($extraImp$getterContentHead"; -
trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm
r71232 r71329 224 224 $svgPropertyType = $svgWrappedNativeType; 225 225 $implIncludes{"SVGAnimatedPropertyTearOff.h"} = 1; 226 } elsif ($svgNativeType =~ /SVGListPropertyTearOff/ ) {226 } elsif ($svgNativeType =~ /SVGListPropertyTearOff/ or $svgNativeType =~ /SVGStaticListPropertyTearOff/) { 227 227 $svgListPropertyType = $svgWrappedNativeType; 228 228 $implIncludes{"SVGAnimatedListPropertyTearOff.h"} = 1; 229 } elsif ($svgNativeType =~ /SVGStringListPropertyTearOff/) {230 $svgListPropertyType = "SVGStringList";231 $implIncludes{"$svgWrappedNativeType.h"} = 1;232 229 } 233 230 … … 276 273 push(@headerContent, "\ntemplate<typename PropertyType> class SVGPropertyTearOff;\n") if $svgPropertyType; 277 274 if ($svgListPropertyType) { 278 if ($svgListPropertyType eq "SVGStringList") {279 push(@headerContent, "\n class SVGStringListPropertyTearOff;\n");275 if ($svgListPropertyType =~ /SVGStaticListPropertyTearOff/) { 276 push(@headerContent, "\ntemplate<typename PropertyType> class SVGStaticListPropertyTearOff;\n"); 280 277 } else { 281 278 push(@headerContent, "\ntemplate<typename PropertyType> class SVGListPropertyTearOff;\n"); … … 753 750 } elsif ($svgNativeType) { 754 751 my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($implClassName); 755 if ($svgWrappedNativeType =~ /List$/ or $implClassName eq "SVGStringList") {752 if ($svgWrappedNativeType =~ /List$/) { 756 753 push(@implContentDecls, <<END); 757 754 $svgNativeType* imp = V8${implClassName}::toNative(info.Holder()); … … 932 929 $implIncludes{"V8$attrType.h"} = 1; 933 930 my $tearOffType = $codeGenerator->GetSVGTypeNeedingTearOff($attrType); 934 if ($tearOffType eq "SVGStringListPropertyTearOff") { 935 $implIncludes{"SVGStringListPropertyTearOff.h"} = 1; 931 if ($tearOffType =~ /SVGStaticListPropertyTearOff/) { 936 932 my $extraImp = "GetOwnerElementForType<$implClassName, IsDerivedFromSVGElement<$implClassName>::value>::ownerElement(imp), "; 937 933 push(@implContentDecls, " return toV8(WTF::getPtr(${tearOffType}::create($extraImp$result)));\n"); -
trunk/WebCore/svg/properties/SVGAnimatedListPropertyTearOff.h
r71236 r71329 24 24 #include "SVGAnimatedProperty.h" 25 25 #include "SVGListPropertyTearOff.h" 26 #include "SVGStaticListPropertyTearOff.h" 26 27 27 28 namespace WebCore { -
trunk/WebCore/svg/properties/SVGListPropertyTearOff.h
r71240 r71329 22 22 23 23 #if ENABLE(SVG) 24 #include "ExceptionCode.h" 25 #include "SVGAnimatedProperty.h" 26 #include "SVGPropertyTearOff.h" 27 #include "SVGPropertyTraits.h" 24 #include "SVGListProperty.h" 28 25 29 26 namespace WebCore { 30 27 31 28 template<typename PropertyType> 32 class SVGAnimatedListPropertyTearOff; 33 34 template<typename PropertyType> 35 class SVGListPropertyTearOff : public SVGProperty { 29 class SVGListPropertyTearOff : public SVGListProperty<PropertyType> { 36 30 public: 37 typedef SVGListProperty TearOff<PropertyType> Self;31 typedef SVGListProperty<PropertyType> Base; 38 32 39 33 typedef typename SVGPropertyTraits<PropertyType>::ListItemType ListItemType; … … 43 37 typedef typename SVGAnimatedListPropertyTearOff<PropertyType>::ListWrapperCache ListWrapperCache; 44 38 45 static PassRefPtr<S elf> create(AnimatedListPropertyTearOff* animatedProperty, SVGPropertyRole role)39 static PassRefPtr<SVGListPropertyTearOff<PropertyType> > create(AnimatedListPropertyTearOff* animatedProperty, SVGPropertyRole role) 46 40 { 47 41 ASSERT(animatedProperty); 48 return adoptRef(new S elf(animatedProperty, role));42 return adoptRef(new SVGListPropertyTearOff<PropertyType>(animatedProperty, role)); 49 43 } 50 44 … … 78 72 void clear(ExceptionCode& ec) 79 73 { 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); 87 75 } 88 76 89 77 unsigned numberOfItems() const 90 78 { 91 return m_animatedProperty->values().size();79 return Base::numberOfItemsValuesAndWrappers(m_animatedProperty.get()); 92 80 } 93 81 94 82 PassListItemTearOff initialize(PassListItemTearOff passNewItem, ExceptionCode& ec) 95 83 { 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); 125 85 } 126 86 127 87 PassListItemTearOff getItem(unsigned index, ExceptionCode& ec) 128 88 { 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); 150 90 } 151 91 152 92 PassListItemTearOff insertItemBefore(PassListItemTearOff passNewItem, unsigned index, ExceptionCode& ec) 153 93 { 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); 187 95 } 188 96 189 97 PassListItemTearOff replaceItem(PassListItemTearOff passNewItem, unsigned index, ExceptionCode& ec) 190 98 { 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); 227 100 } 228 101 229 102 PassListItemTearOff removeItem(unsigned index, ExceptionCode& ec) 230 103 { 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); 256 105 } 257 106 258 107 PassListItemTearOff appendItem(PassListItemTearOff passNewItem, ExceptionCode& ec) 259 108 { 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); 286 110 } 287 111 288 112 private: 289 113 SVGListPropertyTearOff(AnimatedListPropertyTearOff* animatedProperty, SVGPropertyRole role) 290 : m_animatedProperty(animatedProperty)291 , m_ role(role)114 : SVGListProperty<PropertyType>(role) 115 , m_animatedProperty(animatedProperty) 292 116 { 293 ASSERT(animatedProperty);294 ASSERT(role != UndefinedRole);295 117 } 296 118 297 v oid commitChange()119 virtual void commitChange() 298 120 { 299 121 PropertyType& values = m_animatedProperty->values(); … … 314 136 } 315 137 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) 317 144 { 318 145 SVGAnimatedProperty* animatedPropertyOfItem = newItem->animatedProperty(); … … 338 165 // 'newItem' is already living in another list. If it's not our list, synchronize the other lists wrappers after the removal. 339 166 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); 341 168 ASSERT(removedIndex != -1); 342 169 … … 357 184 // For example (text.x.baseVal): m_animatedProperty points to the 'x' SVGAnimatedLengthList object 358 185 RefPtr<AnimatedListPropertyTearOff> m_animatedProperty; 359 360 // The role of this property (baseVal or animVal)361 SVGPropertyRole m_role;362 186 }; 363 187
Note: See TracChangeset
for help on using the changeset viewer.