Changeset 52373 in webkit
- Timestamp:
- Dec 18, 2009 8:34:57 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r52372 r52373 1 2009-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 1 66 2009-12-18 Dumitru Daniliuc <dumi@chromium.org> 2 67 -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r52349 r52373 136 136 08C4C51A0EF19A4000E4840F /* WMLImageLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08C4C5160EF19A4000E4840F /* WMLImageLoader.cpp */; }; 137 137 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 */; }; 138 139 08C925190FCC7C4A00480DEC /* FilterEffect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08C925170FCC7C4A00480DEC /* FilterEffect.cpp */; }; 139 140 08C9251A0FCC7C4A00480DEC /* FilterEffect.h in Headers */ = {isa = PBXBuildFile; fileRef = 08C925180FCC7C4A00480DEC /* FilterEffect.h */; }; … … 1145 1146 656581B209D14EE6000E61D7 /* UserAgentStyleSheets.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581AE09D14EE6000E61D7 /* UserAgentStyleSheets.h */; }; 1146 1147 656581FE09D1508D000E61D7 /* SVGElementFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581E709D1508D000E61D7 /* SVGElementFactory.h */; }; 1147 6565820009D1508D000E61D7 /* SVGNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581E909D1508D000E61D7 /* SVGNames.h */; };1148 1148 6565820209D1508D000E61D7 /* XLinkNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581EB09D1508D000E61D7 /* XLinkNames.h */; }; 1149 1149 656D37320ADBA5DE00A4554D /* LoaderNSURLExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 656D371A0ADBA5DE00A4554D /* LoaderNSURLExtras.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 3324 3324 B22279740D00BF220071B782 /* SVGAElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B22277DE0D00BF1F0071B782 /* SVGAElement.h */; }; 3325 3325 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, ); }; }; 3327 3327 B22279790D00BF220071B782 /* SVGAnimateColorElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22277E30D00BF1F0071B782 /* SVGAnimateColorElement.cpp */; }; 3328 3328 B222797A0D00BF220071B782 /* SVGAnimateColorElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B22277E40D00BF1F0071B782 /* SVGAnimateColorElement.h */; }; … … 3501 3501 B2227A940D00BF220071B782 /* SVGPolylineElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B22278FE0D00BF210071B782 /* SVGPolylineElement.h */; }; 3502 3502 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, ); }; }; 3504 3504 B2227A990D00BF220071B782 /* SVGRadialGradientElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22279030D00BF210071B782 /* SVGRadialGradientElement.cpp */; }; 3505 3505 B2227A9A0D00BF220071B782 /* SVGRadialGradientElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B22279040D00BF210071B782 /* SVGRadialGradientElement.h */; }; … … 4825 4825 dstSubfolderSpec = 1; 4826 4826 files = ( 4827 08C7A2C710DC7462002D368B /* SVGNames.h in Copy Generated Headers */, 4827 4828 1CCA732210ADD44A00FD440D /* DOMHTMLInputElementPrivate.h in Copy Generated Headers */, 4828 4829 5DF7F5C20F01F92A00526B4B /* CSSPropertyNames.h in Copy Generated Headers */, … … 5337 5338 08C4C5160EF19A4000E4840F /* WMLImageLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WMLImageLoader.cpp; sourceTree = "<group>"; }; 5338 5339 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; }; 5339 5341 08C925170FCC7C4A00480DEC /* FilterEffect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FilterEffect.cpp; path = filters/FilterEffect.cpp; sourceTree = "<group>"; }; 5340 5342 08C925180FCC7C4A00480DEC /* FilterEffect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FilterEffect.h; path = filters/FilterEffect.h; sourceTree = "<group>"; }; … … 10102 10104 isa = PBXGroup; 10103 10105 children = ( 10106 08C7A2C310DC7431002D368B /* SVGNames.h */, 10104 10107 65C97AF208EA908800ACD273 /* config.h */, 10105 10108 EDEC98020AED7E170059137F /* WebCorePrefix.h */, … … 17972 17975 B2A1F2B10CEF0ABF00442F6A /* SVGMissingGlyphElement.h in Headers */, 17973 17976 B2227A4E0D00BF220071B782 /* SVGMPathElement.h in Headers */, 17974 6565820009D1508D000E61D7 /* SVGNames.h in Headers */,17975 17977 B2227A510D00BF220071B782 /* SVGNumberList.h in Headers */, 17976 17978 B2227A540D00BF220071B782 /* SVGPaint.h in Headers */, -
trunk/WebCore/bindings/scripts/CodeGenerator.pm
r49424 r52373 47 47 48 48 my %podTypeHash = ("SVGNumber" => 1, "SVGTransform" => 1); 49 my %podTypesWithWritablePropertiesHash = ("SVG Length" => 1, "SVGMatrix" => 1, "SVGPoint" => 1, "SVGRect" => 1);49 my %podTypesWithWritablePropertiesHash = ("SVGAngle" => 1, "SVGLength" => 1, "SVGMatrix" => 1, "SVGPoint" => 1, "SVGPreserveAspectRatio" => 1, "SVGRect" => 1); 50 50 my %stringTypeHash = ("DOMString" => 1, "AtomicString" => 1); 51 51 -
trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm
r52082 r52373 1825 1825 "DOMString" => "const UString&", 1826 1826 "NodeFilter" => "RefPtr<NodeFilter>", 1827 "SVGAngle" => "SVGAngle", 1827 1828 "SVGLength" => "SVGLength", 1828 1829 "SVGMatrix" => "TransformationMatrix", 1829 1830 "SVGNumber" => "float", 1830 1831 "SVGPaintType" => "SVGPaint::SVGPaintType", 1832 "SVGPreserveAspectRatio" => "SVGPreserveAspectRatio", 1831 1833 "SVGPoint" => "FloatPoint", 1832 1834 "SVGRect" => "FloatRect", -
trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm
r52224 r52373 1910 1910 return 1 if $type eq "XPathResult"; 1911 1911 1912 return 1 if $type eq "SVGAngle";1913 1912 return 1 if $type eq "SVGElementInstance"; 1914 1913 return 1 if $type eq "SVGElementInstanceList"; … … 1967 1966 return "SVGTransform" if $type eq "SVGTransform"; 1968 1967 return "SVGLength" if $type eq "SVGLength"; 1968 return "SVGAngle" if $type eq "SVGAngle"; 1969 1969 return "double" if $type eq "SVGNumber"; 1970 return "SVGPreserveAspectRatio" if $type eq "SVGPreserveAspectRatio"; 1970 1971 return "SVGPaint::SVGPaintType" if $type eq "SVGPaintType"; 1971 1972 return "DOMTimeStamp" if $type eq "DOMTimeStamp"; … … 2025 2026 "SQLResultSet" => 0, 2026 2027 "Storage" => 0, 2027 "SVGAngle" => 0,2028 "SVGAngle" => 1, 2028 2029 "SVGElement" => 0, 2029 2030 "SVGLength" => 1, … … 2033 2034 "SVGPathSeg" => 0, 2034 2035 "SVGPoint" => 1, 2036 "SVGPreserveAspectRatio" => 1, 2035 2037 "SVGRect" => 1, 2036 2038 "SVGTransform" => 1, … … 2065 2067 my $type = GetTypeFromSignature($signature); 2066 2068 2069 return 1 if $type eq "SVGAngle"; 2067 2070 return 1 if $type eq "SVGLength"; 2068 2071 return 1 if $type eq "SVGMatrix"; 2069 2072 return 1 if $type eq "SVGPoint"; 2073 return 1 if $type eq "SVGPreserveAspectRatio"; 2070 2074 return 1 if $type eq "SVGRect"; 2071 2075 return 1 if $type eq "SVGTransform"; … … 2237 2241 'DOMString' => 1, 2238 2242 'CompareHow' => 1, 2243 'SVGAngle' => 1, 2239 2244 'SVGRect' => 1, 2240 2245 'SVGPoint' => 1, 2246 'SVGPreserveAspectRatio' => 1, 2241 2247 'SVGMatrix' => 1, 2242 2248 'SVGTransform' => 1, -
trunk/WebCore/bindings/v8/V8Index.h
r51901 r52373 518 518 // SVG_OBJECT_TYPES are svg non-node, non-pod types. 519 519 #define SVG_OBJECT_TYPES(V) \ 520 V(SVGANGLE, SVGAngle) \521 520 V(SVGANIMATEDANGLE, SVGAnimatedAngle) \ 522 521 V(SVGANIMATEDBOOLEAN, SVGAnimatedBoolean) \ … … 560 559 V(SVGPATHSEGMOVETOREL, SVGPathSegMovetoRel) \ 561 560 V(SVGPOINTLIST, SVGPointList) \ 562 V(SVGPRESERVEASPECTRATIO, SVGPreserveAspectRatio) \563 561 V(SVGRENDERINGINTENT, SVGRenderingIntent) \ 564 562 V(SVGSTRINGLIST, SVGStringList) \ … … 569 567 // SVG POD types should list all types whose IDL has PODType declaration. 570 568 #define SVG_POD_TYPES(V) \ 569 V(SVGANGLE, SVGAngle) \ 571 570 V(SVGLENGTH, SVGLength) \ 571 V(SVGPRESERVEASPECTRATIO, SVGPreserveAspectRatio) \ 572 572 V(SVGTRANSFORM, SVGTransform) \ 573 573 V(SVGMATRIX, SVGMatrix) \ … … 578 578 // POD types can have different implementation names, see CodeGenerateV8.pm. 579 579 #define SVG_POD_NATIVE_TYPES(V) \ 580 V(SVGANGLE, SVGAngle) \ 580 581 V(SVGLENGTH, SVGLength) \ 582 V(SVGPRESERVEASPECTRATIO, SVGPreserveAspectRatio) \ 581 583 V(SVGTRANSFORM, SVGTransform) \ 582 584 V(SVGMATRIX, TransformationMatrix) \ -
trunk/WebCore/rendering/RenderSVGImage.cpp
r51212 r52373 48 48 } 49 49 50 void RenderSVGImage::adjustRectsForAspectRatio(FloatRect& destRect, FloatRect& srcRect, SVGPreserveAspectRatio*aspectRatio)50 void RenderSVGImage::adjustRectsForAspectRatio(FloatRect& destRect, FloatRect& srcRect, const SVGPreserveAspectRatio& aspectRatio) 51 51 { 52 52 float origDestWidth = destRect.width(); 53 53 float origDestHeight = destRect.height(); 54 if (aspectRatio ->meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_MEET) {54 if (aspectRatio.meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_MEET) { 55 55 float widthToHeightMultiplier = srcRect.height() / srcRect.width(); 56 56 if (origDestHeight > (origDestWidth * widthToHeightMultiplier)) { 57 57 destRect.setHeight(origDestWidth * widthToHeightMultiplier); 58 switch (aspectRatio ->align()) {58 switch (aspectRatio.align()) { 59 59 case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMID: 60 60 case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID: … … 71 71 if (origDestWidth > (origDestHeight / widthToHeightMultiplier)) { 72 72 destRect.setWidth(origDestHeight / widthToHeightMultiplier); 73 switch (aspectRatio ->align()) {73 switch (aspectRatio.align()) { 74 74 case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMIN: 75 75 case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID: … … 84 84 } 85 85 } 86 } else if (aspectRatio ->meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_SLICE) {86 } else if (aspectRatio.meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_SLICE) { 87 87 float widthToHeightMultiplier = srcRect.height() / srcRect.width(); 88 88 // if the destination height is less than the height of the image we'll be drawing … … 90 90 float destToSrcMultiplier = srcRect.width() / destRect.width(); 91 91 srcRect.setHeight(destRect.height() * destToSrcMultiplier); 92 switch (aspectRatio ->align()) {92 switch (aspectRatio.align()) { 93 93 case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMID: 94 94 case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID: … … 107 107 float destToSrcMultiplier = srcRect.height() / destRect.height(); 108 108 srcRect.setWidth(destRect.width() * destToSrcMultiplier); 109 switch (aspectRatio ->align()) {109 switch (aspectRatio.align()) { 110 110 case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMIN: 111 111 case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID: … … 164 164 165 165 SVGImageElement* imageElt = static_cast<SVGImageElement*>(node()); 166 if (imageElt->preserveAspectRatio() ->align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)166 if (imageElt->preserveAspectRatio().align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE) 167 167 adjustRectsForAspectRatio(destRect, srcRect, imageElt->preserveAspectRatio()); 168 168 -
trunk/WebCore/rendering/RenderSVGImage.h
r46815 r52373 25 25 26 26 #if ENABLE(SVG) 27 28 #include "TransformationMatrix.h"29 27 #include "FloatRect.h" 30 28 #include "RenderImage.h" 29 #include "SVGPreserveAspectRatio.h" 31 30 #include "SVGRenderSupport.h" 31 #include "TransformationMatrix.h" 32 32 33 33 namespace WebCore { 34 34 35 35 class SVGImageElement; 36 class SVGPreserveAspectRatio;37 36 38 37 class RenderSVGImage : public RenderImage, SVGRenderBase { … … 59 58 60 59 virtual void imageChanged(WrappedImagePtr, const IntRect* = 0); 61 void adjustRectsForAspectRatio(FloatRect& destRect, FloatRect& srcRect, SVGPreserveAspectRatio*);60 void adjustRectsForAspectRatio(FloatRect& destRect, FloatRect& srcRect, const SVGPreserveAspectRatio&); 62 61 63 62 virtual void layout(); -
trunk/WebCore/svg/SVGAngle.h
r34536 r52373 30 30 class SVGStyledElement; 31 31 32 class SVGAngle : public RefCounted<SVGAngle>{32 class SVGAngle { 33 33 public: 34 static PassRefPtr<SVGAngle> create() 35 { 36 return adoptRef(new SVGAngle); 37 } 34 SVGAngle(); 38 35 virtual ~SVGAngle(); 39 36 40 37 enum SVGAngleType { 41 38 SVG_ANGLETYPE_UNKNOWN = 0, … … 64 61 65 62 private: 66 SVGAngle();67 68 63 SVGAngleType m_unitType; 69 64 float m_value; -
trunk/WebCore/svg/SVGAngle.idl
r50583 r52373 23 23 module svg { 24 24 25 interface [Conditional=SVG, GenerateConstructor ] SVGAngle {25 interface [Conditional=SVG, GenerateConstructor, PODType=SVGAngle] SVGAngle { 26 26 // Angle Unit Types 27 27 const unsigned short SVG_ANGLETYPE_UNKNOWN = 0; -
trunk/WebCore/svg/SVGAnimatedTemplate.h
r51125 r52373 25 25 #include "AtomicString.h" 26 26 #include "FloatRect.h" 27 #include "SVGAngle.h" 27 28 #include "SVGLength.h" 29 #include "SVGPreserveAspectRatio.h" 28 30 #include <wtf/HashMap.h> 29 31 … … 204 206 205 207 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<> 206 217 struct SVGAnimatedTypeValue<SVGLength> : Noncopyable { 207 218 typedef SVGLength StorableType; … … 213 224 214 225 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<> 215 235 struct SVGAnimatedTypeValue<float> : Noncopyable { 216 236 typedef float StorableType; … … 240 260 241 261 // Common type definitions, to ease IDL generation. 242 typedef SVGAnimatedTemplate<SVGAngle *> SVGAnimatedAngle;262 typedef SVGAnimatedTemplate<SVGAngle> SVGAnimatedAngle; 243 263 typedef SVGAnimatedTemplate<bool> SVGAnimatedBoolean; 244 264 typedef SVGAnimatedTemplate<int> SVGAnimatedEnumeration; … … 248 268 typedef SVGAnimatedTemplate<float> SVGAnimatedNumber; 249 269 typedef SVGAnimatedTemplate<SVGNumberList*> SVGAnimatedNumberList; 250 typedef SVGAnimatedTemplate<SVGPreserveAspectRatio *> SVGAnimatedPreserveAspectRatio;270 typedef SVGAnimatedTemplate<SVGPreserveAspectRatio> SVGAnimatedPreserveAspectRatio; 251 271 typedef SVGAnimatedTemplate<FloatRect> SVGAnimatedRect; 252 272 typedef SVGAnimatedTemplate<String> SVGAnimatedString; -
trunk/WebCore/svg/SVGFEImageElement.cpp
r50583 r52373 41 41 , SVGLangSpace() 42 42 , SVGExternalResourcesRequired() 43 , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr , SVGPreserveAspectRatio::create())43 , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr) 44 44 , m_href(this, XLinkNames::hrefAttr) 45 45 , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) … … 56 56 { 57 57 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 { 63 61 if (SVGURIReference::parseMappedAttribute(attr)) { 64 62 if (!href().startsWith("#")) { -
trunk/WebCore/svg/SVGFitToViewBox.cpp
r49602 r52373 78 78 } 79 79 80 TransformationMatrix SVGFitToViewBox::viewBoxToViewTransform(const FloatRect& viewBoxRect, SVGPreserveAspectRatio*preserveAspectRatio, float viewWidth, float viewHeight)80 TransformationMatrix SVGFitToViewBox::viewBoxToViewTransform(const FloatRect& viewBoxRect, const SVGPreserveAspectRatio& preserveAspectRatio, float viewWidth, float viewHeight) 81 81 { 82 ASSERT(preserveAspectRatio);83 82 if (!viewBoxRect.width() || !viewBoxRect.height()) 84 83 return TransformationMatrix(); 85 84 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); 87 86 } 88 87 … … 97 96 return true; 98 97 } 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()); 102 99 return true; 103 100 } -
trunk/WebCore/svg/SVGFitToViewBox.h
r49602 r52373 38 38 39 39 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); 41 41 42 42 bool parseMappedAttribute(Document*, MappedAttribute*); 43 43 bool isKnownAttribute(const QualifiedName&); 44 44 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; 50 47 }; 51 48 -
trunk/WebCore/svg/SVGImageElement.cpp
r49306 r52373 46 46 , m_width(this, SVGNames::widthAttr, LengthModeWidth) 47 47 , m_height(this, SVGNames::heightAttr, LengthModeHeight) 48 , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr , SVGPreserveAspectRatio::create())48 , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr) 49 49 , m_href(this, XLinkNames::hrefAttr) 50 50 , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) … … 63 63 else if (attr->name() == SVGNames::yAttr) 64 64 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) { 70 68 setWidthBaseValue(SVGLength(LengthModeWidth, attr->value())); 71 69 addCSSProperty(attr, CSSPropertyWidth, attr->value()); -
trunk/WebCore/svg/SVGMarkerElement.cpp
r49602 r52373 27 27 #include "PlatformString.h" 28 28 #include "RenderSVGViewportContainer.h" 29 #include "SVGAngle.h"30 29 #include "SVGFitToViewBox.h" 31 30 #include "SVGLength.h" … … 50 49 , m_markerUnits(this, SVGNames::markerUnitsAttr, SVG_MARKERUNITS_STROKEWIDTH) 51 50 , m_orientType(this, SVGNames::orientAttr, SVG_MARKER_ORIENT_ANGLE) 52 , m_orientAngle(this, SVGNames::orientAttr , SVGAngle::create())51 , m_orientAngle(this, SVGNames::orientAttr) 53 52 , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) 54 53 , m_viewBox(this, SVGNames::viewBoxAttr) 55 , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr , SVGPreserveAspectRatio::create())54 , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr) 56 55 { 57 56 // Spec: If the markerWidth/markerHeight attribute is not specified, the effect is as if a value of "3" were specified. … … 88 87 setMarkerHeightBaseValue(SVGLength(LengthModeHeight, attr->value())); 89 88 else if (attr->name() == SVGNames::orientAttr) { 90 RefPtr<SVGAngle> angle = SVGAngle::create();89 SVGAngle angle; 91 90 92 91 if (attr->value() == "auto") 93 92 setOrientTypeBaseValue(SVG_MARKER_ORIENT_AUTO); 94 93 else { 95 angle ->setValueAsString(attr->value());94 angle.setValueAsString(attr->value()); 96 95 setOrientTypeBaseValue(SVG_MARKER_ORIENT_ANGLE); 97 96 } 98 97 99 setOrientAngleBaseValue(angle .get());98 setOrientAngleBaseValue(angle); 100 99 } else { 101 100 if (SVGLangSpace::parseMappedAttribute(attr)) … … 147 146 { 148 147 setOrientTypeBaseValue(SVG_MARKER_ORIENT_AUTO); 149 150 RefPtr<SVGAngle> angle = SVGAngle::create(); 151 setOrientAngleBaseValue(angle.get()); 148 setOrientAngleBaseValue(SVGAngle()); 152 149 153 150 if (!m_marker) … … 160 157 } 161 158 162 void SVGMarkerElement::setOrientToAngle( PassRefPtr<SVGAngle>angle)159 void SVGMarkerElement::setOrientToAngle(const SVGAngle& angle) 163 160 { 164 161 setOrientTypeBaseValue(SVG_MARKER_ORIENT_ANGLE); 165 setOrientAngleBaseValue(angle .get());162 setOrientAngleBaseValue(angle); 166 163 167 164 if (!m_marker) … … 181 178 m_marker->setMarker(toRenderSVGViewportContainer(renderer())); 182 179 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 187 183 m_marker->setAutoAngle(); 188 184 -
trunk/WebCore/svg/SVGMarkerElement.h
r49602 r52373 34 34 35 35 class Document; 36 class SVGAngle;37 36 38 37 extern char SVGOrientTypeAttrIdentifier[]; … … 62 61 63 62 void setOrientToAuto(); 64 void setOrientToAngle( PassRefPtr<SVGAngle>);63 void setOrientToAngle(const SVGAngle&); 65 64 66 65 virtual void parseMappedAttribute(MappedAttribute*); -
trunk/WebCore/svg/SVGPatternElement.cpp
r50583 r52373 66 66 , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) 67 67 , m_viewBox(this, SVGNames::viewBoxAttr) 68 , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr , SVGPreserveAspectRatio::create())68 , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr) 69 69 { 70 70 } -
trunk/WebCore/svg/SVGPreserveAspectRatio.cpp
r50675 r52373 61 61 } 62 62 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; 63 SVGPreserveAspectRatio 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; 68 69 69 70 if (!skipOptionalSpaces(currParam, end)) … … 91 92 if (currParam[6] == 'i') { 92 93 if (currParam[7] == 'n') 93 a lign = SVG_PRESERVEASPECTRATIO_XMINYMIN;94 aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMINYMIN; 94 95 else if (currParam[7] == 'd') 95 a lign = SVG_PRESERVEASPECTRATIO_XMINYMID;96 aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMINYMID; 96 97 else 97 98 goto bail_out; 98 99 } else if (currParam[6] == 'a' && currParam[7] == 'x') 99 a lign = SVG_PRESERVEASPECTRATIO_XMINYMAX;100 aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMINYMAX; 100 101 else 101 102 goto bail_out; … … 103 104 if (currParam[6] == 'i') { 104 105 if (currParam[7] == 'n') 105 a lign = SVG_PRESERVEASPECTRATIO_XMIDYMIN;106 aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMIDYMIN; 106 107 else if (currParam[7] == 'd') 107 a lign = SVG_PRESERVEASPECTRATIO_XMIDYMID;108 aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMIDYMID; 108 109 else 109 110 goto bail_out; 110 111 } else if (currParam[6] == 'a' && currParam[7] == 'x') 111 a lign = SVG_PRESERVEASPECTRATIO_XMIDYMAX;112 aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMIDYMAX; 112 113 else 113 114 goto bail_out; … … 117 118 if (currParam[6] == 'i') { 118 119 if (currParam[7] == 'n') 119 a lign = SVG_PRESERVEASPECTRATIO_XMAXYMIN;120 aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMAXYMIN; 120 121 else if (currParam[7] == 'd') 121 a lign = SVG_PRESERVEASPECTRATIO_XMAXYMID;122 aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMAXYMID; 122 123 else 123 124 goto bail_out; 124 125 } else if (currParam[6] == 'a' && currParam[7] == 'x') 125 a lign = SVG_PRESERVEASPECTRATIO_XMAXYMAX;126 aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMAXYMAX; 126 127 else 127 128 goto bail_out; … … 142 143 goto bail_out; 143 144 skipOptionalSpaces(currParam, end); 144 if (a lign != SVG_PRESERVEASPECTRATIO_NONE)145 meetOrSlice = SVG_MEETORSLICE_SLICE;145 if (aspectRatio.m_align != SVG_PRESERVEASPECTRATIO_NONE) 146 aspectRatio.m_meetOrSlice = SVG_MEETORSLICE_SLICE; 146 147 } 147 148 } … … 150 151 bail_out: 151 152 // FIXME: Should the two values be set to UNKNOWN instead? 152 a lign = SVG_PRESERVEASPECTRATIO_NONE;153 meetOrSlice = SVG_MEETORSLICE_MEET;153 aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_NONE; 154 aspectRatio.m_meetOrSlice = SVG_MEETORSLICE_MEET; 154 155 } 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; 163 159 } 164 160 … … 166 162 double logicWidth, double logicHeight, 167 163 double /*physX*/, double /*physY*/, 168 double physWidth, double physHeight) 164 double physWidth, double physHeight) const 169 165 { 170 166 TransformationMatrix temp; -
trunk/WebCore/svg/SVGPreserveAspectRatio.h
r50583 r52373 26 26 #include "SVGNames.h" 27 27 28 #include <wtf/RefCounted.h>29 30 28 namespace WebCore { 31 29 32 30 class String; 33 31 class TransformationMatrix; 34 class SVGStyledElement;35 32 36 class SVGPreserveAspectRatio : public RefCounted<SVGPreserveAspectRatio> {33 class SVGPreserveAspectRatio { 37 34 public: 38 static PassRefPtr<SVGPreserveAspectRatio> create() { return adoptRef(new SVGPreserveAspectRatio); }39 40 35 enum SVGPreserveAspectRatioType { 41 36 SVG_PRESERVEASPECTRATIO_UNKNOWN = 0, … … 58 53 }; 59 54 55 SVGPreserveAspectRatio(); 60 56 virtual ~SVGPreserveAspectRatio(); 61 57 … … 69 65 double logicWidth, double logicHeight, 70 66 double physX, double physY, 71 double physWidth, double physHeight) ;67 double physWidth, double physHeight) const; 72 68 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 75 82 String valueAsString() const; 76 83 … … 78 85 79 86 private: 80 SVGPreserveAspectRatio();81 82 87 unsigned short m_align; 83 88 unsigned short m_meetOrSlice; … … 88 93 #endif // ENABLE(SVG) 89 94 #endif // SVGPreserveAspectRatio_h 90 -
trunk/WebCore/svg/SVGPreserveAspectRatio.idl
r29672 r52373 26 26 module svg { 27 27 28 interface [Conditional=SVG, GenerateConstructor ] SVGPreserveAspectRatio {28 interface [Conditional=SVG, GenerateConstructor, PODType=SVGPreserveAspectRatio] SVGPreserveAspectRatio { 29 29 // Alignment Types 30 30 const unsigned short SVG_PRESERVEASPECTRATIO_UNKNOWN = 0; -
trunk/WebCore/svg/SVGSVGElement.cpp
r49602 r52373 70 70 , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) 71 71 , m_viewBox(this, SVGNames::viewBoxAttr) 72 , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr , SVGPreserveAspectRatio::create())72 , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr) 73 73 , m_useCurrentView(false) 74 74 , m_timeContainer(SMILTimeContainer::create(this)) … … 375 375 } 376 376 377 PassRefPtr<SVGAngle>SVGSVGElement::createSVGAngle()378 { 379 return SVGAngle ::create();377 SVGAngle SVGSVGElement::createSVGAngle() 378 { 379 return SVGAngle(); 380 380 } 381 381 … … 532 532 else 533 533 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 541 542 if (viewElement->hasAttribute(SVGNames::zoomAndPanAttr)) 542 543 currentView()->setZoomAndPan(viewElement->zoomAndPan()); -
trunk/WebCore/svg/SVGSVGElement.h
r49602 r52373 106 106 static float createSVGNumber(); 107 107 static SVGLength createSVGLength(); 108 static PassRefPtr<SVGAngle>createSVGAngle();108 static SVGAngle createSVGAngle(); 109 109 static FloatPoint createSVGPoint(); 110 110 static TransformationMatrix createSVGMatrix(); -
trunk/WebCore/svg/SVGSymbolElement.cpp
r50583 r52373 35 35 , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) 36 36 , m_viewBox(this, SVGNames::viewBoxAttr) 37 , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr , SVGPreserveAspectRatio::create())37 , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr) 38 38 { 39 39 } -
trunk/WebCore/svg/SVGViewElement.cpp
r50583 r52373 41 41 , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) 42 42 , m_viewBox(this, SVGNames::viewBoxAttr) 43 , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr , SVGPreserveAspectRatio::create())43 , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr) 44 44 { 45 45 } -
trunk/WebCore/svg/SVGViewSpec.cpp
r49745 r52373 37 37 , m_contextElement(contextElement) 38 38 , m_viewBox(this, SVGNames::viewBoxAttr) 39 , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr , SVGPreserveAspectRatio::create())39 , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr) 40 40 , m_transform(SVGTransformList::create(SVGNames::transformAttr)) 41 41 { … … 63 63 void SVGViewSpec::setPreserveAspectRatioString(const String& preserve) 64 64 { 65 const UChar* c = preserve.characters(); 66 const UChar* end = c + preserve.length(); 67 preserveAspectRatioBaseValue()->parsePreserveAspectRatio(c, end); 65 SVGPreserveAspectRatio::parsePreserveAspectRatio(this, preserve); 68 66 } 69 67 … … 142 140 return false; 143 141 currViewSpec++; 144 if (!preserveAspectRatioBaseValue()->parsePreserveAspectRatio(currViewSpec, end, false)) 142 bool result = false; 143 setPreserveAspectRatioBaseValue(SVGPreserveAspectRatio::parsePreserveAspectRatio(currViewSpec, end, false, result)); 144 if (!result) 145 145 return false; 146 146 if (currViewSpec >= end || *currViewSpec != ')')
Note: See TracChangeset
for help on using the changeset viewer.