Title: [149723] trunk
Revision
149723
Author
[email protected]
Date
2013-05-08 01:55:25 -0700 (Wed, 08 May 2013)

Log Message

Make optional arguments in CanvasRenderingContext2D match the spec.
https://bugs.webkit.org/show_bug.cgi?id=115723

Patch by Dongseong Hwang <[email protected]> on 2013-05-08
Reviewed by Dean Jackson.

Source/WebCore:

WebKit r98985 set many arguments optional although the canvas spec[1] does not
indicate. So this patch corrects CanvasRenderingContext2D.idl to match the spec.

[1] http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas/

Covered by existing tests:
  canvas/philip/tests/2d.missingargs.html
  fast/canvas/canvas-overloads-strokeRect.html
  inspector/profiler/canvas2d/canvas2d-profiler-capturing-basics.html

* html/canvas/CanvasRenderingContext2D.idl:

LayoutTests:

When tests use <canvas> API with not enough arguments, TypeError
exception is fired now. So three tests are changed to match the canvas
spec.

* fast/canvas/canvas-overloads-strokeRect-expected.txt:
* fast/canvas/script-tests/canvas-overloads-strokeRect.js:
* platform/mac/canvas/philip/tests/2d.missingargs-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (149722 => 149723)


--- trunk/LayoutTests/ChangeLog	2013-05-08 08:28:12 UTC (rev 149722)
+++ trunk/LayoutTests/ChangeLog	2013-05-08 08:55:25 UTC (rev 149723)
@@ -1,3 +1,18 @@
+2013-05-08  Dongseong Hwang  <[email protected]>
+
+        Make optional arguments in CanvasRenderingContext2D match the spec.
+        https://bugs.webkit.org/show_bug.cgi?id=115723
+
+        Reviewed by Dean Jackson.
+
+        When tests use <canvas> API with not enough arguments, TypeError
+        exception is fired now. So three tests are changed to match the canvas
+        spec.
+
+        * fast/canvas/canvas-overloads-strokeRect-expected.txt:
+        * fast/canvas/script-tests/canvas-overloads-strokeRect.js:
+        * platform/mac/canvas/philip/tests/2d.missingargs-expected.txt:
+
 2013-05-08  Ryosuke Niwa  <[email protected]>
 
         Add an image only failure expectation to fast/css-generated-content/close-quote-negative-depth.html per

Modified: trunk/LayoutTests/fast/canvas/canvas-overloads-strokeRect-expected.txt (149722 => 149723)


--- trunk/LayoutTests/fast/canvas/canvas-overloads-strokeRect-expected.txt	2013-05-08 08:28:12 UTC (rev 149722)
+++ trunk/LayoutTests/fast/canvas/canvas-overloads-strokeRect-expected.txt	2013-05-08 08:55:25 UTC (rev 149723)
@@ -3,10 +3,10 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS ctx.strokeRect() is undefined
-PASS ctx.strokeRect(0) is undefined
-PASS ctx.strokeRect(0, 0) is undefined
-PASS ctx.strokeRect(0, 0, 0) is undefined
+PASS ctx.strokeRect() threw exception TypeError: Not enough arguments.
+PASS ctx.strokeRect(0) threw exception TypeError: Not enough arguments.
+PASS ctx.strokeRect(0, 0) threw exception TypeError: Not enough arguments.
+PASS ctx.strokeRect(0, 0, 0) threw exception TypeError: Not enough arguments.
 PASS ctx.strokeRect(0, 0, 0, 0) is undefined
 PASS ctx.strokeRect(0, 0, 0, 0, 0) is undefined
 PASS successfullyParsed is true

Modified: trunk/LayoutTests/fast/canvas/script-tests/canvas-overloads-strokeRect.js (149722 => 149723)


--- trunk/LayoutTests/fast/canvas/script-tests/canvas-overloads-strokeRect.js	2013-05-08 08:28:12 UTC (rev 149722)
+++ trunk/LayoutTests/fast/canvas/script-tests/canvas-overloads-strokeRect.js	2013-05-08 08:55:25 UTC (rev 149723)
@@ -2,12 +2,11 @@
 
 var ctx = document.createElement('canvas').getContext('2d');
 
-var SyntaxError = "SyntaxError: Syntax error";
-var TypeError = "TypeError: Type error";
+var TypeErrorNotEnoughArguments = "TypeError: Not enough arguments";
 
-shouldBe("ctx.strokeRect()", "undefined");
-shouldBe("ctx.strokeRect(0)", "undefined");
-shouldBe("ctx.strokeRect(0, 0)", "undefined");
-shouldBe("ctx.strokeRect(0, 0, 0)", "undefined");
+shouldThrow("ctx.strokeRect()", "TypeErrorNotEnoughArguments");
+shouldThrow("ctx.strokeRect(0)", "TypeErrorNotEnoughArguments");
+shouldThrow("ctx.strokeRect(0, 0)", "TypeErrorNotEnoughArguments");
+shouldThrow("ctx.strokeRect(0, 0, 0)", "TypeErrorNotEnoughArguments");
 shouldBe("ctx.strokeRect(0, 0, 0, 0)", "undefined");
 shouldBe("ctx.strokeRect(0, 0, 0, 0, 0)", "undefined");

Modified: trunk/LayoutTests/inspector/profiler/canvas2d/canvas2d-profiler-capturing-basics.html (149722 => 149723)


--- trunk/LayoutTests/inspector/profiler/canvas2d/canvas2d-profiler-capturing-basics.html	2013-05-08 08:28:12 UTC (rev 149722)
+++ trunk/LayoutTests/inspector/profiler/canvas2d/canvas2d-profiler-capturing-basics.html	2013-05-08 08:55:25 UTC (rev 149723)
@@ -230,9 +230,9 @@
     assertNumberOfCallsInLog(23);
     for (var i = 0; i < 10; ++i) {
         ctx.rotate(1);
-        ctx.scale(2);
+        ctx.scale(2, 2);
         ctx.clip();
-        ctx.transform(3);
+        ctx.transform(3, 3, 3, 3, 3, 3);
         ctx.restore();
         assertNumberOfCallsInLog(24 + i);
     }

Modified: trunk/LayoutTests/platform/mac/canvas/philip/tests/2d.missingargs-expected.txt (149722 => 149723)


--- trunk/LayoutTests/platform/mac/canvas/philip/tests/2d.missingargs-expected.txt	2013-05-08 08:28:12 UTC (rev 149722)
+++ trunk/LayoutTests/platform/mac/canvas/philip/tests/2d.missingargs-expected.txt	2013-05-08 08:55:25 UTC (rev 149723)
@@ -1,76 +1,2 @@
-Failed assertion: should throw exception of type TypeError: ctx.scale()
-Failed assertion: should throw exception of type TypeError: ctx.scale(1)
-Failed assertion: should throw exception of type TypeError: ctx.rotate()
-Failed assertion: should throw exception of type TypeError: ctx.translate()
-Failed assertion: should throw exception of type TypeError: ctx.translate(0)
-Failed assertion: should throw exception of type TypeError: ctx.transform()
-Failed assertion: should throw exception of type TypeError: ctx.transform(1)
-Failed assertion: should throw exception of type TypeError: ctx.transform(1, 0)
-Failed assertion: should throw exception of type TypeError: ctx.transform(1, 0, 0)
-Failed assertion: should throw exception of type TypeError: ctx.transform(1, 0, 0, 1)
-Failed assertion: should throw exception of type TypeError: ctx.transform(1, 0, 0, 1, 0)
-Failed assertion: should throw exception of type TypeError: ctx.setTransform()
-Failed assertion: should throw exception of type TypeError: ctx.setTransform(1)
-Failed assertion: should throw exception of type TypeError: ctx.setTransform(1, 0)
-Failed assertion: should throw exception of type TypeError: ctx.setTransform(1, 0, 0)
-Failed assertion: should throw exception of type TypeError: ctx.setTransform(1, 0, 0, 1)
-Failed assertion: should throw exception of type TypeError: ctx.setTransform(1, 0, 0, 1, 0)
-Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
-Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
-Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
-Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
-Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
-Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
-Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
-Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
-Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
-Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
-Failed assertion: should throw exception of type TypeError: ctx.clearRect()
-Failed assertion: should throw exception of type TypeError: ctx.clearRect(0)
-Failed assertion: should throw exception of type TypeError: ctx.clearRect(0, 0)
-Failed assertion: should throw exception of type TypeError: ctx.clearRect(0, 0, 0)
-Failed assertion: should throw exception of type TypeError: ctx.fillRect()
-Failed assertion: should throw exception of type TypeError: ctx.fillRect(0)
-Failed assertion: should throw exception of type TypeError: ctx.fillRect(0, 0)
-Failed assertion: should throw exception of type TypeError: ctx.fillRect(0, 0, 0)
-Failed assertion: should throw exception of type TypeError: ctx.strokeRect()
-Failed assertion: should throw exception of type TypeError: ctx.strokeRect(0)
-Failed assertion: should throw exception of type TypeError: ctx.strokeRect(0, 0)
-Failed assertion: should throw exception of type TypeError: ctx.strokeRect(0, 0, 0)
-Failed assertion: should throw exception of type TypeError: ctx.moveTo()
-Failed assertion: should throw exception of type TypeError: ctx.moveTo(0)
-Failed assertion: should throw exception of type TypeError: ctx.lineTo()
-Failed assertion: should throw exception of type TypeError: ctx.lineTo(0)
-Failed assertion: should throw exception of type TypeError: ctx.quadraticCurveTo()
-Failed assertion: should throw exception of type TypeError: ctx.quadraticCurveTo(0)
-Failed assertion: should throw exception of type TypeError: ctx.quadraticCurveTo(0, 0)
-Failed assertion: should throw exception of type TypeError: ctx.quadraticCurveTo(0, 0, 0)
-Failed assertion: should throw exception of type TypeError: ctx.bezierCurveTo()
-Failed assertion: should throw exception of type TypeError: ctx.bezierCurveTo(0)
-Failed assertion: should throw exception of type TypeError: ctx.bezierCurveTo(0, 0)
-Failed assertion: should throw exception of type TypeError: ctx.bezierCurveTo(0, 0, 0)
-Failed assertion: should throw exception of type TypeError: ctx.bezierCurveTo(0, 0, 0, 0)
-Failed assertion: should throw exception of type TypeError: ctx.bezierCurveTo(0, 0, 0, 0, 0)
-Failed assertion: should throw exception of type TypeError: ctx.arcTo()
-Failed assertion: should throw exception of type TypeError: ctx.arcTo(0)
-Failed assertion: should throw exception of type TypeError: ctx.arcTo(0, 0)
-Failed assertion: should throw exception of type TypeError: ctx.arcTo(0, 0, 0)
-Failed assertion: should throw exception of type TypeError: ctx.arcTo(0, 0, 0, 0)
-Failed assertion: should throw exception of type TypeError: ctx.rect()
-Failed assertion: should throw exception of type TypeError: ctx.rect(0)
-Failed assertion: should throw exception of type TypeError: ctx.rect(0, 0)
-Failed assertion: should throw exception of type TypeError: ctx.rect(0, 0, 0)
-Failed assertion: should throw exception of type TypeError: ctx.arc()
-Failed assertion: should throw exception of type TypeError: ctx.arc(0)
-Failed assertion: should throw exception of type TypeError: ctx.arc(0, 0)
-Failed assertion: should throw exception of type TypeError: ctx.arc(0, 0, 1)
-Failed assertion: should throw exception of type TypeError: ctx.arc(0, 0, 1, 0)
-Failed assertion: should throw exception of type TypeError: ctx.isPointInPath()
-Failed assertion: should throw exception of type TypeError: ctx.isPointInPath(0)
-Failed assertion: should throw exception of type TypeError: ctx.measureText()
-Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
-Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
-Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
-Failed assertion: expected exception of type TypeError, got: Error: NotSupportedError: DOM Exception 9
 Failed assertion: expected exception of type TypeError, got: Error: IndexSizeError: DOM Exception 1
 Failed assertion: expected exception of type TypeError, got: Error: SyntaxError: DOM Exception 12

Modified: trunk/Source/WebCore/ChangeLog (149722 => 149723)


--- trunk/Source/WebCore/ChangeLog	2013-05-08 08:28:12 UTC (rev 149722)
+++ trunk/Source/WebCore/ChangeLog	2013-05-08 08:55:25 UTC (rev 149723)
@@ -1,3 +1,22 @@
+2013-05-08  Dongseong Hwang  <[email protected]>
+
+        Make optional arguments in CanvasRenderingContext2D match the spec.
+        https://bugs.webkit.org/show_bug.cgi?id=115723
+
+        Reviewed by Dean Jackson.
+
+        WebKit r98985 set many arguments optional although the canvas spec[1] does not
+        indicate. So this patch corrects CanvasRenderingContext2D.idl to match the spec.
+
+        [1] http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas/
+
+        Covered by existing tests:
+          canvas/philip/tests/2d.missingargs.html
+          fast/canvas/canvas-overloads-strokeRect.html
+          inspector/profiler/canvas2d/canvas2d-profiler-capturing-basics.html
+
+        * html/canvas/CanvasRenderingContext2D.idl:
+
 2013-05-08  Ryosuke Niwa  <[email protected]>
 
         Remove unused method and de-virtualize others in Element.h

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl (149722 => 149723)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl	2013-05-08 08:28:12 UTC (rev 149722)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl	2013-05-08 08:55:25 UTC (rev 149723)
@@ -30,38 +30,18 @@
     void save();
     void restore();
 
-    void scale([Default=Undefined] optional float sx,
-               [Default=Undefined] optional float sy);
-    void rotate([Default=Undefined] optional float angle);
-    void translate([Default=Undefined] optional float tx,
-                   [Default=Undefined] optional float ty);
-    void transform([Default=Undefined] optional float m11,
-                   [Default=Undefined] optional float m12,
-                   [Default=Undefined] optional float m21,
-                   [Default=Undefined] optional float m22,
-                   [Default=Undefined] optional float dx,
-                   [Default=Undefined] optional float dy);
-    void setTransform([Default=Undefined] optional float m11,
-                      [Default=Undefined] optional float m12,
-                      [Default=Undefined] optional float m21,
-                      [Default=Undefined] optional float m22,
-                      [Default=Undefined] optional float dx,
-                      [Default=Undefined] optional float dy);
+    void scale(float sx, float sy);
+    void rotate(float angle);
+    void translate(float tx, float ty);
+    void transform(float m11, float m12, float m21, float m22, float dx, float dy);
+    void setTransform(float m11, float m12, float m21, float m22, float dx, float dy);
 
     attribute float globalAlpha;
     [TreatNullAs=NullString] attribute DOMString globalCompositeOperation;
 
-    CanvasGradient createLinearGradient([Default=Undefined] optional float x0,
-                                        [Default=Undefined] optional float y0,
-                                        [Default=Undefined] optional float x1,
-                                        [Default=Undefined] optional float y1)
+    CanvasGradient createLinearGradient(float x0, float y0, float x1, float y1)
         raises (DOMException);
-    CanvasGradient createRadialGradient([Default=Undefined] optional float x0,
-                                        [Default=Undefined] optional float y0,
-                                        [Default=Undefined] optional float r0,
-                                        [Default=Undefined] optional float x1,
-                                        [Default=Undefined] optional float y1,
-                                        [Default=Undefined] optional float r1)
+    CanvasGradient createRadialGradient(float x0, float y0, float r0, float x1, float y1, float r1)
         raises (DOMException);
 
     attribute float lineWidth;
@@ -81,14 +61,8 @@
     [Custom] attribute Array webkitLineDash;
     attribute float webkitLineDashOffset;
 
-    void clearRect([Default=Undefined] optional float x,
-                   [Default=Undefined] optional float y,
-                   [Default=Undefined] optional float width,
-                   [Default=Undefined] optional float height);
-    void fillRect([Default=Undefined] optional float x,
-                  [Default=Undefined] optional float y,
-                  [Default=Undefined] optional float width,
-                  [Default=Undefined] optional float height);
+    void clearRect(float x, float y, float width, float height);
+    void fillRect(float x, float y, float width, float height);
 
     void beginPath();
 
@@ -98,53 +72,28 @@
 
     // FIXME: These methods should be shared with CanvasRenderingContext2D in the CanvasPathMethods interface.
     void closePath();
-    void moveTo([Default=Undefined] optional float x,
-                [Default=Undefined] optional float y);
-    void lineTo([Default=Undefined] optional float x,
-                [Default=Undefined] optional float y);
-    void quadraticCurveTo([Default=Undefined] optional float cpx,
-                          [Default=Undefined] optional float cpy,
-                          [Default=Undefined] optional float x,
-                          [Default=Undefined] optional float y);
-    void bezierCurveTo([Default=Undefined] optional float cp1x,
-                       [Default=Undefined] optional float cp1y,
-                       [Default=Undefined] optional float cp2x,
-                       [Default=Undefined] optional float cp2y,
-                       [Default=Undefined] optional float x,
-                       [Default=Undefined] optional float y);
-    void arcTo([Default=Undefined] optional float x1,
-               [Default=Undefined] optional float y1,
-               [Default=Undefined] optional float x2,
-               [Default=Undefined] optional float y2,
-               [Default=Undefined] optional float radius)
+    void moveTo(float x, float y);
+    void lineTo(float x, float y);
+    void quadraticCurveTo(float cpx, float cpy, float x, float y);
+    void bezierCurveTo(float cp1x, float cp1y, float cp2x, float cp2y, float x, float y);
+    void arcTo(float x1, float y1, float x2, float y2, float radius)
         raises (DOMException);
-    void rect([Default=Undefined] optional float x,
-              [Default=Undefined] optional float y,
-              [Default=Undefined] optional float width,
-              [Default=Undefined] optional float height);
-    void arc([Default=Undefined] optional float x,
-             [Default=Undefined] optional float y,
-             [Default=Undefined] optional float radius,
-             [Default=Undefined] optional float startAngle,
-             [Default=Undefined] optional float endAngle,
-             [Default=Undefined] optional boolean anticlockwise)
+    void rect(float x, float y, float width, float height);
+    void arc(float x, float y, float radius, float startAngle, float endAngle, [Default=Undefined] optional boolean anticlockwise)
         raises (DOMException);
 
     void fill(optional CanvasWindingRule winding);
     void stroke();
     void clip(optional CanvasWindingRule winding);
-    boolean isPointInPath([Default=Undefined] optional float x,
-                          [Default=Undefined] optional float y,
-                          optional CanvasWindingRule winding);
-    boolean isPointInStroke([Default=Undefined] optional float x,
-                            [Default=Undefined] optional float y);
+    boolean isPointInPath(float x, float y, optional CanvasWindingRule winding);
+    boolean isPointInStroke(float x, float y);
 
     // text
     attribute DOMString font;
     attribute DOMString textAlign;
     attribute DOMString textBaseline;
 
-    TextMetrics measureText([Default=Undefined] optional DOMString text);
+    TextMetrics measureText(DOMString text);
 
     // other
 
@@ -173,11 +122,7 @@
     void setFillColor(float r, float g, float b, float a);
     void setFillColor(float c, float m, float y, float k, float a);
 
-    void strokeRect([Default=Undefined] optional float x,
-                    [Default=Undefined] optional float y,
-                    [Default=Undefined] optional float width,
-                    [Default=Undefined] optional float height,
-                    optional float lineWidth);
+    void strokeRect(float x, float y, float width, float height, optional float lineWidth);
 
     void drawImage(HTMLImageElement? image, float x, float y)
         raises (DOMException);
@@ -233,12 +178,10 @@
     [Custom] attribute custom fillStyle;
 
     // pixel manipulation
-    ImageData getImageData([Default=Undefined] optional float sx, [Default=Undefined] optional float sy,
-                           [Default=Undefined] optional float sw, [Default=Undefined] optional float sh)
+    ImageData getImageData(float sx, float sy, float sw, float sh)
         raises(DOMException);
 
-    ImageData webkitGetImageDataHD([Default=Undefined] optional float sx, [Default=Undefined] optional float sy,
-                                   [Default=Undefined] optional float sw, [Default=Undefined] optional float sh)
+    ImageData webkitGetImageDataHD(float sx, float sy, float sw, float sh)
         raises(DOMException);
 
     readonly attribute float webkitBackingStorePixelRatio;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to