[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.17-1283-gcf603cf
zimmermann at webkit.org
zimmermann at webkit.org
Tue Jan 5 23:54:51 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 64e11bd3a35b240224478dc9426e7027565cb2c8
Author: zimmermann at webkit.org <zimmermann at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Dec 19 04:34:57 2009 +0000
2009-12-18 Nikolas Zimmermann <nzimmermann at rim.com>
Reviewed by Eric Seidel.
SVGAngle / SVGPreserveAspectRatio should be POD types
https://bugs.webkit.org/show_bug.cgi?id=32758
Convert SVGAngle / SVGPreserveAspectRatio to be non-refcounted types, just
like it has been done for SVGMatrix / SVGLength before.
This patch prepares removing the special DOMObjectWithSVGContext hack.
No change in functionality, thus no new tests.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52373 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 80dda33..aca3b47 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,68 @@
+2009-12-18 Nikolas Zimmermann <nzimmermann at rim.com>
+
+ Reviewed by Eric Seidel.
+
+ SVGAngle / SVGPreserveAspectRatio should be POD types
+ https://bugs.webkit.org/show_bug.cgi?id=32758
+
+ Convert SVGAngle / SVGPreserveAspectRatio to be non-refcounted types, just
+ like it has been done for SVGMatrix / SVGLength before.
+
+ This patch prepares removing the special DOMObjectWithSVGContext hack.
+ No change in functionality, thus no new tests.
+
+ * 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.
+ * bindings/scripts/CodeGenerator.pm: Recognize SVGAngle / SVGPreserveAspectRatio as new POD-types (similar to SVGLength)
+ * bindings/scripts/CodeGeneratorJS.pm: Ditto.
+ * bindings/scripts/CodeGeneratorV8.pm: Ditto.
+ * bindings/v8/V8Index.h: Ditto.
+ * rendering/RenderSVGImage.cpp: All following changes, modify SVGAngle/SVGPreserveAspectRatio access, as they are non-refcounted now.
+ (WebCore::RenderSVGImage::adjustRectsForAspectRatio):
+ (WebCore::RenderSVGImage::paint):
+ * rendering/RenderSVGImage.h:
+ * svg/SVGAngle.h:
+ * svg/SVGAngle.idl:
+ * svg/SVGAnimatedTemplate.h:
+ (WebCore::):
+ * svg/SVGFEImageElement.cpp:
+ (WebCore::SVGFEImageElement::SVGFEImageElement):
+ (WebCore::SVGFEImageElement::parseMappedAttribute):
+ * svg/SVGFitToViewBox.cpp:
+ (WebCore::SVGFitToViewBox::viewBoxToViewTransform):
+ (WebCore::SVGFitToViewBox::parseMappedAttribute):
+ * svg/SVGFitToViewBox.h:
+ * svg/SVGImageElement.cpp:
+ (WebCore::SVGImageElement::SVGImageElement):
+ (WebCore::SVGImageElement::parseMappedAttribute):
+ * svg/SVGMarkerElement.cpp:
+ (WebCore::SVGMarkerElement::SVGMarkerElement):
+ (WebCore::SVGMarkerElement::parseMappedAttribute):
+ (WebCore::SVGMarkerElement::setOrientToAuto):
+ (WebCore::SVGMarkerElement::setOrientToAngle):
+ (WebCore::SVGMarkerElement::canvasResource):
+ * svg/SVGMarkerElement.h:
+ * svg/SVGPatternElement.cpp:
+ (WebCore::SVGPatternElement::SVGPatternElement):
+ * svg/SVGPreserveAspectRatio.cpp:
+ (WebCore::SVGPreserveAspectRatio::parsePreserveAspectRatio):
+ (WebCore::SVGPreserveAspectRatio::getCTM):
+ * svg/SVGPreserveAspectRatio.h:
+ (WebCore::SVGPreserveAspectRatio::parsePreserveAspectRatio):
+ * svg/SVGPreserveAspectRatio.idl:
+ * svg/SVGSVGElement.cpp:
+ (WebCore::SVGSVGElement::SVGSVGElement):
+ (WebCore::SVGSVGElement::createSVGAngle):
+ (WebCore::SVGSVGElement::inheritViewAttributes):
+ * svg/SVGSVGElement.h:
+ * svg/SVGSymbolElement.cpp:
+ (WebCore::SVGSymbolElement::SVGSymbolElement):
+ * svg/SVGViewElement.cpp:
+ (WebCore::SVGViewElement::SVGViewElement):
+ * svg/SVGViewSpec.cpp:
+ (WebCore::SVGViewSpec::SVGViewSpec):
+ (WebCore::SVGViewSpec::setPreserveAspectRatioString):
+ (WebCore::SVGViewSpec::parseViewSpec):
+
2009-12-18 Dumitru Daniliuc <dumi at chromium.org>
Chromium build fix, no review.
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index a2ded29..f4367e2 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -135,6 +135,7 @@
08C4C5190EF19A4000E4840F /* WMLImageElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 08C4C5150EF19A4000E4840F /* WMLImageElement.h */; };
08C4C51A0EF19A4000E4840F /* WMLImageLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08C4C5160EF19A4000E4840F /* WMLImageLoader.cpp */; };
08C4C51B0EF19A4000E4840F /* WMLImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 08C4C5170EF19A4000E4840F /* WMLImageLoader.h */; };
+ 08C7A2C710DC7462002D368B /* SVGNames.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 08C7A2C310DC7431002D368B /* SVGNames.h */; };
08C925190FCC7C4A00480DEC /* FilterEffect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08C925170FCC7C4A00480DEC /* FilterEffect.cpp */; };
08C9251A0FCC7C4A00480DEC /* FilterEffect.h in Headers */ = {isa = PBXBuildFile; fileRef = 08C925180FCC7C4A00480DEC /* FilterEffect.h */; };
08CD61BC0ED3929C002DDF51 /* WMLTaskElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08CD61B80ED3929C002DDF51 /* WMLTaskElement.cpp */; };
@@ -1144,7 +1145,6 @@
6565815109D13043000E61D7 /* CSSValueKeywords.h in Headers */ = {isa = PBXBuildFile; fileRef = 6565814809D13043000E61D7 /* CSSValueKeywords.h */; };
656581B209D14EE6000E61D7 /* UserAgentStyleSheets.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581AE09D14EE6000E61D7 /* UserAgentStyleSheets.h */; };
656581FE09D1508D000E61D7 /* SVGElementFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581E709D1508D000E61D7 /* SVGElementFactory.h */; };
- 6565820009D1508D000E61D7 /* SVGNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581E909D1508D000E61D7 /* SVGNames.h */; };
6565820209D1508D000E61D7 /* XLinkNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581EB09D1508D000E61D7 /* XLinkNames.h */; };
656D37320ADBA5DE00A4554D /* LoaderNSURLExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 656D371A0ADBA5DE00A4554D /* LoaderNSURLExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
656D37330ADBA5DE00A4554D /* LoaderNSURLExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = 656D371B0ADBA5DE00A4554D /* LoaderNSURLExtras.mm */; };
@@ -3323,7 +3323,7 @@
B22279730D00BF220071B782 /* SVGAElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22277DD0D00BF1F0071B782 /* SVGAElement.cpp */; };
B22279740D00BF220071B782 /* SVGAElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B22277DE0D00BF1F0071B782 /* SVGAElement.h */; };
B22279760D00BF220071B782 /* SVGAngle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22277E00D00BF1F0071B782 /* SVGAngle.cpp */; };
- B22279770D00BF220071B782 /* SVGAngle.h in Headers */ = {isa = PBXBuildFile; fileRef = B22277E10D00BF1F0071B782 /* SVGAngle.h */; };
+ B22279770D00BF220071B782 /* SVGAngle.h in Headers */ = {isa = PBXBuildFile; fileRef = B22277E10D00BF1F0071B782 /* SVGAngle.h */; settings = {ATTRIBUTES = (Private, ); }; };
B22279790D00BF220071B782 /* SVGAnimateColorElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22277E30D00BF1F0071B782 /* SVGAnimateColorElement.cpp */; };
B222797A0D00BF220071B782 /* SVGAnimateColorElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B22277E40D00BF1F0071B782 /* SVGAnimateColorElement.h */; };
B22279840D00BF220071B782 /* SVGAnimatedPathData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22277EE0D00BF1F0071B782 /* SVGAnimatedPathData.cpp */; };
@@ -3500,7 +3500,7 @@
B2227A930D00BF220071B782 /* SVGPolylineElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22278FD0D00BF210071B782 /* SVGPolylineElement.cpp */; };
B2227A940D00BF220071B782 /* SVGPolylineElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B22278FE0D00BF210071B782 /* SVGPolylineElement.h */; };
B2227A960D00BF220071B782 /* SVGPreserveAspectRatio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22279000D00BF210071B782 /* SVGPreserveAspectRatio.cpp */; };
- B2227A970D00BF220071B782 /* SVGPreserveAspectRatio.h in Headers */ = {isa = PBXBuildFile; fileRef = B22279010D00BF210071B782 /* SVGPreserveAspectRatio.h */; };
+ B2227A970D00BF220071B782 /* SVGPreserveAspectRatio.h in Headers */ = {isa = PBXBuildFile; fileRef = B22279010D00BF210071B782 /* SVGPreserveAspectRatio.h */; settings = {ATTRIBUTES = (Private, ); }; };
B2227A990D00BF220071B782 /* SVGRadialGradientElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22279030D00BF210071B782 /* SVGRadialGradientElement.cpp */; };
B2227A9A0D00BF220071B782 /* SVGRadialGradientElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B22279040D00BF210071B782 /* SVGRadialGradientElement.h */; };
B2227A9D0D00BF220071B782 /* SVGRectElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22279070D00BF210071B782 /* SVGRectElement.cpp */; };
@@ -4824,6 +4824,7 @@
dstPath = Versions/A/PrivateHeaders;
dstSubfolderSpec = 1;
files = (
+ 08C7A2C710DC7462002D368B /* SVGNames.h in Copy Generated Headers */,
1CCA732210ADD44A00FD440D /* DOMHTMLInputElementPrivate.h in Copy Generated Headers */,
5DF7F5C20F01F92A00526B4B /* CSSPropertyNames.h in Copy Generated Headers */,
8538F0300AD71CDB006A81D1 /* DOMAbstractView.h in Copy Generated Headers */,
@@ -5336,6 +5337,7 @@
08C4C5150EF19A4000E4840F /* WMLImageElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMLImageElement.h; sourceTree = "<group>"; };
08C4C5160EF19A4000E4840F /* WMLImageLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WMLImageLoader.cpp; sourceTree = "<group>"; };
08C4C5170EF19A4000E4840F /* WMLImageLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMLImageLoader.h; sourceTree = "<group>"; };
+ 08C7A2C310DC7431002D368B /* SVGNames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SVGNames.h; path = SVGNames.h; sourceTree = SOURCE_ROOT; };
08C925170FCC7C4A00480DEC /* FilterEffect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FilterEffect.cpp; path = filters/FilterEffect.cpp; sourceTree = "<group>"; };
08C925180FCC7C4A00480DEC /* FilterEffect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FilterEffect.h; path = filters/FilterEffect.h; sourceTree = "<group>"; };
08CD61B80ED3929C002DDF51 /* WMLTaskElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WMLTaskElement.cpp; sourceTree = "<group>"; };
@@ -10101,6 +10103,7 @@
0867D691FE84028FC02AAC07 /* WebKit */ = {
isa = PBXGroup;
children = (
+ 08C7A2C310DC7431002D368B /* SVGNames.h */,
65C97AF208EA908800ACD273 /* config.h */,
EDEC98020AED7E170059137F /* WebCorePrefix.h */,
9307061309E0CA8200B17FE4 /* DerivedSources.make */,
@@ -17971,7 +17974,6 @@
B2227A4B0D00BF220071B782 /* SVGMetadataElement.h in Headers */,
B2A1F2B10CEF0ABF00442F6A /* SVGMissingGlyphElement.h in Headers */,
B2227A4E0D00BF220071B782 /* SVGMPathElement.h in Headers */,
- 6565820009D1508D000E61D7 /* SVGNames.h in Headers */,
B2227A510D00BF220071B782 /* SVGNumberList.h in Headers */,
B2227A540D00BF220071B782 /* SVGPaint.h in Headers */,
B25599A70D00D8BA00BB825C /* SVGPaintServer.h in Headers */,
diff --git a/WebCore/bindings/scripts/CodeGenerator.pm b/WebCore/bindings/scripts/CodeGenerator.pm
index c1cb0a0..54c39d5 100644
--- a/WebCore/bindings/scripts/CodeGenerator.pm
+++ b/WebCore/bindings/scripts/CodeGenerator.pm
@@ -46,7 +46,7 @@ my %primitiveTypeHash = ("int" => 1, "short" => 1, "long" => 1, "long long" => 1
"boolean" => 1, "void" => 1);
my %podTypeHash = ("SVGNumber" => 1, "SVGTransform" => 1);
-my %podTypesWithWritablePropertiesHash = ("SVGLength" => 1, "SVGMatrix" => 1, "SVGPoint" => 1, "SVGRect" => 1);
+my %podTypesWithWritablePropertiesHash = ("SVGAngle" => 1, "SVGLength" => 1, "SVGMatrix" => 1, "SVGPoint" => 1, "SVGPreserveAspectRatio" => 1, "SVGRect" => 1);
my %stringTypeHash = ("DOMString" => 1, "AtomicString" => 1);
my %nonPointerTypeHash = ("DOMTimeStamp" => 1, "CompareHow" => 1, "SVGPaintType" => 1);
diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm
index ca4b03c..5e0f58e 100644
--- a/WebCore/bindings/scripts/CodeGeneratorJS.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm
@@ -1824,10 +1824,12 @@ my %nativeType = (
"CompareHow" => "Range::CompareHow",
"DOMString" => "const UString&",
"NodeFilter" => "RefPtr<NodeFilter>",
+ "SVGAngle" => "SVGAngle",
"SVGLength" => "SVGLength",
"SVGMatrix" => "TransformationMatrix",
"SVGNumber" => "float",
"SVGPaintType" => "SVGPaint::SVGPaintType",
+ "SVGPreserveAspectRatio" => "SVGPreserveAspectRatio",
"SVGPoint" => "FloatPoint",
"SVGRect" => "FloatRect",
"SVGTransform" => "SVGTransform",
diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm
index 7507fcb..8ee35b3 100644
--- a/WebCore/bindings/scripts/CodeGeneratorV8.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm
@@ -1909,7 +1909,6 @@ sub IsRefPtrType
return 1 if $type eq "XPathNSResolver";
return 1 if $type eq "XPathResult";
- return 1 if $type eq "SVGAngle";
return 1 if $type eq "SVGElementInstance";
return 1 if $type eq "SVGElementInstanceList";
return 1 if $type =~ /^SVGPathSeg/;
@@ -1966,7 +1965,9 @@ sub GetNativeType
return "TransformationMatrix" if $type eq "SVGMatrix";
return "SVGTransform" if $type eq "SVGTransform";
return "SVGLength" if $type eq "SVGLength";
+ return "SVGAngle" if $type eq "SVGAngle";
return "double" if $type eq "SVGNumber";
+ return "SVGPreserveAspectRatio" if $type eq "SVGPreserveAspectRatio";
return "SVGPaint::SVGPaintType" if $type eq "SVGPaintType";
return "DOMTimeStamp" if $type eq "DOMTimeStamp";
return "unsigned" if $type eq "unsigned int";
@@ -2024,7 +2025,7 @@ my %typeCanFailConversion = (
"Range" => 0,
"SQLResultSet" => 0,
"Storage" => 0,
- "SVGAngle" => 0,
+ "SVGAngle" => 1,
"SVGElement" => 0,
"SVGLength" => 1,
"SVGMatrix" => 1,
@@ -2032,6 +2033,7 @@ my %typeCanFailConversion = (
"SVGPaintType" => 0,
"SVGPathSeg" => 0,
"SVGPoint" => 1,
+ "SVGPreserveAspectRatio" => 1,
"SVGRect" => 1,
"SVGTransform" => 1,
"VoidCallback" => 1,
@@ -2064,9 +2066,11 @@ sub BasicTypeCanFailConversion
my $signature = shift;
my $type = GetTypeFromSignature($signature);
+ return 1 if $type eq "SVGAngle";
return 1 if $type eq "SVGLength";
return 1 if $type eq "SVGMatrix";
return 1 if $type eq "SVGPoint";
+ return 1 if $type eq "SVGPreserveAspectRatio";
return 1 if $type eq "SVGRect";
return 1 if $type eq "SVGTransform";
return 0;
@@ -2236,8 +2240,10 @@ my %non_wrapper_types = (
'boolean' => 1,
'DOMString' => 1,
'CompareHow' => 1,
+ 'SVGAngle' => 1,
'SVGRect' => 1,
'SVGPoint' => 1,
+ 'SVGPreserveAspectRatio' => 1,
'SVGMatrix' => 1,
'SVGTransform' => 1,
'SVGLength' => 1,
diff --git a/WebCore/bindings/v8/V8Index.h b/WebCore/bindings/v8/V8Index.h
index 3fff66e..2cb3c29 100644
--- a/WebCore/bindings/v8/V8Index.h
+++ b/WebCore/bindings/v8/V8Index.h
@@ -517,7 +517,6 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)();
#if ENABLE(SVG)
// SVG_OBJECT_TYPES are svg non-node, non-pod types.
#define SVG_OBJECT_TYPES(V) \
- V(SVGANGLE, SVGAngle) \
V(SVGANIMATEDANGLE, SVGAnimatedAngle) \
V(SVGANIMATEDBOOLEAN, SVGAnimatedBoolean) \
V(SVGANIMATEDENUMERATION, SVGAnimatedEnumeration) \
@@ -559,7 +558,6 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)();
V(SVGPATHSEGMOVETOABS, SVGPathSegMovetoAbs) \
V(SVGPATHSEGMOVETOREL, SVGPathSegMovetoRel) \
V(SVGPOINTLIST, SVGPointList) \
- V(SVGPRESERVEASPECTRATIO, SVGPreserveAspectRatio) \
V(SVGRENDERINGINTENT, SVGRenderingIntent) \
V(SVGSTRINGLIST, SVGStringList) \
V(SVGTRANSFORMLIST, SVGTransformList) \
@@ -568,7 +566,9 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)();
// SVG POD types should list all types whose IDL has PODType declaration.
#define SVG_POD_TYPES(V) \
+ V(SVGANGLE, SVGAngle) \
V(SVGLENGTH, SVGLength) \
+ V(SVGPRESERVEASPECTRATIO, SVGPreserveAspectRatio) \
V(SVGTRANSFORM, SVGTransform) \
V(SVGMATRIX, SVGMatrix) \
V(SVGNUMBER, SVGNumber) \
@@ -577,7 +577,9 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)();
// POD types can have different implementation names, see CodeGenerateV8.pm.
#define SVG_POD_NATIVE_TYPES(V) \
+ V(SVGANGLE, SVGAngle) \
V(SVGLENGTH, SVGLength) \
+ V(SVGPRESERVEASPECTRATIO, SVGPreserveAspectRatio) \
V(SVGTRANSFORM, SVGTransform) \
V(SVGMATRIX, TransformationMatrix) \
V(SVGNUMBER, float) \
diff --git a/WebCore/rendering/RenderSVGImage.cpp b/WebCore/rendering/RenderSVGImage.cpp
index 41a1a10..32d9654 100644
--- a/WebCore/rendering/RenderSVGImage.cpp
+++ b/WebCore/rendering/RenderSVGImage.cpp
@@ -47,15 +47,15 @@ RenderSVGImage::RenderSVGImage(SVGImageElement* impl)
{
}
-void RenderSVGImage::adjustRectsForAspectRatio(FloatRect& destRect, FloatRect& srcRect, SVGPreserveAspectRatio* aspectRatio)
+void RenderSVGImage::adjustRectsForAspectRatio(FloatRect& destRect, FloatRect& srcRect, const SVGPreserveAspectRatio& aspectRatio)
{
float origDestWidth = destRect.width();
float origDestHeight = destRect.height();
- if (aspectRatio->meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_MEET) {
+ if (aspectRatio.meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_MEET) {
float widthToHeightMultiplier = srcRect.height() / srcRect.width();
if (origDestHeight > (origDestWidth * widthToHeightMultiplier)) {
destRect.setHeight(origDestWidth * widthToHeightMultiplier);
- switch (aspectRatio->align()) {
+ switch (aspectRatio.align()) {
case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMID:
case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID:
case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMID:
@@ -70,7 +70,7 @@ void RenderSVGImage::adjustRectsForAspectRatio(FloatRect& destRect, FloatRect& s
}
if (origDestWidth > (origDestHeight / widthToHeightMultiplier)) {
destRect.setWidth(origDestHeight / widthToHeightMultiplier);
- switch (aspectRatio->align()) {
+ switch (aspectRatio.align()) {
case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMIN:
case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID:
case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMAX:
@@ -83,13 +83,13 @@ void RenderSVGImage::adjustRectsForAspectRatio(FloatRect& destRect, FloatRect& s
break;
}
}
- } else if (aspectRatio->meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_SLICE) {
+ } else if (aspectRatio.meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_SLICE) {
float widthToHeightMultiplier = srcRect.height() / srcRect.width();
// if the destination height is less than the height of the image we'll be drawing
if (origDestHeight < (origDestWidth * widthToHeightMultiplier)) {
float destToSrcMultiplier = srcRect.width() / destRect.width();
srcRect.setHeight(destRect.height() * destToSrcMultiplier);
- switch (aspectRatio->align()) {
+ switch (aspectRatio.align()) {
case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMID:
case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID:
case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMID:
@@ -106,7 +106,7 @@ void RenderSVGImage::adjustRectsForAspectRatio(FloatRect& destRect, FloatRect& s
if (origDestWidth < (origDestHeight / widthToHeightMultiplier)) {
float destToSrcMultiplier = srcRect.height() / destRect.height();
srcRect.setWidth(destRect.width() * destToSrcMultiplier);
- switch (aspectRatio->align()) {
+ switch (aspectRatio.align()) {
case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMIN:
case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID:
case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMAX:
@@ -163,7 +163,7 @@ void RenderSVGImage::paint(PaintInfo& paintInfo, int, int)
FloatRect srcRect(0, 0, image()->width(), image()->height());
SVGImageElement* imageElt = static_cast<SVGImageElement*>(node());
- if (imageElt->preserveAspectRatio()->align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
+ if (imageElt->preserveAspectRatio().align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
adjustRectsForAspectRatio(destRect, srcRect, imageElt->preserveAspectRatio());
paintInfo.context->drawImage(image(), DeviceColorSpace, destRect, srcRect);
diff --git a/WebCore/rendering/RenderSVGImage.h b/WebCore/rendering/RenderSVGImage.h
index ef11719..15ffe57 100644
--- a/WebCore/rendering/RenderSVGImage.h
+++ b/WebCore/rendering/RenderSVGImage.h
@@ -24,16 +24,15 @@
#define RenderSVGImage_h
#if ENABLE(SVG)
-
-#include "TransformationMatrix.h"
#include "FloatRect.h"
#include "RenderImage.h"
+#include "SVGPreserveAspectRatio.h"
#include "SVGRenderSupport.h"
+#include "TransformationMatrix.h"
namespace WebCore {
class SVGImageElement;
- class SVGPreserveAspectRatio;
class RenderSVGImage : public RenderImage, SVGRenderBase {
public:
@@ -58,7 +57,7 @@ namespace WebCore {
virtual void addFocusRingRects(GraphicsContext*, int tx, int ty);
virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
- void adjustRectsForAspectRatio(FloatRect& destRect, FloatRect& srcRect, SVGPreserveAspectRatio*);
+ void adjustRectsForAspectRatio(FloatRect& destRect, FloatRect& srcRect, const SVGPreserveAspectRatio&);
virtual void layout();
virtual void paint(PaintInfo&, int parentX, int parentY);
diff --git a/WebCore/svg/SVGAngle.h b/WebCore/svg/SVGAngle.h
index 13b9fd4..9841098 100644
--- a/WebCore/svg/SVGAngle.h
+++ b/WebCore/svg/SVGAngle.h
@@ -29,14 +29,11 @@ namespace WebCore {
class SVGStyledElement;
- class SVGAngle : public RefCounted<SVGAngle> {
+ class SVGAngle {
public:
- static PassRefPtr<SVGAngle> create()
- {
- return adoptRef(new SVGAngle);
- }
+ SVGAngle();
virtual ~SVGAngle();
-
+
enum SVGAngleType {
SVG_ANGLETYPE_UNKNOWN = 0,
SVG_ANGLETYPE_UNSPECIFIED = 1,
@@ -63,8 +60,6 @@ namespace WebCore {
const QualifiedName& associatedAttributeName() const { return SVGNames::orientAttr; }
private:
- SVGAngle();
-
SVGAngleType m_unitType;
float m_value;
float m_valueInSpecifiedUnits;
diff --git a/WebCore/svg/SVGAngle.idl b/WebCore/svg/SVGAngle.idl
index 1a05646..591d329 100644
--- a/WebCore/svg/SVGAngle.idl
+++ b/WebCore/svg/SVGAngle.idl
@@ -22,7 +22,7 @@
module svg {
- interface [Conditional=SVG, GenerateConstructor] SVGAngle {
+ interface [Conditional=SVG, GenerateConstructor, PODType=SVGAngle] SVGAngle {
// Angle Unit Types
const unsigned short SVG_ANGLETYPE_UNKNOWN = 0;
const unsigned short SVG_ANGLETYPE_UNSPECIFIED = 1;
diff --git a/WebCore/svg/SVGAnimatedTemplate.h b/WebCore/svg/SVGAnimatedTemplate.h
index d65fe0b..99215ad 100644
--- a/WebCore/svg/SVGAnimatedTemplate.h
+++ b/WebCore/svg/SVGAnimatedTemplate.h
@@ -24,7 +24,9 @@
#if ENABLE(SVG)
#include "AtomicString.h"
#include "FloatRect.h"
+#include "SVGAngle.h"
#include "SVGLength.h"
+#include "SVGPreserveAspectRatio.h"
#include <wtf/HashMap.h>
namespace WebCore {
@@ -203,6 +205,15 @@ namespace WebCore {
};
template<>
+ struct SVGAnimatedTypeValue<SVGAngle> : Noncopyable {
+ typedef SVGAngle StorableType;
+ typedef SVGAngle DecoratedType;
+
+ static SVGAngle null() { return SVGAngle(); }
+ static String toString(const SVGAngle& type) { return type.valueAsString(); }
+ };
+
+ template<>
struct SVGAnimatedTypeValue<SVGLength> : Noncopyable {
typedef SVGLength StorableType;
typedef SVGLength DecoratedType;
@@ -212,6 +223,15 @@ namespace WebCore {
};
template<>
+ struct SVGAnimatedTypeValue<SVGPreserveAspectRatio> : Noncopyable {
+ typedef SVGPreserveAspectRatio StorableType;
+ typedef SVGPreserveAspectRatio DecoratedType;
+
+ static SVGPreserveAspectRatio null() { return SVGPreserveAspectRatio(); }
+ static String toString(const SVGPreserveAspectRatio& type) { return type.valueAsString(); }
+ };
+
+ template<>
struct SVGAnimatedTypeValue<float> : Noncopyable {
typedef float StorableType;
typedef float DecoratedType;
@@ -239,7 +259,7 @@ namespace WebCore {
};
// Common type definitions, to ease IDL generation.
- typedef SVGAnimatedTemplate<SVGAngle*> SVGAnimatedAngle;
+ typedef SVGAnimatedTemplate<SVGAngle> SVGAnimatedAngle;
typedef SVGAnimatedTemplate<bool> SVGAnimatedBoolean;
typedef SVGAnimatedTemplate<int> SVGAnimatedEnumeration;
typedef SVGAnimatedTemplate<long> SVGAnimatedInteger;
@@ -247,7 +267,7 @@ namespace WebCore {
typedef SVGAnimatedTemplate<SVGLengthList*> SVGAnimatedLengthList;
typedef SVGAnimatedTemplate<float> SVGAnimatedNumber;
typedef SVGAnimatedTemplate<SVGNumberList*> SVGAnimatedNumberList;
- typedef SVGAnimatedTemplate<SVGPreserveAspectRatio*> SVGAnimatedPreserveAspectRatio;
+ typedef SVGAnimatedTemplate<SVGPreserveAspectRatio> SVGAnimatedPreserveAspectRatio;
typedef SVGAnimatedTemplate<FloatRect> SVGAnimatedRect;
typedef SVGAnimatedTemplate<String> SVGAnimatedString;
typedef SVGAnimatedTemplate<SVGTransformList*> SVGAnimatedTransformList;
diff --git a/WebCore/svg/SVGFEImageElement.cpp b/WebCore/svg/SVGFEImageElement.cpp
index 52531ee..d9e13e9 100644
--- a/WebCore/svg/SVGFEImageElement.cpp
+++ b/WebCore/svg/SVGFEImageElement.cpp
@@ -40,7 +40,7 @@ SVGFEImageElement::SVGFEImageElement(const QualifiedName& tagName, Document* doc
, SVGURIReference()
, SVGLangSpace()
, SVGExternalResourcesRequired()
- , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())
+ , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr)
, m_href(this, XLinkNames::hrefAttr)
, m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false)
{
@@ -55,11 +55,9 @@ SVGFEImageElement::~SVGFEImageElement()
void SVGFEImageElement::parseMappedAttribute(MappedAttribute* attr)
{
const String& value = attr->value();
- if (attr->name() == SVGNames::preserveAspectRatioAttr) {
- const UChar* c = value.characters();
- const UChar* end = c + value.length();
- preserveAspectRatioBaseValue()->parsePreserveAspectRatio(c, end);
- } else {
+ if (attr->name() == SVGNames::preserveAspectRatioAttr)
+ SVGPreserveAspectRatio::parsePreserveAspectRatio(this, value);
+ else {
if (SVGURIReference::parseMappedAttribute(attr)) {
if (!href().startsWith("#")) {
// FIXME: this code needs to special-case url fragments and later look them up using getElementById instead of loading them here
diff --git a/WebCore/svg/SVGFitToViewBox.cpp b/WebCore/svg/SVGFitToViewBox.cpp
index c566a8f..561bf59 100644
--- a/WebCore/svg/SVGFitToViewBox.cpp
+++ b/WebCore/svg/SVGFitToViewBox.cpp
@@ -77,13 +77,12 @@ bool SVGFitToViewBox::parseViewBox(Document* doc, const UChar*& c, const UChar*
return true;
}
-TransformationMatrix SVGFitToViewBox::viewBoxToViewTransform(const FloatRect& viewBoxRect, SVGPreserveAspectRatio* preserveAspectRatio, float viewWidth, float viewHeight)
+TransformationMatrix SVGFitToViewBox::viewBoxToViewTransform(const FloatRect& viewBoxRect, const SVGPreserveAspectRatio& preserveAspectRatio, float viewWidth, float viewHeight)
{
- ASSERT(preserveAspectRatio);
if (!viewBoxRect.width() || !viewBoxRect.height())
return TransformationMatrix();
- return preserveAspectRatio->getCTM(viewBoxRect.x(), viewBoxRect.y(), viewBoxRect.width(), viewBoxRect.height(), 0, 0, viewWidth, viewHeight);
+ return preserveAspectRatio.getCTM(viewBoxRect.x(), viewBoxRect.y(), viewBoxRect.width(), viewBoxRect.height(), 0, 0, viewWidth, viewHeight);
}
bool SVGFitToViewBox::parseMappedAttribute(Document* document, MappedAttribute* attr)
@@ -96,9 +95,7 @@ bool SVGFitToViewBox::parseMappedAttribute(Document* document, MappedAttribute*
setViewBoxBaseValue(FloatRect(x, y, w, h));
return true;
} else if (attr->name() == SVGNames::preserveAspectRatioAttr) {
- const UChar* c = attr->value().characters();
- const UChar* end = c + attr->value().length();
- preserveAspectRatioBaseValue()->parsePreserveAspectRatio(c, end);
+ SVGPreserveAspectRatio::parsePreserveAspectRatio(this, attr->value());
return true;
}
diff --git a/WebCore/svg/SVGFitToViewBox.h b/WebCore/svg/SVGFitToViewBox.h
index 503a0ef..2c31fa0 100644
--- a/WebCore/svg/SVGFitToViewBox.h
+++ b/WebCore/svg/SVGFitToViewBox.h
@@ -37,16 +37,13 @@ namespace WebCore {
virtual ~SVGFitToViewBox();
bool parseViewBox(Document*, const UChar*& start, const UChar* end, float& x, float& y, float& w, float& h, bool validate = true);
- static TransformationMatrix viewBoxToViewTransform(const FloatRect& viewBoxRect, SVGPreserveAspectRatio*, float viewWidth, float viewHeight);
+ static TransformationMatrix viewBoxToViewTransform(const FloatRect& viewBoxRect, const SVGPreserveAspectRatio&, float viewWidth, float viewHeight);
bool parseMappedAttribute(Document*, MappedAttribute*);
bool isKnownAttribute(const QualifiedName&);
- protected:
- virtual SVGAnimatedTypeValue<FloatRect>::DecoratedType viewBoxBaseValue() const = 0;
- virtual void setViewBoxBaseValue(SVGAnimatedTypeValue<FloatRect>::DecoratedType type) = 0;
-
- virtual SVGAnimatedTypeValue<SVGPreserveAspectRatio>::DecoratedType preserveAspectRatioBaseValue() const = 0;
+ virtual void setViewBoxBaseValue(SVGAnimatedTypeValue<FloatRect>::DecoratedType) = 0;
+ virtual void setPreserveAspectRatioBaseValue(SVGAnimatedTypeValue<SVGPreserveAspectRatio>::DecoratedType) = 0;
};
} // namespace WebCore
diff --git a/WebCore/svg/SVGImageElement.cpp b/WebCore/svg/SVGImageElement.cpp
index e29846c..a636ff6 100644
--- a/WebCore/svg/SVGImageElement.cpp
+++ b/WebCore/svg/SVGImageElement.cpp
@@ -45,7 +45,7 @@ SVGImageElement::SVGImageElement(const QualifiedName& tagName, Document* doc)
, m_y(this, SVGNames::yAttr, LengthModeHeight)
, m_width(this, SVGNames::widthAttr, LengthModeWidth)
, m_height(this, SVGNames::heightAttr, LengthModeHeight)
- , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())
+ , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr)
, m_href(this, XLinkNames::hrefAttr)
, m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false)
, m_imageLoader(this)
@@ -62,11 +62,9 @@ void SVGImageElement::parseMappedAttribute(MappedAttribute *attr)
setXBaseValue(SVGLength(LengthModeWidth, attr->value()));
else if (attr->name() == SVGNames::yAttr)
setYBaseValue(SVGLength(LengthModeHeight, attr->value()));
- else if (attr->name() == SVGNames::preserveAspectRatioAttr) {
- const UChar* c = attr->value().characters();
- const UChar* end = c + attr->value().length();
- preserveAspectRatioBaseValue()->parsePreserveAspectRatio(c, end);
- } else if (attr->name() == SVGNames::widthAttr) {
+ else if (attr->name() == SVGNames::preserveAspectRatioAttr)
+ SVGPreserveAspectRatio::parsePreserveAspectRatio(this, attr->value());
+ else if (attr->name() == SVGNames::widthAttr) {
setWidthBaseValue(SVGLength(LengthModeWidth, attr->value()));
addCSSProperty(attr, CSSPropertyWidth, attr->value());
if (widthBaseValue().value(this) < 0.0)
diff --git a/WebCore/svg/SVGMarkerElement.cpp b/WebCore/svg/SVGMarkerElement.cpp
index 2e96926..5ef3d5c 100644
--- a/WebCore/svg/SVGMarkerElement.cpp
+++ b/WebCore/svg/SVGMarkerElement.cpp
@@ -26,7 +26,6 @@
#include "MappedAttribute.h"
#include "PlatformString.h"
#include "RenderSVGViewportContainer.h"
-#include "SVGAngle.h"
#include "SVGFitToViewBox.h"
#include "SVGLength.h"
#include "SVGNames.h"
@@ -49,10 +48,10 @@ SVGMarkerElement::SVGMarkerElement(const QualifiedName& tagName, Document* doc)
, m_markerHeight(this, SVGNames::markerHeightAttr, LengthModeHeight, "3")
, m_markerUnits(this, SVGNames::markerUnitsAttr, SVG_MARKERUNITS_STROKEWIDTH)
, m_orientType(this, SVGNames::orientAttr, SVG_MARKER_ORIENT_ANGLE)
- , m_orientAngle(this, SVGNames::orientAttr, SVGAngle::create())
+ , m_orientAngle(this, SVGNames::orientAttr)
, m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false)
, m_viewBox(this, SVGNames::viewBoxAttr)
- , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())
+ , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr)
{
// Spec: If the markerWidth/markerHeight attribute is not specified, the effect is as if a value of "3" were specified.
}
@@ -87,16 +86,16 @@ void SVGMarkerElement::parseMappedAttribute(MappedAttribute* attr)
else if (attr->name() == SVGNames::markerHeightAttr)
setMarkerHeightBaseValue(SVGLength(LengthModeHeight, attr->value()));
else if (attr->name() == SVGNames::orientAttr) {
- RefPtr<SVGAngle> angle = SVGAngle::create();
+ SVGAngle angle;
if (attr->value() == "auto")
setOrientTypeBaseValue(SVG_MARKER_ORIENT_AUTO);
else {
- angle->setValueAsString(attr->value());
+ angle.setValueAsString(attr->value());
setOrientTypeBaseValue(SVG_MARKER_ORIENT_ANGLE);
}
- setOrientAngleBaseValue(angle.get());
+ setOrientAngleBaseValue(angle);
} else {
if (SVGLangSpace::parseMappedAttribute(attr))
return;
@@ -146,9 +145,7 @@ void SVGMarkerElement::childrenChanged(bool changedByParser, Node* beforeChange,
void SVGMarkerElement::setOrientToAuto()
{
setOrientTypeBaseValue(SVG_MARKER_ORIENT_AUTO);
-
- RefPtr<SVGAngle> angle = SVGAngle::create();
- setOrientAngleBaseValue(angle.get());
+ setOrientAngleBaseValue(SVGAngle());
if (!m_marker)
return;
@@ -159,10 +156,10 @@ void SVGMarkerElement::setOrientToAuto()
m_marker->invalidate();
}
-void SVGMarkerElement::setOrientToAngle(PassRefPtr<SVGAngle> angle)
+void SVGMarkerElement::setOrientToAngle(const SVGAngle& angle)
{
setOrientTypeBaseValue(SVG_MARKER_ORIENT_ANGLE);
- setOrientAngleBaseValue(angle.get());
+ setOrientAngleBaseValue(angle);
if (!m_marker)
return;
@@ -180,10 +177,9 @@ SVGResource* SVGMarkerElement::canvasResource()
m_marker->setMarker(toRenderSVGViewportContainer(renderer()));
- if (orientType() == SVG_MARKER_ORIENT_ANGLE) {
- if (orientAngle())
- m_marker->setAngle(orientAngle()->value());
- } else
+ if (orientType() == SVG_MARKER_ORIENT_ANGLE)
+ m_marker->setAngle(orientAngle().value());
+ else
m_marker->setAutoAngle();
m_marker->setRef(refX().value(this), refY().value(this));
diff --git a/WebCore/svg/SVGMarkerElement.h b/WebCore/svg/SVGMarkerElement.h
index 7e08a96..0898aac 100644
--- a/WebCore/svg/SVGMarkerElement.h
+++ b/WebCore/svg/SVGMarkerElement.h
@@ -33,7 +33,6 @@
namespace WebCore {
class Document;
- class SVGAngle;
extern char SVGOrientTypeAttrIdentifier[];
extern char SVGOrientAngleAttrIdentifier[];
@@ -61,7 +60,7 @@ namespace WebCore {
TransformationMatrix viewBoxToViewTransform(float viewWidth, float viewHeight) const;
void setOrientToAuto();
- void setOrientToAngle(PassRefPtr<SVGAngle>);
+ void setOrientToAngle(const SVGAngle&);
virtual void parseMappedAttribute(MappedAttribute*);
virtual void svgAttributeChanged(const QualifiedName&);
diff --git a/WebCore/svg/SVGPatternElement.cpp b/WebCore/svg/SVGPatternElement.cpp
index a10c2c2..2ec71bb 100644
--- a/WebCore/svg/SVGPatternElement.cpp
+++ b/WebCore/svg/SVGPatternElement.cpp
@@ -65,7 +65,7 @@ SVGPatternElement::SVGPatternElement(const QualifiedName& tagName, Document* doc
, m_href(this, XLinkNames::hrefAttr)
, m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false)
, m_viewBox(this, SVGNames::viewBoxAttr)
- , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())
+ , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr)
{
}
diff --git a/WebCore/svg/SVGPreserveAspectRatio.cpp b/WebCore/svg/SVGPreserveAspectRatio.cpp
index e6452c3..4fd1281 100644
--- a/WebCore/svg/SVGPreserveAspectRatio.cpp
+++ b/WebCore/svg/SVGPreserveAspectRatio.cpp
@@ -60,11 +60,12 @@ unsigned short SVGPreserveAspectRatio::meetOrSlice() const
return m_meetOrSlice;
}
-bool SVGPreserveAspectRatio::parsePreserveAspectRatio(const UChar*& currParam, const UChar* end, bool validate)
+SVGPreserveAspectRatio SVGPreserveAspectRatio::parsePreserveAspectRatio(const UChar*& currParam, const UChar* end, bool validate, bool& result)
{
- SVGPreserveAspectRatioType align = SVG_PRESERVEASPECTRATIO_NONE;
- SVGMeetOrSliceType meetOrSlice = SVG_MEETORSLICE_MEET;
- bool ret = false;
+ SVGPreserveAspectRatio aspectRatio;
+ aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_NONE;
+ aspectRatio.m_meetOrSlice = SVG_MEETORSLICE_MEET;
+ result = false;
if (!skipOptionalSpaces(currParam, end))
goto bail_out;
@@ -90,25 +91,25 @@ bool SVGPreserveAspectRatio::parsePreserveAspectRatio(const UChar*& currParam, c
if (currParam[3] == 'n') {
if (currParam[6] == 'i') {
if (currParam[7] == 'n')
- align = SVG_PRESERVEASPECTRATIO_XMINYMIN;
+ aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMINYMIN;
else if (currParam[7] == 'd')
- align = SVG_PRESERVEASPECTRATIO_XMINYMID;
+ aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMINYMID;
else
goto bail_out;
} else if (currParam[6] == 'a' && currParam[7] == 'x')
- align = SVG_PRESERVEASPECTRATIO_XMINYMAX;
+ aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMINYMAX;
else
goto bail_out;
} else if (currParam[3] == 'd') {
if (currParam[6] == 'i') {
if (currParam[7] == 'n')
- align = SVG_PRESERVEASPECTRATIO_XMIDYMIN;
+ aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMIDYMIN;
else if (currParam[7] == 'd')
- align = SVG_PRESERVEASPECTRATIO_XMIDYMID;
+ aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMIDYMID;
else
goto bail_out;
} else if (currParam[6] == 'a' && currParam[7] == 'x')
- align = SVG_PRESERVEASPECTRATIO_XMIDYMAX;
+ aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMIDYMAX;
else
goto bail_out;
} else
@@ -116,13 +117,13 @@ bool SVGPreserveAspectRatio::parsePreserveAspectRatio(const UChar*& currParam, c
} else if (currParam[2] == 'a' && currParam[3] == 'x') {
if (currParam[6] == 'i') {
if (currParam[7] == 'n')
- align = SVG_PRESERVEASPECTRATIO_XMAXYMIN;
+ aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMAXYMIN;
else if (currParam[7] == 'd')
- align = SVG_PRESERVEASPECTRATIO_XMAXYMID;
+ aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMAXYMID;
else
goto bail_out;
} else if (currParam[6] == 'a' && currParam[7] == 'x')
- align = SVG_PRESERVEASPECTRATIO_XMAXYMAX;
+ aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMAXYMAX;
else
goto bail_out;
} else
@@ -141,31 +142,26 @@ bool SVGPreserveAspectRatio::parsePreserveAspectRatio(const UChar*& currParam, c
if (!skipString(currParam, end, "slice"))
goto bail_out;
skipOptionalSpaces(currParam, end);
- if (align != SVG_PRESERVEASPECTRATIO_NONE)
- meetOrSlice = SVG_MEETORSLICE_SLICE;
+ if (aspectRatio.m_align != SVG_PRESERVEASPECTRATIO_NONE)
+ aspectRatio.m_meetOrSlice = SVG_MEETORSLICE_SLICE;
}
}
if (end != currParam && validate) {
bail_out:
// FIXME: Should the two values be set to UNKNOWN instead?
- align = SVG_PRESERVEASPECTRATIO_NONE;
- meetOrSlice = SVG_MEETORSLICE_MEET;
+ aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_NONE;
+ aspectRatio.m_meetOrSlice = SVG_MEETORSLICE_MEET;
} else
- ret = true;
+ result = true;
- if (m_align == align && m_meetOrSlice == meetOrSlice)
- return ret;
-
- m_align = align;
- m_meetOrSlice = meetOrSlice;
- return ret;
+ return aspectRatio;
}
TransformationMatrix SVGPreserveAspectRatio::getCTM(double logicX, double logicY,
double logicWidth, double logicHeight,
double /*physX*/, double /*physY*/,
- double physWidth, double physHeight)
+ double physWidth, double physHeight) const
{
TransformationMatrix temp;
diff --git a/WebCore/svg/SVGPreserveAspectRatio.h b/WebCore/svg/SVGPreserveAspectRatio.h
index 18a89dd..17db42d 100644
--- a/WebCore/svg/SVGPreserveAspectRatio.h
+++ b/WebCore/svg/SVGPreserveAspectRatio.h
@@ -25,18 +25,13 @@
#include "PlatformString.h"
#include "SVGNames.h"
-#include <wtf/RefCounted.h>
-
namespace WebCore {
class String;
class TransformationMatrix;
- class SVGStyledElement;
- class SVGPreserveAspectRatio : public RefCounted<SVGPreserveAspectRatio> {
+ class SVGPreserveAspectRatio {
public:
- static PassRefPtr<SVGPreserveAspectRatio> create() { return adoptRef(new SVGPreserveAspectRatio); }
-
enum SVGPreserveAspectRatioType {
SVG_PRESERVEASPECTRATIO_UNKNOWN = 0,
SVG_PRESERVEASPECTRATIO_NONE = 1,
@@ -57,6 +52,7 @@ namespace WebCore {
SVG_MEETORSLICE_SLICE = 2
};
+ SVGPreserveAspectRatio();
virtual ~SVGPreserveAspectRatio();
void setAlign(unsigned short);
@@ -68,17 +64,26 @@ namespace WebCore {
TransformationMatrix getCTM(double logicX, double logicY,
double logicWidth, double logicHeight,
double physX, double physY,
- double physWidth, double physHeight);
+ double physWidth, double physHeight) const;
+
+ template<class Consumer>
+ static bool parsePreserveAspectRatio(Consumer* consumer, const String& value, bool validate = true)
+ {
+ bool result = false;
+ const UChar* begin = value.characters();
+ const UChar* end = begin + value.length();
+ consumer->setPreserveAspectRatioBaseValue(parsePreserveAspectRatio(begin, end, validate, result));
+ return result;
+ }
+
+ // It's recommended to use the method above, only SVGViewSpec needs this parsing method
+ static SVGPreserveAspectRatio parsePreserveAspectRatio(const UChar*& currParam, const UChar* end, bool validate, bool& result);
- // Helper
- bool parsePreserveAspectRatio(const UChar*& currParam, const UChar* end, bool validate = true);
String valueAsString() const;
const QualifiedName& associatedAttributeName() const { return SVGNames::preserveAspectRatioAttr; }
private:
- SVGPreserveAspectRatio();
-
unsigned short m_align;
unsigned short m_meetOrSlice;
};
@@ -87,4 +92,3 @@ namespace WebCore {
#endif // ENABLE(SVG)
#endif // SVGPreserveAspectRatio_h
-
diff --git a/WebCore/svg/SVGPreserveAspectRatio.idl b/WebCore/svg/SVGPreserveAspectRatio.idl
index 066353e..1edeadf 100644
--- a/WebCore/svg/SVGPreserveAspectRatio.idl
+++ b/WebCore/svg/SVGPreserveAspectRatio.idl
@@ -25,7 +25,7 @@
module svg {
- interface [Conditional=SVG, GenerateConstructor] SVGPreserveAspectRatio {
+ interface [Conditional=SVG, GenerateConstructor, PODType=SVGPreserveAspectRatio] SVGPreserveAspectRatio {
// Alignment Types
const unsigned short SVG_PRESERVEASPECTRATIO_UNKNOWN = 0;
const unsigned short SVG_PRESERVEASPECTRATIO_NONE = 1;
diff --git a/WebCore/svg/SVGSVGElement.cpp b/WebCore/svg/SVGSVGElement.cpp
index 2d5008b..3e6cf54 100644
--- a/WebCore/svg/SVGSVGElement.cpp
+++ b/WebCore/svg/SVGSVGElement.cpp
@@ -69,7 +69,7 @@ SVGSVGElement::SVGSVGElement(const QualifiedName& tagName, Document* doc)
, m_height(this, SVGNames::heightAttr, LengthModeHeight, "100%")
, m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false)
, m_viewBox(this, SVGNames::viewBoxAttr)
- , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())
+ , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr)
, m_useCurrentView(false)
, m_timeContainer(SMILTimeContainer::create(this))
, m_viewSpec(0)
@@ -374,9 +374,9 @@ SVGLength SVGSVGElement::createSVGLength()
return SVGLength();
}
-PassRefPtr<SVGAngle> SVGSVGElement::createSVGAngle()
+SVGAngle SVGSVGElement::createSVGAngle()
{
- return SVGAngle::create();
+ return SVGAngle();
}
FloatPoint SVGSVGElement::createSVGPoint()
@@ -531,13 +531,14 @@ void SVGSVGElement::inheritViewAttributes(SVGViewElement* viewElement)
currentView()->setViewBox(viewElement->viewBox());
else
currentView()->setViewBox(viewBox());
- if (viewElement->hasAttribute(SVGNames::preserveAspectRatioAttr)) {
- currentView()->preserveAspectRatio()->setAlign(viewElement->preserveAspectRatio()->align());
- currentView()->preserveAspectRatio()->setMeetOrSlice(viewElement->preserveAspectRatio()->meetOrSlice());
- } else {
- currentView()->preserveAspectRatio()->setAlign(preserveAspectRatio()->align());
- currentView()->preserveAspectRatio()->setMeetOrSlice(preserveAspectRatio()->meetOrSlice());
- }
+
+ SVGPreserveAspectRatio aspectRatio;
+ if (viewElement->hasAttribute(SVGNames::preserveAspectRatioAttr))
+ aspectRatio = viewElement->preserveAspectRatioBaseValue();
+ else
+ aspectRatio = preserveAspectRatioBaseValue();
+ currentView()->setPreserveAspectRatioBaseValue(aspectRatio);
+
if (viewElement->hasAttribute(SVGNames::zoomAndPanAttr))
currentView()->setZoomAndPan(viewElement->zoomAndPan());
renderer()->setNeedsLayout(true);
diff --git a/WebCore/svg/SVGSVGElement.h b/WebCore/svg/SVGSVGElement.h
index f30e8f6..51eb4f6 100644
--- a/WebCore/svg/SVGSVGElement.h
+++ b/WebCore/svg/SVGSVGElement.h
@@ -105,7 +105,7 @@ namespace WebCore {
static float createSVGNumber();
static SVGLength createSVGLength();
- static PassRefPtr<SVGAngle> createSVGAngle();
+ static SVGAngle createSVGAngle();
static FloatPoint createSVGPoint();
static TransformationMatrix createSVGMatrix();
static FloatRect createSVGRect();
diff --git a/WebCore/svg/SVGSymbolElement.cpp b/WebCore/svg/SVGSymbolElement.cpp
index 6f3a644..1f8072e 100644
--- a/WebCore/svg/SVGSymbolElement.cpp
+++ b/WebCore/svg/SVGSymbolElement.cpp
@@ -34,7 +34,7 @@ SVGSymbolElement::SVGSymbolElement(const QualifiedName& tagName, Document* doc)
, SVGFitToViewBox()
, m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false)
, m_viewBox(this, SVGNames::viewBoxAttr)
- , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())
+ , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr)
{
}
diff --git a/WebCore/svg/SVGViewElement.cpp b/WebCore/svg/SVGViewElement.cpp
index 0fe6a90..0b28b21 100644
--- a/WebCore/svg/SVGViewElement.cpp
+++ b/WebCore/svg/SVGViewElement.cpp
@@ -40,7 +40,7 @@ SVGViewElement::SVGViewElement(const QualifiedName& tagName, Document* doc)
, SVGZoomAndPan()
, m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false)
, m_viewBox(this, SVGNames::viewBoxAttr)
- , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())
+ , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr)
{
}
diff --git a/WebCore/svg/SVGViewSpec.cpp b/WebCore/svg/SVGViewSpec.cpp
index e6ded33..0910a8a 100644
--- a/WebCore/svg/SVGViewSpec.cpp
+++ b/WebCore/svg/SVGViewSpec.cpp
@@ -36,7 +36,7 @@ SVGViewSpec::SVGViewSpec(const SVGSVGElement* contextElement)
, SVGZoomAndPan()
, m_contextElement(contextElement)
, m_viewBox(this, SVGNames::viewBoxAttr)
- , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())
+ , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr)
, m_transform(SVGTransformList::create(SVGNames::transformAttr))
{
}
@@ -62,9 +62,7 @@ void SVGViewSpec::setViewBoxString(const String& viewBox)
void SVGViewSpec::setPreserveAspectRatioString(const String& preserve)
{
- const UChar* c = preserve.characters();
- const UChar* end = c + preserve.length();
- preserveAspectRatioBaseValue()->parsePreserveAspectRatio(c, end);
+ SVGPreserveAspectRatio::parsePreserveAspectRatio(this, preserve);
}
void SVGViewSpec::setViewTargetString(const String& viewTargetString)
@@ -141,7 +139,9 @@ bool SVGViewSpec::parseViewSpec(const String& viewSpec)
if (currViewSpec >= end || *currViewSpec != '(')
return false;
currViewSpec++;
- if (!preserveAspectRatioBaseValue()->parsePreserveAspectRatio(currViewSpec, end, false))
+ bool result = false;
+ setPreserveAspectRatioBaseValue(SVGPreserveAspectRatio::parsePreserveAspectRatio(currViewSpec, end, false, result));
+ if (!result)
return false;
if (currViewSpec >= end || *currViewSpec != ')')
return false;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list