Title: [100764] trunk/Source/WebKit2
Revision
100764
Author
kenn...@webkit.org
Date
2011-11-18 06:15:13 -0800 (Fri, 18 Nov 2011)

Log Message

[Qt] Support wheel event together with resizesToContents

Reviewed by Simon Hausmann.

* UIProcess/API/qt/qquickwebpage.cpp:
* UIProcess/qt/QtViewportInteractionEngine.cpp:
(WebKit::QtViewportInteractionEngine::wheelEvent):
* UIProcess/qt/QtViewportInteractionEngine.h:
* UIProcess/qt/QtWebPageProxy.cpp:
(QtWebPageProxy::handleWheelEvent):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (100763 => 100764)


--- trunk/Source/WebKit2/ChangeLog	2011-11-18 14:00:33 UTC (rev 100763)
+++ trunk/Source/WebKit2/ChangeLog	2011-11-18 14:15:13 UTC (rev 100764)
@@ -1,3 +1,16 @@
+2011-11-18  Kenneth Rohde Christiansen  <kenn...@webkit.org>
+
+        [Qt] Support wheel event together with resizesToContents
+
+        Reviewed by Simon Hausmann.
+
+        * UIProcess/API/qt/qquickwebpage.cpp:
+        * UIProcess/qt/QtViewportInteractionEngine.cpp:
+        (WebKit::QtViewportInteractionEngine::wheelEvent):
+        * UIProcess/qt/QtViewportInteractionEngine.h:
+        * UIProcess/qt/QtWebPageProxy.cpp:
+        (QtWebPageProxy::handleWheelEvent):
+
 2011-11-18  Simon Hausmann  <simon.hausm...@nokia.com>
 
         [Qt][WK2] Layer violation: WebPopupMenuProxyQtDesktop.cpp uses files from WebKit/qt

Modified: trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp (100763 => 100764)


--- trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp	2011-11-18 14:00:33 UTC (rev 100763)
+++ trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp	2011-11-18 14:15:13 UTC (rev 100764)
@@ -27,6 +27,7 @@
 #include <QScrollEvent>
 #include <QScrollPrepareEvent>
 #include <QScrollerProperties>
+#include <QWheelEvent>
 #include <QtDeclarative/qquickitem.h>
 
 namespace WebKit {
@@ -215,6 +216,35 @@
                    qBound(minPosition.y(), position.y(), maxPosition.y()));
 }
 
+void QtViewportInteractionEngine::wheelEvent(QWheelEvent* ev)
+{
+    if (scrollAnimationActive() || scaleAnimationActive() || pinchGestureActive())
+        return; // Ignore.
+
+    int delta = ev->delta();
+    QPointF newPos = -m_content->pos();
+
+    // A delta that is not mod 120 indicates a device that is sending
+    // fine-resolution scroll events, so use the delta as number of wheel ticks
+    // and number of pixels to scroll. See also webkit.org/b/29601
+    bool fullTick = !(delta % 120);
+
+    static const int cDefaultQtScrollStep = 20;
+    static const int wheelScrollLines = 3;
+    int scrollLines = (fullTick) ? wheelScrollLines * cDefaultQtScrollStep : 1;
+
+    delta = (fullTick) ? delta / 120.0f : delta;
+    delta *= scrollLines;
+
+    if (ev->orientation() == Qt::Horizontal)
+        newPos.rx() += delta;
+    else
+        newPos.ry() += delta;
+
+    QRectF endPosRange = computePosRangeForItemAtScale(m_content->scale());
+    m_content->setPos(-boundPosition(endPosRange.topLeft(), newPos, endPosRange.bottomRight()));
+}
+
 void QtViewportInteractionEngine::pagePositionRequest(const QPoint& pagePosition)
 {
     // FIXME: Assert when we are suspending properly.

Modified: trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h (100763 => 100764)


--- trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h	2011-11-18 14:00:33 UTC (rev 100763)
+++ trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h	2011-11-18 14:15:13 UTC (rev 100764)
@@ -33,6 +33,7 @@
 QT_BEGIN_NAMESPACE
 class QPointF;
 class QQuickItem;
+class QWheelEvent;
 QT_END_NAMESPACE
 
 namespace WebKit {
@@ -70,6 +71,7 @@
     void setItemRectVisible(const QRectF&);
     void animateItemRectVisible(const QRectF&);
 
+    void wheelEvent(QWheelEvent*);
     void pagePositionRequest(const QPoint& pos);
 
     bool scrollAnimationActive() const;

Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp (100763 => 100764)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp	2011-11-18 14:00:33 UTC (rev 100763)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp	2011-11-18 14:15:13 UTC (rev 100764)
@@ -269,6 +269,8 @@
 bool QtWebPageProxy::handleWheelEvent(QWheelEvent* ev)
 {
     m_webPageProxy->handleWheelEvent(NativeWebWheelEvent(ev));
+    // FIXME: Handle whether the page used the wheel event or not.
+    m_interactionEngine->wheelEvent(ev);
     return ev->isAccepted();
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to