| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.annotation.TargetApi; | 8 import android.annotation.TargetApi; |
| 9 import android.app.Activity; | 9 import android.app.Activity; |
| 10 import android.app.SearchManager; | 10 import android.app.SearchManager; |
| (...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 public boolean isGamepadAPIActive() { | 992 public boolean isGamepadAPIActive() { |
| 993 return GamepadList.isGamepadAPIActive(); | 993 return GamepadList.isGamepadAPIActive(); |
| 994 } | 994 } |
| 995 | 995 |
| 996 // End FrameLayout overrides. | 996 // End FrameLayout overrides. |
| 997 | 997 |
| 998 /** | 998 /** |
| 999 * @see View#onTouchEvent(MotionEvent) | 999 * @see View#onTouchEvent(MotionEvent) |
| 1000 */ | 1000 */ |
| 1001 public boolean onTouchEvent(MotionEvent event) { | 1001 public boolean onTouchEvent(MotionEvent event) { |
| 1002 // TODO(mustaq): Should we include MotionEvent.TOOL_TYPE_STYLUS here? |
| 1003 // crbug.com/592082 |
| 1004 if (event.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE) { |
| 1005 return sendMouseEvent(event); |
| 1006 } |
| 1002 final boolean isTouchHandleEvent = false; | 1007 final boolean isTouchHandleEvent = false; |
| 1003 return onTouchEventImpl(event, isTouchHandleEvent); | 1008 return sendTouchEvent(event, isTouchHandleEvent); |
| 1009 } |
| 1010 |
| 1011 private boolean sendMouseEvent(MotionEvent event) { |
| 1012 TraceEvent.begin("sendMouseEvent"); |
| 1013 |
| 1014 MotionEvent offsetEvent = createOffsetMotionEvent(event); |
| 1015 try { |
| 1016 mContainerView.removeCallbacks(mFakeMouseMoveRunnable); |
| 1017 if (mNativeContentViewCore != 0) { |
| 1018 nativeSendMouseEvent(mNativeContentViewCore, offsetEvent.getEven
tTime(), |
| 1019 offsetEvent.getActionMasked(), offsetEvent.getX(), offse
tEvent.getY(), |
| 1020 event.getPointerId(0), event.getPressure(0), event.getOr
ientation(0), |
| 1021 event.getAxisValue(MotionEvent.AXIS_TILT, 0), event.getB
uttonState(), |
| 1022 event.getToolType(0)); |
| 1023 } |
| 1024 return true; |
| 1025 } finally { |
| 1026 offsetEvent.recycle(); |
| 1027 TraceEvent.end("sendMouseEvent"); |
| 1028 } |
| 1004 } | 1029 } |
| 1005 | 1030 |
| 1006 /** | 1031 /** |
| 1007 * Called by PopupWindow-based touch handles. | 1032 * Called by PopupWindow-based touch handles. |
| 1008 * @param event the MotionEvent targeting the handle. | 1033 * @param event the MotionEvent targeting the handle. |
| 1009 */ | 1034 */ |
| 1010 public boolean onTouchHandleEvent(MotionEvent event) { | 1035 public boolean onTouchHandleEvent(MotionEvent event) { |
| 1011 final boolean isTouchHandleEvent = true; | 1036 final boolean isTouchHandleEvent = true; |
| 1012 return onTouchEventImpl(event, isTouchHandleEvent); | 1037 return sendTouchEvent(event, isTouchHandleEvent); |
| 1013 } | 1038 } |
| 1014 | 1039 |
| 1015 private boolean onTouchEventImpl(MotionEvent event, boolean isTouchHandleEve
nt) { | 1040 private boolean sendTouchEvent(MotionEvent event, boolean isTouchHandleEvent
) { |
| 1016 TraceEvent.begin("onTouchEvent"); | 1041 TraceEvent.begin("sendTouchEvent"); |
| 1017 try { | 1042 try { |
| 1018 int eventAction = event.getActionMasked(); | 1043 int eventAction = event.getActionMasked(); |
| 1019 | 1044 |
| 1020 if (eventAction == MotionEvent.ACTION_DOWN) { | 1045 if (eventAction == MotionEvent.ACTION_DOWN) { |
| 1021 cancelRequestToScrollFocusedEditableNodeIntoView(); | 1046 cancelRequestToScrollFocusedEditableNodeIntoView(); |
| 1022 } | 1047 } |
| 1023 | 1048 |
| 1024 if (SPenSupport.isSPenSupported(mContext)) { | 1049 if (SPenSupport.isSPenSupported(mContext)) { |
| 1025 eventAction = SPenSupport.convertSPenEventAction(eventAction); | 1050 eventAction = SPenSupport.convertSPenEventAction(eventAction); |
| 1026 } | 1051 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 event.getRawX(), event.getRawY(), | 1090 event.getRawX(), event.getRawY(), |
| 1066 event.getToolType(0), | 1091 event.getToolType(0), |
| 1067 pointerCount > 1 ? event.getToolType(1) : MotionEvent.TOOL_T
YPE_UNKNOWN, | 1092 pointerCount > 1 ? event.getToolType(1) : MotionEvent.TOOL_T
YPE_UNKNOWN, |
| 1068 event.getButtonState(), | 1093 event.getButtonState(), |
| 1069 event.getMetaState(), | 1094 event.getMetaState(), |
| 1070 isTouchHandleEvent); | 1095 isTouchHandleEvent); |
| 1071 | 1096 |
| 1072 if (offset != null) offset.recycle(); | 1097 if (offset != null) offset.recycle(); |
| 1073 return consumed; | 1098 return consumed; |
| 1074 } finally { | 1099 } finally { |
| 1075 TraceEvent.end("onTouchEvent"); | 1100 TraceEvent.end("sendTouchEvent"); |
| 1076 } | 1101 } |
| 1077 } | 1102 } |
| 1078 | 1103 |
| 1079 @CalledByNative | 1104 @CalledByNative |
| 1080 private void requestDisallowInterceptTouchEvent() { | 1105 private void requestDisallowInterceptTouchEvent() { |
| 1081 mContainerView.requestDisallowInterceptTouchEvent(true); | 1106 mContainerView.requestDisallowInterceptTouchEvent(true); |
| 1082 } | 1107 } |
| 1083 | 1108 |
| 1084 private static boolean isValidTouchEventActionForNative(int eventAction) { | 1109 private static boolean isValidTouchEventActionForNative(int eventAction) { |
| 1085 // Only these actions have any effect on gesture detection. Other | 1110 // Only these actions have any effect on gesture detection. Other |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1569 if (event.getToolType(0) == MotionEvent.TOOL_TYPE_FINGER) { | 1594 if (event.getToolType(0) == MotionEvent.TOOL_TYPE_FINGER) { |
| 1570 if (mEnableTouchHover == null) { | 1595 if (mEnableTouchHover == null) { |
| 1571 mEnableTouchHover = | 1596 mEnableTouchHover = |
| 1572 CommandLine.getInstance().hasSwitch(ContentSwitches.
ENABLE_TOUCH_HOVER); | 1597 CommandLine.getInstance().hasSwitch(ContentSwitches.
ENABLE_TOUCH_HOVER); |
| 1573 } | 1598 } |
| 1574 if (!mEnableTouchHover.booleanValue()) return false; | 1599 if (!mEnableTouchHover.booleanValue()) return false; |
| 1575 } | 1600 } |
| 1576 | 1601 |
| 1577 mContainerView.removeCallbacks(mFakeMouseMoveRunnable); | 1602 mContainerView.removeCallbacks(mFakeMouseMoveRunnable); |
| 1578 if (mNativeContentViewCore != 0) { | 1603 if (mNativeContentViewCore != 0) { |
| 1579 nativeSendMouseMoveEvent(mNativeContentViewCore, offset.getEvent
Time(), | 1604 nativeSendMouseEvent(mNativeContentViewCore, offset.getEventTime
(), |
| 1580 offset.getX(), offset.getY(), event.getToolType(0)); | 1605 MotionEvent.ACTION_MOVE, offset.getX(), offset.getY(), |
| 1606 event.getPointerId(0), event.getPressure(0), event.getOr
ientation(0), |
| 1607 event.getAxisValue(MotionEvent.AXIS_TILT, 0), event.getB
uttonState(), |
| 1608 event.getToolType(0)); |
| 1581 } | 1609 } |
| 1582 return true; | 1610 return true; |
| 1583 } finally { | 1611 } finally { |
| 1584 offset.recycle(); | 1612 offset.recycle(); |
| 1585 TraceEvent.end("onHoverEvent"); | 1613 TraceEvent.end("onHoverEvent"); |
| 1586 } | 1614 } |
| 1587 } | 1615 } |
| 1588 | 1616 |
| 1589 /** | 1617 /** |
| 1590 * @see View#onGenericMotionEvent(MotionEvent) | 1618 * @see View#onGenericMotionEvent(MotionEvent) |
| (...skipping 1716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3307 int pointerId0, int pointerId1, | 3335 int pointerId0, int pointerId1, |
| 3308 float touchMajor0, float touchMajor1, | 3336 float touchMajor0, float touchMajor1, |
| 3309 float touchMinor0, float touchMinor1, | 3337 float touchMinor0, float touchMinor1, |
| 3310 float orientation0, float orientation1, | 3338 float orientation0, float orientation1, |
| 3311 float tilt0, float tilt1, | 3339 float tilt0, float tilt1, |
| 3312 float rawX, float rawY, | 3340 float rawX, float rawY, |
| 3313 int androidToolType0, int androidToolType1, | 3341 int androidToolType0, int androidToolType1, |
| 3314 int androidButtonState, int androidMetaState, | 3342 int androidButtonState, int androidMetaState, |
| 3315 boolean isTouchHandleEvent); | 3343 boolean isTouchHandleEvent); |
| 3316 | 3344 |
| 3317 private native int nativeSendMouseMoveEvent( | 3345 private native int nativeSendMouseEvent(long nativeContentViewCoreImpl, long
timeMs, int action, |
| 3318 long nativeContentViewCoreImpl, long timeMs, float x, float y, int t
oolType); | 3346 float x, float y, int pointerId, float pressure, float orientaton, f
loat tilt, |
| 3347 int buttonState, int toolType); |
| 3319 | 3348 |
| 3320 private native int nativeSendMouseWheelEvent(long nativeContentViewCoreImpl,
long timeMs, | 3349 private native int nativeSendMouseWheelEvent(long nativeContentViewCoreImpl,
long timeMs, |
| 3321 float x, float y, float ticksX, float ticksY, float pixelsPerTick); | 3350 float x, float y, float ticksX, float ticksY, float pixelsPerTick); |
| 3322 | 3351 |
| 3323 private native void nativeScrollBegin(long nativeContentViewCoreImpl, long t
imeMs, float x, | 3352 private native void nativeScrollBegin(long nativeContentViewCoreImpl, long t
imeMs, float x, |
| 3324 float y, float hintX, float hintY, boolean targetViewport); | 3353 float y, float hintX, float hintY, boolean targetViewport); |
| 3325 | 3354 |
| 3326 private native void nativeScrollEnd(long nativeContentViewCoreImpl, long tim
eMs); | 3355 private native void nativeScrollEnd(long nativeContentViewCoreImpl, long tim
eMs); |
| 3327 | 3356 |
| 3328 private native void nativeScrollBy( | 3357 private native void nativeScrollBy( |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3394 String textTrackTextShadow, String textTrackTextSize); | 3423 String textTrackTextShadow, String textTrackTextSize); |
| 3395 | 3424 |
| 3396 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp
l, | 3425 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp
l, |
| 3397 int x, int y, int w, int h); | 3426 int x, int y, int w, int h); |
| 3398 | 3427 |
| 3399 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl
, boolean opaque); | 3428 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl
, boolean opaque); |
| 3400 private native boolean nativeIsTouchDragDropEnabled(long nativeContentViewCo
reImpl); | 3429 private native boolean nativeIsTouchDragDropEnabled(long nativeContentViewCo
reImpl); |
| 3401 private native void nativeOnDragEvent(long nativeContentViewCoreImpl, int ac
tion, int x, int y, | 3430 private native void nativeOnDragEvent(long nativeContentViewCoreImpl, int ac
tion, int x, int y, |
| 3402 int screenX, int screenY, String[] mimeTypes, String content); | 3431 int screenX, int screenY, String[] mimeTypes, String content); |
| 3403 } | 3432 } |
| OLD | NEW |