diff options
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 35 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 1 | ||||
-rw-r--r-- | WebKit/android/nav/WebView.cpp | 2 |
3 files changed, 30 insertions, 8 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 4122574..685b41f 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -486,15 +486,34 @@ void WebViewCore::recordPictureSet(PictureSet* content) latestVersion += frame->document()->domTreeVersion(); } } - if (m_lastFocused != oldFocusNode || m_lastFocusedBounds != oldBounds || m_findIsUp - || (m_check_domtree_version && latestVersion != m_domtree_version)) { - m_lastFocused = oldFocusNode; - m_lastFocusedBounds = oldBounds; - DBG_NAV_LOGD("call updateFrameCache m_domtree_version=%d latest=%d", - m_domtree_version, latestVersion); - m_domtree_version = latestVersion; - updateFrameCache(); + bool update = m_lastFocused != oldFocusNode + || m_lastFocusedBounds != oldBounds || m_findIsUp + || (m_check_domtree_version && latestVersion != m_domtree_version); + if (!update && m_hasCursorBounds) { // avoid mutex when possible + bool hasCursorBounds; + void* cursorNode; + gCursorBoundsMutex.lock(); + hasCursorBounds = m_hasCursorBounds; + cursorNode = m_cursorNode; + IntRect bounds = m_cursorBounds; + gCursorBoundsMutex.unlock(); + if (hasCursorBounds && cursorNode) { + IntPoint center = IntPoint(bounds.x() + (bounds.width() >> 1), + bounds.y() + (bounds.height() >> 1)); + HitTestResult hitTestResult = m_mainFrame->eventHandler()-> + hitTestResultAtPoint(center, false); + if (m_cursorNode == hitTestResult.innerNode()) + return; // don't update + DBG_NAV_LOGD("at (%d,%d) old=%p new=%p", center.x(), center.y(), + m_cursorNode, hitTestResult.innerNode()); + } } + m_lastFocused = oldFocusNode; + m_lastFocusedBounds = oldBounds; + DBG_NAV_LOGD("call updateFrameCache m_domtree_version=%d latest=%d", + m_domtree_version, latestVersion); + m_domtree_version = latestVersion; + updateFrameCache(); } void WebViewCore::updateButtonList(WTF::Vector<Container>* buttons) diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index e51afd4..7231941 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -331,6 +331,7 @@ namespace android { bool m_findIsUp; bool m_hasCursorBounds; WebCore::IntRect m_cursorBounds; + void* m_cursorNode; static Mutex gCursorBoundsMutex; // These two fields go together: we use the mutex to protect access to // m_buttons, so that we, and webview.cpp can look/modify the m_buttons diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index 651951e..22b07bc 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -453,6 +453,7 @@ void drawCursorRing(SkCanvas* canvas) DBG_NAV_LOGD("new cursor bounds=(%d,%d,w=%d,h=%d)", bounds.x(), bounds.y(), bounds.width(), bounds.height()); m_viewImpl->m_cursorBounds = bounds; + m_viewImpl->m_cursorNode = node->nodePointer(); m_viewImpl->gCursorBoundsMutex.unlock(); bounds.inflate(SkScalarCeil(CURSOR_RING_OUTER_DIAMETER)); if (canvas->quickReject(bounds, SkCanvas::kAA_EdgeType)) { @@ -681,6 +682,7 @@ bool moveCursor(int keyCode, int count, bool ignoreScroll) m_viewImpl->gCursorBoundsMutex.lock(); m_viewImpl->m_hasCursorBounds = true; m_viewImpl->m_cursorBounds = cachedNode->bounds(); + m_viewImpl->m_cursorNode = cachedNode->nodePointer(); m_viewImpl->gCursorBoundsMutex.unlock(); } DBG_NAV_LOGD("new cursor %d (nativeNode=%p) cursorLocation={%d, %d}" |