@@ -157,6 +157,8 @@ private void doCirc(int left, int top, int diameter, boolean fill) {
157157
158158 private void doArc (double x , double y , double width , double height , double startAngle ,
159159 double arcAngle , boolean fill ) {
160+ if (width < 0 || height < 0 )
161+ return ;
160162// boolean doClose = (arcAngle - startAngle == 360);
161163 ctx .save ();
162164 {
@@ -230,6 +232,8 @@ private void doPoly(int[] axPoints, int[] ayPoints, int nPoints,
230232
231233
232234 public void drawRect (int x , int y , int width , int height ) {
235+ if (width <= 0 || height <= 0 )
236+ return ;
233237 ctx .beginPath ();
234238 ctx .rect (x , y , width , height );
235239 ctx .stroke ();
@@ -245,11 +249,15 @@ public void fillPolygon(int[] axPoints, int[] ayPoints, int nPoints) {
245249
246250
247251 public void fillRect (int x , int y , int width , int height ) {
252+ if (width <= 0 || height <= 0 )
253+ return ;
248254 backgroundPainted = true ;
249255 ctx .fillRect (x , y , width , height );
250256 }
251257
252258 public void fill3DRect (int x , int y , int width , int height , boolean raised ) {
259+ if (width <= 0 || height <= 0 )
260+ return ;
253261 Paint p = getPaint ();
254262 Color c = getColor ();
255263 Color brighter = c .brighter ();
@@ -374,6 +382,8 @@ public boolean drawImage(Image img, int x, int y, ImageObserver observer) {
374382
375383 public boolean drawImage (Image img , int x , int y , int width , int height ,
376384 ImageObserver observer ) {
385+ if (width <= 0 || height <= 0 )
386+ return true ;
377387 backgroundPainted = true ;
378388 if (img != null ) {
379389 DOMNode imgNode = getImageNode (img );
@@ -406,6 +416,8 @@ public boolean drawImage(Image img, int x, int y, Color bgcolor,
406416
407417 public boolean drawImage (Image img , int x , int y , int width , int height ,
408418 Color bgcolor , ImageObserver observer ) {
419+ if (width <= 0 || height <= 0 )
420+ return false ;
409421 backgroundPainted = true ;
410422 JSUtil .notImplemented (null );
411423 return drawImage (img , x , y , width , height , observer );
0 commit comments