Reviewed by Adam.
Fix for http://bugs.webkit.org/show_bug.cgi?id=11251
Corrects canvas tag to not throw JS exception when drawing
zero sized rects, arcs, etc
* html/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::arcTo):
(WebCore::CanvasRenderingContext2D::arc):
(WebCore::CanvasRenderingContext2D::rect):
(WebCore::CanvasRenderingContext2D::clearRect):
(WebCore::CanvasRenderingContext2D::fillRect):
(WebCore::CanvasRenderingContext2D::strokeRect):
Reviewed by Geoff.
Test case for http://bugs.webkit.org/show_bug.cgi?id=11251
* fast/canvas/zero-size-fill-rect-expected.checksum: Added.
* fast/canvas/zero-size-fill-rect-expected.png: Added.
* fast/canvas/zero-size-fill-rect-expected.txt: Added.
* fast/canvas/zero-size-fill-rect.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16993
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-10-11 Oliver Hunt <oliver@apple.com>
+
+ Reviewed by Geoff.
+
+ Test case for http://bugs.webkit.org/show_bug.cgi?id=11251
+
+ * fast/canvas/zero-size-fill-rect-expected.checksum: Added.
+ * fast/canvas/zero-size-fill-rect-expected.png: Added.
+ * fast/canvas/zero-size-fill-rect-expected.txt: Added.
+ * fast/canvas/zero-size-fill-rect.html: Added.
+
2006-10-11 Rob Buis <buis@kde.org>
Reviewed by Mitz.
--- /dev/null
+62de2d21445b7cd4f98238302b39899a
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderHTMLCanvas {CANVAS} at (0,0) size 100x100
+ RenderText {#text} at (100,86) size 4x18
+ text run at (100,86) width 4: " "
+ RenderBR {BR} at (104,100) size 0x0
+ RenderText {#text} at (0,104) size 311x18
+ text run at (0,104) width 311: "PASS -- 0 sized rects did not trigger an exception"
--- /dev/null
+<!--
+ Creates a canvas which is filled red, then attempts to
+ fill a number of 0 size rects, finally fills with green.
+
+ Fill of a 0-sized rect should not throw an exception, so
+ we expected the output to be a green rect.
+-->
+<html>
+<head>
+<script type="text/javascript">
+window.onload = function() {
+ var canvas = document.getElementById("test");
+ var context = canvas.getContext("2d");
+ context.fillStyle = '#f00';
+ context.fillRect(0, 0, canvas.width, canvas.height);
+ try {
+ context.fillRect(0, 0, 0, 0);
+ context.fillRect(0, 0, canvas.width, 0);
+ context.fillRect(0, 0, 0, canvas.height);
+ } catch (e) {
+ var node = document.createTextNode("FAIL -- an exception was thrown when drawing a 0 sized rect");
+ document.getElementById("body").appendChild(node);
+ return;
+ }
+ context.fillStyle = '#0f0';
+ context.fillRect(0, 0, canvas.width, canvas.height);
+ var node = document.createTextNode("PASS -- 0 sized rects did not trigger an exception");
+ document.getElementById("body").appendChild(node);
+}
+</script>
+<title>borkedness</title>
+</head>
+<body id="body">
+<canvas id="test" width="100" height="100"></canvas>
+<br>
+</body>
+</html>
+2006-10-11 Oliver Hunt <oliver@apple.com>
+
+ Reviewed by Adam.
+
+ Fix for http://bugs.webkit.org/show_bug.cgi?id=11251
+ Corrects canvas tag to not throw JS exception when drawing
+ zero sized rects, arcs, etc
+
+ * html/CanvasRenderingContext2D.cpp:
+ (WebCore::CanvasRenderingContext2D::arcTo):
+ (WebCore::CanvasRenderingContext2D::arc):
+ (WebCore::CanvasRenderingContext2D::rect):
+ (WebCore::CanvasRenderingContext2D::clearRect):
+ (WebCore::CanvasRenderingContext2D::fillRect):
+ (WebCore::CanvasRenderingContext2D::strokeRect):
+
2006-10-11 Rob Buis <buis@kde.org>
Reviewed by Mitz.
void CanvasRenderingContext2D::arcTo(float x0, float y0, float x1, float y1, float r, ExceptionCode& ec)
{
ec = 0;
- if (!(r > 0)) {
+ if (r < 0) {
ec = INDEX_SIZE_ERR;
return;
}
void CanvasRenderingContext2D::arc(float x, float y, float r, float sa, float ea, bool clockwise, ExceptionCode& ec)
{
ec = 0;
- if (!(r > 0)) {
+ if (r < 0) {
ec = INDEX_SIZE_ERR;
return;
}
void CanvasRenderingContext2D::rect(float x, float y, float width, float height, ExceptionCode& ec)
{
ec = 0;
- if (!(width > 0 && height > 0)) {
+ if (width < 0 || height < 0) {
ec = INDEX_SIZE_ERR;
return;
}
void CanvasRenderingContext2D::clearRect(float x, float y, float width, float height, ExceptionCode& ec)
{
ec = 0;
- if (!(width > 0 && height > 0)) {
+ if (width < 0 || height < 0) {
ec = INDEX_SIZE_ERR;
return;
}
{
ec = 0;
- if (!(width > 0 && height > 0)) {
+ if (width < 0 || height < 0) {
ec = INDEX_SIZE_ERR;
return;
}
{
ec = 0;
- if (!(width > 0 && height > 0 && lineWidth > 0)) {
+ if (width < 0 || height < 0 || lineWidth < 0) {
ec = INDEX_SIZE_ERR;
return;
}