From 72f9333ec4db1920895ab8639aa39ed289c5edb3 Mon Sep 17 00:00:00 2001 From: "oliver@apple.com" Date: Wed, 19 Mar 2008 22:28:07 +0000 Subject: [PATCH] Bug 17954: Canvas arc() with radius of 0 throws exception http://bugs.webkit.org/show_bug.cgi?id=17954 Reviewed by Antti Simple fix -- use >= instead of > when validating the radius. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@31162 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 10 ++++++++++ .../canvas/canvas-with-incorrect-args-expected.txt | 2 +- .../fast/canvas/canvas-with-incorrect-args.html | 4 ++-- WebCore/ChangeLog | 12 ++++++++++++ WebCore/html/CanvasRenderingContext2D.cpp | 2 +- 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index d6399b62d26..5f05b42a463 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,13 @@ +2008-03-19 Oliver Hunt + + Reviewed by Antti. + + Test case for Canvas.arc with zero-length radius needed to + be updated for current html5 spec. + + * fast/canvas/canvas-with-incorrect-args-expected.txt: + * fast/canvas/canvas-with-incorrect-args.html: + 2008-03-19 Justin Garcia Reviewed by Oliver. diff --git a/LayoutTests/fast/canvas/canvas-with-incorrect-args-expected.txt b/LayoutTests/fast/canvas/canvas-with-incorrect-args-expected.txt index 3f69f8de9c2..cafb28c2a20 100644 --- a/LayoutTests/fast/canvas/canvas-with-incorrect-args-expected.txt +++ b/LayoutTests/fast/canvas/canvas-with-incorrect-args-expected.txt @@ -14,7 +14,7 @@ PASS called rect 0*0 rect without throwing an exception. UNDEFINED called rect with inf*inf rect without throwing an exception. UNDEFINED threw exception code 1 on nan*nan rect. PASS called fill with an empty path without throwing an exception. -PASS threw exception code 1 on arc with zero-length radius +PASS did not throw exception on arc with zero-length radius PASS threw exception code 1 on arc with negative-length radius UNDEFINED did not throw exception on arc with infinite radius UNDEFINED threw exception code 1 on arc with nan-length radius diff --git a/LayoutTests/fast/canvas/canvas-with-incorrect-args.html b/LayoutTests/fast/canvas/canvas-with-incorrect-args.html index 3bc1a9c90e2..1edf49a65b2 100644 --- a/LayoutTests/fast/canvas/canvas-with-incorrect-args.html +++ b/LayoutTests/fast/canvas/canvas-with-incorrect-args.html @@ -94,9 +94,9 @@ function runTest() { } try { context.arc(2, 2, 0, 0, 90, true); - fail("did not throw exception on arc with zero-length radius"); + pass("did not throw exception on arc with zero-length radius"); } catch (e) { - pass("threw exception code " + e.code + " on arc with zero-length radius"); + fail("threw exception code " + e.code + " on arc with zero-length radius"); } try { context.arc(2, 2, -10, 0, 90, true); diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index bcab8aa6f52..0bcfa977c92 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,15 @@ +2008-03-19 Oliver Hunt + + Reviewed by Antti. + + Bug 17954: Canvas arc() with radius of 0 throws exception + http://bugs.webkit.org/show_bug.cgi?id=17954 + + Simple fix -- use >= instead of > when validating the radius. + + * html/CanvasRenderingContext2D.cpp: + (WebCore::CanvasRenderingContext2D::arc): + 2008-03-19 Justin Garcia Reviewed by Oliver. diff --git a/WebCore/html/CanvasRenderingContext2D.cpp b/WebCore/html/CanvasRenderingContext2D.cpp index a5a9f2b677d..1c8ccbc2d74 100644 --- a/WebCore/html/CanvasRenderingContext2D.cpp +++ b/WebCore/html/CanvasRenderingContext2D.cpp @@ -468,7 +468,7 @@ void CanvasRenderingContext2D::arcTo(float x0, float y0, float x1, float y1, flo void CanvasRenderingContext2D::arc(float x, float y, float r, float sa, float ea, bool anticlockwise, ExceptionCode& ec) { ec = 0; - if (!(r > 0)) { + if (!(r >= 0)) { ec = INDEX_SIZE_ERR; return; } -- GitLab