Commit 02a50d7b authored by changwan's avatar changwan Committed by Commit bot

[Android] Offset smart clip rect output when there is a change in viewport

Smart clip rect output needs to be offsetted when there is a change in
viewport, e.g., when location bar is shown.

BUG=414597
TEST=verified by OEM that this fixes the bug

Review URL: https://codereview.chromium.org/565383005

Cr-Commit-Position: refs/heads/master@{#296154}
parent 342eec84
...@@ -2816,6 +2816,19 @@ public class ContentViewCore ...@@ -2816,6 +2816,19 @@ public class ContentViewCore
@CalledByNative @CalledByNative
private void onSmartClipDataExtracted(String text, String html, Rect clipRect) { 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 ) { if (mSmartClipDataListener != null ) {
mSmartClipDataListener.onSmartClipDataExtracted(text, html, clipRect); mSmartClipDataListener.onSmartClipDataExtracted(text, html, clipRect);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment