Bug 685322 - Create explicit conversion constructors for Rect and Point taking IntRect and IntPoint. r=roc

This commit is contained in:
Joe Drew 2011-11-14 17:29:01 +13:00
Родитель af1b95f9bb
Коммит 22c35b1a70
2 изменённых файлов: 31 добавлений и 25 удалений

Просмотреть файл

@ -45,26 +45,21 @@
namespace mozilla {
namespace gfx {
struct Point :
public BasePoint<Float, Point> {
typedef BasePoint<Float, Point> Super;
Point() : Super() {}
Point(Float aX, Float aY) : Super(aX, aY) {}
};
struct IntPoint :
public BasePoint<int32_t, Point> {
typedef BasePoint<int32_t, Point> Super;
public BasePoint<int32_t, IntPoint> {
typedef BasePoint<int32_t, IntPoint> Super;
IntPoint() : Super() {}
IntPoint(int32_t aX, int32_t aY) : Super(aX, aY) {}
};
struct Size :
public BaseSize<Float, Size> {
typedef BaseSize<Float, Size> Super;
struct Point :
public BasePoint<Float, Point> {
typedef BasePoint<Float, Point> 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<Float, Size> {
typedef BaseSize<Float, Size> Super;
Size() : Super() {}
Size(Float aWidth, Float aHeight) : Super(aWidth, aHeight) {}
explicit Size(const IntSize& size) : Super(size.width, size.height) {}
};
}
}

Просмотреть файл

@ -55,17 +55,6 @@ struct Margin :
: Super(aLeft, aTop, aRight, aBottom) {}
};
struct Rect :
public BaseRect<Float, Rect, Point, Size, Margin> {
typedef BaseRect<Float, Rect, Point, mozilla::gfx::Size, Margin> 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<int32_t, IntRect, IntPoint, IntSize, Margin> {
typedef BaseRect<int32_t, IntRect, IntPoint, mozilla::gfx::IntSize, Margin> Super;
@ -77,6 +66,19 @@ struct IntRect :
Super(_x, _y, _width, _height) {}
};
struct Rect :
public BaseRect<Float, Rect, Point, Size, Margin> {
typedef BaseRect<Float, Rect, Point, mozilla::gfx::Size, Margin> 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) {}
};
}
}