[Qt] Apply the devicePixelRatio as soon as possible
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Sep 2012 13:58:10 +0000 (13:58 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Sep 2012 13:58:10 +0000 (13:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=97211

Patch by Jocelyn Turcotte <jocelyn.turcotte@digia.com> on 2012-09-25
Reviewed by Kenneth Rohde Christiansen.

Having to wait for the contents size to apply the devicePixelRatio can
be problematic since the devicePixelRatio affects the layout width, which
then affects the contents size.

Fix the initial issue that this was working around by preventing the
early return if useFixedLayout() is true.

* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewPrivate::QQuickWebViewPrivate):
(QQuickWebViewFlickablePrivate::didChangeContentsSize):
(QQuickWebViewExperimental::devicePixelRatio):
(QQuickWebViewExperimental::setDevicePixelRatio):
* UIProcess/API/qt/qquickwebview_p_p.h:
(QQuickWebViewPrivate::didChangeContentsSize):
(QQuickWebViewPrivate):
* UIProcess/DrawingAreaProxyImpl.cpp:
(WebKit::DrawingAreaProxyImpl::sendUpdateBackingStoreState):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@129500 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/DrawingAreaProxyImpl.cpp

index 9d05f98..316ae29 100644 (file)
@@ -1,5 +1,30 @@
 2012-09-25  Jocelyn Turcotte  <jocelyn.turcotte@digia.com>
 
+        [Qt] Apply the devicePixelRatio as soon as possible
+        https://bugs.webkit.org/show_bug.cgi?id=97211
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Having to wait for the contents size to apply the devicePixelRatio can
+        be problematic since the devicePixelRatio affects the layout width, which
+        then affects the contents size.
+
+        Fix the initial issue that this was working around by preventing the
+        early return if useFixedLayout() is true.
+
+        * UIProcess/API/qt/qquickwebview.cpp:
+        (QQuickWebViewPrivate::QQuickWebViewPrivate):
+        (QQuickWebViewFlickablePrivate::didChangeContentsSize):
+        (QQuickWebViewExperimental::devicePixelRatio):
+        (QQuickWebViewExperimental::setDevicePixelRatio):
+        * UIProcess/API/qt/qquickwebview_p_p.h:
+        (QQuickWebViewPrivate::didChangeContentsSize):
+        (QQuickWebViewPrivate):
+        * UIProcess/DrawingAreaProxyImpl.cpp:
+        (WebKit::DrawingAreaProxyImpl::sendUpdateBackingStoreState):
+
+2012-09-25  Jocelyn Turcotte  <jocelyn.turcotte@digia.com>
+
         [Qt] Don't render at scale 1.0 when doing a pinch-zoom out
         https://bugs.webkit.org/show_bug.cgi?id=97212
 
index ee0ff95..9306d42 100644 (file)
@@ -272,7 +272,6 @@ QQuickWebViewPrivate::QQuickWebViewPrivate(QQuickWebView* viewport)
     , m_navigatorQtObjectEnabled(false)
     , m_renderToOffscreenBuffer(false)
     , m_allowAnyHTTPSCertificateForLocalHost(false)
-    , m_customDevicePixelRatio(0)
     , m_loadProgress(0)
 {
     viewport->setClip(true);
@@ -798,20 +797,6 @@ void QQuickWebViewPrivate::didReceiveMessageFromNavigatorQtObject(const String&
     emit q_ptr->experimental()->messageReceived(variantMap);
 }
 
-void QQuickWebViewPrivate::didChangeContentsSize(const QSize& newSize)
-{
-    if (newSize.isEmpty() || !m_customDevicePixelRatio || webPageProxy->deviceScaleFactor() == m_customDevicePixelRatio)
-        return;
-
-    // DrawingAreaProxy returns early if the page size is empty
-    // and the device pixel ratio property is propagated from QML
-    // before the QML page item has a valid size yet, thus the
-    // information would not reach the web process.
-    // Set the custom device pixel ratio requested from QML as soon
-    // as the content item has a valid size.
-    webPageProxy->setCustomDeviceScaleFactor(m_customDevicePixelRatio);
-}
-
 QQuickWebViewLegacyPrivate::QQuickWebViewLegacyPrivate(QQuickWebView* viewport)
     : QQuickWebViewPrivate(viewport)
 {
@@ -894,8 +879,8 @@ void QQuickWebViewFlickablePrivate::pageDidRequestScroll(const QPoint& pos)
 
 void QQuickWebViewFlickablePrivate::didChangeContentsSize(const QSize& newSize)
 {
-    pageView->setContentsSize(newSize); // emits contentsSizeChanged()
     QQuickWebViewPrivate::didChangeContentsSize(newSize);
+    pageView->setContentsSize(newSize); // emits contentsSizeChanged()
     m_pageViewportController->didChangeContentsSize(newSize);
 }
 
@@ -1239,10 +1224,6 @@ void QQuickWebViewExperimental::setUserAgent(const QString& userAgent)
 qreal QQuickWebViewExperimental::devicePixelRatio() const
 {
     Q_D(const QQuickWebView);
-
-    if (d->m_customDevicePixelRatio)
-        return d->m_customDevicePixelRatio;
-
     return d->webPageProxy->deviceScaleFactor();
 }
 
@@ -1252,7 +1233,7 @@ void QQuickWebViewExperimental::setDevicePixelRatio(qreal devicePixelRatio)
     if (0 >= devicePixelRatio || devicePixelRatio == this->devicePixelRatio())
         return;
 
-    d->m_customDevicePixelRatio = devicePixelRatio;
+    d->webPageProxy->setCustomDeviceScaleFactor(devicePixelRatio);
     emit devicePixelRatioChanged();
 }
 
index a154da8..f172ad6 100644 (file)
@@ -130,7 +130,7 @@ public:
     WebCore::IntSize viewSize() const;
     void didReceiveMessageFromNavigatorQtObject(const String& message);
     virtual void pageDidRequestScroll(const QPoint& pos) { }
-    virtual void didChangeContentsSize(const QSize& newSize);
+    virtual void didChangeContentsSize(const QSize& newSize) { }
     void processDidCrash();
     void didRelaunchProcess();
     PassOwnPtr<WebKit::DrawingAreaProxy> createDrawingAreaProxy();
@@ -194,7 +194,6 @@ protected:
     bool m_navigatorQtObjectEnabled;
     bool m_renderToOffscreenBuffer;
     bool m_allowAnyHTTPSCertificateForLocalHost;
-    qreal m_customDevicePixelRatio;
     WTF::String m_iconUrl;
     int m_loadProgress;
     WTF::String m_currentUrl;
index baf6470..966ac6b 100644 (file)
@@ -307,7 +307,7 @@ void DrawingAreaProxyImpl::sendUpdateBackingStoreState(RespondImmediatelyOrNot r
     if (m_isWaitingForDidUpdateBackingStoreState)
         return;
 
-    if (m_webPageProxy->viewSize().isEmpty())
+    if (m_webPageProxy->viewSize().isEmpty() && !m_webPageProxy->useFixedLayout())
         return;
 
     m_isWaitingForDidUpdateBackingStoreState = respondImmediatelyOrNot == RespondImmediately;