Remove an overloaded strokeRect in <canvas>
https://bugs.webkit.org/show_bug.cgi?id=116017

Patch by Dongseong Hwang <dongseong.hwang@intel.com> on 2013-05-15
Reviewed by Benjamin Poulain.

Source/WebCore:

The canvas spec [1] does not define strokeRect with 5 arguments, so this issue
remains only strokeRect with 4 arguments.

[1] http://www.w3.org/TR/2dcontext2/

Covered by existing tests: canvas/philip/tests/2d.missingargs.html

* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::strokeRect):
* html/canvas/CanvasRenderingContext2D.h:
(CanvasRenderingContext2D):
* html/canvas/CanvasRenderingContext2D.idl:

LayoutTests:

canvas/philip/tests/2d.missingargs.html can cover
fast/canvas/canvas-overloads-strokeRect.html, so this patch removed it.

* fast/canvas/canvas-overloads-strokeRect-expected.txt: Removed.
* fast/canvas/canvas-overloads-strokeRect.html: Removed.
* fast/canvas/script-tests/canvas-overloads-strokeRect.js: Removed.
* fast/canvas/script-tests/canvas-strokeRect.js:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150137 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 675f919..4e2c16f 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,18 @@
+2013-05-15  Dongseong Hwang  <dongseong.hwang@intel.com>
+
+        Remove an overloaded strokeRect in <canvas>
+        https://bugs.webkit.org/show_bug.cgi?id=116017
+
+        Reviewed by Benjamin Poulain.
+
+        canvas/philip/tests/2d.missingargs.html can cover
+        fast/canvas/canvas-overloads-strokeRect.html, so this patch removed it.
+
+        * fast/canvas/canvas-overloads-strokeRect-expected.txt: Removed.
+        * fast/canvas/canvas-overloads-strokeRect.html: Removed.
+        * fast/canvas/script-tests/canvas-overloads-strokeRect.js: Removed.
+        * fast/canvas/script-tests/canvas-strokeRect.js:
+
 2013-05-15  Bruno de Oliveira Abinader  <bruno.abinader@basyskom.com>
 
         [css3-text] text-decoration-line now accepts "blink" as valid value
diff --git a/LayoutTests/fast/canvas/canvas-overloads-strokeRect-expected.txt b/LayoutTests/fast/canvas/canvas-overloads-strokeRect-expected.txt
deleted file mode 100644
index 8e80703..0000000
--- a/LayoutTests/fast/canvas/canvas-overloads-strokeRect-expected.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-Test the behavior of CanvasRenderingContext2D.strokeRect() when called with different numbers of arguments.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-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
-
-TEST COMPLETE
-
diff --git a/LayoutTests/fast/canvas/canvas-overloads-strokeRect.html b/LayoutTests/fast/canvas/canvas-overloads-strokeRect.html
deleted file mode 100644
index 6f2f1d6..0000000
--- a/LayoutTests/fast/canvas/canvas-overloads-strokeRect.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-<script src="../js/resources/js-test-pre.js"></script>
-</head>
-<body>
-<script src="script-tests/canvas-overloads-strokeRect.js"></script>
-<script src="../js/resources/js-test-post.js"></script>
-</body>
-</html>
diff --git a/LayoutTests/fast/canvas/script-tests/canvas-overloads-strokeRect.js b/LayoutTests/fast/canvas/script-tests/canvas-overloads-strokeRect.js
deleted file mode 100644
index d7bbd7c..0000000
--- a/LayoutTests/fast/canvas/script-tests/canvas-overloads-strokeRect.js
+++ /dev/null
@@ -1,12 +0,0 @@
-description("Test the behavior of CanvasRenderingContext2D.strokeRect() when called with different numbers of arguments.");
-
-var ctx = document.createElement('canvas').getContext('2d');
-
-var TypeErrorNotEnoughArguments = "TypeError: Not enough arguments";
-
-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");
diff --git a/LayoutTests/fast/canvas/script-tests/canvas-strokeRect.js b/LayoutTests/fast/canvas/script-tests/canvas-strokeRect.js
index a1eabcf..75a6f5d 100644
--- a/LayoutTests/fast/canvas/script-tests/canvas-strokeRect.js
+++ b/LayoutTests/fast/canvas/script-tests/canvas-strokeRect.js
@@ -5,7 +5,8 @@
 debug("Test canvas.strokeRect() with solid green.");
 ctx.beginPath();
 ctx.strokeStyle = 'green';
-ctx.strokeRect(50, 0, 100, 100, 100);
+ctx.lineWidth = 100;
+ctx.strokeRect(50, 0, 100, 100);
 
 var imageData = ctx.getImageData(1, 1, 98, 98);
 var imgdata = imageData.data;
@@ -25,7 +26,8 @@
 ctx2.fillRect(0, 0, 100, 100);
 var pattern = ctx.createPattern(canvas2, 'repeat');
 ctx.strokeStyle = 'pattern';
-ctx.strokeRect(50, 0, 100, 100, 100);
+ctx.lineWidth = 100;
+ctx.strokeRect(50, 0, 100, 100);
 
 imageData = ctx.getImageData(1, 1, 98, 98);
 imgdata = imageData.data;
@@ -41,7 +43,8 @@
 gradient.addColorStop(0, "green");
 gradient.addColorStop(1, "green");
 ctx.strokeStyle = 'gradient';
-ctx.strokeRect(50, 0, 100, 100, 100);
+ctx.lineWidth = 100;
+ctx.strokeRect(50, 0, 100, 100);
 
 imageData = ctx.getImageData(1, 1, 98, 98);
 imgdata = imageData.data;
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 5e7344a..87a603a 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,23 @@
+2013-05-15  Dongseong Hwang  <dongseong.hwang@intel.com>
+
+        Remove an overloaded strokeRect in <canvas>
+        https://bugs.webkit.org/show_bug.cgi?id=116017
+
+        Reviewed by Benjamin Poulain.
+
+        The canvas spec [1] does not define strokeRect with 5 arguments, so this issue
+        remains only strokeRect with 4 arguments.
+
+        [1] http://www.w3.org/TR/2dcontext2/
+
+        Covered by existing tests: canvas/philip/tests/2d.missingargs.html
+
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::strokeRect):
+        * html/canvas/CanvasRenderingContext2D.h:
+        (CanvasRenderingContext2D):
+        * html/canvas/CanvasRenderingContext2D.idl:
+
 2013-05-15  Bruno de Oliveira Abinader  <bruno.abinader@basyskom.com>
 
         [css3-text] text-decoration-line now accepts "blink" as valid value
diff --git a/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp b/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
index 37afde6..1a97473 100644
--- a/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
+++ b/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
@@ -1112,22 +1112,14 @@
 {
     if (!validateRectForCanvas(x, y, width, height))
         return;
-    strokeRect(x, y, width, height, state().m_lineWidth);
-}
-
-void CanvasRenderingContext2D::strokeRect(float x, float y, float width, float height, float lineWidth)
-{
-    if (!validateRectForCanvas(x, y, width, height))
-        return;
-
-    if (!(lineWidth >= 0))
-        return;
 
     GraphicsContext* c = drawingContext();
     if (!c)
         return;
     if (!state().m_invertibleCTM)
         return;
+    if (!(state().m_lineWidth >= 0))
+        return;
 
     // If gradient size is zero, then paint nothing.
     Gradient* gradient = c->strokeGradient();
@@ -1137,9 +1129,9 @@
     FloatRect rect(x, y, width, height);
 
     FloatRect boundingRect = rect;
-    boundingRect.inflate(lineWidth / 2);
+    boundingRect.inflate(state().m_lineWidth / 2);
 
-    c->strokeRect(rect, lineWidth);
+    c->strokeRect(rect, state().m_lineWidth);
     didDraw(boundingRect);
 }
 
diff --git a/Source/WebCore/html/canvas/CanvasRenderingContext2D.h b/Source/WebCore/html/canvas/CanvasRenderingContext2D.h
index 28bafbd..b2c6073 100644
--- a/Source/WebCore/html/canvas/CanvasRenderingContext2D.h
+++ b/Source/WebCore/html/canvas/CanvasRenderingContext2D.h
@@ -154,7 +154,6 @@
     void clearRect(float x, float y, float width, float height);
     void fillRect(float x, float y, float width, float height);
     void strokeRect(float x, float y, float width, float height);
-    void strokeRect(float x, float y, float width, float height, float lineWidth);
 
     void setShadow(float width, float height, float blur);
     void setShadow(float width, float height, float blur, const String& color);
diff --git a/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl b/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl
index 99f1a31..1909d4d 100644
--- a/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl
+++ b/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl
@@ -122,7 +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(float x, float y, float width, float height, optional float lineWidth);
+    void strokeRect(float x, float y, float width, float height);
 
     void drawImage(HTMLImageElement? image, float x, float y)
         raises (DOMException);