[Qt] Page doesn't get repainted while panning is in progress https://bugs.webkit...
authorkenneth@webkit.org <kenneth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Feb 2012 15:10:30 +0000 (15:10 +0000)
committerkenneth@webkit.org <kenneth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Feb 2012 15:10:30 +0000 (15:10 +0000)
Reviewed by Simon Hausmann.

The tiling code needed the current visibleContentsRect in order to be
able to create tiles, so we now make sure it gets it. We also needed
to make sure to set the trajectory vector while panning and while the
flicking engine was animating kinetic scrolling.

* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewFlickablePrivate::_q_updateVisibleContentRectAndScale):
(QQuickWebViewPrivate::_q_viewportTrajectoryVectorChanged):
* UIProcess/DrawingAreaProxy.h:
(WebKit::DrawingAreaProxy::setVisibleContentRectTrajectoryVector):
* UIProcess/DrawingAreaProxyImpl.cpp:
(WebKit::DrawingAreaProxyImpl::setVisibleContentRectTrajectoryVector):
* UIProcess/DrawingAreaProxyImpl.h:
(DrawingAreaProxyImpl):
* UIProcess/LayerTreeHostProxy.h:
(LayerTreeHostProxy):
* UIProcess/qt/LayerTreeHostProxyQt.cpp:
(WebKit::LayerTreeHostProxy::setVisibleContentRectTrajectoryVector):
* UIProcess/qt/QtViewportInteractionEngine.cpp:
(WebKit::QtViewportInteractionEngine::QtViewportInteractionEngine):
(WebKit::QtViewportInteractionEngine::flickableMovingStateChanged):
(WebKit):
(WebKit::QtViewportInteractionEngine::panMoveStarted):
(WebKit::QtViewportInteractionEngine::panMoveEnded):
(WebKit::QtViewportInteractionEngine::flickableMovingPositionUpdate):
(WebKit::QtViewportInteractionEngine::panGestureRequestUpdate):
* UIProcess/qt/QtViewportInteractionEngine.h:
(QtViewportInteractionEngine):
* WebProcess/WebPage/LayerTreeHost.h:
(WebKit::LayerTreeHost::setVisibleContentRectTrajectoryVector):
* WebProcess/WebPage/LayerTreeHost.messages.in:
* WebProcess/WebPage/qt/LayerTreeHostQt.cpp:
(WebKit::LayerTreeHostQt::setVisibleContentRectAndScale):
(WebKit::LayerTreeHostQt::setVisibleContentRectTrajectoryVector):
* WebProcess/WebPage/qt/LayerTreeHostQt.h:
(LayerTreeHostQt):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@108625 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
Source/WebKit2/UIProcess/DrawingAreaProxy.h
Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp
Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h
Source/WebKit2/UIProcess/LayerTreeHostProxy.h
Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp
Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp
Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h
Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h
Source/WebKit2/WebProcess/WebPage/LayerTreeHost.messages.in
Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp
Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h

index d74d8f4..96df3db 100644 (file)
@@ -1,3 +1,47 @@
+2012-02-23  Kenneth Rohde Christiansen  <kenneth@webkit.org>
+
+        [Qt] Page doesn't get repainted while panning is in progress
+        https://bugs.webkit.org/show_bug.cgi?id=78602
+
+        Reviewed by Simon Hausmann.
+
+        The tiling code needed the current visibleContentsRect in order to be
+        able to create tiles, so we now make sure it gets it. We also needed
+        to make sure to set the trajectory vector while panning and while the
+        flicking engine was animating kinetic scrolling.
+
+        * UIProcess/API/qt/qquickwebview.cpp:
+        (QQuickWebViewFlickablePrivate::_q_updateVisibleContentRectAndScale):
+        (QQuickWebViewPrivate::_q_viewportTrajectoryVectorChanged):
+        * UIProcess/DrawingAreaProxy.h:
+        (WebKit::DrawingAreaProxy::setVisibleContentRectTrajectoryVector):
+        * UIProcess/DrawingAreaProxyImpl.cpp:
+        (WebKit::DrawingAreaProxyImpl::setVisibleContentRectTrajectoryVector):
+        * UIProcess/DrawingAreaProxyImpl.h:
+        (DrawingAreaProxyImpl):
+        * UIProcess/LayerTreeHostProxy.h:
+        (LayerTreeHostProxy):
+        * UIProcess/qt/LayerTreeHostProxyQt.cpp:
+        (WebKit::LayerTreeHostProxy::setVisibleContentRectTrajectoryVector):
+        * UIProcess/qt/QtViewportInteractionEngine.cpp:
+        (WebKit::QtViewportInteractionEngine::QtViewportInteractionEngine):
+        (WebKit::QtViewportInteractionEngine::flickableMovingStateChanged):
+        (WebKit):
+        (WebKit::QtViewportInteractionEngine::panMoveStarted):
+        (WebKit::QtViewportInteractionEngine::panMoveEnded):
+        (WebKit::QtViewportInteractionEngine::flickableMovingPositionUpdate):
+        (WebKit::QtViewportInteractionEngine::panGestureRequestUpdate):
+        * UIProcess/qt/QtViewportInteractionEngine.h:
+        (QtViewportInteractionEngine):
+        * WebProcess/WebPage/LayerTreeHost.h:
+        (WebKit::LayerTreeHost::setVisibleContentRectTrajectoryVector):
+        * WebProcess/WebPage/LayerTreeHost.messages.in:
+        * WebProcess/WebPage/qt/LayerTreeHostQt.cpp:
+        (WebKit::LayerTreeHostQt::setVisibleContentRectAndScale):
+        (WebKit::LayerTreeHostQt::setVisibleContentRectTrajectoryVector):
+        * WebProcess/WebPage/qt/LayerTreeHostQt.h:
+        (LayerTreeHostQt):
+
 2012-02-23  Patrick Gansterer  <paroga@webkit.org>
 
         [CMAKE][WK2] Cleanup WebKit2/CMakeLists.txt.
index 39c916d..42e1b48 100644 (file)
@@ -212,14 +212,6 @@ void QQuickWebViewPrivate::handleDownloadRequest(DownloadProxy* download)
     context->downloadManager()->addDownload(download, downloadItem);
 }
 
-void QQuickWebViewPrivate::_q_viewportTrajectoryVectorChanged(const QPointF& trajectoryVector)
-{
-    DrawingAreaProxy* drawingArea = webPageProxy->drawingArea();
-    if (!drawingArea)
-        return;
-    drawingArea->setVisibleContentRectTrajectoryVector(trajectoryVector);
-}
-
 void QQuickWebViewPrivate::_q_onVisibleChanged()
 {
     webPageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
@@ -620,12 +612,27 @@ void QQuickWebViewFlickablePrivate::_q_updateVisibleContentRectAndScale()
     const QRectF visibleRectInCSSCoordinates = q->mapRectToWebContent(q->boundingRect()).intersected(pageView->boundingRect());
     float scale = pageView->contentsScale();
 
+    // This is only for our QML ViewportInfo debugging API.
+    q->experimental()->viewportInfo()->didUpdateCurrentScale();
+
     QRect alignedVisibleContentRect = visibleRectInCSSCoordinates.toAlignedRect();
     drawingArea->setVisibleContentsRectAndScale(alignedVisibleContentRect, scale);
 
     // FIXME: Once we support suspend and resume, this should be delayed until the page is active if the page is suspended.
     webPageProxy->setFixedVisibleContentRect(alignedVisibleContentRect);
-    q->experimental()->viewportInfo()->didUpdateCurrentScale();
+}
+
+void QQuickWebViewPrivate::_q_viewportTrajectoryVectorChanged(const QPointF& trajectoryVector)
+{
+    DrawingAreaProxy* drawingArea = webPageProxy->drawingArea();
+    if (!drawingArea)
+        return;
+
+    Q_Q(QQuickWebView);
+    const QRectF visibleRectInCSSCoordinates = q->mapRectToWebContent(q->boundingRect()).intersected(pageView->boundingRect());
+
+    QRect alignedVisibleContentRect = visibleRectInCSSCoordinates.toAlignedRect();
+    drawingArea->setVisibleContentRectTrajectoryVector(alignedVisibleContentRect, trajectoryVector);
 }
 
 void QQuickWebViewFlickablePrivate::_q_suspend()
index c5b713c..77295a9 100644 (file)
@@ -94,7 +94,7 @@ public:
 
 #if USE(TILED_BACKING_STORE)
     virtual void setVisibleContentsRectAndScale(const WebCore::IntRect& visibleContentsRect, float scale) { }
-    virtual void setVisibleContentRectTrajectoryVector(const WebCore::FloatPoint&) { }
+    virtual void setVisibleContentRectTrajectoryVector(const WebCore::IntRect& visibleContentsRect, const WebCore::FloatPoint& trajectoryVector) { }
     virtual void createTileForLayer(int layerID, int tileID, const WebKit::UpdateInfo&) { }
     virtual void updateTileForLayer(int layerID, int tileID, const WebKit::UpdateInfo&) { }
     virtual void removeTileForLayer(int layerID, int tileID) { }
index 24a5aed..bedd8c6 100644 (file)
@@ -354,10 +354,10 @@ void DrawingAreaProxyImpl::setVisibleContentsRectAndScale(const WebCore::IntRect
         m_layerTreeHostProxy->setVisibleContentsRectAndScale(visibleContentsRect, scale);
 }
 
-void DrawingAreaProxyImpl::setVisibleContentRectTrajectoryVector(const WebCore::FloatPoint& trajectoryVector)
+void DrawingAreaProxyImpl::setVisibleContentRectTrajectoryVector(const WebCore::IntRect& visibleContentsRect, const WebCore::FloatPoint& trajectoryVector)
 {
     if (m_layerTreeHostProxy)
-        m_layerTreeHostProxy->setVisibleContentRectTrajectoryVector(trajectoryVector);
+        m_layerTreeHostProxy->setVisibleContentRectTrajectoryVector(visibleContentsRect, trajectoryVector);
 }
 
 void DrawingAreaProxyImpl::paintLayerTree(BackingStore::PlatformGraphicsContext context)
index 5fcf24c..335abd1 100644 (file)
@@ -79,7 +79,7 @@ private:
 
 #if USE(TILED_BACKING_STORE)
     virtual void setVisibleContentsRectAndScale(const WebCore::IntRect& visibleContentsRect, float scale);
-    virtual void setVisibleContentRectTrajectoryVector(const WebCore::FloatPoint&);
+    virtual void setVisibleContentRectTrajectoryVector(const WebCore::IntRect& visibleContentsRect, const WebCore::FloatPoint&);
     virtual void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float opacity, const WebCore::FloatRect&);
     virtual void paintLayerTree(BackingStore::PlatformGraphicsContext);
     void didReceiveLayerTreeHostProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
index 808f80f..2d170db 100644 (file)
@@ -58,7 +58,7 @@ public:
     void paintToGraphicsContext(BackingStore::PlatformGraphicsContext);
     void purgeGLResources();
     void setVisibleContentsRectAndScale(const WebCore::IntRect&, float);
-    void setVisibleContentRectTrajectoryVector(const WebCore::FloatPoint&);
+    void setVisibleContentRectTrajectoryVector(const WebCore::IntRect&, const WebCore::FloatPoint&);
 #if USE(TILED_BACKING_STORE)
     void syncRemoteContent();
     void swapContentBuffers();
index 5fd62a4..ecb46a6 100644 (file)
@@ -563,9 +563,9 @@ void LayerTreeHostProxy::destroyDirectlyCompositedImage(int64_t key)
     pushUpdateToQueue(DestroyImageMessage::create(data));
 }
 
-void LayerTreeHostProxy::setVisibleContentRectTrajectoryVector(const FloatPoint& trajectoryVector)
+void LayerTreeHostProxy::setVisibleContentRectTrajectoryVector(const IntRect& rect, const FloatPoint& trajectoryVector)
 {
-    m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::SetVisibleContentRectTrajectoryVector(trajectoryVector), m_drawingAreaProxy->page()->pageID());
+    m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::SetVisibleContentRectTrajectoryVector(rect, trajectoryVector), m_drawingAreaProxy->page()->pageID());
 }
 
 void LayerTreeHostProxy::setVisibleContentsRectAndScale(const IntRect& rect, float scale)
index 7319b7e..b886f3c 100644 (file)
@@ -125,7 +125,7 @@ QtViewportInteractionEngine::QtViewportInteractionEngine(QQuickWebView* viewport
 
     connect(m_content, SIGNAL(widthChanged()), SLOT(itemSizeChanged()), Qt::DirectConnection);
     connect(m_content, SIGNAL(heightChanged()), SLOT(itemSizeChanged()), Qt::DirectConnection);
-    connect(m_flickProvider, SIGNAL(movingChanged()), SLOT(scrollStateChanged()), Qt::DirectConnection);
+    connect(m_flickProvider, SIGNAL(movingChanged()), SLOT(flickableMovingStateChanged()), Qt::DirectConnection);
 
     connect(m_scaleAnimation, SIGNAL(valueChanged(QVariant)),
             SLOT(scaleAnimationValueChanged(QVariant)), Qt::DirectConnection);
@@ -187,12 +187,42 @@ bool QtViewportInteractionEngine::animateItemRectVisible(const QRectF& itemRect)
     return true;
 }
 
-void QtViewportInteractionEngine::scrollStateChanged()
+void QtViewportInteractionEngine::flickableMovingStateChanged()
 {
-    if (m_flickProvider->isMoving() && !m_scrollUpdateDeferrer)
-        m_scrollUpdateDeferrer = adoptPtr(new ViewportUpdateDeferrer(this));
-    else
-        m_scrollUpdateDeferrer.clear();
+    if (m_flickProvider->isMoving()) {
+        if (m_scrollUpdateDeferrer)
+            return; // We get the isMoving() signal multiple times.
+        panMoveStarted();
+    } else
+        panMoveEnded();
+}
+
+void QtViewportInteractionEngine::panMoveStarted()
+{
+    m_scrollUpdateDeferrer = adoptPtr(new ViewportUpdateDeferrer(this));
+
+    m_lastScrollPosition = m_flickProvider->contentPos();
+    connect(m_flickProvider, SIGNAL(contentXChanged()), SLOT(flickableMovingPositionUpdate()));
+    connect(m_flickProvider, SIGNAL(contentYChanged()), SLOT(flickableMovingPositionUpdate()));
+}
+
+void QtViewportInteractionEngine::panMoveEnded()
+{
+    // This method is called on the end of the pan or pan kinetic animation.
+    m_scrollUpdateDeferrer.clear();
+
+    m_lastScrollPosition = QPointF();
+    disconnect(m_flickProvider, SIGNAL(contentXChanged()), this, SLOT(flickableMovingPositionUpdate()));
+    disconnect(m_flickProvider, SIGNAL(contentYChanged()), this, SLOT(flickableMovingPositionUpdate()));
+}
+
+void QtViewportInteractionEngine::flickableMovingPositionUpdate()
+{
+    QPointF newPosition = m_flickProvider->contentPos();
+
+    emit viewportTrajectoryVectorChanged(m_lastScrollPosition - newPosition);
+
+    m_lastScrollPosition = newPosition;
 }
 
 void QtViewportInteractionEngine::scaleAnimationStateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State /*oldState*/)
@@ -427,12 +457,8 @@ void QtViewportInteractionEngine::panGestureRequestUpdate(const QTouchEvent* eve
 {
     ASSERT(event->type() == QEvent::TouchUpdate);
 
-    QPointF viewportPosition = event->touchPoints().first().pos();
-
-    emit viewportTrajectoryVectorChanged(m_lastPinchCenterInViewportCoordinates - viewportPosition);
-
     m_flickProvider->handleTouchFlickEvent(const_cast<QTouchEvent*>(event));
-    m_lastPinchCenterInViewportCoordinates = viewportPosition;
+    m_lastPinchCenterInViewportCoordinates = event->touchPoints().first().pos();
 }
 
 void QtViewportInteractionEngine::panGestureCancelled()
index fd9d84b..c0baa60 100644 (file)
@@ -110,7 +110,9 @@ private Q_SLOTS:
     // Respond to changes of content that are not driven by us, like the page resizing itself.
     void itemSizeChanged();
 
-    void scrollStateChanged();
+    void flickableMovingStateChanged();
+    void flickableMovingPositionUpdate();
+
     void scaleAnimationStateChanged(QAbstractAnimation::State, QAbstractAnimation::State);
     void scaleAnimationValueChanged(QVariant value) { setItemRectVisible(value.toRectF()); }
 
@@ -125,6 +127,9 @@ private:
     qreal innerBoundedCSSScale(qreal);
     qreal outerBoundedCSSScale(qreal);
 
+    void panMoveStarted(); // Called when panning starts.
+    void panMoveEnded(); //   Called when panning (+ kinetic animation) ends.
+
     QRectF computePosRangeForItemAtScale(qreal itemScale) const;
     bool ensureContentWithinViewportBoundary(bool immediate = false);
 
@@ -154,6 +159,7 @@ private:
 
     ScaleAnimation* m_scaleAnimation;
     QPointF m_lastPinchCenterInViewportCoordinates;
+    QPointF m_lastScrollPosition;
     qreal m_pinchStartScale;
 };
 
index 61fbe2f..4f81756 100644 (file)
@@ -81,7 +81,7 @@ public:
 
 #if USE(TILED_BACKING_STORE)
     virtual void setVisibleContentRectAndScale(const WebCore::IntRect&, float scale) { }
-    virtual void setVisibleContentRectTrajectoryVector(const WebCore::FloatPoint&) { }
+    virtual void setVisibleContentRectTrajectoryVector(const WebCore::IntRect&, const WebCore::FloatPoint&) { }
     virtual void setVisibleContentRectForLayer(int layerID, const WebCore::IntRect&) { }
     virtual void renderNextFrame() { }
     virtual void purgeBackingStores() { }
index 4ee1cc3..4247eee 100644 (file)
@@ -20,8 +20,8 @@
 
 #if USE(TILED_BACKING_STORE)
 messages -> LayerTreeHost {
-    SetVisibleContentRectTrajectoryVector(WebCore::FloatPoint trajectoryVectory)
-    SetVisibleContentRectAndScale(WebCore::IntRect contentRect, float scale)
+    SetVisibleContentRectTrajectoryVector(WebCore::IntRect visibleContentsRect, WebCore::FloatPoint trajectoryVectory)
+    SetVisibleContentRectAndScale(WebCore::IntRect visibleContentsRect, float scale)
     RenderNextFrame()
     PurgeBackingStores()
 }
index 48f0b11..5034653 100644 (file)
@@ -420,8 +420,6 @@ WebCore::IntRect LayerTreeHostQt::visibleContentsRect() const
 
 void LayerTreeHostQt::setVisibleContentRectAndScale(const IntRect& rect, float scale)
 {
-    if (rect == m_visibleContentsRect && scale == m_contentsScale)
-        return;
     m_visibleContentsRect = rect;
     m_contentsScale = scale;
 
@@ -433,9 +431,13 @@ void LayerTreeHostQt::setVisibleContentRectAndScale(const IntRect& rect, float s
     scheduleLayerFlush();
 }
 
-void LayerTreeHostQt::setVisibleContentRectTrajectoryVector(const FloatPoint& trajectoryVector)
+void LayerTreeHostQt::setVisibleContentRectTrajectoryVector(const IntRect& rect, const FloatPoint& trajectoryVector)
 {
+    m_visibleContentsRect = rect;
+
     toWebGraphicsLayer(m_nonCompositedContentLayer.get())->setVisibleContentRectTrajectoryVector(trajectoryVector);
+
+    scheduleLayerFlush();
 }
 
 void LayerTreeHostQt::renderNextFrame()
index 590a441..a8627b5 100644 (file)
@@ -74,7 +74,7 @@ public:
     virtual void purgeBackingStores();
     virtual bool layerTreeTileUpdatesAllowed() const;
     virtual void setVisibleContentRectAndScale(const WebCore::IntRect&, float scale);
-    virtual void setVisibleContentRectTrajectoryVector(const WebCore::FloatPoint&);
+    virtual void setVisibleContentRectTrajectoryVector(const WebCore::IntRect&, const WebCore::FloatPoint&);
     virtual void didSyncCompositingStateForLayer(const WebLayerInfo&);
     virtual void attachLayer(WebCore::WebGraphicsLayer*);
     virtual void detachLayer(WebCore::WebGraphicsLayer*);