Title: [87736] trunk
Revision
87736
Author
[email protected]
Date
2011-05-31 09:28:33 -0700 (Tue, 31 May 2011)

Log Message

2011-05-31  Andreas Kling  <[email protected]>

        Reviewed by Antti Koivisto.

        Canvas/JSC: Auto-generate overloads for setShadow()
        https://bugs.webkit.org/show_bug.cgi?id=61786

        Move CanvasRenderingContext2D.setShadow() to auto-generated JSC bindings.

        There is a subtle difference to the previous behavior: invalid numbers of
        arguments now raise TypeError instead of SyntaxError. This is in accordance
        with Web IDL, and matches the existing V8 bindings.

        Test: fast/canvas/canvas-overloads-setShadow.html

        * bindings/js/JSCanvasRenderingContext2DCustom.cpp:
        * html/canvas/CanvasRenderingContext2D.idl:
2011-05-31  Andreas Kling  <[email protected]>

        Reviewed by Antti Koivisto.

        Canvas/JSC: Auto-generate overloads for setShadow()
        https://bugs.webkit.org/show_bug.cgi?id=61786

        Add a test to verify the behavior of setShadow() when called
        with different numbers of arguments.

        * fast/canvas/canvas-overloads-setShadow-expected.txt: Added.
        * fast/canvas/canvas-overloads-setShadow.html: Added.
        * fast/canvas/script-tests/canvas-overloads-setShadow.js: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (87735 => 87736)


--- trunk/LayoutTests/ChangeLog	2011-05-31 16:25:34 UTC (rev 87735)
+++ trunk/LayoutTests/ChangeLog	2011-05-31 16:28:33 UTC (rev 87736)
@@ -2,6 +2,20 @@
 
         Reviewed by Antti Koivisto.
 
+        Canvas/JSC: Auto-generate overloads for setShadow()
+        https://bugs.webkit.org/show_bug.cgi?id=61786
+
+        Add a test to verify the behavior of setShadow() when called
+        with different numbers of arguments.
+
+        * fast/canvas/canvas-overloads-setShadow-expected.txt: Added.
+        * fast/canvas/canvas-overloads-setShadow.html: Added.
+        * fast/canvas/script-tests/canvas-overloads-setShadow.js: Added.
+
+2011-05-31  Andreas Kling  <[email protected]>
+
+        Reviewed by Antti Koivisto.
+
         Canvas/JSC: Auto-generate overloads for drawImageFromRect()
         https://bugs.webkit.org/show_bug.cgi?id=61709
 

Added: trunk/LayoutTests/fast/canvas/canvas-overloads-setShadow-expected.txt (0 => 87736)


--- trunk/LayoutTests/fast/canvas/canvas-overloads-setShadow-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-overloads-setShadow-expected.txt	2011-05-31 16:28:33 UTC (rev 87736)
@@ -0,0 +1,23 @@
+Test the behavior of CanvasRenderingContext2D.setShadow() when called with different numbers of arguments.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS ctx.setShadow() threw exception TypeError: Type error.
+PASS ctx.setShadow(0) threw exception TypeError: Type error.
+PASS ctx.setShadow(0, 0) threw exception TypeError: Type error.
+PASS ctx.setShadow(0, 0, 0) is undefined
+PASS ctx.setShadow(0, 0, 0, 0) is undefined
+PASS ctx.setShadow(0, 0, 0, 0, 0) is undefined
+PASS ctx.setShadow(0, 0, 0, 0, 0, 0) threw exception TypeError: Type error.
+PASS ctx.setShadow(0, 0, 0, 0, 'red') is undefined
+PASS ctx.setShadow(0, 0, 0, 0, 'red', 0) threw exception TypeError: Type error.
+PASS ctx.setShadow(0, 0, 0, 0, 'red', 0, 0) is undefined
+PASS ctx.setShadow(0, 0, 0, 0, 0, 0) threw exception TypeError: Type error.
+PASS ctx.setShadow(0, 0, 0, 0, 0, 0, 0) is undefined
+PASS ctx.setShadow(0, 0, 0, 0, 0, 0, 0, 0) is undefined
+PASS ctx.setShadow(0, 0, 0, 0, 0, 0, 0, 0, 0) threw exception TypeError: Type error.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/canvas/canvas-overloads-setShadow.html (0 => 87736)


--- trunk/LayoutTests/fast/canvas/canvas-overloads-setShadow.html	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-overloads-setShadow.html	2011-05-31 16:28:33 UTC (rev 87736)
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/canvas/script-tests/canvas-overloads-setShadow.js (0 => 87736)


--- trunk/LayoutTests/fast/canvas/script-tests/canvas-overloads-setShadow.js	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/script-tests/canvas-overloads-setShadow.js	2011-05-31 16:28:33 UTC (rev 87736)
@@ -0,0 +1,22 @@
+description("Test the behavior of CanvasRenderingContext2D.setShadow() when called with different numbers of arguments.");
+
+var ctx = document.createElement('canvas').getContext('2d');
+
+var TypeError = "TypeError: Type error";
+
+shouldThrow("ctx.setShadow()", "TypeError");
+shouldThrow("ctx.setShadow(0)", "TypeError");
+shouldThrow("ctx.setShadow(0, 0)", "TypeError");
+shouldBe("ctx.setShadow(0, 0, 0)", "undefined");
+shouldBe("ctx.setShadow(0, 0, 0, 0)", "undefined");
+shouldBe("ctx.setShadow(0, 0, 0, 0, 0)", "undefined");
+shouldThrow("ctx.setShadow(0, 0, 0, 0, 0, 0)", "TypeError");
+shouldBe("ctx.setShadow(0, 0, 0, 0, 'red')", "undefined");
+shouldThrow("ctx.setShadow(0, 0, 0, 0, 'red', 0)", "TypeError");
+shouldBe("ctx.setShadow(0, 0, 0, 0, 'red', 0, 0)", "undefined");
+shouldThrow("ctx.setShadow(0, 0, 0, 0, 0, 0)", "TypeError");
+shouldBe("ctx.setShadow(0, 0, 0, 0, 0, 0, 0)", "undefined");
+shouldBe("ctx.setShadow(0, 0, 0, 0, 0, 0, 0, 0)", "undefined");
+shouldThrow("ctx.setShadow(0, 0, 0, 0, 0, 0, 0, 0, 0)", "TypeError");
+
+var successfullyParsed = true;

Modified: trunk/Source/WebCore/ChangeLog (87735 => 87736)


--- trunk/Source/WebCore/ChangeLog	2011-05-31 16:25:34 UTC (rev 87735)
+++ trunk/Source/WebCore/ChangeLog	2011-05-31 16:28:33 UTC (rev 87736)
@@ -2,6 +2,24 @@
 
         Reviewed by Antti Koivisto.
 
+        Canvas/JSC: Auto-generate overloads for setShadow()
+        https://bugs.webkit.org/show_bug.cgi?id=61786
+
+        Move CanvasRenderingContext2D.setShadow() to auto-generated JSC bindings.
+
+        There is a subtle difference to the previous behavior: invalid numbers of
+        arguments now raise TypeError instead of SyntaxError. This is in accordance
+        with Web IDL, and matches the existing V8 bindings.
+
+        Test: fast/canvas/canvas-overloads-setShadow.html
+
+        * bindings/js/JSCanvasRenderingContext2DCustom.cpp:
+        * html/canvas/CanvasRenderingContext2D.idl:
+
+2011-05-31  Andreas Kling  <[email protected]>
+
+        Reviewed by Antti Koivisto.
+
         Canvas/JSC: Auto-generate overloads for drawImageFromRect()
         https://bugs.webkit.org/show_bug.cgi?id=61709
 

Modified: trunk/Source/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp (87735 => 87736)


--- trunk/Source/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp	2011-05-31 16:25:34 UTC (rev 87735)
+++ trunk/Source/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp	2011-05-31 16:28:33 UTC (rev 87736)
@@ -95,52 +95,6 @@
     context->setFillStyle(toHTMLCanvasStyle(exec, value));
 }
 
-JSValue JSCanvasRenderingContext2D::setShadow(ExecState* exec)
-{ 
-    CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());
-
-    switch (exec->argumentCount()) {
-        case 3:
-            context->setShadow(exec->argument(0).toFloat(exec), exec->argument(1).toFloat(exec),
-                               exec->argument(2).toFloat(exec));
-            break;
-        case 4:
-            if (exec->argument(3).isString())
-                context->setShadow(exec->argument(0).toFloat(exec), exec->argument(1).toFloat(exec),
-                                   exec->argument(2).toFloat(exec), ustringToString(asString(exec->argument(3))->value(exec)));
-            else
-                context->setShadow(exec->argument(0).toFloat(exec), exec->argument(1).toFloat(exec),
-                                   exec->argument(2).toFloat(exec), exec->argument(3).toFloat(exec));
-            break;
-        case 5:
-            if (exec->argument(3).isString())
-                context->setShadow(exec->argument(0).toFloat(exec), exec->argument(1).toFloat(exec),
-                                   exec->argument(2).toFloat(exec), ustringToString(asString(exec->argument(3))->value(exec)),
-                                   exec->argument(4).toFloat(exec));
-            else
-                context->setShadow(exec->argument(0).toFloat(exec), exec->argument(1).toFloat(exec),
-                                   exec->argument(2).toFloat(exec), exec->argument(3).toFloat(exec),
-                                   exec->argument(4).toFloat(exec));
-            break;
-        case 7:
-            context->setShadow(exec->argument(0).toFloat(exec), exec->argument(1).toFloat(exec),
-                               exec->argument(2).toFloat(exec), exec->argument(3).toFloat(exec),
-                               exec->argument(4).toFloat(exec), exec->argument(5).toFloat(exec),
-                               exec->argument(6).toFloat(exec));
-            break;
-        case 8:
-            context->setShadow(exec->argument(0).toFloat(exec), exec->argument(1).toFloat(exec),
-                               exec->argument(2).toFloat(exec), exec->argument(3).toFloat(exec),
-                               exec->argument(4).toFloat(exec), exec->argument(5).toFloat(exec),
-                               exec->argument(6).toFloat(exec), exec->argument(7).toFloat(exec));
-            break;
-        default:
-            return throwSyntaxError(exec);
-    }
-    
-    return jsUndefined();    
-}
-
 JSValue JSCanvasRenderingContext2D::createPattern(ExecState* exec)
 { 
     CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl (87735 => 87736)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl	2011-05-31 16:25:34 UTC (rev 87735)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl	2011-05-31 16:28:33 UTC (rev 87736)
@@ -140,13 +140,12 @@
                                                             in [Optional] float dx, in [Optional] float dy, in [Optional] float dw, in [Optional] float dh,
                                                             in [Optional] DOMString compositeOperation);
 
-#if defined(V8_BINDING) && V8_BINDING
-
         void setShadow(in float width, in float height, in float blur, in [Optional] DOMString color, in [Optional] float alpha);
         void setShadow(in float width, in float height, in float blur, in float grayLevel, in [Optional] float alpha);
         void setShadow(in float width, in float height, in float blur, in float r, in float g, in float b, in float a);
         void setShadow(in float width, in float height, in float blur, in float c, in float m, in float y, in float k, in float a);
 
+#if defined(V8_BINDING) && V8_BINDING
         CanvasPattern createPattern(in HTMLCanvasElement canvas, in [ConvertNullToNullString] DOMString repetitionType)
             raises (DOMException);
         CanvasPattern createPattern(in HTMLImageElement image, in [ConvertNullToNullString] DOMString repetitionType)
@@ -159,7 +158,6 @@
             raises (DOMException);
 #else
         // FIXME: Remove 'else' once JSC supports overloads too.
-        [Custom] void setShadow(/* 3 */);
         [Custom] void createPattern(/* 2 */);
         [Custom] void putImageData(/* in ImageData imagedata, in float dx, in float dy [, in float dirtyX, in float dirtyY, in float dirtyWidth, in float dirtyHeight] */);
         [Custom] ImageData createImageData(/* 3 */);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to