summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WebCore/dom/Document.cpp11
-rw-r--r--WebCore/dom/Node.cpp12
-rw-r--r--WebCore/history/CachedFrame.cpp14
-rw-r--r--WebCore/loader/EmptyClients.h4
-rw-r--r--WebCore/page/ChromeClient.h2
-rw-r--r--WebCore/page/EventHandler.cpp8
-rw-r--r--WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp4
-rw-r--r--WebKit/android/WebCoreSupport/ChromeClientAndroid.h2
-rw-r--r--WebKit/android/jni/WebViewCore.cpp30
-rw-r--r--WebKit/android/jni/WebViewCore.h4
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.cpp10
11 files changed, 49 insertions, 52 deletions
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index d031853..5bae60e 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -1487,6 +1487,17 @@ void Document::detach()
FrameView* view = m_frame->view();
if (view)
view->detachCustomScrollbars();
+
+#if ENABLE(TOUCH_EVENTS)
+ Page* ownerPage = page();
+ if (ownerPage && (m_frame == ownerPage->mainFrame())) {
+ // Inform the Chrome Client that it no longer needs to
+ // foward touch events to WebCore as the document is being
+ // destroyed. It may start again if a subsequent page
+ // registers a touch event listener.
+ ownerPage->chrome()->client()->needTouchEvents(false);
+ }
+#endif
}
// indicate destruction mode, i.e. attached() but renderer == 0
diff --git a/WebCore/dom/Node.cpp b/WebCore/dom/Node.cpp
index c2d5281..b48819a 100644
--- a/WebCore/dom/Node.cpp
+++ b/WebCore/dom/Node.cpp
@@ -2438,18 +2438,6 @@ bool Node::removeEventListener(const AtomicString& eventType, EventListener* lis
updateSVGElementInstancesAfterEventListenerChange(this);
-#if ENABLE(TOUCH_EVENTS)
- if (Document* document = this->document()) {
- if (document->page()
- && (eventType == eventNames().touchstartEvent
- || eventType == eventNames().touchmoveEvent
- || eventType == eventNames().touchendEvent
- || eventType == eventNames().touchcancelEvent))
- // Note the corresponding needTouchEvents(true) is called in Document::addListenerTypeIfNeeded().
- document->page()->chrome()->client()->needTouchEvents(false);
-
- }
-#endif
return true;
}
diff --git a/WebCore/history/CachedFrame.cpp b/WebCore/history/CachedFrame.cpp
index a868134..7d69195 100644
--- a/WebCore/history/CachedFrame.cpp
+++ b/WebCore/history/CachedFrame.cpp
@@ -42,6 +42,11 @@
#include "SVGDocumentExtensions.h"
#endif
+#if ENABLE(TOUCH_EVENTS)
+#include "ChromeClient.h"
+#include "Page.h"
+#endif
+
namespace WebCore {
#ifndef NDEBUG
@@ -104,6 +109,10 @@ void CachedFrameBase::restore()
m_document->dispatchWindowLoadEvent();
#endif
m_document->dispatchWindowEvent(PageTransitionEvent::create(eventNames().pageshowEvent, true), m_document);
+#if ENABLE(TOUCH_EVENTS)
+ if (m_document->hasListenerType(Document::TOUCH_LISTENER))
+ m_document->page()->chrome()->client()->needTouchEvents(true);
+#endif
}
CachedFrame::CachedFrame(Frame* frame)
@@ -146,6 +155,11 @@ CachedFrame::CachedFrame(Frame* frame)
else
LOG(PageCache, "Finished creating CachedFrame for child frame with url '%s' and DocumentLoader %p\n", m_url.string().utf8().data(), m_documentLoader.get());
#endif
+
+#if ENABLE(TOUCH_EVENTS)
+ if (m_document->hasListenerType(Document::TOUCH_LISTENER))
+ m_document->page()->chrome()->client()->needTouchEvents(false);
+#endif
}
void CachedFrame::open()
diff --git a/WebCore/loader/EmptyClients.h b/WebCore/loader/EmptyClients.h
index e4b9af5..e5385c5 100644
--- a/WebCore/loader/EmptyClients.h
+++ b/WebCore/loader/EmptyClients.h
@@ -169,6 +169,10 @@ public:
virtual void setNeedsOneShotDrawingSynchronization() {};
virtual void scheduleCompositingLayerSync() {};
#endif
+
+#if ENABLE(TOUCH_EVENTS)
+ virtual void needTouchEvents(bool) { }
+#endif
};
class EmptyFrameLoaderClient : public FrameLoaderClient {
diff --git a/WebCore/page/ChromeClient.h b/WebCore/page/ChromeClient.h
index b28473b..d4af73b 100644
--- a/WebCore/page/ChromeClient.h
+++ b/WebCore/page/ChromeClient.h
@@ -226,7 +226,7 @@ namespace WebCore {
#endif
#if ENABLE(TOUCH_EVENTS)
- virtual void needTouchEvents(bool, bool force = false) = 0;
+ virtual void needTouchEvents(bool) = 0;
#endif
protected:
diff --git a/WebCore/page/EventHandler.cpp b/WebCore/page/EventHandler.cpp
index 1d5941b..e4274c2 100644
--- a/WebCore/page/EventHandler.cpp
+++ b/WebCore/page/EventHandler.cpp
@@ -210,14 +210,6 @@ void EventHandler::clear()
m_clickNode = 0;
#if ENABLE(TOUCH_EVENTS)
m_touchEventTarget = 0;
- if (Document* doc = m_frame->document()) {
- if (Page* page = doc->page()) {
- // We are clearing event handlers, which includes any touch
- // event handlers so force webkit to tell the chrome client to
- // stop forwarding the events.
- page->chrome()->client()->needTouchEvents(false, true);
- }
- }
#endif
m_frameSetBeingResized = 0;
#if ENABLE(DRAG_SUPPORT)
diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
index 9b0e7b4..17dc0d0 100644
--- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
+++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
@@ -468,12 +468,12 @@ void ChromeClientAndroid::wakeUpMainThreadWithNewQuota(long newQuota) {
}
#if ENABLE(TOUCH_EVENTS)
-void ChromeClientAndroid::needTouchEvents(bool needTouchEvents, bool force)
+void ChromeClientAndroid::needTouchEvents(bool needTouchEvents)
{
FrameView* frameView = m_webFrame->page()->mainFrame()->view();
android::WebViewCore* core = android::WebViewCore::getWebViewCore(frameView);
if (core)
- core->needTouchEvents(needTouchEvents, force);
+ core->needTouchEvents(needTouchEvents);
}
#endif
diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h
index b61f9fd..15bf52a 100644
--- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h
+++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h
@@ -137,7 +137,7 @@ namespace android {
virtual void populateVisitedLinks();
#if ENABLE(TOUCH_EVENTS)
- virtual void needTouchEvents(bool, bool);
+ virtual void needTouchEvents(bool);
#endif
// Methods used to request and provide Geolocation permissions.
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 9778ea0..ae3e47c 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -268,7 +268,9 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m
m_screenWidth = 320;
m_scale = 1;
m_screenWidthScale = 1;
- m_touchEventListenerCount = 0;
+#if ENABLE(TOUCH_EVENTS)
+ m_forwardingTouchEvents = false;
+#endif
LOG_ASSERT(m_mainFrame, "Uh oh, somehow a frameview was made without an initial frame!");
@@ -998,28 +1000,20 @@ void WebViewCore::restoreScreenWidthScale(int scale)
checkException(env);
}
-void WebViewCore::needTouchEvents(bool need, bool force)
+void WebViewCore::needTouchEvents(bool need)
{
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
- 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 ENABLE(TOUCH_EVENTS)
+ if (m_forwardingTouchEvents == need)
+ return;
- if (needToUpdateJava || force) {
- JNIEnv* env = JSC::Bindings::getJNIEnv();
- env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_needTouchEvents, need);
- checkException(env);
- }
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_needTouchEvents, need);
+ checkException(env);
+
+ m_forwardingTouchEvents = need;
#endif
}
diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h
index f528c73..2252878 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, bool);
+ void needTouchEvents(bool);
// Notify the Java side that webkit is requesting a keyboard
void requestKeyboard(bool showKeyboard, bool isTextView);
@@ -536,7 +536,7 @@ namespace android {
WebCore::HTMLAnchorElement* retrieveAnchorElement(WebCore::Frame* frame, WebCore::Node* node);
#if ENABLE(TOUCH_EVENTS)
- int m_touchEventListenerCount;
+ bool m_forwardingTouchEvents;
IntPoint m_lastTouchPoint;
#endif
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp
index 2ea3191..7109ab4 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.cpp
+++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp
@@ -271,14 +271,8 @@ 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) {
- 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);
- }
+ if (flags & kTouch_ANPEventFlag)
+ doc->addListenerTypeIfNeeded(eventNames().touchstartEvent);
}
#endif