diff options
author | Cary Clark <cary@android.com> | 2009-06-11 17:42:23 -0400 |
---|---|---|
committer | Cary Clark <cary@android.com> | 2009-06-12 10:34:20 -0400 |
commit | ea94161abd649e3277ff68a7f4ab820c0ba80086 (patch) | |
tree | a44aca3803e0121650d9aa5656d71dd39b7ee572 /WebKit | |
parent | 9086ba0632b6c0572c69584806ce4b9061e5af2d (diff) | |
download | external_webkit-ea94161abd649e3277ff68a7f4ab820c0ba80086.zip external_webkit-ea94161abd649e3277ff68a7f4ab820c0ba80086.tar.gz external_webkit-ea94161abd649e3277ff68a7f4ab820c0ba80086.tar.bz2 |
rebuild webview nav cache if cursor node changes
Everytime the picture set is rebuilt, the nav cache
is also built if the dom changes. This doesn't catch
javascript that changes locations of objects without
updating the dom. To handle these cases, do a hit-test
on the cursor location and see if it finds the same
node used to build the cursor cache.
This helps track the gmail message floating tool bar.
Diffstat (limited to 'WebKit')
-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}" |