|
26 | 26 | import android.media.MediaFile; |
27 | 27 | import android.net.ProxyProperties; |
28 | 28 | import android.net.Uri; |
| 29 | +import android.os.Bundle; |
29 | 30 | import android.os.Handler; |
30 | 31 | import android.os.Looper; |
31 | 32 | import android.os.Message; |
|
37 | 38 | import android.view.MotionEvent; |
38 | 39 | import android.view.SurfaceView; |
39 | 40 | import android.view.View; |
| 41 | +import android.webkit.WebView.FocusNodeHref; |
40 | 42 |
|
41 | 43 | import junit.framework.Assert; |
42 | 44 |
|
@@ -861,9 +863,19 @@ static class TouchHighlightData { |
861 | 863 | } |
862 | 864 |
|
863 | 865 | static class WebKitHitTest { |
864 | | - int mType; |
865 | | - String mExtra; |
| 866 | + String mLinkUrl; |
| 867 | + String mAnchorText; |
| 868 | + String mImageUrl; |
| 869 | + String mAltDisplayString; |
| 870 | + String mTitle; |
866 | 871 | Rect[] mTouchRects; |
| 872 | + boolean mEditable; |
| 873 | + |
| 874 | + // These are the input values that produced this hit test |
| 875 | + int mHitTestX; |
| 876 | + int mHitTestY; |
| 877 | + int mHitTestSlop; |
| 878 | + boolean mHitTestMovedMouse; |
867 | 879 | } |
868 | 880 |
|
869 | 881 | static class AutoFillData { |
@@ -1514,13 +1526,12 @@ public void handleMessage(Message msg) { |
1514 | 1526 | break; |
1515 | 1527 |
|
1516 | 1528 | case REQUEST_CURSOR_HREF: { |
| 1529 | + WebKitHitTest hit = performHitTest(msg.arg1, msg.arg2, 1, false); |
1517 | 1530 | Message hrefMsg = (Message) msg.obj; |
1518 | | - hrefMsg.getData().putString("url", |
1519 | | - nativeRetrieveHref(mNativeClass, msg.arg1, msg.arg2)); |
1520 | | - hrefMsg.getData().putString("title", |
1521 | | - nativeRetrieveAnchorText(mNativeClass, msg.arg1, msg.arg2)); |
1522 | | - hrefMsg.getData().putString("src", |
1523 | | - nativeRetrieveImageSource(mNativeClass, msg.arg1, msg.arg2)); |
| 1531 | + Bundle data = hrefMsg.getData(); |
| 1532 | + data.putString(FocusNodeHref.URL,hit.mLinkUrl); |
| 1533 | + data.putString(FocusNodeHref.TITLE, hit.mAnchorText); |
| 1534 | + data.putString(FocusNodeHref.SRC, hit.mImageUrl); |
1524 | 1535 | hrefMsg.sendToTarget(); |
1525 | 1536 | break; |
1526 | 1537 | } |
@@ -1685,8 +1696,7 @@ public void handleMessage(Message msg) { |
1685 | 1696 | nativeScrollLayer(mNativeClass, |
1686 | 1697 | d.mNativeLayer, d.mNativeLayerRect); |
1687 | 1698 | } |
1688 | | - WebKitHitTest hit = nativeHitTest(mNativeClass, |
1689 | | - d.mX, d.mY, d.mSlop); |
| 1699 | + WebKitHitTest hit = performHitTest(d.mX, d.mY, d.mSlop, true); |
1690 | 1700 | mWebView.mPrivateHandler.obtainMessage( |
1691 | 1701 | WebView.HIT_TEST_RESULT, hit) |
1692 | 1702 | .sendToTarget(); |
@@ -1890,6 +1900,15 @@ void destroy() { |
1890 | 1900 | // WebViewCore private methods |
1891 | 1901 | //------------------------------------------------------------------------- |
1892 | 1902 |
|
| 1903 | + private WebKitHitTest performHitTest(int x, int y, int slop, boolean moveMouse) { |
| 1904 | + WebKitHitTest hit = nativeHitTest(mNativeClass, x, y, slop, moveMouse); |
| 1905 | + hit.mHitTestX = x; |
| 1906 | + hit.mHitTestY = y; |
| 1907 | + hit.mHitTestSlop = slop; |
| 1908 | + hit.mHitTestMovedMouse = moveMouse; |
| 1909 | + return hit; |
| 1910 | + } |
| 1911 | + |
1893 | 1912 | private void clearCache(boolean includeDiskFiles) { |
1894 | 1913 | mBrowserFrame.clearCache(); |
1895 | 1914 | if (includeDiskFiles) { |
@@ -2940,7 +2959,8 @@ protected DeviceOrientationService getDeviceOrientationService() { |
2940 | 2959 | private native boolean nativeValidNodeAndBounds(int nativeClass, int frame, |
2941 | 2960 | int node, Rect bounds); |
2942 | 2961 |
|
2943 | | - private native WebKitHitTest nativeHitTest(int nativeClass, int x, int y, int slop); |
| 2962 | + private native WebKitHitTest nativeHitTest(int nativeClass, int x, int y, |
| 2963 | + int slop, boolean moveMouse); |
2944 | 2964 |
|
2945 | 2965 | private native void nativeAutoFillForm(int nativeClass, int queryId); |
2946 | 2966 | private native void nativeScrollLayer(int nativeClass, int layer, Rect rect); |
|
0 commit comments