Title: [98379] trunk
Revision
98379
Author
aba...@webkit.org
Date
2011-10-25 12:48:28 -0700 (Tue, 25 Oct 2011)

Log Message

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

Patch by Pavel Podivilov <podivi...@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:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (98378 => 98379)


--- trunk/LayoutTests/ChangeLog	2011-10-25 19:45:27 UTC (rev 98378)
+++ trunk/LayoutTests/ChangeLog	2011-10-25 19:48:28 UTC (rev 98379)
@@ -1,3 +1,15 @@
+2011-10-25  Pavel Podivilov  <podivi...@chromium.org>
+
+        Get rid of optional parameters in the middle in IDLs.
+        https://bugs.webkit.org/show_bug.cgi?id=70816
+
+        Reviewed by Adam Barth.
+
+        Optional parameters in the middle are prohibited by WebIDL spec.
+
+        * fast/canvas/canvas-putImageData-expected.txt:
+        * fast/canvas/canvas-putImageData.js:
+
 2011-10-25  Julien Chaffraix  <jchaffr...@webkit.org>
 
         Unreviewed gardening.

Modified: trunk/LayoutTests/fast/canvas/canvas-putImageData-expected.txt (98378 => 98379)


--- trunk/LayoutTests/fast/canvas/canvas-putImageData-expected.txt	2011-10-25 19:45:27 UTC (rev 98378)
+++ trunk/LayoutTests/fast/canvas/canvas-putImageData-expected.txt	2011-10-25 19:48:28 UTC (rev 98379)
@@ -144,7 +144,7 @@
 PASS getPixel(9,9) is [0,128,0,255]
 PASS getPixel(1,1) is [0,128,0,255]
 PASS getPixel(9,9) is [0,128,0,255]
-PASS context.putImageData({}, 0, 0) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
+PASS context.putImageData({}, 0, 0) threw exception TypeError: Type error.
 PASS context.putImageData(buffer, NaN, 0, 0, 0, 0, 0) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
 PASS context.putImageData(buffer, 0, NaN, 0, 0, 0, 0) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
 PASS context.putImageData(buffer, 0, 0, NaN, 0, 0, 0) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.

Modified: trunk/LayoutTests/fast/canvas/canvas-putImageData.js (98378 => 98379)


--- trunk/LayoutTests/fast/canvas/canvas-putImageData.js	2011-10-25 19:45:27 UTC (rev 98378)
+++ trunk/LayoutTests/fast/canvas/canvas-putImageData.js	2011-10-25 19:48:28 UTC (rev 98379)
@@ -201,7 +201,7 @@
 pixelShouldBe(9, 9, [0, 128,0,255]);
 
 
-shouldThrow("context.putImageData({}, 0, 0)", "'Error: TYPE_MISMATCH_ERR: DOM Exception 17'");
+shouldThrow("context.putImageData({}, 0, 0)", "'TypeError: Type error'");
 shouldThrow("context.putImageData(buffer, NaN, 0, 0, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");
 shouldThrow("context.putImageData(buffer, 0, NaN, 0, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");
 shouldThrow("context.putImageData(buffer, 0, 0, NaN, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");

Modified: trunk/Source/WebCore/ChangeLog (98378 => 98379)


--- trunk/Source/WebCore/ChangeLog	2011-10-25 19:45:27 UTC (rev 98378)
+++ trunk/Source/WebCore/ChangeLog	2011-10-25 19:48:28 UTC (rev 98379)
@@ -1,3 +1,22 @@
+2011-10-25  Pavel Podivilov  <podivi...@chromium.org>
+
+        Get rid of optional parameters in the middle in IDLs.
+        https://bugs.webkit.org/show_bug.cgi?id=70816
+
+        Reviewed by Adam Barth.
+
+        Optional parameters in the middle are prohibited by WebIDL spec.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateHeader):
+        (GenerateImplementation):
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateHeader):
+        (GenerateArgumentsCountCheck):
+        (GenerateImplementation):
+        * html/canvas/CanvasRenderingContext2D.idl:
+        * page/DOMWindow.idl:
+
 2011-10-25  Chris Evans  <cev...@google.com>
 
         Manage the CSS property array length correctly

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (98378 => 98379)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2011-10-25 19:45:27 UTC (rev 98378)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2011-10-25 19:48:28 UTC (rev 98379)
@@ -910,10 +910,10 @@
     if ($numCustomFunctions > 0) {
         push(@headerContent, "\n    // Custom functions\n");
         foreach my $function (@{$dataNode->functions}) {
-            if ($function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"JSCCustom"}) {
-                my $functionImplementationName = $function->signature->extendedAttributes->{"ImplementationFunction"} || $codeGenerator->WK_lcfirst($function->signature->name);
-                push(@headerContent, "    JSC::JSValue " . $functionImplementationName . "(JSC::ExecState*);\n");
-            }
+            next unless $function->signature->extendedAttributes->{"Custom"} or $function->signature->extendedAttributes->{"JSCCustom"};
+            next if $function->{overloads} && $function->{overloadIndex} != 1;
+            my $functionImplementationName = $function->signature->extendedAttributes->{"ImplementationFunction"} || $codeGenerator->WK_lcfirst($function->signature->name);
+            push(@headerContent, "    JSC::JSValue " . $functionImplementationName . "(JSC::ExecState*);\n");
         }
     }
 
@@ -1978,8 +1978,12 @@
             AddIncludesForTypeInImpl($function->signature->type);
 
             my $functionName = $codeGenerator->WK_lcfirst($className) . "PrototypeFunction" . $codeGenerator->WK_ucfirst($function->signature->name);
+            my $isCustom = $function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"JSCCustom"};
+            my $isOverloaded = $function->{overloads} && @{$function->{overloads}} > 1;
 
-            if ($function->{overloads} && @{$function->{overloads}} > 1) {
+            next if $isCustom && $isOverloaded && $function->{overloadIndex} > 1;
+
+            if (!$isCustom && $isOverloaded) {
                 # Append a number to an overloaded method's name to make it unique:
                 $functionName = $functionName . $function->{overloadIndex};
                 # Make this function static to avoid compiler warnings, since we
@@ -2022,7 +2026,7 @@
                 push(@implContent, "        return JSValue::encode(jsUndefined());\n");
             }
 
-            if ($function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"JSCCustom"}) {
+            if ($isCustom) {
                 push(@implContent, "    return JSValue::encode(castedThis->" . $functionImplementationName . "(exec));\n");
             } else {
                 push(@implContent, "    $implType* imp = static_cast<$implType*>(castedThis->impl());\n");
@@ -2059,7 +2063,7 @@
 
             push(@implContent, "}\n\n");
 
-            if ($function->{overloads} && @{$function->{overloads}} > 1 && $function->{overloadIndex} == @{$function->{overloads}}) {
+            if (!$isCustom && $isOverloaded && $function->{overloadIndex} == @{$function->{overloads}}) {
                 # Generate a function dispatching call to the rest of the overloads.
                 GenerateOverloadedPrototypeFunction($function, $dataNode, $implClassName);
             }

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (98378 => 98379)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2011-10-25 19:45:27 UTC (rev 98378)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2011-10-25 19:48:28 UTC (rev 98379)
@@ -264,6 +264,7 @@
     # Copy contents of parent classes except the first parent or if it is
     # EventTarget.
     $codeGenerator->AddMethodsConstantsAndAttributesFromParentClasses($dataNode, \@allParents, 1);
+    $codeGenerator->LinkOverloadedFunctions($dataNode);
 
     my $hasDependentLifetime = $dataNode->extendedAttributes->{"V8DependentLifetime"} || $dataNode->extendedAttributes->{"ActiveDOMObject"} || $className =~ /SVG/;
     if (!$hasDependentLifetime) {
@@ -371,7 +372,7 @@
         my $name = $function->signature->name;
         my $attrExt = $function->signature->extendedAttributes;
 
-        if ($attrExt->{"Custom"} || $attrExt->{"V8Custom"}) {
+        if (($attrExt->{"Custom"} || $attrExt->{"V8Custom"}) && $function->{overloadIndex} == 1) {
             push(@headerContent, <<END);
     static v8::Handle<v8::Value> ${name}Callback(const v8::Arguments&);
 END
@@ -1389,12 +1390,14 @@
     }
     $requiresAllArguments = $function->signature->extendedAttributes->{"RequiresAllArguments"} || $requiresAllArgumentsDefault;
     if ($requiresAllArguments) {
-        my $numMandatoryParams = @{$function->parameters};
-        foreach my $param (reverse(@{$function->parameters})) {
+        my $numMandatoryParams = 0;
+        my $optionalSeen = 0;
+        foreach my $param (@{$function->parameters}) {
             if ($param->extendedAttributes->{"Optional"}) {
-                $numMandatoryParams--;
+                $optionalSeen = 1;
             } else {
-                last;
+                die "An argument must not be declared to be optional unless all subsequent arguments to the operation are also optional." if $optionalSeen;
+                $numMandatoryParams++;
             }
         }
         if ($numMandatoryParams >= 1) {
@@ -2002,13 +2005,12 @@
         GenerateConstructorGetter($implClassName);
     }
 
-    $codeGenerator->LinkOverloadedFunctions($dataNode);
-
     my $indexer;
     my $namedPropertyGetter;
     # Generate methods for functions.
     foreach my $function (@{$dataNode->functions}) {
-        if (!($function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"V8Custom"})) {
+        my $isCustom = $function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"V8Custom"};
+        if (!$isCustom) {
             GenerateFunctionCallback($function, $dataNode, $implClassName);
             if ($function->{overloadIndex} > 1 && $function->{overloadIndex} == @{$function->{overloads}}) {
                 GenerateOverloadedFunctionCallback($function, $dataNode, $implClassName);
@@ -2027,7 +2029,9 @@
         # generate an access getter that returns different function objects
         # for different calling context.
         if (($dataNode->extendedAttributes->{"CheckDomainSecurity"} || ($interfaceName eq "DOMWindow")) && $function->signature->extendedAttributes->{"DoNotCheckDomainSecurity"}) {
-            GenerateDomainSafeFunctionGetter($function, $implClassName);
+            if (!$isCustom || $function->{overloadIndex} == 1) {
+                GenerateDomainSafeFunctionGetter($function, $implClassName);
+            }
         }
     }
 

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl (98378 => 98379)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl	2011-10-25 19:45:27 UTC (rev 98378)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl	2011-10-25 19:48:28 UTC (rev 98379)
@@ -157,8 +157,10 @@
             raises (DOMException);
         CanvasPattern createPattern(in HTMLImageElement image, in [ConvertNullToNullString] DOMString repetitionType)
             raises (DOMException);
-        void putImageData(in ImageData imagedata, in float dx, in float dy, in [Optional] float dirtyX, in float dirtyY, in float dirtyWidth, in float dirtyHeight)
+        void putImageData(in ImageData imagedata, in float dx, in float dy)
             raises(DOMException);
+        void putImageData(in ImageData imagedata, in float dx, in float dy, in float dirtyX, in float dirtyY, in float dirtyWidth, in float dirtyHeight)
+            raises(DOMException);
         ImageData createImageData(in ImageData imagedata)
             raises (DOMException);
         ImageData createImageData(in float sw, in float sh)

Modified: trunk/Source/WebCore/page/DOMWindow.idl (98378 => 98379)


--- trunk/Source/WebCore/page/DOMWindow.idl	2011-10-25 19:45:27 UTC (rev 98378)
+++ trunk/Source/WebCore/page/DOMWindow.idl	2011-10-25 19:48:28 UTC (rev 98379)
@@ -212,10 +212,15 @@
 
         // cross-document messaging
 #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
-        [DoNotCheckDomainSecurity, Custom] void postMessage(in SerializedScriptValue message, in [Optional] Array messagePorts, in DOMString targetOrigin)
+        [DoNotCheckDomainSecurity, Custom] void postMessage(in SerializedScriptValue message, in DOMString targetOrigin)
             raises(DOMException);
-        [DoNotCheckDomainSecurity, Custom] void webkitPostMessage(in SerializedScriptValue message, in [Optional] Array transferList, in DOMString targetOrigin)
+        [DoNotCheckDomainSecurity, Custom] void postMessage(in SerializedScriptValue message, in Array messagePorts, in DOMString targetOrigin)
             raises(DOMException);
+
+        [DoNotCheckDomainSecurity, Custom] void webkitPostMessage(in SerializedScriptValue message, in DOMString targetOrigin)
+            raises(DOMException);
+        [DoNotCheckDomainSecurity, Custom] void webkitPostMessage(in SerializedScriptValue message, in Array transferList, in DOMString targetOrigin)
+            raises(DOMException);
 #else
         // There's no good way to expose an array via the ObjC bindings, so for now just allow passing in a single port.
         [DoNotCheckDomainSecurity, Custom] void postMessage(in SerializedScriptValue message, in [Optional] MessagePort messagePort, in DOMString targetOrigin)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to