Title: [87731] trunk
Revision
87731
Author
[email protected]
Date
2011-05-31 09:12:35 -0700 (Tue, 31 May 2011)

Log Message

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

        Reviewed by Antti Koivisto.

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

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

        * fast/canvas/canvas-overloads-setStrokeColor-expected.txt: Added.
        * fast/canvas/canvas-overloads-setStrokeColor.html: Added.
        * fast/canvas/script-tests/canvas-overloads-setStrokeColor.js: Added.
2011-05-31  Andreas Kling  <[email protected]>

        Reviewed by Antti Koivisto.

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

        Move CanvasRenderingContext2D.setStrokeColor() 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, but doesn't matter much anyway since this method is WebKit-only.

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

        * bindings/js/JSCanvasRenderingContext2DCustom.cpp:
        * html/canvas/CanvasRenderingContext2D.idl:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (87730 => 87731)


--- trunk/LayoutTests/ChangeLog	2011-05-31 16:10:39 UTC (rev 87730)
+++ trunk/LayoutTests/ChangeLog	2011-05-31 16:12:35 UTC (rev 87731)
@@ -2,6 +2,20 @@
 
         Reviewed by Antti Koivisto.
 
+        Canvas/JSC: Auto-generate overloads for setStrokeColor()
+        https://bugs.webkit.org/show_bug.cgi?id=61629
+
+        Add a test to verify the behavior of setStrokeColor() when called with
+        different numbers of arguments.
+
+        * fast/canvas/canvas-overloads-setStrokeColor-expected.txt: Added.
+        * fast/canvas/canvas-overloads-setStrokeColor.html: Added.
+        * fast/canvas/script-tests/canvas-overloads-setStrokeColor.js: Added.
+
+2011-05-31  Andreas Kling  <[email protected]>
+
+        Reviewed by Antti Koivisto.
+
         Canvas/JSC: Auto-generate overloads for strokeText()
         https://bugs.webkit.org/show_bug.cgi?id=61626
 

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


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

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


--- trunk/LayoutTests/fast/canvas/canvas-overloads-setStrokeColor.html	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-overloads-setStrokeColor.html	2011-05-31 16:12:35 UTC (rev 87731)
@@ -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-setStrokeColor.js (0 => 87731)


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

Modified: trunk/Source/WebCore/ChangeLog (87730 => 87731)


--- trunk/Source/WebCore/ChangeLog	2011-05-31 16:10:39 UTC (rev 87730)
+++ trunk/Source/WebCore/ChangeLog	2011-05-31 16:12:35 UTC (rev 87731)
@@ -2,6 +2,24 @@
 
         Reviewed by Antti Koivisto.
 
+        Canvas/JSC: Auto-generate overloads for setStrokeColor()
+        https://bugs.webkit.org/show_bug.cgi?id=61629
+
+        Move CanvasRenderingContext2D.setStrokeColor() 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, but doesn't matter much anyway since this method is WebKit-only.
+
+        Test: fast/canvas/canvas-overloads-setStrokeColor.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 strokeText()
         https://bugs.webkit.org/show_bug.cgi?id=61626
 

Modified: trunk/Source/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp (87730 => 87731)


--- trunk/Source/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp	2011-05-31 16:10:39 UTC (rev 87730)
+++ trunk/Source/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp	2011-05-31 16:12:35 UTC (rev 87731)
@@ -132,44 +132,6 @@
     return jsUndefined();
 }    
 
-JSValue JSCanvasRenderingContext2D::setStrokeColor(ExecState* exec)
-{ 
-    CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());
-
-    // string arg = named color
-    // number arg = gray color
-    // string arg, number arg = named color, alpha
-    // number arg, number arg = gray color, alpha
-    // 4 args = r, g, b, a
-    // 5 args = c, m, y, k, a
-    switch (exec->argumentCount()) {
-        case 1:
-            if (exec->argument(0).isString())
-                context->setStrokeColor(ustringToString(asString(exec->argument(0))->value(exec)));
-            else
-                context->setStrokeColor(exec->argument(0).toFloat(exec));
-            break;
-        case 2:
-            if (exec->argument(0).isString())
-                context->setStrokeColor(ustringToString(asString(exec->argument(0))->value(exec)), exec->argument(1).toFloat(exec));
-            else
-                context->setStrokeColor(exec->argument(0).toFloat(exec), exec->argument(1).toFloat(exec));
-            break;
-        case 4:
-            context->setStrokeColor(exec->argument(0).toFloat(exec), exec->argument(1).toFloat(exec),
-                                    exec->argument(2).toFloat(exec), exec->argument(3).toFloat(exec));
-            break;
-        case 5:
-            context->setStrokeColor(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;
-        default:
-            return throwSyntaxError(exec);
-    }
-    
-    return jsUndefined();
-}
-
 JSValue JSCanvasRenderingContext2D::strokeRect(ExecState* exec)
 { 
     CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl (87730 => 87731)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl	2011-05-31 16:10:39 UTC (rev 87730)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl	2011-05-31 16:12:35 UTC (rev 87731)
@@ -102,12 +102,12 @@
         [RequiresAllArguments=Raise] void fillText(in DOMString text, in float x, in float y, in [Optional] float maxWidth);
         [RequiresAllArguments=Raise] void strokeText(in DOMString text, in float x, in float y, in [Optional] float maxWidth);
 
-#if defined(V8_BINDING) && V8_BINDING
         void setStrokeColor(in DOMString color, in [Optional] float alpha);
         void setStrokeColor(in float grayLevel, in [Optional] float alpha);
         void setStrokeColor(in float r, in float g, in float b, in float a);
         void setStrokeColor(in float c, in float m, in float y, in float k, in float a);
 
+#if defined(V8_BINDING) && V8_BINDING
         void setFillColor(in DOMString color, in [Optional] float alpha);
         void setFillColor(in float grayLevel, in [Optional] float alpha);
         void setFillColor(in float r, in float g, in float b, in float a);
@@ -156,7 +156,6 @@
             raises (DOMException);
 #else
         // FIXME: Remove 'else' once JSC supports overloads too.
-        [Custom] void setStrokeColor(/* 1  */);
         [Custom] void setFillColor(/* 1 */);
         [Custom] void strokeRect(/* 4 */);
         [Custom] void drawImage(/* 3 */);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to