diff options
Diffstat (limited to 'WebKit/android/nav')
-rw-r--r-- | WebKit/android/nav/CachedFrame.cpp | 21 | ||||
-rw-r--r-- | WebKit/android/nav/CachedFrame.h | 2 | ||||
-rw-r--r-- | WebKit/android/nav/CachedLayer.cpp | 32 | ||||
-rw-r--r-- | WebKit/android/nav/CachedLayer.h | 4 | ||||
-rw-r--r-- | WebKit/android/nav/CachedRoot.cpp | 4 | ||||
-rw-r--r-- | WebKit/android/nav/SelectText.cpp | 44 | ||||
-rw-r--r-- | WebKit/android/nav/WebView.cpp | 6 |
7 files changed, 30 insertions, 83 deletions
diff --git a/WebKit/android/nav/CachedFrame.cpp b/WebKit/android/nav/CachedFrame.cpp index 419be14..b26e24b 100644 --- a/WebKit/android/nav/CachedFrame.cpp +++ b/WebKit/android/nav/CachedFrame.cpp @@ -65,24 +65,6 @@ WebCore::IntRect CachedFrame::adjustBounds(const CachedNode* node, return rect; } -// This is for nodes inside a layer. It takes an IntRect that has been -// adjusted by the layer's position and removes the adjustment made by the -// layer. -WebCore::IntRect CachedFrame::unadjustBounds(const CachedNode* node, - const WebCore::IntRect& rect) const -{ -#if USE(ACCELERATED_COMPOSITING) - if (node->isInLayer()) { - const CachedLayer* cachedLayer = layer(node); - const WebCore::LayerAndroid* rootLayer = mRoot->rootLayer(); - const LayerAndroid* aLayer = cachedLayer->layer(rootLayer); - if (aLayer) - return cachedLayer->unadjustBounds(rootLayer, rect); - } -#endif - return rect; -} - bool CachedFrame::CheckBetween(Direction direction, const WebCore::IntRect& bestRect, const WebCore::IntRect& prior, WebCore::IntRect* result) { @@ -435,7 +417,6 @@ const CachedNode* CachedFrame::findBestAt(const WebCore::IntRect& rect, *directHit = test; *directHitFramePtr = this; IntRect r(center, IntSize(0, 0)); - r = unadjustBounds(test, r); *x = r.x(); *y = r.y(); } else { @@ -480,7 +461,6 @@ const CachedNode* CachedFrame::findBestAt(const WebCore::IntRect& rect, *inside = testInside; result = test; *framePtr = this; - both = unadjustBounds(test, both); *x = both.x() + (both.width() >> 1); *y = both.y() + (both.height() >> 1); } @@ -552,7 +532,6 @@ const CachedNode* CachedFrame::findBestHitAt(const WebCore::IntRect& rect, if (cursorRect.intersects(rect)) { WebCore::IntRect intersection(cursorRect); intersection.intersect(rect); - intersection = unadjustBounds(test, intersection); *x = intersection.x() + (intersection.width() >> 1); *y = intersection.y() + (intersection.height() >> 1); *framePtr = this; diff --git a/WebKit/android/nav/CachedFrame.h b/WebKit/android/nav/CachedFrame.h index 470f522..039a0ee 100644 --- a/WebKit/android/nav/CachedFrame.h +++ b/WebKit/android/nav/CachedFrame.h @@ -80,8 +80,6 @@ public: void addFrame(CachedFrame& child) { mCachedFrames.append(child); } WebCore::IntRect adjustBounds(const CachedNode* , const WebCore::IntRect& ) const; - WebCore::IntRect unadjustBounds(const CachedNode*, - const WebCore::IntRect& ) const; bool checkRings(const CachedNode* node, const WebCore::IntRect& testBounds) const; bool checkVisited(const CachedNode* , CachedFrame::Direction ) const; diff --git a/WebKit/android/nav/CachedLayer.cpp b/WebKit/android/nav/CachedLayer.cpp index 3321797..299f2d1 100644 --- a/WebKit/android/nav/CachedLayer.cpp +++ b/WebKit/android/nav/CachedLayer.cpp @@ -99,38 +99,6 @@ IntRect CachedLayer::adjustBounds(const LayerAndroid* root, return result; } -IntRect CachedLayer::unadjustBounds(const LayerAndroid* root, - const IntRect& bounds) const -{ - const LayerAndroid* aLayer = layer(root); - if (!aLayer) - return bounds; - - IntRect temp = bounds; - // Remove the new position (i.e. fixed position elements). - FloatPoint position = getGlobalPosition(aLayer); - - temp.move(-position.x(), -position.y()); - - // Remove any layer translation. - const FloatPoint& translation = aLayer->translation(); - temp.move(-translation.x(), -translation.y()); - - // Move it back to the original offset. - temp.move(mOffset.x(), mOffset.y()); - - DBG_NAV_LOGD("root=%p aLayer=%p [%d]" - " bounds=(%d,%d,w=%d,h=%d) trans=(%g,%g) pos=(%f,%f)" - " offset=(%d,%d)" - " result=(%d,%d,w=%d,h=%d)", - root, aLayer, aLayer->uniqueId(), - bounds.x(), bounds.y(), bounds.width(), bounds.height(), - translation.x(), translation.y(), position.x(), position.y(), - mOffset.x(), mOffset.y(), - temp.x(), temp.y(), temp.width(), temp.height()); - return temp; -} - FloatPoint CachedLayer::getGlobalPosition(const LayerAndroid* aLayer) const { SkPoint result = aLayer->getPosition(); diff --git a/WebKit/android/nav/CachedLayer.h b/WebKit/android/nav/CachedLayer.h index 0a382fd..3d963e0 100644 --- a/WebKit/android/nav/CachedLayer.h +++ b/WebKit/android/nav/CachedLayer.h @@ -48,10 +48,6 @@ public: } // FIXME: adjustBounds should be renamed globalBounds or toGlobal IntRect adjustBounds(const LayerAndroid* root, const IntRect& bounds) const; - // Moves the bounds by the layer's position. Assumes the incoming - // bounds have been adjusted by adjustBounds. - IntRect unadjustBounds(const LayerAndroid* root, - const IntRect& bounds) const; int cachedNodeIndex() const { return mCachedNodeIndex; } FloatPoint getGlobalPosition(const LayerAndroid* ) const; const LayerAndroid* layer(const LayerAndroid* root) const; diff --git a/WebKit/android/nav/CachedRoot.cpp b/WebKit/android/nav/CachedRoot.cpp index 33e7b4f..6083296 100644 --- a/WebKit/android/nav/CachedRoot.cpp +++ b/WebKit/android/nav/CachedRoot.cpp @@ -1379,9 +1379,7 @@ void CachedRoot::innerMove(const CachedNode* node, BestData* bestData, if (bestData->mNode != NULL) { mHistory->addToVisited(bestData->mNode, direction); mHistory->mNavBounds = bestData->bounds(); - mHistory->mMouseBounds = - bestData->mFrame->unadjustBounds(bestData->mNode, - bestData->mouseBounds()); + mHistory->mMouseBounds = bestData->mouseBounds(); } else if (scroll->x() != 0 || scroll->y() != 0) { WebCore::IntRect newBounds = mHistory->mNavBounds; int offsetX = scroll->x(); diff --git a/WebKit/android/nav/SelectText.cpp b/WebKit/android/nav/SelectText.cpp index fce05f7..5ed5c21 100644 --- a/WebKit/android/nav/SelectText.cpp +++ b/WebKit/android/nav/SelectText.cpp @@ -160,6 +160,7 @@ public: reset(); } + /* called only while the picture is parsed */ int base() { if (mBase == INT_MAX) { SkPoint result; @@ -168,7 +169,8 @@ public: } return mBase; } - + + /* called only while the picture is parsed */ int bottom() { if (mBottom == INT_MAX) { SkPoint result; @@ -211,12 +213,14 @@ public: { mLastGlyph = mLastCandidate; mLastUni = mLastUniCandidate; + mLastPaint = mLastPaintCandidate; } const SkIRect& getArea() const { return mArea; } + /* called only while the picture is parsed */ SkUnichar getUniChar(const SkBounder::GlyphRec& rec) { SkUnichar unichar; @@ -253,29 +257,31 @@ public: const SkBounder::GlyphRec& second = mLastGlyph.fLSB.fX < rec.fLSB.fX ? rec : mLastGlyph; uint16_t firstGlyph = first.fGlyphID; - SkScalar firstWidth = mPaint.measureText(&firstGlyph, sizeof(firstGlyph)); + SkScalar firstWidth = mLastPaint.measureText(&firstGlyph, sizeof(firstGlyph)); SkFixed ceilWidth = SkIntToFixed(SkScalarCeil(firstWidth)); SkFixed posNoSpace = first.fLSB.fX + ceilWidth; - SkFixed ceilSpace = SkIntToFixed(SkFixedCeil(minSpaceWidth())); + SkFixed ceilSpace = SkIntToFixed(SkFixedCeil(minSpaceWidth(mLastPaint))); SkFixed posWithSpace = posNoSpace + ceilSpace; SkFixed diffNoSpace = SkFixedAbs(second.fLSB.fX - posNoSpace); SkFixed diffWithSpace = SkFixedAbs(second.fLSB.fX - posWithSpace); - DBG_NAV_LOGD("second=%g width=%g (%g) noSpace=%g (%g) withSpace=%g (%g)", + DBG_NAV_LOGD("second=%g width=%g (%g) noSpace=%g (%g) withSpace=%g (%g)" + " fontSize=%g", SkFixedToScalar(second.fLSB.fX), firstWidth, SkFixedToScalar(ceilWidth), SkFixedToScalar(posNoSpace), SkFixedToScalar(diffNoSpace), - SkFixedToScalar(posWithSpace), SkFixedToScalar(diffWithSpace)); + SkFixedToScalar(posWithSpace), SkFixedToScalar(diffWithSpace), + mLastPaint.getTextSize()); return diffWithSpace < diffNoSpace; } - SkFixed minSpaceWidth() + SkFixed minSpaceWidth(SkPaint& paint) { if (mMinSpaceWidth == SK_FixedMax) { - SkPaint::TextEncoding save = mPaint.getTextEncoding(); - mPaint.setTextEncoding(SkPaint::kUTF8_TextEncoding); - SkScalar width = mPaint.measureText(" ", 1); + SkPaint::TextEncoding save = paint.getTextEncoding(); + paint.setTextEncoding(SkPaint::kUTF8_TextEncoding); + SkScalar width = paint.measureText(" ", 1); mMinSpaceWidth = SkScalarToFixed(width * mMatrix.getScaleX()); - mPaint.setTextEncoding(save); + paint.setTextEncoding(save); DBG_NAV_LOGV("width=%g matrix sx/sy=(%g, %g) tx/ty=(%g, %g)" " mMinSpaceWidth=%g", width, mMatrix.getScaleX(), mMatrix.getScaleY(), @@ -289,6 +295,7 @@ public: { mLastCandidate = rec; mLastUniCandidate = getUniChar(rec); + mLastPaintCandidate = mPaint; } void reset() @@ -302,7 +309,7 @@ public: mLastGlyph = check.mLastGlyph; mLastUni = check.mLastUni; mMatrix = check.mMatrix; - mPaint = check.mPaint; + mLastPaint = check.mLastPaint; reset(); } @@ -310,6 +317,7 @@ public: { mLastGlyph = check.mLastGlyph; mLastUni = check.mLastUni; + mLastPaint = check.mLastPaint; } void setUp(const SkPaint& paint, const SkMatrix& matrix, SkScalar y, @@ -322,6 +330,7 @@ public: reset(); } + /* called only while the picture is parsed */ int top() { if (mTop == INT_MAX) { SkPoint result; @@ -345,10 +354,12 @@ protected: SkIRect mArea; SkBounder::GlyphRec mLastCandidate; SkBounder::GlyphRec mLastGlyph; + SkPaint mLastPaint; // available after picture has been parsed + SkPaint mLastPaintCandidate; // associated with candidate glyph SkUnichar mLastUni; SkUnichar mLastUniCandidate; SkMatrix mMatrix; - SkPaint mPaint; + SkPaint mPaint; // only set up while the picture is parsed const uint16_t* mText; SkScalar mY; private: @@ -446,7 +457,7 @@ public: // assume that characters must be consecutive to describe spaces // (i.e., don't join rects drawn at different times) if (bounds.fTop != mLast.fTop || bounds.fBottom != mLast.fBottom - || bounds.fLeft > mLast.fRight + minSpaceWidth() + || bounds.fLeft > mLast.fRight + minSpaceWidth(mPaint) || bounds.fLeft < mLast.fLeft) { processLine(); mLast = bounds; @@ -477,7 +488,6 @@ protected: SkIRect mLast; SkTDArray<SkIRect> mParagraphs; SkTDArray<SkIRect> mSelected; - SkTDArray<SkIRect> mInColumn; bool mInBetween; private: typedef CommonCheck INHERITED; @@ -651,7 +661,7 @@ public: , mLast(area) , mLeft(left) { - mLast.set(last); + mLast.set(last); // CommonCheck::set() setGlyph(last); } @@ -706,7 +716,7 @@ public: mFocusX, mLeft ? "true" : "false", bounds.fLeft, bounds.fRight); reset(); mFocusX = mLeft ? bounds.fLeft : bounds.fRight; - mLast.set(*this); + mLast.set(*this); // CommonCheck::set() } protected: @@ -844,7 +854,7 @@ protected: mEndExtra.join(full); return mLastIntersects; } - int spaceGap = SkFixedRound(minSpaceWidth() * 3); + int spaceGap = SkFixedRound(minSpaceWidth(mPaint) * 3); // should text to the left of the start be added to the selection bounds? if (!mStartExtra.isEmpty()) { if (VERBOSE_LOGGING) DBG_NAV_LOGD("mSelectRect=(%d,%d,r=%d,b=%d)" diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index 177a9ce..03263ef 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -936,7 +936,7 @@ void selectBestAt(const WebCore::IntRect& rect) } else { DBG_NAV_LOGD("CachedNode:%p (%d)", node, node->index()); WebCore::IntRect bounds = node->bounds(frame); - root->rootHistory()->setMouseBounds(frame->unadjustBounds(node, bounds)); + root->rootHistory()->setMouseBounds(bounds); m_viewImpl->updateCursorBounds(root, frame, node); showCursorTimed(); root->setCursor(const_cast<CachedFrame*>(frame), @@ -988,8 +988,6 @@ bool motionUp(int x, int y, int slop) } DBG_NAV_LOGD("CachedNode:%p (%d) x=%d y=%d rx=%d ry=%d", result, result->index(), x, y, rx, ry); - // No need to call unadjustBounds below. rx and ry are already adjusted to - // the absolute position of the node. WebCore::IntRect navBounds = WebCore::IntRect(rx, ry, 1, 1); history->setNavBounds(navBounds); history->setMouseBounds(navBounds); @@ -2240,7 +2238,7 @@ static bool nativeMoveCursorToNextTextInput(JNIEnv *env, jobject obj) if (!next) return false; const WebCore::IntRect& bounds = next->bounds(frame); - root->rootHistory()->setMouseBounds(frame->unadjustBounds(next, bounds)); + root->rootHistory()->setMouseBounds(bounds); view->getWebViewCore()->updateCursorBounds(root, frame, next); view->showCursorUntimed(); root->setCursor(const_cast<CachedFrame*>(frame), |