Bug 234984. Clean up nsRect/nsSize a bit. r+sr=dbaron

This commit is contained in:
roc+%cs.cmu.edu 2004-03-10 01:59:16 +00:00
parent 563f257e30
commit 260cbe3924
2 changed files with 6 additions and 17 deletions

View File

@ -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;}

View File

@ -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 */