[Qt] Prevent the PageViewportController from affecting the viewport in desktop mode
authorjocelyn.turcotte@digia.com <jocelyn.turcotte@digia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Oct 2012 10:41:27 +0000 (10:41 +0000)
committerjocelyn.turcotte@digia.com <jocelyn.turcotte@digia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Oct 2012 10:41:27 +0000 (10:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=98427

Reviewed by Kenneth Rohde Christiansen.

QQuickFlickable isn't tightly bound to it anymore, we can avoid creating it
completely in this case.

* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewFlickablePrivate::onComponentComplete):
* UIProcess/API/qt/qquickwebview_p_p.h:
(QQuickWebViewPrivate::onComponentComplete):
(QQuickWebViewPrivate::viewportController):
(QQuickWebViewPrivate):
(QQuickWebViewFlickablePrivate::viewportController):
(QQuickWebViewFlickablePrivate):
* UIProcess/qt/QtPageClient.cpp:
(WebKit::QtPageClient::didRenderFrame):
(WebKit::QtPageClient::didChangeContentsSize):
(WebKit::QtPageClient::pageTransitionViewportReady):
* UIProcess/qt/QtWebPageLoadClient.cpp:
(WebKit::QtWebPageLoadClient::didCommitLoad):

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
Source/WebKit2/UIProcess/qt/QtPageClient.cpp
Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.cpp

index e002d0b..0b81c2c 100644 (file)
@@ -1,5 +1,30 @@
 2012-10-04  Jocelyn Turcotte  <jocelyn.turcotte@digia.com>
 
+        [Qt] Prevent the PageViewportController from affecting the viewport in desktop mode
+        https://bugs.webkit.org/show_bug.cgi?id=98427
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        QQuickFlickable isn't tightly bound to it anymore, we can avoid creating it
+        completely in this case.
+
+        * UIProcess/API/qt/qquickwebview.cpp:
+        (QQuickWebViewFlickablePrivate::onComponentComplete):
+        * UIProcess/API/qt/qquickwebview_p_p.h:
+        (QQuickWebViewPrivate::onComponentComplete):
+        (QQuickWebViewPrivate::viewportController):
+        (QQuickWebViewPrivate):
+        (QQuickWebViewFlickablePrivate::viewportController):
+        (QQuickWebViewFlickablePrivate):
+        * UIProcess/qt/QtPageClient.cpp:
+        (WebKit::QtPageClient::didRenderFrame):
+        (WebKit::QtPageClient::didChangeContentsSize):
+        (WebKit::QtPageClient::pageTransitionViewportReady):
+        * UIProcess/qt/QtWebPageLoadClient.cpp:
+        (WebKit::QtWebPageLoadClient::didCommitLoad):
+
+2012-10-04  Jocelyn Turcotte  <jocelyn.turcotte@digia.com>
+
         [Qt] Fix a QSocketNotifier warning at startup
         https://bugs.webkit.org/show_bug.cgi?id=98411
 
index 3387ce3..46df862 100644 (file)
@@ -331,14 +331,6 @@ void QQuickWebViewPrivate::loadDidStop()
     emit q->loadingChanged(&loadRequest);
 }
 
-void QQuickWebViewPrivate::onComponentComplete()
-{
-    Q_Q(QQuickWebView);
-    m_pageViewportControllerClient.reset(new PageViewportControllerClientQt(q, pageView.data()));
-    m_pageViewportController.reset(new PageViewportController(webPageProxy.get(), m_pageViewportControllerClient.data()));
-    pageView->eventHandler()->setViewportController(m_pageViewportControllerClient.data());
-}
-
 void QQuickWebViewPrivate::setTransparentBackground(bool enable)
 {
     webPageProxy->setDrawsTransparentBackground(enable);
@@ -861,6 +853,11 @@ void QQuickWebViewFlickablePrivate::onComponentComplete()
 {
     QQuickWebViewPrivate::onComponentComplete();
 
+    Q_Q(QQuickWebView);
+    m_pageViewportControllerClient.reset(new PageViewportControllerClientQt(q, pageView.data()));
+    m_pageViewportController.reset(new PageViewportController(webPageProxy.get(), m_pageViewportControllerClient.data()));
+    pageView->eventHandler()->setViewportController(m_pageViewportControllerClient.data());
+
     // Trigger setting of correct visibility flags after everything was allocated and initialized.
     _q_onVisibleChanged();
 }
index 65a51fc..15bf818 100644 (file)
@@ -70,7 +70,7 @@ public:
 
     virtual void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0);
 
-    virtual void onComponentComplete();
+    virtual void onComponentComplete() { }
 
     virtual void provisionalLoadDidStart(const WTF::String& url);
     virtual void didReceiveServerRedirectForProvisionalLoad(const WTF::String& url);
@@ -90,7 +90,7 @@ public:
     void setNeedsDisplay();
     void didRenderFrame();
 
-    WebKit::PageViewportController* viewportController() const { return m_pageViewportController.data(); }
+    virtual WebKit::PageViewportController* viewportController() const { return 0; }
     virtual void updateViewportSize() { }
     void updateTouchViewportSize();
 
@@ -172,9 +172,6 @@ protected:
     QScopedPointer<QQuickWebPage> pageView;
     QQuickWebView* q_ptr;
 
-    QScopedPointer<WebKit::PageViewportController> m_pageViewportController;
-    QScopedPointer<WebKit::PageViewportControllerClientQt> m_pageViewportControllerClient;
-
     FlickableAxisLocker axisLocker;
 
     QQmlComponent* alertDialog;
@@ -221,10 +218,15 @@ public:
     virtual void onComponentComplete();
 
     virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&);
+    virtual WebKit::PageViewportController* viewportController() const { return m_pageViewportController.data(); }
     virtual void updateViewportSize();
 
     virtual void pageDidRequestScroll(const QPoint& pos);
     virtual void handleMouseEvent(QMouseEvent*);
+
+private:
+    QScopedPointer<WebKit::PageViewportController> m_pageViewportController;
+    QScopedPointer<WebKit::PageViewportControllerClientQt> m_pageViewportControllerClient;
 };
 
 #endif // qquickwebview_p_p_h
index e000134..7737f65 100644 (file)
@@ -77,7 +77,9 @@ void QtPageClient::didRenderFrame(const WebCore::IntSize& contentsSize, const We
 {
     // The viewport has to be notified first so that the viewport position
     // is adjusted before the loadVisuallyCommitted() signal.
-    QQuickWebViewPrivate::get(m_webView)->viewportController()->didRenderFrame(contentsSize, coveredRect);
+    PageViewportController* pvc = QQuickWebViewPrivate::get(m_webView)->viewportController();
+    if (pvc)
+        pvc->didRenderFrame(contentsSize, coveredRect);
     QQuickWebViewPrivate::get(m_webView)->didRenderFrame();
 }
 
@@ -98,7 +100,9 @@ void QtPageClient::didRelaunchProcess()
 
 void QtPageClient::didChangeContentsSize(const IntSize& newSize)
 {
-    QQuickWebViewPrivate::get(m_webView)->viewportController()->didChangeContentsSize(newSize);
+    PageViewportController* pvc = QQuickWebViewPrivate::get(m_webView)->viewportController();
+    if (pvc)
+        pvc->didChangeContentsSize(newSize);
 }
 
 void QtPageClient::didChangeViewportProperties(const WebCore::ViewportAttributes& attr)
@@ -230,7 +234,9 @@ void QtPageClient::flashBackingStoreUpdates(const Vector<IntRect>&)
 
 void QtPageClient::pageTransitionViewportReady()
 {
-    QQuickWebViewPrivate::get(m_webView)->viewportController()->pageTransitionViewportReady();
+    PageViewportController* pvc = QQuickWebViewPrivate::get(m_webView)->viewportController();
+    if (pvc)
+        pvc->pageTransitionViewportReady();
 }
 
 void QtPageClient::didFindZoomableArea(const IntPoint& target, const IntRect& area)
index d111ad1..b877ca8 100644 (file)
@@ -62,7 +62,9 @@ void QtWebPageLoadClient::didReceiveServerRedirectForProvisionalLoad(const WTF::
 
 void QtWebPageLoadClient::didCommitLoad()
 {
-    m_webView->d_func()->viewportController()->didCommitLoad();
+    PageViewportController* pvc = m_webView->d_func()->viewportController();
+    if (pvc)
+        pvc->didCommitLoad();
     m_webView->d_func()->loadDidCommit();
 }