Changeset 64673 in webkit
- Timestamp:
- Aug 4, 2010 1:31:07 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r64672 r64673 1 2010-08-04 Antonio Gomes <tonikitoo@webkit.org> 2 3 Reviewed by Simon Hausmann and Kenneth Christiansen. 4 5 [Qt] [QtTestBrowser] Clean up static and global menu state controls 6 https://bugs.webkit.org/show_bug.cgi?id=43448 7 8 After LauncherWindow class was refactored out of from main.cpp, all global variables that 9 were hanging in main.cpp became temporarily public static class members of newly added 10 LauncherWindow class. This design was not properly handling the initial purpose of the 11 global variables: newly created launcher windows should inherit the settings of the originating 12 one. 13 14 In order to properly fix the problem, this patch introduces a WindowOptions class, as a POD. It 15 comprises all data needed to handling the goal described above. 16 17 * QtTestBrowser/launcherwindow.cpp: 18 (LauncherWindow::LauncherWindow): The class now receives an optional WindowOptions pointer object 19 holding all user settings configured in the menus and command line. 20 It also receices an optional QGraphicsScene points in case we are doing 21 a "Clone Window". 22 (LauncherWindow::init): Removed the usesGraphics parameter because the class member m_userData holds its 23 value. 24 (LauncherWindow::initializeView): Ditto. 25 (LauncherWindow::createChrome): Changed all references to gXXX to m_userData.XXX 26 (LauncherWindow::applyPrefs): Removed the "LauncherWindow* source" parameter. All data needed to properly 27 apply the preferences is provided by m_userData. 28 (LauncherWindow::toggleAcceleratedCompositing): Change gXXX by m_userData.XXX 29 (LauncherWindow::toggleResizesToContents): Ditto. 30 (LauncherWindow::toggleWebGL): Ditto. 31 (LauncherWindow::toggleFrameFlattening): Ditto. 32 (LauncherWindow::toggleQGLWidgetViewport): Ditto. 33 (LauncherWindow::changeViewportUpdateMode): Ditto. 34 (LauncherWindow::showFPS): Ditto. 35 (LauncherWindow::newWindow): Changed to pass the userData. 36 (LauncherWindow::cloneWindow): Ditto. 37 * QtTestBrowser/launcherwindow.h: 38 (WindowOptions::WindowOptions): 39 * QtTestBrowser/main.cpp: 40 (requiresGraphicsView): 41 (LauncherApplication::handleUserOptions): 42 (main): 43 1 44 2010-08-04 Kevin Ollivier <kevino@theolliviers.com> 2 45 -
trunk/WebKitTools/QtTestBrowser/launcherwindow.cpp
r64671 r64673 33 33 #include "launcherwindow.h" 34 34 35 bool LauncherWindow::gUseGraphicsView = false; 36 bool LauncherWindow::gUseCompositing = true; 37 bool LauncherWindow::gCacheWebView = false; 38 bool LauncherWindow::gShowFrameRate = false; 39 bool LauncherWindow::gResizesToContents = false; 40 bool LauncherWindow::gUseTiledBackingStore = false; 41 QGraphicsView::ViewportUpdateMode LauncherWindow::gViewportUpdateMode = QGraphicsView::MinimalViewportUpdate; 42 QUrl LauncherWindow::gInspectorUrl; 43 44 #if defined(Q_WS_MAEMO_5) || defined(Q_WS_S60) 45 bool LauncherWindow::gUseFrameFlattening = true; 46 #else 47 bool LauncherWindow::gUseFrameFlattening = false; 48 #endif 49 50 #if defined(QT_CONFIGURED_WITH_OPENGL) 51 bool LauncherWindow::gUseQGLWidgetViewport = false; 52 #endif 53 54 LauncherWindow::LauncherWindow(LauncherWindow* other, bool shareScene) 35 const int gExitClickArea = 80; 36 37 LauncherWindow::LauncherWindow(WindowOptions* data, QGraphicsScene* sharedScene) 55 38 : MainWindow() 56 39 , m_currentZoom(100) … … 64 47 #endif 65 48 { 66 if (other) { 67 init(other->isGraphicsBased()); 68 applyPrefs(other); 69 if (shareScene && other->isGraphicsBased()) { 70 QGraphicsView* otherView = static_cast<QGraphicsView*>(other->m_view); 71 static_cast<QGraphicsView*>(m_view)->setScene(otherView->scene()); 72 } 73 } else { 74 init(gUseGraphicsView); 75 applyPrefs(); 76 } 49 if (data) 50 m_windowOptions = *data; 51 52 init(); 53 applyPrefs(); 54 if (sharedScene && data->useGraphicsView) 55 static_cast<QGraphicsView*>(m_view)->setScene(sharedScene); 77 56 78 57 createChrome(); … … 84 63 } 85 64 86 void LauncherWindow::init( bool useGraphicsView)65 void LauncherWindow::init() 87 66 { 88 67 QSplitter* splitter = new QSplitter(Qt::Vertical, this); … … 96 75 #endif 97 76 98 initializeView( useGraphicsView);77 initializeView(); 99 78 100 79 connect(page(), SIGNAL(loadStarted()), this, SLOT(loadStarted())); … … 106 85 m_inspector = new WebInspector(splitter); 107 86 #ifndef QT_NO_PROPERTIES 108 if (! gInspectorUrl.isEmpty())109 m_inspector->setProperty("_q_inspectorUrl", gInspectorUrl);87 if (!m_windowOptions.inspectorUrl.isEmpty()) 88 m_inspector->setProperty("_q_inspectorUrl", m_windowOptions.inspectorUrl); 110 89 #endif 111 90 m_inspector->setPage(page()); … … 121 100 } 122 101 123 void LauncherWindow::initializeView( bool useGraphicsView)102 void LauncherWindow::initializeView() 124 103 { 125 104 delete m_view; … … 127 106 QSplitter* splitter = static_cast<QSplitter*>(centralWidget()); 128 107 129 if (! useGraphicsView) {108 if (!m_windowOptions.useGraphicsView) { 130 109 WebViewTraditional* view = new WebViewTraditional(splitter); 131 110 view->setPage(page()); … … 278 257 QAction* toggleResizesToContents = graphicsViewMenu->addAction("Toggle Resizes To Contents Mode", this, SLOT(toggleResizesToContents(bool))); 279 258 toggleResizesToContents->setCheckable(true); 280 toggleResizesToContents->setChecked( gResizesToContents);259 toggleResizesToContents->setChecked(m_windowOptions.resizesToContents); 281 260 toggleResizesToContents->setEnabled(isGraphicsBased()); 282 261 toggleResizesToContents->connect(toggleGraphicsView, SIGNAL(toggled(bool)), SLOT(setEnabled(bool))); … … 284 263 QAction* toggleTiledBackingStore = graphicsViewMenu->addAction("Toggle Tiled Backing Store", this, SLOT(toggleTiledBackingStore(bool))); 285 264 toggleTiledBackingStore->setCheckable(true); 286 toggle TiledBackingStore->setChecked(false);265 toggleResizesToContents->setChecked(m_windowOptions.useTiledBackingStore); 287 266 toggleTiledBackingStore->setEnabled(isGraphicsBased()); 288 267 toggleTiledBackingStore->connect(toggleGraphicsView, SIGNAL(toggled(bool)), SLOT(setEnabled(bool))); … … 291 270 QAction* toggleQGLWidgetViewport = graphicsViewMenu->addAction("Toggle use of QGLWidget Viewport", this, SLOT(toggleQGLWidgetViewport(bool))); 292 271 toggleQGLWidgetViewport->setCheckable(true); 293 toggleQGLWidgetViewport->setChecked( gUseQGLWidgetViewport);272 toggleQGLWidgetViewport->setChecked(m_windowOptions.useQGLWidgetViewport); 294 273 toggleQGLWidgetViewport->setEnabled(isGraphicsBased()); 295 274 toggleQGLWidgetViewport->connect(toggleGraphicsView, SIGNAL(toggled(bool)), SLOT(setEnabled(bool))); … … 302 281 QAction* fullUpdate = viewportUpdateMenu->addAction("FullViewportUpdate"); 303 282 fullUpdate->setCheckable(true); 304 fullUpdate->setChecked(( gViewportUpdateMode == QGraphicsView::FullViewportUpdate) ? true : false);283 fullUpdate->setChecked((m_windowOptions.viewportUpdateMode == QGraphicsView::FullViewportUpdate) ? true : false); 305 284 306 285 QAction* minimalUpdate = viewportUpdateMenu->addAction("MinimalViewportUpdate"); 307 286 minimalUpdate->setCheckable(true); 308 minimalUpdate->setChecked(( gViewportUpdateMode == QGraphicsView::MinimalViewportUpdate) ? true : false);287 minimalUpdate->setChecked((m_windowOptions.viewportUpdateMode == QGraphicsView::MinimalViewportUpdate) ? true : false); 309 288 310 289 QAction* smartUpdate = viewportUpdateMenu->addAction("SmartViewportUpdate"); 311 290 smartUpdate->setCheckable(true); 312 smartUpdate->setChecked(( gViewportUpdateMode == QGraphicsView::SmartViewportUpdate) ? true : false);291 smartUpdate->setChecked((m_windowOptions.viewportUpdateMode == QGraphicsView::SmartViewportUpdate) ? true : false); 313 292 314 293 QAction* boundingRectUpdate = viewportUpdateMenu->addAction("BoundingRectViewportUpdate"); 315 294 boundingRectUpdate->setCheckable(true); 316 boundingRectUpdate->setChecked(( gViewportUpdateMode == QGraphicsView::BoundingRectViewportUpdate) ? true : false);295 boundingRectUpdate->setChecked((m_windowOptions.viewportUpdateMode == QGraphicsView::BoundingRectViewportUpdate) ? true : false); 317 296 318 297 QAction* noUpdate = viewportUpdateMenu->addAction("NoViewportUpdate"); 319 298 noUpdate->setCheckable(true); 320 noUpdate->setChecked(( gViewportUpdateMode == QGraphicsView::NoViewportUpdate) ? true : false);299 noUpdate->setChecked((m_windowOptions.viewportUpdateMode == QGraphicsView::NoViewportUpdate) ? true : false); 321 300 322 301 QSignalMapper* signalMapper = new QSignalMapper(viewportUpdateMenu); … … 368 347 showFPS->setEnabled(isGraphicsBased()); 369 348 showFPS->connect(toggleGraphicsView, SIGNAL(toggled(bool)), SLOT(setEnabled(bool))); 370 showFPS->setChecked( gShowFrameRate);349 showFPS->setChecked(m_windowOptions.showFrameRate); 371 350 } 372 351 … … 376 355 } 377 356 378 inline void applySetting(QWebSettings::WebAttribute type, QWebSettings* settings, QWebSettings* other, bool defaultValue) 379 { 380 settings->setAttribute(type, other ? other->testAttribute(type) : defaultValue); 381 } 382 383 void LauncherWindow::applyPrefs(LauncherWindow* source) 384 { 385 QWebSettings* other = source ? source->page()->settings() : 0; 357 void LauncherWindow::applyPrefs() 358 { 386 359 QWebSettings* settings = page()->settings(); 387 388 applySetting(QWebSettings::AcceleratedCompositingEnabled, settings, other, gUseCompositing); 389 applySetting(QWebSettings::TiledBackingStoreEnabled, settings, other, gUseTiledBackingStore); 390 applySetting(QWebSettings::WebGLEnabled, settings, other, false); 391 applySetting(QWebSettings::FrameFlatteningEnabled, settings, other, gUseFrameFlattening); 360 settings->setAttribute(QWebSettings::AcceleratedCompositingEnabled, m_windowOptions.useCompositing); 361 settings->setAttribute(QWebSettings::TiledBackingStoreEnabled, m_windowOptions.useTiledBackingStore); 362 settings->setAttribute(QWebSettings::FrameFlatteningEnabled, m_windowOptions.useFrameFlattening); 363 settings->setAttribute(QWebSettings::WebGLEnabled, m_windowOptions.useWebGL); 392 364 393 365 if (!isGraphicsBased()) … … 395 367 396 368 WebViewGraphicsBased* view = static_cast<WebViewGraphicsBased*>(m_view); 397 WebViewGraphicsBased* otherView = source ? qobject_cast<WebViewGraphicsBased*>(source->m_view) : 0; 398 399 view->setViewportUpdateMode(otherView ? otherView->viewportUpdateMode() : gViewportUpdateMode); 400 view->setFrameRateMeasurementEnabled(otherView ? otherView->frameRateMeasurementEnabled() : gShowFrameRate); 401 402 if (otherView) { 403 view->setItemCacheMode(otherView->itemCacheMode()); 404 view->setResizesToContents(otherView->resizesToContents()); 405 view->setCustomLayoutSize(otherView->customLayoutSize()); 406 } else { 407 view->setItemCacheMode(gCacheWebView ? QGraphicsItem::DeviceCoordinateCache : QGraphicsItem::NoCache); 408 toggleResizesToContents(gResizesToContents); 369 view->setViewportUpdateMode(m_windowOptions.viewportUpdateMode); 370 view->setFrameRateMeasurementEnabled(m_windowOptions.showFrameRate); 371 view->setItemCacheMode(m_windowOptions.cacheWebView ? QGraphicsItem::DeviceCoordinateCache : QGraphicsItem::NoCache); 372 373 if (m_windowOptions.resizesToContents) { 374 view->setCustomLayoutSize(size()); 375 toggleResizesToContents(m_windowOptions.resizesToContents); 409 376 } 410 377 } … … 713 680 void LauncherWindow::toggleAcceleratedCompositing(bool toggle) 714 681 { 715 gUseCompositing = toggle;682 m_windowOptions.useCompositing = toggle; 716 683 page()->settings()->setAttribute(QWebSettings::AcceleratedCompositingEnabled, toggle); 717 684 } … … 724 691 void LauncherWindow::toggleResizesToContents(bool toggle) 725 692 { 726 gResizesToContents = toggle;693 m_windowOptions.resizesToContents = toggle; 727 694 static_cast<WebViewGraphicsBased*>(m_view)->setResizesToContents(toggle); 728 695 } … … 730 697 void LauncherWindow::toggleWebGL(bool toggle) 731 698 { 699 m_windowOptions.useWebGL = toggle; 732 700 page()->settings()->setAttribute(QWebSettings::WebGLEnabled, toggle); 733 701 } … … 753 721 void LauncherWindow::toggleFrameFlattening(bool toggle) 754 722 { 755 gUseFrameFlattening = toggle;723 m_windowOptions.useFrameFlattening = toggle; 756 724 page()->settings()->setAttribute(QWebSettings::FrameFlatteningEnabled, toggle); 757 725 } … … 773 741 return; 774 742 775 gUseQGLWidgetViewport = enable;743 m_windowOptions.useQGLWidgetViewport = enable; 776 744 WebViewGraphicsBased* view = static_cast<WebViewGraphicsBased*>(m_view); 777 745 … … 782 750 void LauncherWindow::changeViewportUpdateMode(int mode) 783 751 { 784 gViewportUpdateMode = QGraphicsView::ViewportUpdateMode(mode);752 m_windowOptions.viewportUpdateMode = QGraphicsView::ViewportUpdateMode(mode); 785 753 786 754 if (!isGraphicsBased()) … … 788 756 789 757 WebViewGraphicsBased* view = static_cast<WebViewGraphicsBased*>(m_view); 790 view->setViewportUpdateMode( gViewportUpdateMode);758 view->setViewportUpdateMode(m_windowOptions.viewportUpdateMode); 791 759 } 792 760 … … 796 764 return; 797 765 798 gShowFrameRate = enable;766 m_windowOptions.showFrameRate = enable; 799 767 WebViewGraphicsBased* view = static_cast<WebViewGraphicsBased*>(m_view); 800 768 view->setFrameRateMeasurementEnabled(enable); … … 869 837 LauncherWindow* LauncherWindow::newWindow() 870 838 { 871 LauncherWindow* mw = new LauncherWindow( this, false);839 LauncherWindow* mw = new LauncherWindow(&m_windowOptions); 872 840 mw->show(); 873 841 return mw; … … 876 844 LauncherWindow* LauncherWindow::cloneWindow() 877 845 { 878 LauncherWindow* mw = new LauncherWindow( this, true);846 LauncherWindow* mw = new LauncherWindow(&m_windowOptions, qobject_cast<QGraphicsView*>(m_view)->scene()); 879 847 mw->show(); 880 848 return mw; -
trunk/WebKitTools/QtTestBrowser/launcherwindow.h
r64353 r64673 76 76 #endif 77 77 78 class WindowOptions { 79 public: 80 WindowOptions() 81 : useGraphicsView(false) 82 , useCompositing(true) 83 , useTiledBackingStore(false) 84 , useWebGL(false) 85 #if defined(Q_WS_MAEMO_5) || defined(Q_WS_S60) 86 , useFrameFlattening(true) 87 #else 88 , useFrameFlattening(false) 89 #endif 90 , cacheWebView(false) 91 , showFrameRate(false) 92 , resizesToContents(false) 93 , viewportUpdateMode(QGraphicsView::MinimalViewportUpdate) 94 #if defined(QT_CONFIGURED_WITH_OPENGL) 95 , useQGLWidgetViewport(false) 96 #endif 97 { 98 } 99 100 bool useGraphicsView; 101 bool useCompositing; 102 bool useTiledBackingStore; 103 bool useWebGL; 104 bool useFrameFlattening; 105 bool cacheWebView; 106 bool showFrameRate; 107 bool resizesToContents; 108 QGraphicsView::ViewportUpdateMode viewportUpdateMode; 109 #if defined(QT_CONFIGURED_WITH_OPENGL) 110 bool useQGLWidgetViewport; 111 #endif 112 QUrl inspectorUrl; 113 }; 114 78 115 class LauncherWindow : public MainWindow { 79 116 Q_OBJECT 80 117 81 118 public: 82 LauncherWindow( LauncherWindow* other = 0, bool shareScene = false);119 LauncherWindow(WindowOptions* data = 0, QGraphicsScene* sharedScene = 0); 83 120 virtual ~LauncherWindow(); 84 121 … … 91 128 92 129 bool eventFilter(QObject* obj, QEvent* event); 93 94 public:95 static const int gExitClickArea = 80;96 static bool gUseGraphicsView;97 static bool gUseCompositing;98 static bool gCacheWebView;99 static bool gShowFrameRate;100 static bool gResizesToContents;101 static bool gUseTiledBackingStore;102 static bool gUseFrameFlattening;103 static QGraphicsView::ViewportUpdateMode gViewportUpdateMode;104 static QUrl gInspectorUrl;105 106 #if defined(QT_CONFIGURED_WITH_OPENGL)107 static bool gUseQGLWidgetViewport;108 #endif109 130 110 131 protected slots: … … 128 149 void dumpHtml(); 129 150 130 void initializeView( bool useGraphicsView = false);151 void initializeView(); 131 152 132 153 void setTouchMocking(bool on); … … 159 180 160 181 private: 161 void init( bool useGraphicsView = false);182 void init(); 162 183 bool isGraphicsBased() const; 163 184 void createChrome(); 164 void applyPrefs( LauncherWindow* other = 0);185 void applyPrefs(); 165 186 void applyZoom(); 166 187 … … 171 192 QWidget* m_view; 172 193 WebInspector* m_inspector; 194 195 WindowOptions m_windowOptions; 173 196 174 197 QAction* m_formatMenuAction; -
trunk/WebKitTools/QtTestBrowser/main.cpp
r64297 r64673 34 34 #include "urlloader.h" 35 35 36 WindowOptions windowOptions; 37 36 38 int launcherMain(const QApplication& app) 37 39 { … … 90 92 static void requiresGraphicsView(const QString& option) 91 93 { 92 if ( LauncherWindow::gUseGraphicsView)94 if (windowOptions.useGraphicsView) 93 95 return; 94 96 appQuit(1, QString("%1 only works in combination with the -graphicsbased option").arg(option)); … … 122 124 123 125 if (args.contains("-graphicsbased")) 124 LauncherWindow::gUseGraphicsView = true;126 windowOptions.useGraphicsView = true; 125 127 126 128 if (args.contains("-no-compositing")) { 127 129 requiresGraphicsView("-no-compositing"); 128 LauncherWindow::gUseCompositing = false;130 windowOptions.useCompositing = false; 129 131 } 130 132 131 133 if (args.contains("-show-fps")) { 132 134 requiresGraphicsView("-show-fps"); 133 LauncherWindow::gShowFrameRate = true;135 windowOptions.showFrameRate = true; 134 136 } 135 137 136 138 if (args.contains("-cache-webview")) { 137 139 requiresGraphicsView("-cache-webview"); 138 LauncherWindow::gCacheWebView = true;140 windowOptions.cacheWebView = true; 139 141 } 140 142 141 143 if (args.contains("-tiled-backing-store")) { 142 144 requiresGraphicsView("-tiled-backing-store"); 143 LauncherWindow::gUseTiledBackingStore = true;145 windowOptions.useTiledBackingStore = true; 144 146 } 145 147 146 148 if (args.contains("-resizes-to-contents")) { 147 149 requiresGraphicsView("-resizes-to-contents"); 148 LauncherWindow::gResizesToContents = true;150 windowOptions.resizesToContents = true; 149 151 } 150 152 … … 161 163 appQuit(1, QString("%1 value has to be one of [%2]").arg(arg1).arg(formatKeys(updateModes))); 162 164 163 LauncherWindow::gViewportUpdateMode = static_cast<QGraphicsView::ViewportUpdateMode>(idx);165 windowOptions.viewportUpdateMode = static_cast<QGraphicsView::ViewportUpdateMode>(idx); 164 166 } 165 167 … … 167 169 int inspectorUrlIndex = args.indexOf(inspectorUrlArg); 168 170 if (inspectorUrlIndex != -1) 169 LauncherWindow::gInspectorUrl = takeOptionValue(&args, inspectorUrlIndex);171 windowOptions.inspectorUrl = takeOptionValue(&args, inspectorUrlIndex); 170 172 171 173 int robotIndex = args.indexOf("-r"); … … 214 216 LauncherWindow* newWindow; 215 217 if (!window) 216 newWindow = window = new LauncherWindow( );218 newWindow = window = new LauncherWindow(&windowOptions); 217 219 else 218 220 newWindow = window->newWindow();
Note: See TracChangeset
for help on using the changeset viewer.