From 24c327ac5ed0890b216d7cfca7e86a82313fd099 Mon Sep 17 00:00:00 2001 From: atomizer Date: Wed, 20 Apr 2011 02:47:36 +0400 Subject: [PATCH] special case of zero-width rectangle Signed-off-by: Tj Holowaychuk --- src/CanvasRenderingContext2d.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/CanvasRenderingContext2d.cc b/src/CanvasRenderingContext2d.cc index ab1000a..9ec21a1 100644 --- a/src/CanvasRenderingContext2d.cc +++ b/src/CanvasRenderingContext2d.cc @@ -1695,7 +1695,16 @@ Context2d::Rect(const Arguments &args) { HandleScope scope; RECT_ARGS; Context2d *context = ObjectWrap::Unwrap(args.This()); - cairo_rectangle(context->context(), x, y, width, height); + cairo_t *ctx = context->context(); + if (width == 0) { + cairo_move_to(ctx, x, y); + cairo_line_to(ctx, x, y + height); + } else if (height == 0) { + cairo_move_to(ctx, x, y); + cairo_line_to(ctx, x + width, y); + } else { + cairo_rectangle(ctx, x, y, width, height); + } return Undefined(); }