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

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

Issue 2708613002: Add EventForwarder for routing touch events (Closed)
Patch Set: - Created 3 years, 10 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
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 d0bcd486ece4adf008e0e52c3139b536ddb9d1e6..f6ced639ead2d93c56317138105b07170d601e04 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
@@ -934,26 +934,8 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
return GamepadList.isGamepadAPIActive();
}
- /**
- * @see View#onTouchEvent(MotionEvent)
- */
- public boolean onTouchEvent(MotionEvent event) {
- // TODO(mustaq): Should we include MotionEvent.TOOL_TYPE_STYLUS here?
- // crbug.com/592082
- if (event.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE) {
- // Mouse button info is incomplete on L and below
- int apiVersion = Build.VERSION.SDK_INT;
- if (apiVersion >= android.os.Build.VERSION_CODES.M) {
- return sendMouseEvent(event);
- }
- }
-
- final boolean isTouchHandleEvent = false;
- return sendTouchEvent(event, isTouchHandleEvent);
- }
-
@TargetApi(Build.VERSION_CODES.M)
- private boolean sendMouseEvent(MotionEvent event) {
+ boolean sendMouseEvent(MotionEvent event) {
TraceEvent.begin("sendMouseEvent");
MotionEvent offsetEvent = createOffsetMotionEvent(event);
@@ -981,85 +963,12 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
}
}
- /**
- * Called by PopupWindow-based touch handles.
- * @param event the MotionEvent targeting the handle.
- */
- public boolean onTouchHandleEvent(MotionEvent event) {
- final boolean isTouchHandleEvent = true;
- return sendTouchEvent(event, isTouchHandleEvent);
- }
-
- private boolean sendTouchEvent(MotionEvent event, boolean isTouchHandleEvent) {
- TraceEvent.begin("sendTouchEvent");
- try {
- int eventAction = event.getActionMasked();
-
- if (eventAction == MotionEvent.ACTION_DOWN) {
- cancelRequestToScrollFocusedEditableNodeIntoView();
- }
-
- if (SPenSupport.isSPenSupported(mContext)) {
- eventAction = SPenSupport.convertSPenEventAction(eventAction);
- }
- if (!isValidTouchEventActionForNative(eventAction)) return false;
-
- if (mNativeContentViewCore == 0) return false;
-
- // A zero offset is quite common, in which case the unnecessary copy should be avoided.
- MotionEvent offset = null;
- if (mCurrentTouchOffsetX != 0 || mCurrentTouchOffsetY != 0) {
- offset = createOffsetMotionEvent(event);
- event = offset;
- }
-
- final int pointerCount = event.getPointerCount();
-
- float[] touchMajor = {event.getTouchMajor(),
- pointerCount > 1 ? event.getTouchMajor(1) : 0};
- float[] touchMinor = {event.getTouchMinor(),
- pointerCount > 1 ? event.getTouchMinor(1) : 0};
-
- for (int i = 0; i < 2; i++) {
- if (touchMajor[i] < touchMinor[i]) {
- float tmp = touchMajor[i];
- touchMajor[i] = touchMinor[i];
- touchMinor[i] = tmp;
- }
- }
-
- final boolean consumed = 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,
- touchMajor[0], touchMajor[1],
- touchMinor[0], touchMinor[1],
- event.getOrientation(), pointerCount > 1 ? event.getOrientation(1) : 0,
- event.getAxisValue(MotionEvent.AXIS_TILT),
- pointerCount > 1 ? event.getAxisValue(MotionEvent.AXIS_TILT, 1) : 0,
- event.getRawX(), event.getRawY(),
- event.getToolType(0),
- pointerCount > 1 ? event.getToolType(1) : MotionEvent.TOOL_TYPE_UNKNOWN,
- event.getButtonState(),
- event.getMetaState(),
- isTouchHandleEvent);
-
- if (offset != null) offset.recycle();
- return consumed;
- } finally {
- TraceEvent.end("sendTouchEvent");
- }
- }
-
@CalledByNative
private void requestDisallowInterceptTouchEvent() {
mContainerView.requestDisallowInterceptTouchEvent(true);
}
- private static boolean isValidTouchEventActionForNative(int eventAction) {
+ static boolean isValidTouchEventActionForNative(int eventAction) {
// Only these actions have any effect on gesture detection. Other
// actions have no corresponding WebTouchEvent type and may confuse the
// touch pipline, so we ignore them entirely.
@@ -1442,7 +1351,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
}
}
- private void cancelRequestToScrollFocusedEditableNodeIntoView() {
+ void cancelRequestToScrollFocusedEditableNodeIntoView() {
// Zero-ing the rect will prevent |updateAfterSizeChanged()| from
// issuing the delayed form focus event.
mFocusPreOSKViewportRect.setEmpty();
@@ -2745,21 +2654,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
private native void nativeSendOrientationChangeEvent(
long nativeContentViewCoreImpl, int orientation);
- // All touch events (including flings, scrolls etc) accept coordinates in physical pixels.
- private native boolean nativeOnTouchEvent(
- long nativeContentViewCoreImpl, MotionEvent event,
- long timeMs, int action, int pointerCount, int historySize, int actionIndex,
- float x0, float y0, float x1, float y1,
- int pointerId0, int pointerId1,
- float touchMajor0, float touchMajor1,
- float touchMinor0, float touchMinor1,
- float orientation0, float orientation1,
- float tilt0, float tilt1,
- float rawX, float rawY,
- int androidToolType0, int androidToolType1,
- int androidButtonState, int androidMetaState,
- boolean isTouchHandleEvent);
-
private native int nativeSendMouseEvent(long nativeContentViewCoreImpl, long timeMs, int action,
float x, float y, int pointerId, float pressure, float orientaton, float tilt,
int changedButton, int buttonState, int metaState, int toolType);

Powered by Google App Engine
This is Rietveld 408576698