OSDN Git Service

b/3133123 Pass touch point ids to WebKit
authorHuahui Wu <hwu@google.com>
Thu, 13 Jan 2011 23:57:11 +0000 (15:57 -0800)
committerHuahui Wu <hwu@google.com>
Fri, 14 Jan 2011 00:43:58 +0000 (16:43 -0800)
This is the CL in WebKit side and it needs the framwork CL:
  https://android-git.corp.google.com/g/#change,89630
Notice some changes touch open source WebKit's code, so b/3351313 is filed
to keep track of that.

Change-Id: I0ac5d75c4a90f14afeb2e3fc2dc5b1c437c631f8

WebCore/platform/PlatformTouchEvent.h
WebCore/platform/android/PlatformTouchEventAndroid.cpp
WebKit/android/jni/WebViewCore.cpp
WebKit/android/jni/WebViewCore.h

index 84ed910..e93c00e 100644 (file)
@@ -66,7 +66,8 @@ public:
 #if PLATFORM(QT)
     PlatformTouchEvent(QTouchEvent*);
 #elif PLATFORM(ANDROID)
-    PlatformTouchEvent(const Vector<IntPoint>&, TouchEventType, PlatformTouchPoint::State, int metaState);
+    // Changes in next line is in ANDROID but waiting to upstream to WebKit. TODO: upstream it.
+    PlatformTouchEvent(const Vector<int>&, const Vector<IntPoint>&, TouchEventType, PlatformTouchPoint::State, int metaState);
 #elif PLATFORM(BREWMP)
     PlatformTouchEvent(AEEEvent, uint16 wParam, uint32 dwParam);
 #endif
index 8b3d285..957fc54 100644 (file)
@@ -37,13 +37,15 @@ enum AndroidMetaKeyState {
     META_SYM_ON = 0x04
 };
 
-PlatformTouchEvent::PlatformTouchEvent(const Vector<IntPoint>& windowPoints, TouchEventType type, PlatformTouchPoint::State state, int metaState)
+// Changes in next line is in ANDROID but waiting to upstream to WebKit. TODO: upstream it.
+PlatformTouchEvent::PlatformTouchEvent(const Vector<int>& ids, const Vector<IntPoint>& windowPoints, TouchEventType type, PlatformTouchPoint::State state, int metaState)
     : m_type(type)
     , m_metaKey(false)
 {
     m_touchPoints.reserveCapacity(windowPoints.size());
     for (unsigned c = 0; c < windowPoints.size(); c++)
-        m_touchPoints.append(PlatformTouchPoint(c, windowPoints[c], state));
+        // Changes in next line is in ANDROID but waiting to upstream to WebKit. TODO: upstream it.
+        m_touchPoints.append(PlatformTouchPoint(ids[c], windowPoints[c], state));
 
     m_altKey = metaState & META_ALT_ON;
     m_shiftKey = metaState & META_SHIFT_ON;
index f7f1058..902ab96 100644 (file)
@@ -2784,7 +2784,7 @@ GraphicsLayerAndroid* WebViewCore::graphicsRootLayer() const
 }
 #endif
 
-bool WebViewCore::handleTouchEvent(int action, Vector<IntPoint>& points, int metaState)
+bool WebViewCore::handleTouchEvent(int action, Vector<int>& ids, Vector<IntPoint>& points, int metaState)
 {
     bool preventDefault = false;
 
@@ -2835,7 +2835,7 @@ bool WebViewCore::handleTouchEvent(int action, Vector<IntPoint>& points, int met
         points[c].setX(points[c].x() - m_scrollOffsetX);
         points[c].setY(points[c].y() - m_scrollOffsetY);
     }
-    WebCore::PlatformTouchEvent te(points, type, touchState, metaState);
+    WebCore::PlatformTouchEvent te(ids, points, type, touchState, metaState);
     preventDefault = m_mainFrame->eventHandler()->handleTouchEvent(te);
 #endif
 
@@ -3756,7 +3756,7 @@ static jstring FindAddress(JNIEnv *env, jobject obj, jstring addr,
     return ret;
 }
 
-static jboolean HandleTouchEvent(JNIEnv *env, jobject obj, jint action,
+static jboolean HandleTouchEvent(JNIEnv *env, jobject obj, jint action, jintArray idArray,
                                  jintArray xArray, jintArray yArray, jint count, jint metaState)
 {
 #ifdef ANDROID_INSTRUMENT
@@ -3764,17 +3764,21 @@ static jboolean HandleTouchEvent(JNIEnv *env, jobject obj, jint action,
 #endif
     WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
     LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__);
+    jint* ptrIdArray = env->GetIntArrayElements(idArray, 0);
     jint* ptrXArray = env->GetIntArrayElements(xArray, 0);
     jint* ptrYArray = env->GetIntArrayElements(yArray, 0);
+    Vector<int> ids(count);
     Vector<IntPoint> points(count);
     for (int c = 0; c < count; c++) {
+        ids[c] = ptrIdArray[c];
         points[c].setX(ptrXArray[c]);
         points[c].setY(ptrYArray[c]);
     }
+    env->ReleaseIntArrayElements(idArray, ptrIdArray, JNI_ABORT);
     env->ReleaseIntArrayElements(xArray, ptrXArray, JNI_ABORT);
     env->ReleaseIntArrayElements(yArray, ptrYArray, JNI_ABORT);
 
-    return viewImpl->handleTouchEvent(action, points, metaState);
+    return viewImpl->handleTouchEvent(action, ids, points, metaState);
 }
 
 static void TouchUp(JNIEnv *env, jobject obj, jint touchGeneration,
@@ -4200,7 +4204,7 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = {
         (void*) SaveDocumentState },
     { "nativeFindAddress", "(Ljava/lang/String;Z)Ljava/lang/String;",
         (void*) FindAddress },
-    { "nativeHandleTouchEvent", "(I[I[III)Z",
+    { "nativeHandleTouchEvent", "(I[I[I[III)Z",
             (void*) HandleTouchEvent },
     { "nativeTouchUp", "(IIIII)V",
         (void*) TouchUp },
index fa474ce..698b711 100644 (file)
@@ -332,7 +332,7 @@ namespace android {
         /**
          * Handle touch event
          */
-        bool handleTouchEvent(int action, Vector<IntPoint>& points, int metaState);
+        bool handleTouchEvent(int action, Vector<int>& ids, Vector<IntPoint>& points, int metaState);
 
         /**
          * Handle motionUp event from the UI thread (called touchUp in the