Changeset 64556 in webkit


Ignore:
Timestamp:
Aug 3, 2010 8:14:52 AM (14 years ago)
Author:
tonikitoo@webkit.org
Message:

2010-08-02 Antonio Gomes <tonikitoo@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.

Location:
trunk/WebKitTools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r64549 r64556  
     12010-08-02  Antonio Gomes  <tonikitoo@webkit.org>
     2
     3        Reviewed by Kenneth Christiansen.
     4
     5        [Qt] QtTestBrowser not setting preferredContentsSize for resizesToContents
     6        https://bugs.webkit.org/show_bug.cgi?id=43168
     7
     8        QGraphicsWebView resizesToContents property has to work together with QWebPage's
     9        setPreferredContentsSize as stated by the docs. Patch addresses that for QtTestBrowser.
     10
     11        * QtTestBrowser/launcherwindow.cpp:
     12        (LauncherWindow::applyPrefs):
     13        * QtTestBrowser/webview.cpp:
     14        (WebViewGraphicsBased::setResizesToContents): Properly handle scene, webview and viewport sizes
     15                                                      needed when toggle resizesToContents on/off.
     16        (WebViewGraphicsBased::resizeEvent):
     17        * QtTestBrowser/webview.h:
     18        (WebViewGraphicsBased::setCustomLayoutSize): Setter helper.
     19        (WebViewGraphicsBased::customLayoutSize): Getter helper.
     20
    1212010-08-03  Jochen Eisinger  <jochen@chromium.org>
    222
  • trunk/WebKitTools/QtTestBrowser/launcherwindow.cpp

    r64354 r64556  
    403403        view->setItemCacheMode(otherView->itemCacheMode());
    404404        view->setResizesToContents(otherView->resizesToContents());
     405        view->setCustomLayoutSize(otherView->customLayoutSize());
    405406    } else {
    406407        view->setItemCacheMode(gCacheWebView ? QGraphicsItem::DeviceCoordinateCache : QGraphicsItem::NoCache);
    407         view->setResizesToContents(gResizesToContents);
     408        toggleResizesToContents(gResizesToContents);
    408409    }
    409410}
  • trunk/WebKitTools/QtTestBrowser/webview.cpp

    r62298 r64556  
    8282void WebViewGraphicsBased::setResizesToContents(bool b)
    8383{
     84    if (b == m_resizesToContents)
     85        return;
     86
    8487    m_resizesToContents = b;
    8588    m_item->setResizesToContents(m_resizesToContents);
     89
     90    // When setting resizesToContents ON, our web view widget will always size as big as the
     91    // web content being displayed, and so will the QWebPage's viewport. It implies that internally
     92    // WebCore will work as if there was no content rendered offscreen, and then no scrollbars need
     93    // drawing. In order to keep scrolling working, we:
     94    //
     95    // 1) Set QGraphicsView's scrollbars policy back to 'auto'.
     96    // 2) Set scene's boundaries rect to an invalid size, which automatically makes it to be as big
     97    //    as it needs to enclose all items onto it. We do that because QGraphicsView also calculates
     98    //    the size of its scrollable area according to the amount of content in scene that is rendered
     99    //    offscreen.
     100    // 3) Set QWebPage's preferredContentsSize according to the size of QGraphicsView's viewport,
     101    //    so WebCore properly lays pages out.
     102    //
     103    // On the other hand, when toggling resizesToContents OFF, we set back the default values, as
     104    // opposite as described above.
    86105    if (m_resizesToContents) {
    87106        setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    88107        setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
     108        scene()->setSceneRect(QRectF());
     109        m_item->page()->setPreferredContentsSize(size());
    89110    } else {
    90111        setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    91112        setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     113        m_item->page()->setPreferredContentsSize(QSize());
     114        QRect viewportRect(QPoint(0, 0), size());
     115        m_item->setGeometry(viewportRect);
     116        scene()->setSceneRect(viewportRect);
    92117    }
    93118}
     
    96121{
    97122    QGraphicsView::resizeEvent(event);
    98     if (m_resizesToContents)
     123
     124    QSize size(event->size());
     125
     126    if (m_resizesToContents) {
     127        m_item->page()->setPreferredContentsSize(size);
    99128        return;
    100     QRectF rect(QPoint(0, 0), event->size());
     129    }
     130
     131    QRectF rect(QPoint(0, 0), size);
    101132    m_item->setGeometry(rect);
    102133    scene()->setSceneRect(rect);
  • trunk/WebKitTools/QtTestBrowser/webview.h

    r64354 r64556  
    8585    bool resizesToContents() const { return m_resizesToContents; }
    8686
     87    void setCustomLayoutSize(const QSize& size) { return m_item->page()->setPreferredContentsSize(size); }
     88    QSize customLayoutSize() const { return m_item->page()->preferredContentsSize(); }
     89
    8790    void setYRotation(qreal angle)
    8891    {
Note: See TracChangeset for help on using the changeset viewer.