summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2013-11-15 17:08:26 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-20 11:01:23 +0100
commita038352dc05a880eec6b94b5ba4e01673b1565ca (patch)
tree61e1e1462721ab451dd4d699f64a294e581cd9be
parent3bb9504f1ba458fac713200cb4dfcb2592c8f0ea (diff)
Do not accept all touch events
QtWebKit currently accepts all touch events to prevent the lack of accept on a TouchBegin from preventing receiving TouchUpdate and TouchEnd. This behavior prevents QGuiApplication from converting touch events to mouse events, and makes the WebView widget impossible to interact with by touch. This patch modifies the behavior slighly so that QtWebKit only accepts touch events if they are needed for the active document. Task-number: QTBUG-31938 Change-Id: Iba80ebfaf31c93f82356e3f0622039120921172a Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
-rw-r--r--Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp12
-rw-r--r--Source/WebKit/qt/WidgetApi/qgraphicswebview.cpp6
-rw-r--r--Source/WebKit/qt/WidgetApi/qwebview.cpp6
3 files changed, 15 insertions, 9 deletions
diff --git a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp
index 6f9cebce1..039c23218 100644
--- a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp
@@ -453,6 +453,11 @@ void QWebPageAdapter::adjustPointForClicking(QMouseEvent* ev)
if (!topPadding && !rightPadding && !bottomPadding && !leftPadding)
return;
+ FrameView* view = page->mainFrame()->view();
+ ASSERT(view);
+ if (view->scrollbarAtPoint(ev->pos()))
+ return;
+
EventHandler* eventHandler = page->mainFrame()->eventHandler();
ASSERT(eventHandler);
@@ -1468,7 +1473,12 @@ bool QWebPageAdapter::touchEvent(QTouchEvent* event)
{
#if ENABLE(TOUCH_EVENTS)
Frame* frame = mainFrameAdapter()->frame;
- if (!frame->view())
+ if (!frame->view() || !frame->document())
+ return false;
+
+ // If the document doesn't have touch-event handles, we just ignore it
+ // and let QGuiApplication convert it to a mouse event.
+ if (!frame->document()->hasTouchEventHandlers())
return false;
// Always accept the QTouchEvent so that we'll receive also TouchUpdate and TouchEnd events
diff --git a/Source/WebKit/qt/WidgetApi/qgraphicswebview.cpp b/Source/WebKit/qt/WidgetApi/qgraphicswebview.cpp
index 69138d73f..4aa6a5f8d 100644
--- a/Source/WebKit/qt/WidgetApi/qgraphicswebview.cpp
+++ b/Source/WebKit/qt/WidgetApi/qgraphicswebview.cpp
@@ -291,10 +291,8 @@ bool QGraphicsWebView::sceneEvent(QEvent* event)
|| event->type() == QEvent::TouchEnd
|| event->type() == QEvent::TouchUpdate
|| event->type() == QEvent::TouchCancel)) {
- d->page->event(event);
-
- // Always return true so that we'll receive also TouchUpdate and TouchEnd events
- return true;
+ if (d->page->event(event))
+ return true;
}
return QGraphicsWidget::sceneEvent(event);
diff --git a/Source/WebKit/qt/WidgetApi/qwebview.cpp b/Source/WebKit/qt/WidgetApi/qwebview.cpp
index 9ba962178..bcbf3dcc2 100644
--- a/Source/WebKit/qt/WidgetApi/qwebview.cpp
+++ b/Source/WebKit/qt/WidgetApi/qwebview.cpp
@@ -722,10 +722,8 @@ bool QWebView::event(QEvent *e)
|| e->type() == QEvent::TouchEnd
|| e->type() == QEvent::TouchUpdate
|| e->type() == QEvent::TouchCancel) {
- d->page->event(e);
-
- // Always return true so that we'll receive also TouchUpdate and TouchEnd events
- return true;
+ if (d->page->event(e))
+ return true;
} else if (e->type() == QEvent::Leave)
d->page->event(e);
}