diff options
author | John Reck <jreck@google.com> | 2012-05-17 13:06:18 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2012-05-17 13:48:40 -0700 |
commit | 580a4ea41896c60f782ce1fbaa9363320100c24b (patch) | |
tree | 35c9e014342bf811e89af13e22e9c6403814ae55 | |
parent | 020855054c167ec65720853fff4116f51d6e6f31 (diff) | |
download | external_webkit-580a4ea41896c60f782ce1fbaa9363320100c24b.zip external_webkit-580a4ea41896c60f782ce1fbaa9363320100c24b.tar.gz external_webkit-580a4ea41896c60f782ce1fbaa9363320100c24b.tar.bz2 |
Fix mouse nudging in hit test
Bug: 6490959
Change-Id: I3b9c17a69d15983093047b31d950c16894f6cd24
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.cpp | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 8870b70..73abb07 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -1930,19 +1930,26 @@ AndroidHitTestResult WebViewCore::hitTestAtPoint(int x, int y, int slop, bool do } else { androidHitResult.setURLElement(0); } - IntPoint frameAdjust; - if (frame != m_mainFrame) { - frameAdjust = frame->view()->contentsToWindow(IntPoint()); - frameAdjust.move(m_scrollOffsetX, m_scrollOffsetY); - } - IntRect rect = final.mBounds; - rect.move(frameAdjust.x(), frameAdjust.y()); - if (doMoveMouse) { - // adjust m_mousePos if it is not inside the returned highlight rectangle - testRect.move(frameAdjust.x(), frameAdjust.y()); - testRect.intersect(rect); - if (!testRect.contains(x, y)) - moveMouse(testRect.center().x(), testRect.center().y(), 0, true); + Vector<IntRect>& highlightRects = androidHitResult.highlightRects(); + if (doMoveMouse && highlightRects.size() > 0) { + // adjust m_mousePos if it is not inside the returned highlight + // rectangles + IntRect foundIntersection; + IntRect inputRect = IntRect(x - slop, y - slop, + slop * 2 + 1, slop * 2 + 1); + for (size_t i = 0; i < highlightRects.size(); i++) { + IntRect& hr = highlightRects[i]; + IntRect test = inputRect; + test.intersect(hr); + if (!test.isEmpty()) { + foundIntersection = test; + break; + } + } + if (!foundIntersection.isEmpty() && !foundIntersection.contains(x, y)) { + IntPoint pt = foundIntersection.center(); + moveMouse(pt.x(), pt.y(), 0, true); + } } } else { androidHitResult.searchContentDetectors(); |