Changeset 64556 in webkit
- Timestamp:
- Aug 3, 2010 8:14:52 AM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r64549 r64556 1 2010-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 1 21 2010-08-03 Jochen Eisinger <jochen@chromium.org> 2 22 -
trunk/WebKitTools/QtTestBrowser/launcherwindow.cpp
r64354 r64556 403 403 view->setItemCacheMode(otherView->itemCacheMode()); 404 404 view->setResizesToContents(otherView->resizesToContents()); 405 view->setCustomLayoutSize(otherView->customLayoutSize()); 405 406 } else { 406 407 view->setItemCacheMode(gCacheWebView ? QGraphicsItem::DeviceCoordinateCache : QGraphicsItem::NoCache); 407 view->setResizesToContents(gResizesToContents);408 toggleResizesToContents(gResizesToContents); 408 409 } 409 410 } -
trunk/WebKitTools/QtTestBrowser/webview.cpp
r62298 r64556 82 82 void WebViewGraphicsBased::setResizesToContents(bool b) 83 83 { 84 if (b == m_resizesToContents) 85 return; 86 84 87 m_resizesToContents = b; 85 88 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. 86 105 if (m_resizesToContents) { 87 106 setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); 88 107 setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); 108 scene()->setSceneRect(QRectF()); 109 m_item->page()->setPreferredContentsSize(size()); 89 110 } else { 90 111 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 91 112 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); 92 117 } 93 118 } … … 96 121 { 97 122 QGraphicsView::resizeEvent(event); 98 if (m_resizesToContents) 123 124 QSize size(event->size()); 125 126 if (m_resizesToContents) { 127 m_item->page()->setPreferredContentsSize(size); 99 128 return; 100 QRectF rect(QPoint(0, 0), event->size()); 129 } 130 131 QRectF rect(QPoint(0, 0), size); 101 132 m_item->setGeometry(rect); 102 133 scene()->setSceneRect(rect); -
trunk/WebKitTools/QtTestBrowser/webview.h
r64354 r64556 85 85 bool resizesToContents() const { return m_resizesToContents; } 86 86 87 void setCustomLayoutSize(const QSize& size) { return m_item->page()->setPreferredContentsSize(size); } 88 QSize customLayoutSize() const { return m_item->page()->preferredContentsSize(); } 89 87 90 void setYRotation(qreal angle) 88 91 {
Note: See TracChangeset
for help on using the changeset viewer.