Changeset 56450 in webkit
- Timestamp:
- Mar 24, 2010 12:05:25 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r56449 r56450 1 2010-03-23 Kenneth Rohde Christiansen <kenneth@webkit.org> 2 3 Reviewed by Simon Hausmann. 4 5 Add a way to check if the page client is making use of 6 a QWidget. 7 8 * platform/qt/QWebPageClient.h: 9 (QWebPageClient::isQWidgetClient): 10 1 11 2010-03-24 Jay Campan <jcampan@google.com> 2 12 -
trunk/WebCore/platform/qt/QWebPageClient.h
r53802 r56450 41 41 public: 42 42 virtual ~QWebPageClient() { } 43 43 44 virtual bool isQWidgetClient() const { return false; } 45 44 46 virtual void scroll(int dx, int dy, const QRect&) = 0; 45 47 virtual void update(const QRect&) = 0; -
trunk/WebKit/qt/Api/qgraphicswebview.cpp
r56423 r56450 96 96 97 97 virtual ~QGraphicsWebViewPrivate(); 98 98 99 virtual void scroll(int dx, int dy, const QRect&); 99 100 virtual void update(const QRect& dirtyRect); … … 122 123 void updateCompositingScrollPosition(); 123 124 #endif 124 125 125 126 void updateResizesToContentsForPage(); 126 127 QRectF graphicsItemVisibleRect() const; … … 132 133 133 134 void syncLayers(); 135 136 void unsetPageIfExists(); 137 134 138 void _q_doLoadFinished(bool success); 135 139 void _q_contentsSizeChanged(const QSize&); … … 688 692 } 689 693 694 void QGraphicsWebViewPrivate::unsetPageIfExists() 695 { 696 if (!page) 697 return; 698 699 // if the page client is the special client constructed for 700 // delegating the responsibilities to a QWidget, we need 701 // to destroy it. 702 703 if (page->d->client && page->d->client->isQWidgetClient()) 704 delete page->d->client; 705 706 page->d->client = 0; 707 708 // if the page was created by us, we own it and need to 709 // destroy it as well. 710 711 if (page->parent() == q) 712 delete page; 713 else 714 page->disconnect(q); 715 } 716 690 717 /*! 691 718 Makes \a page the new web page of the web graphicsitem. … … 702 729 return; 703 730 704 if (d->page) { 705 d->page->d->client = 0; // unset the page client 706 if (d->page->parent() == this) 707 delete d->page; 708 else 709 d->page->disconnect(this); 710 } 711 731 d->unsetPageIfExists(); 712 732 d->page = page; 733 713 734 if (!d->page) 714 735 return; 736 737 d->page->d->client = d; // set the page client 738 715 739 if (d->overlay) 716 740 d->overlay->prepareGeometryChange(); 717 d->page->d->client = d; // set the page client718 741 719 742 QSize size = geometry().size().toSize(); 720 743 page->setViewportSize(size); 721 744 722 745 if (d->resizesToContents) 723 746 d->updateResizesToContentsForPage(); -
trunk/WebKit/qt/Api/qwebpage.cpp
r56386 r56450 209 209 } 210 210 211 virtual bool isQWidgetClient() const { return true; } 212 211 213 virtual void scroll(int dx, int dy, const QRect&); 212 214 virtual void update(const QRect& dirtyRect); … … 282 284 { 283 285 #if defined(Q_WS_X11) 284 if (view) 285 return view->x11Info().screen(); 286 #endif 287 286 return view->x11Info().screen(); 287 #endif 288 288 return 0; 289 289 } … … 1781 1781 , d(new QWebPagePrivate(this)) 1782 1782 { 1783 setView(qobject_cast<QWidget 1783 setView(qobject_cast<QWidget*>(parent)); 1784 1784 1785 1785 connect(this, SIGNAL(loadProgress(int)), this, SLOT(_q_onLoadProgressChanged(int))); … … 1865 1865 \sa view() 1866 1866 */ 1867 void QWebPage::setView(QWidget *view) 1868 { 1869 if (this->view() != view) { 1870 d->view = view; 1871 if (!view) { 1872 delete d->client; 1873 d->client = 0; 1874 } else { 1875 if (!d->client) 1876 d->client = new QWebPageWidgetClient(view); 1877 else 1878 static_cast<QWebPageWidgetClient*>(d->client)->view = view; 1879 } 1880 setViewportSize(view ? view->size() : QSize(0, 0)); 1881 } 1867 void QWebPage::setView(QWidget* view) 1868 { 1869 if (this->view() == view) 1870 return; 1871 1872 d->view = view; 1873 setViewportSize(view ? view->size() : QSize(0, 0)); 1874 1875 // If we have no client, we install a special client delegating 1876 // the responsibility to the QWidget. This is the code path 1877 // handling a.o. the "legacy" QWebView. 1878 // 1879 // If such a special delegate already exist, we substitute the view. 1880 1881 if (d->client) { 1882 if (d->client->isQWidgetClient()) 1883 static_cast<QWebPageWidgetClient*>(d->client)->view = view; 1884 return; 1885 } 1886 1887 if (view) 1888 d->client = new QWebPageWidgetClient(view); 1882 1889 } 1883 1890 -
trunk/WebKit/qt/Api/qwebpage.h
r56051 r56450 357 357 friend class QWebPagePrivate; 358 358 friend class QWebView; 359 friend class QWebViewPrivate; 359 360 friend class QGraphicsWebView; 361 friend class QGraphicsWebViewPrivate; 360 362 friend class QWebInspector; 361 363 friend class WebCore::ChromeClientQt; -
trunk/WebKit/qt/Api/qwebview.cpp
r56060 r56450 46 46 47 47 void _q_pageDestroyed(); 48 void unsetPageIfExists(); 48 49 49 50 QWebView *view; … … 348 349 } 349 350 351 void QWebViewPrivate::unsetPageIfExists() 352 { 353 if (!page) 354 return; 355 356 // if the page client is the special client constructed for 357 // delegating the responsibilities to a QWidget, we need 358 // to destroy it. 359 360 if (page->d->client && page->d->client->isQWidgetClient()) 361 delete page->d->client; 362 363 page->d->client = 0; 364 365 // if the page was created by us, we own it and need to 366 // destroy it as well. 367 368 if (page->parent() == view) 369 delete page; 370 else 371 page->disconnect(view); 372 } 373 350 374 /*! 351 375 Makes \a page the new web page of the web view. … … 361 385 if (d->page == page) 362 386 return; 363 if (d->page) { 364 d->page->d->client = 0; // unset the page client 365 if (d->page->parent() == this) 366 delete d->page; 367 else 368 d->page->disconnect(this); 369 } 387 388 d->unsetPageIfExists(); 370 389 d->page = page; 390 371 391 if (d->page) { 372 392 d->page->setView(this); -
trunk/WebKit/qt/ChangeLog
r56439 r56450 1 2010-03-23 Kenneth Rohde Christiansen <kenneth@webkit.org> 2 3 Reviewed by Simon Hausmann. 4 5 Calling setView(0) on a QWebPage being shown by a QGraphicsWebView, 6 would uninstall the page client, deleting the QGraphicsWebViewPrivate 7 instance. If called with an argument, it would do a wrong static_cast 8 and crash. 9 10 * Api/qwebpage.cpp: 11 (QWebPageWidgetClient::QWebPageWidgetClient): 12 (QWebPageWidgetClient::isQWidgetClient): 13 (QWebPageWidgetClient::screenNumber): 14 (QWebPage::QWebPage): 15 (QWebPage::setView): 16 * Api/qgraphicswebview.cpp: 17 (QGraphicsWebViewPrivate::unsetPageIfExists): 18 (QGraphicsWebView::setPage): 19 * Api/qwebpage.cpp: 20 (QWebPageWidgetClient::isQWidgetClient): 21 (QWebPageWidgetClient::screenNumber): 22 (QWebPage::QWebPage): 23 (QWebPage::setView): 24 * Api/qwebpage.h: 25 * Api/qwebview.cpp: 26 (QWebViewPrivate::unsetPageIfExists): 27 (QWebView::setPage): 28 1 29 2010-03-24 Kent Tamura <tkent@chromium.org> 2 30
Note: See TracChangeset
for help on using the changeset viewer.