Changeset 70410 in webkit
- Timestamp:
- Oct 24, 2010 3:38:56 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r70408 r70410 1 2010-10-23 Nikolas Zimmermann <nzimmermann@rim.com> 2 3 Reviewed by Dirk Schulze. 4 5 Convert SVGAngle to the new SVGPropertyTearOff concept, reimplement it properly 6 https://bugs.webkit.org/show_bug.cgi?id=48179 7 8 Add an extensive SVGAngle test, checking all getter/setters & methods, with valid and invalid arguments. 9 The test exposes bugs in Opera & FireFox, we now pass them all. 10 11 * svg/dom/SVGAngle-expected.txt: Added. 12 * svg/dom/SVGAngle.html: Added. 13 * svg/dom/script-tests/SVGAngle.js: Added. 14 * svg/dom/svg-element-attribute-js-null-expected.txt: 15 * svg/dom/svg-element-attribute-js-null.xhtml: Update incorrect test, setting valueAsString to null, should not result in "0deg" but "0". 16 1 17 2010-10-23 Dimitri Glazkov <dglazkov@chromium.org> 2 18 -
trunk/LayoutTests/svg/dom/svg-element-attribute-js-null-expected.txt
r30635 r70410 4 4 TEST SUCCEEDED: The value was the empty string. [tested SVGElement.xmlbase] 5 5 6 TEST SUCCEEDED: The value was the string '0 deg'. [tested SVGAngle.valueAsString]6 TEST SUCCEEDED: The value was the string '0'. [tested SVGAngle.valueAsString] 7 7 8 8 TEST SUCCEEDED: The value was the string '0'. [tested SVGLength.valueAsString] -
trunk/LayoutTests/svg/dom/svg-element-attribute-js-null.xhtml
r23915 r70410 61 61 elementToUse: svg.createSVGAngle(), 62 62 attributes: [ 63 {name: 'valueAsString', expectedNull: '0 deg'}63 {name: 'valueAsString', expectedNull: '0'} 64 64 ] 65 65 }, -
trunk/WebCore/ChangeLog
r70407 r70410 1 2010-10-23 Nikolas Zimmermann <nzimmermann@rim.com> 2 3 Reviewed by Dirk Schulze. 4 5 Convert SVGAngle to the new SVGPropertyTearOff concept, reimplement it properly 6 https://bugs.webkit.org/show_bug.cgi?id=48179 7 8 Rewrite SVGAngle to use the new SVGPropertyTearOff concept, and consume much less memory. 9 Down from two floats, one string and an ushort to one float and one ushort. Synchronize value/valueInSpecifiedUnits/valueAsString on demand. 10 11 Adding an extensive SVGAngle test, that required to implement 'StrictTypeChecking' for attribute setters (was only implemented in V8/JSC for function cals so far). 12 13 Test: svg/dom/SVGAngle.html 14 15 * GNUmakefile.am: Add SVGAnimatedAngle.h to build. 16 * WebCore.gypi: Ditto. 17 * WebCore.pro: Ditto. 18 * WebCore.vcproj/WebCore.vcproj: Ditto. 19 * WebCore.xcodeproj/project.pbxproj: Ditto. 20 * bindings/scripts/CodeGenerator.pm: Split IsPrimitiveType in IsPrimitiveType and IsNumericType. 21 * bindings/scripts/CodeGeneratorJS.pm: Implement 'StrictTypeChecking' for setters and recognize SVGAngle as new SVGPropertyTearOff type. 22 * bindings/scripts/CodeGeneratorObjC.pm: Ditto. 23 * bindings/scripts/CodeGeneratorV8.pm: Ditto. 24 * svg/DeprecatedSVGAnimatedPropertyTraits.h: Remove SVGAngle handling. 25 * svg/DeprecatedSVGAnimatedTemplate.h: Remove SVGAnimatedAngle handling. 26 * svg/SVGAngle.cpp: Rewrite, to consume less memory and to operate more efficient. 27 * svg/SVGAngle.h: Ditto. 28 * svg/SVGAngle.idl: Add 'StrictTypeChecking' to the value/valueInSpecifiedUnits methods. 29 * svg/SVGAnimatedAngle.h: Added. 30 * svg/SVGAnimatedAngle.idl: Mark as [SVGAnimatedProperty]. 31 * svg/SVGMarkerElement.cpp: 32 (WebCore::SVGMarkerElement::parseMappedAttribute): SVGAngle::setValueAsString() now takes an ExceptionCode parameter. 33 * svg/SVGMarkerElement.h: s/ANIMATED_PROPERTY/ANIMATED_PROPERTY_NEW/ for the SVGAngle type. 34 * svg/SVGNumber.idl: Remove exception setter exceptions, which aren't needed. As we're now generating exception handlers in the bindings, it would lead to compile errors. 35 * svg/SVGPoint.idl: Ditto. 36 * svg/SVGRect.idl: Ditto. 37 * svg/SVGSVGElement.idl: Remove obsolete [SVGLiveProperty] flag. 38 1 39 2010-10-23 Daniel Bates <dbates@rim.com> 2 40 -
trunk/WebCore/GNUmakefile.am
r70400 r70410 3029 3029 WebCore/svg/SVGAnimateColorElement.cpp \ 3030 3030 WebCore/svg/SVGAnimateColorElement.h \ 3031 WebCore/svg/SVGAnimatedAngle.h \ 3031 3032 WebCore/svg/SVGAnimatedLength.h \ 3032 3033 WebCore/svg/SVGAnimatedLengthList.h \ -
trunk/WebCore/WebCore.gypi
r70400 r70410 3959 3959 'svg/SVGAnimateTransformElement.cpp', 3960 3960 'svg/SVGAnimateTransformElement.h', 3961 'svg/SVGAnimatedAngle.h', 3961 3962 'svg/SVGAnimatedLength.h', 3962 3963 'svg/SVGAnimatedLengthList.h', -
trunk/WebCore/WebCore.pro
r70400 r70410 2359 2359 svg/SVGAngle.h \ 2360 2360 svg/SVGAnimateColorElement.h \ 2361 svg/SVGAnimatedAngle.h \ 2361 2362 svg/SVGAnimatedLength.h \ 2362 2363 svg/SVGAnimatedLengthList.h \ -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r70400 r70410 61172 61172 </File> 61173 61173 <File 61174 RelativePath="..\svg\SVGAnimatedAngle.h" 61175 > 61176 </File> 61177 <File 61174 61178 RelativePath="..\svg\SVGAnimatedLength.h" 61175 61179 > -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r70400 r70410 157 157 08744BAA0EDB7D86004C9E63 /* WMLOnEventElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08744BA90EDB7D86004C9E63 /* WMLOnEventElement.cpp */; }; 158 158 08744BAE0EDB7D92004C9E63 /* WMLOnEventElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 08744BAD0EDB7D92004C9E63 /* WMLOnEventElement.h */; }; 159 087B84961272CEC800A14417 /* SVGAnimatedAngle.h in Headers */ = {isa = PBXBuildFile; fileRef = 087B84951272CEC700A14417 /* SVGAnimatedAngle.h */; settings = {ATTRIBUTES = (Private, ); }; }; 159 160 087D97BF10FB8D7700C00874 /* JSSVGPODListCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 087D97BE10FB8D7700C00874 /* JSSVGPODListCustom.h */; }; 160 161 087FFA0F0EFF3ED3009DBD88 /* WMLInsertedLegendElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 087FFA0D0EFF3ED3009DBD88 /* WMLInsertedLegendElement.cpp */; }; … … 6156 6157 08744BA90EDB7D86004C9E63 /* WMLOnEventElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WMLOnEventElement.cpp; sourceTree = "<group>"; }; 6157 6158 08744BAD0EDB7D92004C9E63 /* WMLOnEventElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMLOnEventElement.h; sourceTree = "<group>"; }; 6159 087B84951272CEC700A14417 /* SVGAnimatedAngle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedAngle.h; sourceTree = "<group>"; }; 6158 6160 087D97BE10FB8D7700C00874 /* JSSVGPODListCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSVGPODListCustom.h; sourceTree = "<group>"; }; 6159 6161 087FFA0D0EFF3ED3009DBD88 /* WMLInsertedLegendElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WMLInsertedLegendElement.cpp; sourceTree = "<group>"; }; … … 15942 15944 B22277E40D00BF1F0071B782 /* SVGAnimateColorElement.h */, 15943 15945 B22277E50D00BF1F0071B782 /* SVGAnimateColorElement.idl */, 15946 087B84951272CEC700A14417 /* SVGAnimatedAngle.h */, 15944 15947 B22277E60D00BF1F0071B782 /* SVGAnimatedAngle.idl */, 15945 15948 B22277E70D00BF1F0071B782 /* SVGAnimatedBoolean.idl */, … … 21152 21155 089021AD126EF5E90092D5EA /* SVGAnimatedLengthList.h in Headers */, 21153 21156 8AB4BC77126FDB7100DEB727 /* IgnoreDestructiveWriteCountIncrementer.h in Headers */, 21157 087B84961272CEC800A14417 /* SVGAnimatedAngle.h in Headers */, 21154 21158 ); 21155 21159 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/bindings/scripts/CodeGenerator.pm
r70223 r70410 6 6 # Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 7 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. 8 9 # 9 10 # This library is free software; you can redistribute it and/or … … 43 44 my $verbose = 0; 44 45 45 my % primitiveTypeHash = ("int" => 1, "short" => 1, "long" => 1, "long long" => 1,46 47 48 "float" => 1, "double" => 1,49 "boolean" => 1, "void" => 1, 50 46 my %numericTypeHash = ("int" => 1, "short" => 1, "long" => 1, "long long" => 1, 47 "unsigned int" => 1, "unsigned short" => 1, 48 "unsigned long" => 1, "unsigned long long" => 1, 49 "float" => 1, "double" => 1); 50 51 my %primitiveTypeHash = ( "boolean" => 1, "void" => 1, "Date" => 1); 51 52 52 53 my %podTypeHash = ("SVGNumber" => 1, "SVGTransform" => 1); 53 my %podTypesWithWritablePropertiesHash = ("SVG Angle" => 1, "SVGMatrix" => 1, "SVGPoint" => 1, "SVGPreserveAspectRatio" => 1, "SVGRect" => 1);54 my %podTypesWithWritablePropertiesHash = ("SVGMatrix" => 1, "SVGPoint" => 1, "SVGPreserveAspectRatio" => 1, "SVGRect" => 1); 54 55 my %stringTypeHash = ("DOMString" => 1, "AtomicString" => 1); 55 56 56 57 my %nonPointerTypeHash = ("DOMTimeStamp" => 1, "CompareHow" => 1, "SVGPaintType" => 1); 57 58 58 my %svgNewStyleAnimatedTypeHash = ("SVGAnimatedLength" => 1, "SVGAnimatedLengthList" => 1); 59 my %svgTypeNeedingTearOffHash = ("SVGLength" => 1, "SVGAngle" => 1); 60 61 my %svgNewStyleAnimatedTypeHash = ("SVGAnimatedAngle" => 1, "SVGAnimatedLength" => 1, "SVGAnimatedLengthList" => 1); 59 62 60 63 my %svgAnimatedTypeHash = ("SVGAnimatedAngle" => 1, "SVGAnimatedBoolean" => 1, … … 284 287 285 288 # Helpers for all CodeGenerator***.pm modules 289 290 # FIXME: This method will go away once all SVG animated properties are converted to the new scheme. 286 291 sub IsPodType 287 292 { … … 303 308 } 304 309 310 sub IsNumericType 311 { 312 my $object = shift; 313 my $type = shift; 314 315 return 1 if $numericTypeHash{$type}; 316 return 0; 317 } 318 305 319 sub IsPrimitiveType 306 320 { … … 309 323 310 324 return 1 if $primitiveTypeHash{$type}; 325 return 1 if $numericTypeHash{$type}; 311 326 return 0; 312 327 } … … 326 341 my $type = shift; 327 342 328 return 1 if $nonPointerTypeHash{$type} or $primitiveTypeHash{$type}; 343 return 1 if $nonPointerTypeHash{$type} or $primitiveTypeHash{$type} or $numericTypeHash{$type}; 344 return 0; 345 } 346 347 348 sub IsSVGTypeNeedingTearOff 349 { 350 my $object = shift; 351 my $type = shift; 352 353 return 1 if $svgTypeNeedingTearOffHash{$type}; 329 354 return 0; 330 355 } -
trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm
r70300 r70410 325 325 } 326 326 327 # FIXME: This method will go away once all SVG animated properties are converted to the new scheme. 327 328 sub IsSVGTypeNeedingContextParameter 328 329 { 330 # FIXME: This function will be removed, as soon the PODType concept is gone, and all SVG datatypes use the new style JS bindings. 331 329 332 my $implClassName = shift; 330 333 … … 333 336 return 0 if $codeGenerator->IsSVGNewStyleAnimatedType($implClassName); 334 337 335 my @noContextNeeded = ("SVG Length", "SVGLengthList", "SVGPaint", "SVGColor", "SVGDocument", "SVGZoomEvent");338 my @noContextNeeded = ("SVGAngle", "SVGLength", "SVGLengthList", "SVGPaint", "SVGColor", "SVGDocument", "SVGZoomEvent"); 336 339 foreach (@noContextNeeded) { 337 340 return 0 if $implClassName eq $_; … … 1803 1806 push(@implContent, " $className* castedThis = static_cast<$className*>(thisObject);\n"); 1804 1807 push(@implContent, " $implType* imp = static_cast<$implType*>(castedThis->impl());\n"); 1808 push(@implContent, " ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions}; 1809 1810 # For setters with "StrictTypeChecking", if an input parameter's type does not match the signature, 1811 # a TypeError is thrown instead of casting to null. 1812 if ($attribute->signature->extendedAttributes->{"StrictTypeChecking"}) { 1813 my $argType = $attribute->signature->type; 1814 if ($codeGenerator->IsStringType($argType)) { 1815 push(@implContent, " if (!value.isUndefinedOrNull() && !value.isString() && !value.isObject()) {\n"); 1816 push(@implContent, " throwVMTypeError(exec);\n"); 1817 push(@implContent, " return;\n"); 1818 push(@implContent, " };\n"); 1819 } elsif ($codeGenerator->IsNumericType($argType)) { 1820 push(@implContent, " if (!value.isUndefinedOrNull() && !value.isNumber()) {\n"); 1821 push(@implContent, " throwVMTypeError(exec);\n"); 1822 push(@implContent, " return;\n"); 1823 push(@implContent, " };\n"); 1824 } elsif (!IsNativeType($argType)) { 1825 push(@implContent, " if (!value.isUndefinedOrNull() && !value.inherits(&JS${argType}::s_info)) {\n"); 1826 push(@implContent, " throwVMTypeError(exec);\n"); 1827 push(@implContent, " return;\n"); 1828 push(@implContent, " };\n"); 1829 } 1830 } 1831 1832 my $nativeValue = JSValueToNative($attribute->signature, "value"); 1805 1833 if ($svgPropertyOrPodType) { 1806 1834 push(@implContent, " $svgPropertyOrPodType podImp(*imp);\n") if $podType; 1807 1835 push(@implContent, " $svgPropertyOrPodType& podImp = imp->propertyReference();\n") if !$podType; 1808 1836 if ($svgPropertyOrPodType eq "float") { # Special case for JSSVGNumber 1809 push(@implContent, " podImp = " . JSValueToNative($attribute->signature, "value") . ";\n");1837 push(@implContent, " podImp = $nativeValue;\n"); 1810 1838 } else { 1811 push(@implContent, " podImp.set$implSetterFunctionName(" . JSValueToNative($attribute->signature, "value") . ");\n"); 1839 push(@implContent, " podImp.set$implSetterFunctionName($nativeValue"); 1840 push(@implContent, ", ec") if @{$attribute->setterExceptions}; 1841 push(@implContent, ");\n"); 1842 push(@implContent, " setDOMException(exec, ec);\n") if @{$attribute->setterExceptions}; 1812 1843 } 1813 1844 push(@implContent, " imp->commitChange(podImp, castedThis);\n") if $podType; 1814 push(@implContent, " imp->commitChange();\n") if $svgPropertyType; 1845 if ($svgPropertyType) { 1846 if (@{$attribute->setterExceptions}) { 1847 push(@implContent, " if (!ec)\n"); 1848 push(@implContent, " imp->commitChange();\n"); 1849 } else { 1850 push(@implContent, " imp->commitChange();\n"); 1851 } 1852 } 1815 1853 } else { 1816 my $nativeValue = JSValueToNative($attribute->signature, "value");1817 1854 my $setterExpressionPrefix = $codeGenerator->SetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute); 1818 1819 push(@implContent, " ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions};1820 1855 push(@implContent, " imp->$setterExpressionPrefix$nativeValue"); 1821 1856 push(@implContent, ", ec") if @{$attribute->setterExceptions}; … … 2009 2044 2010 2045 my $name = $parameter->name; 2011 2012 if ($parameter->type eq "XPathNSResolver") { 2046 my $argType = $codeGenerator->StripModule($parameter->type); 2047 2048 if ($argType eq "XPathNSResolver") { 2013 2049 push(@implContent, " RefPtr<XPathNSResolver> customResolver;\n"); 2014 2050 push(@implContent, " XPathNSResolver* resolver = toXPathNSResolver(exec->argument($argsIndex));\n"); … … 2020 2056 push(@implContent, " }\n"); 2021 2057 } elsif ($parameter->extendedAttributes->{"Callback"}) { 2022 my $callbackClassName = GetCallbackClassName($ parameter->type);2058 my $callbackClassName = GetCallbackClassName($argType); 2023 2059 $implIncludes{"$callbackClassName.h"} = 1; 2024 2060 if ($parameter->extendedAttributes->{"Optional"}) { 2025 push(@implContent, " RefPtr< " . $parameter->type. "> $name;\n");2061 push(@implContent, " RefPtr<$argType> $name;\n"); 2026 2062 push(@implContent, " if (exec->argumentCount() > $argsIndex && !exec->argument($argsIndex).isNull() && !exec->argument($argsIndex).isUndefined()) {\n"); 2027 2063 push(@implContent, " if (!exec->argument($argsIndex).isObject()) {\n"); … … 2036 2072 push(@implContent, " return JSValue::encode(jsUndefined());\n"); 2037 2073 push(@implContent, " }\n"); 2038 push(@implContent, " RefPtr< " . $parameter->type . "> $name = ${callbackClassName}::create(asObject(exec->argument($argsIndex)), castedThis->globalObject());\n");2074 push(@implContent, " RefPtr<$argType> $name = ${callbackClassName}::create(asObject(exec->argument($argsIndex)), castedThis->globalObject());\n"); 2039 2075 } 2040 2076 } else { … … 2043 2079 if ($function->signature->extendedAttributes->{"StrictTypeChecking"}) { 2044 2080 my $argValue = "exec->argument($argsIndex)"; 2045 my $argType = $codeGenerator->StripModule($parameter->type); 2046 if (!IsNativeType($argType)) { 2081 if ($codeGenerator->IsStringType($argType)) { 2082 push(@implContent, " if (exec->argumentCount() > $argsIndex && !${argValue}.isUndefinedOrNull() && !${argValue}.isString() && !${argValue}.isObject())\n"); 2083 push(@implContent, " return throwVMTypeError(exec);\n"); 2084 } elsif ($codeGenerator->IsNumericType($argType)) { 2085 push(@implContent, " if (exec->argumentCount() > $argsIndex && !${argValue}.isUndefinedOrNull() && !${argValue}.isNumber())\n"); 2086 push(@implContent, " return throwVMTypeError(exec);\n"); 2087 } elsif (!IsNativeType($argType)) { 2047 2088 push(@implContent, " if (exec->argumentCount() > $argsIndex && !${argValue}.isUndefinedOrNull() && !${argValue}.inherits(&JS${argType}::s_info))\n"); 2048 2089 push(@implContent, " return throwVMTypeError(exec);\n"); 2049 } elsif ($codeGenerator->IsStringType($argType)) { 2050 push(@implContent, " if (exec->argumentCount() > $argsIndex && !${argValue}.isUndefinedOrNull() && !${argValue}.isString() && !${argValue}.isObject())\n"); 2051 push(@implContent, " return throwVMTypeError(exec);\n"); 2052 } 2090 } 2053 2091 } 2054 2092 … … 2068 2106 push(@implContent, " if (exec->hadException())\n"); 2069 2107 push(@implContent, " return JSValue::encode(jsUndefined());\n"); 2108 2109 if ($codeGenerator->IsSVGTypeNeedingTearOff($argType) and not $implClassName =~ /List$/) { 2110 push(@implContent, " if (!$name) {\n"); 2111 push(@implContent, " setDOMException(exec, TYPE_MISMATCH_ERR);\n"); 2112 push(@implContent, " return JSValue::encode(jsUndefined());\n"); 2113 push(@implContent, " }\n"); 2114 } 2070 2115 } 2071 2116 2072 2117 $functionString .= ", " if $paramIndex; 2073 2118 2074 if ($ parameter->type eq "NodeFilter") {2119 if ($argType eq "NodeFilter") { 2075 2120 $functionString .= "$name.get()"; 2121 } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($argType) and not $implClassName =~ /List$/) { 2122 $functionString .= "$name->propertyReference()"; 2076 2123 } else { 2077 2124 $functionString .= $name; … … 2372 2419 push(@implContent, $indent . "setDOMException(exec, ec);\n") if @{$function->raisesExceptions}; 2373 2420 push(@implContent, $indent . "imp->commitChange(podImp, castedThis);\n") if $podType; 2374 push(@implContent, $indent . "imp->commitChange();\n") if $svgPropertyType; 2421 2422 if ($svgPropertyType) { 2423 if (@{$function->raisesExceptions}) { 2424 push(@implContent, $indent . "if (!ec)\n"); 2425 push(@implContent, $indent . " imp->commitChange();\n"); 2426 } else { 2427 push(@implContent, $indent . "imp->commitChange();\n"); 2428 } 2429 } 2430 2375 2431 push(@implContent, $indent . "return JSValue::encode(jsUndefined());\n"); 2376 2432 } else { … … 2414 2470 "SerializedScriptValue" => "RefPtr<SerializedScriptValue>", 2415 2471 "IDBKey" => "RefPtr<IDBKey>", 2416 "SVGAngle" => "SVG Angle",2472 "SVGAngle" => "SVGPropertyTearOff<SVGAngle>*", 2417 2473 "SVGLength" => "SVGPropertyTearOff<SVGLength>*", 2418 2474 "SVGMatrix" => "AffineTransform", … … 2568 2624 } 2569 2625 2570 my $svgLivePropertyType = $signature->extendedAttributes->{"SVGLiveProperty"};2571 if ($svgLivePropertyType) {2572 $implIncludes{"JS$type.h"} = 1;2573 return "toJS(exec, $globalObject, SVGPropertyTearOff<$type>::create($value).get())";2574 }2575 2576 2626 if ($type eq "CSSStyleDeclaration") { 2577 2627 $implIncludes{"CSSMutableStyleDeclaration.h"} = 1; … … 2613 2663 } 2614 2664 2615 # Convert from abstract SVGProperty to real type, so the right toJS() method can be invoked.2616 2665 if ($codeGenerator->IsSVGNewStyleAnimatedType($implClassName)) { 2666 # Convert from abstract SVGProperty to real type, so the right toJS() method can be invoked. 2617 2667 if ($implClassName =~ /List$/) { 2618 2668 $value = "static_cast<SVGListPropertyTearOff<$type>*>($value)"; … … 2620 2670 $value = "static_cast<SVGPropertyTearOff<$type>*>($value)"; 2621 2671 } 2672 } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($type) and not $implClassName =~ /List$/) { 2673 $value = "SVGPropertyTearOff<$type>::create($value)"; 2622 2674 } 2623 2675 -
trunk/WebCore/bindings/scripts/CodeGeneratorObjC.pm
r70223 r70410 7 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 8 8 # Copyright (C) 2010 Google Inc. 9 # Copyright (C) Research In Motion Limited 2010. All rights reserved. 9 10 # 10 11 # This library is free software; you can redistribute it and/or … … 1370 1371 $getterContentHead = "$getterExpressionPrefix"; 1371 1372 push(@implContent, " $svgPropertyTypeWithNamespace& podImpl = IMPL->propertyReference();\n"); 1372 push(@implContent, " podImpl.$coreSetterName($arg);\n"); 1373 push(@implContent, " IMPL->commitChange();\n"); 1373 my $ec = $hasSetterException ? ", ec" : ""; 1374 push(@implContent, " $exceptionInit\n") if $hasSetterException; 1375 push(@implContent, " podImpl.$coreSetterName($arg$ec);\n"); 1376 if ($hasSetterException) { 1377 push(@implContent, " if (!ec)\n"); 1378 push(@implContent, " IMPL->commitChange();\n"); 1379 push(@implContent, " $exceptionRaiseOnError\n"); 1380 } else { 1381 push(@implContent, " IMPL->commitChange();\n"); 1382 } 1374 1383 } elsif ($svgListPropertyType) { 1375 1384 $getterContentHead = "$getterExpressionPrefix"; … … 1504 1513 push(@parameterNames, "ec") if $raisesExceptions and !($svgMatrixRotateFromVector || $svgMatrixInverse); 1505 1514 push(@parameterNames, "0 /* FIXME */") if $svgLengthConvertToSpecifiedUnits; 1515 1516 # Handle arguments that are 'SVGProperty' based (SVGAngle/SVGLength). We need to convert from SVGPropertyTearOff<Type>* to Type, 1517 # to be able to call the desired WebCore function. If the conversion fails, we can't extract Type and need to raise an exception. 1518 my $currentParameter = -1; 1519 foreach my $param (@{$function->parameters}) { 1520 $currentParameter++; 1521 1522 my $paramName = $param->name; 1523 my $idlType = $codeGenerator->StripModule($param->type); 1524 next if not $codeGenerator->IsSVGTypeNeedingTearOff($idlType) or $implClassName =~ /List$/; 1525 1526 my $implGetter = GetObjCTypeGetter($paramName, $idlType); 1527 my $idlTypeWithNamespace = ($idlType eq "float") ? "$idlType" : "WebCore::$idlType"; 1528 1529 push(@functionContent, " WebCore::SVGPropertyTearOff<$idlTypeWithNamespace>* ${paramName}Core = $implGetter;\n"); 1530 push(@functionContent, " if (!${paramName}Core) {\n"); 1531 push(@functionContent, " WebCore::ExceptionCode ec = WebCore::TYPE_MISMATCH_ERR;\n"); 1532 push(@functionContent, " $exceptionRaiseOnError\n"); 1533 if ($returnType eq "void") { 1534 push(@functionContent, " return;\n"); 1535 } else { 1536 push(@functionContent, " return nil;\n"); 1537 } 1538 push(@functionContent, " }\n"); 1539 1540 # Replace the paramter core() getter, by the cached variable. 1541 splice(@parameterNames, $currentParameter, 1, "${paramName}Core->propertyReference()"); 1542 } 1543 1506 1544 my $content = $codeGenerator->WK_lcfirst($functionName) . "(" . join(", ", @parameterNames) . ")"; 1507 1545 … … 1555 1593 } else { 1556 1594 if (ConversionNeeded($function->signature->type)) { 1557 my $svgLiveProperty = $function->signature->extendedAttributes->{"SVGLiveProperty"}; 1558 if ($svgLiveProperty) { 1559 $content = "kit(WebCore::SVGPropertyTearOff<WebCore::" . $function->signature->type . ">::create($content).get())"; 1595 if ($codeGenerator->IsSVGTypeNeedingTearOff($function->signature->type) and not $implClassName =~ /List$/) { 1596 $content = "kit(WTF::getPtr(WebCore::SVGPropertyTearOff<WebCore::" . $function->signature->type . ">::create($content)))"; 1560 1597 } elsif ($codeGenerator->IsPodType($function->signature->type)) { 1561 1598 $content = "kit($content)"; -
trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm
r70300 r70410 7 7 # Copyright (C) 2007, 2008, 2009 Google Inc. 8 8 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 9 # Copyright (C) Research In Motion Limited 2010. All rights reserved. 9 10 # 10 11 # This library is free software; you can redistribute it and/or … … 88 89 89 90 # Workaround for V8 bindings difference where RGBColor is not a POD type. 91 # FIXME: This method will go away once all SVG animated properties are converted to the new scheme. 90 92 sub IsPodType 91 93 { … … 937 939 push(@implContentDecls, " INC_STATS(\"DOM.$implClassName.$attrName._set\");\n"); 938 940 941 # For functions with "StrictTypeChecking", if an input parameter's type does not match the signature, 942 # a TypeError is thrown instead of casting to null. 943 if ($attribute->signature->extendedAttributes->{"StrictTypeChecking"}) { 944 my $argType = GetTypeFromSignature($attribute->signature); 945 if ($codeGenerator->IsStringType($argType)) { 946 push(@implContentDecls, " if (!isUndefinedOrNull(value) && !value->IsString() && !value->IsObject()) {\n"); 947 push(@implContentDecls, " V8Proxy::throwTypeError();\n"); 948 push(@implContentDecls, " return;\n"); 949 push(@implContentDecls, " }\n"); 950 } elsif ($codeGenerator->IsNumericType($argType)) { 951 push(@implContentDecls, " if (!isUndefinedOrNull(value) && !value->IsNumber()) {\n"); 952 push(@implContentDecls, " V8Proxy::throwTypeError();\n"); 953 push(@implContentDecls, " return;\n"); 954 push(@implContentDecls, " }\n"); 955 } elsif (IsWrapperType($argType)) { 956 push(@implContentDecls, " if (!isUndefinedOrNull(value) && !V8${argType}::HasInstance(value)) {\n"); 957 push(@implContentDecls, " V8Proxy::throwTypeError();\n"); 958 push(@implContentDecls, " return;\n"); 959 push(@implContentDecls, " }\n"); 960 } 961 } 962 939 963 my $isPodType = IsPodType($implClassName); 940 964 my $svgPropertyType = $dataNode->extendedAttributes->{"SVGProperty"}; … … 1051 1075 push(@implContentDecls, " wrapper->commitChange(*imp, V8Proxy::svgContext(wrapper));\n"); 1052 1076 } elsif ($svgPropertyType) { 1053 push(@implContentDecls, " wrapper->commitChange();\n"); 1077 if ($useExceptions) { 1078 push(@implContentDecls, " if (!ec)\n"); 1079 push(@implContentDecls, " wrapper->commitChange();\n"); 1080 } else { 1081 push(@implContentDecls, " wrapper->commitChange();\n"); 1082 } 1054 1083 } elsif (IsSVGTypeNeedingContextParameter($implClassName)) { 1055 1084 $implIncludes{"SVGElement.h"} = 1; … … 1378 1407 my $argValue = "args[$paramIndex]"; 1379 1408 my $argType = GetTypeFromSignature($parameter); 1380 if ( IsWrapperType($argType)) {1381 push(@implContentDecls, " if (args.Length() > $paramIndex && !isUndefinedOrNull($argValue) && ! V8${argType}::HasInstance($argValue)) {\n");1409 if ($codeGenerator->IsStringType($argType)) { 1410 push(@implContentDecls, " if (args.Length() > $paramIndex && !isUndefinedOrNull($argValue) && !${argValue}->IsString() && !${argValue}->IsObject()) {\n"); 1382 1411 push(@implContentDecls, " V8Proxy::throwTypeError();\n"); 1383 1412 push(@implContentDecls, " return notHandledByInterceptor();\n"); 1384 1413 push(@implContentDecls, " }\n"); 1385 } elsif ($codeGenerator->IsStringType($argType)) { 1386 push(@implContentDecls, " if (args.Length() > $paramIndex && !isUndefinedOrNull($argValue) && !${argValue}->IsString() && !${argValue}->IsObject()) {\n"); 1414 } elsif ($codeGenerator->IsNumericType($argType)) { 1415 push(@implContentDecls, " if (args.Length() > $paramIndex && !isUndefinedOrNull($argValue) && !${argValue}->IsNumber()) {\n"); 1416 push(@implContentDecls, " V8Proxy::throwTypeError();\n"); 1417 push(@implContentDecls, " return notHandledByInterceptor();\n"); 1418 push(@implContentDecls, " }\n"); 1419 } elsif (IsWrapperType($argType)) { 1420 push(@implContentDecls, " if (args.Length() > $paramIndex && !isUndefinedOrNull($argValue) && !V8${argType}::HasInstance($argValue)) {\n"); 1387 1421 push(@implContentDecls, " V8Proxy::throwTypeError();\n"); 1388 1422 push(@implContentDecls, " return notHandledByInterceptor();\n"); … … 2712 2746 if ($parameter->type eq "NodeFilter" || $parameter->type eq "XPathNSResolver") { 2713 2747 $functionString .= "$paramName.get()"; 2748 } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($parameter->type) and not $implClassName =~ /List$/) { 2749 $functionString .= "$paramName->propertyReference()"; 2750 $result .= $indent . "if (!$paramName) {\n"; 2751 $result .= $indent . " V8Proxy::setDOMException(WebCore::TYPE_MISMATCH_ERR);\n"; 2752 $result .= $indent . " return v8::Handle<v8::Value>();\n"; 2753 $result .= $indent . "}\n"; 2714 2754 } else { 2715 2755 $functionString .= $paramName; … … 2776 2816 $return = "wrapper"; 2777 2817 } 2778 2779 my $svgLivePropertyType = $function->signature->extendedAttributes->{"SVGLiveProperty"}; 2780 if ($svgLivePropertyType) { 2818 2819 if ($codeGenerator->IsSVGTypeNeedingTearOff($returnType) and not $implClassName =~ /List$/) { 2781 2820 $implIncludes{"V8$returnType.h"} = 1; 2782 2821 $implIncludes{"SVGPropertyTearOff.h"} = 1; 2783 return $indent . "return toV8( SVGPropertyTearOff<$returnType>::create($return).get());\n";2822 return $indent . "return toV8(WTF::getPtr(SVGPropertyTearOff<$returnType>::create($return)));\n"; 2784 2823 } 2785 2824 … … 2903 2942 return "AffineTransform" if $type eq "SVGMatrix"; 2904 2943 return "SVGTransform" if $type eq "SVGTransform"; 2905 return " SVGAngle" if $type eq "SVGAngle";2944 return "RefPtr<SVGPropertyTearOff<SVGAngle> >" if $type eq "SVGAngle"; 2906 2945 return "RefPtr<SVGPropertyTearOff<SVGLength> >" if $type eq "SVGLength"; 2907 2946 return "SVGListPropertyTearOff<SVGLengthList>*" if $type eq "SVGLengthList"; … … 2957 2996 my $type = GetTypeFromSignature($signature); 2958 2997 2959 return 1 if $type eq "SVGAngle";2960 2998 return 1 if $type eq "SVGMatrix"; 2961 2999 return 1 if $type eq "SVGPoint"; … … 3281 3319 } 3282 3320 3321 # FIXME: This method will go away once all SVG animated properties are converted to the new scheme. 3283 3322 sub GenerateSVGStaticPodTypeWrapper { 3284 3323 my $type = shift; … … 3335 3374 } 3336 3375 3376 # FIXME: This method will go away once all SVG animated properties are converted to the new scheme. 3337 3377 sub IsSVGTypeNeedingContextParameter 3338 3378 { … … 3341 3381 return 0 if $codeGenerator->IsSVGNewStyleAnimatedType($implClassName); 3342 3382 if ($implClassName =~ /SVG/ and not $implClassName =~ /Element/) { 3343 return 1 unless $implClassName =~ /SVGPaint/ or $implClassName =~ /SVGColor/ or $implClassName =~ /SVGDocument/ or $implClassName =~ /SVGLength/ or $implClassName =~/SVGLengthList/; 3383 return 1 unless $implClassName =~ /SVGAngle/ 3384 or $implClassName =~ /SVGPaint/ 3385 or $implClassName =~ /SVGColor/ 3386 or $implClassName =~ /SVGDocument/ 3387 or $implClassName =~ /SVGLength/ 3388 or $implClassName =~ /SVGLengthList/; 3344 3389 } 3345 3390 … … 3347 3392 } 3348 3393 3394 # FIXME: This method will go away once all SVG animated properties are converted to the new scheme. 3349 3395 sub GenerateSVGContextAssignment 3350 3396 { … … 3359 3405 } 3360 3406 3407 # FIXME: This method will go away once all SVG animated properties are converted to the new scheme. 3361 3408 sub GenerateSVGContextRetrieval 3362 3409 { -
trunk/WebCore/svg/DeprecatedSVGAnimatedPropertyTraits.h
r70223 r70410 25 25 #include "FloatRect.h" 26 26 #include "PlatformString.h" 27 #include "SVGAngle.h"28 27 #include "SVGNumberList.h" 29 28 #include "SVGPreserveAspectRatio.h" … … 34 33 template<typename Type> 35 34 struct DeprecatedSVGAnimatedPropertyTraits : public Noncopyable { }; 36 37 // SVGAnimatedAngle38 template<>39 struct DeprecatedSVGAnimatedPropertyTraits<SVGAngle> : public Noncopyable {40 typedef const SVGAngle& PassType;41 typedef SVGAngle ReturnType;42 typedef SVGAngle StoredType;43 44 static ReturnType null() { return SVGAngle(); }45 static ReturnType toReturnType(const StoredType& type) { return type; }46 static String toString(PassType type) { return type.valueAsString(); }47 };48 35 49 36 // SVGAnimatedBoolean -
trunk/WebCore/svg/DeprecatedSVGAnimatedTemplate.h
r70223 r70410 29 29 namespace WebCore { 30 30 31 class SVGAngle;32 31 class SVGElement; 33 32 class SVGNumberList; … … 156 155 157 156 // Common type definitions, to ease IDL generation. 158 typedef DeprecatedSVGAnimatedTemplate<SVGAngle> SVGAnimatedAngle;159 157 typedef DeprecatedSVGAnimatedTemplate<bool> SVGAnimatedBoolean; 160 158 typedef DeprecatedSVGAnimatedTemplate<int> SVGAnimatedEnumeration; -
trunk/WebCore/svg/SVGAngle.cpp
r66397 r70410 2 2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 3 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> 4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 4 5 * 5 6 * This library is free software; you can redistribute it and/or … … 20 21 21 22 #include "config.h" 23 24 #if ENABLE(SVG) 22 25 #include "SVGAngle.h" 23 26 24 #i f ENABLE(SVG)25 27 #include "SVGParserUtilities.h" 28 #include <wtf/text/StringConcatenate.h> 26 29 #include <wtf/MathExtras.h> 27 30 … … 29 32 30 33 SVGAngle::SVGAngle() 31 : m_unitType(SVG_ANGLETYPE_UNKNOWN) 32 , m_value(0) 34 : m_unitType(SVG_ANGLETYPE_UNSPECIFIED) 33 35 , m_valueInSpecifiedUnits(0) 34 36 { 35 37 } 36 38 39 float SVGAngle::value() const 40 { 41 switch (m_unitType) { 42 case SVG_ANGLETYPE_GRAD: 43 return grad2deg(m_valueInSpecifiedUnits); 44 case SVG_ANGLETYPE_RAD: 45 return rad2deg(m_valueInSpecifiedUnits); 46 case SVG_ANGLETYPE_UNSPECIFIED: 47 case SVG_ANGLETYPE_UNKNOWN: 48 case SVG_ANGLETYPE_DEG: 49 return m_valueInSpecifiedUnits; 50 } 51 52 ASSERT_NOT_REACHED(); 53 return 0; 54 } 55 37 56 void SVGAngle::setValue(float value) 38 57 { 39 m_value = value; 40 } 41 42 // calc m_value 43 void SVGAngle::calculate() 44 { 45 if (m_unitType == SVG_ANGLETYPE_GRAD) 46 m_value = grad2deg(m_valueInSpecifiedUnits); 47 else if (m_unitType == SVG_ANGLETYPE_RAD) 48 m_value = rad2deg(m_valueInSpecifiedUnits); 49 else if (m_unitType == SVG_ANGLETYPE_UNSPECIFIED || m_unitType == SVG_ANGLETYPE_DEG) 50 m_value = m_valueInSpecifiedUnits; 51 } 52 53 void SVGAngle::setValueInSpecifiedUnits(float valueInSpecifiedUnits) 54 { 58 switch (m_unitType) { 59 case SVG_ANGLETYPE_GRAD: 60 m_valueInSpecifiedUnits = deg2grad(value); 61 break; 62 case SVG_ANGLETYPE_RAD: 63 m_valueInSpecifiedUnits = deg2rad(value); 64 break; 65 case SVG_ANGLETYPE_UNSPECIFIED: 66 case SVG_ANGLETYPE_UNKNOWN: 67 case SVG_ANGLETYPE_DEG: 68 m_valueInSpecifiedUnits = value; 69 break; 70 } 71 } 72 73 inline SVGAngle::SVGAngleType stringToAngleType(const UChar*& ptr, const UChar* end) 74 { 75 // If there's no unit given, the angle type is unspecified. 76 if (ptr == end) 77 return SVGAngle::SVG_ANGLETYPE_UNSPECIFIED; 78 79 const UChar firstChar = *ptr; 80 81 // If the unit contains only one character, the angle type is unknown. 82 ++ptr; 83 if (ptr == end) 84 return SVGAngle::SVG_ANGLETYPE_UNKNOWN; 85 86 const UChar secondChar = *ptr; 87 88 // If the unit contains only two characters, the angle type is unknown. 89 ++ptr; 90 if (ptr == end) 91 return SVGAngle::SVG_ANGLETYPE_UNKNOWN; 92 93 const UChar thirdChar = *ptr; 94 if (firstChar == 'd' && secondChar == 'e' && thirdChar == 'g') 95 return SVGAngle::SVG_ANGLETYPE_DEG; 96 if (firstChar == 'r' && secondChar == 'a' && thirdChar == 'd') 97 return SVGAngle::SVG_ANGLETYPE_RAD; 98 99 // If the unit contains three characters, but is not deg or rad, then it's unknown. 100 ++ptr; 101 if (ptr == end) 102 return SVGAngle::SVG_ANGLETYPE_UNKNOWN; 103 104 const UChar fourthChar = *ptr; 105 106 if (firstChar == 'g' && secondChar == 'r' && thirdChar == 'a' && fourthChar == 'd') 107 return SVGAngle::SVG_ANGLETYPE_GRAD; 108 109 return SVGAngle::SVG_ANGLETYPE_UNKNOWN; 110 } 111 112 String SVGAngle::valueAsString() const 113 { 114 switch (m_unitType) { 115 case SVG_ANGLETYPE_DEG: 116 return makeString(String::number(m_valueInSpecifiedUnits), "deg"); 117 case SVG_ANGLETYPE_RAD: 118 return makeString(String::number(m_valueInSpecifiedUnits), "rad"); 119 case SVG_ANGLETYPE_GRAD: 120 return makeString(String::number(m_valueInSpecifiedUnits), "grad"); 121 case SVG_ANGLETYPE_UNSPECIFIED: 122 case SVG_ANGLETYPE_UNKNOWN: 123 return makeString(String::number(m_valueInSpecifiedUnits)); 124 } 125 126 ASSERT_NOT_REACHED(); 127 return String(); 128 } 129 130 void SVGAngle::setValueAsString(const String& value, ExceptionCode& ec) 131 { 132 if (value.isEmpty()) { 133 m_unitType = SVG_ANGLETYPE_UNSPECIFIED; 134 return; 135 } 136 137 float valueInSpecifiedUnits = 0; 138 const UChar* ptr = value.characters(); 139 const UChar* end = ptr + value.length(); 140 141 if (!parseNumber(ptr, end, valueInSpecifiedUnits, false)) { 142 ec = SYNTAX_ERR; 143 return; 144 } 145 146 SVGAngleType unitType = stringToAngleType(ptr, end); 147 if (unitType == SVG_ANGLETYPE_UNKNOWN) { 148 ec = SYNTAX_ERR; 149 return; 150 } 151 152 m_unitType = unitType; 55 153 m_valueInSpecifiedUnits = valueInSpecifiedUnits; 56 calculate(); 57 } 58 59 void SVGAngle::setValueAsString(const String& s) 60 { 61 m_valueAsString = s; 62 63 bool bOK; 64 m_valueInSpecifiedUnits = m_valueAsString.toFloat(&bOK); 65 m_unitType = SVG_ANGLETYPE_UNSPECIFIED; 66 67 if (!bOK) { 68 if (m_valueAsString.endsWith("deg")) 69 m_unitType = SVG_ANGLETYPE_DEG; 70 else if (m_valueAsString.endsWith("grad")) 71 m_unitType = SVG_ANGLETYPE_GRAD; 72 else if (m_valueAsString.endsWith("rad")) 73 m_unitType = SVG_ANGLETYPE_RAD; 74 } 75 76 calculate(); 77 } 78 79 String SVGAngle::valueAsString() const 80 { 81 m_valueAsString = String::number(m_valueInSpecifiedUnits); 82 83 switch (m_unitType) { 154 } 155 156 void SVGAngle::newValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits, ExceptionCode& ec) 157 { 158 if (unitType == SVG_ANGLETYPE_UNKNOWN || unitType > SVG_ANGLETYPE_GRAD) { 159 ec = NOT_SUPPORTED_ERR; 160 return; 161 } 162 163 if (unitType != m_unitType) 164 m_unitType = static_cast<SVGAngleType>(unitType); 165 166 m_valueInSpecifiedUnits = valueInSpecifiedUnits; 167 } 168 169 void SVGAngle::convertToSpecifiedUnits(unsigned short unitType, ExceptionCode& ec) 170 { 171 if (unitType == SVG_ANGLETYPE_UNKNOWN || m_unitType == SVG_ANGLETYPE_UNKNOWN || unitType > SVG_ANGLETYPE_GRAD) { 172 ec = NOT_SUPPORTED_ERR; 173 return; 174 } 175 176 if (unitType == m_unitType) 177 return; 178 179 switch (m_unitType) { 180 case SVG_ANGLETYPE_RAD: 181 switch (unitType) { 182 case SVG_ANGLETYPE_GRAD: 183 m_valueInSpecifiedUnits = rad2grad(m_valueInSpecifiedUnits); 184 break; 84 185 case SVG_ANGLETYPE_UNSPECIFIED: 85 186 case SVG_ANGLETYPE_DEG: 86 m_value AsString += "deg";187 m_valueInSpecifiedUnits = rad2deg(m_valueInSpecifiedUnits); 87 188 break; 88 189 case SVG_ANGLETYPE_RAD: 89 m_valueAsString += "rad"; 190 case SVG_ANGLETYPE_UNKNOWN: 191 ASSERT_NOT_REACHED(); 192 break; 193 } 194 break; 195 case SVG_ANGLETYPE_GRAD: 196 switch (unitType) { 197 case SVG_ANGLETYPE_RAD: 198 m_valueInSpecifiedUnits = grad2rad(m_valueInSpecifiedUnits); 199 break; 200 case SVG_ANGLETYPE_UNSPECIFIED: 201 case SVG_ANGLETYPE_DEG: 202 m_valueInSpecifiedUnits = grad2deg(m_valueInSpecifiedUnits); 90 203 break; 91 204 case SVG_ANGLETYPE_GRAD: 92 m_valueAsString += "grad";93 break;94 205 case SVG_ANGLETYPE_UNKNOWN: 95 break; 96 } 97 98 return m_valueAsString; 99 } 100 101 void SVGAngle::newValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits) 102 { 103 m_unitType = (SVGAngleType)unitType; 104 m_valueInSpecifiedUnits = valueInSpecifiedUnits; 105 calculate(); 106 } 107 108 void SVGAngle::convertToSpecifiedUnits(unsigned short unitType) 109 { 110 if (m_unitType == unitType) 111 return; 112 113 if (m_unitType == SVG_ANGLETYPE_DEG && unitType == SVG_ANGLETYPE_RAD) 114 m_valueInSpecifiedUnits = deg2rad(m_valueInSpecifiedUnits); 115 else if (m_unitType == SVG_ANGLETYPE_GRAD && unitType == SVG_ANGLETYPE_RAD) 116 m_valueInSpecifiedUnits = grad2rad(m_valueInSpecifiedUnits); 117 else if (m_unitType == SVG_ANGLETYPE_DEG && unitType == SVG_ANGLETYPE_GRAD) 118 m_valueInSpecifiedUnits = deg2grad(m_valueInSpecifiedUnits); 119 else if (m_unitType == SVG_ANGLETYPE_RAD && unitType == SVG_ANGLETYPE_GRAD) 120 m_valueInSpecifiedUnits = rad2grad(m_valueInSpecifiedUnits); 121 else if (m_unitType == SVG_ANGLETYPE_RAD && unitType == SVG_ANGLETYPE_DEG) 122 m_valueInSpecifiedUnits = rad2deg(m_valueInSpecifiedUnits); 123 else if (m_unitType == SVG_ANGLETYPE_GRAD && unitType == SVG_ANGLETYPE_DEG) 124 m_valueInSpecifiedUnits = grad2deg(m_valueInSpecifiedUnits); 125 126 m_unitType = (SVGAngleType)unitType; 206 ASSERT_NOT_REACHED(); 207 break; 208 } 209 break; 210 case SVG_ANGLETYPE_UNSPECIFIED: 211 // Spec: For angles, a unitless value is treated the same as if degrees were specified. 212 case SVG_ANGLETYPE_DEG: 213 switch (unitType) { 214 case SVG_ANGLETYPE_RAD: 215 m_valueInSpecifiedUnits = deg2rad(m_valueInSpecifiedUnits); 216 break; 217 case SVG_ANGLETYPE_GRAD: 218 m_valueInSpecifiedUnits = deg2grad(m_valueInSpecifiedUnits); 219 break; 220 case SVG_ANGLETYPE_UNSPECIFIED: 221 break; 222 case SVG_ANGLETYPE_DEG: 223 case SVG_ANGLETYPE_UNKNOWN: 224 ASSERT_NOT_REACHED(); 225 break; 226 } 227 break; 228 case SVG_ANGLETYPE_UNKNOWN: 229 ASSERT_NOT_REACHED(); 230 break; 231 } 232 233 m_unitType = static_cast<SVGAngleType>(unitType); 127 234 } 128 235 -
trunk/WebCore/svg/SVGAngle.h
r66397 r70410 2 2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 3 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> 4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 4 5 * 5 6 * This library is free software; you can redistribute it and/or … … 23 24 24 25 #if ENABLE(SVG) 25 #include "PlatformString.h" 26 #include "ExceptionCode.h" 27 #include <wtf/text/WTFString.h> 26 28 27 29 namespace WebCore { 28 30 29 30 31 31 class SVGAngle { 32 public: 33 SVGAngle(); 32 34 33 34 SVG_ANGLETYPE_UNKNOWN= 0,35 SVG_ANGLETYPE_UNSPECIFIED= 1,36 SVG_ANGLETYPE_DEG= 2,37 SVG_ANGLETYPE_RAD= 3,38 SVG_ANGLETYPE_GRAD= 439 35 enum SVGAngleType { 36 SVG_ANGLETYPE_UNKNOWN = 0, 37 SVG_ANGLETYPE_UNSPECIFIED = 1, 38 SVG_ANGLETYPE_DEG = 2, 39 SVG_ANGLETYPE_RAD = 3, 40 SVG_ANGLETYPE_GRAD = 4 41 }; 40 42 41 43 SVGAngleType unitType() const { return m_unitType; } 42 44 43 44 float value() const { return m_value; }45 void setValue(float); 46 float value() const; 45 47 46 void setValueInSpecifiedUnits(float valueInSpecifiedUnits);47 48 void setValueInSpecifiedUnits(float valueInSpecifiedUnits) { m_valueInSpecifiedUnits = valueInSpecifiedUnits; } 49 float valueInSpecifiedUnits() const { return m_valueInSpecifiedUnits; } 48 50 49 void setValueAsString(const String&);50 51 void setValueAsString(const String&, ExceptionCode&); 52 String valueAsString() const; 51 53 52 void newValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits);53 void convertToSpecifiedUnits(unsigned short unitType);54 void newValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits, ExceptionCode&); 55 void convertToSpecifiedUnits(unsigned short unitType, ExceptionCode&); 54 56 55 private: 56 SVGAngleType m_unitType; 57 float m_value; 58 float m_valueInSpecifiedUnits; 59 mutable String m_valueAsString; 60 61 void calculate(); 62 }; 57 private: 58 SVGAngleType m_unitType; 59 float m_valueInSpecifiedUnits; 60 }; 63 61 64 62 } // namespace WebCore -
trunk/WebCore/svg/SVGAngle.idl
r64579 r70410 23 23 module svg { 24 24 25 interface [Conditional=SVG, PODType=SVGAngle] SVGAngle {25 interface [Conditional=SVG, SVGProperty=SVGAngle] SVGAngle { 26 26 // Angle Unit Types 27 const unsigned short SVG_ANGLETYPE_UNKNOWN 27 const unsigned short SVG_ANGLETYPE_UNKNOWN = 0; 28 28 const unsigned short SVG_ANGLETYPE_UNSPECIFIED = 1; 29 const unsigned short SVG_ANGLETYPE_DEG 30 const unsigned short SVG_ANGLETYPE_RAD 31 const unsigned short SVG_ANGLETYPE_GRAD 32 29 const unsigned short SVG_ANGLETYPE_DEG = 2; 30 const unsigned short SVG_ANGLETYPE_RAD = 3; 31 const unsigned short SVG_ANGLETYPE_GRAD = 4; 32 33 33 readonly attribute unsigned short unitType; 34 attribute float value; 35 attribute float valueInSpecifiedUnits; 36 attribute [ConvertNullToNullString] DOMString valueAsString; 37 38 void newValueSpecifiedUnits(in unsigned short unitType, 39 in float valueInSpecifiedUnits); 40 void convertToSpecifiedUnits(in unsigned short unitType); 34 attribute [StrictTypeChecking] float value; 35 attribute [StrictTypeChecking] float valueInSpecifiedUnits; 36 37 attribute [ConvertNullToNullString] DOMString valueAsString 38 setter raises(DOMException); 39 40 void newValueSpecifiedUnits(in unsigned short unitType, in float valueInSpecifiedUnits) 41 raises(DOMException); 42 43 void convertToSpecifiedUnits(in unsigned short unitType) 44 raises(DOMException); 41 45 }; 42 46 -
trunk/WebCore/svg/SVGAnimatedAngle.idl
r64579 r70410 26 26 module svg { 27 27 28 interface [Conditional=SVG ] SVGAnimatedAngle {28 interface [Conditional=SVG, SVGAnimatedProperty] SVGAnimatedAngle { 29 29 readonly attribute SVGAngle baseVal; 30 30 readonly attribute SVGAngle animVal; -
trunk/WebCore/svg/SVGMarkerElement.cpp
r66498 r70410 82 82 setOrientTypeBaseValue(SVG_MARKER_ORIENT_AUTO); 83 83 else { 84 angle.setValueAsString(attr->value()); 84 ExceptionCode ec = 0; 85 angle.setValueAsString(attr->value(), ec); 85 86 setOrientTypeBaseValue(SVG_MARKER_ORIENT_ANGLE); 86 87 } -
trunk/WebCore/svg/SVGMarkerElement.h
r70223 r70410 83 83 DECLARE_ANIMATED_PROPERTY(SVGMarkerElement, SVGNames::markerUnitsAttr, int, MarkerUnits, markerUnits) 84 84 DECLARE_ANIMATED_PROPERTY_MULTIPLE_WRAPPERS(SVGMarkerElement, SVGNames::orientAttr, SVGOrientTypeAttrIdentifier, int, OrientType, orientType) 85 DECLARE_ANIMATED_PROPERTY_ MULTIPLE_WRAPPERS(SVGMarkerElement, SVGNames::orientAttr, SVGOrientAngleAttrIdentifier, SVGAngle, OrientAngle, orientAngle)85 DECLARE_ANIMATED_PROPERTY_NEW_MULTIPLE_WRAPPERS(SVGMarkerElement, SVGNames::orientAttr, SVGOrientAngleAttrIdentifier, SVGAngle, OrientAngle, orientAngle) 86 86 87 87 // SVGExternalResourcesRequired -
trunk/WebCore/svg/SVGNumber.idl
r64579 r70410 24 24 25 25 interface [Conditional=SVG, PODType=float] SVGNumber { 26 attribute float value 27 setter raises(DOMException); 26 attribute float value; 28 27 }; 29 28 -
trunk/WebCore/svg/SVGPoint.idl
r64579 r70410 24 24 25 25 interface [Conditional=SVG, PODType=FloatPoint] SVGPoint { 26 attribute float x 27 setter raises(DOMException); 28 attribute float y 29 setter raises(DOMException); 26 attribute float x; 27 attribute float y; 30 28 31 29 SVGPoint matrixTransform(in SVGMatrix matrix); -
trunk/WebCore/svg/SVGRect.idl
r64579 r70410 24 24 25 25 interface [Conditional=SVG, PODType=FloatRect] SVGRect { 26 attribute float x 27 setter raises(DOMException); 28 attribute float y 29 setter raises(DOMException); 30 attribute float width 31 setter raises(DOMException); 32 attribute float height 33 setter raises(DOMException); 26 attribute float x; 27 attribute float y; 28 attribute float width; 29 attribute float height; 34 30 }; 35 31 -
trunk/WebCore/svg/SVGSVGElement.idl
r70223 r70410 74 74 75 75 SVGNumber createSVGNumber(); 76 [SVGLiveProperty]SVGLength createSVGLength();76 SVGLength createSVGLength(); 77 77 SVGAngle createSVGAngle(); 78 78 SVGPoint createSVGPoint();
Note: See TracChangeset
for help on using the changeset viewer.