Index: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
index fa3f4e9a7c266e9112fec27d12d2bffad6369197..58f66b441d6269e7d65e33ec5aa133102bdda485 100644 |
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
@@ -3015,6 +3015,19 @@ public class ContentViewCore |
@CalledByNative |
private void onSmartClipDataExtracted(String text, String html, Rect clipRect) { |
+ // Translate the positions by the offsets introduced by location bar. Note that the |
+ // coordinates are in dp scale, and that this definitely has the potential to be |
+ // different from the offsets when extractSmartClipData() was called. However, |
+ // as long as OEM has a UI that consumes all the inputs and waits until the |
+ // callback is called, then there shouldn't be any difference. |
+ // TODO(changwan): once crbug.com/416432 is resolved, try to pass offsets as |
+ // separate params for extractSmartClipData(), and apply them not the new offset |
+ // values in the callback. |
+ final float deviceScale = mRenderCoordinates.getDeviceScaleFactor(); |
+ final int offsetXInDp = (int) (mSmartClipOffsetX / deviceScale); |
+ final int offsetYInDp = (int) (mSmartClipOffsetY / deviceScale); |
+ clipRect.offset(-offsetXInDp, -offsetYInDp); |
+ |
if (mSmartClipDataListener != null ) { |
mSmartClipDataListener.onSmartClipDataExtracted(text, html, clipRect); |
} |