mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1092222, part 2 - Add CCWCorner, CCWCorner and CWCorner methods to BaseRect. r=roc
This commit is contained in:
parent
15a8e15ca2
commit
2b1b28af50
@ -13,6 +13,7 @@
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
#include "Types.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
@ -311,6 +312,33 @@ struct BaseRect {
|
||||
Point TopRight() const { return Point(XMost(), y); }
|
||||
Point BottomLeft() const { return Point(x, YMost()); }
|
||||
Point BottomRight() const { return Point(XMost(), YMost()); }
|
||||
Point AtCorner(int aCorner) const {
|
||||
switch (aCorner) {
|
||||
case RectCorner::TopLeft: return TopLeft();
|
||||
case RectCorner::TopRight: return TopRight();
|
||||
case RectCorner::BottomRight: return BottomRight();
|
||||
case RectCorner::BottomLeft: return BottomLeft();
|
||||
}
|
||||
MOZ_CRASH("Incomplete switch");
|
||||
}
|
||||
Point CCWCorner(mozilla::Side side) const {
|
||||
switch (side) {
|
||||
case NS_SIDE_TOP: return TopLeft();
|
||||
case NS_SIDE_RIGHT: return TopRight();
|
||||
case NS_SIDE_BOTTOM: return BottomRight();
|
||||
case NS_SIDE_LEFT: return BottomLeft();
|
||||
}
|
||||
MOZ_CRASH("Incomplete switch");
|
||||
}
|
||||
Point CWCorner(mozilla::Side side) const {
|
||||
switch (side) {
|
||||
case NS_SIDE_TOP: return TopRight();
|
||||
case NS_SIDE_RIGHT: return BottomRight();
|
||||
case NS_SIDE_BOTTOM: return BottomLeft();
|
||||
case NS_SIDE_LEFT: return TopLeft();
|
||||
}
|
||||
MOZ_CRASH("Incomplete switch");
|
||||
}
|
||||
Point Center() const { return Point(x, y) + Point(width, height)/2; }
|
||||
SizeT Size() const { return SizeT(width, height); }
|
||||
|
||||
|
@ -153,21 +153,6 @@ inline TemporaryRef<Path> MakePathForRect(const DrawTarget& aDrawTarget,
|
||||
return builder->Finish();
|
||||
}
|
||||
|
||||
// We can't use MOZ_BEGIN_ENUM_CLASS here because that prevents the enum
|
||||
// values from being used for indexing. Wrapping the enum in a struct does at
|
||||
// least gives us name scoping.
|
||||
struct RectCorner {
|
||||
enum {
|
||||
// This order is important since AppendRoundedRectToPath and other code
|
||||
// depends on it!
|
||||
TopLeft = 0,
|
||||
TopRight = 1,
|
||||
BottomRight = 2,
|
||||
BottomLeft = 3,
|
||||
Count = 4
|
||||
};
|
||||
};
|
||||
|
||||
struct RectCornerRadii {
|
||||
Size radii[RectCorner::Count];
|
||||
|
||||
|
@ -294,6 +294,22 @@ struct GradientStop
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
// We can't use MOZ_BEGIN_ENUM_CLASS here because that prevents the enum
|
||||
// values from being used for indexing. Wrapping the enum in a struct does at
|
||||
// least gives us name scoping.
|
||||
struct RectCorner {
|
||||
enum {
|
||||
// This order is important since Rect::AtCorner, AppendRoundedRectToPath
|
||||
// and other code depends on it!
|
||||
TopLeft = 0,
|
||||
TopRight = 1,
|
||||
BottomRight = 2,
|
||||
BottomLeft = 3,
|
||||
Count = 4
|
||||
};
|
||||
};
|
||||
|
||||
// Side constants for use in various places.
|
||||
enum Side { eSideTop, eSideRight, eSideBottom, eSideLeft };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user