⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 98379 in webkit


Ignore:
Timestamp:
Oct 25, 2011, 12:48:28 PM (15 years ago)
Author:
abarth@webkit.org
Message:

Get rid of optional parameters in the middle in IDLs.
https://bugs.webkit.org/show_bug.cgi?id=70816

Patch by Pavel Podivilov <podivilov@chromium.org> on 2011-10-25
Reviewed by Adam Barth.

Optional parameters in the middle are prohibited by WebIDL spec.

Source/WebCore:

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateHeader):
(GenerateImplementation):

  • bindings/scripts/CodeGeneratorV8.pm:

(GenerateHeader):
(GenerateArgumentsCountCheck):
(GenerateImplementation):

  • html/canvas/CanvasRenderingContext2D.idl:
  • page/DOMWindow.idl:

LayoutTests:

  • fast/canvas/canvas-putImageData-expected.txt:
  • fast/canvas/canvas-putImageData.js:
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r98375 r98379  
     12011-10-25  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Get rid of optional parameters in the middle in IDLs.
     4        https://bugs.webkit.org/show_bug.cgi?id=70816
     5
     6        Reviewed by Adam Barth.
     7
     8        Optional parameters in the middle are prohibited by WebIDL spec.
     9
     10        * fast/canvas/canvas-putImageData-expected.txt:
     11        * fast/canvas/canvas-putImageData.js:
     12
    1132011-10-25  Julien Chaffraix  <jchaffraix@webkit.org>
    214
  • trunk/LayoutTests/fast/canvas/canvas-putImageData-expected.txt

    r97566 r98379  
    145145PASS getPixel(1,1) is [0,128,0,255]
    146146PASS getPixel(9,9) is [0,128,0,255]
    147 PASS context.putImageData({}, 0, 0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
     147PASS context.putImageData({}, 0, 0) threw exception TypeError: Type error.
    148148PASS context.putImageData(buffer, NaN, 0, 0, 0, 0, 0) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
    149149PASS context.putImageData(buffer, 0, NaN, 0, 0, 0, 0) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
  • trunk/LayoutTests/fast/canvas/canvas-putImageData.js

    r59582 r98379  
    202202
    203203
    204 shouldThrow("context.putImageData({}, 0, 0)", "'Error: TYPE_MISMATCH_ERR: DOM Exception 17'");
     204shouldThrow("context.putImageData({}, 0, 0)", "'TypeError: Type error'");
    205205shouldThrow("context.putImageData(buffer, NaN, 0, 0, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");
    206206shouldThrow("context.putImageData(buffer, 0, NaN, 0, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");
  • trunk/Source/WebCore/ChangeLog

    r98374 r98379  
     12011-10-25  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Get rid of optional parameters in the middle in IDLs.
     4        https://bugs.webkit.org/show_bug.cgi?id=70816
     5
     6        Reviewed by Adam Barth.
     7
     8        Optional parameters in the middle are prohibited by WebIDL spec.
     9
     10        * bindings/scripts/CodeGeneratorJS.pm:
     11        (GenerateHeader):
     12        (GenerateImplementation):
     13        * bindings/scripts/CodeGeneratorV8.pm:
     14        (GenerateHeader):
     15        (GenerateArgumentsCountCheck):
     16        (GenerateImplementation):
     17        * html/canvas/CanvasRenderingContext2D.idl:
     18        * page/DOMWindow.idl:
     19
    1202011-10-25  Chris Evans  <cevans@google.com>
    221
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r98261 r98379  
    911911        push(@headerContent, "\n    // Custom functions\n");
    912912        foreach my $function (@{$dataNode->functions}) {
    913             if ($function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"JSCCustom"}) {
    914                 my $functionImplementationName = $function->signature->extendedAttributes->{"ImplementationFunction"} || $codeGenerator->WK_lcfirst($function->signature->name);
    915                 push(@headerContent, "    JSC::JSValue " . $functionImplementationName . "(JSC::ExecState*);\n");
    916             }
     913            next unless $function->signature->extendedAttributes->{"Custom"} or $function->signature->extendedAttributes->{"JSCCustom"};
     914            next if $function->{overloads} && $function->{overloadIndex} != 1;
     915            my $functionImplementationName = $function->signature->extendedAttributes->{"ImplementationFunction"} || $codeGenerator->WK_lcfirst($function->signature->name);
     916            push(@headerContent, "    JSC::JSValue " . $functionImplementationName . "(JSC::ExecState*);\n");
    917917        }
    918918    }
     
    19791979
    19801980            my $functionName = $codeGenerator->WK_lcfirst($className) . "PrototypeFunction" . $codeGenerator->WK_ucfirst($function->signature->name);
    1981 
    1982             if ($function->{overloads} && @{$function->{overloads}} > 1) {
     1981            my $isCustom = $function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"JSCCustom"};
     1982            my $isOverloaded = $function->{overloads} && @{$function->{overloads}} > 1;
     1983
     1984            next if $isCustom && $isOverloaded && $function->{overloadIndex} > 1;
     1985
     1986            if (!$isCustom && $isOverloaded) {
    19831987                # Append a number to an overloaded method's name to make it unique:
    19841988                $functionName = $functionName . $function->{overloadIndex};
     
    20232027            }
    20242028
    2025             if ($function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"JSCCustom"}) {
     2029            if ($isCustom) {
    20262030                push(@implContent, "    return JSValue::encode(castedThis->" . $functionImplementationName . "(exec));\n");
    20272031            } else {
     
    20602064            push(@implContent, "}\n\n");
    20612065
    2062             if ($function->{overloads} && @{$function->{overloads}} > 1 && $function->{overloadIndex} == @{$function->{overloads}}) {
     2066            if (!$isCustom && $isOverloaded && $function->{overloadIndex} == @{$function->{overloads}}) {
    20632067                # Generate a function dispatching call to the rest of the overloads.
    20642068                GenerateOverloadedPrototypeFunction($function, $dataNode, $implClassName);
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r98278 r98379  
    265265    # EventTarget.
    266266    $codeGenerator->AddMethodsConstantsAndAttributesFromParentClasses($dataNode, \@allParents, 1);
     267    $codeGenerator->LinkOverloadedFunctions($dataNode);
    267268
    268269    my $hasDependentLifetime = $dataNode->extendedAttributes->{"V8DependentLifetime"} || $dataNode->extendedAttributes->{"ActiveDOMObject"} || $className =~ /SVG/;
     
    372373        my $attrExt = $function->signature->extendedAttributes;
    373374
    374         if ($attrExt->{"Custom"} || $attrExt->{"V8Custom"}) {
     375        if (($attrExt->{"Custom"} || $attrExt->{"V8Custom"}) && $function->{overloadIndex} == 1) {
    375376            push(@headerContent, <<END);
    376377    static v8::Handle<v8::Value> ${name}Callback(const v8::Arguments&);
     
    13901391    $requiresAllArguments = $function->signature->extendedAttributes->{"RequiresAllArguments"} || $requiresAllArgumentsDefault;
    13911392    if ($requiresAllArguments) {
    1392         my $numMandatoryParams = @{$function->parameters};
    1393         foreach my $param (reverse(@{$function->parameters})) {
     1393        my $numMandatoryParams = 0;
     1394        my $optionalSeen = 0;
     1395        foreach my $param (@{$function->parameters}) {
    13941396            if ($param->extendedAttributes->{"Optional"}) {
    1395                 $numMandatoryParams--;
     1397                $optionalSeen = 1;
    13961398            } else {
    1397                 last;
     1399                die "An argument must not be declared to be optional unless all subsequent arguments to the operation are also optional." if $optionalSeen;
     1400                $numMandatoryParams++;
    13981401            }
    13991402        }
     
    20032006    }
    20042007
    2005     $codeGenerator->LinkOverloadedFunctions($dataNode);
    2006 
    20072008    my $indexer;
    20082009    my $namedPropertyGetter;
    20092010    # Generate methods for functions.
    20102011    foreach my $function (@{$dataNode->functions}) {
    2011         if (!($function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"V8Custom"})) {
     2012        my $isCustom = $function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"V8Custom"};
     2013        if (!$isCustom) {
    20122014            GenerateFunctionCallback($function, $dataNode, $implClassName);
    20132015            if ($function->{overloadIndex} > 1 && $function->{overloadIndex} == @{$function->{overloads}}) {
     
    20282030        # for different calling context.
    20292031        if (($dataNode->extendedAttributes->{"CheckDomainSecurity"} || ($interfaceName eq "DOMWindow")) && $function->signature->extendedAttributes->{"DoNotCheckDomainSecurity"}) {
    2030             GenerateDomainSafeFunctionGetter($function, $implClassName);
     2032            if (!$isCustom || $function->{overloadIndex} == 1) {
     2033                GenerateDomainSafeFunctionGetter($function, $implClassName);
     2034            }
    20312035        }
    20322036    }
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl

    r96626 r98379  
    158158        CanvasPattern createPattern(in HTMLImageElement image, in [ConvertNullToNullString] DOMString repetitionType)
    159159            raises (DOMException);
    160         void putImageData(in ImageData imagedata, in float dx, in float dy, in [Optional] float dirtyX, in float dirtyY, in float dirtyWidth, in float dirtyHeight)
     160        void putImageData(in ImageData imagedata, in float dx, in float dy)
     161            raises(DOMException);
     162        void putImageData(in ImageData imagedata, in float dx, in float dy, in float dirtyX, in float dirtyY, in float dirtyWidth, in float dirtyHeight)
    161163            raises(DOMException);
    162164        ImageData createImageData(in ImageData imagedata)
  • trunk/Source/WebCore/page/DOMWindow.idl

    r97926 r98379  
    213213        // cross-document messaging
    214214#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
    215         [DoNotCheckDomainSecurity, Custom] void postMessage(in SerializedScriptValue message, in [Optional] Array messagePorts, in DOMString targetOrigin)
     215        [DoNotCheckDomainSecurity, Custom] void postMessage(in SerializedScriptValue message, in DOMString targetOrigin)
    216216            raises(DOMException);
    217         [DoNotCheckDomainSecurity, Custom] void webkitPostMessage(in SerializedScriptValue message, in [Optional] Array transferList, in DOMString targetOrigin)
     217        [DoNotCheckDomainSecurity, Custom] void postMessage(in SerializedScriptValue message, in Array messagePorts, in DOMString targetOrigin)
     218            raises(DOMException);
     219
     220        [DoNotCheckDomainSecurity, Custom] void webkitPostMessage(in SerializedScriptValue message, in DOMString targetOrigin)
     221            raises(DOMException);
     222        [DoNotCheckDomainSecurity, Custom] void webkitPostMessage(in SerializedScriptValue message, in Array transferList, in DOMString targetOrigin)
    218223            raises(DOMException);
    219224#else
Note: See TracChangeset for help on using the changeset viewer.