Commit 7cc6060a authored by lars's avatar lars
Browse files

Added the start of a public API to the Qt build

        of WebKit. Currently we have QWebPage and QWebFrame
        with a few small methods.

        Converted the QtLauncher and DumpRenderTree 
        to use the new public API.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@18886 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e10f23a9
2007-01-16 Lars Knoll <lars@trolltech.com>
Reviewed by Zack
Remove everything but the new public API from
the include path.
* WebKit.pri:
2007-01-11 George Staikos <staikos@kde.org>
Fix the Qt build
......
2007-01-16 Lars Knoll <lars@trolltech.com>
Reviewed by Zack
Cleaned up the way we create native widgets. They are
now not created in WebCore anymore, but in the new
Qt API to WebKit.
Fix a compile issue in the ResourceHandleManager.
* WebCore.pro:
* platform/ScrollView.h:
* platform/Widget.h:
(WebCore::ResourceHandleManager::cancel):
* platform/qt/ScrollViewCanvasQt.cpp:
(WebCore::ScrollViewCanvasQt::ScrollViewCanvasQt):
(WebCore::ScrollViewCanvasQt::paintEvent):
(WebCore::ScrollViewCanvasQt::mouseMoveEvent):
(WebCore::ScrollViewCanvasQt::mousePressEvent):
(WebCore::ScrollViewCanvasQt::mouseReleaseEvent):
(WebCore::ScrollViewCanvasQt::handleKeyEvent):
* platform/qt/ScrollViewCanvasQt.h:
* platform/qt/ScrollViewQt.cpp:
(WebCore::ScrollView::ScrollView):
(WebCore::ScrollView::setScrollArea):
(WebCore::ScrollView::addChild):
* platform/qt/WidgetQt.cpp:
* platform/network/qt/ResourceHandleManagerQt.cpp:
2007-01-16 Lars Knoll <lars@trolltech.com>
Reviewed by Zack
......
......@@ -67,6 +67,7 @@ INCLUDEPATH += $$PWD \
$$PWD/ksvg2 $$PWD/ksvg2/css $$PWD/ksvg2/svg $$PWD/ksvg2/misc $$PWD/ksvg2/events \
$$PWD/platform/image-decoders \
$$PWD/../WebKitQt/WebCoreSupport \
$$PWD/../WebKitQt/Api \
$$PWD/WebCore+SVG
QT += network
!mac:CONFIG += link_pkgconfig
......@@ -101,7 +102,9 @@ STYLESHEETS_EMBED = $$PWD/css/html4.css
MANUALMOC += \
$$PWD/platform/qt/SharedTimerQt.h \
$$PWD/platform/qt/ScrollViewCanvasQt.h \
$$PWD/platform/network/qt/ResourceHandleManagerQt.h
$$PWD/platform/network/qt/ResourceHandleManagerQt.h \
$$PWD/../WebKitQt/Api/qwebpage.h \
$$PWD/../WebKitQt/Api/qwebframe.h
LUT_FILES += \
bindings/js/kjs_window.cpp \
......@@ -671,7 +674,9 @@ SOURCES += \
../WebKitQt/WebCoreSupport/FrameLoaderClientQt.cpp \
../WebKitQt/WebCoreSupport/EditorClientQt.cpp \
../WebKitQt/WebCoreSupport/ChromeClientQt.cpp \
../WebKitQt/WebCoreSupport/ContextMenuClientQt.cpp
../WebKitQt/WebCoreSupport/ContextMenuClientQt.cpp \
../WebKitQt/Api/qwebpage.cpp \
../WebKitQt/Api/qwebframe.cpp
contains(DEFINES, XPATH_SUPPORT=1) {
FEATURE_DEFINES_JAVASCRIPT += XPATH_SUPPORT
......
......@@ -146,7 +146,7 @@ namespace WebCore {
ScrollView();
~ScrollView();
virtual void setParentWidget(QWidget*);
void setScrollArea(QScrollArea*);
private:
QScrollArea* m_area;
......
......@@ -149,9 +149,6 @@ namespace WebCore {
#endif
#if PLATFORM(QT)
QWidget* parentWidget() const;
virtual void setParentWidget(QWidget*);
QWidget* qwidget();
void setQWidget(QWidget*);
#endif
......
......@@ -180,6 +180,9 @@ void ResourceHandleManager::cancel(ResourceHandle* resource)
DEBUG() << "ResourceHandleManager::cancel" << resource->url().path();
RequestQt* request = pendingRequests[resource];
if (!request)
return;
request->cancelled = true;
String protocol = request->hostInfo.protocol;
......
......@@ -47,6 +47,7 @@
#include <QPainter>
#include <QPaintEvent>
#include <QMouseEvent>
#include <qdebug.h>
//this output ms that it takes WebKit to render in each paint event
......@@ -58,31 +59,20 @@
namespace WebCore {
ScrollViewCanvasQt::ScrollViewCanvasQt(ScrollView* frameView, QWidget* parent)
: QWidget(parent),
m_scrollView(frameView),
m_frameView(0)
ScrollViewCanvasQt::ScrollViewCanvasQt(FrameView* frameView, QWidget* parent)
: QWidget(0),
m_frameView(frameView)
{
setMouseTracking(true);
setFocusPolicy(Qt::StrongFocus);
}
bool ScrollViewCanvasQt::updateFrameView()
{
m_frameView = static_cast<FrameView*>(m_scrollView);
if (!m_frameView || !m_frameView->frame())
return false;
return true;
resize(500, 500);
}
void ScrollViewCanvasQt::paintEvent(QPaintEvent* ev)
{
if (!m_frameView) {
if (!updateFrameView() ||
!m_frameView->frame()->renderer())
return;
}
if (!m_frameView || !m_frameView->frame()->renderer())
return;
#ifdef QWEBKIT_TIME_RENDERING
QTime time;
......@@ -109,30 +99,24 @@ void ScrollViewCanvasQt::paintEvent(QPaintEvent* ev)
void ScrollViewCanvasQt::mouseMoveEvent(QMouseEvent* ev)
{
if (!m_frameView) {
if (!updateFrameView())
return;
}
if (!m_frameView)
return;
m_frameView->handleMouseMoveEvent(PlatformMouseEvent(ev, 0));
}
void ScrollViewCanvasQt::mousePressEvent(QMouseEvent* ev)
{
if (!m_frameView) {
if (!updateFrameView() || !m_frameView->frame()->eventHandler())
return;
}
if (!m_frameView || !m_frameView->frame()->eventHandler())
return;
m_frameView->frame()->eventHandler()->handleMousePressEvent(PlatformMouseEvent(ev, 1));
}
void ScrollViewCanvasQt::mouseReleaseEvent(QMouseEvent* ev)
{
if (!m_frameView) {
if (!updateFrameView())
return;
}
if (!m_frameView)
return;
m_frameView->handleMouseReleaseEvent(PlatformMouseEvent(ev, 0));
}
......@@ -151,10 +135,9 @@ void ScrollViewCanvasQt::handleKeyEvent(QKeyEvent* ev, bool isKeyUp)
{
PlatformKeyboardEvent kevent(ev, isKeyUp);
if (!m_frameView) {
if (!updateFrameView())
return;
}
if (!m_frameView)
return;
FrameQt* frame = static_cast<FrameQt*>(m_frameView->frame());
if (!frame)
return;
......
......@@ -46,7 +46,7 @@ class ScrollViewCanvasQt : public QWidget
{
Q_OBJECT
public:
ScrollViewCanvasQt(ScrollView*, QWidget* parent = 0);
ScrollViewCanvasQt(FrameView*, QWidget* parent = 0);
protected:
virtual void paintEvent(QPaintEvent*);
......@@ -58,9 +58,7 @@ protected:
private:
void handleKeyEvent(QKeyEvent*, bool isKeyUp);
bool updateFrameView();
ScrollView* m_scrollView;
FrameView* m_frameView;
};
......
......@@ -31,6 +31,7 @@
#include "config.h"
#include "ScrollView.h"
#include "FrameView.h"
#include "FloatRect.h"
#include "IntPoint.h"
......@@ -45,21 +46,22 @@
namespace WebCore {
ScrollView::ScrollView()
: m_area(new QScrollArea(0))
: m_area(0)
{
ScrollViewCanvasQt* canvas = new ScrollViewCanvasQt(this, m_area);
setQWidget(m_area);
m_area->setWidget(canvas);
}
ScrollView::~ScrollView()
{
}
void ScrollView::setParentWidget(QWidget* parent)
void ScrollView::setScrollArea(QScrollArea* area)
{
Widget::setParentWidget(parent);
m_area = area;
if (isFrameView()) {
ScrollViewCanvasQt* canvas = new ScrollViewCanvasQt(static_cast<FrameView*>(this), m_area);
m_area->setWidget(canvas);
}
Widget::setQWidget(area);
}
void ScrollView::updateContents(const IntRect& updateRect, bool now)
......@@ -228,10 +230,11 @@ void ScrollView::setStaticBackground(bool flag)
void ScrollView::addChild(Widget* child)
{
Q_ASSERT(child != 0);
Q_ASSERT(m_area && m_area->widget());
notImplemented();
// Q_ASSERT(child != 0);
// Q_ASSERT(m_area && m_area->widget());
child->setParentWidget(m_area->widget());
// child->setParentWidget(m_area->widget());
}
void ScrollView::removeChild(Widget*)
......
......@@ -149,16 +149,6 @@ QWidget* Widget::qwidget()
return data->m_widget;
}
void Widget::setParentWidget(QWidget* parent)
{
data->m_parent = parent;
}
QWidget* Widget::parentWidget() const
{
return data->m_parent;
}
void Widget::setFrameGeometry(const IntRect& r)
{
if (!data->m_widget)
......
# Include file to make it easy to include WebKit into Qt projects
INCLUDEPATH += $$PWD/JavaScriptCore \
$$PWD/WebCore \
$$PWD/WebCore/platform \
$$PWD/WebCore/platform/qt \
$$PWD/WebCore/platform/network \
$$PWD/WebCore/platform/graphics \
$$PWD/WebCore/editing \
$$PWD/WebCore/page \
$$PWD/WebCore/page/qt \
$$PWD/WebCore/dom \
$$PWD/WebCore/html \
$$PWD/WebCore/history \
$$PWD/WebCore/rendering \
$$PWD/WebCore/loader \
$$PWD/WebCore/loader/qt \
$$PWD/WebCore/css \
$$PWD/WebCore/bridge \
$$PWD/WebKitQt/WebCoreSupport
INCLUDEPATH += $$PWD/WebKitQt/Api
DEFINES += BUILDING_QT__=1
......
/*
Copyright (C) 2007 Trolltech ASA
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
This class provides all functionality needed for loading images, style sheets and html
pages from the web. It has a memory cache for these objects.
*/
#include "qwebframe.h"
#include "qwebpage.h"
#include "qwebpage_p.h"
#include "qwebframe_p.h"
#include <qdebug.h>
#include "FrameLoaderClientQt.h"
#include "FrameQtClient.h"
#include "FrameQt.h"
#include "FrameView.h"
#include "markup.h"
#include "RenderTreeAsText.h"
#include "Element.h"
#include "Document.h"
#include "bindings/runtime.h"
#include "bindings/runtime_root.h"
#include "ExecState.h"
#include "object.h"
using namespace WebCore;
QWebFrame::QWebFrame(QWebPage *parent)
: QScrollArea(parent)
, d(new QWebFramePrivate)
{
d->frameLoaderClient = new FrameLoaderClientQt();
d->frame = new FrameQt(parent->d->page, 0, new FrameQtClient(), d->frameLoaderClient);
d->frameLoaderClient->setFrame(this, d->frame);
d->frameView = new FrameView(d->frame);
d->frameView->setScrollArea(this);
d->frame->setView(d->frameView);
}
QWebFrame::QWebFrame(QWebFrame *parent)
: QScrollArea(parent)
, d(new QWebFramePrivate)
{
// d->frameLoaderClient = new FrameLoaderClientQt();
// d->frame = new FrameQt(page, 0, new FrameQtClient(), frameLoaderClient);
// d->frameLoaderClient->setFrame(d->frame);
// d->frameView = new FrameView(d->frame);
// d->frameView->setScrollArea(this);
// d->frame->setView(d->frameView);
}
QWebFrame::~QWebFrame()
{
delete d->frame;
}
void QWebFrame::addToJSWindowObject(const QByteArray &name, QObject *object)
{
KJS::Bindings::RootObject *root = d->frame->bindingRootObject();
KJS::ExecState *exec = root->interpreter()->globalExec();
KJS::JSObject *rootObject = root->interpreter()->globalObject();
KJS::JSObject *window = rootObject->get(exec, KJS::Identifier("window"))->getObject();
if (!window) {
qDebug() << "Warning: couldn't get window object";
return;
}
KJS::JSObject *testController =
KJS::Bindings::Instance::createRuntimeObject(KJS::Bindings::Instance::QtLanguage,
object, root);
window->put(exec, KJS::Identifier(name.constData()), testController);
}
QString QWebFrame::markup() const
{
return createMarkup(d->frame->document());
}
QString QWebFrame::innerText() const
{
Element *documentElement = d->frame->document()->documentElement();
return documentElement->innerText();
}
QString QWebFrame::renderTreeDump() const
{
return externalRepresentation(d->frame->renderer());
}
#include "qwebframe.moc"
/*
Copyright (C) 2007 Trolltech ASA
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
This class provides all functionality needed for loading images, style sheets and html
pages from the web. It has a memory cache for these objects.
*/
#ifndef QWEBFRAME_H
#define QWEBFRAME_H
#include <qscrollarea.h>
class QWebFramePrivate;
class QWebPage;
namespace WebCore {
class FrameLoaderClientQt;
}
class QWebFrame : public QScrollArea
{
Q_OBJECT
public:
QWebFrame(QWebPage *parent);
QWebFrame(QWebFrame *parent);
~QWebFrame();
void addToJSWindowObject(const QByteArray &name, QObject *object);
QString markup() const;
QString innerText() const;
QString renderTreeDump() const;
signals:
void cleared();
void loadDone();
private:
friend class QWebPage;
friend class WebCore::FrameLoaderClientQt;
QWebFramePrivate *d;
};
#endif
/*
Copyright (C) 2007 Trolltech ASA
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
This class provides all functionality needed for loading images, style sheets and html
pages from the web. It has a memory cache for these objects.
*/
#ifndef QWEBFRAME_P_H
#define QWEBFRAME_P_H
#include "qwebframe.h"
#include "qwebpage_p.h"
namespace WebCore
{
class FrameLoaderClientQt;
class FrameQt;
class FrameView;
}
class QWebFramePrivate
{
public:
QWebFramePrivate()
: frameLoaderClient(0)
, frame(0)
, frameView(0)
{}
WebCore::FrameLoaderClientQt *frameLoaderClient;
WebCore::FrameQt *frame;
WebCore::FrameView *frameView;
};
#endif
/*
Copyright (C) 2007 Trolltech ASA
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
This class provides all functionality needed for loading images, style sheets and html
pages from the web. It has a memory cache for these objects.
*/
#include "qwebpage.h"
#include "qwebframe.h"
#include "qwebpage_p.h"
#include "qwebframe_p.h"
#include <qurl.h>
#include "FrameQt.h"
#include "ChromeClientQt.h"
#include "ContextMenuClientQt.h"
#include "EditorClientQt.h"
#include "Page.h"
#include "FrameLoader.h"
#include "KURL.h"
#include "qboxlayout.h"
using namespace WebCore;
QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
: q(qq)
{
chromeClient = new ChromeClientQt(q);
contextMenuClient = new ContextMenuClientQt();
editorClient = new EditorClientQt();
page = new Page(chromeClient, contextMenuClient, editorClient);
mainFrame = 0;
}
QWebPagePrivate::~QWebPagePrivate()
{
delete page;
}
void QWebPagePrivate::createMainFrame()
{
if (!mainFrame) {
mainFrame = q->createFrame(0);
layout->addWidget(mainFrame);
}
}
QWebPage::QWebPage(QWidget *parent)
: QWidget(parent)
, d(new QWebPagePrivate(this))
{
d->layout = new QVBoxLayout(this);
d->layout->setMargin(0);
d->layout->setSpacing(0);
}
QWebPage::~QWebPage()
{
delete d;
</