diff options
Diffstat (limited to 'WebKitTools/DumpRenderTree/qt')
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp | 344 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/DumpRenderTree.h | 76 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro | 19 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp | 19 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/ImageDiff.pro | 3 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp | 63 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h | 12 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro | 8 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/WorkQueue.cpp | 102 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/WorkQueue.h | 54 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/WorkQueueItem.h | 21 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/jsobjects.cpp | 5 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/main.cpp | 23 |
13 files changed, 469 insertions, 280 deletions
diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp index 9faa37f..6d466bf 100644 --- a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp @@ -29,6 +29,8 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" + #include "DumpRenderTree.h" #include "EventSenderQt.h" #include "LayoutTestControllerQt.h" @@ -41,25 +43,29 @@ #include <QCryptographicHash> #include <QDir> #include <QFile> -#include <QTimer> -#include <QBoxLayout> -#include <QScrollArea> #include <QApplication> #include <QUrl> +#include <QFileInfo> #include <QFocusEvent> #include <QFontDatabase> +#include <QNetworkAccessManager> +#include <QNetworkReply> #include <QNetworkRequest> +#include <QUndoStack> -#include <qwebpage.h> -#include <qwebframe.h> -#include <qwebview.h> #include <qwebsettings.h> #include <qwebsecurityorigin.h> +#ifndef QT_NO_UITOOLS +#include <QtUiTools/QUiLoader> +#endif + #ifdef Q_WS_X11 #include <fontconfig/fontconfig.h> #endif +#include <limits.h> + #include <unistd.h> #include <qdebug.h> @@ -69,6 +75,7 @@ extern void qt_dump_frame_loader(bool b); extern void qt_drt_clearFrameName(QWebFrame* qFrame); extern void qt_drt_overwritePluginDirectories(); extern void qt_drt_resetOriginAccessWhiteLists(); +extern bool qt_drt_hasDocumentElement(QWebFrame* qFrame); namespace WebCore { @@ -76,39 +83,39 @@ namespace WebCore { const unsigned int maxViewWidth = 800; const unsigned int maxViewHeight = 600; -class WebPage : public QWebPage { - Q_OBJECT -public: - WebPage(QWidget *parent, DumpRenderTree *drt); - - QWebPage *createWindow(QWebPage::WebWindowType); - - void javaScriptAlert(QWebFrame *frame, const QString& message); - void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID); - bool javaScriptConfirm(QWebFrame *frame, const QString& msg); - bool javaScriptPrompt(QWebFrame *frame, const QString& msg, const QString& defaultValue, QString* result); - - void resetSettings(); - -public slots: - bool shouldInterruptJavaScript() { return false; } +NetworkAccessManager::NetworkAccessManager(QObject* parent) + : QNetworkAccessManager(parent) +{ +#ifndef QT_NO_SSL + connect(this, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)), + this, SLOT(sslErrorsEncountered(QNetworkReply*, const QList<QSslError>&))); +#endif +} -protected: - bool acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest& request, NavigationType type); +#ifndef QT_NO_SSL +void NetworkAccessManager::sslErrorsEncountered(QNetworkReply* reply, const QList<QSslError>& errors) +{ + if (reply->url().host() == "127.0.0.1" || reply->url().host() == "localhost") { + bool ignore = true; + + // Accept any HTTPS certificate. + foreach (const QSslError& error, errors) { + if (error.error() < QSslError::UnableToGetIssuerCertificate || error.error() > QSslError::HostNameMismatch) { + ignore = false; + break; + } + } -private slots: - void setViewGeometry(const QRect &r) - { - QWidget *v = view(); - if (v) - v->setGeometry(r); + if (ignore) + reply->ignoreSslErrors(); } -private: - DumpRenderTree *m_drt; -}; +} +#endif -WebPage::WebPage(QWidget *parent, DumpRenderTree *drt) - : QWebPage(parent), m_drt(drt) +WebPage::WebPage(QObject* parent, DumpRenderTree* drt) + : QWebPage(parent) + , m_webInspector(0) + , m_drt(drt) { QWebSettings* globalSettings = QWebSettings::globalSettings(); @@ -129,21 +136,37 @@ WebPage::WebPage(QWidget *parent, DumpRenderTree *drt) connect(this, SIGNAL(geometryChangeRequested(const QRect &)), this, SLOT(setViewGeometry(const QRect & ))); + setNetworkAccessManager(new NetworkAccessManager(this)); setPluginFactory(new TestPlugin(this)); } +WebPage::~WebPage() +{ + delete m_webInspector; +} + +QWebInspector* WebPage::webInspector() +{ + if (!m_webInspector) { + m_webInspector = new QWebInspector; + m_webInspector->setPage(this); + } + return m_webInspector; +} + void WebPage::resetSettings() { // After each layout test, reset the settings that may have been changed by // layoutTestController.overridePreference() or similar. settings()->resetFontSize(QWebSettings::DefaultFontSize); - settings()->resetAttribute(QWebSettings::JavascriptCanOpenWindows); settings()->resetAttribute(QWebSettings::JavascriptEnabled); settings()->resetAttribute(QWebSettings::PrivateBrowsingEnabled); settings()->resetAttribute(QWebSettings::LinksIncludedInFocusChain); settings()->resetAttribute(QWebSettings::OfflineWebApplicationCacheEnabled); + settings()->resetAttribute(QWebSettings::LocalContentCanAccessRemoteUrls); + QWebSettings::setMaximumPagesInCache(0); // reset to default } QWebPage *WebPage::createWindow(QWebPage::WebWindowType) @@ -153,22 +176,52 @@ QWebPage *WebPage::createWindow(QWebPage::WebWindowType) void WebPage::javaScriptAlert(QWebFrame*, const QString& message) { + if (!isTextOutputEnabled()) + return; + fprintf(stdout, "ALERT: %s\n", message.toUtf8().constData()); } +static QString urlSuitableForTestResult(const QString& url) +{ + if (url.isEmpty() || !url.startsWith(QLatin1String("file://"))) + return url; + + return QFileInfo(url).fileName(); +} + void WebPage::javaScriptConsoleMessage(const QString& message, int lineNumber, const QString&) { - fprintf (stdout, "CONSOLE MESSAGE: line %d: %s\n", lineNumber, message.toUtf8().constData()); + if (!isTextOutputEnabled()) + return; + + QString newMessage; + if (!message.isEmpty()) { + newMessage = message; + + size_t fileProtocol = newMessage.indexOf(QLatin1String("file://")); + if (fileProtocol != -1) { + newMessage = newMessage.left(fileProtocol) + urlSuitableForTestResult(newMessage.mid(fileProtocol)); + } + } + + fprintf (stdout, "CONSOLE MESSAGE: line %d: %s\n", lineNumber, newMessage.toUtf8().constData()); } bool WebPage::javaScriptConfirm(QWebFrame*, const QString& msg) { + if (!isTextOutputEnabled()) + return true; + fprintf(stdout, "CONFIRM: %s\n", msg.toUtf8().constData()); return true; } bool WebPage::javaScriptPrompt(QWebFrame*, const QString& msg, const QString& defaultValue, QString* result) { + if (!isTextOutputEnabled()) + return true; + fprintf(stdout, "PROMPT: %s, default text: %s\n", msg.toUtf8().constData(), defaultValue.toUtf8().constData()); *result = defaultValue; return true; @@ -203,35 +256,83 @@ bool WebPage::acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest& r typeDescription = "illegal value"; } - fprintf(stdout, "Policy delegate: attempt to load %s with navigation type '%s'\n", - url.toUtf8().constData(), typeDescription.toUtf8().constData()); + if (isTextOutputEnabled()) + fprintf(stdout, "Policy delegate: attempt to load %s with navigation type '%s'\n", + url.toUtf8().constData(), typeDescription.toUtf8().constData()); + m_drt->layoutTestController()->notifyDone(); } return QWebPage::acceptNavigationRequest(frame, request, type); } +bool WebPage::supportsExtension(QWebPage::Extension extension) const +{ + if (extension == QWebPage::ErrorPageExtension) + return m_drt->layoutTestController()->shouldHandleErrorPages(); + + return false; +} + +bool WebPage::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output) +{ + const QWebPage::ErrorPageExtensionOption* info = static_cast<const QWebPage::ErrorPageExtensionOption*>(option); + + // Lets handle error pages for the main frame for now. + if (info->frame != mainFrame()) + return false; + + QWebPage::ErrorPageExtensionReturn* errorPage = static_cast<QWebPage::ErrorPageExtensionReturn*>(output); + + errorPage->content = QString("data:text/html,<body/>").toUtf8(); + + return true; +} + +QObject* WebPage::createPlugin(const QString& classId, const QUrl& url, const QStringList& paramNames, const QStringList& paramValues) +{ + Q_UNUSED(url); + Q_UNUSED(paramNames); + Q_UNUSED(paramValues); +#ifndef QT_NO_UITOOLS + QUiLoader loader; + return loader.createWidget(classId, view()); +#else + Q_UNUSED(classId); + return 0; +#endif +} + DumpRenderTree::DumpRenderTree() : m_dumpPixels(false) , m_stdin(0) , m_notifier(0) + , m_enableTextOutput(false) { qt_drt_overwritePluginDirectories(); QWebSettings::enablePersistentStorage(); + // create our primary testing page/view. + m_mainView = new QWebView(0); + m_mainView->resize(QSize(maxViewWidth, maxViewHeight)); + m_page = new WebPage(m_mainView, this); + m_mainView->setPage(m_page); + + // create out controllers. This has to be done before connectFrame, + // as it exports there to the JavaScript DOM window. m_controller = new LayoutTestController(this); connect(m_controller, SIGNAL(done()), this, SLOT(dump())); + m_eventSender = new EventSender(m_page); + m_textInputController = new TextInputController(m_page); + m_gcController = new GCController(m_page); - QWebView *view = new QWebView(0); - view->resize(QSize(maxViewWidth, maxViewHeight)); - m_page = new WebPage(view, this); - view->setPage(m_page); - connect(m_page, SIGNAL(frameCreated(QWebFrame *)), this, SLOT(connectFrame(QWebFrame *))); + // now connect our different signals + connect(m_page, SIGNAL(frameCreated(QWebFrame *)), + this, SLOT(connectFrame(QWebFrame *))); connectFrame(m_page->mainFrame()); - connect(m_page->mainFrame(), SIGNAL(loadFinished(bool)), m_controller, SLOT(maybeDump(bool))); + connect(m_page, SIGNAL(loadFinished(bool)), + m_controller, SLOT(maybeDump(bool))); - m_page->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); - m_page->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); connect(m_page->mainFrame(), SIGNAL(titleChanged(const QString&)), SLOT(titleChanged(const QString&))); connect(m_page, SIGNAL(databaseQuotaExceeded(QWebFrame*,QString)), @@ -239,20 +340,15 @@ DumpRenderTree::DumpRenderTree() connect(m_page, SIGNAL(statusBarMessage(const QString&)), this, SLOT(statusBarMessage(const QString&))); - m_eventSender = new EventSender(m_page); - m_textInputController = new TextInputController(m_page); - m_gcController = new GCController(m_page); - QObject::connect(this, SIGNAL(quit()), qApp, SLOT(quit()), Qt::QueuedConnection); qt_drt_run(true); QFocusEvent event(QEvent::FocusIn, Qt::ActiveWindowFocusReason); - QApplication::sendEvent(view, &event); + QApplication::sendEvent(m_mainView, &event); } DumpRenderTree::~DumpRenderTree() { - delete m_page; - + delete m_mainView; delete m_stdin; delete m_notifier; } @@ -270,29 +366,48 @@ void DumpRenderTree::open() } } -void DumpRenderTree::resetToConsistentStateBeforeTesting() +static void clearHistory(QWebPage* page) { - closeRemainingWindows(); + // QWebHistory::clear() leaves current page, so remove it as well by setting + // max item count to 0, and then setting it back to it's original value. + + QWebHistory* history = page->history(); + int itemCount = history->maximumItemCount(); + + history->clear(); + history->setMaximumItemCount(0); + history->setMaximumItemCount(itemCount); +} - // Reset so that any current loads are stopped +void DumpRenderTree::resetToConsistentStateBeforeTesting() +{ + // reset so that any current loads are stopped + // NOTE: that this has to be done before the layoutTestController is + // reset or we get timeouts for some tests. m_page->blockSignals(true); m_page->triggerAction(QWebPage::Stop); m_page->blockSignals(false); - m_page->mainFrame()->setZoomFactor(1.0); + // reset the layoutTestController at this point, so that we under no + // circumstance dump (stop the waitUntilDone timer) during the reset + // of the DRT. + m_controller->reset(); + + closeRemainingWindows(); - static_cast<WebPage*>(m_page)->resetSettings(); + m_page->resetSettings(); + m_page->undoStack()->clear(); + m_page->mainFrame()->setZoomFactor(1.0); + clearHistory(m_page); qt_drt_clearFrameName(m_page->mainFrame()); WorkQueue::shared()->clear(); - // Causes timeout, why? - //WorkQueue::shared()->setFrozen(false); + WorkQueue::shared()->setFrozen(false); - m_controller->reset(); qt_drt_resetOriginAccessWhiteLists(); - QLocale qlocale; - QLocale::setDefault(qlocale); + QLocale::setDefault(QLocale::c()); + setlocale(LC_ALL, ""); } void DumpRenderTree::open(const QUrl& aurl) @@ -316,7 +431,7 @@ void DumpRenderTree::open(const QUrl& aurl) bool isW3CTest = url.toString().contains("svg/W3C-SVG-1.1"); int width = isW3CTest ? 480 : maxViewWidth; int height = isW3CTest ? 360 : maxViewHeight; - m_page->view()->resize(QSize(width, height)); + m_mainView->resize(QSize(width, height)); m_page->setPreferredContentsSize(QSize()); m_page->setViewportSize(QSize(width, height)); @@ -329,6 +444,7 @@ void DumpRenderTree::open(const QUrl& aurl) #endif qt_dump_frame_loader(url.toString().contains("loading/")); + setTextOutputEnabled(true); m_page->mainFrame()->load(url); } @@ -359,7 +475,7 @@ void DumpRenderTree::setDumpPixels(bool dump) void DumpRenderTree::closeRemainingWindows() { - foreach(QWidget *widget, windows) + foreach (QObject* widget, windows) delete widget; windows.clear(); } @@ -377,7 +493,7 @@ void DumpRenderTree::initJSObjects() QString DumpRenderTree::dumpFramesAsText(QWebFrame* frame) { - if (!frame) + if (!frame || !qt_drt_hasDocumentElement(frame)) return QString(); QString result; @@ -388,7 +504,8 @@ QString DumpRenderTree::dumpFramesAsText(QWebFrame* frame) result.append(QLatin1String("'\n--------\n")); } - result.append(frame->toPlainText()); + QString innerText = frame->toPlainText(); + result.append(innerText); result.append(QLatin1String("\n")); if (m_controller->shouldDumpChildrenAsText()) { @@ -400,11 +517,69 @@ QString DumpRenderTree::dumpFramesAsText(QWebFrame* frame) return result; } +static QString dumpHistoryItem(const QWebHistoryItem& item, int indent, bool current) +{ + QString result; + + int start = 0; + if (current) { + result.append(QLatin1String("curr->")); + start = 6; + } + for (int i = start; i < indent; i++) + result.append(' '); + + QString url = item.url().toString(); + if (url.contains("file://")) { + static QString layoutTestsString("/LayoutTests/"); + static QString fileTestString("(file test):"); + + QString res = url.mid(url.indexOf(layoutTestsString) + layoutTestsString.length()); + if (res.isEmpty()) + return result; + + result.append(fileTestString); + result.append(res); + } else { + result.append(url); + } + + // FIXME: Wrong, need (private?) API for determining this. + result.append(QLatin1String(" **nav target**")); + result.append(QLatin1String("\n")); + + return result; +} + QString DumpRenderTree::dumpBackForwardList() { + QWebHistory* history = webPage()->history(); + QString result; result.append(QLatin1String("\n============== Back Forward List ==============\n")); - result.append(QLatin1String("FIXME: Unimplemented!\n")); + + // FORMAT: + // " (file test):fast/loader/resources/click-fragment-link.html **nav target**" + // "curr-> (file test):fast/loader/resources/click-fragment-link.html#testfragment **nav target**" + + int maxItems = history->maximumItemCount(); + + foreach (const QWebHistoryItem item, history->backItems(maxItems)) { + if (!item.isValid()) + continue; + result.append(dumpHistoryItem(item, 8, false)); + } + + QWebHistoryItem item = history->currentItem(); + if (item.isValid()) + result.append(dumpHistoryItem(item, 8, true)); + + foreach (const QWebHistoryItem item, history->forwardItems(maxItems)) { + if (!item.isValid()) + continue; + result.append(dumpHistoryItem(item, 8, false)); + } + result.append(QLatin1String("===============================================\n")); return result; } @@ -551,25 +726,28 @@ QWebPage *DumpRenderTree::createWindow() { if (!m_controller->canOpenWindows()) return 0; - QWidget *container = new QWidget(0); - container->resize(0, 0); - container->move(-1, -1); - container->hide(); - QWebPage *page = new WebPage(container, this); - connectFrame(page->mainFrame()); - connect(m_page, SIGNAL(frameCreated(QWebFrame *)), this, SLOT(connectFrame(QWebFrame *))); + + // Create a dummy container object to track the page in DRT. + // QObject is used instead of QWidget to prevent DRT from + // showing the main view when deleting the container. + + QObject* container = new QObject(m_mainView); + // create a QWebPage we want to return + QWebPage* page = static_cast<QWebPage*>(new WebPage(container, this)); + // gets cleaned up in closeRemainingWindows() windows.append(container); + + // connect the needed signals to the page + connect(page, SIGNAL(frameCreated(QWebFrame*)), this, SLOT(connectFrame(QWebFrame*))); + connectFrame(page->mainFrame()); + connect(page, SIGNAL(loadFinished(bool)), m_controller, SLOT(maybeDump(bool))); return page; } int DumpRenderTree::windowCount() const { - int count = 0; - foreach(QWidget *w, windows) { - if (w->children().count()) - ++count; - } - return count + 1; +// include the main view in the count + return windows.count() + 1; } #if defined(Q_WS_X11) @@ -613,5 +791,3 @@ void DumpRenderTree::initializeFonts() #endif } - -#include "DumpRenderTree.moc" diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h index c5b4801..ab229fe 100644 --- a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h @@ -31,15 +31,25 @@ #define DUMPRENDERTREE_H #include <QList> +#include <QNetworkAccessManager> #include <QObject> #include <QTextStream> #include <QSocketNotifier> +#ifndef QT_NO_SSL +#include <QSslError> +#endif + +#include <qwebframe.h> +#include <qwebinspector.h> +#include <qwebpage.h> +#include <qwebview.h> + QT_BEGIN_NAMESPACE class QUrl; class QFile; QT_END_NAMESPACE -class QWebPage; + class QWebFrame; class LayoutTestController; @@ -49,6 +59,8 @@ class GCController; namespace WebCore { +class WebPage; + class DumpRenderTree : public QObject { Q_OBJECT @@ -62,6 +74,9 @@ public: // Initialize in single-file mode. void open(const QUrl& url); + void setTextOutputEnabled(bool enable) { m_enableTextOutput = enable; } + bool isTextOutputEnabled() { return m_enableTextOutput; } + void setDumpPixels(bool); void closeRemainingWindows(); @@ -74,7 +89,7 @@ public: QWebPage *createWindow(); int windowCount() const; - QWebPage *webPage() const { return m_page; } + WebPage *webPage() const { return m_page; } #if defined(Q_WS_X11) @@ -101,7 +116,8 @@ private: bool m_dumpPixels; QString m_expectedHash; - QWebPage *m_page; + WebPage *m_page; + QWebView* m_mainView; EventSender *m_eventSender; TextInputController *m_textInputController; @@ -110,7 +126,59 @@ private: QFile *m_stdin; QSocketNotifier* m_notifier; - QList<QWidget *> windows; + QList<QObject*> windows; + bool m_enableTextOutput; +}; + +class NetworkAccessManager : public QNetworkAccessManager { + Q_OBJECT +public: + NetworkAccessManager(QObject* parent); + +private slots: +#ifndef QT_NO_SSL + void sslErrorsEncountered(QNetworkReply*, const QList<QSslError>&); +#endif +}; + +class WebPage : public QWebPage { + Q_OBJECT +public: + WebPage(QObject* parent, DumpRenderTree*); + virtual ~WebPage(); + QWebInspector* webInspector(); + + QWebPage *createWindow(QWebPage::WebWindowType); + + void javaScriptAlert(QWebFrame *frame, const QString& message); + void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID); + bool javaScriptConfirm(QWebFrame *frame, const QString& msg); + bool javaScriptPrompt(QWebFrame *frame, const QString& msg, const QString& defaultValue, QString* result); + + void resetSettings(); + + virtual bool supportsExtension(QWebPage::Extension extension) const; + virtual bool extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output); + + QObject* createPlugin(const QString&, const QUrl&, const QStringList&, const QStringList&); + +public slots: + bool shouldInterruptJavaScript() { return false; } + +protected: + bool acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest& request, NavigationType type); + bool isTextOutputEnabled() { return m_drt->isTextOutputEnabled(); } + +private slots: + void setViewGeometry(const QRect &r) + { + QWidget *v = view(); + if (v) + v->setGeometry(r); + } +private: + QWebInspector* m_webInspector; + DumpRenderTree *m_drt; }; } diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro index 571313c..81e929b 100644 --- a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro @@ -1,9 +1,20 @@ TARGET = DumpRenderTree CONFIG -= app_bundle +CONFIG += uitools + +mac:!static:contains(QT_CONFIG, qt_framework):!CONFIG(webkit_no_framework) { + CONFIG -= debug + CONFIG += release +} + +BASEDIR = $$PWD/../ include(../../../WebKit.pri) INCLUDEPATH += /usr/include/freetype2 +INCLUDEPATH += ../../.. INCLUDEPATH += ../../../JavaScriptCore +INCLUDEPATH += ../../../JavaScriptCore/ForwardingHeaders +INCLUDEPATH += $$BASEDIR DESTDIR = ../../../bin CONFIG += link_pkgconfig @@ -12,7 +23,7 @@ PKGCONFIG += fontconfig QT = core gui network macx: QT += xml -HEADERS = WorkQueue.h \ +HEADERS = $$BASEDIR/WorkQueue.h \ WorkQueueItem.h \ DumpRenderTree.h \ EventSenderQt.h \ @@ -20,7 +31,7 @@ HEADERS = WorkQueue.h \ LayoutTestControllerQt.h \ jsobjects.h \ testplugin.h -SOURCES = WorkQueue.cpp \ +SOURCES = $$BASEDIR/WorkQueue.cpp \ DumpRenderTree.cpp \ EventSenderQt.cpp \ TextInputControllerQt.cpp \ @@ -34,8 +45,4 @@ unix:!mac { QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR } -lessThan(QT_MINOR_VERSION, 4) { - DEFINES += QT_BEGIN_NAMESPACE="" QT_END_NAMESPACE="" -} - DEFINES+=USE_SYSTEM_MALLOC diff --git a/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp b/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp index bbefed9..a0da273 100644 --- a/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp +++ b/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp @@ -30,6 +30,15 @@ #include "EventSenderQt.h" //#include <QtDebug> + +#define KEYCODE_DEL 127 +#define KEYCODE_BACKSPACE 8 +#define KEYCODE_LEFTARROW 0xf702 +#define KEYCODE_RIGHTARROW 0xf703 +#define KEYCODE_UPARROW 0xf700 +#define KEYCODE_DOWNARROW 0xf701 + + EventSender::EventSender(QWebPage* parent) : QObject(parent) { @@ -129,7 +138,7 @@ void EventSender::keyDown(const QString& string, const QStringList& modifiers) if (modifs == Qt::ShiftModifier) code = Qt::Key_Backtab; s = QString(); - } else if (code == 127) { + } else if (code == KEYCODE_DEL || code == KEYCODE_BACKSPACE) { code = Qt::Key_Backspace; if (modifs == Qt::AltModifier) modifs = Qt::ControlModifier; @@ -148,28 +157,28 @@ void EventSender::keyDown(const QString& string, const QStringList& modifiers) s = QString(); code = Qt::Key_Home; modifs = 0; - } else if (code == 0xf702) { + } else if (code == KEYCODE_LEFTARROW) { s = QString(); code = Qt::Key_Left; if (modifs & Qt::MetaModifier) { code = Qt::Key_Home; modifs &= ~Qt::MetaModifier; } - } else if (code == 0xf703) { + } else if (code == KEYCODE_RIGHTARROW) { s = QString(); code = Qt::Key_Right; if (modifs & Qt::MetaModifier) { code = Qt::Key_End; modifs &= ~Qt::MetaModifier; } - } else if (code == 0xf700) { + } else if (code == KEYCODE_UPARROW) { s = QString(); code = Qt::Key_Up; if (modifs & Qt::MetaModifier) { code = Qt::Key_PageUp; modifs &= ~Qt::MetaModifier; } - } else if (code == 0xf701) { + } else if (code == KEYCODE_DOWNARROW) { s = QString(); code = Qt::Key_Down; if (modifs & Qt::MetaModifier) { diff --git a/WebKitTools/DumpRenderTree/qt/ImageDiff.pro b/WebKitTools/DumpRenderTree/qt/ImageDiff.pro index 11ee1fa..636835a 100644 --- a/WebKitTools/DumpRenderTree/qt/ImageDiff.pro +++ b/WebKitTools/DumpRenderTree/qt/ImageDiff.pro @@ -13,6 +13,3 @@ unix:!mac { QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR } -lessThan(QT_MINOR_VERSION, 4) { - DEFINES += QT_BEGIN_NAMESPACE="" QT_END_NAMESPACE="" -} diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp index b8de6a5..0ea5632 100644 --- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp +++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp @@ -32,13 +32,16 @@ #include "DumpRenderTree.h" #include "WorkQueue.h" #include "WorkQueueItem.h" +#include <QDir> extern void qt_dump_editing_callbacks(bool b); extern void qt_dump_resource_load_callbacks(bool b); extern void qt_drt_setJavaScriptProfilingEnabled(QWebFrame*, bool enabled); extern bool qt_drt_pauseAnimation(QWebFrame*, const QString& name, double time, const QString& elementId); extern bool qt_drt_pauseTransitionOfProperty(QWebFrame*, const QString& name, double time, const QString& elementId); +extern bool qt_drt_pauseSVGAnimation(QWebFrame*, const QString& animationId, double time, const QString& elementId); extern int qt_drt_numberOfActiveAnimations(QWebFrame*); + extern void qt_drt_whiteListAccessFromOrigin(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains); extern QString qt_drt_counterValueForElementById(QWebFrame* qFrame, const QString& id); @@ -63,6 +66,7 @@ void LayoutTestController::reset() m_timeoutTimer.stop(); m_topLoadingFrame = 0; m_waitForPolicy = false; + m_handleErrorPages = false; qt_dump_editing_callbacks(false); qt_dump_resource_load_callbacks(false); } @@ -72,7 +76,7 @@ void LayoutTestController::processWork() // qDebug() << ">>>processWork"; // if we didn't start a new load, then we finished all the commands, so we're ready to dump state - if (!WorkQueue::shared()->processWork() && !shouldWaitUntilDone()) { + if (WorkQueue::shared()->processWork() && !shouldWaitUntilDone()) { emit done(); m_isLoading = false; } @@ -81,7 +85,7 @@ void LayoutTestController::processWork() // Called on loadFinished on mainFrame. void LayoutTestController::maybeDump(bool success) { - Q_ASSERT(sender() == m_topLoadingFrame); + Q_ASSERT(sender() == m_topLoadingFrame->page()); // as the function is called on loadFinished, the test might // already have dumped and thus no longer be active, thus @@ -107,7 +111,7 @@ void LayoutTestController::waitUntilDone() { //qDebug() << ">>>>waitForDone"; m_waitForDone = true; - m_timeoutTimer.start(11000, this); + m_timeoutTimer.start(15000, this); } QString LayoutTestController::counterValueForElementById(const QString& id) @@ -123,10 +127,14 @@ void LayoutTestController::keepWebHistory() void LayoutTestController::notifyDone() { qDebug() << ">>>>notifyDone"; + if (!m_timeoutTimer.isActive()) return; + m_timeoutTimer.stop(); emit done(); + + // FIXME: investigate why always resetting these result in timeouts m_isLoading = false; m_waitForDone = false; m_waitForPolicy = false; @@ -142,6 +150,12 @@ void LayoutTestController::clearBackForwardList() m_drt->webPage()->history()->clear(); } +QString LayoutTestController::pathToLocalResource(const QString& url) +{ + // Function introduced in r28690. + return QLatin1String("file://") + QUrl(url).toLocalFile(); +} + void LayoutTestController::dumpEditingCallbacks() { qDebug() << ">>>dumpEditingCallbacks"; @@ -179,10 +193,16 @@ void LayoutTestController::queueReload() WorkQueue::shared()->queue(new ReloadItem(m_drt->webPage())); } -void LayoutTestController::queueScript(const QString &url) +void LayoutTestController::queueLoadingScript(const QString& script) +{ + //qDebug() << ">>>queueLoadingScript" << script; + WorkQueue::shared()->queue(new LoadingScriptItem(script, m_drt->webPage())); +} + +void LayoutTestController::queueNonLoadingScript(const QString& script) { - //qDebug() << ">>>queueScript" << url; - WorkQueue::shared()->queue(new ScriptItem(url, m_drt->webPage())); + //qDebug() << ">>>queueNonLoadingScript" << script; + WorkQueue::shared()->queue(new NonLoadingScriptItem(script, m_drt->webPage())); } void LayoutTestController::provisionalLoad() @@ -195,7 +215,9 @@ void LayoutTestController::provisionalLoad() void LayoutTestController::timerEvent(QTimerEvent *ev) { if (ev->timerId() == m_timeoutTimer.timerId()) { - //qDebug() << ">>>>>>>>>>>>> timeout"; + const char* message = "FAIL: Timed out waiting for notifyDone to be called\n"; + fprintf(stderr, "%s", message); + fprintf(stdout, "%s", message); notifyDone(); } else QObject::timerEvent(ev); @@ -215,6 +237,22 @@ QString LayoutTestController::decodeHostName(const QString& host) return decoded; } +void LayoutTestController::showWebInspector() +{ + m_drt->webPage()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); + m_drt->webPage()->webInspector()->show(); +} + +void LayoutTestController::hideWebInspector() +{ + m_drt->webPage()->webInspector()->hide(); +} + +void LayoutTestController::setAllowUniversalAccessFromFileURLs(bool enabled) +{ + m_drt->webPage()->settings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, enabled); +} + void LayoutTestController::setJavaScriptProfilingEnabled(bool enable) { m_topLoadingFrame->page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); @@ -260,6 +298,15 @@ bool LayoutTestController::pauseTransitionAtTimeOnElementWithId(const QString& p return qt_drt_pauseTransitionOfProperty(frame, propertyName, time, elementId); } +bool LayoutTestController::sampleSVGAnimationForElementAtTime(const QString& animationId, + double time, + const QString& elementId) +{ + QWebFrame* frame = m_drt->webPage()->mainFrame(); + Q_ASSERT(frame); + return qt_drt_pauseSVGAnimation(frame, animationId, time, elementId); +} + unsigned LayoutTestController::numberOfActiveAnimations() const { QWebFrame* frame = m_drt->webPage()->mainFrame(); @@ -313,4 +360,6 @@ void LayoutTestController::overridePreference(const QString& name, const QVarian settings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, value.toBool()); else if (name == "WebKitDefaultFontSize") settings->setFontSize(QWebSettings::DefaultFontSize, value.toInt()); + else if (name == "WebKitUsesPageCachePreferenceKey") + QWebSettings::setMaximumPagesInCache(value.toInt()); } diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h index cab014c..ac8681f 100644 --- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h +++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h @@ -63,6 +63,7 @@ public: bool shouldDumpDatabaseCallbacks() const { return m_dumpDatabaseCallbacks; } bool shouldDumpStatusCallbacks() const { return m_dumpStatusCallbacks; } bool shouldWaitUntilDone() const { return m_waitForDone; } + bool shouldHandleErrorPages() const { return m_handleErrorPages; } bool canOpenWindows() const { return m_canOpenWindows; } bool shouldDumpTitleChanges() const { return m_dumpTitleChanges; } bool waitForPolicy() const { return m_waitForPolicy; } @@ -87,22 +88,28 @@ public slots: void keepWebHistory(); void notifyDone(); void dumpBackForwardList() { m_dumpBackForwardList = true; } + void handleErrorPages() { m_handleErrorPages = true; } void dumpEditingCallbacks(); void dumpResourceLoadCallbacks(); void queueBackNavigation(int howFarBackward); void queueForwardNavigation(int howFarForward); void queueLoad(const QString& url, const QString& target = QString()); void queueReload(); - void queueScript(const QString& url); + void queueLoadingScript(const QString& script); + void queueNonLoadingScript(const QString& script); void provisionalLoad(); void setCloseRemainingWindowsWhenComplete(bool = false) {} int windowCount(); void display() {} void clearBackForwardList(); + QString pathToLocalResource(const QString& url); void dumpTitleChanges() { m_dumpTitleChanges = true; } QString encodeHostName(const QString& host); QString decodeHostName(const QString& host); void dumpSelectionRect() const {} + void showWebInspector(); + void hideWebInspector(); + void setAllowUniversalAccessFromFileURLs(bool enable); void setJavaScriptProfilingEnabled(bool enable); void setFixedContentsSize(int width, int height); void setPrivateBrowsingEnabled(bool enable); @@ -111,6 +118,8 @@ public slots: bool pauseAnimationAtTimeOnElementWithId(const QString& animationName, double time, const QString& elementId); bool pauseTransitionAtTimeOnElementWithId(const QString& propertyName, double time, const QString& elementId); + bool sampleSVGAnimationForElementAtTime(const QString& animationId, double time, const QString& elementId); + unsigned numberOfActiveAnimations() const; void whiteListAccessFromOrigin(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains); @@ -138,6 +147,7 @@ private: bool m_dumpDatabaseCallbacks; bool m_dumpStatusCallbacks; bool m_waitForPolicy; + bool m_handleErrorPages; QBasicTimer m_timeoutTimer; QWebFrame* m_topLoadingFrame; diff --git a/WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro b/WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro index 7f502f8..7b8162b 100644 --- a/WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro +++ b/WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro @@ -1,7 +1,7 @@ TEMPLATE = lib TARGET = TestNetscapePlugIn -VPATH = ../../gtk/TestNetscapePlugin ../../TestNetscapePlugIn.subproj +VPATH = ../../unix/TestNetscapePlugin ../../TestNetscapePlugIn.subproj include(../../../../WebKit.pri) DESTDIR = $$OUTPUT_DIR/lib/plugins @@ -18,8 +18,8 @@ mac { } INCLUDEPATH += ../../../../JavaScriptCore \ - ../../gtk/TestNetscapePlugin/ForwardingHeaders \ - ../../gtk/TestNetscapePlugin/ForwardingHeaders/WebKit \ + ../../unix/TestNetscapePlugin/ForwardingHeaders \ + ../../unix/TestNetscapePlugin/ForwardingHeaders/WebKit \ ../../../../WebCore \ ../../../../WebCore/bridge \ ../../TestNetscapePlugIn.subproj @@ -31,5 +31,5 @@ mac { SOURCES += ../../TestNetscapePlugIn.subproj/main.cpp LIBS += -framework Carbon } else { - SOURCES += ../../gtk/TestNetscapePlugin/TestNetscapePlugin.cpp + SOURCES += ../../unix/TestNetscapePlugin/TestNetscapePlugin.cpp } diff --git a/WebKitTools/DumpRenderTree/qt/WorkQueue.cpp b/WebKitTools/DumpRenderTree/qt/WorkQueue.cpp deleted file mode 100644 index f8448e4..0000000 --- a/WebKitTools/DumpRenderTree/qt/WorkQueue.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "WorkQueue.h" - -static const unsigned queueLength = 1024; - -static WorkQueueItem* theQueue[queueLength]; -static unsigned startOfQueue; -static unsigned endOfQueue; - -WorkQueue* WorkQueue::shared() -{ - static WorkQueue* sharedInstance = new WorkQueue; - return sharedInstance; -} - -WorkQueue::WorkQueue() - : m_frozen(false) -{ -} - -void WorkQueue::queue(WorkQueueItem* item) -{ - Q_ASSERT(endOfQueue < queueLength); - Q_ASSERT(endOfQueue >= startOfQueue); - - if (m_frozen) { - delete item; - return; - } - - theQueue[endOfQueue++] = item; -} - -WorkQueueItem* WorkQueue::dequeue() -{ - Q_ASSERT(endOfQueue >= startOfQueue); - - if (startOfQueue == endOfQueue) - return 0; - - return theQueue[startOfQueue++]; -} - -unsigned WorkQueue::count() -{ - return endOfQueue - startOfQueue; -} - -void WorkQueue::clear() -{ - for (unsigned i = startOfQueue; i < endOfQueue; ++i) { - delete theQueue[i]; - theQueue[i] = 0; - } - - startOfQueue = 0; - endOfQueue = 0; -} - -bool WorkQueue::processWork() -{ - bool startedLoad = false; - - while (!startedLoad && count()) { - WorkQueueItem* item = dequeue(); - Q_ASSERT(item); - startedLoad = item->invoke(); - delete item; - } - - // If we're done and we didn't start a load, then we're really done, so return true. - return !startedLoad; -} diff --git a/WebKitTools/DumpRenderTree/qt/WorkQueue.h b/WebKitTools/DumpRenderTree/qt/WorkQueue.h deleted file mode 100644 index 902ba0d..0000000 --- a/WebKitTools/DumpRenderTree/qt/WorkQueue.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef WorkQueue_h -#define WorkQueue_h - -#include "WorkQueueItem.h" - -class WorkQueue { -public: - static WorkQueue* shared(); - - void queue(WorkQueueItem*); - WorkQueueItem* dequeue(); - void clear(); - unsigned count(); - - void setFrozen(bool b) { m_frozen = b; } - - bool processWork(); // Returns true if all work is done, false if we started a load. - -private: - WorkQueue(); - - bool m_frozen; -}; - -#endif // !defined(WorkQueue_h) diff --git a/WebKitTools/DumpRenderTree/qt/WorkQueueItem.h b/WebKitTools/DumpRenderTree/qt/WorkQueueItem.h index 9819ec0..d534493 100644 --- a/WebKitTools/DumpRenderTree/qt/WorkQueueItem.h +++ b/WebKitTools/DumpRenderTree/qt/WorkQueueItem.h @@ -89,6 +89,27 @@ private: QString m_script; }; +class LoadingScriptItem : public ScriptItem { +public: + LoadingScriptItem(const QString& script, QWebPage* page) + : ScriptItem(script, page) + { + } + + virtual bool invoke() const { return ScriptItem::invoke(); } +}; + +class NonLoadingScriptItem : public ScriptItem { +public: + NonLoadingScriptItem(const QString& script, QWebPage* page) + : ScriptItem(script, page) + { + } + + virtual bool invoke() const { ScriptItem::invoke(); return false; } +}; + + class BackForwardItem : public WorkQueueItem { public: virtual bool invoke() const; diff --git a/WebKitTools/DumpRenderTree/qt/jsobjects.cpp b/WebKitTools/DumpRenderTree/qt/jsobjects.cpp index e747aeb..af331f0 100644 --- a/WebKitTools/DumpRenderTree/qt/jsobjects.cpp +++ b/WebKitTools/DumpRenderTree/qt/jsobjects.cpp @@ -26,7 +26,10 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <jsobjects.h> + +#include "config.h" +#include "jsobjects.h" + #include <qwebpage.h> GCController::GCController(QWebPage* parent) diff --git a/WebKitTools/DumpRenderTree/qt/main.cpp b/WebKitTools/DumpRenderTree/qt/main.cpp index ae67a59..719315f 100644 --- a/WebKitTools/DumpRenderTree/qt/main.cpp +++ b/WebKitTools/DumpRenderTree/qt/main.cpp @@ -29,6 +29,8 @@ #include "DumpRenderTree.h" +#include <wtf/AlwaysInline.h> + #include <qstringlist.h> #include <qapplication.h> #include <qurl.h> @@ -38,6 +40,7 @@ #include <qwebsettings.h> #include <qwebdatabase.h> #include <qdesktopservices.h> +#include <qwindowsstyle.h> #ifdef Q_WS_X11 #include <qx11info_x11.h> @@ -86,7 +89,7 @@ QString get_backtrace() { return s; } -static void crashHandler(int sig) +static NO_RETURN void crashHandler(int sig) { fprintf(stderr, "%s\n", strsignal(sig)); fprintf(stderr, "%s\n", get_backtrace().toLatin1().constData()); @@ -98,23 +101,25 @@ int main(int argc, char* argv[]) #ifdef Q_WS_X11 FcInit(); WebCore::DumpRenderTree::initializeFonts(); +#endif + #if QT_VERSION >= 0x040500 QApplication::setGraphicsSystem("raster"); #endif -#endif - QApplication app(argc, argv); -#ifdef Q_WS_X11 - QX11Info::setAppDpiY(0, 96); - QX11Info::setAppDpiX(0, 96); -#endif + + QApplication::setStyle(new QWindowsStyle); QFont f("Sans Serif"); f.setPointSize(9); f.setWeight(QFont::Normal); f.setStyle(QFont::StyleNormal); - app.setFont(f); - app.setStyle(QLatin1String("Plastique")); + QApplication::setFont(f); + QApplication app(argc, argv); +#ifdef Q_WS_X11 + QX11Info::setAppDpiY(0, 96); + QX11Info::setAppDpiX(0, 96); +#endif signal(SIGILL, crashHandler); /* 4: illegal instruction (not reset when caught) */ signal(SIGTRAP, crashHandler); /* 5: trace trap (not reset when caught) */ |