diff options
author | Upstream <upstream-import@none> | 1970-01-12 13:46:40 +0000 |
---|---|---|
committer | Upstream <upstream-import@none> | 1970-01-12 13:46:40 +0000 |
commit | d8543bb6618c17b12da906afa77d216f58cf4058 (patch) | |
tree | c58dc05ed86825bd0ef8d305d58c8205106b540f /WebKitTools/DumpRenderTree/qt | |
download | external_webkit-d8543bb6618c17b12da906afa77d216f58cf4058.zip external_webkit-d8543bb6618c17b12da906afa77d216f58cf4058.tar.gz external_webkit-d8543bb6618c17b12da906afa77d216f58cf4058.tar.bz2 |
external/webkit r30707
Diffstat (limited to 'WebKitTools/DumpRenderTree/qt')
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp | 310 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/DumpRenderTree.h | 98 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro | 18 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/fonts.conf | 258 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/fonts/AHEM____.TTF | bin | 0 -> 12480 bytes | |||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/jsobjects.cpp | 360 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/jsobjects.h | 139 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/main.cpp | 177 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/testplugin.cpp | 71 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/testplugin.h | 52 |
10 files changed, 1483 insertions, 0 deletions
diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp new file mode 100644 index 0000000..5df8a38 --- /dev/null +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp @@ -0,0 +1,310 @@ +/* + * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> + * + * 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 "DumpRenderTree.h" +#include "jsobjects.h" + +#include <QDir> +#include <QFile> +#include <QTimer> +#include <QBoxLayout> +#include <QScrollArea> +#include <QApplication> +#include <QUrl> +#include <QFocusEvent> + +#include <qwebpage.h> +#include <qwebframe.h> +#include <qwebview.h> +#include <qwebsettings.h> + +#include <unistd.h> +#include <qdebug.h> +extern void qt_drt_run(bool b); +extern void qt_dump_set_accepts_editing(bool b); + + +namespace WebCore { + +// Choose some default values. +const unsigned int maxViewWidth = 800; +const unsigned int maxViewHeight = 600; + +class WebPage : public QWebPage { + Q_OBJECT +public: + WebPage(QWidget *parent, DumpRenderTree *drt); + + QWebPage *createWindow(); + + void javaScriptAlert(QWebFrame *frame, const QString& message); + void javaScriptConsoleMessage(const QString& message, unsigned int lineNumber, const QString& sourceID); + bool javaScriptConfirm(QWebFrame *frame, const QString& msg); + bool javaScriptPrompt(QWebFrame *frame, const QString& msg, const QString& defaultValue, QString* result); + +private slots: + void setViewGeometry(const QRect &r) + { + QWidget *v = view(); + if (v) + v->setGeometry(r); + } +private: + DumpRenderTree *m_drt; +}; + +WebPage::WebPage(QWidget *parent, DumpRenderTree *drt) + : QWebPage(parent), m_drt(drt) +{ + settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true); + settings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true); + settings()->setAttribute(QWebSettings::LinksIncludedInFocusChain, false); + connect(this, SIGNAL(geometryChangeRequest(const QRect &)), + this, SLOT(setViewGeometry(const QRect & ))); +} + +QWebPage *WebPage::createWindow() +{ + return m_drt->createWindow(); +} + +void WebPage::javaScriptAlert(QWebFrame *frame, const QString& message) +{ + fprintf(stdout, "ALERT: %s\n", message.toUtf8().constData()); +} + +void WebPage::javaScriptConsoleMessage(const QString& message, unsigned int lineNumber, const QString&) +{ + fprintf (stdout, "CONSOLE MESSAGE: line %d: %s\n", lineNumber, message.toUtf8().constData()); +} + +bool WebPage::javaScriptConfirm(QWebFrame *frame, const QString& msg) +{ + fprintf(stdout, "CONFIRM: %s\n", msg.toUtf8().constData()); + return true; +} + +bool WebPage::javaScriptPrompt(QWebFrame *frame, const QString& msg, const QString& defaultValue, QString* result) +{ + fprintf(stdout, "PROMPT: %s, default text: %s\n", msg.toUtf8().constData(), defaultValue.toUtf8().constData()); + *result = defaultValue; + return true; +} + +DumpRenderTree::DumpRenderTree() + : m_stdin(0) + , m_notifier(0) +{ + m_controller = new LayoutTestController(this); + connect(m_controller, SIGNAL(done()), this, SLOT(dump()), Qt::QueuedConnection); + + 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 *))); + connectFrame(m_page->mainFrame()); + + m_page->mainFrame()->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_page->mainFrame()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + connect(m_page->mainFrame(), SIGNAL(titleChanged(const QString&)), + SLOT(titleChanged(const QString&))); + + m_eventSender = new EventSender(m_page); + m_textInputController = new TextInputController(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); +} + +DumpRenderTree::~DumpRenderTree() +{ + delete m_page; + + delete m_stdin; + delete m_notifier; +} + +void DumpRenderTree::open() +{ + if (!m_stdin) { + m_stdin = new QFile; + m_stdin->open(stdin, QFile::ReadOnly); + } + + if (!m_notifier) { + m_notifier = new QSocketNotifier(STDIN_FILENO, QSocketNotifier::Read); + connect(m_notifier, SIGNAL(activated(int)), this, SLOT(readStdin(int))); + } +} + +void DumpRenderTree::open(const QUrl& url) +{ + resetJSObjects(); + m_page->mainFrame()->load(url); +} + +void DumpRenderTree::readStdin(int /* socket */) +{ + // Read incoming data from stdin... + QByteArray line = m_stdin->readLine(); + if (line.endsWith('\n')) + line.truncate(line.size()-1); + //fprintf(stderr, "\n opening %s\n", line.constData()); + if (line.isEmpty()) + quit(); + QFileInfo fi(line); + open(QUrl::fromLocalFile(fi.absoluteFilePath())); + fflush(stdout); +} + +void DumpRenderTree::resetJSObjects() +{ + m_controller->reset(); + foreach(QWidget *widget, windows) + delete widget; + windows.clear(); +} + +void DumpRenderTree::initJSObjects() +{ + QWebFrame *frame = qobject_cast<QWebFrame*>(sender()); + Q_ASSERT(frame); + frame->addToJSWindowObject(QLatin1String("layoutTestController"), m_controller); + frame->addToJSWindowObject(QLatin1String("eventSender"), m_eventSender); + frame->addToJSWindowObject(QLatin1String("textInputController"), m_textInputController); +} + + +QString DumpRenderTree::dumpFramesAsText(QWebFrame* frame) +{ + if (!frame) + return QString(); + + QString result; + QWebFrame *parent = qobject_cast<QWebFrame *>(frame->parent()); + if (parent) { + result.append(QLatin1String("\n--------\nFrame: '")); + result.append(frame->name()); + result.append(QLatin1String("'\n--------\n")); + } + + result.append(frame->innerText()); + result.append(QLatin1String("\n")); + + if (m_controller->shouldDumpChildrenAsText()) { + QList<QWebFrame *> children = frame->childFrames(); + for (int i = 0; i < children.size(); ++i) + result += dumpFramesAsText(children.at(i)); + } + + return result; +} + +void DumpRenderTree::dump() +{ + QWebFrame *frame = m_page->mainFrame(); + + //fprintf(stderr, " Dumping\n"); + if (!m_notifier) { + // Dump markup in single file mode... + QString markup = frame->markup(); + fprintf(stdout, "Source:\n\n%s\n", markup.toUtf8().constData()); + } + + // Dump render text... + QString renderDump; + if (m_controller->shouldDumpAsText()) { + renderDump = dumpFramesAsText(frame); + } else { + renderDump = frame->renderTreeDump(); + } + if (renderDump.isEmpty()) { + printf("ERROR: nil result from %s", m_controller->shouldDumpAsText() ? "[documentElement innerText]" : "[frame renderTreeAsExternalRepresentation]"); + } else { + fprintf(stdout, "%s", renderDump.toUtf8().constData()); + } + + fprintf(stdout, "#EOF\n"); + + fflush(stdout); + + if (!m_notifier) { + // Exit now in single file mode... + quit(); + } +} + +void DumpRenderTree::titleChanged(const QString &s) +{ + if (m_controller->shouldDumpTitleChanges()) + printf("TITLE CHANGED: %s\n", s.toUtf8().data()); +} + +void DumpRenderTree::connectFrame(QWebFrame *frame) +{ + connect(frame, SIGNAL(cleared()), this, SLOT(initJSObjects())); + connect(frame, SIGNAL(provisionalLoad()), + layoutTestController(), SLOT(provisionalLoad())); + + if (frame == m_page->mainFrame()) { + connect(frame, SIGNAL(loadDone(bool)), + layoutTestController(), SLOT(maybeDump(bool))); + } +} + +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); + connect(m_page, SIGNAL(frameCreated(QWebFrame *)), this, SLOT(connectFrame(QWebFrame *))); + windows.append(container); + return page; +} + +int DumpRenderTree::windowCount() const +{ + int count = 0; + foreach(QWidget *w, windows) { + if (w->children().count()) + ++count; + } + return count + 1; +} + +} + +#include "DumpRenderTree.moc" diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h new file mode 100644 index 0000000..b939fad --- /dev/null +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> + * + * 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 DUMPRENDERTREE_H +#define DUMPRENDERTREE_H + +#include <QList> +#include <QObject> +#include <QTextStream> +#include <QSocketNotifier> +class QUrl; +class QFile; +class QWebPage; +class QWebFrame; + +class LayoutTestController; +class EventSender; +class TextInputController; + +namespace WebCore { + +class DumpRenderTree : public QObject { +Q_OBJECT + +public: + DumpRenderTree(); + virtual ~DumpRenderTree(); + + // Initialize in multi-file mode, used by run-webkit-tests. + void open(); + + // Initialize in single-file mode. + void open(const QUrl& url); + + void resetJSObjects(); + + LayoutTestController *layoutTestController() const { return m_controller; } + EventSender *eventSender() const { return m_eventSender; } + TextInputController *textInputController() const { return m_textInputController; } + + QWebPage *createWindow(); + int windowCount() const; + + QWebPage *webPage() const { return m_page; } + +public Q_SLOTS: + void initJSObjects(); + void readStdin(int); + void dump(); + void titleChanged(const QString &s); + void connectFrame(QWebFrame *frame); + +Q_SIGNALS: + void quit(); + +private: + QString dumpFramesAsText(QWebFrame* frame); + LayoutTestController *m_controller; + + QWebPage *m_page; + + EventSender *m_eventSender; + TextInputController *m_textInputController; + + QFile *m_stdin; + QSocketNotifier* m_notifier; + + QList<QWidget *> windows; +}; + +} + +#endif diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro new file mode 100644 index 0000000..8c3dbbf --- /dev/null +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro @@ -0,0 +1,18 @@ +TARGET = DumpRenderTree +CONFIG -= app_bundle + +include(../../../WebKit.pri) +INCLUDEPATH += /usr/include/freetype2 +INCLUDEPATH += ../../../JavaScriptCore/kjs +DESTDIR = ../../../bin + + +QT = core gui +macx: QT += xml network + +HEADERS = DumpRenderTree.h jsobjects.h testplugin.h +SOURCES = DumpRenderTree.cpp main.cpp jsobjects.cpp testplugin.cpp + +unix:!mac { + QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR +} diff --git a/WebKitTools/DumpRenderTree/qt/fonts.conf b/WebKitTools/DumpRenderTree/qt/fonts.conf new file mode 100644 index 0000000..3540c47 --- /dev/null +++ b/WebKitTools/DumpRenderTree/qt/fonts.conf @@ -0,0 +1,258 @@ +<?xml version="1.0"?> +<!DOCTYPE fontconfig SYSTEM "fonts.dtd"> +<fontconfig> + +<!-- + Accept deprecated 'mono' alias, replacing it with 'monospace' +--> + <match target="pattern"> + <test qual="any" name="family"> + <string>mono</string> + </test> + <edit name="family" mode="assign"> + <string>monospace</string> + </edit> + </match> + +<!-- + Accept alternate 'sans serif' spelling, replacing it with 'sans-serif' +--> + <match target="pattern"> + <test qual="any" name="family"> + <string>sans serif</string> + </test> + <edit name="family" mode="assign"> + <string>sans-serif</string> + </edit> + </match> + +<!-- + Accept deprecated 'sans' alias, replacing it with 'sans-serif' +--> + <match target="pattern"> + <test qual="any" name="family"> + <string>sans</string> + </test> + <edit name="family" mode="assign"> + <string>sans-serif</string> + </edit> + </match> + + + <config> +<!-- + These are the default Unicode chars that are expected to be blank + in fonts. All other blank chars are assumed to be broken and + won't appear in the resulting charsets + --> + <blank> + <int>0x0020</int> <!-- SPACE --> + <int>0x00A0</int> <!-- NO-BREAK SPACE --> + <int>0x00AD</int> <!-- SOFT HYPHEN --> + <int>0x034F</int> <!-- COMBINING GRAPHEME JOINER --> + <int>0x0600</int> <!-- ARABIC NUMBER SIGN --> + <int>0x0601</int> <!-- ARABIC SIGN SANAH --> + <int>0x0602</int> <!-- ARABIC FOOTNOTE MARKER --> + <int>0x0603</int> <!-- ARABIC SIGN SAFHA --> + <int>0x06DD</int> <!-- ARABIC END OF AYAH --> + <int>0x070F</int> <!-- SYRIAC ABBREVIATION MARK --> + <int>0x115F</int> <!-- HANGUL CHOSEONG FILLER --> + <int>0x1160</int> <!-- HANGUL JUNGSEONG FILLER --> + <int>0x1680</int> <!-- OGHAM SPACE MARK --> + <int>0x17B4</int> <!-- KHMER VOWEL INHERENT AQ --> + <int>0x17B5</int> <!-- KHMER VOWEL INHERENT AA --> + <int>0x180E</int> <!-- MONGOLIAN VOWEL SEPARATOR --> + <int>0x2000</int> <!-- EN QUAD --> + <int>0x2001</int> <!-- EM QUAD --> + <int>0x2002</int> <!-- EN SPACE --> + <int>0x2003</int> <!-- EM SPACE --> + <int>0x2004</int> <!-- THREE-PER-EM SPACE --> + <int>0x2005</int> <!-- FOUR-PER-EM SPACE --> + <int>0x2006</int> <!-- SIX-PER-EM SPACE --> + <int>0x2007</int> <!-- FIGURE SPACE --> + <int>0x2008</int> <!-- PUNCTUATION SPACE --> + <int>0x2009</int> <!-- THIN SPACE --> + <int>0x200A</int> <!-- HAIR SPACE --> + <int>0x200B</int> <!-- ZERO WIDTH SPACE --> + <int>0x200C</int> <!-- ZERO WIDTH NON-JOINER --> + <int>0x200D</int> <!-- ZERO WIDTH JOINER --> + <int>0x200E</int> <!-- LEFT-TO-RIGHT MARK --> + <int>0x200F</int> <!-- RIGHT-TO-LEFT MARK --> + <int>0x2028</int> <!-- LINE SEPARATOR --> + <int>0x2029</int> <!-- PARAGRAPH SEPARATOR --> + <int>0x202A</int> <!-- LEFT-TO-RIGHT EMBEDDING --> + <int>0x202B</int> <!-- RIGHT-TO-LEFT EMBEDDING --> + <int>0x202C</int> <!-- POP DIRECTIONAL FORMATTING --> + <int>0x202D</int> <!-- LEFT-TO-RIGHT OVERRIDE --> + <int>0x202E</int> <!-- RIGHT-TO-LEFT OVERRIDE --> + <int>0x202F</int> <!-- NARROW NO-BREAK SPACE --> + <int>0x205F</int> <!-- MEDIUM MATHEMATICAL SPACE --> + <int>0x2060</int> <!-- WORD JOINER --> + <int>0x2061</int> <!-- FUNCTION APPLICATION --> + <int>0x2062</int> <!-- INVISIBLE TIMES --> + <int>0x2063</int> <!-- INVISIBLE SEPARATOR --> + <int>0x206A</int> <!-- INHIBIT SYMMETRIC SWAPPING --> + <int>0x206B</int> <!-- ACTIVATE SYMMETRIC SWAPPING --> + <int>0x206C</int> <!-- INHIBIT ARABIC FORM SHAPING --> + <int>0x206D</int> <!-- ACTIVATE ARABIC FORM SHAPING --> + <int>0x206E</int> <!-- NATIONAL DIGIT SHAPES --> + <int>0x206F</int> <!-- NOMINAL DIGIT SHAPES --> + <int>0x3000</int> <!-- IDEOGRAPHIC SPACE --> + <int>0x3164</int> <!-- HANGUL FILLER --> + <int>0xFEFF</int> <!-- ZERO WIDTH NO-BREAK SPACE --> + <int>0xFFA0</int> <!-- HALFWIDTH HANGUL FILLER --> + <int>0xFFF9</int> <!-- INTERLINEAR ANNOTATION ANCHOR --> + <int>0xFFFA</int> <!-- INTERLINEAR ANNOTATION SEPARATOR --> + <int>0xFFFB</int> <!-- INTERLINEAR ANNOTATION TERMINATOR --> + </blank> +<!-- + Rescan configuration every 30 seconds when FcFontSetList is called + --> + <rescan> + <int>30</int> + </rescan> + </config> + +<!-- + URW provides metric and shape compatible fonts for these 10 Adobe families. + + However, these fonts are quite ugly and do not render well on-screen, + so we avoid matching them if the application said `anymetrics'; in that + case, a more generic font with different metrics but better appearance + will be used. + --> + <match target="pattern"> + <test name="family"> + <string>Avant Garde</string> + </test> + <test name="anymetrics" qual="all" compare="not_eq"> + <bool>true</bool> + </test> + <edit name="family" mode="append"> + <string>URW Gothic L</string> + </edit> + </match> + <match target="pattern"> + <test name="family"> + <string>Bookman</string> + </test> + <test name="anymetrics" qual="all" compare="not_eq"> + <bool>true</bool> + </test> + <edit name="family" mode="append"> + <string>URW Bookman L</string> + </edit> + </match> + <match target="pattern"> + <test name="family"> + <string>Courier</string> + </test> + <test name="anymetrics" qual="all" compare="not_eq"> + <bool>true</bool> + </test> + <edit name="family" mode="append"> + <string>Nimbus Mono L</string> + </edit> + </match> + <match target="pattern"> + <test name="family"> + <string>Helvetica</string> + </test> + <test name="anymetrics" qual="all" compare="not_eq"> + <bool>true</bool> + </test> + <edit name="family" mode="append"> + <string>Nimbus Sans L</string> + </edit> + </match> + <match target="pattern"> + <test name="family"> + <string>New Century Schoolbook</string> + </test> + <test name="anymetrics" qual="all" compare="not_eq"> + <bool>true</bool> + </test> + <edit name="family" mode="append"> + <string>Century Schoolbook L</string> + </edit> + </match> + <match target="pattern"> + <test name="family"> + <string>Palatino</string> + </test> + <test name="anymetrics" qual="all" compare="not_eq"> + <bool>true</bool> + </test> + <edit name="family" mode="append"> + <string>URW Palladio L</string> + </edit> + </match> + <match target="pattern"> + <test name="family"> + <string>Times</string> + </test> + <test name="anymetrics" qual="all" compare="not_eq"> + <bool>true</bool> + </test> + <edit name="family" mode="append"> + <string>Nimbus Roman No9 L</string> + </edit> + </match> + <match target="pattern"> + <test name="family"> + <string>Zapf Chancery</string> + </test> + <test name="anymetrics" qual="all" compare="not_eq"> + <bool>true</bool> + </test> + <edit name="family" mode="append"> + <string>URW Chancery L</string> + </edit> + </match> + <match target="pattern"> + <test name="family"> + <string>Zapf Dingbats</string> + </test> + <test name="anymetrics" qual="all" compare="not_eq"> + <bool>true</bool> + </test> + <edit name="family" mode="append"> + <string>Dingbats</string> + </edit> + </match> + <match target="pattern"> + <test name="family"> + <string>Symbol</string> + </test> + <test name="anymetrics" qual="all" compare="not_eq"> + <bool>true</bool> + </test> + <edit name="family" mode="append" binding="same"> + <string>Standard Symbols L</string> + </edit> + </match> + +<!-- + Serif faces + --> + <alias> + <family>Nimbus Roman No9 L</family> + <default><family>serif</family></default> + </alias> +<!-- + Sans-serif faces + --> + <alias> + <family>Nimbus Sans L</family> + <default><family>sans-serif</family></default> + </alias> +<!-- + Monospace faces + --> + <alias> + <family>Nimbus Mono L</family> + <default><family>monospace</family></default> + </alias> + + +</fontconfig> diff --git a/WebKitTools/DumpRenderTree/qt/fonts/AHEM____.TTF b/WebKitTools/DumpRenderTree/qt/fonts/AHEM____.TTF Binary files differnew file mode 100644 index 0000000..ac81cb0 --- /dev/null +++ b/WebKitTools/DumpRenderTree/qt/fonts/AHEM____.TTF diff --git a/WebKitTools/DumpRenderTree/qt/jsobjects.cpp b/WebKitTools/DumpRenderTree/qt/jsobjects.cpp new file mode 100644 index 0000000..78a93fe --- /dev/null +++ b/WebKitTools/DumpRenderTree/qt/jsobjects.cpp @@ -0,0 +1,360 @@ +/* + * Copyright (C) 2006 Trolltech ASA + * + * 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 <jsobjects.h> +#include <qwebpage.h> +#include <qwebhistory.h> +#include <qwebframe.h> +#include <qevent.h> +#include <qapplication.h> +#include <qevent.h> + +#include "DumpRenderTree.h" +extern void qt_dump_editing_callbacks(bool b); + +LayoutTestController::LayoutTestController(WebCore::DumpRenderTree *drt) + : QObject() + , m_drt(drt) +{ + m_timeoutTimer = 0; + reset(); +} + +void LayoutTestController::reset() +{ + m_isLoading = true; + m_textDump = false; + m_dumpChildrenAsText = false; + m_canOpenWindows = false; + m_waitForDone = false; + m_dumpTitleChanges = false; + if (m_timeoutTimer) { + killTimer(m_timeoutTimer); + m_timeoutTimer = 0; + } + m_topLoadingFrame = 0; + qt_dump_editing_callbacks(false); +} + +void LayoutTestController::maybeDump(bool ok) +{ + QWebFrame *frame = qobject_cast<QWebFrame*>(sender()); + if (frame != m_topLoadingFrame) + return; + + m_topLoadingFrame = 0; + + if (!shouldWaitUntilDone()) { + emit done(); + m_isLoading = false; + } +} + +void LayoutTestController::waitUntilDone() +{ + //qDebug() << ">>>>waitForDone"; + m_waitForDone = true; + m_timeoutTimer = startTimer(11000); +} + +void LayoutTestController::notifyDone() +{ + //qDebug() << ">>>>notifyDone"; + if (!m_timeoutTimer) + return; + killTimer(m_timeoutTimer); + m_timeoutTimer = 0; + emit done(); + m_isLoading = false; +} + +int LayoutTestController::windowCount() +{ + return m_drt->windowCount(); +} + +void LayoutTestController::clearBackForwardList() +{ + m_drt->webPage()->history()->clear(); +} + + +void LayoutTestController::dumpEditingCallbacks() +{ + qDebug() << ">>>dumpEditingCallbacks"; + qt_dump_editing_callbacks(true); +} + +void LayoutTestController::queueReload() +{ + //qDebug() << ">>>queueReload"; +} + +void LayoutTestController::provisionalLoad() +{ + QWebFrame *frame = qobject_cast<QWebFrame*>(sender()); + if (!m_topLoadingFrame && m_isLoading) + m_topLoadingFrame = frame; +} + +void LayoutTestController::timerEvent(QTimerEvent *) +{ + qDebug() << ">>>>>>>>>>>>> timeout"; + notifyDone(); +} + +QString LayoutTestController::encodeHostName(const QString &host) +{ + QString encoded = QString::fromLatin1(QUrl::toAce(host + QLatin1String(".no"))); + encoded.truncate(encoded.length() - 3); // strip .no + return encoded; +} + +QString LayoutTestController::decodeHostName(const QString &host) +{ + QString decoded = QUrl::fromAce(host.toLatin1() + QByteArray(".no")); + decoded.truncate(decoded.length() - 3); + return decoded; +} + + +EventSender::EventSender(QWebPage *parent) + : QObject(parent) +{ + m_page = parent; +} + +void EventSender::mouseDown() +{ +// qDebug() << "EventSender::mouseDown" << frame; + QMouseEvent event(QEvent::MouseButtonPress, m_mousePos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + QApplication::sendEvent(m_page, &event); +} + +void EventSender::mouseUp() +{ +// qDebug() << "EventSender::mouseUp" << frame; + QMouseEvent event(QEvent::MouseButtonRelease, m_mousePos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + QApplication::sendEvent(m_page, &event); +} + +void EventSender::mouseMoveTo(int x, int y) +{ +// qDebug() << "EventSender::mouseMoveTo" << x << y; + m_mousePos = QPoint(x, y); + QMouseEvent event(QEvent::MouseMove, m_mousePos, Qt::NoButton, Qt::NoButton, Qt::NoModifier); + QApplication::sendEvent(m_page, &event); +} + +void EventSender::leapForward(int ms) +{ + m_timeLeap += ms; + qDebug() << "EventSender::leapForward" << ms; +} + +void EventSender::keyDown(const QString &string, const QStringList &modifiers) +{ + QString s = string; + Qt::KeyboardModifiers modifs = 0; + for (int i = 0; i < modifiers.size(); ++i) { + const QString &m = modifiers.at(i); + if (m == "ctrlKey") + modifs |= Qt::ControlModifier; + else if (m == "shiftKey") + modifs |= Qt::ShiftModifier; + else if (m == "altKey") + modifs |= Qt::AltModifier; + else if (m == "metaKey") + modifs |= Qt::MetaModifier; + } + int code = 0; + if (string.length() == 1) { + code = string.unicode()->unicode(); + qDebug() << ">>>>>>>>> keyDown" << code << (char)code; + // map special keycodes used by the tests to something that works for Qt/X11 + if (code == '\t') { + code = Qt::Key_Tab; + if (modifs == Qt::ShiftModifier) + code = Qt::Key_Backtab; + s = QString(); + } else if (code == 127) { + code = Qt::Key_Backspace; + if (modifs == Qt::AltModifier) + modifs = Qt::ControlModifier; + s = QString(); + } else if (code == 'o' && modifs == Qt::ControlModifier) { + s = QLatin1String("\n"); + code = '\n'; + modifs = 0; + } else if (code == 'y' && modifs == Qt::ControlModifier) { + s = QLatin1String("c"); + code = 'c'; + } else if (code == 'k' && modifs == Qt::ControlModifier) { + s = QLatin1String("x"); + code = 'x'; + } else if (code == 'a' && modifs == Qt::ControlModifier) { + s = QString(); + code = Qt::Key_Home; + modifs = 0; + } else if (code == 0xf702) { + s = QString(); + code = Qt::Key_Left; + if (modifs & Qt::MetaModifier) { + code = Qt::Key_Home; + modifs &= ~Qt::MetaModifier; + } + } else if (code == 0xf703) { + s = QString(); + code = Qt::Key_Right; + if (modifs & Qt::MetaModifier) { + code = Qt::Key_End; + modifs &= ~Qt::MetaModifier; + } + } else if (code == 'a' && modifs == Qt::ControlModifier) { + s = QString(); + code = Qt::Key_Home; + modifs = 0; + } else { + code = string.unicode()->toUpper().unicode(); + } + } + QKeyEvent event(QEvent::KeyPress, code, modifs, s); + QApplication::sendEvent(m_page, &event); +} + +QWebFrame *EventSender::frameUnderMouse() const +{ + QWebFrame *frame = m_page->mainFrame(); + +redo: + QList<QWebFrame*> children = frame->childFrames(); + for (int i = 0; i < children.size(); ++i) { + if (children.at(i)->geometry().contains(m_mousePos)) { + frame = children.at(i); + goto redo; + } + } + if (frame->geometry().contains(m_mousePos)) + return frame; + return 0; +} + + +TextInputController::TextInputController(QWebPage *parent) + : QObject(parent) +{ +} + +void TextInputController::doCommand(const QString &command) +{ + Qt::KeyboardModifiers modifiers = Qt::NoModifier; + int keycode = 0; + if (command == "moveBackwardAndModifySelection:") { + modifiers |= Qt::ShiftModifier; + keycode = Qt::Key_Left; + } else if(command =="moveDown:") { + keycode = Qt::Key_Down; + } else if(command =="moveDownAndModifySelection:") { + modifiers |= Qt::ShiftModifier; + keycode = Qt::Key_Down; + } else if(command =="moveForward:") { + keycode = Qt::Key_Right; + } else if(command =="moveForwardAndModifySelection:") { + modifiers |= Qt::ShiftModifier; + keycode = Qt::Key_Right; + } else if(command =="moveLeft:") { + keycode = Qt::Key_Left; + } else if(command =="moveLeftAndModifySelection:") { + modifiers |= Qt::ShiftModifier; + keycode = Qt::Key_Left; + } else if(command =="moveRight:") { + keycode = Qt::Key_Right; + } else if(command =="moveRightAndModifySelection:") { + modifiers |= Qt::ShiftModifier; + keycode = Qt::Key_Right; + } else if(command =="moveToBeginningOfDocument:") { + modifiers |= Qt::ControlModifier; + keycode = Qt::Key_Home; + } else if(command =="moveToBeginningOfLine:") { + keycode = Qt::Key_Home; +// } else if(command =="moveToBeginningOfParagraph:") { + } else if(command =="moveToEndOfDocument:") { + modifiers |= Qt::ControlModifier; + keycode = Qt::Key_End; + } else if(command =="moveToEndOfLine:") { + keycode = Qt::Key_End; +// } else if(command =="moveToEndOfParagraph:") { + } else if(command =="moveUp:") { + keycode = Qt::Key_Up; + } else if(command =="moveUpAndModifySelection:") { + modifiers |= Qt::ShiftModifier; + keycode = Qt::Key_Up; + } else if(command =="moveWordBackward:") { + modifiers |= Qt::ControlModifier; + keycode = Qt::Key_Up; + } else if(command =="moveWordBackwardAndModifySelection:") { + modifiers |= Qt::ShiftModifier; + modifiers |= Qt::ControlModifier; + keycode = Qt::Key_Left; + } else if(command =="moveWordForward:") { + modifiers |= Qt::ControlModifier; + keycode = Qt::Key_Right; + } else if(command =="moveWordForwardAndModifySelection:") { + modifiers |= Qt::ControlModifier; + modifiers |= Qt::ShiftModifier; + keycode = Qt::Key_Right; + } else if(command =="moveWordLeft:") { + modifiers |= Qt::ControlModifier; + keycode = Qt::Key_Left; + } else if(command =="moveWordRight:") { + modifiers |= Qt::ControlModifier; + keycode = Qt::Key_Left; + } else if(command =="moveWordRightAndModifySelection:") { + modifiers |= Qt::ShiftModifier; + modifiers |= Qt::ControlModifier; + keycode = Qt::Key_Right; + } else if(command =="moveWordLeftAndModifySelection:") { + modifiers |= Qt::ShiftModifier; + modifiers |= Qt::ControlModifier; + keycode = Qt::Key_Left; + } else if(command =="pageDown:") { + keycode = Qt::Key_PageDown; + } else if(command =="pageUp:") { + keycode = Qt::Key_PageUp; + } else if(command == "deleteWordBackward:") { + modifiers |= Qt::ControlModifier; + keycode = Qt::Key_Backspace; + } else if(command == "deleteBackward:") { + keycode = Qt::Key_Backspace; + } else if(command == "deleteForward:") { + keycode = Qt::Key_Delete; + } + QKeyEvent event(QEvent::KeyPress, keycode, modifiers); + QApplication::sendEvent(parent(), &event); + QKeyEvent event2(QEvent::KeyRelease, keycode, modifiers); + QApplication::sendEvent(parent(), &event2); +} diff --git a/WebKitTools/DumpRenderTree/qt/jsobjects.h b/WebKitTools/DumpRenderTree/qt/jsobjects.h new file mode 100644 index 0000000..511e857 --- /dev/null +++ b/WebKitTools/DumpRenderTree/qt/jsobjects.h @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2006 Trolltech ASA + * + * 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 JSOBJECTS_H +#define JSOBJECTS_H + +#include <qobject.h> +#include <qdebug.h> +#include <qpoint.h> +#include <qstringlist.h> + +class QWebFrame; +namespace WebCore { + class DumpRenderTree; +} +class LayoutTestController : public QObject +{ + Q_OBJECT +public: + LayoutTestController(WebCore::DumpRenderTree *drt); + + bool isLoading() const { return m_isLoading; } + void setLoading(bool loading) { m_isLoading = loading; } + + bool shouldDumpAsText() const { return m_textDump; } + bool shouldDumpChildrenAsText() const { return m_dumpChildrenAsText; } + bool shouldWaitUntilDone() const { return m_waitForDone; } + bool canOpenWindows() const { return m_canOpenWindows; } + bool shouldDumpTitleChanges() const { return m_dumpTitleChanges; } + + void reset(); + +protected: + void timerEvent(QTimerEvent *); + +signals: + void done(); + +public slots: + void maybeDump(bool ok); + void dumpAsText() { m_textDump = true; } + void dumpChildFramesAsText() { m_dumpChildrenAsText = true; } + void setCanOpenWindows() { m_canOpenWindows = true; } + void waitUntilDone(); + void notifyDone(); + void dumpEditingCallbacks(); + void queueReload(); + void provisionalLoad(); + void setCloseRemainingWindowsWhenComplete(bool=false) {} + int windowCount(); + void display() {} + void clearBackForwardList(); + void dumpTitleChanges() { m_dumpTitleChanges = true; } + QString encodeHostName(const QString &host); + QString decodeHostName(const QString &host); + void dumpSelectionRect() const {} + +private: + bool m_isLoading; + bool m_textDump; + bool m_dumpChildrenAsText; + bool m_canOpenWindows; + bool m_waitForDone; + bool m_dumpTitleChanges; + int m_timeoutTimer; + QWebFrame *m_topLoadingFrame; + WebCore::DumpRenderTree *m_drt; +}; + +class QWebPage; +class QWebFrame; + +class EventSender : public QObject +{ + Q_OBJECT +public: + EventSender(QWebPage *parent); + +public slots: + void mouseDown(); + void mouseUp(); + void mouseMoveTo(int x, int y); + void leapForward(int ms); + void keyDown(const QString &string, const QStringList &modifiers=QStringList()); + void clearKillRing() {} + +private: + QPoint m_mousePos; + QWebPage *m_page; + int m_timeLeap; + QWebFrame *frameUnderMouse() const; +}; + +class TextInputController : public QObject +{ + Q_OBJECT +public: + TextInputController(QWebPage *parent); + +public slots: + void doCommand(const QString &command); +// void setMarkedText(const QString &str, int from, int length); +// bool hasMarkedText(); +// void unmarkText(); +// QList<int> markedRange(); +// QList<int> selectedRange(); +// void validAttributesForMarkedText(); +// void inserText(const QString &); +// void firstRectForCharacterRange(); +// void characterIndexForPoint(int, int); +// void substringFromRange(int, int); +// void conversationIdentifier(); +}; + +#endif diff --git a/WebKitTools/DumpRenderTree/qt/main.cpp b/WebKitTools/DumpRenderTree/qt/main.cpp new file mode 100644 index 0000000..dd4c0e9 --- /dev/null +++ b/WebKitTools/DumpRenderTree/qt/main.cpp @@ -0,0 +1,177 @@ +/* + * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2007 Trolltech ASA + * + * 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 "DumpRenderTree.h" +#include "testplugin.h" + +#include <qstringlist.h> +#include <qapplication.h> +#include <qurl.h> +#include <qdir.h> +#include <qdebug.h> +#include <qfont.h> + +#ifdef Q_WS_X11 +#include <qx11info_x11.h> +#include <fontconfig/fontconfig.h> +#endif + +#include <limits.h> +#include <signal.h> + +#if defined(__GLIBC__) +#include <execinfo.h> +#endif + +#if QT_VERSION < 0x040400 +Q_IMPORT_PLUGIN(testplugin) +#endif + +void messageHandler(QtMsgType type, const char *message) +{ + if (type == QtCriticalMsg) { + fprintf(stderr, "%s\n", message); + return; + } + // do nothing +} + +QString get_backtrace() { + QString s; + +#if defined(__GLIBC__) + void* array[256]; + size_t size; /* number of stack frames */ + + size = backtrace(array, 256); + + if (!size) + return s; + + char** strings = backtrace_symbols(array, size); + for (int i = 0; i < size; ++i) { + s += QString::number(i) + + QLatin1String(": ") + + QLatin1String(strings[i]) + QLatin1String("\n"); + } + + if (strings) + free (strings); +#endif + + return s; +} + +static void crashHandler(int sig) +{ + fprintf(stderr, "%s\n", strsignal(sig)); + fprintf(stderr, "%s\n", get_backtrace().toLatin1().constData()); + exit(128 + sig); +} + +int main(int argc, char* argv[]) +{ +#ifdef Q_WS_X11 + FcInit(); + FcConfig *config = FcConfigCreate(); + 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 checkout from svn://labs.trolltech.com/svn/webkit/testfonts\n" + "--------------------------------------------------------------------\n" +); + exit(1); + } + char currentPath[PATH_MAX+1]; + getcwd(currentPath, PATH_MAX); + QByteArray configFile = currentPath; + configFile += "/WebKitTools/DumpRenderTree/qt/fonts.conf"; + if (!FcConfigParseAndLoad (config, (FcChar8*) configFile.data(), true)) + qFatal("Couldn't load font configuration file"); + if (!FcConfigAppFontAddDir (config, (FcChar8*) fontDir.data())) + qFatal("Couldn't add font dir!"); + FcConfigSetCurrent(config); +#endif + QApplication app(argc, argv); +#ifdef Q_WS_X11 + QX11Info::setAppDpiY(0, 96); + QX11Info::setAppDpiX(0, 96); +#endif + + QFont f("Sans Serif"); + f.setPointSize(9); + f.setWeight(QFont::Normal); + f.setStyle(QFont::StyleNormal); + app.setFont(f); + app.setStyle(QLatin1String("Plastique")); + + + signal(SIGILL, crashHandler); /* 4: illegal instruction (not reset when caught) */ + signal(SIGTRAP, crashHandler); /* 5: trace trap (not reset when caught) */ + signal(SIGFPE, crashHandler); /* 8: floating point exception */ + signal(SIGBUS, crashHandler); /* 10: bus error */ + signal(SIGSEGV, crashHandler); /* 11: segmentation violation */ + signal(SIGSYS, crashHandler); /* 12: bad argument to system call */ + signal(SIGPIPE, crashHandler); /* 13: write on a pipe with no reader */ + signal(SIGXCPU, crashHandler); /* 24: exceeded CPU time limit */ + signal(SIGXFSZ, crashHandler); /* 25: exceeded file size limit */ + + QStringList args = app.arguments(); + if (args.count() < 2) { + qDebug() << "Usage: DumpRenderTree [-v] filename"; + exit(0); + } + + // supress debug output from Qt if not started with -v + if (!args.contains(QLatin1String("-v"))) + qInstallMsgHandler(messageHandler); + + WebCore::DumpRenderTree dumper; + + if (args.last() == QLatin1String("-")) { + dumper.open(); + } else { + if (!args.last().startsWith("/") + && !args.last().startsWith("file:")) { + QString path = QDir::currentPath(); + if (!path.endsWith('/')) + path.append('/'); + args.last().prepend(path); + } + dumper.open(QUrl(args.last())); + } + return app.exec(); +#ifdef Q_WS_X11 + FcConfigSetCurrent(0); +#endif +} diff --git a/WebKitTools/DumpRenderTree/qt/testplugin.cpp b/WebKitTools/DumpRenderTree/qt/testplugin.cpp new file mode 100644 index 0000000..27558c9 --- /dev/null +++ b/WebKitTools/DumpRenderTree/qt/testplugin.cpp @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2007 Trolltech ASA + * + * 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 "testplugin.h" + +#if QT_VERSION < 0x040400 + +TestPlugin::TestPlugin(QObject *parent) + : QWebObjectPlugin(parent) +{ +} + +TestPlugin::~TestPlugin() +{ +} + +QStringList TestPlugin::keys() const +{ + return QStringList(QLatin1String("testplugin")); +} + +QString TestPlugin::descriptionForKey(const QString &) const +{ + return QLatin1String("testdescription"); +} + +QStringList TestPlugin::mimetypesForKey(const QString &) const +{ + return QStringList(QLatin1String("testtype")); +} + +QStringList TestPlugin::extensionsForMimetype(const QString &) const +{ + return QStringList(QLatin1String("testsuffixes")); +} + +QObject *TestPlugin::create(QWebObjectPluginConnector *, + const QUrl &, + const QString &, + const QStringList &, + const QStringList &) const +{ + return 0; +} + +Q_EXPORT_PLUGIN2(testplugin, TestPlugin) +#endif diff --git a/WebKitTools/DumpRenderTree/qt/testplugin.h b/WebKitTools/DumpRenderTree/qt/testplugin.h new file mode 100644 index 0000000..e305069 --- /dev/null +++ b/WebKitTools/DumpRenderTree/qt/testplugin.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2007 Trolltech ASA + * + * 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 <qglobal.h> +#if QT_VERSION < 0x040400 +#define QT_STATICPLUGIN +#include <qwebobjectplugin.h> + + +class TestPlugin : public QWebObjectPlugin +{ +public: + explicit TestPlugin(QObject *parent = 0); + virtual ~TestPlugin(); + + virtual QStringList keys() const; + + virtual QString descriptionForKey(const QString &key) const; + virtual QStringList mimetypesForKey(const QString &key) const; + virtual QStringList extensionsForMimetype(const QString &mimeType) const; + virtual QObject *create(QWebObjectPluginConnector *connector, + const QUrl &url, + const QString &mimeType, + const QStringList &argumentNames, + const QStringList &argumentValues) const; +}; + +#endif |