Bug 620658: Add nsRegion::Contains(nsRegion). sr=roc

This commit is contained in:
Chris Jones 2011-01-26 00:26:37 -06:00
parent d5e0476347
commit ef159da4a5
2 changed files with 17 additions and 0 deletions

View File

@ -1013,6 +1013,18 @@ PRBool nsRegion::Contains (const nsRect& aRect) const
return tmpRgn.IsEmpty(); return tmpRgn.IsEmpty();
} }
PRBool nsRegion::Contains (const nsRegion& aRgn) const
{
// XXX this could be made faster
nsRegionRectIterator iter(aRgn);
while (const nsRect* r = iter.Next()) {
if (!Contains (*r)) {
return PR_FALSE;
}
}
return PR_TRUE;
}
PRBool nsRegion::Intersects (const nsRect& aRect) const PRBool nsRegion::Intersects (const nsRect& aRect) const
{ {
if (aRect.IsEmpty() || IsEmpty()) if (aRect.IsEmpty() || IsEmpty())

View File

@ -160,6 +160,7 @@ public:
} }
PRBool Contains (const nsRect& aRect) const; PRBool Contains (const nsRect& aRect) const;
PRBool Contains (const nsRegion& aRgn) const;
PRBool Intersects (const nsRect& aRect) const; PRBool Intersects (const nsRect& aRect) const;
void MoveBy (PRInt32 aXOffset, PRInt32 aYOffset) void MoveBy (PRInt32 aXOffset, PRInt32 aYOffset)
@ -400,6 +401,10 @@ public:
{ {
return mImpl.Contains (ToRect (aRect)); return mImpl.Contains (ToRect (aRect));
} }
PRBool Contains (const nsIntRegion& aRgn) const
{
return mImpl.Contains (aRgn.mImpl);
}
PRBool Intersects (const nsIntRect& aRect) const PRBool Intersects (const nsIntRect& aRect) const
{ {
return mImpl.Intersects (ToRect (aRect)); return mImpl.Intersects (ToRect (aRect));