summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WebCore/platform/PlatformTouchEvent.h2
-rw-r--r--WebCore/platform/android/PlatformTouchEventAndroid.cpp4
-rw-r--r--WebKit/android/jni/WebViewCore.cpp51
-rw-r--r--WebKit/android/jni/WebViewCore.h2
4 files changed, 41 insertions, 18 deletions
diff --git a/WebCore/platform/PlatformTouchEvent.h b/WebCore/platform/PlatformTouchEvent.h
index e93c00e..9105887 100644
--- a/WebCore/platform/PlatformTouchEvent.h
+++ b/WebCore/platform/PlatformTouchEvent.h
@@ -67,7 +67,7 @@ public:
PlatformTouchEvent(QTouchEvent*);
#elif PLATFORM(ANDROID)
// 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);
+ PlatformTouchEvent(const Vector<int>&, const Vector<IntPoint>&, TouchEventType, const Vector<PlatformTouchPoint::State>&, int metaState);
#elif PLATFORM(BREWMP)
PlatformTouchEvent(AEEEvent, uint16 wParam, uint32 dwParam);
#endif
diff --git a/WebCore/platform/android/PlatformTouchEventAndroid.cpp b/WebCore/platform/android/PlatformTouchEventAndroid.cpp
index 957fc54..84af56d 100644
--- a/WebCore/platform/android/PlatformTouchEventAndroid.cpp
+++ b/WebCore/platform/android/PlatformTouchEventAndroid.cpp
@@ -38,14 +38,14 @@ enum AndroidMetaKeyState {
};
// 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)
+PlatformTouchEvent::PlatformTouchEvent(const Vector<int>& ids, const Vector<IntPoint>& windowPoints, TouchEventType type, const Vector<PlatformTouchPoint::State>& states, int metaState)
: m_type(type)
, m_metaKey(false)
{
m_touchPoints.reserveCapacity(windowPoints.size());
for (unsigned c = 0; c < windowPoints.size(); c++)
// 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_touchPoints.append(PlatformTouchPoint(ids[c], windowPoints[c], states[c]));
m_altKey = metaState & META_ALT_ON;
m_shiftKey = metaState & META_SHIFT_ON;
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