summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2012-05-24 18:15:40 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-05-24 18:15:40 -0700
commite0d7d53d0af7715347bc694de7b140773174149e (patch)
treec423f0dbde9d6ec9d60495d4096a04f94059b369 /Source
parent3551374e25ca65d153ff3c3ffe7f7c79095d6025 (diff)
parent8959907b97e269d7183d4817f295234718b41365 (diff)
downloadexternal_webkit-e0d7d53d0af7715347bc694de7b140773174149e.zip
external_webkit-e0d7d53d0af7715347bc694de7b140773174149e.tar.gz
external_webkit-e0d7d53d0af7715347bc694de7b140773174149e.tar.bz2
am 8959907b: am 91f41286: Support skipping a touch stream due to lack of handlers
* commit '8959907b97e269d7183d4817f295234718b41365': Support skipping a touch stream due to lack of handlers
Diffstat (limited to 'Source')
-rw-r--r--Source/WebCore/dom/Event.h4
-rw-r--r--Source/WebCore/dom/EventTarget.cpp15
-rw-r--r--Source/WebCore/dom/TouchEvent.cpp6
-rw-r--r--Source/WebCore/dom/TouchEvent.h9
-rw-r--r--Source/WebCore/page/EventHandler.cpp4
-rw-r--r--Source/WebCore/platform/PlatformTouchEvent.h5
-rw-r--r--Source/WebCore/platform/android/PlatformTouchEventAndroid.cpp1
-rw-r--r--Source/WebKit/android/jni/WebViewCore.cpp18
-rw-r--r--Source/WebKit/android/jni/WebViewCore.h5
9 files changed, 60 insertions, 7 deletions
diff --git a/Source/WebCore/dom/Event.h b/Source/WebCore/dom/Event.h
index f6e5586..e913745 100644
--- a/Source/WebCore/dom/Event.h
+++ b/Source/WebCore/dom/Event.h
@@ -136,6 +136,10 @@ namespace WebCore {
virtual bool isErrorEvent() const;
#if ENABLE(TOUCH_EVENTS)
virtual bool isTouchEvent() const;
+#if PLATFORM(ANDROID)
+ virtual bool hitTouchHandler() const { return false; }
+ virtual void setHitTouchHandler() { }
+#endif
#endif
#if ENABLE(DEVICE_ORIENTATION)
virtual bool isDeviceMotionEvent() const;
diff --git a/Source/WebCore/dom/EventTarget.cpp b/Source/WebCore/dom/EventTarget.cpp
index d84d66b..c9cece2 100644
--- a/Source/WebCore/dom/EventTarget.cpp
+++ b/Source/WebCore/dom/EventTarget.cpp
@@ -326,6 +326,16 @@ bool EventTarget::fireEventListeners(Event* event)
EventListenerMap::iterator result = d->eventListenerMap.find(event->type());
if (result != d->eventListenerMap.end())
fireEventListeners(event, d, *result->second);
+
+#if ENABLE(TOUCH_EVENTS) && PLATFORM(ANDROID)
+ if (event->isTouchEvent() && !event->hitTouchHandler()) {
+ // Check for touchmove or touchend to see if we can skip
+ // the rest of the stream (we always get touchstart, don't need to check that)
+ if (d->eventListenerMap.contains(eventNames().touchmoveEvent)
+ || d->eventListenerMap.contains(eventNames().touchendEvent))
+ event->setHitTouchHandler();
+ }
+#endif
return !event->defaultPrevented();
}
@@ -334,6 +344,11 @@ void EventTarget::fireEventListeners(Event* event, EventTargetData* d, EventList
{
RefPtr<EventTarget> protect = this;
+#if ENABLE(TOUCH_EVENTS) && PLATFORM(ANDROID)
+ if (event->isTouchEvent())
+ event->setHitTouchHandler();
+#endif
+
// Fire all listeners registered for this event. Don't fire listeners removed
// during event dispatch. Also, don't fire event listeners added during event
// dispatch. Conveniently, all new event listeners will be added after 'end',
diff --git a/Source/WebCore/dom/TouchEvent.cpp b/Source/WebCore/dom/TouchEvent.cpp
index 225e3ae..bd1577d 100644
--- a/Source/WebCore/dom/TouchEvent.cpp
+++ b/Source/WebCore/dom/TouchEvent.cpp
@@ -33,6 +33,9 @@ namespace WebCore {
TouchEvent::TouchEvent()
{
+#if PLATFORM(ANDROID)
+ m_hitTouchHandler = false;
+#endif
}
TouchEvent::TouchEvent(TouchList* touches, TouchList* targetTouches,
@@ -45,6 +48,9 @@ TouchEvent::TouchEvent(TouchList* touches, TouchList* targetTouches,
, m_targetTouches(targetTouches)
, m_changedTouches(changedTouches)
{
+#if PLATFORM(ANDROID)
+ m_hitTouchHandler = false;
+#endif
}
TouchEvent::~TouchEvent()
diff --git a/Source/WebCore/dom/TouchEvent.h b/Source/WebCore/dom/TouchEvent.h
index 1514cf8..fba613f 100644
--- a/Source/WebCore/dom/TouchEvent.h
+++ b/Source/WebCore/dom/TouchEvent.h
@@ -62,6 +62,11 @@ public:
TouchList* targetTouches() const { return m_targetTouches.get(); }
TouchList* changedTouches() const { return m_changedTouches.get(); }
+#if PLATFORM(ANDROID)
+ virtual bool hitTouchHandler() const { return m_hitTouchHandler; }
+ virtual void setHitTouchHandler() { m_hitTouchHandler = true; }
+#endif
+
private:
TouchEvent();
TouchEvent(TouchList* touches, TouchList* targetTouches,
@@ -72,6 +77,10 @@ private:
virtual bool isTouchEvent() const { return true; }
+#if PLATFORM(ANDROID)
+ bool m_hitTouchHandler;
+#endif
+
RefPtr<TouchList> m_touches;
RefPtr<TouchList> m_targetTouches;
RefPtr<TouchList> m_changedTouches;
diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp
index 45450b5..cbe01ed 100644
--- a/Source/WebCore/page/EventHandler.cpp
+++ b/Source/WebCore/page/EventHandler.cpp
@@ -3239,6 +3239,10 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
ExceptionCode ec = 0;
touchEventTarget->dispatchEvent(touchEvent.get(), ec);
defaultPrevented |= touchEvent->defaultPrevented();
+#if PLATFORM(ANDROID)
+ if (touchEvent->hitTouchHandler())
+ const_cast<PlatformTouchEvent&>(event).setHitTouchHandler();
+#endif
}
}
diff --git a/Source/WebCore/platform/PlatformTouchEvent.h b/Source/WebCore/platform/PlatformTouchEvent.h
index f7524b4..d1de018 100644
--- a/Source/WebCore/platform/PlatformTouchEvent.h
+++ b/Source/WebCore/platform/PlatformTouchEvent.h
@@ -68,6 +68,8 @@ public:
PlatformTouchEvent(QTouchEvent*);
#elif PLATFORM(ANDROID)
PlatformTouchEvent(const Vector<int>&, const Vector<IntPoint>&, TouchEventType, const Vector<PlatformTouchPoint::State>&, int metaState);
+ bool hitTouchHandler() { return m_hitTouchHandler; }
+ void setHitTouchHandler() { m_hitTouchHandler = true; }
#elif PLATFORM(BREWMP)
PlatformTouchEvent(AEEEvent, uint16 wParam, uint32 dwParam);
#elif PLATFORM(EFL)
@@ -93,6 +95,9 @@ protected:
bool m_shiftKey;
bool m_metaKey;
double m_timestamp;
+#if PLATFORM(ANDROID)
+ bool m_hitTouchHandler;
+#endif
};
}
diff --git a/Source/WebCore/platform/android/PlatformTouchEventAndroid.cpp b/Source/WebCore/platform/android/PlatformTouchEventAndroid.cpp
index dd06400..579461a 100644
--- a/Source/WebCore/platform/android/PlatformTouchEventAndroid.cpp
+++ b/Source/WebCore/platform/android/PlatformTouchEventAndroid.cpp
@@ -42,6 +42,7 @@ PlatformTouchEvent::PlatformTouchEvent(const Vector<int>& ids, const Vector<IntP
: m_type(type)
, m_metaKey(false)
, m_timestamp(WTF::currentTime())
+ , m_hitTouchHandler(false)
{
m_touchPoints.reserveCapacity(windowPoints.size());
for (unsigned c = 0; c < windowPoints.size(); c++)
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp
index 874a812..1e87b6e 100644
--- a/Source/WebKit/android/jni/WebViewCore.cpp
+++ b/Source/WebKit/android/jni/WebViewCore.cpp
@@ -178,6 +178,9 @@ FILE* gRenderTreeFile = 0;
// prerenders
#define PRERENDER_AFTER_SCROLL_DELAY 750
+#define TOUCH_FLAG_HIT_HANDLER 0x1
+#define TOUCH_FLAG_PREVENT_DEFAULT 0x2
+
////////////////////////////////////////////////////////////////////////////////////////////////
namespace android {
@@ -3185,9 +3188,9 @@ GraphicsLayerAndroid* WebViewCore::graphicsRootLayer() const
}
#endif
-bool WebViewCore::handleTouchEvent(int action, Vector<int>& ids, Vector<IntPoint>& points, int actionIndex, int metaState)
+int WebViewCore::handleTouchEvent(int action, Vector<int>& ids, Vector<IntPoint>& points, int actionIndex, int metaState)
{
- bool preventDefault = false;
+ int flags = 0;
#if USE(ACCELERATED_COMPOSITING)
GraphicsLayerAndroid* rootLayer = graphicsRootLayer();
@@ -3251,14 +3254,17 @@ bool WebViewCore::handleTouchEvent(int action, Vector<int>& ids, Vector<IntPoint
}
WebCore::PlatformTouchEvent te(ids, points, type, touchStates, metaState);
- preventDefault = m_mainFrame->eventHandler()->handleTouchEvent(te);
+ if (m_mainFrame->eventHandler()->handleTouchEvent(te))
+ flags |= TOUCH_FLAG_PREVENT_DEFAULT;
+ if (te.hitTouchHandler())
+ flags |= TOUCH_FLAG_HIT_HANDLER;
#endif
#if USE(ACCELERATED_COMPOSITING)
if (rootLayer)
rootLayer->pauseDisplay(false);
#endif
- return preventDefault;
+ return flags;
}
bool WebViewCore::performMouseClick()
@@ -4596,7 +4602,7 @@ static jstring FindAddress(JNIEnv* env, jobject obj, jstring addr,
return ret;
}
-static jboolean HandleTouchEvent(JNIEnv* env, jobject obj, jint nativeClass,
+static jint HandleTouchEvent(JNIEnv* env, jobject obj, jint nativeClass,
jint action, jintArray idArray, jintArray xArray, jintArray yArray,
jint count, jint actionIndex, jint metaState)
{
@@ -5011,7 +5017,7 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = {
(void*) SaveDocumentState },
{ "nativeFindAddress", "(Ljava/lang/String;Z)Ljava/lang/String;",
(void*) FindAddress },
- { "nativeHandleTouchEvent", "(II[I[I[IIII)Z",
+ { "nativeHandleTouchEvent", "(II[I[I[IIII)I",
(void*) HandleTouchEvent },
{ "nativeMouseClick", "(I)Z",
(void*) MouseClick },
diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h
index 8dc782f..221b012 100644
--- a/Source/WebKit/android/jni/WebViewCore.h
+++ b/Source/WebKit/android/jni/WebViewCore.h
@@ -323,8 +323,11 @@ namespace android {
/**
* Handle touch event
+ * Returns an int with the following flags:
+ * bit 0: hit an event handler
+ * bit 1: preventDefault was called
*/
- bool handleTouchEvent(int action, WTF::Vector<int>& ids,
+ int handleTouchEvent(int action, WTF::Vector<int>& ids,
WTF::Vector<WebCore::IntPoint>& points,
int actionIndex, int metaState);