summaryrefslogtreecommitdiffstats
path: root/WebCore
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore')
-rw-r--r--WebCore/dom/EventNames.h2
-rw-r--r--WebCore/dom/TouchEvent.cpp2
-rw-r--r--WebCore/dom/TouchEvent.h11
-rw-r--r--WebCore/page/EventHandler.cpp35
-rw-r--r--WebCore/page/EventHandler.h11
-rw-r--r--WebCore/platform/PlatformTouchEvent.h2
-rw-r--r--WebCore/plugins/android/PluginViewAndroid.cpp21
7 files changed, 69 insertions, 15 deletions
diff --git a/WebCore/dom/EventNames.h b/WebCore/dom/EventNames.h
index 930ef3a..b2db177 100644
--- a/WebCore/dom/EventNames.h
+++ b/WebCore/dom/EventNames.h
@@ -96,6 +96,8 @@ namespace WebCore {
macro(touchmove) \
macro(touchend) \
macro(touchcancel) \
+ macro(touchlongpress) \
+ macro(touchdoubletap) \
/* #endif */ \
macro(unload) \
macro(updateready) \
diff --git a/WebCore/dom/TouchEvent.cpp b/WebCore/dom/TouchEvent.cpp
index d02bac8..7ce856f 100644
--- a/WebCore/dom/TouchEvent.cpp
+++ b/WebCore/dom/TouchEvent.cpp
@@ -39,6 +39,8 @@ TouchEvent::TouchEvent(TouchList* touches, TouchList* targetTouches,
, m_touches(touches)
, m_targetTouches(targetTouches)
, m_changedTouches(changedTouches)
+ , m_longPressPrevented(false)
+ , m_doubleTapPrevented(false)
{
}
diff --git a/WebCore/dom/TouchEvent.h b/WebCore/dom/TouchEvent.h
index e8423e5..6b7d384 100644
--- a/WebCore/dom/TouchEvent.h
+++ b/WebCore/dom/TouchEvent.h
@@ -57,6 +57,14 @@ namespace WebCore {
TouchList* targetTouches() const {return m_targetTouches.get();}
TouchList* changedTouches() const {return m_changedTouches.get();}
+ bool longPressPrevented() const { return m_longPressPrevented; }
+ void preventLongPress() { m_longPressPrevented = true; }
+ void setLongPressPrevented(bool prevented) { m_longPressPrevented = prevented; }
+
+ bool doubleTapPrevented() const { return m_doubleTapPrevented; }
+ void preventDoubleTap() { m_doubleTapPrevented = true; }
+ void setDoubleTapPrevented(bool prevented) { m_doubleTapPrevented = prevented; }
+
private:
TouchEvent() {}
TouchEvent(TouchList* touches, TouchList* targetTouches,
@@ -69,6 +77,9 @@ namespace WebCore {
RefPtr<TouchList> m_touches;
RefPtr<TouchList> m_targetTouches;
RefPtr<TouchList> m_changedTouches;
+
+ bool m_longPressPrevented;
+ bool m_doubleTapPrevented;
};
} // namespace WebCore
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)
diff --git a/WebCore/platform/PlatformTouchEvent.h b/WebCore/platform/PlatformTouchEvent.h
index 4f547b2..6c8629c 100644
--- a/WebCore/platform/PlatformTouchEvent.h
+++ b/WebCore/platform/PlatformTouchEvent.h
@@ -32,7 +32,7 @@
namespace WebCore {
- enum TouchEventType {TouchEventStart, TouchEventMove, TouchEventEnd, TouchEventCancel};
+ enum TouchEventType {TouchEventStart, TouchEventMove, TouchEventEnd, TouchEventCancel, TouchEventLongPress, TouchEventDoubleTap};
class PlatformTouchEvent {
public:
diff --git a/WebCore/plugins/android/PluginViewAndroid.cpp b/WebCore/plugins/android/PluginViewAndroid.cpp
index 08ac7c8..4266a9a 100644
--- a/WebCore/plugins/android/PluginViewAndroid.cpp
+++ b/WebCore/plugins/android/PluginViewAndroid.cpp
@@ -183,6 +183,7 @@ void PluginView::handleTouchEvent(TouchEvent* event)
ANPEvent evt;
SkANP::InitEvent(&evt, kTouch_ANPEventType);
+ bool ignoreRet = false;
const AtomicString& type = event->type();
if (eventNames().touchstartEvent == type)
evt.data.touch.action = kDown_ANPTouchAction;
@@ -192,7 +193,13 @@ void PluginView::handleTouchEvent(TouchEvent* event)
evt.data.touch.action = kMove_ANPTouchAction;
else if (eventNames().touchcancelEvent == type)
evt.data.touch.action = kCancel_ANPTouchAction;
- else
+ else if (eventNames().touchlongpressEvent == type) {
+ evt.data.touch.action = kLongPress_ANPTouchAction;
+ ignoreRet = true;
+ } else if (eventNames().touchdoubletapEvent == type) {
+ evt.data.touch.action = kDoubleTap_ANPTouchAction;
+ ignoreRet = true;
+ } else
return;
evt.data.touch.modifiers = 0; // todo
@@ -203,14 +210,22 @@ void PluginView::handleTouchEvent(TouchEvent* event)
evt.data.touch.x = event->pageX() - m_npWindow.x;
evt.data.touch.y = event->pageY() - m_npWindow.y;
- if (m_plugin->pluginFuncs()->event(m_instance, &evt)) {
+ int16 ret = m_plugin->pluginFuncs()->event(m_instance, &evt);
+ if (ignoreRet)
+ return;
+ if (ret & kHandleTouch_ANPTouchResult) {
// The plugin needs focus to receive keyboard events
if (evt.data.touch.action == kDown_ANPTouchAction) {
if (Page* page = m_parentFrame->page())
page->focusController()->setFocusedFrame(m_parentFrame);
m_parentFrame->document()->setFocusedNode(m_element);
}
- event->setDefaultPrevented(true);
+ event->preventDefault();
+ } else {
+ if (ret & kHandleLongPress_ANPTouchResult)
+ event->preventLongPress();
+ if (ret & kHandleDoubleTap_ANPTouchResult)
+ event->preventDoubleTap();
}
}