diff options
Diffstat (limited to 'WebKit')
| -rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 33 | ||||
| -rw-r--r-- | WebKit/android/nav/CacheBuilder.cpp | 3 | ||||
| -rw-r--r-- | WebKit/android/nav/CachedFrame.cpp | 32 | ||||
| -rw-r--r-- | WebKit/android/nav/CachedFrame.h | 11 | ||||
| -rw-r--r-- | WebKit/android/nav/CachedHistory.cpp | 34 | ||||
| -rw-r--r-- | WebKit/android/nav/CachedHistory.h | 2 | ||||
| -rw-r--r-- | WebKit/android/nav/CachedNode.cpp | 14 | ||||
| -rw-r--r-- | WebKit/android/nav/CachedNode.h | 8 | ||||
| -rw-r--r-- | WebKit/android/nav/CachedRoot.cpp | 60 | ||||
| -rw-r--r-- | WebKit/android/nav/CachedRoot.h | 11 | ||||
| -rw-r--r-- | WebKit/android/nav/WebView.cpp | 45 |
11 files changed, 148 insertions, 105 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 8439295..4122574 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -1021,13 +1021,38 @@ bool WebViewCore::prepareFrameCache() return true; int x, y; const CachedFrame* frame; - const CachedNode* node = m_temp->findAt(bounds, &frame, &x, &y); + const CachedNode* node = m_temp->findAt(bounds, &frame, &x, &y, false); + if (!node) + return true; + // require that node have approximately the same bounds (+/- 4) and the same + // center (+/- 2) + IntPoint oldCenter = IntPoint(bounds.x() + (bounds.width() >> 1), + bounds.y() + (bounds.height() >> 1)); + IntRect newBounds = node->bounds(); + IntPoint newCenter = IntPoint(newBounds.x() + (newBounds.width() >> 1), + newBounds.y() + (newBounds.height() >> 1)); + DBG_NAV_LOGD("oldCenter=(%d,%d) newCenter=(%d,%d)" + " bounds=(%d,%d,w=%d,h=%d) newBounds=(%d,%d,w=%d,h=%d)", + oldCenter.x(), oldCenter.y(), newCenter.x(), newCenter.y(), + bounds.x(), bounds.y(), bounds.width(), bounds.height(), + newBounds.x(), newBounds.y(), newBounds.width(), newBounds.height()); + if (abs(oldCenter.x() - newCenter.x()) > 2) + return true; + if (abs(oldCenter.y() - newCenter.y()) > 2) + return true; + if (abs(bounds.x() - newBounds.x()) > 4) + return true; + if (abs(bounds.y() - newBounds.y()) > 4) + return true; + if (abs(bounds.right() - newBounds.right()) > 4) + return true; + if (abs(bounds.bottom() - newBounds.bottom()) > 4) + return true; DBG_NAV_LOGD("node=%p frame=%p x=%d y=%d bounds=(%d,%d,w=%d,h=%d)", node, frame, x, y, bounds.x(), bounds.y(), bounds.width(), bounds.height()); - if (node) - m_temp->setCursor(const_cast<CachedFrame*>(frame), - const_cast<CachedNode*>(node)); + m_temp->setCursor(const_cast<CachedFrame*>(frame), + const_cast<CachedNode*>(node)); return true; } diff --git a/WebKit/android/nav/CacheBuilder.cpp b/WebKit/android/nav/CacheBuilder.cpp index d9b3125..d8d8076 100644 --- a/WebKit/android/nav/CacheBuilder.cpp +++ b/WebKit/android/nav/CacheBuilder.cpp @@ -988,7 +988,6 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, bool hasMouseOver = false; bool isAnchor = false; bool isArea = node->hasTagName(HTMLNames::areaTag); - bool isInput = false; bool isPassword = false; bool isTextArea = false; bool isTextField = false; @@ -1099,7 +1098,6 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, HTMLInputElement* input = (HTMLInputElement*) node; if (input->inputType() == HTMLInputElement::FILE) continue; - isInput = true; isTextField = input->isTextField(); if (isTextField) wantsKeyEvents = true; @@ -1197,7 +1195,6 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, cachedNode.setIsAnchor(isAnchor); cachedNode.setIsArea(isArea); cachedNode.setIsFocus(isFocus); - cachedNode.setIsInput(isInput); cachedNode.setIsPassword(isPassword); cachedNode.setIsRtlText(isRtlText); cachedNode.setIsTextArea(isTextArea); diff --git a/WebKit/android/nav/CachedFrame.cpp b/WebKit/android/nav/CachedFrame.cpp index ffd0f1b..4bf9805 100644 --- a/WebKit/android/nav/CachedFrame.cpp +++ b/WebKit/android/nav/CachedFrame.cpp @@ -112,11 +112,12 @@ bool CachedFrame::checkVisited(const CachedNode* node, Direction direction) cons void CachedFrame::clearCursor() { - if (mCursorIndex < 0) + DBG_NAV_LOGD("mCursorIndex=%d", mCursorIndex); + if (mCursorIndex < CURSOR_SET) return; CachedNode& cursor = mCachedNodes[mCursorIndex]; cursor.clearCursor(this); - mCursorIndex = -1; + mCursorIndex = CURSOR_CLEARED; // initialized and explicitly cleared } // returns 0 if test is preferable to best, 1 if not preferable, or -1 if unknown @@ -290,7 +291,7 @@ const CachedNode* CachedFrame::currentCursor(const CachedFrame** framePtr) const { if (framePtr) *framePtr = this; - if (mCursorIndex < 0) + if (mCursorIndex < CURSOR_SET) return NULL; const CachedNode* result = &mCachedNodes[mCursorIndex]; const CachedFrame* frame = hasFrame(result); @@ -334,8 +335,10 @@ CachedNode* CachedFrame::find(WebCore::Node* node) // !!! probably debugging onl } #endif -const CachedNode* CachedFrame::findBestAt(const WebCore::IntRect& rect, int* best, - bool* inside, const CachedNode** directHit, const CachedFrame** framePtr, int* x, int* y) const +const CachedNode* CachedFrame::findBestAt(const WebCore::IntRect& rect, + int* best, bool* inside, const CachedNode** directHit, + const CachedFrame** framePtr, int* x, int* y, + bool checkForHiddenStart) const { const CachedNode* result = NULL; int rectWidth = rect.width(); @@ -349,7 +352,7 @@ const CachedNode* CachedFrame::findBestAt(const WebCore::IntRect& rect, int* bes BestData testData; testData.mNode = test; testData.mMouseBounds = testData.mNodeBounds = test->getBounds(); - bool checkForHidden = true; + bool checkForHidden = checkForHiddenStart; for (size_t part = 0; part < parts; part++) { if (test->cursorRings().at(part).intersects(rect)) { if (checkForHidden && mRoot->maskIfHidden(&testData) == true) @@ -412,8 +415,8 @@ const CachedNode* CachedFrame::findBestAt(const WebCore::IntRect& rect, int* bes } for (const CachedFrame* frame = mCachedFrames.begin(); frame != mCachedFrames.end(); frame++) { - const CachedNode* frameResult = frame->findBestAt(rect, best, inside, directHit, - framePtr, x, y); + const CachedNode* frameResult = frame->findBestAt(rect, best, inside, + directHit, framePtr, x, y, checkForHiddenStart); if (NULL != frameResult) result = frameResult; } @@ -747,7 +750,7 @@ int CachedFrame::frameNodeCommon(BestData& testData, const CachedNode* test, Bes int CachedFrame::framePartCommon(BestData& testData, const CachedNode* test, BestData* bestData, const CachedNode* cursor) const { - if (testData.mNodeBounds.contains(mRoot->cursorBounds())) { + if (cursor && testData.mNodeBounds.contains(cursor->bounds())) { testData.mNode->setCondition(CachedNode::NOT_ENCLOSING_CURSOR); return REJECT_TEST; } @@ -840,6 +843,15 @@ const CachedFrame* CachedFrame::hasFrame(const CachedNode* node) const return node->isFrame() ? &mCachedFrames[node->childFrameIndex()] : NULL; } +void CachedFrame::hideCursor() +{ + DBG_NAV_LOGD("mCursorIndex=%d", mCursorIndex); + if (mCursorIndex < CURSOR_SET) + return; + CachedNode& cursor = mCachedNodes[mCursorIndex]; + cursor.hideCursor(this); +} + CachedHistory* CachedFrame::history() const { return mRoot->rootHistory(); @@ -852,7 +864,7 @@ void CachedFrame::init(const CachedRoot* root, int childFrameIndex, mLocalViewBounds = WebCore::IntRect(0, 0, 0, 0); mViewBounds = WebCore::IntRect(0, 0, 0, 0); mRoot = root; - mCursorIndex = -1; + mCursorIndex = CURSOR_UNINITIALIZED; // not explicitly cleared mFocusIndex = -1; mFrame = frame; mParent = NULL; // set up parents after stretchy arrays are set up diff --git a/WebKit/android/nav/CachedFrame.h b/WebKit/android/nav/CachedFrame.h index 30d9f88..0df5489 100644 --- a/WebKit/android/nav/CachedFrame.h +++ b/WebKit/android/nav/CachedFrame.h @@ -60,6 +60,11 @@ public: TEST_IS_BEST, REJECT_TEST }; + enum CursorInit { + CURSOR_UNINITIALIZED = -2, + CURSOR_CLEARED = -1, + CURSOR_SET = 0 + }; CachedFrame() {} void add(CachedNode& node) { mCachedNodes.append(node); } void addFrame(CachedFrame& child) { mCachedFrames.append(child); } @@ -73,8 +78,9 @@ public: bool directionChange() const; const CachedNode* document() const { return mCachedNodes.begin(); } bool empty() const { return mCachedNodes.size() < 2; } // must have 1 past doc - const CachedNode* findBestAt(const WebCore::IntRect& , int* best, bool* inside, - const CachedNode** , const CachedFrame** , int* x, int* y) const; + const CachedNode* findBestAt(const WebCore::IntRect& , int* best, + bool* inside, const CachedNode** , const CachedFrame** , int* x, + int* y, bool checkForHidden) const; const CachedFrame* findBestFrameAt(int x, int y) const; const CachedNode* findBestHitAt(const WebCore::IntRect& , int* best, const CachedFrame** , int* x, int* y) const; @@ -85,6 +91,7 @@ public: CachedNode* getIndex(int index) { return index >= 0 ? &mCachedNodes[index] : NULL; } const CachedFrame* hasFrame(const CachedNode* node) const; + void hideCursor(); int indexInParent() const { return mIndexInParent; } void init(const CachedRoot* root, int index, WebCore::Frame* frame); const CachedFrame* lastChild() const { return &mCachedFrames.last(); } diff --git a/WebKit/android/nav/CachedHistory.cpp b/WebKit/android/nav/CachedHistory.cpp index f75f237..7aca1ad 100644 --- a/WebKit/android/nav/CachedHistory.cpp +++ b/WebKit/android/nav/CachedHistory.cpp @@ -84,8 +84,6 @@ void CachedHistory::reset() // mLastScroll = 0; mPriorBounds = WebCore::IntRect(0, 0, 0, 0); mDirectionChange = false; - mFocusIsInput = false; - mPriorIsInput = false; mDidFirstLayout = false; mPriorMove = mLastMove = CachedFrame::UNINITIALIZED; mMinWorkingHorizontal = mMinWorkingVertical = INT_MIN; @@ -93,24 +91,22 @@ void CachedHistory::reset() } void CachedHistory::setWorking(CachedFrame::Direction newMove, - const CachedNode* focus, const WebCore::IntRect& viewBounds) + const CachedNode* cursor, const WebCore::IntRect& viewBounds) { CachedFrame::Direction lastAxis = (CachedFrame::Direction) (mLastMove & ~CachedFrame::RIGHT_DOWN); // up, left or uninitialized CachedFrame::Direction newAxis = (CachedFrame::Direction) (newMove & ~CachedFrame::RIGHT_DOWN); bool change = newAxis != lastAxis; mDirectionChange = change && mLastMove != CachedFrame::UNINITIALIZED; - if (focus != NULL || mLastMove != CachedFrame::UNINITIALIZED) { + if (cursor != NULL || mLastMove != CachedFrame::UNINITIALIZED) { mPriorMove = mLastMove; mLastMove = newMove; } const WebCore::IntRect* navBounds = &mNavBounds; - if (focus != NULL) { - WebCore::IntRect focusBounds; - focus->getBounds(&focusBounds); - if (focusBounds.isEmpty() == false) - mNavBounds = focusBounds; - mPriorIsInput = mFocusIsInput; - mFocusIsInput = focus->isInput(); // focus->localName() == "input"; + if (cursor != NULL) { + WebCore::IntRect cursorBounds; + cursor->getBounds(&cursorBounds); + if (cursorBounds.isEmpty() == false) + mNavBounds = cursorBounds; } if (change) { // uninitialized or change in direction if (lastAxis != CachedFrame::LEFT && navBounds->height() > 0) { @@ -121,18 +117,6 @@ void CachedHistory::setWorking(CachedFrame::Direction newMove, mMinWorkingVertical = navBounds->x(); mMaxWorkingVertical = navBounds->right(); } - } else if (mPriorIsInput) { - if (newAxis == CachedFrame::UP_DOWN) { - if (mPriorBounds.x() == mMinWorkingVertical && mPriorBounds.right() == mMaxWorkingVertical) { - mMinWorkingVertical = navBounds->x(); - mMaxWorkingVertical = navBounds->right(); - } - } else { - if (mPriorBounds.y() == mMinWorkingHorizontal && mPriorBounds.bottom() == mMaxWorkingHorizontal) { - mMinWorkingHorizontal = navBounds->y(); - mMaxWorkingHorizontal = navBounds->bottom(); - } - } } pinMaxMin(viewBounds); } @@ -176,11 +160,11 @@ void CachedHistory::Debug::print(CachedRoot* root) const } DUMP_NAV_LOGD("// };\n"); // DUMP_NAV_LOGD("// int mLastScroll=%d;\n", b->mLastScroll); + DEBUG_PRINT_RECT(mMouseBounds); DEBUG_PRINT_RECT(mNavBounds); DEBUG_PRINT_RECT(mPriorBounds); DEBUG_PRINT_BOOL(mDirectionChange); - DEBUG_PRINT_BOOL(mFocusIsInput); - DEBUG_PRINT_BOOL(mPriorIsInput); + DEBUG_PRINT_BOOL(mDidFirstLayout); DUMP_NAV_LOGD("// CachedFrame::Direction mLastMove=%s, mPriorMove=%s;\n", direction(b->mLastMove), direction(b->mPriorMove)); int max = b->mMaxWorkingHorizontal; diff --git a/WebKit/android/nav/CachedHistory.h b/WebKit/android/nav/CachedHistory.h index e48d44b..c60f416 100644 --- a/WebKit/android/nav/CachedHistory.h +++ b/WebKit/android/nav/CachedHistory.h @@ -64,8 +64,6 @@ private: WebCore::IntRect mNavBounds; // focus ring bounds plus optional keystroke movement WebCore::IntRect mPriorBounds; // prior chosen focus ring (for reversing narrowing) bool mDirectionChange; - bool mFocusIsInput; // defer max/min to non-focus node if focus is too broad - bool mPriorIsInput; // defer max/min to non-focus node if focus is too broad bool mDidFirstLayout; // set true when page is newly laid out CachedFrame::Direction mLastMove; CachedFrame::Direction mPriorMove; diff --git a/WebKit/android/nav/CachedNode.cpp b/WebKit/android/nav/CachedNode.cpp index 4408cb6..e7cab9e 100644 --- a/WebKit/android/nav/CachedNode.cpp +++ b/WebKit/android/nav/CachedNode.cpp @@ -205,6 +205,15 @@ void CachedNode::cursorRingBounds(WebCore::IntRect* bounds) const bounds->inflate(CURSOR_RING_HIT_TEST_RADIUS); } +void CachedNode::hideCursor(CachedFrame* parent) +{ + if (isFrame()) { + CachedFrame* child = const_cast<CachedFrame*>(parent->hasFrame(this)); + child->hideCursor(); + } + mIsHidden = false; +} + void CachedNode::init(WebCore::Node* node) { bzero(this, sizeof(CachedNode)); @@ -343,7 +352,8 @@ void CachedNode::Debug::print() const DEBUG_PRINT_BOOL(mIsAnchor); DEBUG_PRINT_BOOL(mIsArea); DEBUG_PRINT_BOOL(mIsCursor); - DEBUG_PRINT_BOOL(mIsInput); + DEBUG_PRINT_BOOL(mIsFocus); + DEBUG_PRINT_BOOL(mIsHidden); DEBUG_PRINT_BOOL(mIsParentAnchor); DEBUG_PRINT_BOOL(mIsPassword); DEBUG_PRINT_BOOL(mIsRtlText); @@ -352,6 +362,8 @@ void CachedNode::Debug::print() const DEBUG_PRINT_BOOL(mIsTransparent); DEBUG_PRINT_BOOL(mIsUnclipped); DEBUG_PRINT_BOOL(mLast); + DEBUG_PRINT_BOOL(mUseBounds); + DEBUG_PRINT_BOOL(mUseHitBounds); DEBUG_PRINT_BOOL(mWantsKeyEvents); DUMP_NAV_LOGD("\n"); } diff --git a/WebKit/android/nav/CachedNode.h b/WebKit/android/nav/CachedNode.h index 6ae1ba8..9361309 100644 --- a/WebKit/android/nav/CachedNode.h +++ b/WebKit/android/nav/CachedNode.h @@ -102,8 +102,9 @@ public: const WebCore::IntRect& getBounds() const { return mBounds; } void getBounds(WebCore::IntRect* bounds) const { *bounds = mBounds; } const WebCore::String& getExport() const { return mExport; } - bool hasCursorRing() const { return mHasCursorRing; } + bool hasCursorRing() const { return !mIsHidden && mHasCursorRing; } bool hasMouseOver() const { return mHasMouseOver; } + void hideCursor(CachedFrame* ); const WebCore::IntRect& hitBounds() const { return mHitBounds; } int index() const { return mIndex; } void init(WebCore::Node* node); @@ -112,7 +113,6 @@ public: bool isArea() const { return mIsArea; } bool isFocus() const { return mIsFocus; } bool isFrame() const { return mChildFrameIndex >= 0 ; } - bool isInput() const { return mIsInput; } bool isNavable(const WebCore::IntRect& clip) const { return clip.intersects(mBounds); } @@ -147,7 +147,6 @@ public: void setIsArea(bool isArea) { mIsArea = isArea; } void setIsCursor(bool isCursor) { mIsCursor = isCursor; } void setIsFocus(bool isFocus) { mIsFocus = isFocus; } - void setIsInput(bool isInput) { mIsInput = isInput; } void setIsParentAnchor(bool isAnchor) { mIsParentAnchor = isAnchor; } void setIsPassword(bool isPassword) { mIsPassword = isPassword; } void setIsRtlText(bool isRtlText) { mIsRtlText = isRtlText; } @@ -165,6 +164,7 @@ public: void setTextSize(int textSize) { mTextSize = textSize; } void setType(CachedNodeType type) { mType = type; } void setWantsKeyEvents(bool wantsKeys) { mWantsKeyEvents = wantsKeys; } + void show() { mIsHidden = false; } int tabIndex() const { return mTabIndex; } const CachedNode* traverseNextNode() const { return mLast ? NULL : &this[1]; } int textSize() const { return mTextSize; } @@ -198,7 +198,7 @@ private: bool mIsArea : 1; bool mIsCursor : 1; bool mIsFocus : 1; - bool mIsInput : 1; + bool mIsHidden : 1; bool mIsParentAnchor : 1; bool mIsPassword : 1; bool mIsRtlText : 1; diff --git a/WebKit/android/nav/CachedRoot.cpp b/WebKit/android/nav/CachedRoot.cpp index 98750b8..7de2bfa 100644 --- a/WebKit/android/nav/CachedRoot.cpp +++ b/WebKit/android/nav/CachedRoot.cpp @@ -643,13 +643,14 @@ bool CachedRoot::checkRings(const WTF::Vector<WebCore::IntRect>& rings, } const CachedNode* CachedRoot::findAt(const WebCore::IntRect& rect, - const CachedFrame** framePtr, int* x, int* y) const + const CachedFrame** framePtr, int* x, int* y, bool checkForHidden) const { int best = INT_MAX; bool inside = false; (const_cast<CachedRoot*>(this))->resetClippedOut(); const CachedNode* directHit = NULL; - const CachedNode* node = findBestAt(rect, &best, &inside, &directHit, framePtr, x, y); + const CachedNode* node = findBestAt(rect, &best, &inside, &directHit, + framePtr, x, y, checkForHidden); DBG_NAV_LOGD("node=%d (%p)", node == NULL ? 0 : node->index(), node == NULL ? NULL : node->nodePointer()); if (node == NULL) { @@ -728,11 +729,12 @@ bool CachedRoot::innerDown(const CachedNode* test, BestData* bestData) const mScrolledBounds.setHeight(mScrolledBounds.height() + mMaxYScroll); int testTop = mScrolledBounds.y(); int viewBottom = mViewBounds.bottom(); - if (mCursorBounds.isEmpty() == false && - mCursorBounds.bottom() > viewBottom && viewBottom < mContents.height()) + const WebCore::IntRect& navBounds = mHistory->mNavBounds; + if (navBounds.isEmpty() == false && + navBounds.bottom() > viewBottom && viewBottom < mContents.height()) return false; - if (mHistory->mNavBounds.isEmpty() == false) { - int navTop = mHistory->mNavBounds.y(); + if (navBounds.isEmpty() == false) { + int navTop = navBounds.y(); int scrollBottom; if (testTop < navTop && navTop < (scrollBottom = mScrolledBounds.bottom())) { mScrolledBounds.setHeight(scrollBottom - navTop); @@ -752,11 +754,12 @@ bool CachedRoot::innerLeft(const CachedNode* test, BestData* bestData) const mScrolledBounds.setWidth(mScrolledBounds.width() + mMaxXScroll); int testRight = mScrolledBounds.right(); int viewLeft = mViewBounds.x(); - if (mCursorBounds.isEmpty() == false && - mCursorBounds.x() < viewLeft && viewLeft > mContents.x()) + const WebCore::IntRect& navBounds = mHistory->mNavBounds; + if (navBounds.isEmpty() == false && + navBounds.x() < viewLeft && viewLeft > mContents.x()) return false; - if (mHistory->mNavBounds.isEmpty() == false) { - int navRight = mHistory->mNavBounds.right(); + if (navBounds.isEmpty() == false) { + int navRight = navBounds.right(); int scrollLeft; if (testRight > navRight && navRight > (scrollLeft = mScrolledBounds.x())) mScrolledBounds.setWidth(navRight - scrollLeft); @@ -770,20 +773,17 @@ void CachedRoot::innerMove(const CachedNode* node, BestData* bestData, Direction direction, WebCore::IntPoint* scroll, bool firstCall) { bestData->reset(); - mCursorChild = false; - bool outOfCursor = mCursorIndex < 0; - bool firstTime = mHistory->didFirstLayout() && outOfCursor; + bool outOfCursor = mCursorIndex == CURSOR_CLEARED; #if DEBUG_NAV_UI && !defined BROWSER_DEBUG LOGD("%s mHistory->didFirstLayout()=%s && mCursorIndex=%d\n", __FUNCTION__, mHistory->didFirstLayout() ? "true" : "false", mCursorIndex); #endif - if (firstTime) + if (mHistory->didFirstLayout() && mCursorIndex < CURSOR_SET) { mHistory->reset(); + outOfCursor = true; + } const CachedNode* cursor = currentCursor(); mHistory->setWorking(direction, cursor, mViewBounds); - mCursorBounds = WebCore::IntRect(0, 0, 0, 0); - if (cursor != NULL) - cursor->getBounds(&mCursorBounds); bool findClosest = false; if (mScrollOnly == false) { switch (direction) { @@ -823,7 +823,7 @@ void CachedRoot::innerMove(const CachedNode* node, BestData* bestData, return; if (bestData->mNode != NULL) { mHistory->addToVisited(bestData->mNode, direction); - mHistory->mNavBounds = mCursorBounds = bestData->mNodeBounds; + mHistory->mNavBounds = bestData->mNodeBounds; mHistory->mMouseBounds = bestData->mMouseBounds; } else if (scroll->x() != 0 || scroll->y() != 0) { WebCore::IntRect newBounds = mHistory->mNavBounds; @@ -852,11 +852,12 @@ bool CachedRoot::innerRight(const CachedNode* test, BestData* bestData) const mScrolledBounds.setWidth(mScrolledBounds.width() + mMaxXScroll); int testLeft = mScrolledBounds.x(); int viewRight = mViewBounds.right(); - if (mCursorBounds.isEmpty() == false && - mCursorBounds.right() > viewRight && viewRight < mContents.width()) + const WebCore::IntRect& navBounds = mHistory->mNavBounds; + if (navBounds.isEmpty() == false && + navBounds.right() > viewRight && viewRight < mContents.width()) return false; - if (mHistory->mNavBounds.isEmpty() == false) { - int navLeft = mHistory->mNavBounds.x(); + if (navBounds.isEmpty() == false) { + int navLeft = navBounds.x(); int scrollRight; if (testLeft < navLeft && navLeft < (scrollRight = mScrolledBounds.right())) { mScrolledBounds.setWidth(scrollRight - navLeft); @@ -876,11 +877,12 @@ bool CachedRoot::innerUp(const CachedNode* test, BestData* bestData) const mScrolledBounds.setHeight(mScrolledBounds.height() + mMaxYScroll); int testBottom = mScrolledBounds.bottom(); int viewTop = mViewBounds.y(); - if (mCursorBounds.isEmpty() == false && - mCursorBounds.y() < viewTop && viewTop > mContents.y()) + const WebCore::IntRect& navBounds = mHistory->mNavBounds; + if (navBounds.isEmpty() == false && + navBounds.y() < viewTop && viewTop > mContents.y()) return false; - if (mHistory->mNavBounds.isEmpty() == false) { - int navBottom = mHistory->mNavBounds.bottom(); + if (navBounds.isEmpty() == false) { + int navBottom = navBounds.bottom(); int scrollTop; if (testBottom > navBottom && navBottom > (scrollTop = mScrolledBounds.y())) mScrolledBounds.setHeight(navBottom - scrollTop); @@ -1034,7 +1036,6 @@ void CachedRoot::reset() mMaxXScroll = mMaxYScroll = 0; mSelectionStart = mSelectionEnd = -1; mScrollOnly = false; - mCursorBounds = WebCore::IntRect(0, 0, 0, 0); } bool CachedRoot::scrollDelta(WebCore::IntRect& newOutset, Direction direction, int* delta) @@ -1097,11 +1098,10 @@ void CachedRoot::setCursor(CachedFrame* frame, CachedNode* node) bounds.width(), bounds.height()); #endif clearCursor(); - mCursorBounds = WebCore::IntRect(0, 0, 0, 0); if (node == NULL) return; node->setIsCursor(true); - mCursorBounds = node->bounds(); + node->show(); frame->setCursorIndex(node - frame->document()); CachedFrame* parent; while ((parent = frame->parent()) != NULL) { @@ -1145,10 +1145,8 @@ void CachedRoot::Debug::print() const CachedRoot* b = base(); b->CachedFrame::mDebug.print(); b->mHistory->mDebug.print(b); - DEBUG_PRINT_RECT(mCursorBounds); DUMP_NAV_LOGD("// int mMaxXScroll=%d, mMaxYScroll=%d;\n", b->mMaxXScroll, b->mMaxYScroll); - DEBUG_PRINT_BOOL(mCursorChild); #ifdef DUMP_NAV_CACHE_USING_PRINTF if (gNavCacheLogFile) fclose(gNavCacheLogFile); diff --git a/WebKit/android/nav/CachedRoot.h b/WebKit/android/nav/CachedRoot.h index 52b6e34..1167a22 100644 --- a/WebKit/android/nav/CachedRoot.h +++ b/WebKit/android/nav/CachedRoot.h @@ -46,20 +46,17 @@ public: void checkForJiggle(int* ) const; bool checkRings(const WTF::Vector<WebCore::IntRect>& rings, const WebCore::IntRect& bounds) const; - const WebCore::IntRect& cursorBounds() const { return mCursorBounds; } WebCore::IntPoint cursorLocation() const; int documentHeight() { return mContents.height(); } int documentWidth() { return mContents.width(); } const CachedNode* findAt(const WebCore::IntRect& , const CachedFrame** , - int* x, int* y) const; + int* x, int* y, bool checkForHidden) const; const WebCore::IntRect& focusBounds() const { return mFocusBounds; } WebCore::IntPoint focusLocation() const; SkPicture* getPicture() { return mPicture; } int getAndResetSelectionEnd(); int getAndResetSelectionStart(); -// const WebCore::IntRect& navClipBounds() const { return mClippedBounds; } void getSimulatedMousePosition(WebCore::IntPoint* ); -// bool hasNavClipBounds() { return mClippedBounds.isEmpty() == false; } void init(WebCore::Frame* , CachedHistory* ); bool innerDown(const CachedNode* , BestData* ) const; bool innerLeft(const CachedNode* , BestData* ) const; @@ -71,18 +68,14 @@ public: bool maskIfHidden(BestData* ) const; const CachedNode* moveCursor(Direction , const CachedFrame** , WebCore::IntPoint* scroll); void reset(); -// void resetNavClipBounds() { mClippedBounds = WebCore::IntRect(-1, -1, 0, 0); } CachedHistory* rootHistory() const { return mHistory; } bool scrollDelta(WebCore::IntRect& cursorRingBounds, Direction , int* delta); const WebCore::IntRect& scrolledBounds() const { return mScrolledBounds; } void setCursor(CachedFrame* , CachedNode* ); void setCachedFocus(CachedFrame* , CachedNode* ); - void setCursorBounds(const WebCore::IntRect& r) { mCursorBounds = r; } void setFocusBounds(const WebCore::IntRect& r) { mFocusBounds = r; } void setTextGeneration(int textGeneration) { mTextGeneration = textGeneration; } - void setCursorChild(bool state) const { mCursorChild = state; } void setMaxScroll(int x, int y) { mMaxXScroll = x; mMaxYScroll = y; } -// void setNavClipBounds(const WebCore::IntRect& r) { mClippedBounds = r; } void setPicture(SkPicture* picture) { mPicture = picture; } void setScrollOnly(bool state) { mScrollOnly = state; } void setSelection(int start, int end) { mSelectionStart = start; mSelectionEnd = end; } @@ -93,7 +86,6 @@ public: private: CachedHistory* mHistory; SkPicture* mPicture; - WebCore::IntRect mCursorBounds; // chosen cursor ring WebCore::IntRect mFocusBounds; // dom text input focus node bounds mutable WebCore::IntRect mScrolledBounds; // view bounds + amount visible as result of scroll int mTextGeneration; @@ -102,7 +94,6 @@ private: // These two are ONLY used when the tree is rebuilt and the focus is a textfield/area int mSelectionStart; int mSelectionEnd; - mutable bool mCursorChild; // temporary state set if walked nodes are children of focus bool mScrollOnly; #if DUMP_NAV_CACHE public: diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index 6260d7e..651951e 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -181,16 +181,26 @@ WebViewCore* getWebViewCore() const { return m_viewImpl; } -void clearCursor(int x, int y, bool inval) +// removes the cursor altogether (e.g., when going to a new page) +void clearCursor() { - DBG_NAV_LOGD("x=%d y=%d inval=%s", x, y, inval ? "true" : "false"); CachedRoot* root = getFrameCache(AllowNewer); - if (!root || !root->currentCursor()) + if (!root) return; - DBG_NAV_LOG("root->setCursor(0, 0)"); - root->setCursor(0, 0); - if (inval) - viewInvalidate(); + DBG_NAV_LOG(""); + root->clearCursor(); + viewInvalidate(); +} + +// leaves the cursor where it is, but suppresses drawing it +void hideCursor() +{ + CachedRoot* root = getFrameCache(AllowNewer); + if (!root) + return; + DBG_NAV_LOG(""); + root->hideCursor(); + viewInvalidate(); } void clearTextEntry() @@ -659,7 +669,7 @@ bool moveCursor(int keyCode, int count, bool ignoreScroll) int dx = 0; int dy = 0; int counter = count; - if (!cursor || !cursor->isInput() || !m_followedLink) + if (!cursor || !m_followedLink) root->setScrollOnly(m_followedLink); while (--counter >= 0) { WebCore::IntPoint scroll = WebCore::IntPoint(0, 0); @@ -744,7 +754,7 @@ const CachedNode* findAt(CachedRoot* root, const WebCore::IntRect& rect, WebCore::IntRect visibleRect; getVisibleRect(&visibleRect); root->setVisibleRect(visibleRect); - return root->findAt(rect, framePtr, rxPtr, ryPtr); + return root->findAt(rect, framePtr, rxPtr, ryPtr, true); } void selectBestAt(const WebCore::IntRect& rect) @@ -796,7 +806,7 @@ bool motionUp(int x, int y, int slop) DBG_NAV_LOGD("no nodes found root=%p", root); setNavBounds(rect); if (root) { - root->clearCursor(); + root->hideCursor(); int dx = root->checkForCenter(x, y); if (dx) { scrollBy(dx, 0); @@ -1203,11 +1213,11 @@ static jstring WebCoreStringToJString(JNIEnv *env, WebCore::String string) return ret; } -static void nativeClearCursor(JNIEnv *env, jobject obj, int x, int y) +static void nativeClearCursor(JNIEnv *env, jobject obj) { WebView* view = GET_NATIVE_VIEW(env, obj); LOG_ASSERT(view, "view not set in %s", __FUNCTION__); - view->clearCursor(x, y, true); + view->clearCursor(); } static void nativeCreate(JNIEnv *env, jobject obj, int viewImpl) @@ -1478,6 +1488,13 @@ static bool nativeCursorWantsKeyEvents(JNIEnv* env, jobject jwebview) { return view->cursorWantsKeyEvents(); } +static void nativeHideCursor(JNIEnv *env, jobject obj) +{ + WebView* view = GET_NATIVE_VIEW(env, obj); + LOG_ASSERT(view, "view not set in %s", __FUNCTION__); + view->hideCursor(); +} + static void nativeInstrumentReport(JNIEnv *env, jobject obj) { #ifdef ANDROID_INSTRUMENT @@ -1720,7 +1737,7 @@ static void nativeDumpDisplayTree(JNIEnv* env, jobject jwebview, jstring jurl) * JNI registration */ static JNINativeMethod gJavaWebViewMethods[] = { - { "nativeClearCursor", "(II)V", + { "nativeClearCursor", "()V", (void*) nativeClearCursor }, { "nativeCreate", "(I)V", (void*) nativeCreate }, @@ -1788,6 +1805,8 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeHasCursorNode }, { "nativeHasFocusNode", "()Z", (void*) nativeHasFocusNode }, + { "nativeHideCursor", "()V", + (void*) nativeHideCursor }, { "nativeImageURI", "(II)Ljava/lang/String;", (void*) nativeImageURI }, { "nativeInstrumentReport", "()V", |
