diff options
author | Grace Kloba <klobag@google.com> | 2009-12-08 09:50:32 -0800 |
---|---|---|
committer | Grace Kloba <klobag@google.com> | 2009-12-09 09:56:11 -0800 |
commit | 3d0d3fdaa1308448b47592c03cda81c7f9e1f789 (patch) | |
tree | 0f7edf54cfb1a5ff64e6b22451e78f847cf35c12 /WebCore/page | |
parent | bf16ddc110ef3fde2cfa1ae43ab31d993377981d (diff) | |
download | external_webkit-3d0d3fdaa1308448b47592c03cda81c7f9e1f789.zip external_webkit-3d0d3fdaa1308448b47592c03cda81c7f9e1f789.tar.gz external_webkit-3d0d3fdaa1308448b47592c03cda81c7f9e1f789.tar.bz2 |
Enable longpress and doubletap to WebKit as touch
event if it is requested.
Diffstat (limited to 'WebCore/page')
-rw-r--r-- | WebCore/page/EventHandler.cpp | 35 | ||||
-rw-r--r-- | WebCore/page/EventHandler.h | 11 |
2 files changed, 35 insertions, 11 deletions
diff --git a/WebCore/page/EventHandler.cpp b/WebCore/page/EventHandler.cpp index 9d45ca7..6a92aa8 100644 --- a/WebCore/page/EventHandler.cpp +++ b/WebCore/page/EventHandler.cpp @@ -2525,7 +2525,7 @@ bool EventHandler::passMousePressEventToScrollbar(MouseEventWithHitTestResults& } #if ENABLE(TOUCH_EVENTS) // Android -bool EventHandler::handleTouchEvent(const PlatformTouchEvent& e) +int EventHandler::handleTouchEvent(const PlatformTouchEvent& e) { // only handle the touch event in the top frame handler if (m_frame->tree()->parent(true)) @@ -2533,17 +2533,17 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& e) Document* doc = m_frame->document(); if (!doc) - return false; + return 0; RenderObject* docRenderer = doc->renderer(); if (!docRenderer) - return false; + return 0; if (doc->touchEventListeners().size() == 0) - return false; + return 0; TouchEventType type = e.eventType(); - if (type == TouchEventStart) { + if (type == TouchEventStart || type == TouchEventLongPress || type == TouchEventDoubleTap) { Frame* frame = m_frame; IntPoint vPoint = frame->view()->windowToContents(e.pos()); HitTestRequest request(HitTestRequest::ReadOnly); @@ -2583,13 +2583,13 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& e) if ((type == TouchEventMove) && (e.x() == m_touch->screenX()) && (e.y() == m_touch->screenY())) { // don't trigger the event if it hasn't really moved - return false; + return 0; } IntPoint vPoint = m_touch->frame()->view()->windowToContents(e.pos()); m_touch->updateLocation(e.x(), e.y(), vPoint.x(), vPoint.y()); } else { - return false; + return 0; } RefPtr<TouchList> touchList = TouchList::create(); @@ -2622,15 +2622,30 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& e) m_touch->screenX(), m_touch->screenY(), m_touch->pageX(), m_touch->pageY()); break; + case TouchEventLongPress: + te = TouchEvent::create(touchList.get(), touchList.get(), touchList.get(), + eventNames().touchlongpressEvent, m_touch->frame()->document()->defaultView(), + m_touch->screenX(), m_touch->screenY(), m_touch->pageX(), m_touch->pageY()); + break; + + case TouchEventDoubleTap: + te = TouchEvent::create(touchList.get(), touchList.get(), touchList.get(), + eventNames().touchdoubletapEvent, m_touch->frame()->document()->defaultView(), + m_touch->screenX(), m_touch->screenY(), m_touch->pageX(), m_touch->pageY()); + break; + default: return false; } ExceptionCode ec = 0; m_touch->target()->dispatchEvent(te.get(), ec); - if (type == TouchEventEnd || type == TouchEventCancel) { + if (type == TouchEventEnd || type == TouchEventCancel) m_touch = 0; - } - return te->defaultPrevented(); + if (type == TouchEventLongPress || type == TouchEventDoubleTap) + return 0; + return (te->defaultPrevented() ? preventTouch : 0) + | (te->longPressPrevented() ? preventLongPress : 0) + | (te->doubleTapPrevented() ? preventDoubleTap : 0); } #endif diff --git a/WebCore/page/EventHandler.h b/WebCore/page/EventHandler.h index daf5a67..d8cd3a2 100644 --- a/WebCore/page/EventHandler.h +++ b/WebCore/page/EventHandler.h @@ -75,6 +75,14 @@ extern const int GeneralDragHysteresis; enum HitTestScrollbars { ShouldHitTestScrollbars, DontHitTestScrollbars }; +#if ENABLE(TOUCH_EVENTS) // Android +enum TouchResultMask { + preventTouch = 1 << 0, + preventLongPress = 1 << 1, + preventDoubleTap = 1 << 2, +}; +#endif + class EventHandler : public Noncopyable { public: EventHandler(Frame*); @@ -144,7 +152,8 @@ public: bool handleWheelEvent(PlatformWheelEvent&); #if ENABLE(TOUCH_EVENTS) // Android - bool handleTouchEvent(const PlatformTouchEvent&); + // See TouchResultMask for the return value options + int handleTouchEvent(const PlatformTouchEvent&); #endif #if ENABLE(CONTEXT_MENUS) |