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

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

Issue 2113183003: Support dragging texts into Chrome on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Intercept dragEvent and set TouchEventOffsets there Created 4 years, 6 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 | « content/public/android/java/src/org/chromium/content/browser/ContentView.java ('k') | 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 33c34fa82a9dc3e40d7331c7c7340a6074d4faa7..357cf7c1672c52636dde7ec47589051096605ac7 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
@@ -1793,12 +1793,13 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
}
/**
- * Sets the current amount to offset incoming touch events by. This is used to handle content
- * moving and not lining up properly with the android input system.
+ * Sets the current amount to offset incoming touch events by (including MotionEvent and
+ * DragEvent). This is used to handle content moving and not lining up properly with the
+ * android input system.
* @param dx The X offset in pixels to shift touch events.
* @param dy The Y offset in pixels to shift touch events.
*/
- public void setCurrentMotionEventOffsets(float dx, float dy) {
+ public void setCurrentTouchEventOffsets(float dx, float dy) {
mCurrentTouchOffsetX = dx;
mCurrentTouchOffsetY = dy;
}
@@ -3312,17 +3313,19 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
}
}
- float scale = (float) DeviceDisplayInfo.create(mContainerView.getContext()).getDIPScale();
int[] locationOnScreen = new int[2];
mContainerView.getLocationOnScreen(locationOnScreen);
- int x = (int) (event.getX() / scale);
- int y = (int) (event.getY() / scale);
- int screenX = (int) ((event.getX() + locationOnScreen[0]) / scale);
- int screenY = (int) ((event.getY() + locationOnScreen[1]) / scale);
+ float xPix = event.getX() + mRenderCoordinates.getScrollXPixInt() + mCurrentTouchOffsetX;
+ float yPix = event.getY() + mRenderCoordinates.getScrollYPixInt() + mCurrentTouchOffsetY;
- nativeOnDragEvent(mNativeContentViewCore, event.getAction(), x, y, screenX, screenY,
- mimeTypes, content.toString());
+ int xCss = (int) mRenderCoordinates.fromPixToLocalCss(xPix);
+ int yCss = (int) mRenderCoordinates.fromPixToLocalCss(yPix);
+ int screenXCss = (int) mRenderCoordinates.fromPixToLocalCss(xPix + locationOnScreen[0]);
+ int screenYCss = (int) mRenderCoordinates.fromPixToLocalCss(yPix + locationOnScreen[1]);
+
+ nativeOnDragEvent(mNativeContentViewCore, event.getAction(), xCss, yCss, screenXCss,
+ screenYCss, mimeTypes, content.toString());
return true;
}
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/ContentView.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698