mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 234984. Clean up nsRect/nsSize a bit. r+sr=dbaron
This commit is contained in:
parent
563f257e30
commit
260cbe3924
@ -124,20 +124,9 @@ struct NS_GFX nsRect {
|
||||
return (PRBool) !operator==(aRect);
|
||||
}
|
||||
|
||||
// This method is weird. It should probably be deprecated.
|
||||
nsRect operator+(const nsRect& aRect) const {
|
||||
return nsRect(x + aRect.x, y + aRect.y,
|
||||
width + aRect.width, height + aRect.height);
|
||||
}
|
||||
nsRect operator+(const nsPoint& aPoint) const {
|
||||
return nsRect(x + aPoint.x, y + aPoint.y, width, height);
|
||||
}
|
||||
|
||||
// This method is weird. It should probably be deprecated.
|
||||
nsRect operator-(const nsRect& aRect) const {
|
||||
return nsRect(x - aRect.x, y - aRect.y,
|
||||
width - aRect.width, height - aRect.height);
|
||||
}
|
||||
nsRect operator-(const nsPoint& aPoint) const {
|
||||
return nsRect(x - aPoint.x, y - aPoint.y, width, height);
|
||||
}
|
||||
@ -153,6 +142,12 @@ struct NS_GFX nsRect {
|
||||
nsRect& ScaleRoundOut(const float aScale);
|
||||
nsRect& ScaleRoundIn(const float aScale);
|
||||
|
||||
// Helpers for accessing the vertices
|
||||
nsPoint TopLeft() const { return nsPoint(x, y); }
|
||||
nsPoint TopRight() const { return nsPoint(XMost(), y); }
|
||||
nsPoint BottomLeft() const { return nsPoint(x, YMost()); }
|
||||
nsPoint BottomRight() const { return nsPoint(XMost(), YMost()); }
|
||||
|
||||
// Helper methods for computing the extents
|
||||
nscoord XMost() const {return x + width;}
|
||||
nscoord YMost() const {return y + height;}
|
||||
|
@ -67,15 +67,9 @@ struct nsSize {
|
||||
nsSize operator+(const nsSize& aSize) const {
|
||||
return nsSize(width + aSize.width, height + aSize.height);
|
||||
}
|
||||
nsSize operator-(const nsSize& aSize) const {
|
||||
return nsSize(width - aSize.width, height - aSize.height);
|
||||
}
|
||||
nsSize& operator+=(const nsSize& aSize) {width += aSize.width;
|
||||
height += aSize.height;
|
||||
return *this;}
|
||||
nsSize& operator-=(const nsSize& aSize) {width -= aSize.width;
|
||||
height -= aSize.height;
|
||||
return *this;}
|
||||
};
|
||||
|
||||
#endif /* NSSIZE_H */
|
||||
|
Loading…
Reference in New Issue
Block a user