|
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 { |
@@ -1512,13 +1524,12 @@ public void handleMessage(Message msg) { |
1512 | 1524 | break; |
1513 | 1525 |
|
1514 | 1526 | case REQUEST_CURSOR_HREF: { |
| 1527 | + WebKitHitTest hit = performHitTest(msg.arg1, msg.arg2, 1, false); |
1515 | 1528 | Message hrefMsg = (Message) msg.obj; |
1516 | | - hrefMsg.getData().putString("url", |
1517 | | - nativeRetrieveHref(mNativeClass, msg.arg1, msg.arg2)); |
1518 | | - hrefMsg.getData().putString("title", |
1519 | | - nativeRetrieveAnchorText(mNativeClass, msg.arg1, msg.arg2)); |
1520 | | - hrefMsg.getData().putString("src", |
1521 | | - nativeRetrieveImageSource(mNativeClass, msg.arg1, msg.arg2)); |
| 1529 | + Bundle data = hrefMsg.getData(); |
| 1530 | + data.putString(FocusNodeHref.URL,hit.mLinkUrl); |
| 1531 | + data.putString(FocusNodeHref.TITLE, hit.mAnchorText); |
| 1532 | + data.putString(FocusNodeHref.SRC, hit.mImageUrl); |
1522 | 1533 | hrefMsg.sendToTarget(); |
1523 | 1534 | break; |
1524 | 1535 | } |
@@ -1683,8 +1694,7 @@ public void handleMessage(Message msg) { |
1683 | 1694 | nativeScrollLayer(mNativeClass, |
1684 | 1695 | d.mNativeLayer, d.mNativeLayerRect); |
1685 | 1696 | } |
1686 | | - WebKitHitTest hit = nativeHitTest(mNativeClass, |
1687 | | - d.mX, d.mY, d.mSlop); |
| 1697 | + WebKitHitTest hit = performHitTest(d.mX, d.mY, d.mSlop, true); |
1688 | 1698 | mWebView.mPrivateHandler.obtainMessage( |
1689 | 1699 | WebView.HIT_TEST_RESULT, hit) |
1690 | 1700 | .sendToTarget(); |
@@ -1883,6 +1893,15 @@ void destroy() { |
1883 | 1893 | // WebViewCore private methods |
1884 | 1894 | //------------------------------------------------------------------------- |
1885 | 1895 |
|
| 1896 | + private WebKitHitTest performHitTest(int x, int y, int slop, boolean moveMouse) { |
| 1897 | + WebKitHitTest hit = nativeHitTest(mNativeClass, x, y, slop, moveMouse); |
| 1898 | + hit.mHitTestX = x; |
| 1899 | + hit.mHitTestY = y; |
| 1900 | + hit.mHitTestSlop = slop; |
| 1901 | + hit.mHitTestMovedMouse = moveMouse; |
| 1902 | + return hit; |
| 1903 | + } |
| 1904 | + |
1886 | 1905 | private void clearCache(boolean includeDiskFiles) { |
1887 | 1906 | mBrowserFrame.clearCache(); |
1888 | 1907 | if (includeDiskFiles) { |
@@ -2933,7 +2952,8 @@ protected DeviceOrientationService getDeviceOrientationService() { |
2933 | 2952 | private native boolean nativeValidNodeAndBounds(int nativeClass, int frame, |
2934 | 2953 | int node, Rect bounds); |
2935 | 2954 |
|
2936 | | - private native WebKitHitTest nativeHitTest(int nativeClass, int x, int y, int slop); |
| 2955 | + private native WebKitHitTest nativeHitTest(int nativeClass, int x, int y, |
| 2956 | + int slop, boolean moveMouse); |
2937 | 2957 |
|
2938 | 2958 | private native void nativeAutoFillForm(int nativeClass, int queryId); |
2939 | 2959 | private native void nativeScrollLayer(int nativeClass, int layer, Rect rect); |
|
0 commit comments