summaryrefslogtreecommitdiff
path: root/Tools/QtTestBrowser
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2016-12-26 00:24:34 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2017-02-02 12:31:19 +0000
commitb9e202b0f12f275d4aade98943df92bf67684f52 (patch)
tree4471f3da5f573679c3f42b0ad54c46bdd0a50910 /Tools/QtTestBrowser
parent1c8f056531c65706b85c44c2db657ea891be868d (diff)
downloadqtwebkit-b9e202b0f12f275d4aade98943df92bf67684f52.tar.gz
Imported WebKit commit 12fbea815480c3b3fad139cd8dfb82e8c954bc9a
Change-Id: Iccbb1e8bd8b7f72322614224c203fc509a8dbb79 Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Tools/QtTestBrowser')
-rw-r--r--Tools/QtTestBrowser/cookiejar.h4
-rw-r--r--Tools/QtTestBrowser/fpstimer.h4
-rw-r--r--Tools/QtTestBrowser/launcherwindow.cpp9
-rw-r--r--Tools/QtTestBrowser/launcherwindow.h6
-rw-r--r--Tools/QtTestBrowser/locationedit.h6
-rw-r--r--Tools/QtTestBrowser/mainwindow.cpp10
-rw-r--r--Tools/QtTestBrowser/mainwindow.h2
-rw-r--r--Tools/QtTestBrowser/webinspector.h6
-rw-r--r--Tools/QtTestBrowser/webpage.cpp24
-rw-r--r--Tools/QtTestBrowser/webpage.h6
-rw-r--r--Tools/QtTestBrowser/webview.h18
11 files changed, 72 insertions, 23 deletions
diff --git a/Tools/QtTestBrowser/cookiejar.h b/Tools/QtTestBrowser/cookiejar.h
index da62fb829..701cffc1f 100644
--- a/Tools/QtTestBrowser/cookiejar.h
+++ b/Tools/QtTestBrowser/cookiejar.h
@@ -33,14 +33,14 @@
#include <QNetworkCookieJar>
#include <QTimer>
-class TestBrowserCookieJar : public QNetworkCookieJar {
+class TestBrowserCookieJar final : public QNetworkCookieJar {
Q_OBJECT
public:
TestBrowserCookieJar(QObject* parent = 0);
virtual ~TestBrowserCookieJar();
- virtual bool setCookiesFromUrl(const QList<QNetworkCookie>&, const QUrl&);
+ bool setCookiesFromUrl(const QList<QNetworkCookie>&, const QUrl&) final;
void setDiskStorageEnabled(bool);
diff --git a/Tools/QtTestBrowser/fpstimer.h b/Tools/QtTestBrowser/fpstimer.h
index 256745aa8..833b3cc74 100644
--- a/Tools/QtTestBrowser/fpstimer.h
+++ b/Tools/QtTestBrowser/fpstimer.h
@@ -32,7 +32,7 @@
#include <QSet>
#include <QTime>
-class FpsTimer : public QObject {
+class FpsTimer final : public QObject {
Q_OBJECT
public:
@@ -44,7 +44,7 @@ public Q_SLOTS:
void stop();
protected Q_SLOTS:
- virtual void timerEvent(QTimerEvent*);
+ void timerEvent(QTimerEvent*) final;
private:
int m_timer;
diff --git a/Tools/QtTestBrowser/launcherwindow.cpp b/Tools/QtTestBrowser/launcherwindow.cpp
index 84a4c0873..537eccf64 100644
--- a/Tools/QtTestBrowser/launcherwindow.cpp
+++ b/Tools/QtTestBrowser/launcherwindow.cpp
@@ -381,6 +381,9 @@ void LauncherWindow::createChrome()
toolsMenu->addSeparator();
toolsMenu->addAction("Load URLs from file", this, SLOT(loadURLListFromFile()));
+ toolsMenu->addSeparator();
+ toolsMenu->addAction("Clear memory caches", this, SLOT(clearMemoryCaches()));
+
// GraphicsView sub menu.
QAction* toggleAcceleratedCompositing = graphicsViewMenu->addAction("Toggle Accelerated Compositing", this, SLOT(toggleAcceleratedCompositing(bool)));
toggleAcceleratedCompositing->setCheckable(true);
@@ -1110,6 +1113,12 @@ void LauncherWindow::fileDownloadFinished()
}
#endif
+void LauncherWindow::clearMemoryCaches()
+{
+ QWebSettings::clearMemoryCaches();
+ qDebug() << "Memory caches were cleared";
+}
+
void LauncherWindow::updateFPS(int fps)
{
QString fpsStatusText = QString("Current FPS: %1").arg(fps);
diff --git a/Tools/QtTestBrowser/launcherwindow.h b/Tools/QtTestBrowser/launcherwindow.h
index 9fd41a445..d4a3b832d 100644
--- a/Tools/QtTestBrowser/launcherwindow.h
+++ b/Tools/QtTestBrowser/launcherwindow.h
@@ -91,7 +91,7 @@ public:
bool startMaximized { false };
};
-class LauncherWindow : public MainWindow {
+class LauncherWindow final : public MainWindow {
Q_OBJECT
public:
@@ -100,7 +100,7 @@ public:
void sendTouchEvent();
- bool eventFilter(QObject*, QEvent*);
+ bool eventFilter(QObject*, QEvent*) final;
protected Q_SLOTS:
void loadStarted();
@@ -170,6 +170,8 @@ protected Q_SLOTS:
void fileDownloadFinished();
#endif
+ void clearMemoryCaches();
+
public Q_SLOTS:
LauncherWindow* newWindow();
LauncherWindow* cloneWindow();
diff --git a/Tools/QtTestBrowser/locationedit.h b/Tools/QtTestBrowser/locationedit.h
index 5750cba36..43b30e38d 100644
--- a/Tools/QtTestBrowser/locationedit.h
+++ b/Tools/QtTestBrowser/locationedit.h
@@ -36,7 +36,7 @@
#include <QStyleOptionFrame>
#include <QTimer>
-class LocationEdit : public QLineEdit {
+class LocationEdit final : public QLineEdit {
Q_OBJECT
public:
@@ -51,8 +51,8 @@ private Q_SLOTS:
void reset();
protected:
- virtual void paintEvent(QPaintEvent*);
- virtual void resizeEvent(QResizeEvent*);
+ void paintEvent(QPaintEvent*) final;
+ void resizeEvent(QResizeEvent*) final;
private:
void updateInternalGeometry();
diff --git a/Tools/QtTestBrowser/mainwindow.cpp b/Tools/QtTestBrowser/mainwindow.cpp
index 68217696b..d342147ac 100644
--- a/Tools/QtTestBrowser/mainwindow.cpp
+++ b/Tools/QtTestBrowser/mainwindow.cpp
@@ -42,6 +42,7 @@
#ifndef QT_NO_FILEDIALOG
#include <QFileDialog>
#endif
+#include <QMenuBar>
MainWindow::MainWindow()
: m_page(new WebPage(this))
@@ -118,6 +119,15 @@ void MainWindow::setPage(WebPage* page)
buildUI();
}
+void MainWindow::setToolBarsVisible(bool visible)
+{
+ if (menuBar())
+ menuBar()->setVisible(visible);
+
+ if (m_toolBar)
+ m_toolBar->setVisible(visible);
+}
+
WebPage* MainWindow::page() const
{
return m_page;
diff --git a/Tools/QtTestBrowser/mainwindow.h b/Tools/QtTestBrowser/mainwindow.h
index 70b3e5e1c..6e978576e 100644
--- a/Tools/QtTestBrowser/mainwindow.h
+++ b/Tools/QtTestBrowser/mainwindow.h
@@ -55,6 +55,8 @@ public:
WebPage* page() const;
void setPage(WebPage*);
+ void setToolBarsVisible(bool);
+
protected Q_SLOTS:
void setAddressUrl(const QString&);
void setAddressUrl(const QUrl&);
diff --git a/Tools/QtTestBrowser/webinspector.h b/Tools/QtTestBrowser/webinspector.h
index c75bbdc2f..72a3a3b48 100644
--- a/Tools/QtTestBrowser/webinspector.h
+++ b/Tools/QtTestBrowser/webinspector.h
@@ -30,7 +30,7 @@
#include "qwebinspector.h"
-class WebInspector : public QWebInspector {
+class WebInspector final : public QWebInspector {
Q_OBJECT
public:
@@ -40,12 +40,12 @@ Q_SIGNALS:
void visibleChanged(bool nowVisible);
protected:
- void showEvent(QShowEvent* event)
+ void showEvent(QShowEvent* event) final
{
QWebInspector::showEvent(event);
emit visibleChanged(true);
}
- void hideEvent(QHideEvent* event)
+ void hideEvent(QHideEvent* event) final
{
QWebInspector::hideEvent(event);
emit visibleChanged(false);
diff --git a/Tools/QtTestBrowser/webpage.cpp b/Tools/QtTestBrowser/webpage.cpp
index 1a3ae3c82..a0efed1d8 100644
--- a/Tools/QtTestBrowser/webpage.cpp
+++ b/Tools/QtTestBrowser/webpage.cpp
@@ -33,6 +33,7 @@
#include "webpage.h"
#include "launcherwindow.h"
+#include "mainwindow.h"
#include <QAction>
#include <QApplication>
@@ -47,13 +48,16 @@
#ifndef QT_NO_LINEEDIT
#include <QLineEdit>
#endif
+#include <QMessageBox>
#include <QProgressBar>
+#include <QWindow>
#include <QtNetwork/QNetworkReply>
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkProxy>
-WebPage::WebPage(QObject* parent)
+WebPage::WebPage(MainWindow* parent)
: QWebPage(parent)
+ , m_mainWindow(parent)
, m_userAgent()
, m_interruptingJavaScriptEnabled(false)
{
@@ -63,6 +67,7 @@ WebPage::WebPage(QObject* parent)
this, SLOT(authenticationRequired(QNetworkReply*, QAuthenticator*)));
connect(this, SIGNAL(featurePermissionRequested(QWebFrame*, QWebPage::Feature)), this, SLOT(requestPermission(QWebFrame*, QWebPage::Feature)));
connect(this, SIGNAL(featurePermissionRequestCanceled(QWebFrame*, QWebPage::Feature)), this, SLOT(featurePermissionRequestCanceled(QWebFrame*, QWebPage::Feature)));
+ connect(this, &QWebPage::fullScreenRequested, this, &WebPage::requestFullScreen);
}
void WebPage::applyProxy()
@@ -201,6 +206,23 @@ void WebPage::featurePermissionRequestCanceled(QWebFrame*, QWebPage::Feature)
{
}
+void WebPage::requestFullScreen(QWebFullScreenRequest request)
+{
+ if (request.toggleOn()) {
+ if (QMessageBox::question(view(), "Enter Full Screen Mode", "Do you want to enter full screen mode?", QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel) == QMessageBox::Ok) {
+ request.accept();
+ m_mainWindow->setToolBarsVisible(false);
+ m_mainWindow->showFullScreen();
+ return;
+ }
+ } else {
+ request.accept();
+ m_mainWindow->setToolBarsVisible(true);
+ m_mainWindow->showNormal();
+ return;
+ }
+ request.reject();
+}
QWebPage* WebPage::createWindow(QWebPage::WebWindowType type)
{
LauncherWindow* mw = new LauncherWindow;
diff --git a/Tools/QtTestBrowser/webpage.h b/Tools/QtTestBrowser/webpage.h
index 1a6ef2e38..0238354aa 100644
--- a/Tools/QtTestBrowser/webpage.h
+++ b/Tools/QtTestBrowser/webpage.h
@@ -36,11 +36,13 @@
#include <qwebframe.h>
#include <qwebpage.h>
+class MainWindow;
+
class WebPage : public QWebPage {
Q_OBJECT
public:
- WebPage(QObject* parent = 0);
+ WebPage(MainWindow* parent);
QWebPage* createWindow(QWebPage::WebWindowType) override;
QObject* createPlugin(const QString&, const QUrl&, const QStringList&, const QStringList&) override;
@@ -62,9 +64,11 @@ public Q_SLOTS:
void authenticationRequired(QNetworkReply*, QAuthenticator*);
void requestPermission(QWebFrame*, QWebPage::Feature);
void featurePermissionRequestCanceled(QWebFrame*, QWebPage::Feature);
+ void requestFullScreen(QWebFullScreenRequest);
private:
void applyProxy();
+ MainWindow *m_mainWindow;
QString m_userAgent;
bool m_interruptingJavaScriptEnabled;
};
diff --git a/Tools/QtTestBrowser/webview.h b/Tools/QtTestBrowser/webview.h
index a45a972b7..de0b273de 100644
--- a/Tools/QtTestBrowser/webview.h
+++ b/Tools/QtTestBrowser/webview.h
@@ -45,31 +45,31 @@ QT_BEGIN_NAMESPACE
class QStateMachine;
QT_END_NAMESPACE
-class WebViewTraditional : public QWebView {
+class WebViewTraditional final : public QWebView {
Q_OBJECT
public:
WebViewTraditional(QWidget* parent) : QWebView(parent) {}
protected:
- virtual void contextMenuEvent(QContextMenuEvent*);
- virtual void mousePressEvent(QMouseEvent*);
+ void contextMenuEvent(QContextMenuEvent*) final;
+ void mousePressEvent(QMouseEvent*) final;
};
-class GraphicsWebView : public QGraphicsWebView {
+class GraphicsWebView final : public QGraphicsWebView {
Q_OBJECT
public:
GraphicsWebView(QGraphicsItem* parent = 0) : QGraphicsWebView(parent) {};
protected:
- virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent*);
- virtual void mousePressEvent(QGraphicsSceneMouseEvent*);
+ void contextMenuEvent(QGraphicsSceneContextMenuEvent*) final;
+ void mousePressEvent(QGraphicsSceneMouseEvent*) final;
};
-class WebViewGraphicsBased : public QGraphicsView {
+class WebViewGraphicsBased final : public QGraphicsView {
Q_OBJECT
Q_PROPERTY(qreal yRotation READ yRotation WRITE setYRotation)
@@ -83,8 +83,8 @@ public:
void setFrameRateMeasurementEnabled(bool);
bool frameRateMeasurementEnabled() const { return m_measureFps; }
- virtual void resizeEvent(QResizeEvent*);
- virtual void paintEvent(QPaintEvent*);
+ void resizeEvent(QResizeEvent*) final;
+ void paintEvent(QPaintEvent*) final;
void setResizesToContents(bool);
bool resizesToContents() const { return m_resizesToContents; }