summaryrefslogtreecommitdiffstats
path: root/WebKit/android/jni/WebViewCore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/android/jni/WebViewCore.cpp')
-rw-r--r--WebKit/android/jni/WebViewCore.cpp70
1 files changed, 53 insertions, 17 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 8414068..5ebc8eb 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -25,7 +25,7 @@
#define LOG_TAG "webcoreglue"
-#include <config.h>
+#include "config.h"
#include "WebViewCore.h"
#include "AtomicString.h"
@@ -65,7 +65,6 @@
#include "HTMLSelectElement.h"
#include "HTMLTextAreaElement.h"
#include "InlineTextBox.h"
-#include <JNIHelp.h>
#include "KeyboardCodes.h"
#include "Navigator.h"
#include "Node.h"
@@ -102,8 +101,10 @@
#include "WebFrameView.h"
#include "HistoryItem.h"
#include "android_graphics.h"
+
+#include <JNIHelp.h>
+#include <JNIUtility.h>
#include <ui/KeycodeLabels.h>
-#include "jni_utility.h"
#include <wtf/CurrentTime.h>
#if USE(V8)
@@ -266,6 +267,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 +350,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 +996,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
}
@@ -1371,7 +1389,6 @@ void WebViewCore::drawPlugins()
SkIRect dirty;
if (w->isDirty(&dirty)) {
w->draw();
- w->localToDocumentCoords(&dirty);
inval.op(dirty, SkRegion::kUnion_Op);
}
}
@@ -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, type, touchState);
preventDefault = m_mainFrame->eventHandler()->handleTouchEvent(te);
#endif
@@ -2943,7 +2978,8 @@ static void FullScreenPluginHidden(JNIEnv* env, jobject obj, jint npp)
{
WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
PluginWidgetAndroid* plugin = viewImpl->getPluginWidget((NPP)npp);
- plugin->exitFullScreen(false);
+ if (plugin)
+ plugin->exitFullScreen(false);
}
static WebCore::IntRect jrect_to_webrect(JNIEnv* env, jobject obj)