| Index: content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java
|
| diff --git a/content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java b/content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java
|
| index e2eebabac8082e7b55b7c1250e9cf4cf6da5d887..bf0728f86633c9f76d740d689719c5ce7194ea9b 100644
|
| --- a/content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java
|
| +++ b/content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java
|
| @@ -20,6 +20,7 @@ import org.chromium.base.annotations.CalledByNative;
|
| import org.chromium.base.annotations.JNINamespace;
|
| import org.chromium.content.browser.AppWebMessagePort;
|
| import org.chromium.content.browser.MediaSessionImpl;
|
| +import org.chromium.content.browser.RenderCoordinates;
|
| import org.chromium.content.browser.framehost.RenderFrameHostDelegate;
|
| import org.chromium.content_public.browser.AccessibilitySnapshotCallback;
|
| import org.chromium.content_public.browser.AccessibilitySnapshotNode;
|
| @@ -106,7 +107,32 @@ import java.util.UUID;
|
| // the same life time as native MediaSession.
|
| private MediaSessionImpl mMediaSession;
|
|
|
| - private SmartClipCallback mSmartClipCallback;
|
| + class SmartClipCallbackImpl implements SmartClipCallback {
|
| + public SmartClipCallbackImpl(final Handler smartClipHandler) {
|
| + mHandler = smartClipHandler;
|
| + }
|
| + public void storeRequestRect(Rect rect) {
|
| + mRect = rect;
|
| + }
|
| +
|
| + @Override
|
| + public void onSmartClipDataExtracted(String text, String html) {
|
| + Bundle bundle = new Bundle();
|
| + bundle.putString("url", getVisibleUrl());
|
| + bundle.putString("title", getTitle());
|
| + bundle.putString("text", text);
|
| + bundle.putString("html", html);
|
| + bundle.putParcelable("rect", mRect);
|
| +
|
| + Message msg = Message.obtain(mHandler, 0);
|
| + msg.setData(bundle);
|
| + msg.sendToTarget();
|
| + }
|
| +
|
| + Rect mRect;
|
| + final Handler mHandler;
|
| + }
|
| + private SmartClipCallbackImpl mSmartClipCallback;
|
|
|
| private EventForwarder mEventForwarder;
|
|
|
| @@ -400,10 +426,14 @@ import java.util.UUID;
|
| }
|
|
|
| @Override
|
| - public void requestSmartClipExtract(int x, int y, int width, int height) {
|
| + public void requestSmartClipExtract(
|
| + int x, int y, int width, int height, RenderCoordinates coordinateSpace) {
|
| if (mSmartClipCallback == null) return;
|
| - nativeRequestSmartClipExtract(
|
| - mNativeWebContentsAndroid, mSmartClipCallback, x, y, width, height);
|
| + mSmartClipCallback.storeRequestRect(new Rect(x, y, x + width, y + height));
|
| + float dpi = coordinateSpace.getDeviceScaleFactor();
|
| + y -= coordinateSpace.getContentOffsetYPix();
|
| + nativeRequestSmartClipExtract(mNativeWebContentsAndroid, mSmartClipCallback,
|
| + (int) (x / dpi), (int) (y / dpi), (int) (width / dpi), (int) (height / dpi));
|
| }
|
|
|
| @Override
|
| @@ -412,20 +442,7 @@ import java.util.UUID;
|
| mSmartClipCallback = null;
|
| return;
|
| }
|
| - mSmartClipCallback = new SmartClipCallback() {
|
| - @Override
|
| - public void onSmartClipDataExtracted(String text, String html) {
|
| - Bundle bundle = new Bundle();
|
| - bundle.putString("url", getVisibleUrl());
|
| - bundle.putString("title", getTitle());
|
| - bundle.putString("text", text);
|
| - bundle.putString("html", html);
|
| -
|
| - Message msg = Message.obtain(smartClipHandler, 0);
|
| - msg.setData(bundle);
|
| - msg.sendToTarget();
|
| - }
|
| - };
|
| + mSmartClipCallback = new SmartClipCallbackImpl(smartClipHandler);
|
| }
|
|
|
| @CalledByNative
|
|
|