summaryrefslogtreecommitdiffstats
path: root/WebKit
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit')
-rw-r--r--WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp10
-rw-r--r--WebKit/android/WebCoreSupport/ChromeClientAndroid.h4
-rw-r--r--WebKit/android/jni/WebViewCore.cpp59
-rw-r--r--WebKit/android/jni/WebViewCore.h7
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.cpp19
5 files changed, 82 insertions, 17 deletions
diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
index f14c2c1..ffa96f8 100644
--- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
+++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
@@ -465,4 +465,14 @@ void ChromeClientAndroid::wakeUpMainThreadWithNewQuota(long newQuota) {
m_quotaThreadCondition.signal();
}
+#if ENABLE(TOUCH_EVENTS)
+void ChromeClientAndroid::needTouchEvents(bool needTouchEvents, bool force)
+{
+ FrameView* frameView = m_webFrame->page()->mainFrame()->view();
+ android::WebViewCore* core = android::WebViewCore::getWebViewCore(frameView);
+ if (core)
+ core->needTouchEvents(needTouchEvents, force);
+}
+#endif
+
}
diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h
index 45dd078..b61f9fd 100644
--- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h
+++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h
@@ -136,6 +136,10 @@ namespace android {
virtual void populateVisitedLinks();
+#if ENABLE(TOUCH_EVENTS)
+ virtual void needTouchEvents(bool, bool);
+#endif
+
// Methods used to request and provide Geolocation permissions.
virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*);
// Android-specific
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 8414068..15cef2b 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -266,6 +266,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m
m_screenWidth = 320;
m_scale = 1;
m_screenWidthScale = 1;
+ m_touchEventListenerCount = 0;
LOG_ASSERT(m_mainFrame, "Uh oh, somehow a frameview was made without an initial frame!");
@@ -348,6 +349,9 @@ WebViewCore* WebViewCore::getWebViewCore(const WebCore::FrameView* view)
WebViewCore* WebViewCore::getWebViewCore(const WebCore::ScrollView* view)
{
+ if (!view)
+ return 0;
+
WebFrameView* webFrameView = static_cast<WebFrameView*>(view->platformWidget());
if (!webFrameView)
return 0;
@@ -991,15 +995,28 @@ void WebViewCore::restoreScreenWidthScale(int scale)
checkException(env);
}
-void WebViewCore::needTouchEvents(bool need)
+void WebViewCore::needTouchEvents(bool need, bool force)
{
DEBUG_NAV_UI_LOGD("%s", __FUNCTION__);
LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
#if ENABLE(TOUCH_EVENTS) // Android
- JNIEnv* env = JSC::Bindings::getJNIEnv();
- env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_needTouchEvents, need);
- checkException(env);
+ bool needToUpdateJava = false;
+ if (need) {
+ if (++m_touchEventListenerCount == 1)
+ needToUpdateJava = true;
+ } else {
+ if (force)
+ m_touchEventListenerCount = 0;
+ else if (--m_touchEventListenerCount == 0)
+ needToUpdateJava = true;
+ }
+
+ if (needToUpdateJava || force) {
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_needTouchEvents, need);
+ checkException(env);
+ }
#endif
}
@@ -1910,29 +1927,47 @@ int WebViewCore::handleTouchEvent(int action, int x, int y)
#endif
#if ENABLE(TOUCH_EVENTS) // Android
- WebCore::TouchEventType type = WebCore::TouchEventCancel;
+ WebCore::TouchEventType type = WebCore::TouchStart;
+ WebCore::PlatformTouchPoint::State touchState = WebCore::PlatformTouchPoint::TouchPressed;
switch (action) {
case 0: // MotionEvent.ACTION_DOWN
- type = WebCore::TouchEventStart;
+ type = WebCore::TouchStart;
break;
case 1: // MotionEvent.ACTION_UP
- type = WebCore::TouchEventEnd;
+ type = WebCore::TouchEnd;
+ touchState = WebCore::PlatformTouchPoint::TouchReleased;
break;
case 2: // MotionEvent.ACTION_MOVE
- type = WebCore::TouchEventMove;
+ type = WebCore::TouchMove;
+ touchState = WebCore::PlatformTouchPoint::TouchMoved;
break;
case 3: // MotionEvent.ACTION_CANCEL
- type = WebCore::TouchEventCancel;
+ type = WebCore::TouchCancel;
+ touchState = WebCore::PlatformTouchPoint::TouchCancelled;
break;
case 0x100: // WebViewCore.ACTION_LONGPRESS
- type = WebCore::TouchEventLongPress;
+ type = WebCore::TouchLongPress;
+ touchState = WebCore::PlatformTouchPoint::TouchPressed;
break;
case 0x200: // WebViewCore.ACTION_DOUBLETAP
- type = WebCore::TouchEventDoubleTap;
+ type = WebCore::TouchDoubleTap;
+ touchState = WebCore::PlatformTouchPoint::TouchPressed;
+ break;
+ default:
+ type = WebCore::TouchCancel;
+ touchState = WebCore::PlatformTouchPoint::TouchCancelled;
break;
}
+
+ // Track previous touch and if stationary set the state.
WebCore::IntPoint pt(x - m_scrollOffsetX, y - m_scrollOffsetY);
- WebCore::PlatformTouchEvent te(pt, pt, type);
+
+ if (type == WebCore::TouchMove && pt == m_lastTouchPoint)
+ touchState = WebCore::PlatformTouchPoint::TouchStationary;
+
+ m_lastTouchPoint = pt;
+
+ WebCore::PlatformTouchEvent te(pt, pt, type, touchState);
preventDefault = m_mainFrame->eventHandler()->handleTouchEvent(te);
#endif
diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h
index 0569b4d..c662441 100644
--- a/WebKit/android/jni/WebViewCore.h
+++ b/WebKit/android/jni/WebViewCore.h
@@ -375,7 +375,7 @@ namespace android {
Node* cursorNodeIsPlugin();
// Notify the Java side whether it needs to pass down the touch events
- void needTouchEvents(bool);
+ void needTouchEvents(bool, bool);
// Notify the Java side that webkit is requesting a keyboard
void requestKeyboard(bool showKeyboard, bool isTextView);
@@ -526,6 +526,11 @@ namespace android {
bool handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* nodePtr);
WebCore::HTMLAnchorElement* retrieveAnchorElement(WebCore::Frame* frame, WebCore::Node* node);
+#if ENABLE(TOUCH_EVENTS)
+ int m_touchEventListenerCount;
+ IntPoint m_lastTouchPoint;
+#endif
+
#if DEBUG_NAV_UI
uint32_t m_now;
#endif
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp
index 0fcdc3b..17443b7 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.cpp
+++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp
@@ -28,6 +28,7 @@
#include "Document.h"
#include "Element.h"
#include "Frame.h"
+#include "Page.h"
#include "PluginPackage.h"
#include "PluginView.h"
#include "PluginWidgetAndroid.h"
@@ -38,6 +39,10 @@
#include "WebViewCore.h"
#include "jni_utility.h"
+#if ENABLE(TOUCH_EVENTS)
+#include "ChromeClient.h"
+#endif
+
#define DEBUG_VISIBLE_RECTS 1 // temporary debug printfs and fixes
PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view)
@@ -259,12 +264,18 @@ void PluginWidgetAndroid::updateEventFlags(ANPEventFlags flags) {
}
Document* doc = m_pluginView->getParentFrame()->document();
+#if ENABLE(TOUCH_EVENTS)
if((m_eventFlags ^ flags) & kTouch_ANPEventFlag) {
- if(flags & kTouch_ANPEventFlag)
- doc->addTouchEventListener(m_pluginView->getElement());
- else
- doc->removeTouchEventListener(m_pluginView->getElement());
+ if (flags & kTouch_ANPEventFlag) {
+ if (Page* page = doc->page())
+ page->chrome()->client()->needTouchEvents(true, false);
+ doc->addListenerTypeIfNeeded(eventNames().touchstartEvent);
+ } else {
+ if (Page* page = doc->page())
+ page->chrome()->client()->needTouchEvents(false, false);
+ }
}
+#endif
m_eventFlags = flags;
}