Changeset 70410 in webkit


Ignore:
Timestamp:
Oct 24, 2010 3:38:56 AM (14 years ago)
Author:
Nikolas Zimmermann
Message:

2010-10-23 Nikolas Zimmermann <nzimmermann@rim.com>

Reviewed by Dirk Schulze.

Convert SVGAngle to the new SVGPropertyTearOff concept, reimplement it properly
https://bugs.webkit.org/show_bug.cgi?id=48179

Rewrite SVGAngle to use the new SVGPropertyTearOff concept, and consume much less memory.
Down from two floats, one string and an ushort to one float and one ushort. Synchronize value/valueInSpecifiedUnits/valueAsString on demand.

Adding an extensive SVGAngle test, that required to implement 'StrictTypeChecking' for attribute setters (was only implemented in V8/JSC for function cals so far).

Test: svg/dom/SVGAngle.html

  • GNUmakefile.am: Add SVGAnimatedAngle.h to build.
  • WebCore.gypi: Ditto.
  • WebCore.pro: Ditto.
  • WebCore.vcproj/WebCore.vcproj: Ditto.
  • WebCore.xcodeproj/project.pbxproj: Ditto.
  • bindings/scripts/CodeGenerator.pm: Split IsPrimitiveType in IsPrimitiveType and IsNumericType.
  • bindings/scripts/CodeGeneratorJS.pm: Implement 'StrictTypeChecking' for setters and recognize SVGAngle as new SVGPropertyTearOff type.
  • bindings/scripts/CodeGeneratorObjC.pm: Ditto.
  • bindings/scripts/CodeGeneratorV8.pm: Ditto.
  • svg/DeprecatedSVGAnimatedPropertyTraits.h: Remove SVGAngle handling.
  • svg/DeprecatedSVGAnimatedTemplate.h: Remove SVGAnimatedAngle handling.
  • svg/SVGAngle.cpp: Rewrite, to consume less memory and to operate more efficient.
  • svg/SVGAngle.h: Ditto.
  • svg/SVGAngle.idl: Add 'StrictTypeChecking' to the value/valueInSpecifiedUnits methods.
  • svg/SVGAnimatedAngle.h: Added.
  • svg/SVGAnimatedAngle.idl: Mark as [SVGAnimatedProperty].
  • svg/SVGMarkerElement.cpp: (WebCore::SVGMarkerElement::parseMappedAttribute): SVGAngle::setValueAsString() now takes an ExceptionCode parameter.
  • svg/SVGMarkerElement.h: s/ANIMATED_PROPERTY/ANIMATED_PROPERTY_NEW/ for the SVGAngle type.
  • 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.
  • svg/SVGPoint.idl: Ditto.
  • svg/SVGRect.idl: Ditto.
  • svg/SVGSVGElement.idl: Remove obsolete [SVGLiveProperty] flag.

2010-10-23 Nikolas Zimmermann <nzimmermann@rim.com>

Reviewed by Dirk Schulze.

Convert SVGAngle to the new SVGPropertyTearOff concept, reimplement it properly
https://bugs.webkit.org/show_bug.cgi?id=48179

Add an extensive SVGAngle test, checking all getter/setters & methods, with valid and invalid arguments.
The test exposes bugs in Opera & FireFox, we now pass them all.

  • svg/dom/SVGAngle-expected.txt: Added.
  • svg/dom/SVGAngle.html: Added.
  • svg/dom/script-tests/SVGAngle.js: Added.
  • svg/dom/svg-element-attribute-js-null-expected.txt:
  • svg/dom/svg-element-attribute-js-null.xhtml: Update incorrect test, setting valueAsString to null, should not result in "0deg" but "0".
Location:
trunk
Files:
4 added
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r70408 r70410  
     12010-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
    1172010-10-23  Dimitri Glazkov  <dglazkov@chromium.org>
    218
  • trunk/LayoutTests/svg/dom/svg-element-attribute-js-null-expected.txt

    r30635 r70410  
    44TEST SUCCEEDED: The value was the empty string. [tested SVGElement.xmlbase]
    55
    6 TEST SUCCEEDED: The value was the string '0deg'. [tested SVGAngle.valueAsString]
     6TEST SUCCEEDED: The value was the string '0'. [tested SVGAngle.valueAsString]
    77
    88TEST SUCCEEDED: The value was the string '0'. [tested SVGLength.valueAsString]
  • trunk/LayoutTests/svg/dom/svg-element-attribute-js-null.xhtml

    r23915 r70410  
    6161                    elementToUse: svg.createSVGAngle(),
    6262                    attributes: [
    63                         {name: 'valueAsString', expectedNull: '0deg'}
     63                        {name: 'valueAsString', expectedNull: '0'}
    6464                    ]
    6565                },
  • trunk/WebCore/ChangeLog

    r70407 r70410  
     12010-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
    1392010-10-23  Daniel Bates  <dbates@rim.com>
    240
  • trunk/WebCore/GNUmakefile.am

    r70400 r70410  
    30293029        WebCore/svg/SVGAnimateColorElement.cpp \
    30303030        WebCore/svg/SVGAnimateColorElement.h \
     3031        WebCore/svg/SVGAnimatedAngle.h \
    30313032        WebCore/svg/SVGAnimatedLength.h \
    30323033        WebCore/svg/SVGAnimatedLengthList.h \
  • trunk/WebCore/WebCore.gypi

    r70400 r70410  
    39593959            'svg/SVGAnimateTransformElement.cpp',
    39603960            'svg/SVGAnimateTransformElement.h',
     3961            'svg/SVGAnimatedAngle.h',
    39613962            'svg/SVGAnimatedLength.h',
    39623963            'svg/SVGAnimatedLengthList.h',
  • trunk/WebCore/WebCore.pro

    r70400 r70410  
    23592359    svg/SVGAngle.h \
    23602360    svg/SVGAnimateColorElement.h \
     2361    svg/SVGAnimatedAngle.h \
    23612362    svg/SVGAnimatedLength.h \
    23622363    svg/SVGAnimatedLengthList.h \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r70400 r70410  
    6117261172                        </File>
    6117361173                        <File
     61174                                RelativePath="..\svg\SVGAnimatedAngle.h"
     61175                                >
     61176                        </File>
     61177                        <File
    6117461178                                RelativePath="..\svg\SVGAnimatedLength.h"
    6117561179                                >
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r70400 r70410  
    157157                08744BAA0EDB7D86004C9E63 /* WMLOnEventElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08744BA90EDB7D86004C9E63 /* WMLOnEventElement.cpp */; };
    158158                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, ); }; };
    159160                087D97BF10FB8D7700C00874 /* JSSVGPODListCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 087D97BE10FB8D7700C00874 /* JSSVGPODListCustom.h */; };
    160161                087FFA0F0EFF3ED3009DBD88 /* WMLInsertedLegendElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 087FFA0D0EFF3ED3009DBD88 /* WMLInsertedLegendElement.cpp */; };
     
    61566157                08744BA90EDB7D86004C9E63 /* WMLOnEventElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WMLOnEventElement.cpp; sourceTree = "<group>"; };
    61576158                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>"; };
    61586160                087D97BE10FB8D7700C00874 /* JSSVGPODListCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSVGPODListCustom.h; sourceTree = "<group>"; };
    61596161                087FFA0D0EFF3ED3009DBD88 /* WMLInsertedLegendElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WMLInsertedLegendElement.cpp; sourceTree = "<group>"; };
     
    1594215944                                B22277E40D00BF1F0071B782 /* SVGAnimateColorElement.h */,
    1594315945                                B22277E50D00BF1F0071B782 /* SVGAnimateColorElement.idl */,
     15946                                087B84951272CEC700A14417 /* SVGAnimatedAngle.h */,
    1594415947                                B22277E60D00BF1F0071B782 /* SVGAnimatedAngle.idl */,
    1594515948                                B22277E70D00BF1F0071B782 /* SVGAnimatedBoolean.idl */,
     
    2115221155                                089021AD126EF5E90092D5EA /* SVGAnimatedLengthList.h in Headers */,
    2115321156                                8AB4BC77126FDB7100DEB727 /* IgnoreDestructiveWriteCountIncrementer.h in Headers */,
     21157                                087B84961272CEC800A14417 /* SVGAnimatedAngle.h in Headers */,
    2115421158                        );
    2115521159                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/bindings/scripts/CodeGenerator.pm

    r70223 r70410  
    66# Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
    77# Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
     8# Copyright (C) Research In Motion Limited 2010. All rights reserved.
    89#
    910# This library is free software; you can redistribute it and/or
     
    4344my $verbose = 0;
    4445
    45 my %primitiveTypeHash = ("int" => 1, "short" => 1, "long" => 1, "long long" => 1,
    46                          "unsigned int" => 1, "unsigned short" => 1,
    47                          "unsigned long" => 1, "unsigned long long" => 1,
    48                          "float" => 1, "double" => 1,
    49                          "boolean" => 1, "void" => 1,
    50                         "Date" => 1);
     46my %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
     51my %primitiveTypeHash = ( "boolean" => 1, "void" => 1, "Date" => 1);
    5152
    5253my %podTypeHash = ("SVGNumber" => 1, "SVGTransform" => 1);
    53 my %podTypesWithWritablePropertiesHash = ("SVGAngle" => 1, "SVGMatrix" => 1, "SVGPoint" => 1, "SVGPreserveAspectRatio" => 1, "SVGRect" => 1);
     54my %podTypesWithWritablePropertiesHash = ("SVGMatrix" => 1, "SVGPoint" => 1, "SVGPreserveAspectRatio" => 1, "SVGRect" => 1);
    5455my %stringTypeHash = ("DOMString" => 1, "AtomicString" => 1);
    5556
    5657my %nonPointerTypeHash = ("DOMTimeStamp" => 1, "CompareHow" => 1, "SVGPaintType" => 1);
    5758
    58 my %svgNewStyleAnimatedTypeHash = ("SVGAnimatedLength" => 1, "SVGAnimatedLengthList" => 1);
     59my %svgTypeNeedingTearOffHash = ("SVGLength" => 1, "SVGAngle" => 1);
     60
     61my %svgNewStyleAnimatedTypeHash = ("SVGAnimatedAngle" => 1, "SVGAnimatedLength" => 1, "SVGAnimatedLengthList" => 1);
    5962
    6063my %svgAnimatedTypeHash = ("SVGAnimatedAngle" => 1, "SVGAnimatedBoolean" => 1,
     
    284287
    285288# 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.
    286291sub IsPodType
    287292{
     
    303308}
    304309
     310sub IsNumericType
     311{
     312    my $object = shift;
     313    my $type = shift;
     314
     315    return 1 if $numericTypeHash{$type};
     316    return 0;
     317}
     318
    305319sub IsPrimitiveType
    306320{
     
    309323
    310324    return 1 if $primitiveTypeHash{$type};
     325    return 1 if $numericTypeHash{$type};
    311326    return 0;
    312327}
     
    326341    my $type = shift;
    327342
    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
     348sub IsSVGTypeNeedingTearOff
     349{
     350    my $object = shift;
     351    my $type = shift;
     352
     353    return 1 if $svgTypeNeedingTearOffHash{$type};
    329354    return 0;
    330355}
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r70300 r70410  
    325325}
    326326
     327# FIXME: This method will go away once all SVG animated properties are converted to the new scheme.
    327328sub IsSVGTypeNeedingContextParameter
    328329{
     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
    329332    my $implClassName = shift;
    330333
     
    333336    return 0 if $codeGenerator->IsSVGNewStyleAnimatedType($implClassName);
    334337
    335     my @noContextNeeded = ("SVGLength", "SVGLengthList", "SVGPaint", "SVGColor", "SVGDocument", "SVGZoomEvent");
     338    my @noContextNeeded = ("SVGAngle", "SVGLength", "SVGLengthList", "SVGPaint", "SVGColor", "SVGDocument", "SVGZoomEvent");
    336339    foreach (@noContextNeeded) {
    337340        return 0 if $implClassName eq $_;
     
    18031806                            push(@implContent, "    $className* castedThis = static_cast<$className*>(thisObject);\n");
    18041807                            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");
    18051833                            if ($svgPropertyOrPodType) {
    18061834                                push(@implContent, "    $svgPropertyOrPodType podImp(*imp);\n") if $podType;
    18071835                                push(@implContent, "    $svgPropertyOrPodType& podImp = imp->propertyReference();\n") if !$podType;
    18081836                                if ($svgPropertyOrPodType eq "float") { # Special case for JSSVGNumber
    1809                                     push(@implContent, "    podImp = " . JSValueToNative($attribute->signature, "value") . ";\n");
     1837                                    push(@implContent, "    podImp = $nativeValue;\n");
    18101838                                } 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};
    18121843                                }
    18131844                                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                                }
    18151853                            } else {
    1816                                 my $nativeValue = JSValueToNative($attribute->signature, "value");
    18171854                                my $setterExpressionPrefix = $codeGenerator->SetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute);
    1818 
    1819                                 push(@implContent, "    ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions};
    18201855                                push(@implContent, "    imp->$setterExpressionPrefix$nativeValue");
    18211856                                push(@implContent, ", ec") if @{$attribute->setterExceptions};
     
    20092044
    20102045                        my $name = $parameter->name;
    2011 
    2012                         if ($parameter->type eq "XPathNSResolver") {
     2046                        my $argType = $codeGenerator->StripModule($parameter->type);
     2047
     2048                        if ($argType eq "XPathNSResolver") {
    20132049                            push(@implContent, "    RefPtr<XPathNSResolver> customResolver;\n");
    20142050                            push(@implContent, "    XPathNSResolver* resolver = toXPathNSResolver(exec->argument($argsIndex));\n");
     
    20202056                            push(@implContent, "    }\n");
    20212057                        } elsif ($parameter->extendedAttributes->{"Callback"}) {
    2022                             my $callbackClassName = GetCallbackClassName($parameter->type);
     2058                            my $callbackClassName = GetCallbackClassName($argType);
    20232059                            $implIncludes{"$callbackClassName.h"} = 1;
    20242060                            if ($parameter->extendedAttributes->{"Optional"}) {
    2025                                 push(@implContent, "    RefPtr<" . $parameter->type. "> $name;\n");
     2061                                push(@implContent, "    RefPtr<$argType> $name;\n");
    20262062                                push(@implContent, "    if (exec->argumentCount() > $argsIndex && !exec->argument($argsIndex).isNull() && !exec->argument($argsIndex).isUndefined()) {\n");
    20272063                                push(@implContent, "        if (!exec->argument($argsIndex).isObject()) {\n");
     
    20362072                                push(@implContent, "        return JSValue::encode(jsUndefined());\n");
    20372073                                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");
    20392075                            }
    20402076                        } else {
     
    20432079                            if ($function->signature->extendedAttributes->{"StrictTypeChecking"}) {
    20442080                                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)) {
    20472088                                    push(@implContent, "    if (exec->argumentCount() > $argsIndex && !${argValue}.isUndefinedOrNull() && !${argValue}.inherits(&JS${argType}::s_info))\n");
    20482089                                    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                                }
    20532091                            }
    20542092
     
    20682106                            push(@implContent, "    if (exec->hadException())\n");
    20692107                            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                            }
    20702115                        }
    20712116
    20722117                        $functionString .= ", " if $paramIndex;
    20732118
    2074                         if ($parameter->type eq "NodeFilter") {
     2119                        if ($argType eq "NodeFilter") {
    20752120                            $functionString .= "$name.get()";
     2121                        } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($argType) and not $implClassName =~ /List$/) {
     2122                            $functionString .= "$name->propertyReference()";
    20762123                        } else {
    20772124                            $functionString .= $name;
     
    23722419        push(@implContent, $indent . "setDOMException(exec, ec);\n") if @{$function->raisesExceptions};
    23732420        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
    23752431        push(@implContent, $indent . "return JSValue::encode(jsUndefined());\n");
    23762432    } else {
     
    24142470    "SerializedScriptValue" => "RefPtr<SerializedScriptValue>",
    24152471    "IDBKey" => "RefPtr<IDBKey>",
    2416     "SVGAngle" => "SVGAngle",
     2472    "SVGAngle" => "SVGPropertyTearOff<SVGAngle>*",
    24172473    "SVGLength" => "SVGPropertyTearOff<SVGLength>*",
    24182474    "SVGMatrix" => "AffineTransform",
     
    25682624    }
    25692625
    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 
    25762626    if ($type eq "CSSStyleDeclaration") {
    25772627        $implIncludes{"CSSMutableStyleDeclaration.h"} = 1;
     
    26132663    }
    26142664
    2615     # Convert from abstract SVGProperty to real type, so the right toJS() method can be invoked.
    26162665    if ($codeGenerator->IsSVGNewStyleAnimatedType($implClassName)) {
     2666        # Convert from abstract SVGProperty to real type, so the right toJS() method can be invoked.
    26172667        if ($implClassName =~ /List$/) {
    26182668            $value = "static_cast<SVGListPropertyTearOff<$type>*>($value)";
     
    26202670            $value = "static_cast<SVGPropertyTearOff<$type>*>($value)";
    26212671        }
     2672    } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($type) and not $implClassName =~ /List$/) {
     2673        $value = "SVGPropertyTearOff<$type>::create($value)";
    26222674    }
    26232675
  • trunk/WebCore/bindings/scripts/CodeGeneratorObjC.pm

    r70223 r70410  
    77# Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
    88# Copyright (C) 2010 Google Inc.
     9# Copyright (C) Research In Motion Limited 2010. All rights reserved.
    910#
    1011# This library is free software; you can redistribute it and/or
     
    13701371                    $getterContentHead = "$getterExpressionPrefix";
    13711372                    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                    }
    13741383                } elsif ($svgListPropertyType) {
    13751384                    $getterContentHead = "$getterExpressionPrefix";
     
    15041513            push(@parameterNames, "ec") if $raisesExceptions and !($svgMatrixRotateFromVector || $svgMatrixInverse);
    15051514            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
    15061544            my $content = $codeGenerator->WK_lcfirst($functionName) . "(" . join(", ", @parameterNames) . ")";
    15071545
     
    15551593            } else {
    15561594                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)))";
    15601597                    } elsif ($codeGenerator->IsPodType($function->signature->type)) {
    15611598                        $content = "kit($content)";
  • trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r70300 r70410  
    77# Copyright (C) 2007, 2008, 2009 Google Inc.
    88# Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
     9# Copyright (C) Research In Motion Limited 2010. All rights reserved.
    910#
    1011# This library is free software; you can redistribute it and/or
     
    8889
    8990# 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.
    9092sub IsPodType
    9193{
     
    937939    push(@implContentDecls, "    INC_STATS(\"DOM.$implClassName.$attrName._set\");\n");
    938940
     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
    939963    my $isPodType = IsPodType($implClassName);
    940964    my $svgPropertyType = $dataNode->extendedAttributes->{"SVGProperty"};
     
    10511075        push(@implContentDecls, "    wrapper->commitChange(*imp, V8Proxy::svgContext(wrapper));\n");
    10521076    } 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        }
    10541083    } elsif (IsSVGTypeNeedingContextParameter($implClassName)) {
    10551084        $implIncludes{"SVGElement.h"} = 1;
     
    13781407                my $argValue = "args[$paramIndex]";
    13791408                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");
    13821411                    push(@implContentDecls, "        V8Proxy::throwTypeError();\n");
    13831412                    push(@implContentDecls, "        return notHandledByInterceptor();\n");
    13841413                    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");
    13871421                    push(@implContentDecls, "        V8Proxy::throwTypeError();\n");
    13881422                    push(@implContentDecls, "        return notHandledByInterceptor();\n");
     
    27122746        if ($parameter->type eq "NodeFilter" || $parameter->type eq "XPathNSResolver") {
    27132747            $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";
    27142754        } else {
    27152755            $functionString .= $paramName;
     
    27762816        $return = "wrapper";
    27772817    }
    2778    
    2779     my $svgLivePropertyType = $function->signature->extendedAttributes->{"SVGLiveProperty"};
    2780     if ($svgLivePropertyType) {
     2818
     2819    if ($codeGenerator->IsSVGTypeNeedingTearOff($returnType) and not $implClassName =~ /List$/) {
    27812820        $implIncludes{"V8$returnType.h"} = 1;
    27822821        $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";
    27842823    }
    27852824
     
    29032942    return "AffineTransform" if $type eq "SVGMatrix";
    29042943    return "SVGTransform" if $type eq "SVGTransform";
    2905     return "SVGAngle" if $type eq "SVGAngle";
     2944    return "RefPtr<SVGPropertyTearOff<SVGAngle> >" if $type eq "SVGAngle";
    29062945    return "RefPtr<SVGPropertyTearOff<SVGLength> >" if $type eq "SVGLength";
    29072946    return "SVGListPropertyTearOff<SVGLengthList>*" if $type eq "SVGLengthList";
     
    29572996    my $type = GetTypeFromSignature($signature);
    29582997
    2959     return 1 if $type eq "SVGAngle";
    29602998    return 1 if $type eq "SVGMatrix";
    29612999    return 1 if $type eq "SVGPoint";
     
    32813319}
    32823320
     3321# FIXME: This method will go away once all SVG animated properties are converted to the new scheme.
    32833322sub GenerateSVGStaticPodTypeWrapper {
    32843323    my $type = shift;
     
    33353374}
    33363375
     3376# FIXME: This method will go away once all SVG animated properties are converted to the new scheme.
    33373377sub IsSVGTypeNeedingContextParameter
    33383378{
     
    33413381    return 0 if $codeGenerator->IsSVGNewStyleAnimatedType($implClassName);
    33423382    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/;
    33443389    }
    33453390
     
    33473392}
    33483393
     3394# FIXME: This method will go away once all SVG animated properties are converted to the new scheme.
    33493395sub GenerateSVGContextAssignment
    33503396{
     
    33593405}
    33603406
     3407# FIXME: This method will go away once all SVG animated properties are converted to the new scheme.
    33613408sub GenerateSVGContextRetrieval
    33623409{
  • trunk/WebCore/svg/DeprecatedSVGAnimatedPropertyTraits.h

    r70223 r70410  
    2525#include "FloatRect.h"
    2626#include "PlatformString.h"
    27 #include "SVGAngle.h"
    2827#include "SVGNumberList.h"
    2928#include "SVGPreserveAspectRatio.h"
     
    3433template<typename Type>
    3534struct DeprecatedSVGAnimatedPropertyTraits : public Noncopyable { };
    36 
    37 // SVGAnimatedAngle
    38 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 };
    4835
    4936// SVGAnimatedBoolean
  • trunk/WebCore/svg/DeprecatedSVGAnimatedTemplate.h

    r70223 r70410  
    2929namespace WebCore {
    3030   
    31     class SVGAngle;
    3231    class SVGElement;
    3332    class SVGNumberList;
     
    156155
    157156    // Common type definitions, to ease IDL generation.
    158     typedef DeprecatedSVGAnimatedTemplate<SVGAngle> SVGAnimatedAngle;
    159157    typedef DeprecatedSVGAnimatedTemplate<bool> SVGAnimatedBoolean;
    160158    typedef DeprecatedSVGAnimatedTemplate<int> SVGAnimatedEnumeration;
  • trunk/WebCore/svg/SVGAngle.cpp

    r66397 r70410  
    22 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
     4 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
    45 *
    56 * This library is free software; you can redistribute it and/or
     
    2021
    2122#include "config.h"
     23
     24#if ENABLE(SVG)
    2225#include "SVGAngle.h"
    2326
    24 #if ENABLE(SVG)
    25 
     27#include "SVGParserUtilities.h"
     28#include <wtf/text/StringConcatenate.h>
    2629#include <wtf/MathExtras.h>
    2730
     
    2932
    3033SVGAngle::SVGAngle()
    31     : m_unitType(SVG_ANGLETYPE_UNKNOWN)
    32     , m_value(0)
     34    : m_unitType(SVG_ANGLETYPE_UNSPECIFIED)
    3335    , m_valueInSpecifiedUnits(0)
    3436{
    3537}
    3638
     39float 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
    3756void SVGAngle::setValue(float value)
    3857{
    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
     73inline 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
     112String 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
     130void 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;
    55153    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
     156void 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
     169void 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;
    84185        case SVG_ANGLETYPE_UNSPECIFIED:
    85186        case SVG_ANGLETYPE_DEG:
    86             m_valueAsString += "deg";
     187            m_valueInSpecifiedUnits = rad2deg(m_valueInSpecifiedUnits);
    87188            break;
    88189        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);
    90203            break;
    91204        case SVG_ANGLETYPE_GRAD:
    92             m_valueAsString += "grad";
    93             break;
    94205        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);
    127234}
    128235
  • trunk/WebCore/svg/SVGAngle.h

    r66397 r70410  
    22 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
     4 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
    45 *
    56 * This library is free software; you can redistribute it and/or
     
    2324
    2425#if ENABLE(SVG)
    25 #include "PlatformString.h"
     26#include "ExceptionCode.h"
     27#include <wtf/text/WTFString.h>
    2628
    2729namespace WebCore {
    2830
    29     class SVGAngle {
    30     public:
    31         SVGAngle();
     31class SVGAngle {
     32public:
     33    SVGAngle();
    3234
    33         enum SVGAngleType {
    34             SVG_ANGLETYPE_UNKNOWN          = 0,
    35             SVG_ANGLETYPE_UNSPECIFIED      = 1,
    36             SVG_ANGLETYPE_DEG              = 2,
    37             SVG_ANGLETYPE_RAD              = 3,
    38             SVG_ANGLETYPE_GRAD              = 4
    39         };
     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    };
    4042
    41         SVGAngleType unitType() const { return m_unitType; }
     43    SVGAngleType unitType() const { return m_unitType; }
    4244
    43         void setValue(float);
    44         float value() const { return m_value; }
     45    void setValue(float);
     46    float value() const;
    4547
    46         void setValueInSpecifiedUnits(float valueInSpecifiedUnits);
    47         float valueInSpecifiedUnits() const { return m_valueInSpecifiedUnits; }
     48    void setValueInSpecifiedUnits(float valueInSpecifiedUnits) { m_valueInSpecifiedUnits = valueInSpecifiedUnits; }
     49    float valueInSpecifiedUnits() const { return m_valueInSpecifiedUnits; }
    4850
    49         void setValueAsString(const String&);
    50         String valueAsString() const;
     51    void setValueAsString(const String&, ExceptionCode&);
     52    String valueAsString() const;
    5153
    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&);
    5456
    55     private:
    56         SVGAngleType m_unitType;
    57         float m_value;
    58         float m_valueInSpecifiedUnits;
    59         mutable String m_valueAsString;
    60 
    61         void calculate();
    62     };
     57private:
     58    SVGAngleType m_unitType;
     59    float m_valueInSpecifiedUnits;
     60};
    6361
    6462} // namespace WebCore
  • trunk/WebCore/svg/SVGAngle.idl

    r64579 r70410  
    2323module svg {
    2424
    25     interface [Conditional=SVG, PODType=SVGAngle] SVGAngle {
     25    interface [Conditional=SVG, SVGProperty=SVGAngle] SVGAngle {
    2626        // Angle Unit Types
    27         const unsigned short SVG_ANGLETYPE_UNKNOWN     = 0;
     27        const unsigned short SVG_ANGLETYPE_UNKNOWN = 0;
    2828        const unsigned short SVG_ANGLETYPE_UNSPECIFIED = 1;
    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        
     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
    3333        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);
    4145    };
    4246
  • trunk/WebCore/svg/SVGAnimatedAngle.idl

    r64579 r70410  
    2626module svg {
    2727
    28     interface [Conditional=SVG] SVGAnimatedAngle {
     28    interface [Conditional=SVG, SVGAnimatedProperty] SVGAnimatedAngle {
    2929        readonly attribute SVGAngle baseVal;
    3030        readonly attribute SVGAngle animVal;
  • trunk/WebCore/svg/SVGMarkerElement.cpp

    r66498 r70410  
    8282            setOrientTypeBaseValue(SVG_MARKER_ORIENT_AUTO);
    8383        else {
    84             angle.setValueAsString(attr->value());
     84            ExceptionCode ec = 0;
     85            angle.setValueAsString(attr->value(), ec);
    8586            setOrientTypeBaseValue(SVG_MARKER_ORIENT_ANGLE);
    8687        }
  • trunk/WebCore/svg/SVGMarkerElement.h

    r70223 r70410  
    8383    DECLARE_ANIMATED_PROPERTY(SVGMarkerElement, SVGNames::markerUnitsAttr, int, MarkerUnits, markerUnits)
    8484    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)
    8686
    8787    // SVGExternalResourcesRequired
  • trunk/WebCore/svg/SVGNumber.idl

    r64579 r70410  
    2424
    2525    interface [Conditional=SVG, PODType=float] SVGNumber {
    26                  attribute float value
    27                      setter raises(DOMException);
     26        attribute float value;
    2827    };
    2928
  • trunk/WebCore/svg/SVGPoint.idl

    r64579 r70410  
    2424
    2525    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;
    3028
    3129        SVGPoint matrixTransform(in SVGMatrix matrix);
  • trunk/WebCore/svg/SVGRect.idl

    r64579 r70410  
    2424
    2525    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;
    3430    };
    3531
  • trunk/WebCore/svg/SVGSVGElement.idl

    r70223 r70410  
    7474
    7575        SVGNumber createSVGNumber();
    76         [SVGLiveProperty] SVGLength createSVGLength();
     76        SVGLength createSVGLength();
    7777        SVGAngle createSVGAngle();
    7878        SVGPoint createSVGPoint();
Note: See TracChangeset for help on using the changeset viewer.