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 226d7989bdbde0dff01f6c93f8b8918dab52fe19..d0551617f22b17a39b8370e4a628ef3414a8fa31 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 |
@@ -2816,6 +2816,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 |
Ted C
2014/09/22 15:23:51
Sadly these offsets can be driven not only by user
|
+ // 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); |
} |