diff options
author | Steve Block <steveblock@google.com> | 2011-05-25 19:08:45 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-06-08 13:51:31 +0100 |
commit | 2bde8e466a4451c7319e3a072d118917957d6554 (patch) | |
tree | 28f4a1b869a513e565c7760d0e6a06e7cf1fe95a /Tools/QtTestBrowser | |
parent | 6939c99b71d9372d14a0c74a772108052e8c48c8 (diff) | |
download | external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.zip external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.gz external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.bz2 |
Merge WebKit at r82507: Initial merge by git
Change-Id: I60ce9d780725b58b45e54165733a8ffee23b683e
Diffstat (limited to 'Tools/QtTestBrowser')
-rw-r--r-- | Tools/QtTestBrowser/QtTestBrowser.pro | 8 | ||||
-rw-r--r-- | Tools/QtTestBrowser/QtTestBrowser.qrc | 1 | ||||
-rw-r--r-- | Tools/QtTestBrowser/favicon.png | bin | 0 -> 891 bytes | |||
-rw-r--r-- | Tools/QtTestBrowser/launcherwindow.cpp | 15 | ||||
-rw-r--r-- | Tools/QtTestBrowser/launcherwindow.h | 12 | ||||
-rw-r--r-- | Tools/QtTestBrowser/locationedit.cpp | 48 | ||||
-rw-r--r-- | Tools/QtTestBrowser/locationedit.h | 6 | ||||
-rw-r--r-- | Tools/QtTestBrowser/main.cpp | 81 | ||||
-rw-r--r-- | Tools/QtTestBrowser/mainwindow.cpp | 27 | ||||
-rw-r--r-- | Tools/QtTestBrowser/mainwindow.h | 3 |
10 files changed, 196 insertions, 5 deletions
diff --git a/Tools/QtTestBrowser/QtTestBrowser.pro b/Tools/QtTestBrowser/QtTestBrowser.pro index 6c8cdf4..4cd7ecb 100644 --- a/Tools/QtTestBrowser/QtTestBrowser.pro +++ b/Tools/QtTestBrowser/QtTestBrowser.pro @@ -26,6 +26,7 @@ CONFIG += uitools isEmpty(OUTPUT_DIR): OUTPUT_DIR = ../.. include(../../Source/WebKit.pri) +INCLUDEPATH += ../../Source/WebKit/qt/WebCoreSupport DESTDIR = $$OUTPUT_DIR/bin !CONFIG(standalone_package): CONFIG -= app_bundle @@ -33,6 +34,11 @@ DESTDIR = $$OUTPUT_DIR/bin QT += network macx:QT+=xml +unix:!mac:!symbian { + CONFIG += link_pkgconfig + PKGCONFIG += fontconfig +} + linux-* { # From Creator's src/rpath.pri: # Do the rpath by hand since it's not possible to use ORIGIN in QMAKE_RPATHDIR @@ -57,5 +63,7 @@ contains(QT_CONFIG, opengl) { DEFINES += QT_CONFIGURED_WITH_OPENGL } +DEFINES -= QT_ASCII_CAST_WARNINGS + RESOURCES += \ QtTestBrowser.qrc diff --git a/Tools/QtTestBrowser/QtTestBrowser.qrc b/Tools/QtTestBrowser/QtTestBrowser.qrc index ffe77b0..b6036e8 100644 --- a/Tools/QtTestBrowser/QtTestBrowser.qrc +++ b/Tools/QtTestBrowser/QtTestBrowser.qrc @@ -1,5 +1,6 @@ <RCC> <qresource prefix="/"> <file>useragentlist.txt</file> + <file>favicon.png</file> </qresource> </RCC> diff --git a/Tools/QtTestBrowser/favicon.png b/Tools/QtTestBrowser/favicon.png Binary files differnew file mode 100644 index 0000000..4462752 --- /dev/null +++ b/Tools/QtTestBrowser/favicon.png diff --git a/Tools/QtTestBrowser/launcherwindow.cpp b/Tools/QtTestBrowser/launcherwindow.cpp index d76ad3a..f4db898 100644 --- a/Tools/QtTestBrowser/launcherwindow.cpp +++ b/Tools/QtTestBrowser/launcherwindow.cpp @@ -108,6 +108,10 @@ void LauncherWindow::initializeView() m_view = view; } else { WebViewGraphicsBased* view = new WebViewGraphicsBased(splitter); + m_view = view; +#if defined(QT_CONFIGURED_WITH_OPENGL) + toggleQGLWidgetViewport(m_windowOptions.useQGLWidgetViewport); +#endif view->setPage(page()); connect(view, SIGNAL(currentFPSUpdated(int)), this, SLOT(updateFPS(int))); @@ -116,8 +120,6 @@ void LauncherWindow::initializeView() // The implementation of QAbstractScrollArea::eventFilter makes us need // to install the event filter also on the viewport of a QGraphicsView. view->viewport()->installEventFilter(this); - - m_view = view; } m_touchMocking = false; @@ -128,6 +130,9 @@ void LauncherWindow::initializeView() this, SLOT(showLinkHover(const QString&, const QString&))); connect(this, SIGNAL(enteredFullScreenMode(bool)), this, SLOT(toggleFullScreenMode(bool))); + if (m_windowOptions.printLoadedUrls) + connect(page()->mainFrame(), SIGNAL(urlChanged(QUrl)), this, SLOT(printURL(QUrl))); + applyPrefs(); splitter->addWidget(m_inspector); @@ -895,6 +900,12 @@ void LauncherWindow::showUserAgentDialog() delete dialog; } +void LauncherWindow::printURL(const QUrl& url) +{ + QTextStream output(stdout); + output << "Loaded: " << url.toString() << endl; +} + 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 0b8e87d..8bdad4d 100644 --- a/Tools/QtTestBrowser/launcherwindow.h +++ b/Tools/QtTestBrowser/launcherwindow.h @@ -61,13 +61,13 @@ #include <qx11info_x11.h> #endif +#include "DumpRenderTreeSupportQt.h" #include "mainwindow.h" #include "urlloader.h" #include "utils.h" #include "webinspector.h" #include "webpage.h" #include "webview.h" -#include "../../Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h" #ifdef Q_WS_MAEMO_5 #include <X11/Xatom.h> @@ -100,6 +100,10 @@ public: #if defined(QT_CONFIGURED_WITH_OPENGL) , useQGLWidgetViewport(false) #endif +#if defined(Q_WS_X11) + , useTestFonts(false) +#endif + , printLoadedUrls(false) { } @@ -119,6 +123,10 @@ public: #if defined(QT_CONFIGURED_WITH_OPENGL) bool useQGLWidgetViewport; #endif +#if defined(Q_WS_X11) + bool useTestFonts; +#endif + bool printLoadedUrls; QUrl inspectorUrl; quint16 remoteInspectorPort; }; @@ -186,6 +194,8 @@ protected slots: void showFPS(bool enable); void showUserAgentDialog(); + void printURL(const QUrl&); + public slots: LauncherWindow* newWindow(); LauncherWindow* cloneWindow(); diff --git a/Tools/QtTestBrowser/locationedit.cpp b/Tools/QtTestBrowser/locationedit.cpp index 85bd222..04a6018 100644 --- a/Tools/QtTestBrowser/locationedit.cpp +++ b/Tools/QtTestBrowser/locationedit.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * Copyright (C) 2011 Andreas Kling <kling@webkit.org> * * All rights reserved. * @@ -29,12 +30,35 @@ #ifndef QT_NO_INPUTDIALOG +static const QSize gPageIconSize(16, 16); + +static QPixmap defaultPageIcon() +{ + static QPixmap icon; + if (icon.isNull()) + icon.load(":/favicon.png"); + + return icon; +} + LocationEdit::LocationEdit(QWidget* parent) : QLineEdit(parent) , m_progress(0) { m_clearTimer.setSingleShot(true); connect(&m_clearTimer, SIGNAL(timeout()), this, SLOT(reset())); + + m_pageIconLabel = new QLabel(this); + m_pageIconLabel->setFixedSize(gPageIconSize); + m_pageIconLabel->setPixmap(defaultPageIcon()); +} + +void LocationEdit::setPageIcon(const QIcon& icon) +{ + if (icon.isNull()) + m_pageIconLabel->setPixmap(defaultPageIcon()); + else + m_pageIconLabel->setPixmap(icon.pixmap(gPageIconSize)); } void LocationEdit::setProgress(int progress) @@ -49,6 +73,30 @@ void LocationEdit::reset() setProgress(0); } +void LocationEdit::resizeEvent(QResizeEvent*) +{ + updateInternalGeometry(); +} + +void LocationEdit::updateInternalGeometry() +{ + QStyleOptionFrameV3 styleOption; + initStyleOption(&styleOption); + + QRect textRect = style()->subElementRect(QStyle::SE_LineEditContents, &styleOption, this); + + const int spacing = 2; + + int x = textRect.x() + spacing; + int y = (textRect.center().y() + 1) - gPageIconSize.height() / 2; + + m_pageIconLabel->move(x, y); + + QMargins margins = textMargins(); + margins.setLeft(m_pageIconLabel->sizeHint().width() + spacing); + setTextMargins(margins); +} + void LocationEdit::paintEvent(QPaintEvent* ev) { QColor backgroundColor = QApplication::palette().color(QPalette::Base); diff --git a/Tools/QtTestBrowser/locationedit.h b/Tools/QtTestBrowser/locationedit.h index 962b422..e8afe70 100644 --- a/Tools/QtTestBrowser/locationedit.h +++ b/Tools/QtTestBrowser/locationedit.h @@ -39,6 +39,8 @@ class LocationEdit : public QLineEdit { public: LocationEdit(QWidget* parent = 0); + void setPageIcon(const QIcon&); + public slots: void setProgress(int progress); @@ -48,10 +50,14 @@ private slots: protected: virtual void paintEvent(QPaintEvent*); virtual void focusInEvent(QFocusEvent*); + virtual void resizeEvent(QResizeEvent*); private: + void updateInternalGeometry(); + int m_progress; QTimer m_clearTimer; + QLabel* m_pageIconLabel; }; #endif diff --git a/Tools/QtTestBrowser/main.cpp b/Tools/QtTestBrowser/main.cpp index eecd9c3..059269c 100644 --- a/Tools/QtTestBrowser/main.cpp +++ b/Tools/QtTestBrowser/main.cpp @@ -35,8 +35,68 @@ WindowOptions windowOptions; + +#include <QDir> +#include <QFile> +#include <QFileInfo> +#include <QFontDatabase> + + +#if defined(Q_WS_X11) +#include <fontconfig/fontconfig.h> +#endif + + +#if defined(Q_WS_X11) +// Very similar to WebCore::DumpRenderTree::initializeFonts(); +// Duplicated here so that QtTestBrowser would display contents +// with the same fonts as run-webkit-tests/DumpRenderTree. +static void initTestFonts() +{ + static int numFonts = -1; + + // Some test cases may add or remove application fonts (via @font-face). + // Make sure to re-initialize the font set if necessary. + FcFontSet* appFontSet = FcConfigGetFonts(0, FcSetApplication); + if (appFontSet && numFonts >= 0 && appFontSet->nfont == numFonts) + return; + + QByteArray fontDir = getenv("WEBKIT_TESTFONTS"); + if (fontDir.isEmpty() || !QDir(fontDir).exists()) { + fprintf(stderr, + "\n\n" + "----------------------------------------------------------------------\n" + "WEBKIT_TESTFONTS environment variable is not set correctly.\n" + "This variable has to point to the directory containing the fonts\n" + "you can clone from git://gitorious.org/qtwebkit/testfonts.git\n" + "----------------------------------------------------------------------\n" + ); + exit(1); + } + // Looks for qt/fonts.conf relative to the directory of the QtTestBrowser + // executable. + QString configFileString = QCoreApplication::applicationDirPath(); + configFileString += "/../../../Tools/DumpRenderTree/qt/fonts.conf"; + QByteArray configFileArray = configFileString.toUtf8(); + FcConfig* config = FcConfigCreate(); + if (!FcConfigParseAndLoad (config, (FcChar8*) configFileArray.data(), true)) + qFatal("Couldn't load font configuration file"); + if (!FcConfigAppFontAddDir (config, (FcChar8*) fontDir.data())) + qFatal("Couldn't add font dir!"); + FcConfigSetCurrent(config); + + appFontSet = FcConfigGetFonts(config, FcSetApplication); + numFonts = appFontSet->nfont; +} +#endif + int launcherMain(const QApplication& app) { +#ifdef Q_WS_X11 + if (windowOptions.useTestFonts) + initTestFonts(); +#endif + #ifndef NDEBUG int retVal = app.exec(); DumpRenderTreeSupportQt::garbageCollectorCollect(); @@ -117,6 +177,10 @@ void LauncherApplication::handleUserOptions() qDebug() << "Usage:" << programName.toLatin1().data() << "[-graphicsbased]" << "[-no-compositing]" +#if defined(QT_CONFIGURED_WITH_OPENGL) + << "[-gl-viewport]" + << "[-webgl]" +#endif << QString("[-viewport-update-mode %1]").arg(formatKeys(updateModes)).toLatin1().data() << "[-cache-webview]" << "[-show-fps]" @@ -130,6 +194,10 @@ void LauncherApplication::handleUserOptions() << "[-offline-storage-database-enabled]" << "[-offline-web-application-cache-enabled]" << "[-set-offline-storage-default-quota maxSize]" +#if defined(Q_WS_X11) + << "[-use-test-fonts]" +#endif + << "[-print-loaded-urls]" << "URLs"; appQuit(0); } @@ -200,8 +268,21 @@ void LauncherApplication::handleUserOptions() requiresGraphicsView("-gl-viewport"); windowOptions.useQGLWidgetViewport = true; } + + if (args.contains("-webgl")) { + requiresGraphicsView("-webgl"); + windowOptions.useWebGL = true; + } #endif +#if defined(Q_WS_X11) + if (args.contains("-use-test-fonts")) + windowOptions.useTestFonts = true; +#endif + + if (args.contains("-print-loaded-urls")) + windowOptions.printLoadedUrls = true; + QString inspectorUrlArg("-inspector-url"); int inspectorUrlIndex = args.indexOf(inspectorUrlArg); if (inspectorUrlIndex != -1) diff --git a/Tools/QtTestBrowser/mainwindow.cpp b/Tools/QtTestBrowser/mainwindow.cpp index e2ea41d..dcd350d 100644 --- a/Tools/QtTestBrowser/mainwindow.cpp +++ b/Tools/QtTestBrowser/mainwindow.cpp @@ -84,8 +84,9 @@ void MainWindow::buildUI() connect(page(), SIGNAL(loadProgress(int)), urlEdit, SLOT(setProgress(int))); #endif - connect(page()->mainFrame(), SIGNAL(titleChanged(const QString&)), - this, SLOT(setWindowTitle(const QString&))); + connect(page()->mainFrame(), SIGNAL(loadStarted()), this, SLOT(onLoadStarted())); + connect(page()->mainFrame(), SIGNAL(iconChanged()), this, SLOT(onIconChanged())); + connect(page()->mainFrame(), SIGNAL(titleChanged(QString)), this, SLOT(onTitleChanged(QString))); connect(page(), SIGNAL(windowCloseRequested()), this, SLOT(close())); #ifndef QT_NO_SHORTCUT @@ -219,3 +220,25 @@ void MainWindow::openLocation() urlEdit->setFocus(); #endif } + +void MainWindow::onIconChanged() +{ +#ifndef QT_NO_INPUTDIALOG + urlEdit->setPageIcon(page()->mainFrame()->icon()); +#endif +} + +void MainWindow::onLoadStarted() +{ +#ifndef QT_NO_INPUTDIALOG + urlEdit->setPageIcon(QIcon()); +#endif +} + +void MainWindow::onTitleChanged(const QString& title) +{ + if (title.isEmpty()) + setWindowTitle(QCoreApplication::applicationName()); + else + setWindowTitle(QString::fromLatin1("%1 - %2").arg(title).arg(QCoreApplication::applicationName())); +} diff --git a/Tools/QtTestBrowser/mainwindow.h b/Tools/QtTestBrowser/mainwindow.h index 08fa81e..f8baebc 100644 --- a/Tools/QtTestBrowser/mainwindow.h +++ b/Tools/QtTestBrowser/mainwindow.h @@ -58,6 +58,9 @@ protected slots: void openFile(); void openLocation(); void changeLocation(); + void onIconChanged(); + void onLoadStarted(); + void onTitleChanged(const QString&); protected: QString addressUrl() const; |