Commit b0b15df5 authored by andersca's avatar andersca

2006-08-27 Anders Carlsson <acarlsson@apple.com>

        Forgot to add these.
        
        * DumpRenderTree/DumpRenderTree.qtproj/CMakeLists.txt: Added.
        * DumpRenderTree/DumpRenderTree.qtproj/DumpRenderTree.cpp: Added.
        (WebCore::DumpRenderTree::DumpRenderTree):
        (WebCore::DumpRenderTree::~DumpRenderTree):
        (WebCore::DumpRenderTree::open):
        (WebCore::DumpRenderTree::readStdin):
        (WebCore::DumpRenderTree::checkLoaded):
        * DumpRenderTree/DumpRenderTree.qtproj/DumpRenderTree.h: Added.
        * DumpRenderTree/DumpRenderTree.qtproj/main.cpp: Added.
        (main):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@16061 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 09245423
2006-08-27 Anders Carlsson <acarlsson@apple.com>
Forgot to add these.
* DumpRenderTree/DumpRenderTree.qtproj/CMakeLists.txt: Added.
* DumpRenderTree/DumpRenderTree.qtproj/DumpRenderTree.cpp: Added.
(WebCore::DumpRenderTree::DumpRenderTree):
(WebCore::DumpRenderTree::~DumpRenderTree):
(WebCore::DumpRenderTree::open):
(WebCore::DumpRenderTree::readStdin):
(WebCore::DumpRenderTree::checkLoaded):
* DumpRenderTree/DumpRenderTree.qtproj/DumpRenderTree.h: Added.
* DumpRenderTree/DumpRenderTree.qtproj/main.cpp: Added.
(main):
2006-08-27 Nikolas Zimmermann <zimmermann@kde.org>
Reviewed by Eric, landed by Anders.
......
include_directories(
BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/../../../WebCore
BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/../../../JavaScriptCore
BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/../../../WebCore/bridge
BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/../../../WebCore/page
BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/../../../WebCore/loader
BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/../../../WebCore/platform
BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/../../../WebCore/platform/qt
BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/../../../WebCore/kwq
BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/../../../WebCore/rendering
BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/../../../WebCore/editing
BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/../../../WebCore/html
BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/../../../WebCore/css
BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/../../../WebCore/dom
BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/../../../WebCore/xml
BEFORE ${CMAKE_SOURCE_DIR}/kdecore
)
add_definitions(-Wno-undef -Wno-unused-parameter)
set(DumpRenderTree_SRCS main.cpp DumpRenderTree.cpp)
kde4_automoc(${DumpRenderTree_SRCS})
kde4_add_executable(DumpRenderTree RUN_UNINSTALLED ${DumpRenderTree_SRCS})
target_link_libraries(DumpRenderTree ${KDE4_KDECORE_LIBS} WebCore-unity)
/*
* 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 "config.h"
#include "markup.h"
#include "Document.h"
#include "DumpRenderTree.h"
#include "RenderTreeAsText.h"
#include <QTimer>
#include <QBoxLayout>
#include <QApplication>
#include <QDebug>
#include <QScrollArea>
#include <unistd.h>
namespace WebCore {
// Choose some default values.
const unsigned int maxViewWidth = 800;
const unsigned int maxViewHeight = 600;
DumpRenderTree::DumpRenderTree()
: m_frame(0)
, m_stdin(0)
, m_notifier()
{
m_frame = new FrameQt(0 /* no toplevel widget */);
m_frame->view()->setScrollBarsMode(ScrollBarAlwaysOff);
// Reverse calculations in QAbstractScrollArea::maximumViewportSize()
QScrollArea* area = qobject_cast<QScrollArea*>(m_frame->view()->qwidget());
unsigned int viewWidth = maxViewWidth + 2 * area->frameWidth();
unsigned int viewHeight = maxViewHeight + 2 * area->frameWidth();
area->resize(viewWidth, viewHeight);
}
DumpRenderTree::~DumpRenderTree()
{
delete m_frame;
delete m_stdin;
delete m_notifier;
}
void DumpRenderTree::open()
{
if (!m_stdin)
m_stdin = new QTextStream(stdin, IO_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 KURL& url)
{
m_frame->openURL(url);
// Simple poll mechanism, to find out when the page is loaded...
checkLoaded();
}
void DumpRenderTree::readStdin(int /* socket */)
{
// Read incoming data from stdin...
QString line = m_stdin->readLine();
if (!line.isEmpty())
open(KURL(line.toLatin1()));
}
void DumpRenderTree::checkLoaded()
{
if(m_frame->isComplete()) {
if (!m_notifier) {
// Dump markup in single file mode...
DeprecatedString markup = createMarkup(m_frame->document());
fprintf(stdout, "Source:\n\n%s\n", markup.ascii());
}
// Dump render text...
DeprecatedString renderDump = externalRepresentation(m_frame->renderer());
fprintf(stdout, "%s#EOF\n", renderDump.ascii());
fflush(stdout);
if (!m_notifier) {
// Exit now in single file mode...
QApplication::exit();
}
} else
QTimer::singleShot(20, this, SLOT(checkLoaded()));
}
}
#include "DumpRenderTree.moc"
/*
* 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 <QObject>
#include <QTextStream>
#include <QSocketNotifier>
#include "FrameQt.h"
namespace WebCore {
class DumpRenderTree : public QObject {
Q_OBJECT
public:
DumpRenderTree();
~DumpRenderTree();
// Initialize in multi-file mode, used by run-webkit-tests.
void open();
// Initialize in single-file mode.
void open(const KURL& url);
public Q_SLOTS:
void readStdin(int);
void checkLoaded();
private:
FrameQt* m_frame;
QTextStream* m_stdin;
QSocketNotifier* m_notifier;
};
}
#endif
/*
* 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 "config.h"
#include "DumpRenderTree.h"
#include <kapplication.h>
#include <kcmdlineargs.h>
using namespace WebCore;
static KCmdLineOptions options[] =
{
{ "+file", "File to load", 0 },
KCmdLineLastOption
};
int main(int argc, char* argv[])
{
KCmdLineArgs::init(argc, argv, "DumpRenderTree", "DumpRenderTree", "testing application", "0.1");
KCmdLineArgs::addCmdLineOptions(options);
KApplication app;
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
WebCore::DumpRenderTree dumper;
if (args->count() == 1 && args->arg(0) == QLatin1String("-"))
dumper.open();
else if (args->count() == 1)
dumper.open(KURL(args->arg(0)));
return app.exec();
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment