static float GetDisplayportCoverage(const CSSRect& aDisplayPort, const Matrix4x4& aTransformToScreen, const IntRect& aScreenRect) { Rect transformedDisplayport = aTransformToScreen.TransformBounds(aDisplayPort.ToUnknownRect()); transformedDisplayport.RoundOut(); IntRect displayport = IntRect(transformedDisplayport.x, transformedDisplayport.y, transformedDisplayport.width, transformedDisplayport.height); if (!displayport.Contains(aScreenRect)) { nsIntRegion coveredRegion; coveredRegion.And(aScreenRect, displayport); return coveredRegion.Area() / (float)(aScreenRect.width * aScreenRect.height); } return 1.0f; }
View* View::ViewAt(const BPoint& where) { if (!fVisible) return NULL; IntRect frame = Frame(); if (Parent() != NULL) Parent()->ConvertToScreen(&frame); if (!frame.Contains(where)) return NULL; for (View* child = FirstChild(); child; child = child->NextSibling()) { View* view = child->ViewAt(where); if (view != NULL) return view; } return this; }
static bool _get_rectangular_clip (cairo_t *cr, const IntRect& bounds, bool *need_clip, IntRect *rectangles, int max_rectangles, int *num_rectangles) { cairo_rectangle_list_t *cliplist; cairo_rectangle_t *clips; int i; bool retval = true; cliplist = cairo_copy_clip_rectangle_list (cr); if (cliplist->status != CAIRO_STATUS_SUCCESS) { retval = false; NATIVE_DRAWING_NOTE("FALLBACK: non-rectangular clip"); goto FINISH; } /* the clip is always in surface backend coordinates (i.e. native backend coords) */ clips = cliplist->rectangles; for (i = 0; i < cliplist->num_rectangles; ++i) { IntRect rect; if (!_convert_coord_to_int (clips[i].x, &rect.x) || !_convert_coord_to_int (clips[i].y, &rect.y) || !_convert_coord_to_int (clips[i].width, &rect.width) || !_convert_coord_to_int (clips[i].height, &rect.height)) { retval = false; NATIVE_DRAWING_NOTE("FALLBACK: non-integer clip"); goto FINISH; } if (rect.IsEqualInterior(bounds)) { /* the bounds are entirely inside the clip region so we don't need to clip. */ *need_clip = false; goto FINISH; } NS_ASSERTION(bounds.Contains(rect), "Was expecting to be clipped to bounds"); if (i >= max_rectangles) { retval = false; NATIVE_DRAWING_NOTE("FALLBACK: unsupported clip rectangle count"); goto FINISH; } rectangles[i] = rect; } *need_clip = true; *num_rectangles = cliplist->num_rectangles; FINISH: cairo_rectangle_list_destroy (cliplist); return retval; }