diff options
author | Huahui Wu <hwu@google.com> | 2011-03-14 14:42:05 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-03-14 14:42:05 -0700 |
commit | 9bddcae7719c7fd62778a3cf1a63b1fdceb8e25a (patch) | |
tree | 2282ed8b4dcf751bb78d05f12cc32f1936623b46 /WebKit | |
parent | df04d7a71c88ac5b84b3a3d06fdc8834eb1f2da2 (diff) | |
parent | 5aaefcaef41a898511a92306a8f66a11c0cca1d0 (diff) | |
download | external_webkit-9bddcae7719c7fd62778a3cf1a63b1fdceb8e25a.zip external_webkit-9bddcae7719c7fd62778a3cf1a63b1fdceb8e25a.tar.gz external_webkit-9bddcae7719c7fd62778a3cf1a63b1fdceb8e25a.tar.bz2 |
Merge "b/3392594 keep the remaining touch points when one is ended." into honeycomb-mr1
Diffstat (limited to 'WebKit')
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 51 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 2 |
2 files changed, 38 insertions, 15 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index c956b39..834120d 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -3021,7 +3021,7 @@ GraphicsLayerAndroid* WebViewCore::graphicsRootLayer() const } #endif -bool WebViewCore::handleTouchEvent(int action, Vector<int>& ids, Vector<IntPoint>& points, int metaState) +bool WebViewCore::handleTouchEvent(int action, Vector<int>& ids, Vector<IntPoint>& points, int actionIndex, int metaState) { bool preventDefault = false; @@ -3032,33 +3032,45 @@ bool WebViewCore::handleTouchEvent(int action, Vector<int>& ids, Vector<IntPoint #endif #if ENABLE(TOUCH_EVENTS) // Android + #define MOTION_EVENT_ACTION_POINTER_DOWN 5 + #define MOTION_EVENT_ACTION_POINTER_UP 6 + WebCore::TouchEventType type = WebCore::TouchStart; - WebCore::PlatformTouchPoint::State touchState = WebCore::PlatformTouchPoint::TouchPressed; + WebCore::PlatformTouchPoint::State defaultTouchState; + Vector<WebCore::PlatformTouchPoint::State> touchStates(points.size()); + switch (action) { case 0: // MotionEvent.ACTION_DOWN - case 5: // MotionEvent.ACTION_POINTER_DOWN type = WebCore::TouchStart; + defaultTouchState = WebCore::PlatformTouchPoint::TouchPressed; break; case 1: // MotionEvent.ACTION_UP - case 6: // MotionEvent.ACTION_POINTER_UP type = WebCore::TouchEnd; - touchState = WebCore::PlatformTouchPoint::TouchReleased; + defaultTouchState = WebCore::PlatformTouchPoint::TouchReleased; break; case 2: // MotionEvent.ACTION_MOVE type = WebCore::TouchMove; - touchState = WebCore::PlatformTouchPoint::TouchMoved; + defaultTouchState = WebCore::PlatformTouchPoint::TouchMoved; break; case 3: // MotionEvent.ACTION_CANCEL type = WebCore::TouchCancel; - touchState = WebCore::PlatformTouchPoint::TouchCancelled; + defaultTouchState = WebCore::PlatformTouchPoint::TouchCancelled; + break; + case 5: // MotionEvent.ACTION_POINTER_DOWN + type = WebCore::TouchStart; + defaultTouchState = WebCore::PlatformTouchPoint::TouchStationary; + break; + case 6: // MotionEvent.ACTION_POINTER_UP + type = WebCore::TouchEnd; + defaultTouchState = WebCore::PlatformTouchPoint::TouchStationary; break; case 0x100: // WebViewCore.ACTION_LONGPRESS type = WebCore::TouchLongPress; - touchState = WebCore::PlatformTouchPoint::TouchPressed; + defaultTouchState = WebCore::PlatformTouchPoint::TouchPressed; break; case 0x200: // WebViewCore.ACTION_DOUBLETAP type = WebCore::TouchDoubleTap; - touchState = WebCore::PlatformTouchPoint::TouchPressed; + defaultTouchState = WebCore::PlatformTouchPoint::TouchPressed; break; default: // We do not support other kinds of touch event inside WebCore @@ -3067,12 +3079,22 @@ bool WebViewCore::handleTouchEvent(int action, Vector<int>& ids, Vector<IntPoint return 0; } - // Track previous touch and if stationary set the state. for (unsigned c = 0; c < points.size(); c++) { points[c].setX(points[c].x() - m_scrollOffsetX); points[c].setY(points[c].y() - m_scrollOffsetY); + + // Setting the touch state for each point. + // Note: actionIndex will be 0 for all actions that are not ACTION_POINTER_DOWN/UP. + if (action == MOTION_EVENT_ACTION_POINTER_DOWN && c == actionIndex) { + touchStates[c] = WebCore::PlatformTouchPoint::TouchPressed; + } else if (action == MOTION_EVENT_ACTION_POINTER_UP && c == actionIndex) { + touchStates[c] = WebCore::PlatformTouchPoint::TouchReleased; + } else { + touchStates[c] = defaultTouchState; + }; } - WebCore::PlatformTouchEvent te(ids, points, type, touchState, metaState); + + WebCore::PlatformTouchEvent te(ids, points, type, touchStates, metaState); preventDefault = m_mainFrame->eventHandler()->handleTouchEvent(te); #endif @@ -3979,7 +4001,8 @@ static jstring FindAddress(JNIEnv *env, jobject obj, jstring addr, } static jboolean HandleTouchEvent(JNIEnv *env, jobject obj, jint action, jintArray idArray, - jintArray xArray, jintArray yArray, jint count, jint metaState) + jintArray xArray, jintArray yArray, + jint count, jint actionIndex, jint metaState) { #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter); @@ -4000,7 +4023,7 @@ static jboolean HandleTouchEvent(JNIEnv *env, jobject obj, jint action, jintArra env->ReleaseIntArrayElements(xArray, ptrXArray, JNI_ABORT); env->ReleaseIntArrayElements(yArray, ptrYArray, JNI_ABORT); - return viewImpl->handleTouchEvent(action, ids, points, metaState); + return viewImpl->handleTouchEvent(action, ids, points, actionIndex, metaState); } static void TouchUp(JNIEnv *env, jobject obj, jint touchGeneration, @@ -4436,7 +4459,7 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { (void*) SaveDocumentState }, { "nativeFindAddress", "(Ljava/lang/String;Z)Ljava/lang/String;", (void*) FindAddress }, - { "nativeHandleTouchEvent", "(I[I[I[III)Z", + { "nativeHandleTouchEvent", "(I[I[I[IIII)Z", (void*) HandleTouchEvent }, { "nativeTouchUp", "(IIIII)V", (void*) TouchUp }, diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index 74f4064..59efe35 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -327,7 +327,7 @@ namespace android { /** * Handle touch event */ - bool handleTouchEvent(int action, Vector<int>& ids, Vector<IntPoint>& points, int metaState); + bool handleTouchEvent(int action, Vector<int>& ids, Vector<IntPoint>& points, int actionIndex, int metaState); /** * Handle motionUp event from the UI thread (called touchUp in the |