@@ -145,6 +145,8 @@ public void fillArc(int centerX, int centerY, int width, int height, int startAn
145145 }
146146
147147 private void doCirc (int left , int top , int diameter , boolean fill ) {
148+ if (diameter <= 0 )
149+ return ;
148150 double r = diameter / 2f ;
149151 ctx .beginPath ();
150152 ctx .arc (left + r , top + r , r , 0 , 2 * Math .PI , false );
@@ -157,6 +159,8 @@ private void doCirc(int left, int top, int diameter, boolean fill) {
157159
158160 private void doArc (double x , double y , double width , double height , double startAngle ,
159161 double arcAngle , boolean fill ) {
162+ if (width <= 0 || height <= 0 )
163+ return ;
160164// boolean doClose = (arcAngle - startAngle == 360);
161165 ctx .save ();
162166 {
@@ -230,6 +234,8 @@ private void doPoly(int[] axPoints, int[] ayPoints, int nPoints,
230234
231235
232236 public void drawRect (int x , int y , int width , int height ) {
237+ if (width <= 0 || height <= 0 )
238+ return ;
233239 ctx .beginPath ();
234240 ctx .rect (x , y , width , height );
235241 ctx .stroke ();
@@ -245,11 +251,15 @@ public void fillPolygon(int[] axPoints, int[] ayPoints, int nPoints) {
245251
246252
247253 public void fillRect (int x , int y , int width , int height ) {
254+ if (width <= 0 || height <= 0 )
255+ return ;
248256 backgroundPainted = true ;
249257 ctx .fillRect (x , y , width , height );
250258 }
251259
252260 public void fill3DRect (int x , int y , int width , int height , boolean raised ) {
261+ if (width <= 0 || height <= 0 )
262+ return ;
253263 Paint p = getPaint ();
254264 Color c = getColor ();
255265 Color brighter = c .brighter ();
@@ -374,6 +384,8 @@ public boolean drawImage(Image img, int x, int y, ImageObserver observer) {
374384
375385 public boolean drawImage (Image img , int x , int y , int width , int height ,
376386 ImageObserver observer ) {
387+ if (width <= 0 || height <= 0 )
388+ return true ;
377389 backgroundPainted = true ;
378390 if (img != null ) {
379391 DOMNode imgNode = getImageNode (img );
@@ -406,6 +418,8 @@ public boolean drawImage(Image img, int x, int y, Color bgcolor,
406418
407419 public boolean drawImage (Image img , int x , int y , int width , int height ,
408420 Color bgcolor , ImageObserver observer ) {
421+ if (width <= 0 || height <= 0 )
422+ return false ;
409423 backgroundPainted = true ;
410424 JSUtil .notImplemented (null );
411425 return drawImage (img , x , y , width , height , observer );
0 commit comments