From 5aaefcaef41a898511a92306a8f66a11c0cca1d0 Mon Sep 17 00:00:00 2001 From: Huahui Wu Date: Sun, 13 Mar 2011 18:10:25 -0700 Subject: b/3392594 keep the remaining touch points when one is ended. This is native side code for b/3392594, which takes the action index from java side, and set the touch point state accordingly. Change-Id: I894bcfc25f761725a5f37317a8fadffbba68b6df --- WebKit/android/jni/WebViewCore.cpp | 51 +++++++++++++++++++++++++++----------- WebKit/android/jni/WebViewCore.h | 2 +- 2 files changed, 38 insertions(+), 15 deletions(-) (limited to 'WebKit/android') diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 5744609..05f33cf 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -3026,7 +3026,7 @@ GraphicsLayerAndroid* WebViewCore::graphicsRootLayer() const } #endif -bool WebViewCore::handleTouchEvent(int action, Vector& ids, Vector& points, int metaState) +bool WebViewCore::handleTouchEvent(int action, Vector& ids, Vector& points, int actionIndex, int metaState) { bool preventDefault = false; @@ -3037,33 +3037,45 @@ bool WebViewCore::handleTouchEvent(int action, Vector& ids, Vector 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 @@ -3072,12 +3084,22 @@ bool WebViewCore::handleTouchEvent(int action, Vector& ids, VectoreventHandler()->handleTouchEvent(te); #endif @@ -3974,7 +3996,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); @@ -3995,7 +4018,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, @@ -4431,7 +4454,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 be8de94..40087c2 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& ids, Vector& points, int metaState); + bool handleTouchEvent(int action, Vector& ids, Vector& points, int actionIndex, int metaState); /** * Handle motionUp event from the UI thread (called touchUp in the -- cgit v1.1