[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756

antti at apple.com antti at apple.com
Fri Feb 26 22:19:48 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 6bcf7762adde378c3093b0f84d02bd20d69033fb
Author: antti at apple.com <antti at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Feb 15 09:28:27 2010 +0000

    2010-02-12  Antti Koivisto  <koivisto at iki.fi>
    
            Reviewed by Kenneth Rohde Christiansen and Simon Hausmann.
    
            https://bugs.webkit.org/show_bug.cgi?id=34885
            Add a QGraphicsWebView mode that makes it automatically resize itself to the size of the content.
    
            This is useful for cases where the client wants to implement page panning and zooming by manipulating
            the graphics item.
    
            Add a option to QGVLauncher to test this mode.
    
            * Api/qgraphicswebview.cpp:
            (QGraphicsWebViewPrivate::QGraphicsWebViewPrivate):
            (QGraphicsWebViewPrivate::updateResizesToContentsForPage):
            (QGraphicsWebViewPrivate::_q_contentsSizeChanged):
            (QGraphicsWebView::setPage):
            (QGraphicsWebView::setResizesToContents):
            (QGraphicsWebView::resizesToContents):
            * Api/qgraphicswebview.h:
            * QGVLauncher/main.cpp:
            (WebView::WebView):
            (MainView::MainView):
            (MainView::setMainWidget):
            (MainView::resizeEvent):
            (main):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54767 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/qt/Api/qgraphicswebview.cpp b/WebKit/qt/Api/qgraphicswebview.cpp
index b323598..5f49463 100644
--- a/WebKit/qt/Api/qgraphicswebview.cpp
+++ b/WebKit/qt/Api/qgraphicswebview.cpp
@@ -77,6 +77,7 @@ public:
     QGraphicsWebViewPrivate(QGraphicsWebView* parent)
         : q(parent)
         , page(0)
+        , resizesToContents(false)
 #if USE(ACCELERATED_COMPOSITING)
         , rootGraphicsLayer(0)
         , shouldSync(false)
@@ -117,12 +118,18 @@ public:
     virtual void markForSync(bool scheduleSync);
     void updateCompositingScrollPosition();
 #endif
+    
+    void updateResizesToContentsForPage();
 
     void syncLayers();
     void _q_doLoadFinished(bool success);
+    void _q_contentsSizeChanged(const QSize&);
 
     QGraphicsWebView* q;
     QWebPage* page;
+
+    bool resizesToContents;
+
 #if USE(ACCELERATED_COMPOSITING)
     QGraphicsItem* rootGraphicsLayer;
 
@@ -304,6 +311,30 @@ QStyle* QGraphicsWebViewPrivate::style() const
     return q->style();
 }
 
+void QGraphicsWebViewPrivate::updateResizesToContentsForPage()
+{
+    ASSERT(page);
+
+    if (resizesToContents) {
+        // resizes to contents mode requires preferred contents size to be set
+        if (!page->preferredContentsSize().isValid())
+            page->setPreferredContentsSize(QSize(960, 800));
+
+        QObject::connect(page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)),
+            q, SLOT(_q_contentsSizeChanged(const QSize&)), Qt::UniqueConnection);
+    } else {
+        QObject::disconnect(page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)),
+                         q, SLOT(_q_contentsSizeChanged(const QSize&)));
+    }
+}
+
+void QGraphicsWebViewPrivate::_q_contentsSizeChanged(const QSize& size)
+{
+    if (!resizesToContents)
+        return;
+    q->setGeometry(QRectF(q->geometry().topLeft(), size));
+}
+
 /*!
     \class QGraphicsWebView
     \brief The QGraphicsWebView class allows Web content to be added to a GraphicsView.
@@ -586,6 +617,9 @@ void QGraphicsWebView::setPage(QWebPage* page)
 
     QSize size = geometry().size().toSize();
     page->setViewportSize(size);
+    
+    if (d->resizesToContents)
+        d->updateResizesToContentsForPage();
 
     QWebFrame* mainFrame = d->page->mainFrame();
 
@@ -918,6 +952,34 @@ bool QGraphicsWebView::findText(const QString &subString, QWebPage::FindFlags op
     return false;
 }
 
+/*!
+    \property QGraphicsWebView::resizesToContents
+    \brief whether the size of the QGraphicsWebView and its viewport changes to match the contents size
+    \since 4.7 
+
+    If this property is set, the QGraphicsWebView will automatically change its
+    size to match the size of the main frame contents. As a result the top level frame
+    will never have scrollbars.
+
+    This property should be used in conjunction with the QWebPage::preferredContentsSize property.
+    If not explicitly set, the preferredContentsSize is automatically set to a reasonable value.
+
+    \sa QWebPage::setPreferredContentsSize
+*/
+void QGraphicsWebView::setResizesToContents(bool enabled)
+{
+    if (d->resizesToContents == enabled)
+        return;
+    d->resizesToContents = enabled;
+    if (d->page)
+        d->updateResizesToContentsForPage();
+}
+
+bool QGraphicsWebView::resizesToContents() const
+{
+    return d->resizesToContents;
+}
+
 /*! \reimp
 */
 void QGraphicsWebView::hoverMoveEvent(QGraphicsSceneHoverEvent* ev)
diff --git a/WebKit/qt/Api/qgraphicswebview.h b/WebKit/qt/Api/qgraphicswebview.h
index 3cf51b2..14de9d5 100644
--- a/WebKit/qt/Api/qgraphicswebview.h
+++ b/WebKit/qt/Api/qgraphicswebview.h
@@ -45,6 +45,7 @@ class QWEBKIT_EXPORT QGraphicsWebView : public QGraphicsWidget {
     Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
 
     Q_PROPERTY(bool modified READ isModified)
+    Q_PROPERTY(bool resizesToContents READ resizesToContents WRITE setResizesToContents)
 
 public:
     explicit QGraphicsWebView(QGraphicsItem* parent = 0);
@@ -79,6 +80,9 @@ public:
 
     bool findText(const QString& subString, QWebPage::FindFlags options = 0);
 
+    bool resizesToContents() const;
+    void setResizesToContents(bool enabled);
+
     virtual void setGeometry(const QRectF& rect);
     virtual void updateGeometry();
     virtual void paint(QPainter*, const QStyleOptionGraphicsItem* options, QWidget* widget = 0);
@@ -137,6 +141,7 @@ private:
     // we don't want to change the moc based on USE() macro, so this function is here
     // but will be empty if ACCLERATED_COMPOSITING is disabled
     Q_PRIVATE_SLOT(d, void syncLayers())
+    Q_PRIVATE_SLOT(d, void _q_contentsSizeChanged(const QSize&))
 
     QGraphicsWebViewPrivate* const d;
     friend class QGraphicsWebViewPrivate;
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index e0d1b28..e1e2bc8 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,30 @@
+2010-02-12  Antti Koivisto  <koivisto at iki.fi>
+
+        Reviewed by Kenneth Rohde Christiansen and Simon Hausmann.
+        
+        https://bugs.webkit.org/show_bug.cgi?id=34885
+        Add a QGraphicsWebView mode that makes it automatically resize itself to the size of the content.
+
+        This is useful for cases where the client wants to implement page panning and zooming by manipulating
+        the graphics item.
+        
+        Add a option to QGVLauncher to test this mode.
+
+        * Api/qgraphicswebview.cpp:
+        (QGraphicsWebViewPrivate::QGraphicsWebViewPrivate):
+        (QGraphicsWebViewPrivate::updateResizesToContentsForPage):
+        (QGraphicsWebViewPrivate::_q_contentsSizeChanged):
+        (QGraphicsWebView::setPage):
+        (QGraphicsWebView::setResizesToContents):
+        (QGraphicsWebView::resizesToContents):
+        * Api/qgraphicswebview.h:
+        * QGVLauncher/main.cpp:
+        (WebView::WebView):
+        (MainView::MainView):
+        (MainView::setMainWidget):
+        (MainView::resizeEvent):
+        (main):
+
 2010-02-12  Diego Gonzalez  <diego.gonzalez at openbossa.org>
 
         Reviewed by Kenneth Rohde Christiansen.
diff --git a/WebKit/qt/QGVLauncher/main.cpp b/WebKit/qt/QGVLauncher/main.cpp
index 0536af5..448b4b0 100644
--- a/WebKit/qt/QGVLauncher/main.cpp
+++ b/WebKit/qt/QGVLauncher/main.cpp
@@ -74,6 +74,8 @@ public:
     {
         if (QApplication::instance()->arguments().contains("--cacheWebView"))
             setCacheMode(QGraphicsItem::DeviceCoordinateCache);
+        if (QApplication::instance()->arguments().contains("--resizesToContents"))
+            setResizesToContents(true);
     }
     void setYRotation(qreal angle)
     {
@@ -129,8 +131,11 @@ public:
         , m_numTotalPaints(0)
         , m_numPaintsSinceLastMeasure(0)
     {
-        setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-        setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+        // Use the graphics view scrollbars when the webview is set to size to the content.
+        if (!QApplication::instance()->arguments().contains("--resizesToContents")) {
+            setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+            setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+        }
 
         setFrameShape(QFrame::NoFrame);
         setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
@@ -143,17 +148,19 @@ public:
         }
     }
 
-    void setMainWidget(QGraphicsWidget* widget)
+    void setMainWidget(WebView* widget)
     {
-        QRectF rect(QRect(QPoint(0, 0), size()));
-        widget->setGeometry(rect);
         m_mainWidget = widget;
+        if (m_mainWidget->resizesToContents())
+            return;
+        QRectF rect(QRect(QPoint(0, 0), size()));
+        m_mainWidget->setGeometry(rect);
     }
 
     void resizeEvent(QResizeEvent* event)
     {
         QGraphicsView::resizeEvent(event);
-        if (!m_mainWidget)
+        if (!m_mainWidget || m_mainWidget->resizesToContents())
             return;
         QRectF rect(QPoint(0, 0), event->size());
         m_mainWidget->setGeometry(rect);
@@ -231,7 +238,7 @@ signals:
     void flipRequest();
 
 private:
-    QGraphicsWidget* m_mainWidget;
+    WebView* m_mainWidget;
     bool m_measureFps;
     int m_numTotalPaints;
     int m_numPaintsSinceLastMeasure;
@@ -493,7 +500,7 @@ int main(int argc, char** argv)
 {
     QApplication app(argc, argv);
     if (app.arguments().contains("--help")) {
-        qDebug() << "Usage: QGVLauncher [--url url] [--compositing] [--updateMode Full|Minimal|Smart|No|BoundingRect] [--cacheWebView]\n";
+        qDebug() << "Usage: QGVLauncher [--url url] [--compositing] [--updateMode Full|Minimal|Smart|No|BoundingRect] [--cacheWebView] [--resizesToContents]\n";
         return 0;
     }
     QString url = QString("file://%1/%2").arg(QDir::homePath()).arg(QLatin1String("index.html"));

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list