[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

tonikitoo at webkit.org tonikitoo at webkit.org
Wed Dec 22 11:40:28 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 961c51771448a8e22b554e7b978bc2b37809c123
Author: tonikitoo at webkit.org <tonikitoo at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Aug 3 15:14:52 2010 +0000

    2010-08-02  Antonio Gomes  <tonikitoo at webkit.org>
    
            Reviewed by Kenneth Christiansen.
    
            [Qt] QtTestBrowser not setting preferredContentsSize for resizesToContents
            https://bugs.webkit.org/show_bug.cgi?id=43168
    
            QGraphicsWebView resizesToContents property has to work together with QWebPage's
            setPreferredContentsSize as stated by the docs. Patch addresses that for QtTestBrowser.
    
            * QtTestBrowser/launcherwindow.cpp:
            (LauncherWindow::applyPrefs):
            * QtTestBrowser/webview.h:
            (WebViewGraphicsBased::setCustomLayoutSize): Setter helper.
            (WebViewGraphicsBased::customLayoutSize): Getter helper.
            * QtTestBrowser/webview.cpp:
            (WebViewGraphicsBased::resizeEvent):
            (WebViewGraphicsBased::setResizesToContents): Properly handle scene, webview and viewport sizes
                                                          needed when toggle resizesToContents on/off.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64556 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 7ee0d44..6b8db04 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,23 @@
+2010-08-02  Antonio Gomes  <tonikitoo at webkit.org>
+
+        Reviewed by Kenneth Christiansen.
+
+        [Qt] QtTestBrowser not setting preferredContentsSize for resizesToContents
+        https://bugs.webkit.org/show_bug.cgi?id=43168
+
+        QGraphicsWebView resizesToContents property has to work together with QWebPage's
+        setPreferredContentsSize as stated by the docs. Patch addresses that for QtTestBrowser.
+
+        * QtTestBrowser/launcherwindow.cpp:
+        (LauncherWindow::applyPrefs):
+        * QtTestBrowser/webview.cpp:
+        (WebViewGraphicsBased::setResizesToContents): Properly handle scene, webview and viewport sizes
+                                                      needed when toggle resizesToContents on/off.
+        (WebViewGraphicsBased::resizeEvent):
+        * QtTestBrowser/webview.h:
+        (WebViewGraphicsBased::setCustomLayoutSize): Setter helper.
+        (WebViewGraphicsBased::customLayoutSize): Getter helper.
+
 2010-08-03  Jochen Eisinger  <jochen at chromium.org>
 
         Unreviewed. Adding myself as committer.
diff --git a/WebKitTools/QtTestBrowser/launcherwindow.cpp b/WebKitTools/QtTestBrowser/launcherwindow.cpp
index 177adea..3ebc6c9 100644
--- a/WebKitTools/QtTestBrowser/launcherwindow.cpp
+++ b/WebKitTools/QtTestBrowser/launcherwindow.cpp
@@ -402,9 +402,10 @@ void LauncherWindow::applyPrefs(LauncherWindow* source)
     if (otherView) {
         view->setItemCacheMode(otherView->itemCacheMode());
         view->setResizesToContents(otherView->resizesToContents());
+        view->setCustomLayoutSize(otherView->customLayoutSize());
     } else {
         view->setItemCacheMode(gCacheWebView ? QGraphicsItem::DeviceCoordinateCache : QGraphicsItem::NoCache);
-        view->setResizesToContents(gResizesToContents);
+        toggleResizesToContents(gResizesToContents);
     }
 }
 
diff --git a/WebKitTools/QtTestBrowser/webview.cpp b/WebKitTools/QtTestBrowser/webview.cpp
index d06493e..e456f90 100644
--- a/WebKitTools/QtTestBrowser/webview.cpp
+++ b/WebKitTools/QtTestBrowser/webview.cpp
@@ -81,23 +81,54 @@ WebViewGraphicsBased::WebViewGraphicsBased(QWidget* parent)
 
 void WebViewGraphicsBased::setResizesToContents(bool b)
 {
+    if (b == m_resizesToContents)
+        return;
+
     m_resizesToContents = b;
     m_item->setResizesToContents(m_resizesToContents);
+
+    // When setting resizesToContents ON, our web view widget will always size as big as the
+    // web content being displayed, and so will the QWebPage's viewport. It implies that internally
+    // WebCore will work as if there was no content rendered offscreen, and then no scrollbars need
+    // drawing. In order to keep scrolling working, we:
+    //
+    // 1) Set QGraphicsView's scrollbars policy back to 'auto'.
+    // 2) Set scene's boundaries rect to an invalid size, which automatically makes it to be as big
+    //    as it needs to enclose all items onto it. We do that because QGraphicsView also calculates
+    //    the size of its scrollable area according to the amount of content in scene that is rendered
+    //    offscreen.
+    // 3) Set QWebPage's preferredContentsSize according to the size of QGraphicsView's viewport,
+    //    so WebCore properly lays pages out.
+    //
+    // On the other hand, when toggling resizesToContents OFF, we set back the default values, as
+    // opposite as described above.
     if (m_resizesToContents) {
         setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
         setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+        scene()->setSceneRect(QRectF());
+        m_item->page()->setPreferredContentsSize(size());
     } else {
         setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
         setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+        m_item->page()->setPreferredContentsSize(QSize());
+        QRect viewportRect(QPoint(0, 0), size());
+        m_item->setGeometry(viewportRect);
+        scene()->setSceneRect(viewportRect);
     }
 }
 
 void WebViewGraphicsBased::resizeEvent(QResizeEvent* event)
 {
     QGraphicsView::resizeEvent(event);
-    if (m_resizesToContents)
+
+    QSize size(event->size());
+
+    if (m_resizesToContents) {
+        m_item->page()->setPreferredContentsSize(size);
         return;
-    QRectF rect(QPoint(0, 0), event->size());
+    }
+
+    QRectF rect(QPoint(0, 0), size);
     m_item->setGeometry(rect);
     scene()->setSceneRect(rect);
 }
diff --git a/WebKitTools/QtTestBrowser/webview.h b/WebKitTools/QtTestBrowser/webview.h
index 9b533b3..433844c 100644
--- a/WebKitTools/QtTestBrowser/webview.h
+++ b/WebKitTools/QtTestBrowser/webview.h
@@ -84,6 +84,9 @@ public:
     void setResizesToContents(bool b);
     bool resizesToContents() const { return m_resizesToContents; }
 
+    void setCustomLayoutSize(const QSize& size) { return m_item->page()->setPreferredContentsSize(size); }
+    QSize customLayoutSize() const { return m_item->page()->preferredContentsSize(); }
+
     void setYRotation(qreal angle)
     {
 #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list