Bug 675837 - Add gfxContext::ClipContainsRect. r=roc

This commit is contained in:
Matt Woodrow 2011-08-27 12:03:04 +12:00
parent bffee7f7cc
commit 6c63c596b7
2 changed files with 30 additions and 0 deletions

View File

@ -696,6 +696,29 @@ gfxContext::GetClipExtents()
return gfxRect(xmin, ymin, xmax - xmin, ymax - ymin);
}
PRBool
gfxContext::ClipContainsRect(const gfxRect& aRect)
{
cairo_rectangle_list_t *clip =
cairo_copy_clip_rectangle_list(mCairo);
PRBool result = PR_FALSE;
if (clip->status == CAIRO_STATUS_SUCCESS) {
for (int i = 0; i < clip->num_rectangles; i++) {
gfxRect rect(clip->rectangles[i].x, clip->rectangles[i].y,
clip->rectangles[i].width, clip->rectangles[i].height);
if (rect.Contains(aRect)) {
result = PR_TRUE;
break;
}
}
}
cairo_rectangle_list_destroy(clip);
return result;
}
// rendering sources
void

View File

@ -605,6 +605,13 @@ public:
*/
gfxRect GetClipExtents();
/**
* Returns true if the given rectangle is fully contained in the current clip.
* This is conservative; it may return false even when the given rectangle is
* fully contained by the current clip.
*/
PRBool ClipContainsRect(const gfxRect& aRect);
/**
* Groups
*/