diff options
Diffstat (limited to 'WebKit/android/nav/CachedRoot.cpp')
-rw-r--r-- | WebKit/android/nav/CachedRoot.cpp | 115 |
1 files changed, 10 insertions, 105 deletions
diff --git a/WebKit/android/nav/CachedRoot.cpp b/WebKit/android/nav/CachedRoot.cpp index 2f0e74d..2662071 100644 --- a/WebKit/android/nav/CachedRoot.cpp +++ b/WebKit/android/nav/CachedRoot.cpp @@ -131,104 +131,6 @@ public: #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: @@ -675,10 +577,12 @@ public: class RingCheck : public CommonCheck { public: RingCheck(const WTF::Vector<WebCore::IntRect>& rings, - const WebCore::IntRect& bitBounds, const WebCore::IntRect& testBounds) + const WebCore::IntRect& bitBounds, const WebCore::IntRect& testBounds, + bool singleImage) : mTestBounds(testBounds) , mBitBounds(bitBounds) , mPushPop(false) + , mSingleImage(singleImage) { const WebCore::IntRect* r; for (r = rings.begin(); r != rings.end(); r++) { @@ -910,7 +814,7 @@ protected: && mType != kDrawSprite_Type && mType != kDrawBitmap_Type) return false; if (mLayerTypes.isEmpty() || mLayerTypes.last() != mType - || !mAppendLikeTypes || mPushPop + || !mAppendLikeTypes || mPushPop || mSingleImage // if the last and current were not glyphs, // and the two bounds have a gap between, don't join them -- push // an empty between them @@ -1054,6 +958,7 @@ private: char mCh; bool mAppendLikeTypes; bool mPushPop; + bool mSingleImage; }; class RingCanvas : public BoundsCanvas { @@ -1205,16 +1110,16 @@ void CachedRoot::checkForJiggle(int* xDeltaPtr) const *xDeltaPtr = jiggleCheck.jiggle(); } -bool CachedRoot::checkRings(SkPicture* picture, - const WTF::Vector<WebCore::IntRect>& rings, - const WebCore::IntRect& nodeBounds, +bool CachedRoot::checkRings(SkPicture* picture, const CachedNode* node, const WebCore::IntRect& testBounds) const { if (!picture) return false; + const WTF::Vector<WebCore::IntRect>& rings = node->rings(); + const WebCore::IntRect& nodeBounds = node->rawBounds(); IntRect bitBounds; calcBitBounds(nodeBounds, &bitBounds); - RingCheck ringCheck(rings, bitBounds, testBounds); + RingCheck ringCheck(rings, bitBounds, testBounds, node->singleImage()); RingCanvas checker(&ringCheck); SkBitmap bitmap; bitmap.setConfig(SkBitmap::kARGB_8888_Config, bitBounds.width(), @@ -1576,7 +1481,7 @@ bool CachedRoot::maskIfHidden(BestData* best) const const WebCore::IntRect& bounds = bestNode->bounds(frame); IntRect bitBounds; calcBitBounds(bounds, &bitBounds); - RingCheck ringCheck(rings, bitBounds, bounds); + RingCheck ringCheck(rings, bitBounds, bounds, bestNode->singleImage()); RingCanvas checker(&ringCheck); SkBitmap bitmap; bitmap.setConfig(SkBitmap::kARGB_8888_Config, bitBounds.width(), |