Title: [114546] trunk
Revision
114546
Author
[email protected]
Date
2012-04-18 12:48:34 -0700 (Wed, 18 Apr 2012)

Log Message

Clean-up WheelEvent Conversion.
https://bugs.webkit.org/show_bug.cgi?id=84243

Source/WebKit/qt:

Patch by Allan Sandfeld Jensen <[email protected]> on 2012-04-18
Reviewed by Simon Hausmann.

* WebCoreSupport/WebEventConversion.cpp:
(WebCore::WebKitPlatformWheelEvent::applyDelta):

Source/WebKit2:

Patch by Allan Sandfeld Jensen <[email protected]> on 2012-04-18
Reviewed by Simon Hausmann.

* Shared/qt/WebEventFactoryQt.cpp:
(WebKit::WebEventFactory::createWebWheelEvent):
* UIProcess/qt/QtViewportInteractionEngine.cpp:
(WebKit::QtViewportInteractionEngine::wheelEvent):

Tools:

Patch by Allan Sandfeld Jensen <[email protected]> on 2012-04-18
Reviewed by Simon Hausmann.

Calculate proper wheel-delta from pixel-delta given.

* DumpRenderTree/qt/EventSenderQt.cpp:
(EventSender::EventSender):
(EventSender::mouseScrollBy):
(EventSender::continuousMouseScrollBy):

LayoutTests:

Patch by Allan Sandfeld Jensen <[email protected]> on 2012-04-18
Reviewed by Simon Hausmann.

* platform/qt/fast/events/continuous-platform-wheelevent-in-scrolling-div-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (114545 => 114546)


--- trunk/LayoutTests/ChangeLog	2012-04-18 19:32:16 UTC (rev 114545)
+++ trunk/LayoutTests/ChangeLog	2012-04-18 19:48:34 UTC (rev 114546)
@@ -1,3 +1,12 @@
+2012-04-18  Allan Sandfeld Jensen  <[email protected]>
+
+        Clean-up WheelEvent Conversion.
+        https://bugs.webkit.org/show_bug.cgi?id=84243
+
+        Reviewed by Simon Hausmann.
+
+        * platform/qt/fast/events/continuous-platform-wheelevent-in-scrolling-div-expected.txt:
+
 2012-04-18  Keishi Hattori  <[email protected]>
 
         [chromium] Turn on ENABLE_DATALIST for chromium

Modified: trunk/LayoutTests/platform/qt/fast/events/continuous-platform-wheelevent-in-scrolling-div-expected.txt (114545 => 114546)


--- trunk/LayoutTests/platform/qt/fast/events/continuous-platform-wheelevent-in-scrolling-div-expected.txt	2012-04-18 19:32:16 UTC (rev 114545)
+++ trunk/LayoutTests/platform/qt/fast/events/continuous-platform-wheelevent-in-scrolling-div-expected.txt	2012-04-18 19:48:34 UTC (rev 114546)
@@ -1,9 +1,9 @@
 FAIL event.wheelDeltaY should be -600. Was 0.
-FAIL event.wheelDeltaX should be -300. Was -12000.
-FAIL event.wheelDelta should be -300. Was -12000.
-FAIL event.wheelDeltaY should be -600. Was -24000.
+PASS event.wheelDeltaX is window.expectedScrollLeft*-3
+PASS event.wheelDelta is window.expectedScrollLeft*-3
+PASS event.wheelDeltaY is window.expectedScrollTop*-3
 FAIL event.wheelDeltaX should be -300. Was 0.
-FAIL event.wheelDelta should be -600. Was -24000.
+PASS event.wheelDelta is window.expectedScrollTop*-3
 PASS div.scrollTop is window.expectedScrollTop
 PASS div.scrollLeft is window.expectedScrollLeft
 

Modified: trunk/Source/WebKit/qt/ChangeLog (114545 => 114546)


--- trunk/Source/WebKit/qt/ChangeLog	2012-04-18 19:32:16 UTC (rev 114545)
+++ trunk/Source/WebKit/qt/ChangeLog	2012-04-18 19:48:34 UTC (rev 114546)
@@ -1,3 +1,13 @@
+2012-04-18  Allan Sandfeld Jensen  <[email protected]>
+
+        Clean-up WheelEvent Conversion.
+        https://bugs.webkit.org/show_bug.cgi?id=84243
+
+        Reviewed by Simon Hausmann.
+
+        * WebCoreSupport/WebEventConversion.cpp:
+        (WebCore::WebKitPlatformWheelEvent::applyDelta):
+
 2012-04-13  Tor Arne Vestbø  <[email protected]>
 
         [Qt] Build fix with QT_NO_BEARERMANAGEMENT

Modified: trunk/Source/WebKit/qt/WebCoreSupport/WebEventConversion.cpp (114545 => 114546)


--- trunk/Source/WebKit/qt/WebCoreSupport/WebEventConversion.cpp	2012-04-18 19:32:16 UTC (rev 114545)
+++ trunk/Source/WebKit/qt/WebCoreSupport/WebEventConversion.cpp	2012-04-18 19:48:34 UTC (rev 114546)
@@ -178,27 +178,21 @@
 
 void WebKitPlatformWheelEvent::applyDelta(int delta, Qt::Orientation orientation)
 {
-    // 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);
-
     if (orientation == Qt::Horizontal) {
-        m_deltaX = (fullTick) ? delta / 120.0f : delta;
+        m_deltaX = delta;
         m_deltaY = 0;
     } else {
         m_deltaX = 0;
-        m_deltaY = (fullTick) ? delta / 120.0f : delta;
+        m_deltaY = delta;
     }
+    m_wheelTicksX = m_deltaX / 120.0f;
+    m_wheelTicksY = m_deltaY / 120.0f;
 
-    m_wheelTicksX = m_deltaX;
-    m_wheelTicksY = m_deltaY;
-
-    // Use the same single scroll step as QTextEdit
-    // (in QTextEditPrivate::init [h,v]bar->setSingleStep)
+    // Since we request the scroll delta by the pixel, convert the wheel delta to pixel delta using the standard scroll step.
+    // Use the same single scroll step as QTextEdit (in QTextEditPrivate::init [h,v]bar->setSingleStep)
     static const float cDefaultQtScrollStep = 20.f;
-    m_deltaX *= (fullTick) ? QApplication::wheelScrollLines() * cDefaultQtScrollStep : 1;
-    m_deltaY *= (fullTick) ? QApplication::wheelScrollLines() * cDefaultQtScrollStep : 1;
+    m_deltaX = m_wheelTicksX * QApplication::wheelScrollLines() * cDefaultQtScrollStep;
+    m_deltaY = m_wheelTicksY * QApplication::wheelScrollLines() * cDefaultQtScrollStep;
 }
 
 WebKitPlatformWheelEvent::WebKitPlatformWheelEvent(QGraphicsSceneWheelEvent* e)

Modified: trunk/Source/WebKit2/ChangeLog (114545 => 114546)


--- trunk/Source/WebKit2/ChangeLog	2012-04-18 19:32:16 UTC (rev 114545)
+++ trunk/Source/WebKit2/ChangeLog	2012-04-18 19:48:34 UTC (rev 114546)
@@ -1,3 +1,15 @@
+2012-04-18  Allan Sandfeld Jensen  <[email protected]>
+
+        Clean-up WheelEvent Conversion.
+        https://bugs.webkit.org/show_bug.cgi?id=84243
+
+        Reviewed by Simon Hausmann.
+
+        * Shared/qt/WebEventFactoryQt.cpp:
+        (WebKit::WebEventFactory::createWebWheelEvent):
+        * UIProcess/qt/QtViewportInteractionEngine.cpp:
+        (WebKit::QtViewportInteractionEngine::wheelEvent):
+
 2012-04-18  Zalan Bujtas  <[email protected]>
 
         [Qt][WK2] Minibrowser asserts on startup at QtViewportInteractionEngine::ensureContentWithinViewportBoundary()

Modified: trunk/Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp (114545 => 114546)


--- trunk/Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp	2012-04-18 19:32:16 UTC (rev 114545)
+++ trunk/Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp	2012-04-18 19:48:34 UTC (rev 114546)
@@ -133,26 +133,21 @@
     WebEvent::Modifiers modifiers           = modifiersForEvent(e->modifiers());
     double timestamp                        = currentTimeForEvent(e);
 
-    // 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 = !(e->delta() % 120);
-
     if (e->orientation() == Qt::Horizontal) {
-        deltaX = (fullTick) ? e->delta() / 120.0f : e->delta();
-        wheelTicksX = deltaX;
+        deltaX = e->delta();
+        wheelTicksX = deltaX / 120.0f;
     } else {
-        deltaY = (fullTick) ? e->delta() / 120.0f : e->delta();
-        wheelTicksY = deltaY;
+        deltaY = e->delta();
+        wheelTicksY = deltaY / 120.0f;
     }
 
-    // Use the same single scroll step as QTextEdit
-    // (in QTextEditPrivate::init [h,v]bar->setSingleStep)
+    // Since we report the scroll by the pixel, convert the delta to pixel distance using standard scroll step.
+    // Use the same single scroll step as QTextEdit (in QTextEditPrivate::init [h,v]bar->setSingleStep)
     static const float cDefaultQtScrollStep = 20.f;
     // ### FIXME: Default from QtGui. Should use Qt platform theme API once configurable.
     const int wheelScrollLines = 3;
-    deltaX *= (fullTick) ? wheelScrollLines * cDefaultQtScrollStep : 1;
-    deltaY *= (fullTick) ? wheelScrollLines * cDefaultQtScrollStep : 1;
+    deltaX = wheelTicksX * wheelScrollLines * cDefaultQtScrollStep;
+    deltaY = wheelTicksY * wheelScrollLines * cDefaultQtScrollStep;
 
     return WebWheelEvent(WebEvent::Wheel, fromItemTransform.map(e->posF()).toPoint(), e->globalPosF().toPoint(), FloatSize(deltaX, deltaY), FloatSize(wheelTicksX, wheelTicksY), granularity, modifiers, timestamp);
 }

Modified: trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp (114545 => 114546)


--- trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp	2012-04-18 19:32:16 UTC (rev 114545)
+++ trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp	2012-04-18 19:48:34 UTC (rev 114546)
@@ -253,26 +253,21 @@
     if (scrollAnimationActive() || scaleAnimationActive() || pinchGestureActive())
         return; // Ignore.
 
-    int delta = ev->delta();
 
-    // 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);
-
+    // A normal scroll-tick should have a delta of 120 (1/8) degrees. Convert this to
+    // local standard scroll step of 3 lines of 20 pixels.
     static const int cDefaultQtScrollStep = 20;
     static const int wheelScrollLines = 3;
-    int scrollLines = (fullTick) ? wheelScrollLines * cDefaultQtScrollStep : 1;
+    const int wheelTick = wheelScrollLines * cDefaultQtScrollStep;
 
-    delta = (fullTick) ? delta / 120.0f : delta;
-    delta *= scrollLines;
+    int pixelDelta = ev->delta() * (wheelTick / 120.f);
 
     QPointF newPosition = m_viewport->contentPos();
 
     if (ev->orientation() == Qt::Horizontal)
-        newPosition.rx() -= delta;
+        newPosition.rx() -= pixelDelta;
     else
-        newPosition.ry() -= delta;
+        newPosition.ry() -= pixelDelta;
 
     QRectF endPosRange = computePosRangeForItemAtScale(m_content->contentsScale());
 

Modified: trunk/Tools/ChangeLog (114545 => 114546)


--- trunk/Tools/ChangeLog	2012-04-18 19:32:16 UTC (rev 114545)
+++ trunk/Tools/ChangeLog	2012-04-18 19:48:34 UTC (rev 114546)
@@ -1,3 +1,17 @@
+2012-04-18  Allan Sandfeld Jensen  <[email protected]>
+
+        Clean-up WheelEvent Conversion.
+        https://bugs.webkit.org/show_bug.cgi?id=84243
+
+        Reviewed by Simon Hausmann.
+        
+        Calculate proper wheel-delta from pixel-delta given.
+
+        * DumpRenderTree/qt/EventSenderQt.cpp:
+        (EventSender::EventSender):
+        (EventSender::mouseScrollBy):
+        (EventSender::continuousMouseScrollBy):
+
 2012-04-18  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r114506.

Modified: trunk/Tools/DumpRenderTree/qt/EventSenderQt.cpp (114545 => 114546)


--- trunk/Tools/DumpRenderTree/qt/EventSenderQt.cpp	2012-04-18 19:32:16 UTC (rev 114545)
+++ trunk/Tools/DumpRenderTree/qt/EventSenderQt.cpp	2012-04-18 19:48:34 UTC (rev 114546)
@@ -69,8 +69,8 @@
     m_currentButton = 0;
     resetClickCount();
     m_page->view()->installEventFilter(this);
-    // So that we can match Scrollbar::pixelsPerLineStep() in WheelEventQt.cpp and
-    // pass fast/events/platform-wheelevent-in-scrolling-div.html
+    // This is a hack that works because we normally scroll 60 pixels (3*20) per tick, but Apple scrolls 120.
+    // But Apple also has a bug where they report lines instead of ticks in PlatformWheelEvent, making 2 lines = 40 pixels match.
     QApplication::setWheelScrollLines(2);
 }
 
@@ -199,22 +199,26 @@
 }
 
 #ifndef QT_NO_WHEELEVENT
-void EventSender::mouseScrollBy(int x, int y)
+void EventSender::mouseScrollBy(int ticksX, int ticksY)
 {
-    continuousMouseScrollBy((x*120), (y*120));
+    const int tickStep = QApplication::wheelScrollLines() * 20;
+    continuousMouseScrollBy((ticksX * tickStep), (ticksY * tickStep));
 }
 
 void EventSender::continuousMouseScrollBy(int x, int y)
 {
     // continuousMouseScrollBy() mimics devices that send fine-grained scroll events where the 'delta' specified is not the usual
     // multiple of 120. See http://doc.qt.nokia.com/4.6/qwheelevent.html#delta for a good explanation of this.
+
+    // A wheel delta of 120 (in 1/8 degrees) corresponds to one wheel tick, and we scroll tickStep pixels per wheel tick.
+    const int tickStep = QApplication::wheelScrollLines() * 20;
     if (x) {
         QEvent* event;
         if (isGraphicsBased()) {
             event = createGraphicsSceneWheelEvent(QEvent::GraphicsSceneWheel,
-                        m_mousePos, m_mousePos, x, Qt::NoModifier, Qt::Horizontal);
+                        m_mousePos, m_mousePos, (x * 120) / tickStep, Qt::NoModifier, Qt::Horizontal);
         } else
-            event = new QWheelEvent(m_mousePos, m_mousePos, x, m_mouseButtons, Qt::NoModifier, Qt::Horizontal);
+            event = new QWheelEvent(m_mousePos, m_mousePos, (x * 120) / tickStep, m_mouseButtons, Qt::NoModifier, Qt::Horizontal);
 
         sendOrQueueEvent(event);
     }
@@ -222,9 +226,9 @@
         QEvent* event;
         if (isGraphicsBased()) {
             event = createGraphicsSceneWheelEvent(QEvent::GraphicsSceneWheel,
-                        m_mousePos, m_mousePos, y, Qt::NoModifier, Qt::Vertical);
+                        m_mousePos, m_mousePos, (y * 120) / tickStep, Qt::NoModifier, Qt::Vertical);
         } else
-            event = new QWheelEvent(m_mousePos, m_mousePos, y, m_mouseButtons, Qt::NoModifier, Qt::Vertical);
+            event = new QWheelEvent(m_mousePos, m_mousePos, (y * 120) / tickStep, m_mouseButtons, Qt::NoModifier, Qt::Vertical);
 
         sendOrQueueEvent(event);
     }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to