#define kMargin 16
#define kSlop 2
-class BoundsCheck : public CommonCheck {
-public:
- BoundsCheck() {
- mAllDrawnIn.setEmpty();
- mLastAll.setEmpty();
- mLastOver.setEmpty();
- }
-
- static int Area(SkIRect test) {
- return test.width() * test.height();
- }
-
- void checkLast() {
- if (mAllDrawnIn.isEmpty())
- return;
- if (mLastAll.isEmpty() || Area(mLastAll) < Area(mAllDrawnIn)) {
- mLastAll = mAllDrawnIn;
- mDrawnOver.setEmpty();
- }
- mAllDrawnIn.setEmpty();
- }
-
- bool hidden() {
- return (mLastAll.isEmpty() && mLastOver.isEmpty()) ||
- mDrawnOver.contains(mBounds);
- }
-
- virtual bool onIRect(const SkIRect& rect) {
- if (joinGlyphs(rect))
- return false;
- bool interestingType = mType == kDrawBitmap_Type
- || mType == kDrawSprite_Type
- || mType == kDrawRect_Type || isTextType(mType);
- if (SkIRect::Intersects(mBounds, rect) == false) {
- DBG_NAV_LOGD("BoundsCheck (no intersect) rect={%d,%d,%d,%d}"
- " mType=%s", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom,
- TypeNames[mType]);
- if (interestingType)
- checkLast();
- return false;
- }
- if (interestingType == false)
- return false;
- if (!mDrawnOver.contains(rect) && (mBoundsSlop.contains(rect) ||
- (mBounds.fLeft == rect.fLeft && mBounds.fRight == rect.fRight &&
- mBounds.fTop >= rect.fTop && mBounds.fBottom <= rect.fBottom) ||
- (mBounds.fTop == rect.fTop && mBounds.fBottom == rect.fBottom &&
- mBounds.fLeft >= rect.fLeft && mBounds.fRight <= rect.fRight))) {
- mDrawnOver.setEmpty();
- mAllDrawnIn.join(rect);
- DBG_NAV_LOGD("BoundsCheck (contains) rect={%d,%d,%d,%d}"
- " mAllDrawnIn={%d,%d,%d,%d} mType=%s",
- rect.fLeft, rect.fTop, rect.fRight, rect.fBottom,
- mAllDrawnIn.fLeft, mAllDrawnIn.fTop, mAllDrawnIn.fRight,
- mAllDrawnIn.fBottom, TypeNames[mType]);
- } else {
- checkLast();
- if (!isTextType(mType)) {
- if (
-#if 0
-// should the opaqueness of the bitmap disallow its ability to draw over?
-// not sure that this test is needed
- (mType != kDrawBitmap_Type ||
- (mIsOpaque && mAllOpaque)) &&
-#endif
- mLastAll.isEmpty() == false)
- mDrawnOver.op(rect, SkRegion::kUnion_Op);
- } else {
-// FIXME
-// sometimes the text is not drawn entirely inside the cursor area, even though
-// it is the correct text. Until I figure out why, I allow text drawn at the
-// end that is not covered up by something else to represent the link
-// example that triggers this that should be figured out:
-// http://cdn.labpixies.com/campaigns/blackjack/blackjack.html?lang=en&country=US&libs=assets/feature/core
-// ( http://tinyurl.com/ywsyzb )
- mLastOver = rect;
- }
-#if DEBUG_NAV_UI
- const SkIRect& drawnOver = mDrawnOver.getBounds();
- DBG_NAV_LOGD("(overlaps) rect={%d,%d,%d,%d}"
- " mDrawnOver={%d,%d,%d,%d} mType=%s mIsOpaque=%s mAllOpaque=%s",
- rect.fLeft, rect.fTop, rect.fRight, rect.fBottom,
- drawnOver.fLeft, drawnOver.fTop, drawnOver.fRight, drawnOver.fBottom,
- TypeNames[mType], mIsOpaque ? "true" : "false",
- mAllOpaque ? "true" : "false");
-#endif
- }
- return false;
- }
-
- SkIRect mBounds;
- SkIRect mBoundsSlop;
- SkRegion mDrawnOver;
- SkIRect mLastOver;
- SkIRect mAllDrawnIn;
- SkIRect mLastAll;
-};
-
class BoundsCanvas : public ParseCanvas {
public: