diff options
| author | Grace Kloba <klobag@google.com> | 2009-12-08 09:50:32 -0800 |
|---|---|---|
| committer | Grace Kloba <klobag@google.com> | 2009-12-09 09:56:11 -0800 |
| commit | 3d0d3fdaa1308448b47592c03cda81c7f9e1f789 (patch) | |
| tree | 0f7edf54cfb1a5ff64e6b22451e78f847cf35c12 /WebKit/android | |
| parent | bf16ddc110ef3fde2cfa1ae43ab31d993377981d (diff) | |
| download | external_webkit-3d0d3fdaa1308448b47592c03cda81c7f9e1f789.zip external_webkit-3d0d3fdaa1308448b47592c03cda81c7f9e1f789.tar.gz external_webkit-3d0d3fdaa1308448b47592c03cda81c7f9e1f789.tar.bz2 | |
Enable longpress and doubletap to WebKit as touch
event if it is requested.
Diffstat (limited to 'WebKit/android')
| -rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 14 | ||||
| -rw-r--r-- | WebKit/android/jni/WebViewCore.h | 2 | ||||
| -rw-r--r-- | WebKit/android/plugins/android_npapi.h | 24 |
3 files changed, 31 insertions, 9 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 135d1b2..0b7e63b 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -2052,9 +2052,9 @@ void WebViewCore::click(WebCore::Frame* frame, WebCore::Node* node) { } } -bool WebViewCore::handleTouchEvent(int action, int x, int y) +int WebViewCore::handleTouchEvent(int action, int x, int y) { - bool preventDefault = false; + int preventDefault = 0; #if ENABLE(TOUCH_EVENTS) // Android WebCore::TouchEventType type = WebCore::TouchEventCancel; @@ -2071,6 +2071,12 @@ bool WebViewCore::handleTouchEvent(int action, int x, int y) case 3: // MotionEvent.ACTION_CANCEL type = WebCore::TouchEventCancel; break; + case 0x100: // WebViewCore.ACTION_LONGPRESS + type = WebCore::TouchEventLongPress; + break; + case 0x200: // WebViewCore.ACTION_DOUBLETAP + type = WebCore::TouchEventDoubleTap; + break; } WebCore::IntPoint pt(x - m_scrollOffsetX, y - m_scrollOffsetY); WebCore::PlatformTouchEvent te(pt, pt, type); @@ -2829,7 +2835,7 @@ static jstring FindAddress(JNIEnv *env, jobject obj, jstring addr, return ret; } -static jboolean HandleTouchEvent(JNIEnv *env, jobject obj, jint action, jint x, jint y) +static jint HandleTouchEvent(JNIEnv *env, jobject obj, jint action, jint x, jint y) { #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter); @@ -3216,7 +3222,7 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { (void*) SaveDocumentState }, { "nativeFindAddress", "(Ljava/lang/String;Z)Ljava/lang/String;", (void*) FindAddress }, - { "nativeHandleTouchEvent", "(III)Z", + { "nativeHandleTouchEvent", "(III)I", (void*) HandleTouchEvent }, { "nativeTouchUp", "(IIIII)V", (void*) TouchUp }, diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index 09f02a5..d1c8511 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -278,7 +278,7 @@ namespace android { /** * Handle touch event */ - bool handleTouchEvent(int action, int x, int y); + int handleTouchEvent(int action, int x, int y); /** * Handle motionUp event from the UI thread (called touchUp in the diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h index e52debb..14553ff 100644 --- a/WebKit/android/plugins/android_npapi.h +++ b/WebKit/android/plugins/android_npapi.h @@ -790,13 +790,29 @@ enum ANPTouchActions { the plugin chooses to not handle this action then no other events related to that particular touch gesture will be generated. */ - kDown_ANPTouchAction = 0, - kUp_ANPTouchAction = 1, - kMove_ANPTouchAction = 2, - kCancel_ANPTouchAction = 3, + kDown_ANPTouchAction = 0, + kUp_ANPTouchAction = 1, + kMove_ANPTouchAction = 2, + kCancel_ANPTouchAction = 3, + // The web view will ignore the return value from the following actions + kLongPress_ANPTouchAction = 4, + kDoubleTap_ANPTouchAction = 5, }; typedef int32_t ANPTouchAction; +/** + * When a plugin returns from NPP_HandleEvent() for a touch event, it can use + * ANPTouchResultMask to tell the web view which touch event it wants to handle. + * kHandleTouch_ANPTouchResult will handle all touch event inside the plugin. If + * it is not set, a plugin can choose only handle individual event like long + * press, or double tap. + */ +enum ANPTouchResultMask { + kHandleTouch_ANPTouchResult = 1, + kHandleLongPress_ANPTouchResult = 2, + kHandleDoubleTap_ANPTouchResult = 4, +}; + enum ANPLifecycleActions { /** The web view containing this plugin has been paused. See documentation on the android activity lifecycle for more information. |
