| 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 b3ac7613a9e1d90c3d7a49b5a1f5d1ef8b214361..e59d6f86e7e68fb30a181e4825eb73809f665517 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
|
| @@ -439,6 +439,10 @@ public class ContentViewCore
|
| // if there is no render process.
|
| public static final int INVALID_RENDER_PROCESS_PID = 0;
|
|
|
| + // Offsets for the events that passes through this ContentViewCore.
|
| + private float mCurrentTouchOffsetX;
|
| + private float mCurrentTouchOffsetY;
|
| +
|
| /**
|
| * Constructs a new ContentViewCore. Embedders must call initialize() after constructing
|
| * a ContentViewCore and before using it.
|
| @@ -1186,6 +1190,8 @@ public class ContentViewCore
|
| * @see View#onTouchEvent(MotionEvent)
|
| */
|
| public boolean onTouchEvent(MotionEvent event) {
|
| + MotionEvent offset = createOffsetMotionEvent(event);
|
| +
|
| cancelRequestToScrollFocusedEditableNodeIntoView();
|
|
|
| if (!mRequestedVSyncForInput) {
|
| @@ -1193,7 +1199,7 @@ public class ContentViewCore
|
| addVSyncSubscriber();
|
| }
|
|
|
| - final int eventAction = event.getActionMasked();
|
| + final int eventAction = offset.getActionMasked();
|
|
|
| // Only these actions have any effect on gesture detection. Other
|
| // actions have no corresponding WebTouchEvent type and may confuse the
|
| @@ -1208,15 +1214,17 @@ public class ContentViewCore
|
| }
|
|
|
| if (mNativeContentViewCore == 0) return false;
|
| - final int pointerCount = event.getPointerCount();
|
| - return nativeOnTouchEvent(mNativeContentViewCore, event,
|
| - event.getEventTime(), eventAction,
|
| - pointerCount, event.getHistorySize(), event.getActionIndex(),
|
| - event.getX(), event.getY(),
|
| - pointerCount > 1 ? event.getX(1) : 0,
|
| - pointerCount > 1 ? event.getY(1) : 0,
|
| - event.getPointerId(0), pointerCount > 1 ? event.getPointerId(1) : -1,
|
| - event.getTouchMajor(), pointerCount > 1 ? event.getTouchMajor(1) : 0);
|
| + final int pointerCount = offset.getPointerCount();
|
| + boolean consumed = nativeOnTouchEvent(mNativeContentViewCore, offset,
|
| + offset.getEventTime(), eventAction,
|
| + pointerCount, offset.getHistorySize(), offset.getActionIndex(),
|
| + offset.getX(), offset.getY(),
|
| + pointerCount > 1 ? offset.getX(1) : 0,
|
| + pointerCount > 1 ? offset.getY(1) : 0,
|
| + offset.getPointerId(0), pointerCount > 1 ? offset.getPointerId(1) : -1,
|
| + offset.getTouchMajor(), pointerCount > 1 ? offset.getTouchMajor(1) : 0);
|
| + offset.recycle();
|
| + return consumed;
|
| }
|
|
|
| public void setIgnoreRemainingTouchEvents() {
|
| @@ -1709,23 +1717,25 @@ public class ContentViewCore
|
| */
|
| public boolean onHoverEvent(MotionEvent event) {
|
| TraceEvent.begin("onHoverEvent");
|
| + MotionEvent offset = createOffsetMotionEvent(event);
|
|
|
| if (mBrowserAccessibilityManager != null) {
|
| - return mBrowserAccessibilityManager.onHoverEvent(event);
|
| + return mBrowserAccessibilityManager.onHoverEvent(offset);
|
| }
|
|
|
| // Work around Android bug where the x, y coordinates of a hover exit
|
| // event are incorrect when touch exploration is on.
|
| - if (mTouchExplorationEnabled && event.getAction() == MotionEvent.ACTION_HOVER_EXIT) {
|
| + if (mTouchExplorationEnabled && offset.getAction() == MotionEvent.ACTION_HOVER_EXIT) {
|
| return true;
|
| }
|
|
|
| mContainerView.removeCallbacks(mFakeMouseMoveRunnable);
|
| if (mNativeContentViewCore != 0) {
|
| - nativeSendMouseMoveEvent(mNativeContentViewCore, event.getEventTime(),
|
| - event.getX(), event.getY());
|
| + nativeSendMouseMoveEvent(mNativeContentViewCore, offset.getEventTime(),
|
| + offset.getX(), offset.getY());
|
| }
|
| TraceEvent.end("onHoverEvent");
|
| + offset.recycle();
|
| return true;
|
| }
|
|
|
| @@ -1758,6 +1768,23 @@ public class ContentViewCore
|
| }
|
|
|
| /**
|
| + * 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.
|
| + * @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) {
|
| + mCurrentTouchOffsetX = dx;
|
| + mCurrentTouchOffsetY = dy;
|
| + }
|
| +
|
| + private MotionEvent createOffsetMotionEvent(MotionEvent src) {
|
| + MotionEvent dst = MotionEvent.obtain(src);
|
| + dst.offsetLocation(mCurrentTouchOffsetX, mCurrentTouchOffsetY);
|
| + return dst;
|
| + }
|
| +
|
| + /**
|
| * @see View#scrollBy(int, int)
|
| * Currently the ContentView scrolling happens in the native side. In
|
| * the Java view system, it is always pinned at (0, 0). scrollBy() and scrollTo()
|
|
|