Title: [117069] trunk/Source
Revision
117069
Author
[email protected]
Date
2012-05-15 08:07:59 -0700 (Tue, 15 May 2012)

Log Message

[Qt][WK2] Fix scrolling in touch mode
https://bugs.webkit.org/show_bug.cgi?id=75006

Patch by Allan Sandfeld Jensen <[email protected]> on 2012-05-15
Reviewed by Kenneth Rohde Christiansen.

Source/WebCore:

* page/FrameView.cpp:
(WebCore::FrameView::setFixedVisibleContentRect):
    On changes to fixedVisibleContentRect update scroll-animators position, and
    recalculate page-step sizes in scrollbars.
* platform/ScrollView.cpp:
(WebCore::ScrollView::scrollTo):
    Forward scrolling-request to the host window.
(WebCore::ScrollView::updateScrollbars):
    Allow ScrollViews to have invisible scrollbars when scrolling is delegated.
* platform/ScrollView.h:
(ScrollView):

Source/WebKit2:

Only handle mouse-wheel events in WebCore to avoid double scrolling, and
scale pixels scrolled by wheel events according to viewport transformation.

* Shared/qt/WebEventFactoryQt.cpp:
(WebKit::WebEventFactory::createWebWheelEvent):
* UIProcess/qt/QtViewportInteractionEngine.cpp:
* UIProcess/qt/QtViewportInteractionEngine.h:
(QtViewportInteractionEngine):
* UIProcess/qt/QtWebPageEventHandler.cpp:
(QtWebPageEventHandler::handleWheelEvent):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (117068 => 117069)


--- trunk/Source/WebCore/ChangeLog	2012-05-15 14:57:56 UTC (rev 117068)
+++ trunk/Source/WebCore/ChangeLog	2012-05-15 15:07:59 UTC (rev 117069)
@@ -1,3 +1,22 @@
+2012-05-15  Allan Sandfeld Jensen  <[email protected]>
+
+        [Qt][WK2] Fix scrolling in touch mode
+        https://bugs.webkit.org/show_bug.cgi?id=75006
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::setFixedVisibleContentRect):
+            On changes to fixedVisibleContentRect update scroll-animators position, and
+            recalculate page-step sizes in scrollbars.
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::scrollTo):
+            Forward scrolling-request to the host window.
+        (WebCore::ScrollView::updateScrollbars):
+            Allow ScrollViews to have invisible scrollbars when scrolling is delegated.
+        * platform/ScrollView.h:
+        (ScrollView):
+
 2012-05-15  Vsevolod Vlasov  <[email protected]>
 
         Web Inspector: Refactor SnippetsModel: extract SnippetStorage, make SnippetScriptMapping delegate calls to ScriptSnippetModel and provide public interface on ScriptSnippetModel in terms of uiSourceCodes

Modified: trunk/Source/WebCore/page/FrameView.cpp (117068 => 117069)


--- trunk/Source/WebCore/page/FrameView.cpp	2012-05-15 14:57:56 UTC (rev 117068)
+++ trunk/Source/WebCore/page/FrameView.cpp	2012-05-15 15:07:59 UTC (rev 117069)
@@ -1722,11 +1722,13 @@
 
 void FrameView::setFixedVisibleContentRect(const IntRect& visibleContentRect)
 {
+    bool visibleContentSizeDidChange = false;
     if (visibleContentRect.size() != this->fixedVisibleContentRect().size()) {
         // When the viewport size changes or the content is scaled, we need to
         // reposition the fixed positioned elements.
         if (RenderView* root = rootRenderer(this))
             root->setFixedPositionedObjectsNeedLayout();
+        visibleContentSizeDidChange = true;
     }
 
     IntSize offset = scrollOffset();
@@ -1734,8 +1736,13 @@
     if (offset != scrollOffset()) {
         if (m_frame->page()->settings()->acceleratedCompositingForFixedPositionEnabled())
             updateFixedElementsAfterScrolling();
+        scrollAnimator()->setCurrentPosition(scrollPosition());
         scrollPositionChanged();
     }
+    if (visibleContentSizeDidChange) {
+        // Update the scroll-bars to calculate new page-step size.
+        updateScrollbars(scrollOffset());
+    }
     frame()->loader()->client()->didChangeScrollOffset();
 }
 

Modified: trunk/Source/WebCore/platform/ScrollView.cpp (117068 => 117069)


--- trunk/Source/WebCore/platform/ScrollView.cpp	2012-05-15 14:57:56 UTC (rev 117068)
+++ trunk/Source/WebCore/platform/ScrollView.cpp	2012-05-15 15:07:59 UTC (rev 117069)
@@ -371,6 +371,12 @@
         return;
 
     repaintFixedElementsAfterScrolling();
+#if USE(TILED_BACKING_STORE)
+    if (delegatesScrolling()) {
+        hostWindow()->delegatedScrollRequested(IntPoint(newOffset));
+        return;
+    }
+#endif
     scrollContents(scrollDelta);
     updateFixedElementsAfterScrolling();
 }
@@ -453,7 +459,7 @@
 
 void ScrollView::updateScrollbars(const IntSize& desiredOffset)
 {
-    if (m_inUpdateScrollbars || prohibitsScrolling() || delegatesScrolling() || platformWidget())
+    if (m_inUpdateScrollbars || prohibitsScrolling() || platformWidget())
         return;
 
     // If we came in here with the view already needing a layout, then go ahead and do that

Modified: trunk/Source/WebCore/platform/ScrollView.h (117068 => 117069)


--- trunk/Source/WebCore/platform/ScrollView.h	2012-05-15 14:57:56 UTC (rev 117068)
+++ trunk/Source/WebCore/platform/ScrollView.h	2012-05-15 15:07:59 UTC (rev 117069)
@@ -313,6 +313,9 @@
     virtual bool isVerticalDocument() const { return true; }
     virtual bool isFlippedDocument() const { return false; }
 
+    // Called to update the scrollbars to accurately reflect the state of the view.
+    void updateScrollbars(const IntSize& desiredOffset);
+
 private:
     RefPtr<Scrollbar> m_horizontalScrollbar;
     RefPtr<Scrollbar> m_verticalScrollbar;
@@ -355,8 +358,6 @@
     void init();
     void destroy();
 
-    // Called to update the scrollbars to accurately reflect the state of the view.
-    void updateScrollbars(const IntSize& desiredOffset);
     IntRect rectToCopyOnScroll() const;
 
     // Called when the scroll position within this view changes.  FrameView overrides this to generate repaint invalidations.

Modified: trunk/Source/WebKit2/ChangeLog (117068 => 117069)


--- trunk/Source/WebKit2/ChangeLog	2012-05-15 14:57:56 UTC (rev 117068)
+++ trunk/Source/WebKit2/ChangeLog	2012-05-15 15:07:59 UTC (rev 117069)
@@ -1,3 +1,21 @@
+2012-05-15  Allan Sandfeld Jensen  <[email protected]>
+
+        [Qt][WK2] Fix scrolling in touch mode
+        https://bugs.webkit.org/show_bug.cgi?id=75006
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Only handle mouse-wheel events in WebCore to avoid double scrolling, and
+        scale pixels scrolled by wheel events according to viewport transformation.
+
+        * Shared/qt/WebEventFactoryQt.cpp:
+        (WebKit::WebEventFactory::createWebWheelEvent):
+        * UIProcess/qt/QtViewportInteractionEngine.cpp:
+        * UIProcess/qt/QtViewportInteractionEngine.h:
+        (QtViewportInteractionEngine):
+        * UIProcess/qt/QtWebPageEventHandler.cpp:
+        (QtWebPageEventHandler::handleWheelEvent):
+
 2012-05-15  Kenneth Rohde Christiansen  <[email protected]>
 
         [Qt] Add infra for testing double-tap to zoom functionality etc

Modified: trunk/Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp (117068 => 117069)


--- trunk/Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp	2012-05-15 14:57:56 UTC (rev 117068)
+++ trunk/Source/WebKit2/Shared/qt/WebEventFactoryQt.cpp	2012-05-15 15:07:59 UTC (rev 117069)
@@ -27,9 +27,11 @@
 #include "config.h"
 #include "WebEventFactoryQt.h"
 #include <QKeyEvent>
+#include <QLineF>
 #include <QTransform>
+#include <WebCore/FloatPoint.h>
+#include <WebCore/FloatSize.h>
 #include <WebCore/IntPoint.h>
-#include <WebCore/FloatPoint.h>
 #include <WebCore/PlatformKeyboardEvent.h>
 #include <wtf/ASCIICType.h>
 #include <wtf/CurrentTime.h>
@@ -149,7 +151,13 @@
     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);
+    // Transform the position and the pixel scrolling distance.
+    QLineF transformedScroll = fromItemTransform.map(QLineF(e->posF(), e->posF() + QPointF(deltaX, deltaY)));
+    IntPoint transformedPoint = transformedScroll.p1().toPoint();
+    IntPoint globalPoint = e->globalPosF().toPoint();
+    FloatSize transformedDelta(transformedScroll.dx(), transformedScroll.dy());
+    FloatSize wheelTicks(wheelTicksX, wheelTicksY);
+    return WebWheelEvent(WebEvent::Wheel, transformedPoint, globalPoint, transformedDelta, wheelTicks, granularity, modifiers, timestamp);
 }
 
 WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(QKeyEvent* event)

Modified: trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp (117068 => 117069)


--- trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp	2012-05-15 14:57:56 UTC (rev 117068)
+++ trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp	2012-05-15 15:07:59 UTC (rev 117069)
@@ -261,36 +261,6 @@
                    qBound(minPosition.y(), position.y(), maxPosition.y()));
 }
 
-void QtViewportInteractionEngine::wheelEvent(QWheelEvent* ev)
-{
-    if (scrollAnimationActive() || scaleAnimationActive() || pinchGestureActive())
-        return; // Ignore.
-
-
-    // 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;
-    const int wheelTick = wheelScrollLines * cDefaultQtScrollStep;
-
-    int pixelDelta = ev->delta() * (wheelTick / 120.f);
-
-    QPointF newPosition = m_viewport->contentPos();
-
-    if (ev->orientation() == Qt::Horizontal)
-        newPosition.rx() -= pixelDelta;
-    else
-        newPosition.ry() -= pixelDelta;
-
-    QRectF endPosRange = computePosRangeForItemAtScale(m_content->contentsScale());
-
-    QPointF currentPosition = m_viewport->contentPos();
-    newPosition = boundPosition(endPosRange.topLeft(), newPosition, endPosRange.bottomRight());
-    m_viewport->setContentPos(newPosition);
-
-    emit contentViewportChanged(currentPosition - newPosition);
-}
-
 void QtViewportInteractionEngine::pagePositionRequest(const QPoint& pagePosition)
 {
     // Ignore the request if suspended. Can only happen due to delay in event delivery.

Modified: trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h (117068 => 117069)


--- trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h	2012-05-15 14:57:56 UTC (rev 117068)
+++ trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h	2012-05-15 15:07:59 UTC (rev 117069)
@@ -65,7 +65,6 @@
     void setItemRectVisible(const QRectF&);
     bool animateItemRectVisible(const QRectF&);
 
-    void wheelEvent(QWheelEvent*);
     void pagePositionRequest(const QPoint& pos);
     void touchBegin();
     void touchEnd();

Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp (117068 => 117069)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp	2012-05-15 14:57:56 UTC (rev 117068)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp	2012-05-15 15:07:59 UTC (rev 117069)
@@ -154,9 +154,6 @@
 {
     QTransform fromItemTransform = m_webPage->transformFromItem();
     m_webPageProxy->handleWheelEvent(NativeWebWheelEvent(ev, fromItemTransform));
-    // FIXME: Handle whether the page used the wheel event or not.
-    if (m_interactionEngine)
-        m_interactionEngine->wheelEvent(ev);
 }
 
 void QtWebPageEventHandler::handleHoverLeaveEvent(QHoverEvent* ev)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to