Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1643)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java

Issue 2842653004: Add back Rect parcelable to onSmartClipDataExtracted. (Closed)
Patch Set: Code review comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698