diff options
author | John Reck <jreck@google.com> | 2012-05-24 18:15:40 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-05-24 18:15:40 -0700 |
commit | e0d7d53d0af7715347bc694de7b140773174149e (patch) | |
tree | c423f0dbde9d6ec9d60495d4096a04f94059b369 /Source/WebCore | |
parent | 3551374e25ca65d153ff3c3ffe7f7c79095d6025 (diff) | |
parent | 8959907b97e269d7183d4817f295234718b41365 (diff) | |
download | external_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/WebCore')
-rw-r--r-- | Source/WebCore/dom/Event.h | 4 | ||||
-rw-r--r-- | Source/WebCore/dom/EventTarget.cpp | 15 | ||||
-rw-r--r-- | Source/WebCore/dom/TouchEvent.cpp | 6 | ||||
-rw-r--r-- | Source/WebCore/dom/TouchEvent.h | 9 | ||||
-rw-r--r-- | Source/WebCore/page/EventHandler.cpp | 4 | ||||
-rw-r--r-- | Source/WebCore/platform/PlatformTouchEvent.h | 5 | ||||
-rw-r--r-- | Source/WebCore/platform/android/PlatformTouchEventAndroid.cpp | 1 |
7 files changed, 44 insertions, 0 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++) |