diff options
| author | Cary Clark <cary@android.com> | 2010-12-15 11:24:37 -0500 |
|---|---|---|
| committer | Cary Clark <cary@android.com> | 2010-12-15 15:23:50 -0500 |
| commit | 861368a307cb1763b567ba90e418b1523359ee71 (patch) | |
| tree | 9b28834367467fac0b12f5f981715f1b92702063 /core/java/android | |
| parent | 9742148fb2a5a3c9d148ee2ece8d3221d3b99fef (diff) | |
extract anchor href and image src separately
Long pressing a link may return an anchor, an image, or an
image in an anchor. Sometimes we want one, sometimes the other.
Make both available so the context menu can choose.
Update the documentation in WebView.java
Companion changes are in external/webkit, packages/apps/Browser
bug:3282745
bug:3263340
Change-Id: I9917a2c69d26601a230051f2e95c9464ba6155e9
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/webkit/WebView.java | 18 | ||||
| -rw-r--r-- | core/java/android/webkit/WebViewCore.java | 3 |
2 files changed, 13 insertions, 8 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 5b43953fd357..5f47a2d6822d 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -2180,17 +2180,19 @@ public class WebView extends AbsoluteLayout } } /** - * Request the href of an anchor element due to getFocusNodePath returning - * "href." If hrefMsg is null, this method returns immediately and does not - * dispatch hrefMsg to its target. + * Request the anchor or image element URL at the last tapped point. + * If hrefMsg is null, this method returns immediately and does not + * dispatch hrefMsg to its target. If the tapped point hits an image, + * an anchor, or an image in an anchor, the message associates + * strings in named keys in its data. The value paired with the key + * may be an empty string. * * @param hrefMsg This message will be dispatched with the result of the - * request as the data member with "url" as key. The result can - * be null. + * request. The message data contains three keys: + * - "url" returns the anchor's href attribute. + * - "title" returns the anchor's text. + * - "src" returns the image's src attribute. */ - // FIXME: API change required to change the name of this function. We now - // look at the cursor node, and not the focus node. Also, what is - // getFocusNodePath? public void requestFocusNodeHref(Message hrefMsg) { if (hrefMsg == null) { return; diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index 942fe0bba254..b8c8913f2f7a 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -555,6 +555,7 @@ final class WebViewCore { private native String nativeRetrieveHref(int x, int y); private native String nativeRetrieveAnchorText(int x, int y); + private native String nativeRetrieveImageSource(int x, int y); private native void nativeTouchUp(int touchGeneration, int framePtr, int nodePtr, int x, int y); @@ -1335,6 +1336,8 @@ final class WebViewCore { nativeRetrieveHref(msg.arg1, msg.arg2)); hrefMsg.getData().putString("title", nativeRetrieveAnchorText(msg.arg1, msg.arg2)); + hrefMsg.getData().putString("src", + nativeRetrieveImageSource(msg.arg1, msg.arg2)); hrefMsg.sendToTarget(); break; } |
