From 22c35b1a70a32a2c19a19c704fc44f5ef328fd79 Mon Sep 17 00:00:00 2001 From: Joe Drew Date: Mon, 14 Nov 2011 17:29:01 +1300 Subject: [PATCH] Bug 685322 - Create explicit conversion constructors for Rect and Point taking IntRect and IntPoint. r=roc --- gfx/2d/Point.h | 32 ++++++++++++++++++-------------- gfx/2d/Rect.h | 24 +++++++++++++----------- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/gfx/2d/Point.h b/gfx/2d/Point.h index 2d8913635c06..fabed9dd71a4 100644 --- a/gfx/2d/Point.h +++ b/gfx/2d/Point.h @@ -45,26 +45,21 @@ namespace mozilla { namespace gfx { -struct Point : - public BasePoint { - typedef BasePoint Super; - Point() : Super() {} - Point(Float aX, Float aY) : Super(aX, aY) {} -}; - struct IntPoint : - public BasePoint { - typedef BasePoint Super; + public BasePoint { + typedef BasePoint Super; + IntPoint() : Super() {} IntPoint(int32_t aX, int32_t aY) : Super(aX, aY) {} }; -struct Size : - public BaseSize { - typedef BaseSize Super; +struct Point : + public BasePoint { + typedef BasePoint Super; - Size() : Super() {} - Size(Float aWidth, Float aHeight) : Super(aWidth, aHeight) {} + Point() : Super() {} + Point(Float aX, Float aY) : Super(aX, aY) {} + Point(const IntPoint& point) : Super(point.x, point.y) {} }; struct IntSize : @@ -75,6 +70,15 @@ struct IntSize : IntSize(int32_t aWidth, int32_t aHeight) : Super(aWidth, aHeight) {} }; +struct Size : + public BaseSize { + typedef BaseSize Super; + + Size() : Super() {} + Size(Float aWidth, Float aHeight) : Super(aWidth, aHeight) {} + explicit Size(const IntSize& size) : Super(size.width, size.height) {} +}; + } } diff --git a/gfx/2d/Rect.h b/gfx/2d/Rect.h index 3028c08995d8..0246d940d952 100644 --- a/gfx/2d/Rect.h +++ b/gfx/2d/Rect.h @@ -55,17 +55,6 @@ struct Margin : : Super(aLeft, aTop, aRight, aBottom) {} }; -struct Rect : - public BaseRect { - typedef BaseRect Super; - - Rect() : Super() {} - Rect(Point aPos, mozilla::gfx::Size aSize) : - Super(aPos, aSize) {} - Rect(Float _x, Float _y, Float _width, Float _height) : - Super(_x, _y, _width, _height) {} -}; - struct IntRect : public BaseRect { typedef BaseRect Super; @@ -77,6 +66,19 @@ struct IntRect : Super(_x, _y, _width, _height) {} }; +struct Rect : + public BaseRect { + typedef BaseRect Super; + + Rect() : Super() {} + Rect(Point aPos, mozilla::gfx::Size aSize) : + Super(aPos, aSize) {} + Rect(Float _x, Float _y, Float _width, Float _height) : + Super(_x, _y, _width, _height) {} + explicit Rect(const IntRect& rect) : + Super(rect.x, rect.y, rect.width, rect.height) {} +}; + } }