Diff
Modified: trunk/LayoutTests/ChangeLog (87729 => 87730)
--- trunk/LayoutTests/ChangeLog 2011-05-31 16:08:49 UTC (rev 87729)
+++ trunk/LayoutTests/ChangeLog 2011-05-31 16:10:39 UTC (rev 87730)
@@ -2,6 +2,24 @@
Reviewed by Antti Koivisto.
+ Canvas/JSC: Auto-generate overloads for strokeText()
+ https://bugs.webkit.org/show_bug.cgi?id=61626
+
+ Add a test to verify the behavior of strokeText() when called with different
+ numbers of arguments. There are two differences to the previous behavior:
+
+ - SyntaxError exceptions are now raised with the message "Not enough arguments."
+ - Calling strokeText() with superfluous arguments now lets the call through
+ instead of raising a SyntaxError. This matches both Gecko and Presto.
+
+ * fast/canvas/canvas-overloads-strokeText-expected.txt: Added.
+ * fast/canvas/canvas-overloads-strokeText.html: Added.
+ * fast/canvas/script-tests/canvas-overloads-strokeText.js: Added.
+
+2011-05-31 Andreas Kling <[email protected]>
+
+ Reviewed by Antti Koivisto.
+
Canvas/JSC: Auto-generate overloads for fillText()
https://bugs.webkit.org/show_bug.cgi?id=61623
Added: trunk/LayoutTests/fast/canvas/canvas-overloads-strokeText-expected.txt (0 => 87730)
--- trunk/LayoutTests/fast/canvas/canvas-overloads-strokeText-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-overloads-strokeText-expected.txt 2011-05-31 16:10:39 UTC (rev 87730)
@@ -0,0 +1,15 @@
+Test the behavior of CanvasRenderingContext2D.strokeText() when called with different numbers of arguments.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS ctx.strokeText() threw exception SyntaxError: Not enough arguments.
+PASS ctx.strokeText('moo') threw exception SyntaxError: Not enough arguments.
+PASS ctx.strokeText('moo',0) threw exception SyntaxError: Not enough arguments.
+PASS ctx.strokeText('moo',0,0) is undefined
+PASS ctx.strokeText('moo',0,0,0) is undefined
+PASS ctx.strokeText('moo',0,0,0,0) is undefined
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/canvas/canvas-overloads-strokeText.html (0 => 87730)
--- trunk/LayoutTests/fast/canvas/canvas-overloads-strokeText.html (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-overloads-strokeText.html 2011-05-31 16:10:39 UTC (rev 87730)
@@ -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-strokeText.js (0 => 87730)
--- trunk/LayoutTests/fast/canvas/script-tests/canvas-overloads-strokeText.js (rev 0)
+++ trunk/LayoutTests/fast/canvas/script-tests/canvas-overloads-strokeText.js 2011-05-31 16:10:39 UTC (rev 87730)
@@ -0,0 +1,14 @@
+description("Test the behavior of CanvasRenderingContext2D.strokeText() when called with different numbers of arguments.");
+
+var ctx = document.createElement('canvas').getContext('2d');
+
+var SyntaxError = "SyntaxError: Not enough arguments";
+
+shouldThrow("ctx.strokeText()", "SyntaxError");
+shouldThrow("ctx.strokeText('moo')", "SyntaxError");
+shouldThrow("ctx.strokeText('moo',0)", "SyntaxError");
+shouldBe("ctx.strokeText('moo',0,0)", "undefined");
+shouldBe("ctx.strokeText('moo',0,0,0)", "undefined");
+shouldBe("ctx.strokeText('moo',0,0,0,0)", "undefined");
+
+var successfullyParsed = true;
Modified: trunk/Source/WebCore/ChangeLog (87729 => 87730)
--- trunk/Source/WebCore/ChangeLog 2011-05-31 16:08:49 UTC (rev 87729)
+++ trunk/Source/WebCore/ChangeLog 2011-05-31 16:10:39 UTC (rev 87730)
@@ -2,6 +2,22 @@
Reviewed by Antti Koivisto.
+ Canvas/JSC: Auto-generate overloads for strokeText()
+ https://bugs.webkit.org/show_bug.cgi?id=61626
+
+ Move CanvasRenderingContext2D.strokeText() to auto-generated JSC bindings.
+ Make it [RequiresAllArguments=Raise] to match the old behavior.
+ This has the side-effect of aligning the behaviors of JSC and V8.
+
+ Test: fast/canvas/canvas-overloads-strokeText.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 fillText()
https://bugs.webkit.org/show_bug.cgi?id=61623
Modified: trunk/Source/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp (87729 => 87730)
--- trunk/Source/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp 2011-05-31 16:08:49 UTC (rev 87729)
+++ trunk/Source/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp 2011-05-31 16:10:39 UTC (rev 87730)
@@ -409,22 +409,4 @@
return jsUndefined();
}
-JSValue JSCanvasRenderingContext2D::strokeText(ExecState* exec)
-{
- CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());
-
- // string arg = text to draw
- // number arg = x
- // number arg = y
- // optional number arg = maxWidth
- if (exec->argumentCount() < 3 || exec->argumentCount() > 4)
- return throwSyntaxError(exec);
-
- if (exec->argumentCount() == 4)
- context->strokeText(ustringToString(exec->argument(0).toString(exec)), exec->argument(1).toFloat(exec), exec->argument(2).toFloat(exec), exec->argument(3).toFloat(exec));
- else
- context->strokeText(ustringToString(exec->argument(0).toString(exec)), exec->argument(1).toFloat(exec), exec->argument(2).toFloat(exec));
- return jsUndefined();
-}
-
} // namespace WebCore
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl (87729 => 87730)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl 2011-05-31 16:08:49 UTC (rev 87729)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl 2011-05-31 16:10:39 UTC (rev 87730)
@@ -100,10 +100,9 @@
void clearShadow();
[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 strokeText(in DOMString text, in float x, in float y, in [Optional] float maxWidth);
-
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);
@@ -157,7 +156,6 @@
raises (DOMException);
#else
// FIXME: Remove 'else' once JSC supports overloads too.
- [Custom] void strokeText(/* 4 */);
[Custom] void setStrokeColor(/* 1 */);
[Custom] void setFillColor(/* 1 */);
[Custom] void strokeRect(/* 4 */);