Title: [109415] trunk/Source/WebKit2
Revision
109415
Author
abe...@webkit.org
Date
2012-03-01 13:51:26 -0800 (Thu, 01 Mar 2012)

Log Message

[Qt][WK2] Make the interaction with the Flickable work on the N9
https://bugs.webkit.org/show_bug.cgi?id=80029

Reviewed by Simon Hausmann.

Because the WebView item accepts all touch events it receives and sends
them to the web process before propagating them to the gesture recognizers,
which is correct behaviour, we can not rely on the touch->mouse conversion
of Qt5 when controlling Flickable. Hence we need to convert the received
touch events to mouse events in the QtFlickProvider.

* UIProcess/qt/QtFlickProvider.cpp:
(QtFlickProvider::handleTouchFlickEvent):
Do the touch to mouse event conversion for the Flickable.
* UIProcess/qt/QtPanGestureRecognizer.cpp:
(WebKit::QtPanGestureRecognizer::recognize):
A touch begin event should cancel the previous pan gesture
and stop the ongoing flick animation.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (109414 => 109415)


--- trunk/Source/WebKit2/ChangeLog	2012-03-01 21:50:18 UTC (rev 109414)
+++ trunk/Source/WebKit2/ChangeLog	2012-03-01 21:51:26 UTC (rev 109415)
@@ -1,3 +1,24 @@
+2012-03-01  Andras Becsi  <andras.be...@nokia.com>
+
+        [Qt][WK2] Make the interaction with the Flickable work on the N9
+        https://bugs.webkit.org/show_bug.cgi?id=80029
+
+        Reviewed by Simon Hausmann.
+
+        Because the WebView item accepts all touch events it receives and sends
+        them to the web process before propagating them to the gesture recognizers,
+        which is correct behaviour, we can not rely on the touch->mouse conversion
+        of Qt5 when controlling Flickable. Hence we need to convert the received
+        touch events to mouse events in the QtFlickProvider.
+
+        * UIProcess/qt/QtFlickProvider.cpp:
+        (QtFlickProvider::handleTouchFlickEvent):
+        Do the touch to mouse event conversion for the Flickable.
+        * UIProcess/qt/QtPanGestureRecognizer.cpp:
+        (WebKit::QtPanGestureRecognizer::recognize):
+        A touch begin event should cancel the previous pan gesture
+        and stop the ongoing flick animation.
+
 2012-03-01  Anders Carlsson  <ander...@apple.com>
 
         Assertion failure in pageContainsAnyHorizontalScrollbars() (scrollableArea->isOnActivePage()) when leaving pages with embedded PDFs

Modified: trunk/Source/WebKit2/UIProcess/qt/QtFlickProvider.cpp (109414 => 109415)


--- trunk/Source/WebKit2/UIProcess/qt/QtFlickProvider.cpp	2012-03-01 21:50:18 UTC (rev 109414)
+++ trunk/Source/WebKit2/UIProcess/qt/QtFlickProvider.cpp	2012-03-01 21:51:26 UTC (rev 109415)
@@ -26,7 +26,9 @@
 
 #include <QCoreApplication>
 #include <QDeclarativeEngine>
+#include <QMouseEvent>
 #include <QPointF>
+#include <QQuickCanvas>
 #include <QQuickItem>
 #include <QTouchEvent>
 #include <wtf/Assertions.h>
@@ -116,9 +118,42 @@
     connect(m_flickable, SIGNAL(contentYChanged()), SIGNAL(contentYChanged()), Qt::DirectConnection);
 }
 
-void QtFlickProvider::handleTouchFlickEvent(QTouchEvent* event)
+void QtFlickProvider::handleTouchFlickEvent(QTouchEvent* touchEvent)
 {
-    QCoreApplication::sendEvent(m_flickable, event);
+    // Since the Flickable does not handle touch events directly the sent
+    // touch event would end up in the WebView again and would thus trigger
+    // an infinite loop.
+    // Hence do the touch to mouse event conversion for the Flickable here.
+    QEvent::Type mouseEventType = QEvent::None;
+    Qt::MouseButton mouseButton = Qt::NoButton;
+
+    switch (touchEvent->type()) {
+    case QEvent::TouchBegin:
+        mouseEventType = QEvent::MouseButtonPress;
+
+        // We need to set the mouse button so that the Flickable
+        // item receives the initial mouse press event.
+        mouseButton = Qt::LeftButton;
+        break;
+    case QEvent::TouchUpdate:
+        mouseEventType = QEvent::MouseMove;
+        break;
+    case QEvent::TouchEnd:
+        mouseEventType = QEvent::MouseButtonRelease;
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+        break;
+    }
+
+    QPointF touchPosition = touchEvent->touchPoints().last().pos();
+    QMouseEvent mouseEvent(mouseEventType, touchPosition, mouseButton, mouseButton, Qt::NoModifier);
+
+    // Send the event to the canvas and let the canvas propagate it
+    // to the Flickable. This makes sure that the Flickable grabs
+    // the mouse so that it also receives the events of gestures
+    // which started inside the viewport but ended outside of it.
+    QCoreApplication::sendEvent(m_flickable->canvas(), &mouseEvent);
 }
 
 QQuickItem* QtFlickProvider::contentItem()

Modified: trunk/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.cpp (109414 => 109415)


--- trunk/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.cpp	2012-03-01 21:50:18 UTC (rev 109414)
+++ trunk/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.cpp	2012-03-01 21:51:26 UTC (rev 109415)
@@ -63,6 +63,7 @@
         m_state = GestureRecognitionStarted;
         m_firstPosition = touchPoint.screenPos();
         m_touchBegin.reset(new QTouchEvent(*event));
+        interactionEngine()->panGestureCancelled();
         return false;
     case QEvent::TouchUpdate: {
         ASSERT(m_state != NoGesture);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to