Bug 681192. Part 0.1: Add BaseRect::ClampPoint. r=bas

--HG--
extra : rebase_source : 32e086725d450d8867a4b5978cd76a2f03609572
This commit is contained in:
Robert O'Callahan 2012-05-10 17:24:17 +12:00
parent 528e055ee2
commit 2ec4edf80b

View File

@ -415,6 +415,16 @@ struct BaseRect {
height = bottom - y;
}
/**
* Clamp aPoint to this rectangle. It is allowed to end up on any
* edge of the rectangle.
*/
Point ClampPoint(const Point& aPoint) const
{
return Point(NS_MAX(x, NS_MIN(XMost(), aPoint.x)),
NS_MAX(y, NS_MIN(YMost(), aPoint.y)));
}
private:
// Do not use the default operator== or operator!= !
// Use IsEqualEdges or IsEqualInterior explicitly.