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

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

Issue 565383005: [Android] Offset smart clip rect output when there is a change in viewport (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added a TODO Created 6 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698