summaryrefslogtreecommitdiffstats
path: root/WebKit/qt
diff options
context:
space:
mode:
authorUpstream <upstream-import@none>1970-01-12 13:46:40 +0000
committerUpstream <upstream-import@none>1970-01-12 13:46:40 +0000
commitd8543bb6618c17b12da906afa77d216f58cf4058 (patch)
treec58dc05ed86825bd0ef8d305d58c8205106b540f /WebKit/qt
downloadexternal_webkit-d8543bb6618c17b12da906afa77d216f58cf4058.zip
external_webkit-d8543bb6618c17b12da906afa77d216f58cf4058.tar.gz
external_webkit-d8543bb6618c17b12da906afa77d216f58cf4058.tar.bz2
external/webkit r30707
Diffstat (limited to 'WebKit/qt')
-rw-r--r--WebKit/qt/Api/headers.pri11
-rw-r--r--WebKit/qt/Api/qcookiejar.cpp105
-rw-r--r--WebKit/qt/Api/qcookiejar.h55
-rw-r--r--WebKit/qt/Api/qtwebkit.prf4
-rw-r--r--WebKit/qt/Api/qwebframe.cpp625
-rw-r--r--WebKit/qt/Api/qwebframe.h138
-rw-r--r--WebKit/qt/Api/qwebframe_p.h90
-rw-r--r--WebKit/qt/Api/qwebhistory.cpp281
-rw-r--r--WebKit/qt/Api/qwebhistory.h92
-rw-r--r--WebKit/qt/Api/qwebhistory_p.h39
-rw-r--r--WebKit/qt/Api/qwebhistoryinterface.cpp110
-rw-r--r--WebKit/qt/Api/qwebhistoryinterface.h43
-rw-r--r--WebKit/qt/Api/qwebkitglobal.h39
-rw-r--r--WebKit/qt/Api/qwebnetworkinterface.cpp1265
-rw-r--r--WebKit/qt/Api/qwebnetworkinterface.h175
-rw-r--r--WebKit/qt/Api/qwebnetworkinterface_p.h223
-rw-r--r--WebKit/qt/Api/qwebobjectplugin.cpp192
-rw-r--r--WebKit/qt/Api/qwebobjectplugin.h66
-rw-r--r--WebKit/qt/Api/qwebobjectplugin_p.h76
-rw-r--r--WebKit/qt/Api/qwebobjectpluginconnector.cpp64
-rw-r--r--WebKit/qt/Api/qwebobjectpluginconnector.h69
-rw-r--r--WebKit/qt/Api/qwebpage.cpp1593
-rw-r--r--WebKit/qt/Api/qwebpage.h242
-rw-r--r--WebKit/qt/Api/qwebpage_p.h159
-rw-r--r--WebKit/qt/Api/qwebsettings.cpp384
-rw-r--r--WebKit/qt/Api/qwebsettings.h112
-rw-r--r--WebKit/qt/Api/qwebview.cpp593
-rw-r--r--WebKit/qt/Api/qwebview.h135
-rw-r--r--WebKit/qt/Plugins/ICOHandler.cpp459
-rw-r--r--WebKit/qt/Plugins/ICOHandler.h52
-rw-r--r--WebKit/qt/Plugins/Plugins.pro14
-rw-r--r--WebKit/qt/QtLauncher/QtLauncher.pro9
-rw-r--r--WebKit/qt/QtLauncher/main.cpp397
-rw-r--r--WebKit/qt/WebCoreSupport/ChromeClientQt.cpp356
-rw-r--r--WebKit/qt/WebCoreSupport/ChromeClientQt.h121
-rw-r--r--WebKit/qt/WebCoreSupport/ContextMenuClientQt.cpp81
-rw-r--r--WebKit/qt/WebCoreSupport/ContextMenuClientQt.h52
-rw-r--r--WebKit/qt/WebCoreSupport/DragClientQt.cpp80
-rw-r--r--WebKit/qt/WebCoreSupport/DragClientQt.h46
-rw-r--r--WebKit/qt/WebCoreSupport/EditCommandQt.cpp52
-rw-r--r--WebKit/qt/WebCoreSupport/EditCommandQt.h42
-rw-r--r--WebKit/qt/WebCoreSupport/EditorClientQt.cpp551
-rw-r--r--WebKit/qt/WebCoreSupport/EditorClientQt.h120
-rw-r--r--WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp1023
-rw-r--r--WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h228
-rw-r--r--WebKit/qt/WebCoreSupport/InspectorClientQt.cpp187
-rw-r--r--WebKit/qt/WebCoreSupport/InspectorClientQt.h74
-rw-r--r--WebKit/qt/WebKitPart/WebKitFactory.cpp114
-rw-r--r--WebKit/qt/WebKitPart/WebKitFactory.h66
-rw-r--r--WebKit/qt/WebKitPart/WebKitPart.cpp133
-rw-r--r--WebKit/qt/WebKitPart/WebKitPart.desktop12
-rw-r--r--WebKit/qt/WebKitPart/WebKitPart.h106
-rw-r--r--WebKit/qt/WebKitPart/WebKitPart.rc16
-rw-r--r--WebKit/qt/WebKitPart/WebKitPartBrowser.rc46
-rw-r--r--WebKit/qt/WebKitPart/WebKitPartBrowserExtension.cpp40
-rw-r--r--WebKit/qt/WebKitPart/WebKitPartBrowserExtension.h84
-rw-r--r--WebKit/qt/WebKitPart/WebKitPartClient.cpp50
-rw-r--r--WebKit/qt/WebKitPart/WebKitPartClient.h48
-rw-r--r--WebKit/qt/WebKitPart/WebKitPartInterface.cpp55
-rw-r--r--WebKit/qt/WebKitPart/WebKitPartInterface.h54
-rw-r--r--WebKit/qt/WebKitPart/org.kde.WebKitPart.xml10
-rw-r--r--WebKit/qt/WebKit_pch.h76
62 files changed, 11834 insertions, 0 deletions
diff --git a/WebKit/qt/Api/headers.pri b/WebKit/qt/Api/headers.pri
new file mode 100644
index 0000000..1e70072
--- /dev/null
+++ b/WebKit/qt/Api/headers.pri
@@ -0,0 +1,11 @@
+WEBKIT_API_HEADERS = $$PWD/qcookiejar.h \
+ $$PWD/qwebframe.h \
+ $$PWD/qwebkitglobal.h \
+ $$PWD/qwebnetworkinterface.h \
+ $$PWD/qwebobjectplugin.h \
+ $$PWD/qwebobjectpluginconnector.h \
+ $$PWD/qwebpage.h \
+ $$PWD/qwebview.h \
+ $$PWD/qwebpagehistory.h \
+ $$PWD/qwebsettings.h \
+ $$PWD/qwebhistoryinterface.h
diff --git a/WebKit/qt/Api/qcookiejar.cpp b/WebKit/qt/Api/qcookiejar.cpp
new file mode 100644
index 0000000..a6cbdab
--- /dev/null
+++ b/WebKit/qt/Api/qcookiejar.cpp
@@ -0,0 +1,105 @@
+/*
+ Copyright (C) 2007 Staikos Computing Services Inc.
+
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+
+#include "qcookiejar.h"
+#include <QCoreApplication>
+uint qHash(const QUrl&);
+#include <QHash>
+#include <QPointer>
+
+class QCookieJarPrivate {
+ public:
+ QCookieJarPrivate() {
+ enabled = true;
+ }
+ bool enabled;
+ QHash<QUrl, QString> jar;
+};
+
+
+uint qHash(const QUrl& url) {
+ return qHash(url.toString());
+}
+
+
+QCookieJar::QCookieJar()
+: QObject(), d(new QCookieJarPrivate)
+{
+}
+
+
+QCookieJar::~QCookieJar()
+{
+ delete d;
+}
+
+
+void QCookieJar::setCookies(const QUrl& url, const QUrl& policyUrl, const QString& value)
+{
+ Q_UNUSED(policyUrl)
+ d->jar.insert(url, value);
+}
+
+
+QString QCookieJar::cookies(const QUrl& url)
+{
+ return d->jar.value(url);
+}
+
+
+bool QCookieJar::isEnabled() const
+{
+ return d->enabled;
+}
+
+
+void QCookieJar::setEnabled(bool enabled)
+{
+ d->enabled = enabled;
+}
+
+
+static QPointer<QCookieJar> gJar;
+static bool gRoutineAdded = false;
+
+static void gCleanupJar()
+{
+ delete gJar;
+}
+
+
+void QCookieJar::setCookieJar(QCookieJar *jar)
+{
+ if (!gRoutineAdded) {
+ qAddPostRoutine(gCleanupJar);
+ gRoutineAdded = true;
+ }
+ delete gJar;
+ gJar = jar;
+}
+
+
+QCookieJar *QCookieJar::cookieJar()
+{
+ if (!gJar) {
+ setCookieJar(new QCookieJar);
+ }
+ return gJar;
+}
diff --git a/WebKit/qt/Api/qcookiejar.h b/WebKit/qt/Api/qcookiejar.h
new file mode 100644
index 0000000..0ca00bd
--- /dev/null
+++ b/WebKit/qt/Api/qcookiejar.h
@@ -0,0 +1,55 @@
+/*
+ Copyright (C) 2007 Staikos Computing Services Inc.
+
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef QCOOKIEJAR_H
+#define QCOOKIEJAR_H
+
+#include <QtCore/qobject.h>
+#include <QtCore/qurl.h>
+#include "qwebkitglobal.h"
+
+class QCookieJarPrivate;
+
+class QWEBKIT_EXPORT QCookieJar : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
+public:
+ QCookieJar();
+ ~QCookieJar();
+
+ virtual void setCookies(const QUrl& url, const QUrl& policyUrl, const QString& value);
+ virtual QString cookies(const QUrl& url);
+
+ bool isEnabled() const;
+
+ static void setCookieJar(QCookieJar *jar);
+ static QCookieJar *cookieJar();
+
+public slots:
+ virtual void setEnabled(bool enabled);
+
+private:
+ friend class QCookieJarPrivate;
+ QCookieJarPrivate *d;
+};
+
+
+#endif
diff --git a/WebKit/qt/Api/qtwebkit.prf b/WebKit/qt/Api/qtwebkit.prf
new file mode 100644
index 0000000..37417c6
--- /dev/null
+++ b/WebKit/qt/Api/qtwebkit.prf
@@ -0,0 +1,4 @@
+
+qtAddLibrary(QtWebKit)
+
+QT += network
diff --git a/WebKit/qt/Api/qwebframe.cpp b/WebKit/qt/Api/qwebframe.cpp
new file mode 100644
index 0000000..155731c
--- /dev/null
+++ b/WebKit/qt/Api/qwebframe.cpp
@@ -0,0 +1,625 @@
+/*
+ Copyright (C) 2007 Trolltech ASA
+ Copyright (C) 2007 Staikos Computing Services Inc.
+
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, 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 "config.h"
+#include "qwebframe.h"
+#include "qwebpage.h"
+#include "qwebpage_p.h"
+#include "qwebframe_p.h"
+
+#include "DocumentLoader.h"
+#include "FocusController.h"
+#include "FrameLoaderClientQt.h"
+#include "Frame.h"
+#include "FrameTree.h"
+#include "FrameView.h"
+#include "IconDatabase.h"
+#include "Page.h"
+#include "ResourceRequest.h"
+#include "SelectionController.h"
+#include "PlatformScrollBar.h"
+#include "SubstituteData.h"
+
+#include "markup.h"
+#include "RenderTreeAsText.h"
+#include "Element.h"
+#include "Document.h"
+#include "DragData.h"
+#include "RenderObject.h"
+#include "GraphicsContext.h"
+#include "PlatformScrollBar.h"
+#include "PlatformMouseEvent.h"
+#include "PlatformWheelEvent.h"
+#include "GraphicsContext.h"
+#include "HitTestResult.h"
+
+#include "bindings/runtime.h"
+#include "bindings/runtime_root.h"
+#include "kjs_proxy.h"
+#include "kjs_window.h"
+#include "kjs_binding.h"
+#include "ExecState.h"
+#include "object.h"
+
+#include "wtf/HashMap.h"
+
+#include <qdebug.h>
+#include <qevent.h>
+#include <qpainter.h>
+#if QT_VERSION >= 0x040400
+#include <qnetworkrequest.h>
+#else
+#include "qwebnetworkinterface.h"
+#endif
+#include <qregion.h>
+
+using namespace WebCore;
+
+void QWebFramePrivate::init(QWebFrame *qframe, WebCore::Page *webcorePage, QWebFrameData *frameData)
+{
+ q = qframe;
+
+ frameLoaderClient = new FrameLoaderClientQt();
+ frame = new Frame(webcorePage, frameData->ownerElement, frameLoaderClient);
+ frameLoaderClient->setFrame(qframe, frame.get());
+
+ frameView = new FrameView(frame.get());
+ frameView->deref();
+ frameView->setQWebFrame(qframe);
+ if (!frameData->allowsScrolling)
+ frameView->setScrollbarsMode(ScrollbarAlwaysOff);
+ if (frameData->marginWidth != -1)
+ frameView->setMarginWidth(frameData->marginWidth);
+ if (frameData->marginHeight != -1)
+ frameView->setMarginHeight(frameData->marginHeight);
+
+ frame->setView(frameView.get());
+ frame->init();
+
+ QObject::connect(q, SIGNAL(hoveringOverLink(const QString&, const QString&, const QString&)),
+ page, SIGNAL(hoveringOverLink(const QString&, const QString&, const QString&)));
+}
+
+WebCore::PlatformScrollbar *QWebFramePrivate::horizontalScrollBar() const
+{
+ Q_ASSERT(frameView);
+ return frameView->horizontalScrollBar();
+}
+
+WebCore::PlatformScrollbar *QWebFramePrivate::verticalScrollBar() const
+{
+ Q_ASSERT(frameView);
+ return frameView->verticalScrollBar();
+}
+
+/*!
+ \class QWebFrame
+ \since 4.4
+ \brief The QWebFrame class represents a frame in a web page.
+
+ QWebFrame represents a frame inside a web page. Each QWebPage
+ object contains at least one frame, the mainFrame(). Additional
+ frames will be created for HTML &lt;frame&gt; or &lt;iframe&gt;
+ elements.
+
+ QWebFrame objects are created and controlled by the web page. You
+ can connect to the web pages frameCreated() signal to find out
+ about creation of new frames.
+
+ \sa QWebPage
+*/
+
+QWebFrame::QWebFrame(QWebPage *parent, QWebFrameData *frameData)
+ : QObject(parent)
+ , d(new QWebFramePrivate)
+{
+ d->page = parent;
+ d->init(this, parent->d->page, frameData);
+
+ if (!frameData->url.isEmpty()) {
+ ResourceRequest request(frameData->url, frameData->referrer);
+ d->frame->loader()->load(request, frameData->name);
+ }
+}
+
+QWebFrame::QWebFrame(QWebFrame *parent, QWebFrameData *frameData)
+ : QObject(parent)
+ , d(new QWebFramePrivate)
+{
+ d->page = parent->d->page;
+ d->init(this, parent->d->page->d->page, frameData);
+}
+
+QWebFrame::~QWebFrame()
+{
+ Q_ASSERT(d->frame == 0);
+ Q_ASSERT(d->frameView == 0);
+ delete d;
+}
+
+/*!
+ Make \a object available under \a name from within the frames
+ JavaScript context. The \a object will be inserted as a child of the
+ frames window object.
+
+ Qt properties will be exposed as JavaScript properties and slots as
+ JavaScript methods.
+*/
+void QWebFrame::addToJSWindowObject(const QString &name, QObject *object)
+{
+ KJS::JSLock lock;
+ KJS::Window *window = KJS::Window::retrieveWindow(d->frame.get());
+ KJS::Bindings::RootObject *root = d->frame->bindingRootObject();
+ if (!window) {
+ qDebug() << "Warning: couldn't get window object";
+ return;
+ }
+
+ KJS::JSObject *runtimeObject =
+ KJS::Bindings::Instance::createRuntimeObject(KJS::Bindings::Instance::QtLanguage,
+ object, root);
+
+ window->put(window->globalExec(), KJS::Identifier((const KJS::UChar *) name.constData(), name.length()), runtimeObject);
+}
+
+/*!
+ returns the markup (HTML) contained in the current frame.
+*/
+QString QWebFrame::markup() const
+{
+ if (!d->frame->document())
+ return QString();
+ return createMarkup(d->frame->document());
+}
+
+/*!
+ returns the content of this frame as plain text.
+*/
+QString QWebFrame::innerText() const
+{
+ if (d->frameView->layoutPending())
+ d->frameView->layout();
+
+ Element *documentElement = d->frame->document()->documentElement();
+ return documentElement->innerText();
+}
+
+/*!
+ returns a dump of the rendering tree. Mainly useful for debugging html.
+*/
+QString QWebFrame::renderTreeDump() const
+{
+ if (d->frameView->layoutPending())
+ d->frameView->layout();
+
+ return externalRepresentation(d->frame->renderer());
+}
+
+/*!
+ The title of the frame as defined by the HTML &lt;title&gt;
+ element.
+*/
+QString QWebFrame::title() const
+{
+ if (d->frame->document())
+ return d->frame->loader()->documentLoader()->title();
+ else return QString();
+}
+
+/*!
+ The url of this frame.
+*/
+QUrl QWebFrame::url() const
+{
+ return d->frame->loader()->url();
+}
+
+/*!
+ The icon associated with this frame.
+*/
+QPixmap QWebFrame::icon() const
+{
+ String url = d->frame->loader()->url().string();
+
+ Image* image = 0;
+ if (!url.isEmpty()) {
+ image = iconDatabase()->iconForPageURL(url, IntSize(16, 16));
+ }
+
+ if (!image || image->isNull()) {
+ image = iconDatabase()->defaultIcon(IntSize(16, 16));
+ }
+
+ if (!image) {
+ return QPixmap();
+ }
+
+ QPixmap *icon = image->getPixmap();
+ if (!icon) {
+ return QPixmap();
+ }
+ return *icon;
+}
+
+/*!
+ The name of this frame as defined by the parent frame.
+*/
+QString QWebFrame::name() const
+{
+ return d->frame->tree()->name();
+}
+
+/*!
+ The web page that contains this frame.
+*/
+QWebPage *QWebFrame::page() const
+{
+ return d->page;
+}
+
+/*!
+ Load \a url into this frame.
+*/
+void QWebFrame::load(const QUrl &url)
+{
+#if QT_VERSION < 0x040400
+ load(QWebNetworkRequest(url));
+#else
+ load(QNetworkRequest(url));
+#endif
+}
+
+#if QT_VERSION < 0x040400
+/*!
+ Load network request \a req into this frame.
+*/
+void QWebFrame::load(const QWebNetworkRequest &req)
+{
+ if (d->parentFrame())
+ d->page->d->insideOpenCall = true;
+
+ QUrl url = req.url();
+ QHttpRequestHeader httpHeader = req.httpHeader();
+ QByteArray postData = req.postData();
+
+ WebCore::ResourceRequest request(url);
+
+ QString method = httpHeader.method();
+ if (!method.isEmpty())
+ request.setHTTPMethod(method);
+
+ QList<QPair<QString, QString> > values = httpHeader.values();
+ for (int i = 0; i < values.size(); ++i) {
+ const QPair<QString, QString> &val = values.at(i);
+ request.addHTTPHeaderField(val.first, val.second);
+ }
+
+ if (!postData.isEmpty())
+ request.setHTTPBody(WebCore::FormData::create(postData.constData(), postData.size()));
+
+ d->frame->loader()->load(request);
+
+ if (d->parentFrame())
+ d->page->d->insideOpenCall = false;
+}
+
+#else
+
+/*!
+ Load network request \a req into this frame. Use the method specified in \a
+ operation. \a body is optional and is only used for POST operations.
+*/
+void QWebFrame::load(const QNetworkRequest &req,
+ QNetworkAccessManager::Operation operation,
+ const QByteArray &body)
+{
+ if (d->parentFrame())
+ d->page->d->insideOpenCall = true;
+
+ QUrl url = req.url();
+
+ WebCore::ResourceRequest request(url);
+
+ switch (operation) {
+ case QNetworkAccessManager::HeadOperation:
+ request.setHTTPMethod("HEAD");
+ break;
+ case QNetworkAccessManager::GetOperation:
+ request.setHTTPMethod("GET");
+ break;
+ case QNetworkAccessManager::PutOperation:
+ request.setHTTPMethod("PUT");
+ break;
+ case QNetworkAccessManager::PostOperation:
+ request.setHTTPMethod("POST");
+ break;
+ case QNetworkAccessManager::UnknownOperation:
+ // eh?
+ break;
+ }
+
+ QList<QByteArray> httpHeaders = req.rawHeaderList();
+ for (int i = 0; i < httpHeaders.size(); ++i) {
+ const QByteArray &headerName = httpHeaders.at(i);
+ request.addHTTPHeaderField(QString::fromLatin1(headerName), QString::fromLatin1(req.rawHeader(headerName)));
+ }
+
+ if (!body.isEmpty())
+ request.setHTTPBody(WebCore::FormData::create(body.constData(), body.size()));
+
+ d->frame->loader()->load(request);
+
+ if (d->parentFrame())
+ d->page->d->insideOpenCall = false;
+}
+#endif
+
+/*!
+ Sets the content of this frame to \a html. \a baseUrl is optional and used to resolve relative
+ URLs in the document.
+*/
+void QWebFrame::setHtml(const QString &html, const QUrl &baseUrl)
+{
+ KURL kurl(baseUrl);
+ WebCore::ResourceRequest request(kurl);
+ WTF::RefPtr<WebCore::SharedBuffer> data = new WebCore::SharedBuffer(reinterpret_cast<const uchar *>(html.unicode()), html.length() * 2);
+ WebCore::SubstituteData substituteData(data, WebCore::String("text/html"), WebCore::String("utf-16"), kurl);
+ d->frame->loader()->load(request, substituteData);
+}
+
+/*!
+ \overload
+*/
+void QWebFrame::setHtml(const QByteArray &html, const QUrl &baseUrl)
+{
+ setContent(html, QString(), baseUrl);
+}
+
+/*!
+ Sets the content of this frame to \a data assuming \a mimeType. If
+ \a mimeType is not specified it defaults to 'text/html'. \a baseUrl
+ us optional and used to resolve relative URLs in the document.
+*/
+void QWebFrame::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
+{
+ KURL kurl(baseUrl);
+ WebCore::ResourceRequest request(kurl);
+ WTF::RefPtr<WebCore::SharedBuffer> buffer = new WebCore::SharedBuffer(data.constData(), data.length());
+ QString actualMimeType = mimeType;
+ if (actualMimeType.isEmpty())
+ actualMimeType = QLatin1String("text/html");
+ WebCore::SubstituteData substituteData(buffer, WebCore::String(actualMimeType), WebCore::String(), kurl);
+ d->frame->loader()->load(request, substituteData);
+}
+
+
+/*!
+ Returns the parent frame of this frame, or 0 if the frame is the web pages
+ main frame.
+
+ This is equivalent to qobject_cast<QWebFrame*>(frame->parent()).
+*/
+QWebFrame *QWebFrame::parentFrame() const
+{
+ return d->parentFrame();
+}
+
+/*!
+ Returns a list of all frames that are direct children of this frame.
+*/
+QList<QWebFrame*> QWebFrame::childFrames() const
+{
+ QList<QWebFrame*> rc;
+ if (d->frame) {
+ FrameTree *tree = d->frame->tree();
+ for (Frame *child = tree->firstChild(); child; child = child->tree()->nextSibling()) {
+ FrameLoader *loader = child->loader();
+ FrameLoaderClientQt *client = static_cast<FrameLoaderClientQt*>(loader->client());
+ if (client)
+ rc.append(client->webFrame());
+ }
+
+ }
+ return rc;
+}
+
+/*!
+ \property QWebFrame::verticalScrollBarPolicy
+
+ This property defines the vertical scrollbar policy.
+
+ \sa Qt::ScrollBarPolicy
+*/
+Qt::ScrollBarPolicy QWebFrame::verticalScrollBarPolicy() const
+{
+ return (Qt::ScrollBarPolicy) d->frameView->vScrollbarMode();
+}
+
+void QWebFrame::setVerticalScrollBarPolicy(Qt::ScrollBarPolicy policy)
+{
+ Q_ASSERT((int)ScrollbarAuto == (int)Qt::ScrollBarAsNeeded);
+ Q_ASSERT((int)ScrollbarAlwaysOff == (int)Qt::ScrollBarAlwaysOff);
+ Q_ASSERT((int)ScrollbarAlwaysOn == (int)Qt::ScrollBarAlwaysOn);
+ d->frameView->setVScrollbarMode((ScrollbarMode)policy);
+}
+
+/*!
+ \property QWebFrame::horizontalScrollBarPolicy
+
+ This property defines the horizontal scrollbar policy.
+
+ \sa Qt::ScrollBarPolicy
+*/
+Qt::ScrollBarPolicy QWebFrame::horizontalScrollBarPolicy() const
+{
+ return (Qt::ScrollBarPolicy) d->frameView->hScrollbarMode();
+}
+
+void QWebFrame::setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy policy)
+{
+ d->frameView->setHScrollbarMode((ScrollbarMode)policy);
+}
+
+/*!
+ Render the frame into \a painter clipping to \a clip.
+*/
+void QWebFrame::render(QPainter *painter, const QRegion &clip)
+{
+ if (!d->frameView || !d->frame->renderer())
+ return;
+
+ layout();
+
+ GraphicsContext ctx(painter);
+ QVector<QRect> vector = clip.rects();
+ for (int i = 0; i < vector.size(); ++i)
+ d->frameView->paint(&ctx, vector.at(i));
+}
+
+/*!
+ Ensure that the content of the frame and all subframes are correctly layouted.
+*/
+void QWebFrame::layout()
+{
+ if (!d->frameView)
+ return;
+
+ d->frameView->layoutIfNeededRecursive();
+}
+
+/*!
+ returns the position of the frame relative to it's parent frame.
+*/
+QPoint QWebFrame::pos() const
+{
+ Q_ASSERT(d->frameView);
+ return d->pos();
+}
+
+/*!
+ return the geometry of the frame relative to it's parent frame.
+*/
+QRect QWebFrame::geometry() const
+{
+ Q_ASSERT(d->frameView);
+ return d->frameView->frameGeometry();
+}
+
+/*!
+ Evaluate JavaScript defined by \a scriptSource using this frame as context.
+*/
+QString QWebFrame::evaluateJavaScript(const QString& scriptSource)
+{
+ KJSProxy *proxy = d->frame->scriptProxy();
+ QString rc;
+ if (proxy) {
+ KJS::JSValue *v = proxy->evaluate(String(), 0, scriptSource);
+ if (v) {
+ rc = String(v->toString(proxy->globalObject()->globalExec()));
+ }
+ }
+ return rc;
+}
+
+WebCore::Frame* QWebFramePrivate::core(QWebFrame* webFrame)
+{
+ return webFrame->d->frame.get();
+}
+
+QWebFrame* QWebFramePrivate::kit(WebCore::Frame* coreFrame)
+{
+ return static_cast<FrameLoaderClientQt*>(coreFrame->loader()->client())->webFrame();
+}
+
+
+/*!
+ \fn void QWebFrame::cleared()
+
+ This signal is emitted whenever the content of the frame is cleared
+ (e.g. before starting a new load).
+*/
+
+/*!
+ \fn void QWebFrame::loadDone(bool ok)
+
+ This signal is emitted when the frame is completely loaded. \a ok will indicate whether the load
+ was successful or any error occurred.
+*/
+
+/*!
+ \fn void QWebFrame::provisionalLoad()
+
+ \internal
+*/
+
+/*!
+ \fn void QWebFrame::titleChanged(const QString &title)
+
+ This signal is emitted whenever the title of the frame changes.
+ The \a title string specifies the new title.
+
+ \sa title()
+*/
+
+/*!
+ \fn void QWebFrame::urlChanged(const QUrl &url)
+
+ This signal is emitted whenever the \a url of the frame changes.
+
+ \sa url()
+*/
+
+/*!
+ \fn void QWebFrame::hoveringOverLink(const QString &link, const QString &title, const QString &textContent)
+
+ This signal is emitted whenever the mouse cursor is hovering over a
+ link. It can be used to display information about the link in
+ e.g. the status bar. The signal arguments consist of the \a link destination, the \a title and the
+ link text as \a textContent .
+*/
+
+
+/*!
+ \fn void QWebFrame::loadStarted()
+
+ This signal is emitted when a new load of the frame is started.
+*/
+
+/*!
+ \fn void QWebFrame::loadFinished()
+
+ This signal is emitted when a load of the frame is finished.
+*/
+
+/*!
+ \fn void QWebFrame::initialLayoutComplete()
+
+ This signal is emitted when the first (initial) layout of the frame
+ has happened. This is the earliest time something can be shown on
+ the screen.
+*/
+
+/*!
+ \fn void QWebFrame::iconLoaded()
+
+ This signal is emitted when the icon ("favicon") associated with the frame has been loaded.
+*/
diff --git a/WebKit/qt/Api/qwebframe.h b/WebKit/qt/Api/qwebframe.h
new file mode 100644
index 0000000..a1cdb25
--- /dev/null
+++ b/WebKit/qt/Api/qwebframe.h
@@ -0,0 +1,138 @@
+/*
+ Copyright (C) 2007 Trolltech ASA
+ Copyright (C) 2007 Staikos Computing Services Inc.
+
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, 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 <QtCore/qobject.h>
+#include <QtCore/qurl.h>
+#if QT_VERSION >= 0x040400
+#include <QtNetwork/qnetworkaccessmanager.h>
+#endif
+#include "qwebkitglobal.h"
+
+class QRect;
+class QPoint;
+class QPainter;
+class QPixmap;
+class QMouseEvent;
+class QWheelEvent;
+class QWebNetworkRequest;
+class QNetworkRequest;
+
+class QWebFramePrivate;
+class QWebPage;
+class QRegion;
+
+namespace WebCore {
+ class WidgetPrivate;
+ class FrameLoaderClientQt;
+ class ChromeClientQt;
+}
+class QWebFrameData;
+
+class QWEBKIT_EXPORT QWebFrame : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(Qt::ScrollBarPolicy verticalScrollBarPolicy READ verticalScrollBarPolicy WRITE setVerticalScrollBarPolicy)
+ Q_PROPERTY(Qt::ScrollBarPolicy horizontalScrollBarPolicy READ horizontalScrollBarPolicy WRITE setHorizontalScrollBarPolicy)
+private:
+ QWebFrame(QWebPage *parent, QWebFrameData *frameData);
+ QWebFrame(QWebFrame *parent, QWebFrameData *frameData);
+ ~QWebFrame();
+
+public:
+ QWebPage *page() const;
+
+ void load(const QUrl &url);
+#if QT_VERSION < 0x040400
+ void load(const QWebNetworkRequest &request);
+#else
+ void load(const QNetworkRequest &request,
+ QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation,
+ const QByteArray &body = QByteArray());
+#endif
+ void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
+ void setHtml(const QByteArray &html, const QUrl &baseUrl = QUrl());
+ void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl());
+
+ void addToJSWindowObject(const QString &name, QObject *object);
+ QString markup() const;
+ QString innerText() const;
+ QString renderTreeDump() const;
+
+ QString title() const;
+ QUrl url() const;
+ QPixmap icon() const;
+
+ QString name() const;
+
+ QWebFrame *parentFrame() const;
+ QList<QWebFrame*> childFrames() const;
+
+ Qt::ScrollBarPolicy verticalScrollBarPolicy() const;
+ void setVerticalScrollBarPolicy(Qt::ScrollBarPolicy);
+ Qt::ScrollBarPolicy horizontalScrollBarPolicy() const;
+ void setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy);
+
+ void render(QPainter *painter, const QRegion &clip);
+ void layout();
+
+ QPoint pos() const;
+ QRect geometry() const;
+
+public Q_SLOTS:
+ QString evaluateJavaScript(const QString& scriptSource);
+
+Q_SIGNALS:
+ void cleared();
+ void loadDone(bool ok);
+ void provisionalLoad();
+ void titleChanged(const QString &title);
+ void hoveringOverLink(const QString &link, const QString &title, const QString &textContent);
+ void urlChanged(const QUrl &url);
+
+ void loadStarted();
+ void loadFinished();
+
+ /**
+ * Signal is emitted when the mainframe()'s initial layout is completed.
+ */
+ void initialLayoutComplete();
+
+ /**
+ * Signal is emitted when an icon ("favicon") is loaded from the site.
+ */
+ void iconLoaded();
+
+private:
+ friend class QWebPage;
+ friend class QWebPagePrivate;
+ friend class QWebFramePrivate;
+ friend class WebCore::WidgetPrivate;
+ friend class WebCore::FrameLoaderClientQt;
+ friend class WebCore::ChromeClientQt;
+ QWebFramePrivate *d;
+};
+
+#endif
diff --git a/WebKit/qt/Api/qwebframe_p.h b/WebKit/qt/Api/qwebframe_p.h
new file mode 100644
index 0000000..136cf78
--- /dev/null
+++ b/WebKit/qt/Api/qwebframe_p.h
@@ -0,0 +1,90 @@
+/*
+ Copyright (C) 2007 Trolltech ASA
+ Copyright (C) 2007 Staikos Computing Services Inc.
+
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, 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"
+
+#include "EventHandler.h"
+#include "FrameView.h"
+#include "KURL.h"
+#include "PlatformString.h"
+#include "wtf/RefPtr.h"
+
+namespace WebCore
+{
+ class FrameLoaderClientQt;
+ class Frame;
+ class FrameView;
+ class HTMLFrameOwnerElement;
+ class PlatformScrollbar;
+}
+class QWebPage;
+
+
+class QWebFrameData
+{
+public:
+ WebCore::KURL url;
+ WebCore::String name;
+ WebCore::HTMLFrameOwnerElement* ownerElement;
+
+ WebCore::String referrer;
+ bool allowsScrolling;
+ int marginWidth;
+ int marginHeight;
+};
+
+class QWebFramePrivate
+{
+public:
+ QWebFramePrivate()
+ : q(0)
+ , frameLoaderClient(0)
+ , frame(0)
+ , frameView(0)
+ , page(0)
+ {}
+ void init(QWebFrame *qframe, WebCore::Page *page,
+ QWebFrameData *frameData);
+
+ inline QWebFrame *parentFrame() { return qobject_cast<QWebFrame*>(q->parent()); }
+
+ WebCore::PlatformScrollbar *horizontalScrollBar() const;
+ WebCore::PlatformScrollbar *verticalScrollBar() const;
+
+ inline QPoint pos() const
+ { return frameView->frameGeometry().topLeft(); }
+
+ static WebCore::Frame* core(QWebFrame*);
+ static QWebFrame* kit(WebCore::Frame*);
+
+ QWebFrame *q;
+ WebCore::FrameLoaderClientQt *frameLoaderClient;
+ WTF::RefPtr<WebCore::Frame> frame;
+ WTF::RefPtr<WebCore::FrameView> frameView;
+ QWebPage *page;
+};
+
+#endif
diff --git a/WebKit/qt/Api/qwebhistory.cpp b/WebKit/qt/Api/qwebhistory.cpp
new file mode 100644
index 0000000..10127a4
--- /dev/null
+++ b/WebKit/qt/Api/qwebhistory.cpp
@@ -0,0 +1,281 @@
+/*
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, 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 "qwebhistory.h"
+#include "qwebhistory_p.h"
+
+#include "PlatformString.h"
+#include "Image.h"
+
+#include <QSharedData>
+
+/*!
+ \class QWebHistoryItem
+ \since 4.4
+ \brief The QWebHistoryItem class represents one item in the history of a QWebPage
+
+ QWebHistoryItem represents on entry in the history stack of a web page.
+
+ \sa QWebPage::history() QWebHistory
+
+ QWebHistoryItem objects are value based and explicitly shared.
+*/
+
+/*!
+ Constructs a history item from \a other.
+*/
+QWebHistoryItem::QWebHistoryItem(const QWebHistoryItem &other)
+ : d(other.d)
+{
+}
+
+/*!
+ Assigns the \a other history item to this.
+*/
+QWebHistoryItem &QWebHistoryItem::operator=(const QWebHistoryItem &other)
+{
+ d = other.d;
+ return *this;
+}
+
+/*!
+ Destructs a history item.
+*/
+QWebHistoryItem::~QWebHistoryItem()
+{
+}
+
+/*!
+ The original url associated with the history item.
+*/
+QUrl QWebHistoryItem::originalUrl() const
+{
+ return QUrl(d->item->originalURL().string());
+}
+
+
+/*!
+ The current url associated with the history item.
+*/
+QUrl QWebHistoryItem::currentUrl() const
+{
+ return QUrl(d->item->url().string());
+}
+
+
+/*!
+ The title of the page associated with the history item.
+*/
+QString QWebHistoryItem::title() const
+{
+ return d->item->title();
+}
+
+
+/*!
+ The time when the apge associated with the item was last visited.
+*/
+QDateTime QWebHistoryItem::lastVisited() const
+{
+ //FIXME : this will be wrong unless we correctly set lastVisitedTime ourselves
+ return QDateTime::fromTime_t((uint)d->item->lastVisitedTime());
+}
+
+
+/*!
+ The icon associated with the history item.
+*/
+QPixmap QWebHistoryItem::icon() const
+{
+ return *d->item->icon()->getPixmap();
+}
+
+/*!
+ \internal
+*/
+QWebHistoryItem::QWebHistoryItem(QWebHistoryItemPrivate *priv)
+{
+ d = priv;
+}
+
+/*!
+ \class QWebHistory
+ \since 4.4
+ \brief The QWebHistory class represents the history of a QWebPage
+
+ Each QWebPage contains a history of visited pages that can be accessed by QWebPage::history().
+ QWebHistory represents this history and makes it possible to navigate it.
+*/
+
+
+QWebHistory::QWebHistory()
+ : d(0)
+{
+}
+
+QWebHistory::~QWebHistory()
+{
+ delete d;
+}
+
+/*!
+ Clears the history.
+*/
+void QWebHistory::clear()
+{
+ RefPtr<WebCore::HistoryItem> current = d->lst->currentItem();
+ int capacity = d->lst->capacity();
+ d->lst->setCapacity(0);
+ d->lst->setCapacity(capacity);
+ d->lst->addItem(current.get());
+ d->lst->goToItem(current.get());
+}
+
+/*!
+ returns a list of all items currently in the history.
+*/
+QList<QWebHistoryItem> QWebHistory::items() const
+{
+ const WebCore::HistoryItemVector &items = d->lst->entries();
+
+ QList<QWebHistoryItem> ret;
+ for (int i = 0; i < items.size(); ++i) {
+ QWebHistoryItemPrivate *priv = new QWebHistoryItemPrivate(items[i].get());
+ ret.append(QWebHistoryItem(priv));
+ }
+ return ret;
+}
+
+/*!
+ Returns the list of items that are in the backwards history.
+ At most \a maxItems entries are returned.
+*/
+QList<QWebHistoryItem> QWebHistory::backItems(int maxItems) const
+{
+ WebCore::HistoryItemVector items(maxItems);
+ d->lst->backListWithLimit(maxItems, items);
+
+ QList<QWebHistoryItem> ret;
+ for (int i = 0; i < items.size(); ++i) {
+ QWebHistoryItemPrivate *priv = new QWebHistoryItemPrivate(items[i].get());
+ ret.append(QWebHistoryItem(priv));
+ }
+ return ret;
+}
+
+/*!
+ Returns the list of items that are in the forward history.
+ At most \a maxItems entries are returned.
+*/
+QList<QWebHistoryItem> QWebHistory::forwardItems(int maxItems) const
+{
+ WebCore::HistoryItemVector items(maxItems);
+ d->lst->forwardListWithLimit(maxItems, items);
+
+ QList<QWebHistoryItem> ret;
+ for (int i = 0; i < items.size(); ++i) {
+ QWebHistoryItemPrivate *priv = new QWebHistoryItemPrivate(items[i].get());
+ ret.append(QWebHistoryItem(priv));
+ }
+ return ret;
+}
+
+/*!
+ returns true if we have an item to go back to.
+*/
+bool QWebHistory::canGoBack() const
+{
+ return d->lst->backListCount() > 0;
+}
+
+/*!
+ returns true if we have an item to go forward to.
+*/
+bool QWebHistory::canGoForward() const
+{
+ return d->lst->forwardListCount() > 0;
+}
+
+/*!
+ goes back one history item.
+*/
+void QWebHistory::goBack()
+{
+ d->lst->goBack();
+}
+
+/*!
+ goes forward one history item.
+*/
+void QWebHistory::goForward()
+{
+ d->lst->goBack();
+}
+
+/*!
+ goes to item \a item in the history.
+*/
+void QWebHistory::goToItem(const QWebHistoryItem &item)
+{
+ d->lst->goToItem(item.d->item);
+}
+
+/*!
+ returns the item before the current item.
+*/
+QWebHistoryItem QWebHistory::backItem() const
+{
+ WebCore::HistoryItem *i = d->lst->backItem();
+ QWebHistoryItemPrivate *priv = new QWebHistoryItemPrivate(i);
+ return QWebHistoryItem(priv);
+}
+
+/*!
+ returns the current item.
+*/
+QWebHistoryItem QWebHistory::currentItem() const
+{
+ WebCore::HistoryItem *i = d->lst->currentItem();
+ QWebHistoryItemPrivate *priv = new QWebHistoryItemPrivate(i);
+ return QWebHistoryItem(priv);
+}
+
+/*!
+ returns the item after the current item.
+*/
+QWebHistoryItem QWebHistory::forwardItem() const
+{
+ WebCore::HistoryItem *i = d->lst->forwardItem();
+ QWebHistoryItemPrivate *priv = new QWebHistoryItemPrivate(i);
+ return QWebHistoryItem(priv);
+}
+
+/*!
+ returns the item at index \a i.
+*/
+QWebHistoryItem QWebHistory::itemAtIndex(int i) const
+{
+ WebCore::HistoryItem *item = d->lst->itemAtIndex(i);
+
+ QWebHistoryItemPrivate *priv = new QWebHistoryItemPrivate(item);
+ return QWebHistoryItem(priv);
+}
+
diff --git a/WebKit/qt/Api/qwebhistory.h b/WebKit/qt/Api/qwebhistory.h
new file mode 100644
index 0000000..6c8a4f4
--- /dev/null
+++ b/WebKit/qt/Api/qwebhistory.h
@@ -0,0 +1,92 @@
+/*
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, 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 QWEBHISTORY_H
+#define QWEBHISTORY_H
+
+#include <QtCore/qurl.h>
+#include <QtCore/qstring.h>
+#include <QtGui/qicon.h>
+#include <QtCore/qdatetime.h>
+#include <QtCore/qshareddata.h>
+
+#include "qwebkitglobal.h"
+
+class QWebPage;
+
+class QWebHistoryItemPrivate;
+class QWEBKIT_EXPORT QWebHistoryItem
+{
+public:
+ QWebHistoryItem(const QWebHistoryItem &other);
+ QWebHistoryItem &operator=(const QWebHistoryItem &other);
+ ~QWebHistoryItem();
+
+ QUrl originalUrl() const;
+ QUrl currentUrl() const;
+
+ QString title() const;
+ QDateTime lastVisited() const;
+
+ QPixmap icon() const;
+
+private:
+ QWebHistoryItem(QWebHistoryItemPrivate *priv);
+ friend class QWebHistory;
+ friend class QWebPage;
+ QExplicitlySharedDataPointer<QWebHistoryItemPrivate> d;
+};
+
+class QWebHistoryPrivate;
+class QWEBKIT_EXPORT QWebHistory
+{
+public:
+ void clear();
+
+ QList<QWebHistoryItem> items() const;
+ QList<QWebHistoryItem> backItems(int maxItems) const;
+ QList<QWebHistoryItem> forwardItems(int maxItems) const;
+
+ bool canGoBack() const;
+ bool canGoForward() const;
+
+ void goBack();
+ void goForward();
+ void goToItem(const QWebHistoryItem &item);
+
+ QWebHistoryItem backItem() const;
+ QWebHistoryItem currentItem() const;
+ QWebHistoryItem forwardItem() const;
+ QWebHistoryItem itemAtIndex(int i) const;
+
+private:
+ QWebHistory();
+ ~QWebHistory();
+
+ friend class QWebPage;
+ friend class QWebPagePrivate;
+
+ Q_DISABLE_COPY(QWebHistory)
+
+ QWebHistoryPrivate *d;
+};
+
+#endif
diff --git a/WebKit/qt/Api/qwebhistory_p.h b/WebKit/qt/Api/qwebhistory_p.h
new file mode 100644
index 0000000..5b56667
--- /dev/null
+++ b/WebKit/qt/Api/qwebhistory_p.h
@@ -0,0 +1,39 @@
+#ifndef QWEBHISTORY_P_H
+#define QWEBHISTORY_P_H
+
+#include "BackForwardList.h"
+#include "HistoryItem.h"
+
+class QWebHistoryItemPrivate : public QSharedData
+{
+public:
+ QWebHistoryItemPrivate(WebCore::HistoryItem *i)
+ {
+ i->ref();
+ item = i;
+ }
+ ~QWebHistoryItemPrivate()
+ {
+ item->deref();
+ }
+
+ WebCore::HistoryItem *item;
+};
+
+class QWebHistoryPrivate : public QSharedData
+{
+public:
+ QWebHistoryPrivate(WebCore::BackForwardList *l)
+ {
+ l->ref();
+ lst = l;
+ }
+ ~QWebHistoryPrivate()
+ {
+ lst->deref();
+ }
+ WebCore::BackForwardList *lst;
+};
+
+
+#endif
diff --git a/WebKit/qt/Api/qwebhistoryinterface.cpp b/WebKit/qt/Api/qwebhistoryinterface.cpp
new file mode 100644
index 0000000..8890350
--- /dev/null
+++ b/WebKit/qt/Api/qwebhistoryinterface.cpp
@@ -0,0 +1,110 @@
+/*
+ Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net>
+
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ This class provides all functionality needed for tracking global history.
+*/
+
+#include "qwebhistoryinterface.h"
+
+#include <QCoreApplication>
+
+#include "PlatformString.h"
+#include <wtf/Platform.h>
+
+// FIXME: It's not correct to just implement a WebCore function in WebKit!
+// This needs to be fixed to match other platforms.
+
+namespace WebCore {
+
+bool historyContains(const UChar* characters, unsigned length)
+{
+ if (!QWebHistoryInterface::defaultInterface())
+ return false;
+
+ return QWebHistoryInterface::defaultInterface()->historyContains(QString(reinterpret_cast<const QChar*>(characters), length));
+}
+
+} // namespace WebCore
+
+static QWebHistoryInterface *default_interface;
+
+static bool gRoutineAdded;
+
+static void gCleanupInterface()
+{
+ delete default_interface;
+ default_interface = 0;
+}
+
+/*!
+ Sets a new default interface that will be used by all of WebKit
+ for managing history.
+*/
+void QWebHistoryInterface::setDefaultInterface(QWebHistoryInterface *defaultInterface)
+{
+ if (default_interface == defaultInterface)
+ return;
+ if (default_interface)
+ delete default_interface;
+ default_interface = defaultInterface;
+ if (!gRoutineAdded) {
+ qAddPostRoutine(gCleanupInterface);
+ gRoutineAdded = true;
+ }
+}
+
+/*!
+ Returns the default interface that will be used by WebKit. If no
+ default interface has been set, QtWebkit will not track history.
+*/
+QWebHistoryInterface *QWebHistoryInterface::defaultInterface()
+{
+ return default_interface;
+}
+
+/*!
+ \class QWebHistoryInterface
+ \since 4.4
+ \brief The QWebHistoryInterface class provides an interface to implement link history.
+
+ The QWebHistoryInterface is an interface that can be used to
+ implement link history. It contains two pure virtual methods that
+ are called by the WebKit engine. addHistoryEntry() is used to add
+ pages that have been visited to the interface, while
+ historyContains() is used to query whether this page has been
+ visited by the user.
+*/
+QWebHistoryInterface::QWebHistoryInterface(QObject *parent) : QObject(parent)
+{
+}
+
+QWebHistoryInterface::~QWebHistoryInterface()
+{
+}
+
+/*!
+ \fn bool QWebHistoryInterface::historyContains(const QString &url) const
+
+ Called by the WebKit engine to query whether a certain url has been visited by the user already.
+*/
+
+/*!
+ \fn void QWebHistoryInterface::addHistoryEntry(const QString &url) const
+
+ Called by WebKit to add another url to the list of visited pages.
+*/
diff --git a/WebKit/qt/Api/qwebhistoryinterface.h b/WebKit/qt/Api/qwebhistoryinterface.h
new file mode 100644
index 0000000..87dc88c
--- /dev/null
+++ b/WebKit/qt/Api/qwebhistoryinterface.h
@@ -0,0 +1,43 @@
+/*
+ Copyright (C) 2007 Staikos Computing Services, Inc. <info@staikos.net>
+
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ This class provides all functionality needed for tracking global history.
+*/
+
+#ifndef QWEBHISTORYINTERFACE_H
+#define QWEBHISTORYINTERFACE_H
+
+#include <QtCore/qobject.h>
+
+#include "qwebkitglobal.h"
+
+class QWEBKIT_EXPORT QWebHistoryInterface : public QObject
+{
+ Q_OBJECT
+public:
+ QWebHistoryInterface(QObject *parent = 0);
+ ~QWebHistoryInterface();
+
+ static void setDefaultInterface(QWebHistoryInterface *defaultInterface);
+ static QWebHistoryInterface *defaultInterface();
+
+ virtual bool historyContains(const QString &url) const = 0;
+ virtual void addHistoryEntry(const QString &url) = 0;
+};
+
+#endif
diff --git a/WebKit/qt/Api/qwebkitglobal.h b/WebKit/qt/Api/qwebkitglobal.h
new file mode 100644
index 0000000..25fe0f9
--- /dev/null
+++ b/WebKit/qt/Api/qwebkitglobal.h
@@ -0,0 +1,39 @@
+/*
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, 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 QWEBKITGLOBAL_H
+#define QWEBKITGLOBAL_H
+
+#include <qglobal.h>
+
+#if defined(Q_OS_WIN)
+# if defined(BUILD_WEBKIT)
+# define QWEBKIT_EXPORT Q_DECL_EXPORT
+# else
+# define QWEBKIT_EXPORT Q_DECL_IMPORT
+# endif
+#endif
+
+#if !defined(QWEBKIT_EXPORT)
+#define QWEBKIT_EXPORT Q_DECL_EXPORT
+#endif
+
+#endif // QWEBKITGLOBAL_H
diff --git a/WebKit/qt/Api/qwebnetworkinterface.cpp b/WebKit/qt/Api/qwebnetworkinterface.cpp
new file mode 100644
index 0000000..fd0c694
--- /dev/null
+++ b/WebKit/qt/Api/qwebnetworkinterface.cpp
@@ -0,0 +1,1265 @@
+/*
+ Copyright (C) 2006 Enrico Ros <enrico.ros@m31engineering.it>
+ Copyright (C) 2007 Trolltech ASA
+ Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net>
+
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, 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 <qglobal.h>
+#if QT_VERSION < 0x040400
+#include "qwebframe.h"
+#include "qwebnetworkinterface.h"
+#include "qwebnetworkinterface_p.h"
+#include "qwebobjectpluginconnector.h"
+#include "qwebpage.h"
+#include "qcookiejar.h"
+#include <qdebug.h>
+#include <qfile.h>
+#include <qnetworkproxy.h>
+#include <qurl.h>
+#include <QAuthenticator>
+#include <QCoreApplication>
+#include <QSslError>
+
+#include "ResourceHandle.h"
+#include "ResourceHandleClient.h"
+#include "ResourceHandleInternal.h"
+#include "MIMETypeRegistry.h"
+#include "CookieJar.h"
+
+#if 0
+#define DEBUG qDebug
+#else
+#define DEBUG if (1) {} else qDebug
+#endif
+
+static QWebNetworkInterface *s_default_interface = 0;
+static QWebNetworkManager *s_manager = 0;
+
+using namespace WebCore;
+
+uint qHash(const HostInfo &info)
+{
+ return qHash(info.host) + info.port;
+}
+
+static bool operator==(const HostInfo &i1, const HostInfo &i2)
+{
+ return i1.port == i2.port && i1.host == i2.host;
+}
+
+enum ParserState {
+ State_Begin,
+ State_FirstChar,
+ State_SecondChar
+};
+
+/*
+ * Decode URLs without doing any charset conversion.
+ *
+ * Most simple approach to do it without any lookahead.
+ */
+static QByteArray decodePercentEncoding(const QByteArray& input)
+{
+ int actualLength = 0;
+ QByteArray tmpVal;
+ QByteArray output;
+ ParserState state = State_Begin;
+
+ output.resize(input.length());
+ tmpVal.resize(2);
+
+ for (int i = 0; i < input.length(); ++i)
+ if (state == State_Begin) {
+ if (input.at(i) == '%') {
+ state = State_FirstChar;
+ } else {
+ output[actualLength++] = input[i];
+ }
+ } else if (state == State_FirstChar) {
+ state = State_SecondChar;
+ tmpVal[0] = input[i];
+ } else if (state == State_SecondChar) {
+ state = State_Begin;
+ tmpVal[1] = input[i];
+ output[actualLength++] = tmpVal.toShort(0, 16);
+ }
+
+ output.resize(actualLength);
+ return output;
+}
+
+void QWebNetworkRequestPrivate::init(const WebCore::ResourceRequest &resourceRequest)
+{
+ KURL url = resourceRequest.url();
+ QUrl qurl = QString(url.string());
+ init(resourceRequest.httpMethod(), qurl, &resourceRequest);
+}
+
+void QWebNetworkRequestPrivate::init(const QString &method, const QUrl &url, const WebCore::ResourceRequest *resourceRequest)
+{
+ httpHeader = QHttpRequestHeader(method, url.toString(QUrl::RemoveScheme|QUrl::RemoveAuthority));
+ httpHeader.setValue(QLatin1String("Connection"), QLatin1String("Keep-Alive"));
+ setURL(url);
+
+ if (resourceRequest) {
+ httpHeader.setValue(QLatin1String("User-Agent"), resourceRequest->httpUserAgent());
+ const QString scheme = url.scheme().toLower();
+ if (scheme == QLatin1String("http") || scheme == QLatin1String("https")) {
+ QString cookies = QCookieJar::cookieJar()->cookies(resourceRequest->url());
+ if (!cookies.isEmpty())
+ httpHeader.setValue(QLatin1String("Cookie"), cookies);
+ }
+
+
+ const HTTPHeaderMap& loaderHeaders = resourceRequest->httpHeaderFields();
+ HTTPHeaderMap::const_iterator end = loaderHeaders.end();
+ for (HTTPHeaderMap::const_iterator it = loaderHeaders.begin(); it != end; ++it)
+ httpHeader.setValue(it->first, it->second);
+
+ // handle and perform a 'POST' request
+ if (method == "POST") {
+ Vector<char> data;
+ resourceRequest->httpBody()->flatten(data);
+ postData = QByteArray(data.data(), data.size());
+ httpHeader.setValue(QLatin1String("content-length"), QString::number(postData.size()));
+ }
+ }
+}
+
+void QWebNetworkRequestPrivate::setURL(const QUrl &u)
+{
+ url = u;
+ int port = url.port();
+ const QString scheme = u.scheme();
+ if (port > 0 && (port != 80 || scheme != "http") && (port != 443 || scheme != "https"))
+ httpHeader.setValue(QLatin1String("Host"), url.host() + QLatin1Char(':') + QString::number(port));
+ else
+ httpHeader.setValue(QLatin1String("Host"), url.host());
+}
+
+/*!
+ \class QWebNetworkRequest
+
+ The QWebNetworkRequest class represents a request for data from the network with all the
+ necessary information needed for retrieval. This includes the url, extra HTTP header fields
+ as well as data for a HTTP POST request.
+*/
+
+QWebNetworkRequest::QWebNetworkRequest()
+ : d(new QWebNetworkRequestPrivate)
+{
+}
+
+QWebNetworkRequest::QWebNetworkRequest(const QUrl &url, Method method, const QByteArray &postData)
+ : d(new QWebNetworkRequestPrivate)
+{
+ d->init(method == Get ? "GET" : "POST", url);
+ d->postData = postData;
+}
+
+QWebNetworkRequest::QWebNetworkRequest(const QWebNetworkRequest &other)
+ : d(new QWebNetworkRequestPrivate(*other.d))
+{
+}
+
+QWebNetworkRequest &QWebNetworkRequest::operator=(const QWebNetworkRequest &other)
+{
+ *d = *other.d;
+ return *this;
+}
+
+/*!
+ \internal
+*/
+QWebNetworkRequest::QWebNetworkRequest(const QWebNetworkRequestPrivate &priv)
+ : d(new QWebNetworkRequestPrivate(priv))
+{
+}
+
+/*!
+ \internal
+*/
+QWebNetworkRequest::QWebNetworkRequest(const WebCore::ResourceRequest &request)
+ : d(new QWebNetworkRequestPrivate)
+{
+ d->init(request);
+}
+
+QWebNetworkRequest::~QWebNetworkRequest()
+{
+ delete d;
+}
+
+/*!
+ The requested URL
+*/
+QUrl QWebNetworkRequest::url() const
+{
+ return d->url;
+}
+
+/*!
+ Sets the URL to request.
+
+ Note that setting the URL also sets the "Host" field in the HTTP header.
+*/
+void QWebNetworkRequest::setUrl(const QUrl &url)
+{
+ d->setURL(url);
+}
+
+/*!
+ The http request header information.
+*/
+QHttpRequestHeader QWebNetworkRequest::httpHeader() const
+{
+ return d->httpHeader;
+}
+
+void QWebNetworkRequest::setHttpHeader(const QHttpRequestHeader &header) const
+{
+ d->httpHeader = header;
+}
+
+QString QWebNetworkRequest::httpHeaderField(const QString &key) const
+{
+ return d->httpHeader.value(key);
+}
+
+void QWebNetworkRequest::setHttpHeaderField(const QString &key, const QString &value)
+{
+ d->httpHeader.setValue(key, value);
+}
+
+/*!
+ Post data sent with HTTP POST requests.
+*/
+QByteArray QWebNetworkRequest::postData() const
+{
+ return d->postData;
+}
+
+void QWebNetworkRequest::setPostData(const QByteArray &data)
+{
+ d->postData = data;
+}
+
+/*!
+ \class QWebNetworkJob
+
+ The QWebNetworkJob class represents a network job, that needs to be
+ processed by the QWebNetworkInterface.
+
+ This class is only required when implementing a new network layer (or
+ support for a special protocol) using QWebNetworkInterface.
+
+ QWebNetworkJob objects are created and owned by the QtWebKit library.
+ Most of it's properties are read-only.
+
+ The job is reference counted. This can be used to ensure that the job doesn't
+ get deleted while it's still stored in some data structure.
+*/
+
+/*!
+ \internal
+*/
+QWebNetworkJob::QWebNetworkJob()
+ : d(new QWebNetworkJobPrivate)
+{
+}
+
+/*!
+ \internal
+*/
+QWebNetworkJob::~QWebNetworkJob()
+{
+ delete d;
+ d = 0;
+}
+
+/*!
+ The requested URL
+*/
+QUrl QWebNetworkJob::url() const
+{
+ return d->request.url;
+}
+
+/*!
+ Post data associated with the job
+*/
+QByteArray QWebNetworkJob::postData() const
+{
+ return d->request.postData;
+}
+
+/*!
+ The HTTP request header that should be used to download the job.
+*/
+QHttpRequestHeader QWebNetworkJob::httpHeader() const
+{
+ return d->request.httpHeader;
+}
+
+/*!
+ The complete network request that should be used to download the job.
+*/
+QWebNetworkRequest QWebNetworkJob::request() const
+{
+ return QWebNetworkRequest(d->request);
+}
+
+/*!
+ The HTTP response header received from the network.
+*/
+QHttpResponseHeader QWebNetworkJob::response() const
+{
+ return d->response;
+}
+
+/*!
+ The last error of the Job.
+*/
+QString QWebNetworkJob::errorString() const
+{
+ return d->errorString;
+}
+
+/*!
+ Sets the HTTP reponse header. The response header has to be called before
+ emitting QWebNetworkInterface::started.
+*/
+void QWebNetworkJob::setResponse(const QHttpResponseHeader &response)
+{
+ d->response = response;
+}
+
+void QWebNetworkJob::setErrorString(const QString& errorString)
+{
+ d->errorString = errorString;
+}
+
+/*!
+ returns true if the job has been cancelled by the WebKit framework
+*/
+bool QWebNetworkJob::cancelled() const
+{
+ return !d->resourceHandle && !d->connector;
+}
+
+/*!
+ reference the job.
+*/
+void QWebNetworkJob::ref()
+{
+ ++d->ref;
+}
+
+/*!
+ derefence the job.
+
+ If the reference count drops to 0 this method also deletes the job.
+
+ Returns false if the reference count has dropped to 0.
+*/
+bool QWebNetworkJob::deref()
+{
+ if (!--d->ref) {
+ delete this;
+ return false;
+ }
+ return true;
+}
+
+/*!
+ Returns the network interface that is associated with this job.
+*/
+QWebNetworkInterface *QWebNetworkJob::networkInterface() const
+{
+ return d->interface;
+}
+
+/*!
+ Returns the network interface that is associated with this job.
+*/
+QWebFrame *QWebNetworkJob::frame() const
+{
+ if (d->resourceHandle) {
+ ResourceHandleInternal *rhi = d->resourceHandle->getInternal();
+ if (rhi) {
+ return rhi->m_frame;
+ }
+ }
+ return 0;
+}
+
+QWebNetworkJob::JobStatus QWebNetworkJob::status() const
+{
+ return d->jobStatus;
+}
+
+void QWebNetworkJob::setStatus(const JobStatus& status)
+{
+ d->jobStatus = status;
+}
+
+/*!
+ \class QWebNetworkManager
+ \internal
+*/
+QWebNetworkManager::QWebNetworkManager()
+ : QObject(0)
+ , m_scheduledWork(false)
+{
+ connect(this, SIGNAL(scheduleWork()), SLOT(doWork()), Qt::QueuedConnection);
+}
+
+QWebNetworkManager *QWebNetworkManager::self()
+{
+ // ensure everything's constructed and connected
+ QWebNetworkInterface::defaultInterface();
+
+ return s_manager;
+}
+
+bool QWebNetworkManager::add(ResourceHandle *handle, QWebNetworkInterface *interface, JobMode jobMode)
+{
+ if (!interface)
+ interface = s_default_interface;
+
+ ASSERT(interface);
+
+ QWebNetworkJob *job = new QWebNetworkJob();
+ handle->getInternal()->m_job = job;
+ job->d->resourceHandle = handle;
+ job->d->interface = interface;
+ job->d->connector = 0;
+
+ job->d->request.init(handle->request());
+
+ const QString method = handle->getInternal()->m_request.httpMethod();
+ if (method != "POST" && method != "GET" && method != "HEAD") {
+ qWarning("REQUEST: [%s]\n", qPrintable(job->d->request.httpHeader.toString()));
+ return false;
+ }
+
+ DEBUG() << "QWebNetworkManager::add:" << job->d->request.httpHeader.toString();
+
+ if (jobMode == SynchronousJob) {
+ Q_ASSERT(!m_synchronousJobs.contains(job));
+ m_synchronousJobs[job] = 1;
+ }
+
+ interface->addJob(job);
+
+ return true;
+}
+
+void QWebNetworkManager::cancel(ResourceHandle *handle)
+{
+ QWebNetworkJob *job = handle->getInternal()->m_job;
+ if (!job)
+ return;
+ DEBUG() << "QWebNetworkManager::cancel:" << job->d->request.httpHeader.toString();
+ job->d->resourceHandle = 0;
+ job->d->connector = 0;
+ job->d->interface->cancelJob(job);
+ handle->getInternal()->m_job = 0;
+}
+
+void QWebNetworkManager::started(QWebNetworkJob *job)
+{
+ Q_ASSERT(job->d);
+ Q_ASSERT(job->status() == QWebNetworkJob::JobCreated ||
+ job->status() == QWebNetworkJob::JobRecreated);
+
+ job->setStatus(QWebNetworkJob::JobStarted);
+ ResourceHandleClient* client = 0;
+ if (job->d->resourceHandle) {
+ client = job->d->resourceHandle->client();
+ if (!client)
+ return;
+ } else if (!job->d->connector) {
+ return;
+ }
+
+ DEBUG() << "ResourceHandleManager::receivedResponse:";
+ DEBUG() << job->d->response.toString();
+
+ QStringList cookies = job->d->response.allValues("Set-Cookie");
+ KURL url(job->url());
+ foreach (QString c, cookies) {
+ QCookieJar::cookieJar()->setCookies(url, url, c);
+ }
+ QString contentType = job->d->response.value("Content-Type");
+ QString encoding;
+ int idx = contentType.indexOf(QLatin1Char(';'));
+ if (idx > 0) {
+ QString remainder = contentType.mid(idx + 1).toLower();
+ contentType = contentType.left(idx).trimmed();
+
+ idx = remainder.indexOf("charset");
+ if (idx >= 0) {
+ idx = remainder.indexOf(QLatin1Char('='), idx);
+ if (idx >= 0)
+ encoding = remainder.mid(idx + 1).trimmed();
+ }
+ }
+ if (contentType.isEmpty()) {
+ // let's try to guess from the extension
+ QString extension = job->d->request.url.path();
+ int index = extension.lastIndexOf(QLatin1Char('.'));
+ if (index > 0) {
+ extension = extension.mid(index + 1);
+ contentType = MIMETypeRegistry::getMIMETypeForExtension(extension);
+ }
+ }
+// qDebug() << "Content-Type=" << contentType;
+// qDebug() << "Encoding=" << encoding;
+
+
+ ResourceResponse response(url, contentType,
+ 0 /* FIXME */,
+ encoding,
+ String() /* FIXME */);
+
+ int statusCode = job->d->response.statusCode();
+ if (job->url().scheme() != QLatin1String("file"))
+ response.setHTTPStatusCode(statusCode);
+ else if (statusCode == 404)
+ response.setHTTPStatusCode(statusCode);
+
+ /* Fill in the other fields */
+
+ if (statusCode >= 300 && statusCode < 400) {
+ // we're on a redirect page! if the 'Location:' field is valid, we redirect
+ QString location = job->d->response.value("location");
+ DEBUG() << "Redirection";
+ if (!location.isEmpty()) {
+ QUrl newUrl = job->d->request.url.resolved(location);
+ if (job->d->resourceHandle) {
+ ResourceRequest newRequest = job->d->resourceHandle->request();
+ newRequest.setURL(KURL(newUrl));
+ if (client)
+ client->willSendRequest(job->d->resourceHandle, newRequest, response);
+ }
+
+ job->d->request.httpHeader.setRequest(job->d->request.httpHeader.method(),
+ newUrl.toString(QUrl::RemoveScheme|QUrl::RemoveAuthority));
+ job->d->request.setURL(newUrl);
+ job->d->redirected = true;
+ return;
+ }
+ }
+
+ if (client)
+ client->didReceiveResponse(job->d->resourceHandle, response);
+ if (job->d->connector)
+ emit job->d->connector->started(job);
+
+}
+
+void QWebNetworkManager::data(QWebNetworkJob *job, const QByteArray &data)
+{
+ Q_ASSERT(job->status() == QWebNetworkJob::JobStarted ||
+ job->status() == QWebNetworkJob::JobReceivingData);
+
+ job->setStatus(QWebNetworkJob::JobReceivingData);
+ ResourceHandleClient* client = 0;
+ if (job->d->resourceHandle) {
+ client = job->d->resourceHandle->client();
+ if (!client)
+ return;
+ } else if (!job->d->connector) {
+ return;
+ }
+
+ if (job->d->redirected)
+ return; // don't emit the "Document has moved here" type of HTML
+
+ DEBUG() << "receivedData" << job->d->request.url.path();
+ if (client)
+ client->didReceiveData(job->d->resourceHandle, data.constData(), data.length(), data.length() /*FixMe*/);
+ if (job->d->connector)
+ emit job->d->connector->data(job, data);
+
+}
+
+void QWebNetworkManager::finished(QWebNetworkJob *job, int errorCode)
+{
+ Q_ASSERT(errorCode == 1 ||
+ job->status() == QWebNetworkJob::JobStarted ||
+ job->status() == QWebNetworkJob::JobReceivingData);
+
+ if (m_synchronousJobs.contains(job))
+ m_synchronousJobs.remove(job);
+
+ job->setStatus(QWebNetworkJob::JobFinished);
+ ResourceHandleClient* client = 0;
+ if (job->d->resourceHandle) {
+ client = job->d->resourceHandle->client();
+ if (!client)
+ return;
+ } else if (!job->d->connector) {
+ job->deref();
+ return;
+ }
+
+ DEBUG() << "receivedFinished" << errorCode << job->url();
+
+ if (job->d->redirected) {
+ job->d->redirected = false;
+ job->setStatus(QWebNetworkJob::JobRecreated);
+ job->d->interface->addJob(job);
+ return;
+ }
+
+ if (job->d->resourceHandle)
+ job->d->resourceHandle->getInternal()->m_job = 0;
+
+ if (client) {
+ if (errorCode) {
+ //FIXME: error setting error was removed from ResourceHandle
+ client->didFail(job->d->resourceHandle,
+ ResourceError(job->d->request.url.host(), job->d->response.statusCode(),
+ job->d->request.url.toString(), job->d->errorString));
+ } else {
+ client->didFinishLoading(job->d->resourceHandle);
+ }
+ }
+
+ if (job->d->connector)
+ emit job->d->connector->finished(job, errorCode);
+
+ DEBUG() << "receivedFinished done" << job->d->request.url;
+
+ job->deref();
+}
+
+void QWebNetworkManager::addHttpJob(QWebNetworkJob *job)
+{
+ HostInfo hostInfo(job->url());
+ WebCoreHttp *httpConnection = m_hostMapping.value(hostInfo);
+ if (!httpConnection) {
+ // #### fix custom ports
+ DEBUG() << " new connection to" << hostInfo.host << hostInfo.port;
+ httpConnection = new WebCoreHttp(this, hostInfo);
+ QObject::connect(httpConnection, SIGNAL(connectionClosed(const WebCore::HostInfo&)),
+ this, SLOT(httpConnectionClosed(const WebCore::HostInfo&)));
+
+ m_hostMapping[hostInfo] = httpConnection;
+ }
+ httpConnection->request(job);
+}
+
+void QWebNetworkManager::cancelHttpJob(QWebNetworkJob *job)
+{
+ WebCoreHttp *httpConnection = m_hostMapping.value(job->url());
+ if (httpConnection)
+ httpConnection->cancel(job);
+}
+
+void QWebNetworkManager::httpConnectionClosed(const WebCore::HostInfo &info)
+{
+ WebCoreHttp *connection = m_hostMapping.take(info);
+ connection->deleteLater();
+}
+
+void QWebNetworkInterfacePrivate::sendFileData(QWebNetworkJob* job, int statusCode, const QByteArray &data)
+{
+ int error = statusCode >= 400 ? 1 : 0;
+ if (!job->cancelled()) {
+ QHttpResponseHeader response;
+ response.setStatusLine(statusCode);
+ response.setContentLength(data.length());
+ job->setResponse(response);
+ q->started(job);
+ if (!data.isEmpty())
+ q->data(job, data);
+ }
+ q->finished(job, error);
+}
+
+void QWebNetworkInterfacePrivate::parseDataUrl(QWebNetworkJob* job)
+{
+ QByteArray data = job->url().toString().toLatin1();
+ //qDebug() << "handling data url:" << data;
+
+ ASSERT(data.startsWith("data:"));
+
+ // Here's the syntax of data URLs:
+ // dataurl := "data:" [ mediatype ] [ ";base64" ] "," data
+ // mediatype := [ type "/" subtype ] *( ";" parameter )
+ // data := *urlchar
+ // parameter := attribute "=" value
+ QByteArray header;
+ bool base64 = false;
+
+ int index = data.indexOf(',');
+ if (index != -1) {
+ header = data.mid(5, index - 5).toLower();
+ //qDebug() << "header=" << header;
+ data = data.mid(index+1);
+ //qDebug() << "data=" << data;
+
+ if (header.endsWith(";base64")) {
+ //qDebug() << "base64";
+ base64 = true;
+ header = header.left(header.length() - 7);
+ //qDebug() << "mime=" << header;
+ }
+ } else {
+ data = QByteArray();
+ }
+
+ if (base64) {
+ data = QByteArray::fromBase64(data);
+ } else {
+ data = decodePercentEncoding(data);
+ }
+
+ if (header.isEmpty())
+ header = "text/plain;charset=US-ASCII";
+ int statusCode = 200;
+ QHttpResponseHeader response;
+ response.setContentType(header);
+ response.setContentLength(data.size());
+ job->setResponse(response);
+
+ int error = statusCode >= 400 ? 1 : 0;
+ q->started(job);
+ if (!data.isEmpty())
+ q->data(job, data);
+ q->finished(job, error);
+}
+
+void QWebNetworkManager::queueStart(QWebNetworkJob* job)
+{
+ Q_ASSERT(job->d);
+
+ QMutexLocker locker(&m_queueMutex);
+ job->ref();
+ m_pendingWork.append(new JobWork(job));
+ doScheduleWork();
+}
+
+void QWebNetworkManager::queueData(QWebNetworkJob* job, const QByteArray& data)
+{
+ ASSERT(job->d);
+
+ QMutexLocker locker(&m_queueMutex);
+ job->ref();
+ m_pendingWork.append(new JobWork(job, data));
+ doScheduleWork();
+}
+
+void QWebNetworkManager::queueFinished(QWebNetworkJob* job, int errorCode)
+{
+ Q_ASSERT(job->d);
+
+ QMutexLocker locker(&m_queueMutex);
+ job->ref();
+ m_pendingWork.append(new JobWork(job, errorCode));
+ doScheduleWork();
+}
+
+void QWebNetworkManager::doScheduleWork()
+{
+ if (!m_scheduledWork) {
+ m_scheduledWork = true;
+ emit scheduleWork();
+ }
+}
+
+
+/*
+ * We will work on a copy of m_pendingWork. While dispatching m_pendingWork
+ * new work will be added that will be handled at a later doWork call. doWork
+ * will be called we set m_scheduledWork to false early in this method.
+ */
+void QWebNetworkManager::doWork()
+{
+ m_queueMutex.lock();
+ m_scheduledWork = false;
+ bool hasSyncJobs = m_synchronousJobs.size();
+ const QHash<QWebNetworkJob*, int> syncJobs = m_synchronousJobs;
+ m_queueMutex.unlock();
+
+ foreach (JobWork* work, m_pendingWork) {
+ if (hasSyncJobs && !syncJobs.contains(work->job))
+ continue;
+
+ if (work->workType == JobWork::JobStarted)
+ started(work->job);
+ else if (work->workType == JobWork::JobData) {
+ // This job was not yet started
+ if (static_cast<int>(work->job->status()) < QWebNetworkJob::JobStarted)
+ continue;
+
+ data(work->job, work->data);
+ } else if (work->workType == JobWork::JobFinished) {
+ // This job was not yet started... we have no idea if data comes by...
+ // and it won't start in case of errors
+ if (static_cast<int>(work->job->status()) < QWebNetworkJob::JobStarted && work->errorCode != 1)
+ continue;
+
+ finished(work->job, work->errorCode);
+ }
+
+ m_queueMutex.lock();
+ m_pendingWork.removeAll(work);
+ m_queueMutex.unlock();
+
+ work->job->deref();
+ delete work;
+ }
+
+ m_queueMutex.lock();
+ if (hasSyncJobs && m_synchronousJobs.size() == 0)
+ doScheduleWork();
+ m_queueMutex.unlock();
+}
+
+/*!
+ \class QWebNetworkInterface
+
+ The QWebNetworkInterface class provides an abstraction layer for
+ WebKit's network interface. It allows to completely replace or
+ extend the builtin network layer.
+
+ QWebNetworkInterface contains two virtual methods, addJob and
+ cancelJob that have to be reimplemented when implementing your own
+ networking layer.
+
+ QWebNetworkInterface can by default handle the http, https, file and
+ data URI protocols.
+
+*/
+
+static bool gRoutineAdded = false;
+
+static void gCleanupInterface()
+{
+ delete s_default_interface;
+ s_default_interface = 0;
+}
+
+/*!
+ Sets a new default interface that will be used by all of WebKit
+ for downloading data from the internet.
+*/
+void QWebNetworkInterface::setDefaultInterface(QWebNetworkInterface *defaultInterface)
+{
+ if (s_default_interface == defaultInterface)
+ return;
+ if (s_default_interface)
+ delete s_default_interface;
+ s_default_interface = defaultInterface;
+ if (!gRoutineAdded) {
+ qAddPostRoutine(gCleanupInterface);
+ gRoutineAdded = true;
+ }
+}
+
+/*!
+ Returns the default interface that will be used by WebKit. If no
+ default interface has been set, QtWebkit will create an instance of
+ QWebNetworkInterface to do the work.
+*/
+QWebNetworkInterface *QWebNetworkInterface::defaultInterface()
+{
+ if (!s_default_interface) {
+ setDefaultInterface(new QWebNetworkInterface);
+ }
+ return s_default_interface;
+}
+
+
+/*!
+ Constructs a QWebNetworkInterface object.
+*/
+QWebNetworkInterface::QWebNetworkInterface(QObject *parent)
+ : QObject(parent)
+{
+ d = new QWebNetworkInterfacePrivate;
+ d->q = this;
+
+ if (!s_manager)
+ s_manager = new QWebNetworkManager;
+}
+
+/*!
+ Destructs the QWebNetworkInterface object.
+*/
+QWebNetworkInterface::~QWebNetworkInterface()
+{
+ delete d;
+}
+
+/*!
+ This virtual method gets called whenever QtWebkit needs to add a
+ new job to download.
+
+ The QWebNetworkInterface should process this job, by first emitting
+ the started signal, then emitting data repeatedly as new data for
+ the Job is available, and finally ending the job with emitting a
+ finished signal.
+
+ After the finished signal has been emitted, the QWebNetworkInterface
+ is not allowed to access the job anymore.
+*/
+void QWebNetworkInterface::addJob(QWebNetworkJob *job)
+{
+ QString protocol = job->url().scheme();
+ if (protocol == QLatin1String("http") || protocol == QLatin1String("https")) {
+ QWebNetworkManager::self()->addHttpJob(job);
+ return;
+ }
+
+ // "file", "data" and all unhandled stuff go through here
+ //DEBUG() << "fileRequest";
+ DEBUG() << "FileLoader::request" << job->url();
+
+ if (job->cancelled()) {
+ d->sendFileData(job, 400, QByteArray());
+ return;
+ }
+
+ QUrl url = job->url();
+ if (protocol == QLatin1String("data")) {
+ d->parseDataUrl(job);
+ return;
+ }
+
+ int statusCode = 200;
+ QByteArray data;
+ QString path = url.path();
+ if (protocol == QLatin1String("qrc")) {
+ protocol = "file";
+ path.prepend(QLatin1Char(':'));
+ }
+
+ if (!(protocol.isEmpty() || protocol == QLatin1String("file"))) {
+ statusCode = 404;
+ } else {
+ // we simply ignore post data here.
+ QFile f(path);
+ DEBUG() << "opening" << QString(url.path());
+
+ if (f.open(QIODevice::ReadOnly)) {
+ QHttpResponseHeader response;
+ response.setStatusLine(200);
+ job->setResponse(response);
+ data = f.readAll();
+ } else {
+ statusCode = 404;
+ }
+ }
+
+ if (statusCode == 404) {
+ QHttpResponseHeader response;
+ response.setStatusLine(404);
+ job->setResponse(response);
+ }
+
+ d->sendFileData(job, statusCode, data);
+}
+
+/*!
+ This virtual method gets called whenever QtWebkit needs to cancel a
+ new job.
+
+ The QWebNetworkInterface acknowledge the canceling of the job, by
+ emitting the finished signal with an error code of 1. After emitting
+ the finished signal, the interface should not access the job
+ anymore.
+*/
+void QWebNetworkInterface::cancelJob(QWebNetworkJob *job)
+{
+ QString protocol = job->url().scheme();
+ if (protocol == QLatin1String("http") || protocol == QLatin1String("https"))
+ QWebNetworkManager::self()->cancelHttpJob(job);
+}
+
+void QWebNetworkInterface::started(QWebNetworkJob* job)
+{
+ Q_ASSERT(s_manager);
+ s_manager->queueStart(job);
+}
+
+void QWebNetworkInterface::data(QWebNetworkJob* job, const QByteArray& data)
+{
+ Q_ASSERT(s_manager);
+ s_manager->queueData(job, data);
+}
+
+void QWebNetworkInterface::finished(QWebNetworkJob* job, int errorCode)
+{
+ Q_ASSERT(s_manager);
+ s_manager->queueFinished(job, errorCode);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+WebCoreHttp::WebCoreHttp(QObject* parent, const HostInfo &hi)
+ : QObject(parent), info(hi),
+ m_inCancel(false)
+{
+ for (int i = 0; i < 2; ++i) {
+ connection[i].http = new QHttp(info.host, (hi.protocol == QLatin1String("https")) ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp, info.port);
+ connect(connection[i].http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader&)),
+ this, SLOT(onResponseHeaderReceived(const QHttpResponseHeader&)));
+ connect(connection[i].http, SIGNAL(readyRead(const QHttpResponseHeader&)),
+ this, SLOT(onReadyRead()));
+ connect(connection[i].http, SIGNAL(requestFinished(int, bool)),
+ this, SLOT(onRequestFinished(int, bool)));
+ connect(connection[i].http, SIGNAL(done(bool)),
+ this, SLOT(onDone(bool)));
+ connect(connection[i].http, SIGNAL(stateChanged(int)),
+ this, SLOT(onStateChanged(int)));
+ connect(connection[i].http, SIGNAL(authenticationRequired(const QString&, quint16, QAuthenticator*)),
+ this, SLOT(onAuthenticationRequired(const QString&, quint16, QAuthenticator*)));
+ connect(connection[i].http, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)),
+ this, SLOT(onProxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)));
+ connect(connection[i].http, SIGNAL(sslErrors(const QList<QSslError>&)),
+ this, SLOT(onSslErrors(const QList<QSslError>&)));
+ }
+}
+
+WebCoreHttp::~WebCoreHttp()
+{
+ connection[0].http->deleteLater();
+ connection[1].http->deleteLater();
+}
+
+void WebCoreHttp::request(QWebNetworkJob *job)
+{
+ m_pendingRequests.append(job);
+ scheduleNextRequest();
+}
+
+void WebCoreHttp::scheduleNextRequest()
+{
+ int c = 0;
+ for (; c < 2; ++c) {
+ if (!connection[c].current)
+ break;
+ }
+ if (c >= 2)
+ return;
+
+ QWebNetworkJob *job = 0;
+ while (!job && !m_pendingRequests.isEmpty()) {
+ job = m_pendingRequests.takeFirst();
+ if (job->cancelled()) {
+ job->networkInterface()->finished(job, 1);
+ job = 0;
+ }
+ }
+ if (!job)
+ return;
+
+ QHttp *http = connection[c].http;
+
+ connection[c].current = job;
+ connection[c].id = -1;
+#ifndef QT_NO_NETWORKPROXY
+ int proxyId = http->setProxy(job->frame()->page()->networkProxy());
+#endif
+
+ QByteArray postData = job->postData();
+ if (!postData.isEmpty())
+ connection[c].id = http->request(job->httpHeader(), postData);
+ else
+ connection[c].id = http->request(job->httpHeader());
+
+ DEBUG() << "WebCoreHttp::scheduleNextRequest: using connection" << c;
+ DEBUG() << job->httpHeader().toString();
+// DEBUG() << job->request.toString();
+}
+
+int WebCoreHttp::getConnection()
+{
+ QObject *o = sender();
+ int c;
+ if (o == connection[0].http) {
+ c = 0;
+ } else {
+ Q_ASSERT(o == connection[1].http);
+ c = 1;
+ }
+ Q_ASSERT(connection[c].current);
+ return c;
+}
+
+void WebCoreHttp::onResponseHeaderReceived(const QHttpResponseHeader &resp)
+{
+ QHttp *http = qobject_cast<QHttp*>(sender());
+ if (http->currentId() == 0) {
+ qDebug() << "ERROR! Invalid job id. Why?"; // foxnews.com triggers this
+ return;
+ }
+ int c = getConnection();
+ QWebNetworkJob *job = connection[c].current;
+ DEBUG() << "WebCoreHttp::slotResponseHeaderReceived connection=" << c;
+ DEBUG() << resp.toString();
+
+ job->setResponse(resp);
+
+ job->networkInterface()->started(job);
+}
+
+void WebCoreHttp::onReadyRead()
+{
+ QHttp *http = qobject_cast<QHttp*>(sender());
+ if (http->currentId() == 0) {
+ qDebug() << "ERROR! Invalid job id. Why?"; // foxnews.com triggers this
+ return;
+ }
+ int c = getConnection();
+ QWebNetworkJob *job = connection[c].current;
+ Q_ASSERT(http == connection[c].http);
+ //DEBUG() << "WebCoreHttp::slotReadyRead connection=" << c;
+
+ QByteArray data;
+ data.resize(http->bytesAvailable());
+ http->read(data.data(), data.length());
+ job->networkInterface()->data(job, data);
+}
+
+void WebCoreHttp::onRequestFinished(int id, bool error)
+{
+ int c = getConnection();
+ if (connection[c].id != id) {
+ return;
+ }
+
+ QWebNetworkJob *job = connection[c].current;
+ if (!job) {
+ scheduleNextRequest();
+ return;
+ }
+
+ QHttp *http = connection[c].http;
+ DEBUG() << "WebCoreHttp::slotFinished connection=" << c << error << job;
+ if (error) {
+ DEBUG() << " error: " << http->errorString();
+ job->setErrorString(http->errorString());
+ }
+
+ if (!error && http->bytesAvailable()) {
+ QByteArray data;
+ data.resize(http->bytesAvailable());
+ http->read(data.data(), data.length());
+ job->networkInterface()->data(job, data);
+ }
+
+ job->networkInterface()->finished(job, error ? 1 : 0);
+ connection[c].current = 0;
+ connection[c].id = -1;
+ scheduleNextRequest();
+}
+
+void WebCoreHttp::onDone(bool error)
+{
+ DEBUG() << "WebCoreHttp::onDone" << error;
+}
+
+void WebCoreHttp::onStateChanged(int state)
+{
+ DEBUG() << "State changed to" << state << "and connections are" << connection[0].current << connection[1].current;
+ if (state == QHttp::Closing || state == QHttp::Unconnected) {
+ if (!m_inCancel && m_pendingRequests.isEmpty()
+ && !connection[0].current && !connection[1].current)
+ emit connectionClosed(info);
+ }
+}
+
+void WebCoreHttp::cancel(QWebNetworkJob* request)
+{
+ bool doEmit = true;
+ m_inCancel = true;
+ for (int i = 0; i < 2; ++i) {
+ if (request == connection[i].current) {
+ connection[i].http->abort();
+ doEmit = false;
+ }
+ }
+ if (!m_pendingRequests.removeAll(request))
+ doEmit = false;
+ m_inCancel = false;
+
+ if (doEmit)
+ request->networkInterface()->finished(request, 1);
+
+ if (m_pendingRequests.isEmpty()
+ && !connection[0].current && !connection[1].current)
+ emit connectionClosed(info);
+}
+
+void WebCoreHttp::onSslErrors(const QList<QSslError>& errors)
+{
+ int c = getConnection();
+ QWebNetworkJob *job = connection[c].current;
+ if (job) {
+ bool continueAnyway = false;
+ emit job->networkInterface()->sslErrors(job->frame(), job->url(), errors, &continueAnyway);
+#ifndef QT_NO_OPENSSL
+ if (continueAnyway)
+ connection[c].http->ignoreSslErrors();
+#endif
+ }
+}
+
+void WebCoreHttp::onAuthenticationRequired(const QString& hostname, quint16 port, QAuthenticator *auth)
+{
+ int c = getConnection();
+ QWebNetworkJob *job = connection[c].current;
+ if (job) {
+ emit job->networkInterface()->authenticate(job->frame(), job->url(), hostname, port, auth);
+ if (auth->isNull())
+ connection[c].http->abort();
+ }
+}
+
+void WebCoreHttp::onProxyAuthenticationRequired(const QNetworkProxy& proxy, QAuthenticator *auth)
+{
+ int c = getConnection();
+ QWebNetworkJob *job = connection[c].current;
+ if (job) {
+ emit job->networkInterface()->authenticateProxy(job->frame(), job->url(), proxy, auth);
+ if (auth->isNull())
+ connection[c].http->abort();
+ }
+}
+
+HostInfo::HostInfo(const QUrl& url)
+ : protocol(url.scheme())
+ , host(url.host())
+ , port(url.port())
+{
+ if (port < 0) {
+ if (protocol == QLatin1String("http"))
+ port = 80;
+ else if (protocol == QLatin1String("https"))
+ port = 443;
+ }
+}
+
+#endif
diff --git a/WebKit/qt/Api/qwebnetworkinterface.h b/WebKit/qt/Api/qwebnetworkinterface.h
new file mode 100644
index 0000000..fdc38d1
--- /dev/null
+++ b/WebKit/qt/Api/qwebnetworkinterface.h
@@ -0,0 +1,175 @@
+/*
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, 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 QWEBNETWORKINTERFACE_H
+#define QWEBNETWORKINTERFACE_H
+
+#include <QtCore/qobject.h>
+#include <QtCore/qurl.h>
+#include <QtNetwork/qhttp.h>
+#include <QtCore/qbytearray.h>
+
+#include "qwebkitglobal.h"
+
+#if QT_VERSION < 0x040400
+
+class QAuthenticator;
+class QNetworkProxy;
+class QSslError;
+class QWebFrame;
+class QWebNetworkJobPrivate;
+class QWebNetworkInterface;
+class QWebObjectPluginConnector;
+
+namespace WebCore {
+ class WebCoreHttp;
+ class ResourceRequest;
+ class FrameLoaderClientQt;
+}
+
+struct QWebNetworkRequestPrivate;
+class QWEBKIT_EXPORT QWebNetworkRequest
+{
+public:
+ enum Method {
+ Get,
+ Post
+ //Head
+ };
+
+ QWebNetworkRequest();
+ explicit QWebNetworkRequest(const QUrl &url, Method method = Get, const QByteArray &postData = QByteArray());
+ QWebNetworkRequest(const QWebNetworkRequest &other);
+
+ QWebNetworkRequest &operator=(const QWebNetworkRequest &other);
+ ~QWebNetworkRequest();
+
+ QUrl url() const;
+ void setUrl(const QUrl &url);
+
+ QHttpRequestHeader httpHeader() const;
+ void setHttpHeader(const QHttpRequestHeader &header) const;
+
+ QString httpHeaderField(const QString &key) const;
+ void setHttpHeaderField(const QString &key, const QString &value);
+
+ QByteArray postData() const;
+ void setPostData(const QByteArray &data);
+
+private:
+ explicit QWebNetworkRequest(const QWebNetworkRequestPrivate &priv);
+ explicit QWebNetworkRequest(const WebCore::ResourceRequest &request);
+ friend class QWebNetworkJob;
+ friend class WebCore::FrameLoaderClientQt;
+
+ QWebNetworkRequestPrivate *d;
+ friend class QWebObjectPluginConnector;
+};
+
+class QWEBKIT_EXPORT QWebNetworkJob
+{
+public:
+
+ QUrl url() const;
+ QByteArray postData() const;
+ QHttpRequestHeader httpHeader() const;
+ QWebNetworkRequest request() const;
+ QString errorString() const;
+
+ QHttpResponseHeader response() const;
+ void setResponse(const QHttpResponseHeader &response);
+ void setErrorString(const QString&);
+
+ bool cancelled() const;
+
+ void ref();
+ bool deref();
+
+ QWebNetworkInterface *networkInterface() const;
+
+ QWebFrame *frame() const;
+
+protected:
+ enum JobStatus {
+ JobCreated,
+ JobRecreated,
+ JobStarted,
+ JobReceivingData,
+ JobFinished
+ };
+
+ JobStatus status() const;
+ void setStatus(const JobStatus&);
+
+private:
+ QWebNetworkJob();
+ ~QWebNetworkJob();
+
+ friend class QWebNetworkManager;
+ friend class QWebObjectPluginConnector;
+ friend class QWebNetworkJobPrivate;
+
+ QWebNetworkJobPrivate *d;
+};
+
+class QWebNetworkInterfacePrivate;
+
+class QWEBKIT_EXPORT QWebNetworkInterface : public QObject
+{
+ Q_OBJECT
+public:
+ QWebNetworkInterface(QObject *parent = 0);
+ ~QWebNetworkInterface();
+
+ static void setDefaultInterface(QWebNetworkInterface *defaultInterface);
+ static QWebNetworkInterface *defaultInterface();
+
+ virtual void addJob(QWebNetworkJob *job);
+ virtual void cancelJob(QWebNetworkJob *job);
+
+protected:
+ void started(QWebNetworkJob*);
+ void data(QWebNetworkJob*, const QByteArray &data);
+ void finished(QWebNetworkJob*, int errorCode);
+
+signals:
+ /**
+ * Signal is emitted when an SSL error occurs.
+ */
+ void sslErrors(QWebFrame *frame, const QUrl& url, const QList<QSslError>& errors, bool *continueAnyway);
+ /**
+ * Signal is emitted when network authentication is required.
+ */
+ void authenticate(QWebFrame *frame, const QUrl& url, const QString& hostname, quint16 port, QAuthenticator *auth);
+ /**
+ * Signal is emitted when proxy authentication is required.
+ */
+ void authenticateProxy(QWebFrame *frame, const QUrl& url, const QNetworkProxy& proxy, QAuthenticator *auth);
+
+private:
+ friend class QWebNetworkInterfacePrivate;
+ friend class WebCore::WebCoreHttp;
+ QWebNetworkInterfacePrivate *d;
+};
+
+#endif
+
+#endif
diff --git a/WebKit/qt/Api/qwebnetworkinterface_p.h b/WebKit/qt/Api/qwebnetworkinterface_p.h
new file mode 100644
index 0000000..c712ae4
--- /dev/null
+++ b/WebKit/qt/Api/qwebnetworkinterface_p.h
@@ -0,0 +1,223 @@
+/*
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, 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 QWEBNETWORKINTERFACE_P_H
+#define QWEBNETWORKINTERFACE_P_H
+
+#include "qwebnetworkinterface.h"
+#if QT_VERSION < 0x040400
+#include <qthread.h>
+#include <qmutex.h>
+
+namespace WebCore {
+ struct HostInfo;
+ class ResourceRequest;
+};
+uint qHash(const WebCore::HostInfo &info);
+#include <qhash.h>
+
+namespace WebCore {
+ class ResourceHandle;
+}
+
+struct QWebNetworkRequestPrivate
+{
+ QUrl url;
+ QHttpRequestHeader httpHeader;
+ QByteArray postData;
+
+ void init(const WebCore::ResourceRequest &resourceRequest);
+ void init(const QString &method, const QUrl &url, const WebCore::ResourceRequest *resourceRequest = 0);
+ void setURL(const QUrl &u);
+};
+
+class QWebNetworkJobPrivate
+{
+public:
+ QWebNetworkJobPrivate()
+ : ref(1)
+ , resourceHandle(0)
+ , redirected(false)
+ , interface(0)
+ , connector(0)
+ , jobStatus(QWebNetworkJob::JobCreated)
+ {}
+ int ref;
+
+ QWebNetworkRequestPrivate request;
+ QHttpResponseHeader response;
+
+ WebCore::ResourceHandle *resourceHandle;
+ bool redirected;
+
+ QWebNetworkInterface *interface;
+ QWebObjectPluginConnector *connector;
+ QWebNetworkJob::JobStatus jobStatus;
+ QString errorString;
+};
+
+class QWebNetworkManager : public QObject
+{
+ Q_OBJECT
+public:
+ enum JobMode {
+ AsynchronousJob,
+ SynchronousJob
+ };
+
+ static QWebNetworkManager *self();
+
+ bool add(WebCore::ResourceHandle *resourceHandle, QWebNetworkInterface *interface, JobMode = AsynchronousJob);
+ void cancel(WebCore::ResourceHandle *resourceHandle);
+
+ void addHttpJob(QWebNetworkJob *job);
+ void cancelHttpJob(QWebNetworkJob *job);
+
+protected:
+ void queueStart(QWebNetworkJob*);
+ void queueData(QWebNetworkJob*, const QByteArray&);
+ void queueFinished(QWebNetworkJob*, int errorCode);
+
+private:
+ void started(QWebNetworkJob *);
+ void data(QWebNetworkJob *, const QByteArray &data);
+ void finished(QWebNetworkJob *, int errorCode);
+ void doScheduleWork();
+
+signals:
+ void fileRequest(QWebNetworkJob*);
+ void scheduleWork();
+
+private slots:
+ void httpConnectionClosed(const WebCore::HostInfo &);
+ void doWork();
+
+private:
+ friend class QWebNetworkInterface;
+ QWebNetworkManager();
+ QHash<WebCore::HostInfo, WebCore::WebCoreHttp *> m_hostMapping;
+
+ struct JobWork {
+ enum WorkType {
+ JobStarted,
+ JobData,
+ JobFinished
+ };
+
+ explicit JobWork(QWebNetworkJob* _job)
+ : workType(JobStarted)
+ , errorCode(-1)
+ , job(_job)
+ {}
+
+ explicit JobWork(QWebNetworkJob* _job, int _errorCode)
+ : workType(JobFinished)
+ , errorCode(_errorCode)
+ , job(_job)
+ {}
+
+ explicit JobWork(QWebNetworkJob* _job, const QByteArray& _data)
+ : workType(JobData)
+ , errorCode(-1)
+ , job(_job)
+ , data(_data)
+ {}
+
+ const WorkType workType;
+ int errorCode;
+ QByteArray data;
+ QWebNetworkJob* job;
+ };
+
+ QMutex m_queueMutex;
+ bool m_scheduledWork;
+ QList<JobWork*> m_pendingWork;
+ QHash<QWebNetworkJob*, int> m_synchronousJobs;
+};
+
+
+namespace WebCore {
+
+ class NetworkLoader;
+
+ struct HostInfo {
+ HostInfo() {}
+ HostInfo(const QUrl& url);
+ QString protocol;
+ QString host;
+ int port;
+ };
+
+ class WebCoreHttp : public QObject
+ {
+ Q_OBJECT
+ public:
+ WebCoreHttp(QObject *parent, const HostInfo&);
+ ~WebCoreHttp();
+
+ void request(QWebNetworkJob* resource);
+ void cancel(QWebNetworkJob*);
+
+ signals:
+ void connectionClosed(const WebCore::HostInfo &);
+
+ private slots:
+ void onResponseHeaderReceived(const QHttpResponseHeader& resp);
+ void onReadyRead();
+ void onRequestFinished(int, bool);
+ void onDone(bool);
+ void onStateChanged(int);
+ void onSslErrors(const QList<QSslError>&);
+ void onAuthenticationRequired(const QString& hostname, quint16 port, QAuthenticator *);
+ void onProxyAuthenticationRequired(const QNetworkProxy& proxy, QAuthenticator *);
+
+ void scheduleNextRequest();
+
+ int getConnection();
+
+ public:
+ HostInfo info;
+ private:
+ QList<QWebNetworkJob *> m_pendingRequests;
+ struct HttpConnection {
+ HttpConnection() : http(0), current(0), id(-1) {}
+ QHttp *http;
+ QWebNetworkJob *current;
+ int id; // the QHttp id
+ };
+ HttpConnection connection[2];
+ bool m_inCancel;
+ };
+
+}
+
+class QWebNetworkInterfacePrivate
+{
+public:
+ void sendFileData(QWebNetworkJob* job, int statusCode, const QByteArray &data);
+ void parseDataUrl(QWebNetworkJob* job);
+
+ QWebNetworkInterface *q;
+};
+
+#endif
+
+#endif
diff --git a/WebKit/qt/Api/qwebobjectplugin.cpp b/WebKit/qt/Api/qwebobjectplugin.cpp
new file mode 100644
index 0000000..b24d604
--- /dev/null
+++ b/WebKit/qt/Api/qwebobjectplugin.cpp
@@ -0,0 +1,192 @@
+/*
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+*/
+#include "qwebobjectplugin_p.h"
+#include <qwebobjectpluginconnector.h>
+#include <qcoreapplication.h>
+#include <qfileinfo.h>
+
+#if QT_VERSION < 0x040400
+
+#ifndef QT_NO_LIBRARY
+Q_GLOBAL_STATIC_WITH_ARGS(QWebFactoryLoader, loader,
+ (QWebObjectPluginFactoryInterface_iid, QCoreApplication::libraryPaths(), QLatin1String("/webplugins")))
+#endif
+
+
+QWebFactoryLoader::QWebFactoryLoader(const char *iid, const QStringList &paths, const QString &suffix, Qt::CaseSensitivity)
+ : QFactoryLoader(iid, paths, suffix)
+{
+ QStringList plugins = keys();
+ foreach(QString k, plugins) {
+ QWebObjectPlugin *plugin = qobject_cast<QWebObjectPlugin *>(instance(k));
+ if (!plugin)
+ continue;
+ Info info;
+ info.name = k;
+ info.description = plugin->descriptionForKey(k);
+ QStringList mimetypes = plugin->mimetypesForKey(k);
+ foreach(QString m, mimetypes) {
+ MimeInfo mime;
+ mime.type = m;
+ mime.extensions = plugin->extensionsForMimetype(m);
+ info.mimes << mime;
+ }
+ m_pluginInfo.append(info);
+ }
+}
+
+QWebFactoryLoader *QWebFactoryLoader::self()
+{
+ return loader();
+}
+
+
+QString QWebFactoryLoader::descriptionForName(const QString &key) const
+{
+ foreach(const Info &info, m_pluginInfo) {
+ if (info.name == key)
+ return info.description;
+ }
+ return QString();
+}
+
+QStringList QWebFactoryLoader::mimetypesForName(const QString &key) const
+{
+ foreach(const Info &info, m_pluginInfo) {
+ if (info.name == key) {
+ QStringList mimetypes;
+ foreach (const MimeInfo &m, info.mimes)
+ mimetypes.append(m.type);
+ return mimetypes;
+ }
+ }
+ return QStringList();
+}
+
+QString QWebFactoryLoader::mimeTypeForExtension(const QString &extension)
+{
+ foreach(const Info &info, m_pluginInfo) {
+ foreach (const MimeInfo &m, info.mimes) {
+ if (m.extensions.contains(extension))
+ return m.type;
+ }
+ }
+ return QString();
+}
+
+
+QStringList QWebFactoryLoader::extensions() const
+{
+ QStringList extensions;
+ foreach(const Info &info, m_pluginInfo) {
+ foreach (const MimeInfo &m, info.mimes)
+ extensions << m.extensions;
+ }
+ return QStringList();
+
+}
+
+QString QWebFactoryLoader::nameForMimetype(const QString &mimeType) const
+{
+ foreach(const Info &info, m_pluginInfo) {
+ foreach (const MimeInfo &m, info.mimes)
+ if (m.type == mimeType)
+ return info.name;
+ }
+ return QString();
+}
+
+QObject *QWebFactoryLoader::create(QWebFrame *frame,
+ const QUrl &url,
+ const QString &_mimeType,
+ const QStringList &argumentNames,
+ const QStringList &argumentValues)
+{
+ QString mimeType = _mimeType;
+ if (mimeType.isEmpty()) {
+ QFileInfo fi(url.path());
+ mimeType = mimeTypeForExtension(fi.suffix());
+ }
+ QString name = nameForMimetype(mimeType);
+ QWebObjectPlugin *plugin = qobject_cast<QWebObjectPlugin *>(instance(name));
+ if (!plugin)
+ return 0;
+ QWebObjectPluginConnector *connector = new QWebObjectPluginConnector(frame);
+ return plugin->create(connector, url, mimeType, argumentNames, argumentValues);
+}
+
+
+
+/*! \class QWebObjectPlugin
+
+ This class is a plugin for the HTML object tag. It can be used to embed arbitrary content in a web page.
+*/
+
+
+QWebObjectPlugin::QWebObjectPlugin(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QWebObjectPlugin::~QWebObjectPlugin()
+{
+}
+
+/*!
+ \fn QStringList QWebObjectPlugin::keys() const
+
+ The keys should be unique names.
+*/
+
+/*!
+ A description for \a key.
+*/
+QString QWebObjectPlugin::descriptionForKey(const QString &key) const
+{
+ return QString();
+}
+
+/*!
+ returns the mimetypes that can be handled by \a key.
+*/
+QStringList QWebObjectPlugin::mimetypesForKey(const QString &key) const
+{
+ return QStringList();
+}
+
+
+/*!
+ \fn QStringList QWebObjectPlugin::extensionsForMimetype() const
+
+ Should return a list of extensions that are recognised to match the \a mimeType.
+*/
+QStringList QWebObjectPlugin::extensionsForMimetype(const QString &mimeType) const
+{
+ return QStringList();
+}
+
+/*!
+ \fn QObject *QWebObjectPlugin::create(QWebObjectPluginConnector *connector, const QUrl &url, const QString &mimeType, const QStringList &argumentNames, const QStringList &argumentValues) const
+
+ Creates a QObject with \a connector to handle \a mimeType. \a argumentNames and \a argumentValues are a set of key-value pairs passed directly
+ from the &lt;param&gt; elements contained in the HTML object tag.
+*/
+
+#endif
diff --git a/WebKit/qt/Api/qwebobjectplugin.h b/WebKit/qt/Api/qwebobjectplugin.h
new file mode 100644
index 0000000..3c7caf7
--- /dev/null
+++ b/WebKit/qt/Api/qwebobjectplugin.h
@@ -0,0 +1,66 @@
+/*
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+*/
+#ifndef QWEBOBJECTPLUGIN_H
+#define QWEBOBJECTPLUGIN_H
+
+#include "qwebkitglobal.h"
+#include <QtCore/qplugin.h>
+#include <QtCore/qfactoryinterface.h>
+
+#if QT_VERSION < 0x040400
+
+class QWebObjectPluginConnector;
+class QUrl;
+
+struct QWEBKIT_EXPORT QWebObjectPluginFactoryInterface : public QFactoryInterface
+{
+ virtual QObject *create(QWebObjectPluginConnector *connector,
+ const QUrl &url,
+ const QString &mimeType,
+ const QStringList &argumentNames,
+ const QStringList &argumentValues) const = 0;
+};
+
+#define QWebObjectPluginFactoryInterface_iid "com.trolltech.Qt.QWebObjectPluginFactoryInterface"
+Q_DECLARE_INTERFACE(QWebObjectPluginFactoryInterface, QWebObjectPluginFactoryInterface_iid)
+
+class QWEBKIT_EXPORT QWebObjectPlugin : public QObject, public QWebObjectPluginFactoryInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QWebObjectPluginFactoryInterface:QFactoryInterface)
+public:
+ explicit QWebObjectPlugin(QObject *parent = 0);
+ virtual ~QWebObjectPlugin();
+
+ virtual QStringList keys() const = 0;
+
+ 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 = 0;
+};
+
+#endif
+
+#endif
diff --git a/WebKit/qt/Api/qwebobjectplugin_p.h b/WebKit/qt/Api/qwebobjectplugin_p.h
new file mode 100644
index 0000000..e20261f
--- /dev/null
+++ b/WebKit/qt/Api/qwebobjectplugin_p.h
@@ -0,0 +1,76 @@
+#ifndef QWEBOBJECTPLUGIN_P_H
+#define QWEBOBJECTPLUGIN_P_H
+
+#include <QtCore/qglobal.h>
+#include "qwebobjectplugin.h"
+
+#if QT_VERSION < 0x040400
+
+/*
+ FIXME: This is copied from qfactoryloader_p.h.
+ Remove this once we made qfactoryloader public in Qt
+*/
+class QFactoryLoaderPrivate;
+
+class Q_CORE_EXPORT QFactoryLoader : public QObject
+{
+ Q_OBJECT_FAKE
+ Q_DECLARE_PRIVATE(QFactoryLoader)
+
+public:
+ QFactoryLoader(const char *iid,
+ const QStringList &paths = QStringList(),
+ const QString &suffix = QString(),
+ Qt::CaseSensitivity = Qt::CaseSensitive);
+ ~QFactoryLoader();
+
+ QStringList keys() const;
+ QObject *instance(const QString &key) const;
+
+};
+
+class QWebFrame;
+
+class QWebFactoryLoader : public QFactoryLoader
+{
+ Q_OBJECT
+public:
+ QWebFactoryLoader(const char *iid,
+ const QStringList &paths = QStringList(),
+ const QString &suffix = QString(),
+ Qt::CaseSensitivity = Qt::CaseSensitive);
+
+ static QWebFactoryLoader *self();
+
+ QStringList names() const { return keys(); }
+ QStringList extensions() const;
+ QString descriptionForName(const QString &key) const;
+ QStringList mimetypesForName(const QString &key) const;
+ QString nameForMimetype(const QString &mimeType) const;
+ inline bool supportsMimeType(const QString &mimeType) const {
+ return !nameForMimetype(mimeType).isEmpty();
+ }
+
+ QString mimeTypeForExtension(const QString &extension);
+
+ QObject *create(QWebFrame *frame,
+ const QUrl &url,
+ const QString &mimeType,
+ const QStringList &argumentNames,
+ const QStringList &argumentValues);
+
+ struct MimeInfo {
+ QString type;
+ QStringList extensions;
+ };
+ struct Info {
+ QString name;
+ QString description;
+ QList<MimeInfo> mimes;
+ };
+ QList<Info> m_pluginInfo;
+};
+
+#endif
+
+#endif
diff --git a/WebKit/qt/Api/qwebobjectpluginconnector.cpp b/WebKit/qt/Api/qwebobjectpluginconnector.cpp
new file mode 100644
index 0000000..f53c164
--- /dev/null
+++ b/WebKit/qt/Api/qwebobjectpluginconnector.cpp
@@ -0,0 +1,64 @@
+/*
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+*/
+#include "qwebobjectpluginconnector.h"
+#if QT_VERSION < 0x040400
+#include "qwebnetworkinterface.h"
+#include "qwebnetworkinterface_p.h"
+#include "qwebframe.h"
+#include "qwebpage.h"
+
+struct QWebObjectPluginConnectorPrivate
+{
+ QWebFrame *frame;
+};
+
+QWebObjectPluginConnector::QWebObjectPluginConnector(QWebFrame *frame)
+{
+ d = new QWebObjectPluginConnectorPrivate;
+ d->frame = frame;
+}
+
+QWebFrame *QWebObjectPluginConnector::frame() const
+{
+ return d->frame;
+}
+
+QWidget *QWebObjectPluginConnector::pluginParentWidget() const
+{
+ return d->frame->page()->view();
+}
+
+QWebNetworkJob *QWebObjectPluginConnector::requestUrl(const QWebNetworkRequest &request, Target target)
+{
+ if (target != Plugin)
+ return 0;
+
+ QWebNetworkJob *job = new QWebNetworkJob;
+ QWebNetworkJobPrivate *p = job->d;
+ p->interface = d->frame->page()->networkInterface();
+ p->connector = this;
+
+ p->request = *request.d;
+
+ d->frame->page()->networkInterface()->addJob(job);
+ return job;
+}
+
+#endif
diff --git a/WebKit/qt/Api/qwebobjectpluginconnector.h b/WebKit/qt/Api/qwebobjectpluginconnector.h
new file mode 100644
index 0000000..62251a3
--- /dev/null
+++ b/WebKit/qt/Api/qwebobjectpluginconnector.h
@@ -0,0 +1,69 @@
+/*
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+*/
+#ifndef QWEBOBJECTPLUGINCONNECTOR_H
+#define QWEBOBJECTPLUGINCONNECTOR_H
+
+#include "qwebkitglobal.h"
+#include <QtCore/qobject.h>
+
+#if QT_VERSION < 0x040400
+
+#include "qwebnetworkinterface.h"
+
+class QWebFrame;
+class QWebPage;
+class QWidget;
+class QUrl;
+class QWebObjectPluginConnectorPrivate;
+class QWebFactoryLoader;
+class QWebNetworkManager;
+
+class QWEBKIT_EXPORT QWebObjectPluginConnector : public QObject
+{
+ Q_OBJECT
+public:
+ QWebFrame *frame() const;
+ QWidget *pluginParentWidget() const;
+
+ enum Target {
+ Plugin,
+ New,
+ Self,
+ Parent,
+ Top
+ };
+ QWebNetworkJob *requestUrl(const QWebNetworkRequest &request, Target target = Plugin);
+
+signals:
+ void started(QWebNetworkJob*);
+ void data(QWebNetworkJob*, const QByteArray &data);
+ void finished(QWebNetworkJob*, int errorCode);
+
+private:
+ friend class QWebFactoryLoader;
+ friend class QWebNetworkManager;
+ QWebObjectPluginConnector(QWebFrame *frame);
+
+ QWebObjectPluginConnectorPrivate *d;
+};
+
+#endif
+
+#endif
diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp
new file mode 100644
index 0000000..6e5e984
--- /dev/null
+++ b/WebKit/qt/Api/qwebpage.cpp
@@ -0,0 +1,1593 @@
+/*
+ Copyright (C) 2007 Trolltech ASA
+ Copyright (C) 2007 Staikos Computing Services Inc.
+ Copyright (C) 2007 Apple Inc.
+
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, 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 "config.h"
+#include "qwebpage.h"
+#include "qwebview.h"
+#include "qwebframe.h"
+#include "qwebpage_p.h"
+#include "qwebframe_p.h"
+#include "qwebhistory.h"
+#include "qwebhistory_p.h"
+#include "qwebsettings.h"
+
+#include "Frame.h"
+#include "FrameLoaderClientQt.h"
+#include "ChromeClientQt.h"
+#include "ContextMenu.h"
+#include "ContextMenuClientQt.h"
+#include "DragClientQt.h"
+#include "DragController.h"
+#include "DragData.h"
+#include "EditorClientQt.h"
+#include "Settings.h"
+#include "Page.h"
+#include "FrameLoader.h"
+#include "FrameLoadRequest.h"
+#include "KURL.h"
+#include "Image.h"
+#include "InspectorClientQt.h"
+#include "InspectorController.h"
+#include "FocusController.h"
+#include "Editor.h"
+#include "PlatformScrollBar.h"
+#include "PlatformKeyboardEvent.h"
+#include "PlatformWheelEvent.h"
+#include "ProgressTracker.h"
+#include "RefPtr.h"
+#include "HashMap.h"
+#include "HitTestResult.h"
+#include "WindowFeatures.h"
+#include "LocalizedStrings.h"
+
+#include <QDebug>
+#include <QDragEnterEvent>
+#include <QDragLeaveEvent>
+#include <QDragMoveEvent>
+#include <QDropEvent>
+#include <QFileDialog>
+#include <QHttpRequestHeader>
+#include <QInputDialog>
+#include <QMessageBox>
+#include <QNetworkProxy>
+#include <QUndoStack>
+#include <QUrl>
+#include <QPainter>
+#if QT_VERSION >= 0x040400
+#include <QNetworkAccessManager>
+#include <QNetworkRequest>
+#else
+#include "qwebnetworkinterface.h"
+#endif
+
+using namespace WebCore;
+
+static inline DragOperation dropActionToDragOp(Qt::DropActions actions)
+{
+ unsigned result = 0;
+ if (actions & Qt::CopyAction)
+ result |= DragOperationCopy;
+ if (actions & Qt::MoveAction)
+ result |= DragOperationMove;
+ if (actions & Qt::LinkAction)
+ result |= DragOperationLink;
+ return (DragOperation)result;
+}
+
+static inline Qt::DropAction dragOpToDropAction(unsigned actions)
+{
+ Qt::DropAction result = Qt::IgnoreAction;
+ if (actions & DragOperationCopy)
+ result = Qt::CopyAction;
+ else if (actions & DragOperationMove)
+ result = Qt::MoveAction;
+ else if (actions & DragOperationLink)
+ result = Qt::LinkAction;
+ return result;
+}
+
+QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
+ : q(qq)
+ , view(0)
+ , modified(false)
+{
+ chromeClient = new ChromeClientQt(q);
+ contextMenuClient = new ContextMenuClientQt();
+ editorClient = new EditorClientQt(q);
+ page = new Page(chromeClient, contextMenuClient, editorClient,
+ new DragClientQt(q), new InspectorClientQt(q));
+
+ // ### should be configurable
+ page->settings()->setDefaultTextEncodingName("iso-8859-1");
+
+ settings = new QWebSettings(page->settings());
+
+ undoStack = 0;
+ mainFrame = 0;
+#if QT_VERSION < 0x040400
+ networkInterface = 0;
+#else
+ networkManager = 0;
+#endif
+ insideOpenCall = false;
+
+ history.d = new QWebHistoryPrivate(page->backForwardList());
+ memset(actions, 0, sizeof(actions));
+}
+
+QWebPagePrivate::~QWebPagePrivate()
+{
+ delete undoStack;
+ delete settings;
+ delete page;
+#if QT_VERSION >= 0x040400
+ delete networkManager;
+#endif
+}
+
+#if QT_VERSION < 0x040400
+QWebPage::NavigationRequestResponse QWebPagePrivate::navigationRequested(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type)
+{
+ if (insideOpenCall
+ && frame == mainFrame)
+ return QWebPage::AcceptNavigationRequest;
+ return q->navigationRequested(frame, request, type);
+}
+#else
+QWebPage::NavigationRequestResponse QWebPagePrivate::navigationRequested(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
+{
+ if (insideOpenCall
+ && frame == mainFrame)
+ return QWebPage::AcceptNavigationRequest;
+ return q->navigationRequested(frame, request, type);
+}
+#endif
+
+void QWebPagePrivate::createMainFrame()
+{
+ if (!mainFrame) {
+ QWebFrameData frameData;
+ frameData.ownerElement = 0;
+ frameData.allowsScrolling = true;
+ frameData.marginWidth = 0;
+ frameData.marginHeight = 0;
+ mainFrame = new QWebFrame(q, &frameData);
+ mainFrame->d->frameView->setFrameGeometry(IntRect(IntPoint(0,0), q->viewportSize()));
+
+ emit q->frameCreated(mainFrame);
+ }
+}
+
+static QWebPage::WebAction webActionForContextMenuAction(WebCore::ContextMenuAction action)
+{
+ switch (action) {
+ case WebCore::ContextMenuItemTagOpenLink: return QWebPage::OpenLink;
+ case WebCore::ContextMenuItemTagOpenLinkInNewWindow: return QWebPage::OpenLinkInNewWindow;
+ case WebCore::ContextMenuItemTagDownloadLinkToDisk: return QWebPage::DownloadLinkToDisk;
+ case WebCore::ContextMenuItemTagCopyLinkToClipboard: return QWebPage::CopyLinkToClipboard;
+ case WebCore::ContextMenuItemTagOpenImageInNewWindow: return QWebPage::OpenImageInNewWindow;
+ case WebCore::ContextMenuItemTagDownloadImageToDisk: return QWebPage::DownloadImageToDisk;
+ case WebCore::ContextMenuItemTagCopyImageToClipboard: return QWebPage::CopyImageToClipboard;
+ case WebCore::ContextMenuItemTagOpenFrameInNewWindow: return QWebPage::OpenFrameInNewWindow;
+ case WebCore::ContextMenuItemTagCopy: return QWebPage::Copy;
+ case WebCore::ContextMenuItemTagGoBack: return QWebPage::GoBack;
+ case WebCore::ContextMenuItemTagGoForward: return QWebPage::GoForward;
+ case WebCore::ContextMenuItemTagStop: return QWebPage::Stop;
+ case WebCore::ContextMenuItemTagReload: return QWebPage::Reload;
+ case WebCore::ContextMenuItemTagCut: return QWebPage::Cut;
+ case WebCore::ContextMenuItemTagPaste: return QWebPage::Paste;
+ case WebCore::ContextMenuItemTagDefaultDirection: return QWebPage::SetTextDirectionDefault;
+ case WebCore::ContextMenuItemTagLeftToRight: return QWebPage::SetTextDirectionLeftToRight;
+ case WebCore::ContextMenuItemTagRightToLeft: return QWebPage::SetTextDirectionRightToLeft;
+ case WebCore::ContextMenuItemTagBold: return QWebPage::ToggleBold;
+ case WebCore::ContextMenuItemTagItalic: return QWebPage::ToggleItalic;
+ case WebCore::ContextMenuItemTagUnderline: return QWebPage::ToggleUnderline;
+ case WebCore::ContextMenuItemTagInspectElement: return QWebPage::InspectElement;
+ default: break;
+ }
+ return QWebPage::NoWebAction;
+}
+
+QMenu *QWebPagePrivate::createContextMenu(const WebCore::ContextMenu *webcoreMenu, const QList<WebCore::ContextMenuItem> *items)
+{
+ QMenu *menu = new QMenu;
+ for (int i = 0; i < items->count(); ++i) {
+ const ContextMenuItem &item = items->at(i);
+ switch (item.type()) {
+ case WebCore::CheckableActionType: /* fall through */
+ case WebCore::ActionType: {
+ QWebPage::WebAction action = webActionForContextMenuAction(item.action());
+ QAction *a = q->action(action);
+ if (a) {
+ ContextMenuItem it(item);
+ webcoreMenu->checkOrEnableIfNeeded(it);
+ PlatformMenuItemDescription desc = it.releasePlatformDescription();
+ a->setEnabled(desc.enabled);
+ a->setChecked(desc.checked);
+ a->setCheckable(item.type() == WebCore::CheckableActionType);
+
+ menu->addAction(a);
+ }
+ break;
+ }
+ case WebCore::SeparatorType:
+ menu->addSeparator();
+ break;
+ case WebCore::SubmenuType: {
+ QMenu *subMenu = createContextMenu(webcoreMenu, item.platformSubMenu());
+ if (!subMenu->actions().isEmpty()) {
+ subMenu->setTitle(item.title());
+ menu->addAction(subMenu->menuAction());
+ } else {
+ delete subMenu;
+ }
+ break;
+ }
+ }
+ }
+ return menu;
+}
+
+QWebFrame *QWebPagePrivate::frameAt(const QPoint &pos) const
+{
+ QWebFrame *frame = mainFrame;
+
+redo:
+ QList<QWebFrame*> children = frame->childFrames();
+ for (int i = 0; i < children.size(); ++i) {
+ if (children.at(i)->geometry().contains(pos)) {
+ frame = children.at(i);
+ goto redo;
+ }
+ }
+ if (frame->geometry().contains(pos))
+ return frame;
+ return 0;
+}
+
+void QWebPagePrivate::_q_webActionTriggered(bool checked)
+{
+ QAction *a = qobject_cast<QAction *>(q->sender());
+ if (!a)
+ return;
+ QWebPage::WebAction action = static_cast<QWebPage::WebAction>(a->data().toInt());
+ q->triggerAction(action, checked);
+}
+
+void QWebPagePrivate::updateAction(QWebPage::WebAction action)
+{
+ QAction *a = actions[action];
+ if (!a || !mainFrame)
+ return;
+
+ WebCore::FrameLoader *loader = mainFrame->d->frame->loader();
+ WebCore::Editor *editor = page->focusController()->focusedOrMainFrame()->editor();
+
+ bool enabled = a->isEnabled();
+
+ switch (action) {
+ case QWebPage::GoBack:
+ enabled = loader->canGoBackOrForward(-1);
+ break;
+ case QWebPage::GoForward:
+ enabled = loader->canGoBackOrForward(1);
+ break;
+ case QWebPage::Stop:
+ enabled = loader->isLoading();
+ break;
+ case QWebPage::Reload:
+ enabled = !loader->isLoading();
+ break;
+ case QWebPage::Cut:
+ enabled = editor->canCut();
+ break;
+ case QWebPage::Copy:
+ enabled = editor->canCopy();
+ break;
+ case QWebPage::Paste:
+ enabled = editor->canPaste();
+ break;
+ case QWebPage::Undo:
+ case QWebPage::Redo:
+ // those two are handled by QUndoStack
+ break;
+ default: break;
+ }
+
+ a->setEnabled(enabled);
+}
+
+void QWebPagePrivate::updateNavigationActions()
+{
+ updateAction(QWebPage::GoBack);
+ updateAction(QWebPage::GoForward);
+ updateAction(QWebPage::Stop);
+ updateAction(QWebPage::Reload);
+}
+
+void QWebPagePrivate::updateEditorActions()
+{
+ updateAction(QWebPage::Cut);
+ updateAction(QWebPage::Copy);
+ updateAction(QWebPage::Paste);
+}
+
+void QWebPagePrivate::mouseMoveEvent(QMouseEvent *ev)
+{
+ QWebFramePrivate::core(mainFrame)->eventHandler()->mouseMoved(PlatformMouseEvent(ev, 0));
+}
+
+void QWebPagePrivate::mousePressEvent(QMouseEvent *ev)
+{
+ QWebFramePrivate::core(mainFrame)->eventHandler()->handleMousePressEvent(PlatformMouseEvent(ev, 1));
+}
+
+void QWebPagePrivate::mouseDoubleClickEvent(QMouseEvent *ev)
+{
+ QWebFramePrivate::core(mainFrame)->eventHandler()->handleMousePressEvent(PlatformMouseEvent(ev, 2));
+}
+
+void QWebPagePrivate::mouseReleaseEvent(QMouseEvent *ev)
+{
+ QWebFramePrivate::core(mainFrame)->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(ev, 0));
+}
+
+void QWebPagePrivate::contextMenuEvent(QContextMenuEvent *ev)
+{
+ page->contextMenuController()->clearContextMenu();
+
+ WebCore::Frame* focusedFrame = page->focusController()->focusedOrMainFrame();
+ focusedFrame->eventHandler()->sendContextMenuEvent(PlatformMouseEvent(ev, 1));
+ ContextMenu *menu = page->contextMenuController()->contextMenu();
+ // If the website defines its own handler then sendContextMenuEvent takes care of
+ // calling/showing it and the context menu pointer will be zero. This is the case
+ // on maps.google.com for example.
+ if (!menu)
+ return;
+
+ QWebPageContext oldContext = currentContext;
+ currentContext = QWebPageContext(menu->hitTestResult());
+
+ const QList<ContextMenuItem> *items = menu->platformDescription();
+ QMenu *qmenu = createContextMenu(menu, items);
+ if (qmenu) {
+ qmenu->exec(ev->globalPos());
+ delete qmenu;
+ }
+ currentContext = oldContext;
+}
+
+void QWebPagePrivate::wheelEvent(QWheelEvent *ev)
+{
+ WebCore::PlatformWheelEvent pev(ev);
+ bool accepted = QWebFramePrivate::core(mainFrame)->eventHandler()->handleWheelEvent(pev);
+ ev->setAccepted(accepted);
+}
+
+void QWebPagePrivate::keyPressEvent(QKeyEvent *ev)
+{
+ bool handled = false;
+ WebCore::Frame *frame = page->focusController()->focusedOrMainFrame();
+ WebCore::Editor *editor = frame->editor();
+ if (editor->canEdit()) {
+ if (ev == QKeySequence::Cut) {
+ q->triggerAction(QWebPage::Cut);
+ handled = true;
+ } else if (ev == QKeySequence::Copy) {
+ q->triggerAction(QWebPage::Copy);
+ handled = true;
+ } else if (ev == QKeySequence::Paste) {
+ q->triggerAction(QWebPage::Paste);
+ handled = true;
+ } else if (ev == QKeySequence::Undo) {
+ q->triggerAction(QWebPage::Undo);
+ handled = true;
+ } else if (ev == QKeySequence::Redo) {
+ q->triggerAction(QWebPage::Redo);
+ handled = true;
+ } else if(ev == QKeySequence::MoveToNextChar) {
+ q->triggerAction(QWebPage::MoveToNextChar);
+ handled = true;
+ } else if(ev == QKeySequence::MoveToPreviousChar) {
+ q->triggerAction(QWebPage::MoveToPreviousChar);
+ handled = true;
+ } else if(ev == QKeySequence::MoveToNextWord) {
+ q->triggerAction(QWebPage::MoveToNextWord);
+ handled = true;
+ } else if(ev == QKeySequence::MoveToPreviousWord) {
+ q->triggerAction(QWebPage::MoveToPreviousWord);
+ handled = true;
+ } else if(ev == QKeySequence::MoveToNextLine) {
+ q->triggerAction(QWebPage::MoveToNextLine);
+ handled = true;
+ } else if(ev == QKeySequence::MoveToPreviousLine) {
+ q->triggerAction(QWebPage::MoveToPreviousLine);
+ handled = true;
+// } else if(ev == QKeySequence::MoveToNextPage) {
+// } else if(ev == QKeySequence::MoveToPreviousPage) {
+ } else if(ev == QKeySequence::MoveToStartOfLine) {
+ q->triggerAction(QWebPage::MoveToStartOfLine);
+ handled = true;
+ } else if(ev == QKeySequence::MoveToEndOfLine) {
+ q->triggerAction(QWebPage::MoveToEndOfLine);
+ handled = true;
+ } else if(ev == QKeySequence::MoveToStartOfBlock) {
+ q->triggerAction(QWebPage::MoveToStartOfBlock);
+ handled = true;
+ } else if(ev == QKeySequence::MoveToEndOfBlock) {
+ q->triggerAction(QWebPage::MoveToEndOfBlock);
+ handled = true;
+ } else if(ev == QKeySequence::MoveToStartOfDocument) {
+ q->triggerAction(QWebPage::MoveToStartOfDocument);
+ handled = true;
+ } else if(ev == QKeySequence::MoveToEndOfDocument) {
+ q->triggerAction(QWebPage::MoveToEndOfDocument);
+ handled = true;
+ } else if(ev == QKeySequence::SelectNextChar) {
+ q->triggerAction(QWebPage::SelectNextChar);
+ handled = true;
+ } else if(ev == QKeySequence::SelectPreviousChar) {
+ q->triggerAction(QWebPage::SelectPreviousChar);
+ handled = true;
+ } else if(ev == QKeySequence::SelectNextWord) {
+ q->triggerAction(QWebPage::SelectNextWord);
+ handled = true;
+ } else if(ev == QKeySequence::SelectPreviousWord) {
+ q->triggerAction(QWebPage::SelectPreviousWord);
+ handled = true;
+ } else if(ev == QKeySequence::SelectNextLine) {
+ q->triggerAction(QWebPage::SelectNextLine);
+ handled = true;
+ } else if(ev == QKeySequence::SelectPreviousLine) {
+ q->triggerAction(QWebPage::SelectPreviousLine);
+ handled = true;
+// } else if(ev == QKeySequence::SelectNextPage) {
+// } else if(ev == QKeySequence::SelectPreviousPage) {
+ } else if(ev == QKeySequence::SelectStartOfLine) {
+ q->triggerAction(QWebPage::SelectStartOfLine);
+ handled = true;
+ } else if(ev == QKeySequence::SelectEndOfLine) {
+ q->triggerAction(QWebPage::SelectEndOfLine);
+ handled = true;
+ } else if(ev == QKeySequence::SelectStartOfBlock) {
+ q->triggerAction(QWebPage::SelectStartOfBlock);
+ handled = true;
+ } else if(ev == QKeySequence::SelectEndOfBlock) {
+ q->triggerAction(QWebPage::SelectEndOfBlock);
+ handled = true;
+ } else if(ev == QKeySequence::SelectStartOfDocument) {
+ q->triggerAction(QWebPage::SelectStartOfDocument);
+ handled = true;
+ } else if(ev == QKeySequence::SelectEndOfDocument) {
+ q->triggerAction(QWebPage::SelectEndOfDocument);
+ handled = true;
+ } else if(ev == QKeySequence::DeleteStartOfWord) {
+ q->triggerAction(QWebPage::DeleteStartOfWord);
+ handled = true;
+ } else if(ev == QKeySequence::DeleteEndOfWord) {
+ q->triggerAction(QWebPage::DeleteEndOfWord);
+ handled = true;
+// } else if(ev == QKeySequence::DeleteEndOfLine) {
+ }
+ }
+ if (!handled)
+ handled = frame->eventHandler()->keyEvent(ev);
+ if (!handled) {
+ handled = true;
+ PlatformScrollbar *h, *v;
+ h = mainFrame->d->horizontalScrollBar();
+ v = mainFrame->d->verticalScrollBar();
+ QFont defaultFont;
+ if (view)
+ defaultFont = view->font();
+ QFontMetrics fm(defaultFont);
+ int fontHeight = fm.height();
+ if (ev == QKeySequence::MoveToNextPage
+ || ev->key() == Qt::Key_Space) {
+ if (v)
+ v->setValue(v->value() + q->viewportSize().height() - fontHeight);
+ } else if (ev == QKeySequence::MoveToPreviousPage) {
+ if (v)
+ v->setValue(v->value() - q->viewportSize().height() + fontHeight);
+ } else if (ev->key() == Qt::Key_Up && ev->modifiers() == Qt::ControlModifier) {
+ if (v)
+ v->setValue(0);
+ } else if (ev->key() == Qt::Key_Down && ev->modifiers() == Qt::ControlModifier) {
+ if (v)
+ v->setValue(INT_MAX);
+ } else {
+ switch (ev->key()) {
+ case Qt::Key_Up:
+ if (v)
+ v->setValue(v->value() - fontHeight);
+ break;
+ case Qt::Key_Down:
+ if (v)
+ v->setValue(v->value() + fontHeight);
+ break;
+ case Qt::Key_Left:
+ if (h)
+ h->setValue(h->value() - fontHeight);
+ break;
+ case Qt::Key_Right:
+ if (h)
+ h->setValue(h->value() + fontHeight);
+ break;
+ case Qt::Key_Backspace:
+ if (ev->modifiers() == Qt::ShiftModifier)
+ q->triggerAction(QWebPage::GoForward);
+ else
+ q->triggerAction(QWebPage::GoBack);
+ default:
+ handled = false;
+ break;
+ }
+ }
+ }
+
+ ev->setAccepted(handled);
+}
+
+void QWebPagePrivate::keyReleaseEvent(QKeyEvent *ev)
+{
+ if (ev->isAutoRepeat()) {
+ ev->setAccepted(true);
+ return;
+ }
+
+ WebCore::Frame* frame = page->focusController()->focusedOrMainFrame();
+ bool handled = frame->eventHandler()->keyEvent(ev);
+ ev->setAccepted(handled);
+}
+
+void QWebPagePrivate::focusInEvent(QFocusEvent *ev)
+{
+ if (ev->reason() != Qt::PopupFocusReason)
+ page->focusController()->setFocusedFrame(QWebFramePrivate::core(mainFrame));
+}
+
+void QWebPagePrivate::focusOutEvent(QFocusEvent *ev)
+{
+ if (ev->reason() != Qt::PopupFocusReason)
+ page->focusController()->setFocusedFrame(0);
+}
+
+void QWebPagePrivate::dragEnterEvent(QDragEnterEvent *ev)
+{
+#ifndef QT_NO_DRAGANDDROP
+ DragData dragData(ev->mimeData(), ev->pos(), QCursor::pos(),
+ dropActionToDragOp(ev->possibleActions()));
+ Qt::DropAction action = dragOpToDropAction(page->dragController()->dragEntered(&dragData));
+ ev->setDropAction(action);
+ ev->accept();
+#endif
+}
+
+void QWebPagePrivate::dragLeaveEvent(QDragLeaveEvent *ev)
+{
+#ifndef QT_NO_DRAGANDDROP
+ DragData dragData(0, IntPoint(), QCursor::pos(), DragOperationNone);
+ page->dragController()->dragExited(&dragData);
+ ev->accept();
+#endif
+}
+
+void QWebPagePrivate::dragMoveEvent(QDragMoveEvent *ev)
+{
+#ifndef QT_NO_DRAGANDDROP
+ DragData dragData(ev->mimeData(), ev->pos(), QCursor::pos(),
+ dropActionToDragOp(ev->possibleActions()));
+ Qt::DropAction action = dragOpToDropAction(page->dragController()->dragUpdated(&dragData));
+ ev->setDropAction(action);
+ ev->accept();
+#endif
+}
+
+void QWebPagePrivate::dropEvent(QDropEvent *ev)
+{
+#ifndef QT_NO_DRAGANDDROP
+ DragData dragData(ev->mimeData(), ev->pos(), QCursor::pos(),
+ dropActionToDragOp(ev->possibleActions()));
+ Qt::DropAction action = dragOpToDropAction(page->dragController()->performDrag(&dragData));
+ ev->accept();
+#endif
+}
+
+/*!
+ \enum QWebPage::WebAction
+
+ \value NoWebAction No action is triggered.
+ \value OpenLink Open the current link.
+ \value OpenLinkInNewWindow Open the current link in a new window.
+ \value OpenFrameInNewWindow Replicate the current frame in a new window.
+ \value DownloadLinkToDisk Download the current link to the disk.
+ \value CopyLinkToClipboard Copy the current link to the clipboard.
+ \value OpenImageInNewWindow Open the highlighted image in a new window.
+ \value DownloadImageToDisk Download the highlighted image to the disk.
+ \value CopyImageToClipboard Copy the highlighted image to the clipboard.
+ \value GoBack Navigate back in the history of navigated links.
+ \value GoForward Navigate forward in the history of navigated links.
+ \value Stop Stop loading the current page.
+ \value Reload Reload the current page.
+ \value Cut Cut the content currently selected into the clipboard.
+ \value Copy Copy the content currently selected into the clipboard.
+ \value Paste Paste content from the clipboard.
+ \value Undo Undo the last editing action.
+ \value Redo Redo the last editing action.
+ \value MoveToNextChar Move the cursor to the next character.
+ \value MoveToPreviousChar Move the cursor to the previous character.
+ \value MoveToNextWord Move the cursor to the next word.
+ \value MoveToPreviousWord Move the cursor to the previous word.
+ \value MoveToNextLine Move the cursor to the next line.
+ \value MoveToPreviousLine Move the cursor to the previous line.
+ \value MoveToStartOfLine Move the cursor to the start of the line.
+ \value MoveToEndOfLine Move the cursor to the end of the line.
+ \value MoveToStartOfBlock Move the cursor to the start of the block.
+ \value MoveToEndOfBlock Move the cursor to the end of the block.
+ \value MoveToStartOfDocument Move the cursor to the start of the document.
+ \value MoveToEndOfDocument Move the cursor to the end of the document.
+ \value SelectNextChar Select to the next character.
+ \value SelectPreviousChar Select to the previous character.
+ \value SelectNextWord Select to the next word.
+ \value SelectPreviousWord Select to the previous word.
+ \value SelectNextLine Select to the next line.
+ \value SelectPreviousLine Select to the previous line.
+ \value SelectStartOfLine Select to the start of the line.
+ \value SelectEndOfLine Select to the end of the line.
+ \value SelectStartOfBlock Select to the start of the block.
+ \value SelectEndOfBlock Select to the end of the block.
+ \value SelectStartOfDocument Select to the start of the document.
+ \value SelectEndOfDocument Select to the end of the document.
+ \value DeleteStartOfWord Delete to the start of the word.
+ \value DeleteEndOfWord Delete to the end of the word.
+ \value SetTextDirectionDefault Set the text direction to the default direction.
+ \value SetTextDirectionLeftToRight Set the text direction to left-to-right.
+ \value SetTextDirectionRightToLeft Set the text direction to right-to-left.
+ \value ToggleBold Toggle the formatting between bold and normal weight.
+ \value ToggleItalic Toggle the formatting between italic and normal style.
+ \value ToggleUnderline Toggle underlining.
+ \value InspectElement Show the Web Inspector with the currently highlighted HTML element.
+ \omitvalue WebActionCount
+
+*/
+
+/*!
+ \class QWebPage
+ \since 4.4
+ \brief The QWebPage class provides a widget that is used to view and edit web documents.
+
+ QWebPage holds a main frame responsible for web content, settings, the history
+ of navigated links as well as actions. This class can be used, together with QWebFrame,
+ if you want to provide functionality like QWebView in a setup without widgets.
+*/
+
+/*!
+ Constructs an empty QWebView with parent \a parent.
+*/
+QWebPage::QWebPage(QObject *parent)
+ : QObject(parent)
+ , d(new QWebPagePrivate(this))
+{
+ setView(qobject_cast<QWidget *>(parent));
+
+ connect(this, SIGNAL(loadProgressChanged(int)), this, SLOT(_q_onLoadProgressChanged(int)));
+}
+
+/*!
+ Destructor.
+*/
+QWebPage::~QWebPage()
+{
+ FrameLoader *loader = d->mainFrame->d->frame->loader();
+ if (loader)
+ loader->detachFromParent();
+ delete d;
+}
+
+/*!
+ Returns the main frame of the page.
+
+ The main frame provides access to the hierarchy of sub-frames and is also needed if you
+ want to explicitly render a web page into a given painter.
+*/
+QWebFrame *QWebPage::mainFrame() const
+{
+ d->createMainFrame();
+ return d->mainFrame;
+}
+
+/*!
+ Returns the frame currently active.
+*/
+QWebFrame *QWebPage::currentFrame() const
+{
+ return static_cast<WebCore::FrameLoaderClientQt *>(d->page->focusController()->focusedOrMainFrame()->loader()->client())->webFrame();
+}
+
+/*!
+ Returns a pointer to the view's history of navigated web pages.
+
+*/
+QWebHistory *QWebPage::history() const
+{
+ return &d->history;
+}
+
+/*!
+ Sets the \a view that is associated with the web page.
+
+ \sa view()
+*/
+void QWebPage::setView(QWidget *view)
+{
+ d->view = view;
+ setViewportSize(view ? view->size() : QSize(0, 0));
+}
+
+/*!
+ Returns the view widget that is associated with the web page.
+
+ \sa setView()
+*/
+QWidget *QWebPage::view() const
+{
+ return d->view;
+}
+
+
+/*!
+ This function is called whenever a JavaScript program tries to print to what is the console in web browsers.
+*/
+void QWebPage::javaScriptConsoleMessage(const QString& message, unsigned int lineNumber, const QString& sourceID)
+{
+}
+
+/*!
+ This function is called whenever a JavaScript program calls the alert() function.
+*/
+void QWebPage::javaScriptAlert(QWebFrame *frame, const QString& msg)
+{
+ QMessageBox::information(d->view, mainFrame()->title(), msg, QMessageBox::Ok);
+}
+
+/*!
+ This function is called whenever a JavaScript program calls the confirm() function.
+*/
+bool QWebPage::javaScriptConfirm(QWebFrame *frame, const QString& msg)
+{
+ return 0 == QMessageBox::information(d->view, mainFrame()->title(), msg, QMessageBox::Yes, QMessageBox::No);
+}
+
+/*!
+ This function is called whenever a JavaScript program tries to prompt the user of input.
+*/
+bool QWebPage::javaScriptPrompt(QWebFrame *frame, const QString& msg, const QString& defaultValue, QString* result)
+{
+ bool ok = false;
+#ifndef QT_NO_INPUTDIALOG
+ QString x = QInputDialog::getText(d->view, mainFrame()->title(), msg, QLineEdit::Normal, defaultValue, &ok);
+ if (ok && result) {
+ *result = x;
+ }
+#endif
+ return ok;
+}
+
+/*!
+ This function is called whenever WebKit wants to create a new window, for example as a result of
+ a JavaScript request to open a document in a new window.
+*/
+QWebPage *QWebPage::createWindow()
+{
+ QWebView *webView = qobject_cast<QWebView *>(d->view);
+ if (webView) {
+ QWebView *newView = webView->createWindow();
+ if (newView)
+ return newView->page();
+ }
+ return 0;
+}
+
+/*!
+ This function is called whenever WebKit wants to create a new window that should act as a modal dialog.
+*/
+QWebPage *QWebPage::createModalDialog()
+{
+ return 0;
+}
+
+/*!
+ This function is called whenever WebKit encounters a HTML object element with type "application/x-qt-plugin".
+ The \a classid, \a url, \a paramNames and \a paramValues correspond to the HTML object element attributes and
+ child elements to configure the embeddable object.
+*/
+QObject *QWebPage::createPlugin(const QString &classid, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues)
+{
+ Q_UNUSED(classid)
+ Q_UNUSED(url)
+ Q_UNUSED(paramNames)
+ Q_UNUSED(paramValues)
+ return 0;
+}
+
+static WebCore::FrameLoadRequest frameLoadRequest(const QUrl &url, WebCore::Frame *frame)
+{
+ WebCore::ResourceRequest rr(url, frame->loader()->outgoingReferrer());
+ return WebCore::FrameLoadRequest(rr);
+}
+
+static void openNewWindow(const QUrl& url, WebCore::Frame* frame)
+{
+ if (Page* oldPage = frame->page()) {
+ WindowFeatures features;
+ if (Page* newPage = oldPage->chrome()->createWindow(frame,
+ frameLoadRequest(url, frame), features))
+ newPage->chrome()->show();
+ }
+}
+
+/*!
+ This function can be called to trigger the specified \a action.
+ It is also called by QtWebKit if the user triggers the action, for example
+ through a context menu item.
+
+ If \a action is a checkable action then \a checked specified whether the action
+ is toggled or not.
+*/
+void QWebPage::triggerAction(WebAction action, bool checked)
+{
+ WebCore::Frame *frame = d->page->focusController()->focusedOrMainFrame();
+ WebCore::Editor *editor = frame->editor();
+ const char *command = 0;
+
+ switch (action) {
+ case OpenLink:
+ if (QWebFrame *targetFrame = d->currentContext.targetFrame()) {
+ WTF::RefPtr<WebCore::Frame> wcFrame = targetFrame->d->frame;
+ targetFrame->d->frame->loader()->load(frameLoadRequest(d->currentContext.linkUrl(), wcFrame.get()),
+ /*lockHistory*/ false,
+ /*userGesture*/ true,
+ /*event*/ 0,
+ /*HTMLFormElement*/ 0,
+ /*formValues*/
+ WTF::HashMap<String, String>());
+ break;
+ } else {
+ }
+ // fall through
+ case OpenLinkInNewWindow:
+ openNewWindow(d->currentContext.linkUrl(), frame);
+ break;
+ case OpenFrameInNewWindow:
+ break;
+ case CopyLinkToClipboard:
+ editor->copyURL(d->currentContext.linkUrl(), d->currentContext.text());
+ break;
+ case OpenImageInNewWindow:
+ openNewWindow(d->currentContext.imageUrl(), frame);
+ break;
+ case DownloadImageToDisk:
+ case DownloadLinkToDisk:
+ frame->loader()->client()->startDownload(WebCore::ResourceRequest(d->currentContext.linkUrl(), frame->loader()->outgoingReferrer()));
+ break;
+ case CopyImageToClipboard:
+ break;
+ case GoBack:
+ d->page->goBack();
+ break;
+ case GoForward:
+ d->page->goForward();
+ break;
+ case Stop:
+ mainFrame()->d->frame->loader()->stopForUserCancel();
+ break;
+ case Reload:
+ mainFrame()->d->frame->loader()->reload();
+ break;
+ case Cut:
+ command = "Cut";
+ break;
+ case Copy:
+ command = "Copy";
+ break;
+ case Paste:
+ command = "Paste";
+ break;
+
+ case Undo:
+ command = "Undo";
+ break;
+ case Redo:
+ command = "Redo";
+ break;
+
+ case MoveToNextChar:
+ command = "MoveForward";
+ break;
+ case MoveToPreviousChar:
+ command = "MoveBackward";
+ break;
+ case MoveToNextWord:
+ command = "MoveWordForward";
+ break;
+ case MoveToPreviousWord:
+ command = "MoveWordBackward";
+ break;
+ case MoveToNextLine:
+ command = "MoveDown";
+ break;
+ case MoveToPreviousLine:
+ command = "MoveUp";
+ break;
+ case MoveToStartOfLine:
+ command = "MoveToBeginningOfLine";
+ break;
+ case MoveToEndOfLine:
+ command = "MoveToEndOfLine";
+ break;
+ case MoveToStartOfBlock:
+ command = "MoveToBeginningOfParagraph";
+ break;
+ case MoveToEndOfBlock:
+ command = "MoveToEndOfParagraph";
+ break;
+ case MoveToStartOfDocument:
+ command = "MoveToBeginningOfDocument";
+ break;
+ case MoveToEndOfDocument:
+ command = "MoveToEndOfDocument";
+ break;
+ case SelectNextChar:
+ command = "MoveForwardAndModifySelection";
+ break;
+ case SelectPreviousChar:
+ command = "MoveBackwardAndModifySelection";
+ break;
+ case SelectNextWord:
+ command = "MoveWordForwardAndModifySelection";
+ break;
+ case SelectPreviousWord:
+ command = "MoveWordBackwardAndModifySelection";
+ break;
+ case SelectNextLine:
+ command = "MoveDownAndModifySelection";
+ break;
+ case SelectPreviousLine:
+ command = "MoveUpAndModifySelection";
+ break;
+ case SelectStartOfLine:
+ command = "MoveToBeginningOfLineAndModifySelection";
+ break;
+ case SelectEndOfLine:
+ command = "MoveToEndOfLineAndModifySelection";
+ break;
+ case SelectStartOfBlock:
+ command = "MoveToBeginningOfParagraphAndModifySelection";
+ break;
+ case SelectEndOfBlock:
+ command = "MoveToEndOfParagraphAndModifySelection";
+ break;
+ case SelectStartOfDocument:
+ command = "MoveToBeginningOfDocumentAndModifySelection";
+ break;
+ case SelectEndOfDocument:
+ command = "MoveToEndOfDocumentAndModifySelection";
+ break;
+ case DeleteStartOfWord:
+ command = "DeleteWordBackward";
+ break;
+ case DeleteEndOfWord:
+ command = "DeleteWordForward";
+ break;
+
+ case SetTextDirectionDefault:
+ editor->setBaseWritingDirection("inherit");
+ break;
+ case SetTextDirectionLeftToRight:
+ editor->setBaseWritingDirection("ltr");
+ break;
+ case SetTextDirectionRightToLeft:
+ editor->setBaseWritingDirection("rtl");
+ break;
+
+ case ToggleBold:
+ command = "ToggleBold";
+ break;
+ case ToggleItalic:
+ command = "ToggleItalic";
+ break;
+ case ToggleUnderline:
+ editor->toggleUnderline();
+
+ case InspectElement:
+ d->page->inspectorController()->inspect(d->currentContext.d->innerNonSharedNode.get());
+ break;
+
+ default: break;
+ }
+
+ if (command)
+ editor->command(command).execute();
+}
+
+QSize QWebPage::viewportSize() const
+{
+ QWebFrame *frame = mainFrame();
+ if (frame->d->frame && frame->d->frameView)
+ return frame->d->frameView->frameGeometry().size();
+ return QSize(0, 0);
+}
+
+/*!
+ \property QWebPage::viewportSize
+
+ Specifies the size of the viewport. The size affects for example the visibility of scrollbars
+ if the document is larger than the viewport.
+*/
+void QWebPage::setViewportSize(const QSize &size) const
+{
+ QWebFrame *frame = mainFrame();
+ if (frame->d->frame && frame->d->frameView) {
+ frame->d->frameView->setFrameGeometry(QRect(QPoint(0, 0), size));
+ frame->d->frame->forceLayout();
+ frame->d->frame->view()->adjustViewSize();
+ }
+}
+
+
+#if QT_VERSION < 0x040400
+QWebPage::NavigationRequestResponse QWebPage::navigationRequested(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type)
+#else
+QWebPage::NavigationRequestResponse QWebPage::navigationRequested(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
+#endif
+{
+ Q_UNUSED(request)
+ return AcceptNavigationRequest;
+}
+
+/*!
+ \property QWebPage::selectedText
+
+ Returns the text currently selected.
+*/
+QString QWebPage::selectedText() const
+{
+ return d->page->focusController()->focusedOrMainFrame()->selectedText();
+}
+
+/*!
+ Returns a QAction for the specified WebAction \a action.
+
+ The action is owned by the QWebPage but you can customize the look by
+ changing its properties.
+
+ QWebPage also takes care of implementing the action, so that upon
+ triggering the corresponding action is performed on the page.
+*/
+QAction *QWebPage::action(WebAction action) const
+{
+ if (action == QWebPage::NoWebAction) return 0;
+ if (d->actions[action])
+ return d->actions[action];
+
+ QString text;
+ bool checkable = false;
+
+ switch (action) {
+ case OpenLink:
+ text = contextMenuItemTagOpenLink();
+ break;
+ case OpenLinkInNewWindow:
+ text = contextMenuItemTagOpenLinkInNewWindow();
+ break;
+ case OpenFrameInNewWindow:
+ text = contextMenuItemTagOpenFrameInNewWindow();
+ break;
+
+ case DownloadLinkToDisk:
+ text = contextMenuItemTagDownloadLinkToDisk();
+ break;
+ case CopyLinkToClipboard:
+ text = contextMenuItemTagCopyLinkToClipboard();
+ break;
+
+ case OpenImageInNewWindow:
+ text = contextMenuItemTagOpenImageInNewWindow();
+ break;
+ case DownloadImageToDisk:
+ text = contextMenuItemTagDownloadImageToDisk();
+ break;
+ case CopyImageToClipboard:
+ text = contextMenuItemTagCopyImageToClipboard();
+ break;
+
+ case GoBack:
+ text = contextMenuItemTagGoBack();
+ break;
+ case GoForward:
+ text = contextMenuItemTagGoForward();
+ break;
+ case Stop:
+ text = contextMenuItemTagStop();
+ break;
+ case Reload:
+ text = contextMenuItemTagReload();
+ break;
+
+ case Cut:
+ text = contextMenuItemTagCut();
+ break;
+ case Copy:
+ text = contextMenuItemTagCopy();
+ break;
+ case Paste:
+ text = contextMenuItemTagPaste();
+ break;
+
+ case Undo: {
+ QAction *a = undoStack()->createUndoAction(d->q);
+ d->actions[action] = a;
+ return a;
+ }
+ case Redo: {
+ QAction *a = undoStack()->createRedoAction(d->q);
+ d->actions[action] = a;
+ return a;
+ }
+ case MoveToNextChar:
+ case MoveToPreviousChar:
+ case MoveToNextWord:
+ case MoveToPreviousWord:
+ case MoveToNextLine:
+ case MoveToPreviousLine:
+ case MoveToStartOfLine:
+ case MoveToEndOfLine:
+ case MoveToStartOfBlock:
+ case MoveToEndOfBlock:
+ case MoveToStartOfDocument:
+ case MoveToEndOfDocument:
+ case SelectNextChar:
+ case SelectPreviousChar:
+ case SelectNextWord:
+ case SelectPreviousWord:
+ case SelectNextLine:
+ case SelectPreviousLine:
+ case SelectStartOfLine:
+ case SelectEndOfLine:
+ case SelectStartOfBlock:
+ case SelectEndOfBlock:
+ case SelectStartOfDocument:
+ case SelectEndOfDocument:
+ case DeleteStartOfWord:
+ case DeleteEndOfWord:
+ break; // ####
+
+ case SetTextDirectionDefault:
+ text = contextMenuItemTagDefaultDirection();
+ break;
+ case SetTextDirectionLeftToRight:
+ text = contextMenuItemTagLeftToRight();
+ checkable = true;
+ break;
+ case SetTextDirectionRightToLeft:
+ text = contextMenuItemTagRightToLeft();
+ checkable = true;
+ break;
+
+ case ToggleBold:
+ text = contextMenuItemTagBold();
+ checkable = true;
+ break;
+ case ToggleItalic:
+ text = contextMenuItemTagItalic();
+ checkable = true;
+ break;
+ case ToggleUnderline:
+ text = contextMenuItemTagUnderline();
+ checkable = true;
+ break;
+
+ case InspectElement:
+ text = contextMenuItemTagInspectElement();
+ break;
+
+ case NoWebAction:
+ return 0;
+ }
+
+ if (text.isEmpty())
+ return 0;
+
+ QAction *a = new QAction(d->q);
+ a->setText(text);
+ a->setData(action);
+ a->setCheckable(checkable);
+
+ connect(a, SIGNAL(triggered(bool)),
+ this, SLOT(_q_webActionTriggered(bool)));
+
+ d->actions[action] = a;
+ d->updateAction(action);
+ return a;
+}
+
+/*!
+ \property QWebPage::modified
+
+ Specifies if the page contains unsubmitted form data.
+*/
+bool QWebPage::isModified() const
+{
+ return d->modified;
+}
+
+
+/*!
+ Returns a pointer to the undo stack used for editable content.
+*/
+QUndoStack *QWebPage::undoStack() const
+{
+ if (!d->undoStack)
+ d->undoStack = new QUndoStack(const_cast<QWebPage *>(this));
+
+ return d->undoStack;
+}
+
+/*! \reimp
+*/
+bool QWebPage::event(QEvent *ev)
+{
+ switch (ev->type()) {
+ case QEvent::MouseMove:
+ d->mouseMoveEvent(static_cast<QMouseEvent*>(ev));
+ break;
+ case QEvent::MouseButtonPress:
+ d->mousePressEvent(static_cast<QMouseEvent*>(ev));
+ break;
+ case QEvent::MouseButtonDblClick:
+ d->mouseDoubleClickEvent(static_cast<QMouseEvent*>(ev));
+ break;
+ case QEvent::MouseButtonRelease:
+ d->mouseReleaseEvent(static_cast<QMouseEvent*>(ev));
+ break;
+ case QEvent::ContextMenu:
+ d->contextMenuEvent(static_cast<QContextMenuEvent*>(ev));
+ break;
+ case QEvent::Wheel:
+ d->wheelEvent(static_cast<QWheelEvent*>(ev));
+ break;
+ case QEvent::KeyPress:
+ d->keyPressEvent(static_cast<QKeyEvent*>(ev));
+ break;
+ case QEvent::KeyRelease:
+ d->keyReleaseEvent(static_cast<QKeyEvent*>(ev));
+ break;
+ case QEvent::FocusIn:
+ d->focusInEvent(static_cast<QFocusEvent*>(ev));
+ break;
+ case QEvent::FocusOut:
+ d->focusOutEvent(static_cast<QFocusEvent*>(ev));
+ break;
+#ifndef QT_NO_DRAGANDDROP
+ case QEvent::DragEnter:
+ d->dragEnterEvent(static_cast<QDragEnterEvent*>(ev));
+ break;
+ case QEvent::DragLeave:
+ d->dragLeaveEvent(static_cast<QDragLeaveEvent*>(ev));
+ break;
+ case QEvent::DragMove:
+ d->dragMoveEvent(static_cast<QDragMoveEvent*>(ev));
+ break;
+ case QEvent::Drop:
+ d->dropEvent(static_cast<QDropEvent*>(ev));
+ break;
+#endif
+ default:
+ return QObject::event(ev);
+ }
+
+ return true;
+}
+
+/*!
+ Similar to QWidget::focusNextPrevChild it focuses the next focusable web element
+ if \a next is true. Otherwise the previous element is focused.
+*/
+bool QWebPage::focusNextPrevChild(bool next)
+{
+ QKeyEvent ev(QEvent::KeyPress, Qt::Key_Tab, Qt::KeyboardModifiers(next ? Qt::NoModifier : Qt::ShiftModifier));
+ d->keyPressEvent(&ev);
+ bool hasFocusedNode = false;
+ Frame *frame = d->page->focusController()->focusedFrame();
+ if (frame) {
+ Document *document = frame->document();
+ hasFocusedNode = document && document->focusedNode();
+ }
+ //qDebug() << "focusNextPrevChild(" << next << ") =" << ev.isAccepted() << "focusedNode?" << hasFocusedNode;
+ return hasFocusedNode;
+}
+
+/*!
+ Returns a pointe to the page's settings object.
+*/
+QWebSettings *QWebPage::settings()
+{
+ return d->settings;
+}
+
+/*!
+ This function is called when the web content requests a file name, for example
+ as a result of the user clicking on a "file upload" button in a HTML form.
+*/
+QString QWebPage::chooseFile(QWebFrame *parentFrame, const QString& oldFile)
+{
+#ifndef QT_NO_FILEDIALOG
+ return QFileDialog::getOpenFileName(d->view, QString::null, oldFile);
+#else
+ return QString::null;
+#endif
+}
+
+#if QT_VERSION < 0x040400
+
+void QWebPage::setNetworkInterface(QWebNetworkInterface *interface)
+{
+ d->networkInterface = interface;
+}
+
+QWebNetworkInterface *QWebPage::networkInterface() const
+{
+ if (d->networkInterface)
+ return d->networkInterface;
+ else
+ return QWebNetworkInterface::defaultInterface();
+}
+
+#ifndef QT_NO_NETWORKPROXY
+void QWebPage::setNetworkProxy(const QNetworkProxy& proxy)
+{
+ d->networkProxy = proxy;
+}
+
+QNetworkProxy QWebPage::networkProxy() const
+{
+ return d->networkProxy;
+}
+#endif
+
+#else
+
+/*!
+ Sets the QNetworkAccessManager \a manager that is responsible for serving network
+ requests for this QWebPage.
+
+ \sa networkAccessManager
+*/
+void QWebPage::setNetworkAccessManager(QNetworkAccessManager *manager)
+{
+ if (manager == d->networkManager)
+ return;
+ delete d->networkManager;
+ d->networkManager = manager;
+}
+
+/*!
+ Returns the QNetworkAccessManager \a manager that is responsible for serving network
+ requests for this QWebPage.
+
+ \sa setNetworkAccessManager
+*/
+QNetworkAccessManager *QWebPage::networkAccessManager() const
+{
+ if (!d->networkManager) {
+ QWebPage *that = const_cast<QWebPage *>(this);
+ that->d->networkManager = new QNetworkAccessManager(that);
+ }
+ return d->networkManager;
+}
+
+#endif
+
+/*!
+ This function is called when a user agent for HTTP requests is needed. You can re-implement this
+ function to dynamically return different user agent's for different urls, based on the \a url parameter.
+*/
+QString QWebPage::userAgentFor(const QUrl& url) const
+{
+ Q_UNUSED(url)
+ return QLatin1String("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/523.15 (KHTML, like Gecko) Safari/419.3 Qt");
+}
+
+
+void QWebPagePrivate::_q_onLoadProgressChanged(int) {
+ m_totalBytes = page->progress()->totalPageAndResourceBytesToLoad();
+ m_bytesReceived = page->progress()->totalBytesReceived();
+}
+
+
+/*!
+ Returns the total number of bytes that were received from the network to render the current page,
+ including extra content such as embedded images.
+*/
+quint64 QWebPage::totalBytes() const {
+ return d->m_bytesReceived;
+}
+
+
+/*!
+ Returns the number of bytes that were received from the network to render the current page.
+*/
+quint64 QWebPage::bytesReceived() const {
+ return d->m_totalBytes;
+}
+
+QWebPageContext::QWebPageContext(const WebCore::HitTestResult &hitTest)
+ : d(new QWebPageContextPrivate)
+{
+ d->pos = hitTest.point();
+ d->text = hitTest.textContent();
+ d->linkUrl = hitTest.absoluteLinkURL().string();
+ d->imageUrl = hitTest.absoluteImageURL().string();
+ d->innerNonSharedNode = hitTest.innerNonSharedNode();
+ WebCore::Image *img = hitTest.image();
+ if (img) {
+ QPixmap *pix = img->getPixmap();
+ if (pix)
+ d->image = *pix;
+ }
+ WebCore::Frame *frame = hitTest.targetFrame();
+ if (frame)
+ d->targetFrame = frame->view()->qwebframe();
+}
+
+QWebPageContext::QWebPageContext()
+ : d(0)
+{
+}
+
+QWebPageContext::QWebPageContext(const QWebPageContext &other)
+ : d(0)
+{
+ if (other.d)
+ d = new QWebPageContextPrivate(*other.d);
+}
+
+QWebPageContext &QWebPageContext::operator=(const QWebPageContext &other)
+{
+ if (this != &other) {
+ if (other.d) {
+ if (!d)
+ d = new QWebPageContextPrivate;
+ *d = *other.d;
+ } else {
+ delete d;
+ d = 0;
+ }
+ }
+ return *this;
+}
+
+QWebPageContext::~QWebPageContext()
+{
+ delete d;
+}
+
+QPoint QWebPageContext::pos() const
+{
+ if (!d)
+ return QPoint();
+ return d->pos;
+}
+
+QString QWebPageContext::text() const
+{
+ if (!d)
+ return QString();
+ return d->text;
+}
+
+QUrl QWebPageContext::linkUrl() const
+{
+ if (!d)
+ return QUrl();
+ return d->linkUrl;
+}
+
+QUrl QWebPageContext::imageUrl() const
+{
+ if (!d)
+ return QUrl();
+ return d->linkUrl;
+}
+
+QPixmap QWebPageContext::image() const
+{
+ if (!d)
+ return QPixmap();
+ return d->image;
+}
+
+QWebFrame *QWebPageContext::targetFrame() const
+{
+ if (!d)
+ return 0;
+ return d->targetFrame;
+}
+
+/*!
+ \fn void QWebPage::loadProgressChanged(int progress)
+
+ This signal is emitted when the global progress status changes.
+ The current value is provided by \a progress in percent.
+ It accumulates changes from all the child frames.
+*/
+
+/*!
+ \fn void QWebPage::hoveringOverLink(const QString &link, const QString &title, const QString &textContent)
+
+ This signal is emitted when the mouse is hovering over a link.
+ The first parameter is the \a link url, the second is the link \a title
+ if any, and third \a textContent is the text content. Method is emitter with both
+ empty parameters when the mouse isn't hovering over any link element.
+*/
+
+/*!
+ \fn void QWebPage::statusBarTextChanged(const QString& text)
+
+ This signal is emitted when the statusbar \a text is changed by the page.
+*/
+
+/*!
+ \fn void QWebPage::frameCreated(QWebFrame *frame)
+
+ This signal is emitted whenever the page creates a new \a frame.
+*/
+
+/*!
+ \fn void QWebPage::selectionChanged()
+
+ This signal is emitted whenever the selection changes.
+*/
+
+/*!
+ \fn void QWebPage::geometryChangeRequest(const QRect& geom)
+
+ This signal is emitted whenever the document wants to change the position and size of the
+ page to \a geom. This can happen for example through JavaScript.
+*/
+
+/*!
+ \fn void QWebPage::handleUnsupportedContent(QNetworkReply *reply)
+
+ This signals is emitted when webkit cannot handle a link the user navigated to.
+
+ At signal emissions time the meta data of the QNetworkReply is available.
+*/
+
+/*!
+ \fn void QWebPage::download(const QNetworkRequest &request)
+
+ This signals is emitted when the user decides to download a link.
+*/
+
+#include "moc_qwebpage.cpp"
diff --git a/WebKit/qt/Api/qwebpage.h b/WebKit/qt/Api/qwebpage.h
new file mode 100644
index 0000000..e76f935
--- /dev/null
+++ b/WebKit/qt/Api/qwebpage.h
@@ -0,0 +1,242 @@
+/*
+ Copyright (C) 2007 Trolltech ASA
+ Copyright (C) 2007 Staikos Computing Services Inc.
+
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, 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 QWEBPAGE_H
+#define QWEBPAGE_H
+
+#include "qwebsettings.h"
+#include "qwebkitglobal.h"
+
+#include <QtCore/qobject.h>
+#include <QtGui/qwidget.h>
+class QNetworkProxy;
+class QUndoStack;
+class QUrl;
+class QWebFrame;
+class QWebNetworkRequest;
+class QNetworkRequest;
+class QNetworkReply;
+class QNetworkAccessManager;
+class QWebHistory;
+
+class QWebPagePrivate;
+class QWebFrameData;
+class QWebNetworkInterface;
+
+namespace WebCore {
+ class ChromeClientQt;
+ class EditorClientQt;
+ class FrameLoaderClientQt;
+ class FrameLoadRequest;
+ class InspectorClientQt;
+ class ResourceHandle;
+ class HitTestResult;
+}
+
+class QWEBKIT_EXPORT QWebPage : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool modified READ isModified)
+ Q_PROPERTY(QString selectedText READ selectedText)
+ Q_PROPERTY(QSize viewportSize READ viewportSize WRITE setViewportSize)
+public:
+ enum NavigationRequestResponse {
+ AcceptNavigationRequest,
+ IgnoreNavigationRequest
+ };
+
+ enum NavigationType {
+ NavigationTypeLinkClicked,
+ NavigationTypeFormSubmitted,
+ NavigationTypeBackForward,
+ NavigationTypeReload,
+ NavigationTypeFormResubmitted,
+ NavigationTypeOther
+ };
+
+ enum WebAction {
+ NoWebAction = - 1,
+
+ OpenLink,
+
+ OpenLinkInNewWindow,
+ OpenFrameInNewWindow,
+
+ DownloadLinkToDisk,
+ CopyLinkToClipboard,
+
+ OpenImageInNewWindow,
+ DownloadImageToDisk,
+ CopyImageToClipboard,
+
+ GoBack, // ###GoBackward instead?
+ GoForward,
+ Stop,
+ Reload,
+
+ Cut,
+ Copy,
+ Paste,
+
+ Undo,
+ Redo,
+ MoveToNextChar,
+ MoveToPreviousChar,
+ MoveToNextWord,
+ MoveToPreviousWord,
+ MoveToNextLine,
+ MoveToPreviousLine,
+ MoveToStartOfLine,
+ MoveToEndOfLine,
+ MoveToStartOfBlock,
+ MoveToEndOfBlock,
+ MoveToStartOfDocument,
+ MoveToEndOfDocument,
+ SelectNextChar,
+ SelectPreviousChar,
+ SelectNextWord,
+ SelectPreviousWord,
+ SelectNextLine,
+ SelectPreviousLine,
+ SelectStartOfLine,
+ SelectEndOfLine,
+ SelectStartOfBlock,
+ SelectEndOfBlock,
+ SelectStartOfDocument,
+ SelectEndOfDocument,
+ DeleteStartOfWord,
+ DeleteEndOfWord,
+
+ SetTextDirectionDefault,
+ SetTextDirectionLeftToRight,
+ SetTextDirectionRightToLeft,
+
+ ToggleBold,
+ ToggleItalic,
+ ToggleUnderline,
+
+ InspectElement,
+
+ WebActionCount
+ };
+
+
+ explicit QWebPage(QObject *parent = 0);
+ ~QWebPage();
+
+ QWebFrame *mainFrame() const;
+ QWebFrame *currentFrame() const;
+
+ QWebHistory *history() const;
+
+ QWebSettings *settings();
+
+ void setView(QWidget *view);
+ QWidget *view() const;
+
+ bool isModified() const;
+ QUndoStack *undoStack() const;
+
+#if QT_VERSION < 0x040400
+ void setNetworkInterface(QWebNetworkInterface *interface);
+ QWebNetworkInterface *networkInterface() const;
+
+ // #### why is this in the page itself?
+#ifndef QT_NO_NETWORKPROXY
+ void setNetworkProxy(const QNetworkProxy& proxy);
+ QNetworkProxy networkProxy() const;
+#endif
+
+#else
+ void setNetworkAccessManager(QNetworkAccessManager *manager);
+ QNetworkAccessManager *networkAccessManager() const;
+#endif
+
+ quint64 totalBytes() const;
+ quint64 bytesReceived() const;
+
+ QString selectedText() const;
+
+ QAction *action(WebAction action) const;
+ virtual void triggerAction(WebAction action, bool checked = false);
+
+ QSize viewportSize() const;
+ void setViewportSize(const QSize &size) const;
+
+ virtual bool event(QEvent*);
+ virtual bool focusNextPrevChild(bool next);
+
+Q_SIGNALS:
+ void loadProgressChanged(int progress);
+ void hoveringOverLink(const QString &link, const QString &title, const QString &textContent = QString());
+ void statusBarTextChanged(const QString& text);
+ void selectionChanged();
+ void frameCreated(QWebFrame *frame);
+ void geometryChangeRequest(const QRect& geom);
+
+#if QT_VERSION >= 0x040400
+ void handleUnsupportedContent(QNetworkReply *reply);
+ void download(const QNetworkRequest &request);
+#endif
+
+ //void addEmbeddableWidget(QWidget *widget);
+ //void addEmbeddableWidget(const QString &classid, QWidget *widget);
+ //void removeEmbeddableWidget(QWidget *widget);
+ //QHash<QString, QWidget *> embeddableWidgets() const;
+ //void clearEmbeddableWidgets();
+
+protected:
+ virtual QWebPage *createWindow();
+ virtual QWebPage *createModalDialog();
+ virtual QObject *createPlugin(const QString &classid, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues);
+
+#if QT_VERSION < 0x040400
+ virtual NavigationRequestResponse navigationRequested(QWebFrame *frame, const QWebNetworkRequest &request, NavigationType type);
+#else
+ virtual NavigationRequestResponse navigationRequested(QWebFrame *frame, const QNetworkRequest &request, NavigationType type);
+#endif
+ virtual QString chooseFile(QWebFrame *originatingFrame, const QString& oldFile);
+ virtual void javaScriptAlert(QWebFrame *originatingFrame, const QString& msg);
+ virtual bool javaScriptConfirm(QWebFrame *originatingFrame, const QString& msg);
+ virtual bool javaScriptPrompt(QWebFrame *originatingFrame, const QString& msg, const QString& defaultValue, QString* result);
+ virtual void javaScriptConsoleMessage(const QString& message, unsigned int lineNumber, const QString& sourceID);
+
+ virtual QString userAgentFor(const QUrl& url) const;
+
+private:
+ Q_PRIVATE_SLOT(d, void _q_onLoadProgressChanged(int))
+ Q_PRIVATE_SLOT(d, void _q_webActionTriggered(bool checked));
+ friend class QWebFrame;
+ friend class QWebPagePrivate;
+ friend class WebCore::ChromeClientQt;
+ friend class WebCore::EditorClientQt;
+ friend class WebCore::FrameLoaderClientQt;
+ friend class WebCore::InspectorClientQt;
+ friend class WebCore::ResourceHandle;
+ QWebPagePrivate *d;
+};
+
+
+
+#endif
diff --git a/WebKit/qt/Api/qwebpage_p.h b/WebKit/qt/Api/qwebpage_p.h
new file mode 100644
index 0000000..80b1e29
--- /dev/null
+++ b/WebKit/qt/Api/qwebpage_p.h
@@ -0,0 +1,159 @@
+/*
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, 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 QWEBPAGE_P_H
+#define QWEBPAGE_P_H
+
+#include <qnetworkproxy.h>
+#include <qpointer.h>
+
+#include "qwebpage.h"
+#include "qwebhistory.h"
+#include "qwebframe.h"
+
+#include "KURL.h"
+#include "PlatformString.h"
+
+#include <wtf/RefPtr.h>
+
+namespace WebCore
+{
+ class ChromeClientQt;
+ class ContextMenuClientQt;
+ class ContextMenuItem;
+ class ContextMenu;
+ class EditorClientQt;
+ class Element;
+ class Node;
+ class Page;
+}
+
+class QUndoStack;
+class QMenu;
+
+class QWebPageContextPrivate
+{
+public:
+ QPoint pos;
+ QString text;
+ QUrl linkUrl;
+ QUrl imageUrl;
+ QPixmap image;
+ QPointer<QWebFrame> targetFrame;
+ RefPtr<WebCore::Node> innerNonSharedNode;
+};
+
+class QWebPageContext
+{
+public:
+ QWebPageContext();
+ QWebPageContext(const QWebPageContext &other);
+ QWebPageContext &operator=(const QWebPageContext &other);
+ ~QWebPageContext();
+
+ QPoint pos() const;
+ QString text() const;
+ QUrl linkUrl() const;
+ QUrl imageUrl() const;
+ // ### we have a pixmap internally, should this be called pixmap() instead?
+ QPixmap image() const;
+
+ QWebFrame *targetFrame() const;
+
+private:
+ QWebPageContext(const WebCore::HitTestResult &hitTest);
+ QWebPageContextPrivate *d;
+
+ friend class QWebPage;
+ friend class QWebPagePrivate;
+};
+
+class QWebPagePrivate
+{
+public:
+ QWebPagePrivate(QWebPage *);
+ ~QWebPagePrivate();
+ void createMainFrame();
+ QMenu *createContextMenu(const WebCore::ContextMenu *webcoreMenu, const QList<WebCore::ContextMenuItem> *items);
+
+ QWebFrame *frameAt(const QPoint &pos) const;
+
+ void _q_onLoadProgressChanged(int);
+ void _q_webActionTriggered(bool checked);
+ void updateAction(QWebPage::WebAction action);
+ void updateNavigationActions();
+ void updateEditorActions();
+
+ void mouseMoveEvent(QMouseEvent*);
+ void mousePressEvent(QMouseEvent*);
+ void mouseDoubleClickEvent(QMouseEvent*);
+ void mouseReleaseEvent(QMouseEvent*);
+ void contextMenuEvent(QContextMenuEvent*);
+ void wheelEvent(QWheelEvent*);
+ void keyPressEvent(QKeyEvent*);
+ void keyReleaseEvent(QKeyEvent*);
+ void focusInEvent(QFocusEvent*);
+ void focusOutEvent(QFocusEvent*);
+
+ void dragEnterEvent(QDragEnterEvent *);
+ void dragLeaveEvent(QDragLeaveEvent *);
+ void dragMoveEvent(QDragMoveEvent *);
+ void dropEvent(QDropEvent *);
+
+
+ WebCore::ChromeClientQt *chromeClient;
+ WebCore::ContextMenuClientQt *contextMenuClient;
+ WebCore::EditorClientQt *editorClient;
+ WebCore::Page *page;
+
+ QPointer<QWebFrame> mainFrame;
+
+ QWebPage *q;
+ QUndoStack *undoStack;
+ QWidget *view;
+
+ bool modified;
+
+ bool insideOpenCall;
+ quint64 m_totalBytes;
+ quint64 m_bytesReceived;
+
+#if QT_VERSION < 0x040400
+ QWebPage::NavigationRequestResponse navigationRequested(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type);
+
+ QWebNetworkInterface *networkInterface;
+#ifndef QT_NO_NETWORKPROXY
+ QNetworkProxy networkProxy;
+#endif
+
+#else
+ QWebPage::NavigationRequestResponse navigationRequested(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type);
+ QNetworkAccessManager *networkManager;
+#endif
+
+ QWebHistory history;
+ QWebPageContext currentContext;
+ QWebSettings *settings;
+
+ QAction *actions[QWebPage::WebActionCount];
+};
+
+#endif
diff --git a/WebKit/qt/Api/qwebsettings.cpp b/WebKit/qt/Api/qwebsettings.cpp
new file mode 100644
index 0000000..8109de1
--- /dev/null
+++ b/WebKit/qt/Api/qwebsettings.cpp
@@ -0,0 +1,384 @@
+/*
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, 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 "config.h"
+#include "qwebsettings.h"
+
+#include "qwebpage.h"
+#include "qwebpage_p.h"
+
+#include "Page.h"
+#include "Settings.h"
+#include "KURL.h"
+#include "PlatformString.h"
+#include "IconDatabase.h"
+
+#include <QHash>
+#include <QSharedData>
+#include <QUrl>
+#include <QFileInfo>
+
+class QWebSettingsPrivate
+{
+public:
+ QWebSettingsPrivate(WebCore::Settings *wcSettings = 0)
+ : settings(wcSettings)
+ {
+ }
+
+ QHash<int, QString> fontFamilies;
+ QHash<int, int> fontSizes;
+ QHash<int, bool> attributes;
+ QUrl userStyleSheetLocation;
+
+ void apply();
+ WebCore::Settings *settings;
+};
+
+typedef QHash<int, QPixmap> WebGraphicHash;
+Q_GLOBAL_STATIC(WebGraphicHash, graphics)
+
+Q_GLOBAL_STATIC(QList<QWebSettingsPrivate *>, allSettings);
+
+void QWebSettingsPrivate::apply()
+{
+ if (settings) {
+ QWebSettingsPrivate *global = QWebSettings::defaultSettings()->d;
+
+ QString family = fontFamilies.value(QWebSettings::StandardFont,
+ global->fontFamilies.value(QWebSettings::StandardFont));
+ settings->setStandardFontFamily(family);
+
+ family = fontFamilies.value(QWebSettings::FixedFont,
+ global->fontFamilies.value(QWebSettings::FixedFont));
+ settings->setFixedFontFamily(family);
+
+ family = fontFamilies.value(QWebSettings::SerifFont,
+ global->fontFamilies.value(QWebSettings::SerifFont));
+ settings->setSerifFontFamily(family);
+
+ family = fontFamilies.value(QWebSettings::SansSerifFont,
+ global->fontFamilies.value(QWebSettings::SansSerifFont));
+ settings->setSansSerifFontFamily(family);
+
+ family = fontFamilies.value(QWebSettings::CursiveFont,
+ global->fontFamilies.value(QWebSettings::CursiveFont));
+ settings->setCursiveFontFamily(family);
+
+ family = fontFamilies.value(QWebSettings::FantasyFont,
+ global->fontFamilies.value(QWebSettings::FantasyFont));
+ settings->setFantasyFontFamily(family);
+
+ int size = fontSizes.value(QWebSettings::MinimumFontSize,
+ global->fontSizes.value(QWebSettings::MinimumFontSize));
+ settings->setMinimumFontSize(size);
+
+ size = fontSizes.value(QWebSettings::MinimumLogicalFontSize,
+ global->fontSizes.value(QWebSettings::MinimumLogicalFontSize));
+ settings->setMinimumLogicalFontSize(size);
+
+ size = fontSizes.value(QWebSettings::DefaultFontSize,
+ global->fontSizes.value(QWebSettings::DefaultFontSize));
+ settings->setDefaultFontSize(size);
+
+ size = fontSizes.value(QWebSettings::DefaultFixedFontSize,
+ global->fontSizes.value(QWebSettings::DefaultFixedFontSize));
+ settings->setDefaultFixedFontSize(size);
+
+ bool value = attributes.value(QWebSettings::AutoLoadImages,
+ global->attributes.value(QWebSettings::AutoLoadImages));
+ settings->setLoadsImagesAutomatically(value);
+
+ value = attributes.value(QWebSettings::JavascriptEnabled,
+ global->attributes.value(QWebSettings::JavascriptEnabled));
+ settings->setJavaScriptEnabled(value);
+
+ value = attributes.value(QWebSettings::JavascriptCanOpenWindows,
+ global->attributes.value(QWebSettings::JavascriptCanOpenWindows));
+ settings->setJavaScriptCanOpenWindowsAutomatically(value);
+
+ value = attributes.value(QWebSettings::JavaEnabled,
+ global->attributes.value(QWebSettings::JavaEnabled));
+ settings->setJavaEnabled(value);
+
+ value = attributes.value(QWebSettings::PluginsEnabled,
+ global->attributes.value(QWebSettings::PluginsEnabled));
+ settings->setPluginsEnabled(value);
+
+ value = attributes.value(QWebSettings::PrivateBrowsingEnabled,
+ global->attributes.value(QWebSettings::PrivateBrowsingEnabled));
+ settings->setPrivateBrowsingEnabled(value);
+
+ value = attributes.value(QWebSettings::JavascriptCanAccessClipboard,
+ global->attributes.value(QWebSettings::JavascriptCanAccessClipboard));
+ settings->setDOMPasteAllowed(value);
+
+ value = attributes.value(QWebSettings::DeveloperExtrasEnabled,
+ global->attributes.value(QWebSettings::DeveloperExtrasEnabled));
+ settings->setDeveloperExtrasEnabled(value);
+
+ QUrl location = !userStyleSheetLocation.isEmpty() ? userStyleSheetLocation : global->userStyleSheetLocation;
+ settings->setUserStyleSheetLocation(WebCore::KURL(location));
+ } else {
+ QList<QWebSettingsPrivate *> settings = *::allSettings();
+ for (int i = 0; i < settings.count(); ++i)
+ settings[i]->apply();
+ }
+}
+
+/*!
+ Returns the global default settings object.
+
+ Any setting changed on the default object is automatically applied to all
+ QWebPage instances where the particular setting is not overriden already.
+*/
+QWebSettings *QWebSettings::defaultSettings()
+{
+ static QWebSettings *global = 0;
+ if (!global)
+ global = new QWebSettings;
+ return global;
+}
+
+/*!
+ \internal
+*/
+QWebSettings::QWebSettings()
+ : d(new QWebSettingsPrivate)
+{
+ // Initialize our global defaults
+ // changing any of those will likely break the LayoutTests
+ d->fontSizes.insert(QWebSettings::MinimumFontSize, 5);
+ d->fontSizes.insert(QWebSettings::MinimumLogicalFontSize, 5);
+ d->fontSizes.insert(QWebSettings::DefaultFontSize, 14);
+ d->fontSizes.insert(QWebSettings::DefaultFixedFontSize, 14);
+ d->fontFamilies.insert(QWebSettings::StandardFont, QLatin1String("Arial"));
+ d->fontFamilies.insert(QWebSettings::FixedFont, QLatin1String("Courier New"));
+ d->fontFamilies.insert(QWebSettings::SerifFont, QLatin1String("Times New Roman"));
+ d->fontFamilies.insert(QWebSettings::SansSerifFont, QLatin1String("Arial"));
+ d->fontFamilies.insert(QWebSettings::CursiveFont, QLatin1String("Arial"));
+ d->fontFamilies.insert(QWebSettings::FantasyFont, QLatin1String("Arial"));
+
+ d->attributes.insert(QWebSettings::AutoLoadImages, true);
+ d->attributes.insert(QWebSettings::JavascriptEnabled, true);
+ d->attributes.insert(QWebSettings::LinksIncludedInFocusChain, true);
+}
+
+/*!
+ \internal
+*/
+QWebSettings::QWebSettings(WebCore::Settings *settings)
+ : d(new QWebSettingsPrivate(settings))
+{
+ d->settings = settings;
+ d->apply();
+ allSettings()->append(d);
+}
+
+/*!
+ \internal
+*/
+QWebSettings::~QWebSettings()
+{
+ if (d->settings)
+ allSettings()->removeAll(d);
+
+ delete d;
+}
+
+/*!
+ Sets the font size for \a type to \a size.
+*/
+void QWebSettings::setFontSize(FontSize type, int size)
+{
+ d->fontSizes.insert(type, size);
+ d->apply();
+}
+
+/*!
+ Returns the default font size for \a type.
+*/
+int QWebSettings::fontSize(FontSize type) const
+{
+ int defaultValue = 0;
+ if (d->settings) {
+ QWebSettingsPrivate *global = QWebSettings::defaultSettings()->d;
+ defaultValue = global->fontSizes.value(type);
+ }
+ return d->fontSizes.value(type, defaultValue);
+}
+
+/*!
+ Resets the font size for \a type to the size specified in the default settings object.
+
+ This function has not effect on the default QWebSettings instance.
+*/
+void QWebSettings::resetFontSize(FontSize type)
+{
+ if (d->settings) {
+ d->fontSizes.remove(type);
+ d->apply();
+ }
+}
+
+/*!
+ Specifies the location of a user stylesheet to load with every web page.
+
+ The location can be a URL as well as a path on the local filesystem.
+
+ \sa userStyleSheetLocation
+*/
+void QWebSettings::setUserStyleSheetLocation(const QUrl &location)
+{
+ d->userStyleSheetLocation = location;
+ d->apply();
+}
+
+/*!
+ Returns the location of the user stylesheet.
+
+ \sa setUserStyleSheetLocation
+*/
+QUrl QWebSettings::userStyleSheetLocation() const
+{
+ return d->userStyleSheetLocation;
+}
+
+/*!
+ Enables or disables the icon database. The icon database is used to store favicons
+ associated with web sites.
+
+ If \a enabled is true then \a location must be specified and point to an existing directory
+ where the icons are stored.
+*/
+void QWebSettings::setIconDatabaseEnabled(bool enabled, const QString &location)
+{
+ WebCore::iconDatabase()->setEnabled(enabled);
+ if (enabled) {
+ QFileInfo info(location);
+ if (info.isDir() && info.isWritable())
+ WebCore::iconDatabase()->open(location);
+ } else {
+ WebCore::iconDatabase()->close();
+ }
+}
+
+/*!
+ Returns whether the icon database is enabled or not.
+
+ \sa setIconDatabaseEnabled
+*/
+bool QWebSettings::iconDatabaseEnabled()
+{
+ return WebCore::iconDatabase()->isEnabled() && WebCore::iconDatabase()->isOpen();
+}
+
+/*!
+ Sets \a graphic to be drawn when QtWebKit needs to drawn an image of the given \a type.
+*/
+void QWebSettings::setWebGraphic(WebGraphic type, const QPixmap &graphic)
+{
+ WebGraphicHash *h = graphics();
+ if (graphic.isNull())
+ h->remove(type);
+ else
+ h->insert(type, graphic);
+}
+
+/*!
+ Returns a previously set pixmap that is used to draw replacement graphics of the specified \a type.
+*/
+QPixmap QWebSettings::webGraphic(WebGraphic type)
+{
+ return graphics()->value(type);
+}
+
+/*!
+ Sets the default font family to \a family for the specified \a type of font.
+*/
+void QWebSettings::setFontFamily(FontType type, const QString &family)
+{
+ d->fontFamilies.insert(type, family);
+ d->apply();
+}
+
+/*!
+ Returns the default font family to \a family for the specified \a type of font.
+*/
+QString QWebSettings::fontFamily(FontType type) const
+{
+ QString defaultValue;
+ if (d->settings) {
+ QWebSettingsPrivate *global = QWebSettings::defaultSettings()->d;
+ defaultValue = global->fontFamilies.value(type);
+ }
+ return d->fontFamilies.value(type, defaultValue);
+}
+
+/*!
+ Resets the font family for specified \a type of fonts in a web page to the default.
+
+ This function has not effect on the default QWebSettings instance.
+*/
+void QWebSettings::resetFontFamily(FontType type)
+{
+ if (d->settings) {
+ d->fontFamilies.remove(type);
+ d->apply();
+ }
+}
+
+/*!
+ Enables or disables the specified \a attr feature depending on the value of \a on.
+*/
+void QWebSettings::setAttribute(WebAttribute attr, bool on)
+{
+ d->attributes.insert(attr, on);
+ d->apply();
+}
+
+/*!
+ Returns true if \a attr is enabled; false otherwise.
+*/
+bool QWebSettings::testAttribute(WebAttribute attr) const
+{
+ bool defaultValue = false;
+ if (d->settings) {
+ QWebSettingsPrivate *global = QWebSettings::defaultSettings()->d;
+ defaultValue = global->attributes.value(attr);
+ }
+ return d->attributes.value(attr, defaultValue);
+}
+
+/*!
+ Clears the setting of \a attr. The global default for \a attr will be used instead.
+
+ This function has not effect on the default QWebSettings instance.
+*/
+void QWebSettings::clearAttribute(WebAttribute attr)
+{
+ if (d->settings) {
+ d->attributes.remove(attr);
+ d->apply();
+ }
+}
+
diff --git a/WebKit/qt/Api/qwebsettings.h b/WebKit/qt/Api/qwebsettings.h
new file mode 100644
index 0000000..c071e51
--- /dev/null
+++ b/WebKit/qt/Api/qwebsettings.h
@@ -0,0 +1,112 @@
+/*
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, 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 QWEBSETTINGS_H
+#define QWEBSETTINGS_H
+
+#include <qwebkitglobal.h>
+
+#include <QtCore/qstring.h>
+#include <QtGui/qpixmap.h>
+#include <QtCore/qshareddata.h>
+
+namespace WebCore
+{
+ class Settings;
+};
+
+class QWebPage;
+class QWebSettingsPrivate;
+class QUrl;
+
+class QWEBKIT_EXPORT QWebSettings
+{
+public:
+ enum FontType {
+ StandardFont,
+ FixedFont,
+ SerifFont,
+ SansSerifFont,
+ CursiveFont,
+ FantasyFont
+ };
+ enum WebAttribute {
+ AutoLoadImages,
+ JavascriptEnabled,
+ JavaEnabled,
+ PluginsEnabled,
+ PrivateBrowsingEnabled,
+ JavascriptCanOpenWindows,
+ JavascriptCanAccessClipboard,
+ DeveloperExtrasEnabled,
+ LinksIncludedInFocusChain
+ };
+ enum WebGraphic {
+ MissingImageGraphic,
+ MissingPluginGraphic,
+ DefaultFaviconGraphic,
+ TextAreaResizeCornerGraphic
+ };
+ enum FontSize {
+ MinimumFontSize,
+ MinimumLogicalFontSize,
+ DefaultFontSize,
+ DefaultFixedFontSize
+ };
+
+ static QWebSettings *defaultSettings();
+
+ void setFontFamily(FontType type, const QString &family);
+ QString fontFamily(FontType type) const;
+ void resetFontFamily(FontType type);
+
+ void setFontSize(FontSize type, int size);
+ int fontSize(FontSize type) const;
+ void resetFontSize(FontSize type);
+
+ void setAttribute(WebAttribute attr, bool on = true);
+ bool testAttribute(WebAttribute attr) const;
+ void clearAttribute(WebAttribute attr);
+
+ void setUserStyleSheetLocation(const QUrl &location);
+ QUrl userStyleSheetLocation() const;
+
+ static void setIconDatabaseEnabled(bool enabled, const QString &location = QString());
+ static bool iconDatabaseEnabled();
+
+ static void setWebGraphic(WebGraphic type, const QPixmap &graphic);
+ static QPixmap webGraphic(WebGraphic type);
+
+private:
+ friend class QWebPagePrivate;
+ friend class QWebSettingsPrivate;
+
+ Q_DISABLE_COPY(QWebSettings)
+
+ QWebSettings();
+ QWebSettings(WebCore::Settings *settings);
+ ~QWebSettings();
+
+ QWebSettingsPrivate *d;
+};
+
+#endif
diff --git a/WebKit/qt/Api/qwebview.cpp b/WebKit/qt/Api/qwebview.cpp
new file mode 100644
index 0000000..3d67437
--- /dev/null
+++ b/WebKit/qt/Api/qwebview.cpp
@@ -0,0 +1,593 @@
+/*
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "qwebview.h"
+#include "qwebframe.h"
+#include "qevent.h"
+#include "qpainter.h"
+
+class QWebViewPrivate
+{
+public:
+ QWebPage *page;
+};
+
+/*!
+ \class QWebView
+ \since 4.4
+ \brief The QWebView class provides a widget that is used to view and edit web documents.
+
+ QWebView is the main widget component of the QtWebKit web browsing module.
+*/
+
+/*!
+ Constructs an empty QWebView with parent \a parent.
+*/
+QWebView::QWebView(QWidget *parent)
+ : QWidget(parent)
+{
+ d = new QWebViewPrivate;
+ d->page = 0;
+
+ QPalette pal = palette();
+ pal.setBrush(QPalette::Background, Qt::white);
+
+ setAttribute(Qt::WA_OpaquePaintEvent);
+
+ setPalette(pal);
+ setAcceptDrops(true);
+
+ setMouseTracking(true);
+ setFocusPolicy(Qt::WheelFocus);
+}
+
+/*!
+ Destructor.
+*/
+QWebView::~QWebView()
+{
+ if (d->page && d->page->parent() == this)
+ delete d->page;
+ delete d;
+}
+
+/*!
+ Returns a pointer to the underlying web page.
+
+ \sa setPage()
+*/
+QWebPage *QWebView::page() const
+{
+ if (!d->page) {
+ QWebView *that = const_cast<QWebView *>(this);
+ that->setPage(new QWebPage(that));
+ }
+ return d->page;
+}
+
+/*!
+ Makes \a page the new web page of the web view.
+
+ The parent QObject of the provided page remains the owner
+ of the object. If the current document is a child of the web
+ view, then it is deleted.
+
+ \sa page()
+*/
+void QWebView::setPage(QWebPage *page)
+{
+ if (d->page == page)
+ return;
+ if (d->page) {
+ if (d->page->parent() == this) {
+ delete d->page;
+ } else {
+ d->page->disconnect(this);
+ }
+ }
+ d->page = page;
+ if (d->page) {
+ d->page->setView(this);
+ // #### connect signals
+ QWebFrame *mainFrame = d->page->mainFrame();
+ connect(mainFrame, SIGNAL(loadStarted()),
+ this, SIGNAL(loadStarted()));
+ connect(mainFrame, SIGNAL(loadFinished()),
+ this, SIGNAL(loadFinished()));
+ connect(mainFrame, SIGNAL(titleChanged(const QString&)),
+ this, SIGNAL(titleChanged(const QString&)));
+ connect(mainFrame, SIGNAL(iconLoaded()),
+ this, SIGNAL(iconLoaded()));
+ connect(mainFrame, SIGNAL(urlChanged(const QUrl &)),
+ this, SIGNAL(urlChanged(const QUrl &)));
+
+ connect(d->page, SIGNAL(loadProgressChanged(int)),
+ this, SIGNAL(loadProgressChanged(int)));
+ connect(d->page, SIGNAL(statusBarTextChanged(const QString &)),
+ this, SIGNAL(statusBarTextChanged(const QString &)));
+ }
+ update();
+}
+
+/*!
+ Downloads the specified \a url and displays it.
+*/
+void QWebView::load(const QUrl &url)
+{
+ page()->mainFrame()->load(url);
+}
+
+#if QT_VERSION < 0x040400
+void QWebView::load(const QWebNetworkRequest &request)
+#else
+void QWebView::load(const QNetworkRequest &request,
+ QNetworkAccessManager::Operation operation,
+ const QByteArray &body)
+#endif
+{
+ page()->mainFrame()->load(request
+#if QT_VERSION >= 0x040400
+ , operation, body
+#endif
+ );
+}
+
+/*!
+ Sets the content of the web view to the specified \a html.
+
+ External objects referenced in the HTML document are located relative to \a baseUrl.
+*/
+void QWebView::setHtml(const QString &html, const QUrl &baseUrl)
+{
+ page()->mainFrame()->setHtml(html, baseUrl);
+}
+
+/*!
+ Sets the content of the web view to the specified \a html.
+
+ External objects referenced in the HTML document are located relative to \a baseUrl.
+*/
+void QWebView::setHtml(const QByteArray &html, const QUrl &baseUrl)
+{
+ page()->mainFrame()->setHtml(html, baseUrl);
+}
+
+/*!
+ Sets the content of the web view to the specified content \a data. If the \a mimeType argument
+ is empty it is assumed that the content is HTML.
+
+ External objects referenced in the HTML document are located relative to \a baseUrl.
+*/
+void QWebView::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
+{
+ page()->mainFrame()->setContent(data, mimeType, baseUrl);
+}
+
+/*!
+ Returns a pointer to the view's history of navigated web pages.
+
+ It is equivalent to
+
+ \snippet doc/src/snippets/code/src.3rdparty.webkit.WebKit.qt.Api.qwebview.cpp 0
+*/
+QWebHistory *QWebView::history() const
+{
+ return page()->history();
+}
+
+/*!
+ Returns a pointer to the view/page specific settings object.
+
+ It is equivalent to
+
+ \snippet doc/src/snippets/code/src.3rdparty.webkit.WebKit.qt.Api.qwebview.cpp 1
+*/
+QWebSettings *QWebView::settings() const
+{
+ return page()->settings();
+}
+
+/*!
+ \property QWebView::title
+ \brief the title of the web page currently viewed.
+*/
+QString QWebView::title() const
+{
+ if (d->page)
+ return d->page->mainFrame()->title();
+ return QString();
+}
+
+/*!
+ \property QWebView::url
+ \brief the url of the web page currently viewed.
+*/
+QUrl QWebView::url() const
+{
+ if (d->page)
+ return d->page->mainFrame()->url();
+ return QUrl();
+}
+
+/*!
+ \property QWebView::icon
+ \brief the icon associated with the web page currently viewed.
+*/
+QPixmap QWebView::icon() const
+{
+ if (d->page)
+ return d->page->mainFrame()->icon();
+ return QPixmap();
+}
+
+/*!
+ \property QWebView::selectedText
+ \brief the text currently selected.
+*/
+QString QWebView::selectedText() const
+{
+ if (d->page)
+ return d->page->selectedText();
+ return QString();
+}
+
+/*!
+ Returns a pointer to a QAction that encapsulates the specified web action \a action.
+*/
+QAction *QWebView::action(QWebPage::WebAction action) const
+{
+ return page()->action(action);
+}
+
+/*!
+ Triggers the specified \a action. If it is a checkable action the specified \a checked state is assumed.
+
+ The following example triggers the copy action and therefore copies any selected text to the clipboard.
+
+ \snippet doc/src/snippets/code/src.3rdparty.webkit.WebKit.qt.Api.qwebview.cpp 2
+*/
+void QWebView::triggerAction(QWebPage::WebAction action, bool checked)
+{
+ page()->triggerAction(action, checked);
+}
+
+/*!
+ \property QWebView::modified
+ \brief whether the document was modified by the user
+
+ Parts of HTML documents can be editable for example through the \c{contenteditable} attribute on
+ HTML elements.
+*/
+bool QWebView::isModified() const
+{
+ if (d->page)
+ return d->page->isModified();
+ return false;
+}
+
+Qt::TextInteractionFlags QWebView::textInteractionFlags() const
+{
+ // ### FIXME (add to page)
+ return Qt::TextInteractionFlags();
+}
+
+/*!
+ \property QWebView::textInteractionFlags
+ \brief how the view should handle user input
+
+ Specifies how the user can interact with the text on the page.
+*/
+
+void QWebView::setTextInteractionFlags(Qt::TextInteractionFlags flags)
+{
+ Q_UNUSED(flags)
+ // ### FIXME (add to page)
+}
+
+/*!
+ \reimp
+*/
+QSize QWebView::sizeHint() const
+{
+ return QSize(800, 600); // ####...
+}
+
+/*!
+ Convenience slot that stops loading the document.
+
+ It is equivalent to
+
+ \snippet doc/src/snippets/code/src.3rdparty.webkit.WebKit.qt.Api.qwebview.cpp 3
+*/
+void QWebView::stop()
+{
+ if (d->page)
+ d->page->triggerAction(QWebPage::Stop);
+}
+
+/*!
+ Convenience slot that loads the previous document in the list of
+ documents built by navigating links. Does nothing if there is no
+ previous document.
+
+ It is equivalent to
+
+ \snippet doc/src/snippets/code/src.3rdparty.webkit.WebKit.qt.Api.qwebview.cpp 4
+*/
+void QWebView::backward()
+{
+ if (d->page)
+ d->page->triggerAction(QWebPage::GoBack);
+}
+
+/*!
+ Convenience slot that loads the next document in the list of
+ documents built by navigating links. Does nothing if there is no
+ next document.
+
+ It is equivalent to
+
+ \snippet doc/src/snippets/code/src.3rdparty.webkit.WebKit.qt.Api.qwebview.cpp 5
+*/
+void QWebView::forward()
+{
+ if (d->page)
+ d->page->triggerAction(QWebPage::GoForward);
+}
+
+/*!
+ Reloads the current document.
+*/
+void QWebView::reload()
+{
+ if (d->page)
+ d->page->triggerAction(QWebPage::Reload);
+}
+
+/*! \reimp
+*/
+void QWebView::resizeEvent(QResizeEvent *e)
+{
+ if (d->page)
+ d->page->setViewportSize(e->size());
+}
+
+/*! \reimp
+*/
+void QWebView::paintEvent(QPaintEvent *ev)
+{
+ if (!d->page)
+ return;
+#ifdef QWEBKIT_TIME_RENDERING
+ QTime time;
+ time.start();
+#endif
+
+ QWebFrame *frame = d->page->mainFrame();
+ QPainter p(this);
+
+ frame->render(&p, ev->region());
+
+#ifdef QWEBKIT_TIME_RENDERING
+ int elapsed = time.elapsed();
+ qDebug()<<"paint event on "<<ev->region()<<", took to render = "<<elapsed;
+#endif
+}
+
+/*!
+ This function is called whenever WebKit wants to create a new window, for example as a result of
+ a JavaScript request to open a document in a new window.
+*/
+QWebView *QWebView::createWindow()
+{
+ return 0;
+}
+
+/*! \reimp
+*/
+void QWebView::mouseMoveEvent(QMouseEvent* ev)
+{
+ if (d->page)
+ d->page->event(ev);
+}
+
+/*! \reimp
+*/
+void QWebView::mousePressEvent(QMouseEvent* ev)
+{
+ if (d->page)
+ d->page->event(ev);
+}
+
+/*! \reimp
+*/
+void QWebView::mouseDoubleClickEvent(QMouseEvent* ev)
+{
+ if (d->page)
+ d->page->event(ev);
+}
+
+/*! \reimp
+*/
+void QWebView::mouseReleaseEvent(QMouseEvent* ev)
+{
+ if (d->page)
+ d->page->event(ev);
+}
+
+/*! \reimp
+*/
+void QWebView::contextMenuEvent(QContextMenuEvent* ev)
+{
+ if (d->page)
+ d->page->event(ev);
+}
+
+/*! \reimp
+*/
+void QWebView::wheelEvent(QWheelEvent* ev)
+{
+ if (d->page)
+ d->page->event(ev);
+
+ if (!ev->isAccepted())
+ return QWidget::wheelEvent(ev);
+}
+
+/*! \reimp
+*/
+void QWebView::keyPressEvent(QKeyEvent* ev)
+{
+ if (d->page)
+ d->page->event(ev);
+ if (!ev->isAccepted())
+ QWidget::keyPressEvent(ev);
+}
+
+/*! \reimp
+*/
+void QWebView::keyReleaseEvent(QKeyEvent* ev)
+{
+ if (d->page)
+ d->page->event(ev);
+ if (!ev->isAccepted())
+ QWidget::keyReleaseEvent(ev);
+}
+
+/*! \reimp
+*/
+void QWebView::focusInEvent(QFocusEvent* ev)
+{
+ if (d->page)
+ d->page->event(ev);
+ QWidget::focusInEvent(ev);
+}
+
+/*! \reimp
+*/
+void QWebView::focusOutEvent(QFocusEvent* ev)
+{
+ QWidget::focusOutEvent(ev);
+ if (d->page)
+ d->page->event(ev);
+}
+
+/*! \reimp
+*/
+void QWebView::dragEnterEvent(QDragEnterEvent* ev)
+{
+#ifndef QT_NO_DRAGANDDROP
+ if (d->page)
+ d->page->event(ev);
+#endif
+}
+
+/*! \reimp
+*/
+void QWebView::dragLeaveEvent(QDragLeaveEvent* ev)
+{
+#ifndef QT_NO_DRAGANDDROP
+ if (d->page)
+ d->page->event(ev);
+#endif
+}
+
+/*! \reimp
+*/
+void QWebView::dragMoveEvent(QDragMoveEvent* ev)
+{
+#ifndef QT_NO_DRAGANDDROP
+ if (d->page)
+ d->page->event(ev);
+#endif
+}
+
+/*! \reimp
+*/
+void QWebView::dropEvent(QDropEvent* ev)
+{
+#ifndef QT_NO_DRAGANDDROP
+ if (d->page)
+ d->page->event(ev);
+#endif
+}
+
+/*! \reimp
+*/
+bool QWebView::focusNextPrevChild(bool next)
+{
+ if (d->page && d->page->focusNextPrevChild(next))
+ return true;
+ return QWidget::focusNextPrevChild(next);
+}
+
+/*!
+ \fn void QWebView::titleChanged(const QString &title)
+
+ This signal is emitted whenever the \a title of the main frame changes.
+
+ \sa title()
+*/
+
+/*!
+ \fn void QWebView::urlChanged(const QUrl &url)
+
+ This signal is emitted whenever the \a url of the main frame changes.
+
+ \sa url()
+*/
+
+/*!
+ \fn void QWebView::statusBarTextChanged(const QString& text)
+
+ This signal is emitted when the statusbar \a text is changed by the page.
+*/
+
+/*!
+ \fn void QWebView::iconLoaded()
+
+ This signal is emitted whenever the icon of the page is loaded or changes.
+*/
+
+/*!
+ \fn void QWebView::loadStarted()
+
+ This signal is emitted when a new load of the frame is started.
+*/
+
+/*!
+ \fn void QWebView::loadFinished()
+
+ This signal is emitted when a load of the frame is finished.
+*/
+
+/*!
+ \fn void QWebView::selectionChanged()
+
+ This signal is emitted whenever the selection changes.
+*/
+
+/*!
+ \fn void QWebView::loadProgressChanged(int progress)
+
+ This signal is emitted when the global progress status changes.
+ The current value is provided by \a progress in percent.
+ It accumulates changes from all the child frames.
+*/
diff --git a/WebKit/qt/Api/qwebview.h b/WebKit/qt/Api/qwebview.h
new file mode 100644
index 0000000..53043ae
--- /dev/null
+++ b/WebKit/qt/Api/qwebview.h
@@ -0,0 +1,135 @@
+/*
+ Copyright (C) 2007 Trolltech ASA
+ Copyright (C) 2007 Staikos Computing Services Inc.
+
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+#ifndef QWEBVIEW_H
+#define QWEBVIEW_H
+
+#include "qwebkitglobal.h"
+#include "qwebpage.h"
+#include <QtGui/qwidget.h>
+#include <QtCore/qurl.h>
+#if QT_VERSION >= 0x040400
+#include <QtNetwork/qnetworkaccessmanager.h>
+#endif
+
+class QWebPage;
+class QWebViewPrivate;
+class QNetworkRequest;
+class QWebNetworkRequest;
+
+class QWEBKIT_EXPORT QWebView : public QWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(QString title READ title)
+ Q_PROPERTY(QUrl url READ url WRITE load)
+ Q_PROPERTY(QPixmap icon READ icon)
+ Q_PROPERTY(QString selectedText READ selectedText)
+ Q_PROPERTY(bool modified READ isModified)
+ Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
+public:
+ explicit QWebView(QWidget *parent = 0);
+ virtual ~QWebView();
+
+ QWebPage *page() const;
+ void setPage(QWebPage *page);
+
+ void load(const QUrl &url);
+#if QT_VERSION < 0x040400
+ void load(const QWebNetworkRequest &request);
+#else
+ void load(const QNetworkRequest &request,
+ QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation,
+ const QByteArray &body = QByteArray());
+#endif
+ void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
+ void setHtml(const QByteArray &html, const QUrl &baseUrl = QUrl());
+ void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl());
+
+ QWebHistory *history() const;
+ QWebSettings *settings() const;
+
+ QString title() const;
+ QUrl url() const;
+ QPixmap icon() const;
+
+ QString selectedText() const;
+
+ QAction *action(QWebPage::WebAction action) const;
+ void triggerAction(QWebPage::WebAction action, bool checked = false);
+
+ bool isModified() const;
+
+ Qt::TextInteractionFlags textInteractionFlags() const;
+ void setTextInteractionFlags(Qt::TextInteractionFlags flags);
+
+ /* #### QTextBrowser compatibility?
+ bool openLinks() const;
+ void setOpenLinks(bool open);
+
+ bool openExternalLinks() const;
+ void setOpenExternalLinks(bool open);
+ */
+
+ QSize sizeHint() const;
+public Q_SLOTS:
+ void stop();
+ void backward();
+ void forward();
+ void reload();
+
+Q_SIGNALS:
+ void loadStarted();
+ void loadProgressChanged(int progress);
+ void loadFinished();
+ void titleChanged(const QString& title);
+ void statusBarTextChanged(const QString& text);
+ void linkClicked(const QUrl &url);
+ void selectionChanged();
+ void iconLoaded();
+ void urlChanged(const QUrl &url);
+
+protected:
+ void resizeEvent(QResizeEvent *e);
+ void paintEvent(QPaintEvent *ev);
+
+ virtual QWebView *createWindow();
+
+ virtual void mouseMoveEvent(QMouseEvent*);
+ virtual void mousePressEvent(QMouseEvent*);
+ virtual void mouseDoubleClickEvent(QMouseEvent*);
+ virtual void mouseReleaseEvent(QMouseEvent*);
+ virtual void contextMenuEvent(QContextMenuEvent*);
+ virtual void wheelEvent(QWheelEvent*);
+ virtual void keyPressEvent(QKeyEvent*);
+ virtual void keyReleaseEvent(QKeyEvent*);
+ virtual void dragEnterEvent(QDragEnterEvent *);
+ virtual void dragLeaveEvent(QDragLeaveEvent *);
+ virtual void dragMoveEvent(QDragMoveEvent *);
+ virtual void dropEvent(QDropEvent *);
+ virtual void focusInEvent(QFocusEvent*);
+ virtual void focusOutEvent(QFocusEvent*);
+
+ virtual bool focusNextPrevChild(bool next);
+
+private:
+ friend class QWebPage;
+ QWebViewPrivate *d;
+};
+
+#endif // QWEBVIEW_H
diff --git a/WebKit/qt/Plugins/ICOHandler.cpp b/WebKit/qt/Plugins/ICOHandler.cpp
new file mode 100644
index 0000000..6f3b2f0
--- /dev/null
+++ b/WebKit/qt/Plugins/ICOHandler.cpp
@@ -0,0 +1,459 @@
+/*
+ * kimgio import filter for MS Windows .ico files
+ *
+ * Distributed under the terms of the LGPL
+ * Copyright (c) 2000 Malte Starostik <malte@kde.org>
+ *
+ */
+
+#include "ICOHandler.h"
+
+#include <cstring>
+#include <cstdlib>
+#include <algorithm>
+#include <vector>
+
+#include <QtGui/QImage>
+#include <QtGui/QBitmap>
+#include <QtGui/QApplication>
+#include <QtCore/QVector>
+#include <QtGui/QDesktopWidget>
+
+namespace
+{
+ // Global header (see http://www.daubnet.com/formats/ICO.html)
+ struct IcoHeader
+ {
+ enum Type { Icon = 1, Cursor };
+ quint16 reserved;
+ quint16 type;
+ quint16 count;
+ };
+
+ inline QDataStream& operator >>( QDataStream& s, IcoHeader& h )
+ {
+ return s >> h.reserved >> h.type >> h.count;
+ }
+
+ // Based on qt_read_dib et al. from qimage.cpp
+ // (c) 1992-2002 Trolltech AS.
+ struct BMP_INFOHDR
+ {
+ static const quint32 Size = 40;
+ quint32 biSize; // size of this struct
+ quint32 biWidth; // pixmap width
+ quint32 biHeight; // pixmap height
+ quint16 biPlanes; // should be 1
+ quint16 biBitCount; // number of bits per pixel
+ enum Compression { RGB = 0 };
+ quint32 biCompression; // compression method
+ quint32 biSizeImage; // size of image
+ quint32 biXPelsPerMeter; // horizontal resolution
+ quint32 biYPelsPerMeter; // vertical resolution
+ quint32 biClrUsed; // number of colors used
+ quint32 biClrImportant; // number of important colors
+ };
+ const quint32 BMP_INFOHDR::Size;
+
+ QDataStream& operator >>( QDataStream &s, BMP_INFOHDR &bi )
+ {
+ s >> bi.biSize;
+ if ( bi.biSize == BMP_INFOHDR::Size )
+ {
+ s >> bi.biWidth >> bi.biHeight >> bi.biPlanes >> bi.biBitCount;
+ s >> bi.biCompression >> bi.biSizeImage;
+ s >> bi.biXPelsPerMeter >> bi.biYPelsPerMeter;
+ s >> bi.biClrUsed >> bi.biClrImportant;
+ }
+ return s;
+ }
+
+#if 0
+ QDataStream &operator<<( QDataStream &s, const BMP_INFOHDR &bi )
+ {
+ s << bi.biSize;
+ s << bi.biWidth << bi.biHeight;
+ s << bi.biPlanes;
+ s << bi.biBitCount;
+ s << bi.biCompression;
+ s << bi.biSizeImage;
+ s << bi.biXPelsPerMeter << bi.biYPelsPerMeter;
+ s << bi.biClrUsed << bi.biClrImportant;
+ return s;
+ }
+#endif
+
+ // Header for every icon in the file
+ struct IconRec
+ {
+ unsigned char width;
+ unsigned char height;
+ quint16 colors;
+ quint16 hotspotX;
+ quint16 hotspotY;
+ quint32 size;
+ quint32 offset;
+ };
+
+ inline QDataStream& operator >>( QDataStream& s, IconRec& r )
+ {
+ return s >> r.width >> r.height >> r.colors
+ >> r.hotspotX >> r.hotspotY >> r.size >> r.offset;
+ }
+
+ struct LessDifference
+ {
+ LessDifference( unsigned s, unsigned c )
+ : size( s ), colors( c ) {}
+
+ bool operator ()( const IconRec& lhs, const IconRec& rhs ) const
+ {
+ // closest size match precedes everything else
+ if ( std::abs( int( lhs.width - size ) ) <
+ std::abs( int( rhs.width - size ) ) ) return true;
+ else if ( std::abs( int( lhs.width - size ) ) >
+ std::abs( int( rhs.width - size ) ) ) return false;
+ else if ( colors == 0 )
+ {
+ // high/true color requested
+ if ( lhs.colors == 0 ) return true;
+ else if ( rhs.colors == 0 ) return false;
+ else return lhs.colors > rhs.colors;
+ }
+ else
+ {
+ // indexed icon requested
+ if ( lhs.colors == 0 && rhs.colors == 0 ) return false;
+ else if ( lhs.colors == 0 ) return false;
+ else return std::abs( int( lhs.colors - colors ) ) <
+ std::abs( int( rhs.colors - colors ) );
+ }
+ }
+ unsigned size;
+ unsigned colors;
+ };
+
+ bool loadFromDIB( QDataStream& stream, const IconRec& rec, QImage& icon )
+ {
+ BMP_INFOHDR header;
+ stream >> header;
+ if ( stream.atEnd() || header.biSize != BMP_INFOHDR::Size ||
+ header.biSize > rec.size ||
+ header.biCompression != BMP_INFOHDR::RGB ||
+ ( header.biBitCount != 1 && header.biBitCount != 4 &&
+ header.biBitCount != 8 && header.biBitCount != 24 &&
+ header.biBitCount != 32 ) ) return false;
+
+ unsigned paletteSize, paletteEntries;
+
+ if (header.biBitCount > 8)
+ {
+ paletteEntries = 0;
+ paletteSize = 0;
+ }
+ else
+ {
+ paletteSize = (1 << header.biBitCount);
+ paletteEntries = paletteSize;
+ if (header.biClrUsed && header.biClrUsed < paletteSize)
+ paletteEntries = header.biClrUsed;
+ }
+
+ // Always create a 32-bit image to get the mask right
+ // Note: this is safe as rec.width, rec.height are bytes
+ icon = QImage( rec.width, rec.height, QImage::Format_ARGB32 );
+ if ( icon.isNull() ) return false;
+
+ QVector< QRgb > colorTable( paletteSize );
+
+ colorTable.fill( QRgb( 0 ) );
+ for ( unsigned i = 0; i < paletteEntries; ++i )
+ {
+ unsigned char rgb[ 4 ];
+ stream.readRawData( reinterpret_cast< char* >( &rgb ),
+ sizeof( rgb ) );
+ colorTable[ i ] = qRgb( rgb[ 2 ], rgb[ 1 ], rgb[ 0 ] );
+ }
+
+ unsigned bpl = ( rec.width * header.biBitCount + 31 ) / 32 * 4;
+
+ unsigned char* buf = new unsigned char[ bpl ];
+ for ( unsigned y = rec.height; !stream.atEnd() && y--; )
+ {
+ stream.readRawData( reinterpret_cast< char* >( buf ), bpl );
+ unsigned char* pixel = buf;
+ QRgb* p = reinterpret_cast< QRgb* >( icon.scanLine( y ) );
+ switch ( header.biBitCount )
+ {
+ case 1:
+ for ( unsigned x = 0; x < rec.width; ++x )
+ *p++ = colorTable[
+ ( pixel[ x / 8 ] >> ( 7 - ( x & 0x07 ) ) ) & 1 ];
+ break;
+ case 4:
+ for ( unsigned x = 0; x < rec.width; ++x )
+ if ( x & 1 ) *p++ = colorTable[ pixel[ x / 2 ] & 0x0f ];
+ else *p++ = colorTable[ pixel[ x / 2 ] >> 4 ];
+ break;
+ case 8:
+ for ( unsigned x = 0; x < rec.width; ++x )
+ *p++ = colorTable[ pixel[ x ] ];
+ break;
+ case 24:
+ for ( unsigned x = 0; x < rec.width; ++x )
+ *p++ = qRgb( pixel[ 3 * x + 2 ],
+ pixel[ 3 * x + 1 ],
+ pixel[ 3 * x ] );
+ break;
+ case 32:
+ for ( unsigned x = 0; x < rec.width; ++x )
+ *p++ = qRgba( pixel[ 4 * x + 2 ],
+ pixel[ 4 * x + 1 ],
+ pixel[ 4 * x ],
+ pixel[ 4 * x + 3] );
+ break;
+ }
+ }
+ delete[] buf;
+
+ if ( header.biBitCount < 32 )
+ {
+ // Traditional 1-bit mask
+ bpl = ( rec.width + 31 ) / 32 * 4;
+ buf = new unsigned char[ bpl ];
+ for ( unsigned y = rec.height; y--; )
+ {
+ stream.readRawData( reinterpret_cast< char* >( buf ), bpl );
+ QRgb* p = reinterpret_cast< QRgb* >( icon.scanLine( y ) );
+ for ( unsigned x = 0; x < rec.width; ++x, ++p )
+ if ( ( ( buf[ x / 8 ] >> ( 7 - ( x & 0x07 ) ) ) & 1 ) )
+ *p &= RGB_MASK;
+ }
+ delete[] buf;
+ }
+ return true;
+ }
+}
+
+ICOHandler::ICOHandler()
+{
+}
+
+bool ICOHandler::canRead() const
+{
+ return canRead(device());
+}
+
+bool ICOHandler::read(QImage *outImage)
+{
+
+ qint64 offset = device()->pos();
+
+ QDataStream stream( device() );
+ stream.setByteOrder( QDataStream::LittleEndian );
+ IcoHeader header;
+ stream >> header;
+ if ( stream.atEnd() || !header.count ||
+ ( header.type != IcoHeader::Icon && header.type != IcoHeader::Cursor) )
+ return false;
+
+ unsigned requestedSize = 32;
+ unsigned requestedColors = QApplication::desktop()->depth() > 8 ? 0 : QApplication::desktop()->depth();
+ int requestedIndex = -1;
+#if 0
+ if ( io->parameters() )
+ {
+ QStringList params = QString(io->parameters()).split( ';', QString::SkipEmptyParts );
+ QMap< QString, QString > options;
+ for ( QStringList::ConstIterator it = params.begin();
+ it != params.end(); ++it )
+ {
+ QStringList tmp = (*it).split( '=', QString::SkipEmptyParts );
+ if ( tmp.count() == 2 ) options[ tmp[ 0 ] ] = tmp[ 1 ];
+ }
+ if ( options[ "index" ].toUInt() )
+ requestedIndex = options[ "index" ].toUInt();
+ if ( options[ "size" ].toUInt() )
+ requestedSize = options[ "size" ].toUInt();
+ if ( options[ "colors" ].toUInt() )
+ requestedColors = options[ "colors" ].toUInt();
+ }
+#endif
+
+ typedef std::vector< IconRec > IconList;
+ IconList icons;
+ for ( unsigned i = 0; i < header.count; ++i )
+ {
+ if ( stream.atEnd() )
+ return false;
+ IconRec rec;
+ stream >> rec;
+ icons.push_back( rec );
+ }
+ IconList::const_iterator selected;
+ if (requestedIndex >= 0) {
+ selected = std::min( icons.begin() + requestedIndex, icons.end() );
+ } else {
+ selected = std::min_element( icons.begin(), icons.end(),
+ LessDifference( requestedSize, requestedColors ) );
+ }
+ if ( stream.atEnd() || selected == icons.end() ||
+ offset + selected->offset > device()->size() )
+ return false;
+
+ device()->seek( offset + selected->offset );
+ QImage icon;
+ if ( loadFromDIB( stream, *selected, icon ) )
+ {
+#ifndef QT_NO_IMAGE_TEXT
+ icon.setText( "X-Index", 0, QString::number( selected - icons.begin() ) );
+ if ( header.type == IcoHeader::Cursor )
+ {
+ icon.setText( "X-HotspotX", 0, QString::number( selected->hotspotX ) );
+ icon.setText( "X-HotspotY", 0, QString::number( selected->hotspotY ) );
+ }
+#endif
+ *outImage = icon;
+ return true;
+ }
+ return false;
+}
+
+bool ICOHandler::write(const QImage &/*image*/)
+{
+#if 0
+ if (image.isNull())
+ return;
+
+ QByteArray dibData;
+ QDataStream dib(dibData, QIODevice::ReadWrite);
+ dib.setByteOrder(QDataStream::LittleEndian);
+
+ QImage pixels = image;
+ QImage mask;
+ if (io->image().hasAlphaBuffer())
+ mask = image.createAlphaMask();
+ else
+ mask = image.createHeuristicMask();
+ mask.invertPixels();
+ for ( int y = 0; y < pixels.height(); ++y )
+ for ( int x = 0; x < pixels.width(); ++x )
+ if ( mask.pixel( x, y ) == 0 ) pixels.setPixel( x, y, 0 );
+
+ if (!qt_write_dib(dib, pixels))
+ return;
+
+ uint hdrPos = dib.device()->at();
+ if (!qt_write_dib(dib, mask))
+ return;
+ memmove(dibData.data() + hdrPos, dibData.data() + hdrPos + BMP_WIN + 8, dibData.size() - hdrPos - BMP_WIN - 8);
+ dibData.resize(dibData.size() - BMP_WIN - 8);
+
+ QDataStream ico(device());
+ ico.setByteOrder(QDataStream::LittleEndian);
+ IcoHeader hdr;
+ hdr.reserved = 0;
+ hdr.type = Icon;
+ hdr.count = 1;
+ ico << hdr.reserved << hdr.type << hdr.count;
+ IconRec rec;
+ rec.width = image.width();
+ rec.height = image.height();
+ if (image.numColors() <= 16)
+ rec.colors = 16;
+ else if (image.depth() <= 8)
+ rec.colors = 256;
+ else
+ rec.colors = 0;
+ rec.hotspotX = 0;
+ rec.hotspotY = 0;
+ rec.dibSize = dibData.size();
+ ico << rec.width << rec.height << rec.colors
+ << rec.hotspotX << rec.hotspotY << rec.dibSize;
+ rec.dibOffset = ico.device()->at() + sizeof(rec.dibOffset);
+ ico << rec.dibOffset;
+
+ BMP_INFOHDR dibHeader;
+ dib.device()->at(0);
+ dib >> dibHeader;
+ dibHeader.biHeight = image.height() << 1;
+ dib.device()->at(0);
+ dib << dibHeader;
+
+ ico.writeRawBytes(dibData.data(), dibData.size());
+ return true;
+#endif
+ return false;
+}
+
+QByteArray ICOHandler::name() const
+{
+ return "ico";
+}
+
+bool ICOHandler::canRead(QIODevice *device)
+{
+ if (!device) {
+ qWarning("ICOHandler::canRead() called with no device");
+ return false;
+ }
+
+ const qint64 oldPos = device->pos();
+
+ char head[8];
+ qint64 readBytes = device->read(head, sizeof(head));
+ const bool readOk = readBytes == sizeof(head);
+
+ if (device->isSequential()) {
+ while (readBytes > 0)
+ device->ungetChar(head[readBytes-- - 1]);
+ } else {
+ device->seek(oldPos);
+ }
+
+ if ( !readOk )
+ return false;
+
+ return head[2] == '\001' && head[3] == '\000' && // type should be 1
+ ( head[6] == 16 || head[6] == 32 || head[6] == 64 ) && // width can only be one of those
+ ( head[7] == 16 || head[7] == 32 || head[7] == 64 ); // same for height
+}
+
+class ICOPlugin : public QImageIOPlugin
+{
+public:
+ QStringList keys() const;
+ Capabilities capabilities(QIODevice *device, const QByteArray &format) const;
+ QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const;
+};
+
+QStringList ICOPlugin::keys() const
+{
+ return QStringList() << "ico" << "ICO";
+}
+
+QImageIOPlugin::Capabilities ICOPlugin::capabilities(QIODevice *device, const QByteArray &format) const
+{
+ if (format == "ico" || format == "ICO")
+ return Capabilities(CanRead);
+ if (!format.isEmpty())
+ return 0;
+ if (!device->isOpen())
+ return 0;
+
+ Capabilities cap;
+ if (device->isReadable() && ICOHandler::canRead(device))
+ cap |= CanRead;
+ return cap;
+}
+
+QImageIOHandler *ICOPlugin::create(QIODevice *device, const QByteArray &format) const
+{
+ QImageIOHandler *handler = new ICOHandler;
+ handler->setDevice(device);
+ handler->setFormat(format);
+ return handler;
+}
+
+Q_EXPORT_STATIC_PLUGIN(ICOPlugin)
+Q_EXPORT_PLUGIN2(qtwebico, ICOPlugin)
diff --git a/WebKit/qt/Plugins/ICOHandler.h b/WebKit/qt/Plugins/ICOHandler.h
new file mode 100644
index 0000000..4f1f1d6
--- /dev/null
+++ b/WebKit/qt/Plugins/ICOHandler.h
@@ -0,0 +1,52 @@
+/*
+ * ico.h - kimgio import filter for MS Windows .ico files
+ *
+ * Distributed under the terms of the LGPL
+ * Copyright (c) 2000 Malte Starostik <malte@kde.org>
+ *
+ */
+
+// You can use QImageIO::setParameters() to request a specific
+// Icon out of an .ico file:
+//
+// Options consist of a name=value pair and are separated by a semicolon.
+// Available options are:
+// size=<size> select the icon that most closely matches <size> (pixels)
+// default: 32
+// colors=<num> select the icon that has <num> colors (or comes closest)
+// default: 1 << display depth or 0 (RGB) if display depth > 8
+// index=<index> select the indexth icon from the file. If this option
+// is present, the size and colors options will be ignored.
+// default: none
+// If both size and colors are given, size takes precedence.
+//
+// The old format is still supported:
+// the parameters consist of a single string in the form
+// "<size>[:<colors>]" which correspond to the options above
+//
+// If an icon was returned (i.e. the file is valid and the index option
+// if present was not out of range), the icon's index within the .ico
+// file is returned in the text tag "X-Index" of the image.
+// If the icon is in fact a cursor, its hotspot coordinates are returned
+// in the text tags "X-HotspotX" and "X-HotspotY".
+
+#ifndef _ICOHANDLER_H_
+#define _ICOHANDLER_H_
+
+#include <QtGui/QImageIOPlugin>
+
+class ICOHandler : public QImageIOHandler
+{
+public:
+ ICOHandler();
+
+ bool canRead() const;
+ bool read(QImage *image);
+ bool write(const QImage &image);
+
+ QByteArray name() const;
+
+ static bool canRead(QIODevice *device);
+};
+
+#endif
diff --git a/WebKit/qt/Plugins/Plugins.pro b/WebKit/qt/Plugins/Plugins.pro
new file mode 100644
index 0000000..a9b4f82
--- /dev/null
+++ b/WebKit/qt/Plugins/Plugins.pro
@@ -0,0 +1,14 @@
+TEMPLATE = lib
+TARGET = qtwebico
+CONFIG += plugin
+HEADERS += ICOHandler.h
+SOURCES += ICOHandler.cpp
+
+include(../../WebKit.pri)
+
+contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
+unix:contains(QT_CONFIG, reduce_relocations):CONFIG += bsymbolic_functions
+
+target.path = $$[QT_INSTALL_PLUGINS]/imageformats
+INSTALLS += target
+
diff --git a/WebKit/qt/QtLauncher/QtLauncher.pro b/WebKit/qt/QtLauncher/QtLauncher.pro
new file mode 100644
index 0000000..eb43f96
--- /dev/null
+++ b/WebKit/qt/QtLauncher/QtLauncher.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+SOURCES += main.cpp
+CONFIG -= app_bundle
+DESTDIR = ../../../bin
+
+include(../../../WebKit.pri)
+
+macx:QT+=xml network
+QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
diff --git a/WebKit/qt/QtLauncher/main.cpp b/WebKit/qt/QtLauncher/main.cpp
new file mode 100644
index 0000000..7467c6b
--- /dev/null
+++ b/WebKit/qt/QtLauncher/main.cpp
@@ -0,0 +1,397 @@
+/*
+ * Copyright (C) 2006 George Staikos <staikos@kde.org>
+ * Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
+ * Copyright (C) 2006 Zack Rusin <zack@kde.org>
+ * Copyright (C) 2006 Simon Hausmann <hausmann@kde.org>
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 <qwebpage.h>
+#include <qwebview.h>
+#include <qwebframe.h>
+#include <qwebsettings.h>
+
+#include <QtGui>
+#include <QDebug>
+
+
+
+class InfoWidget :public QProgressBar {
+ Q_OBJECT
+public:
+ InfoWidget(QWidget *parent)
+ : QProgressBar(parent), m_progress(0)
+ {
+ setMinimum(0);
+ setMaximum(100);
+ }
+ QSize sizeHint() const
+ {
+ QSize size(100, 20);
+ return size;
+ }
+public slots:
+ void startLoad()
+ {
+ setValue(m_progress);
+ show();
+ }
+ void changeLoad(int change)
+ {
+ m_progress = change;
+ setValue(change);
+ }
+ void endLoad()
+ {
+ QTimer::singleShot(1000, this, SLOT(hide()));
+ m_progress = 0;
+ }
+
+protected:
+ int m_progress;
+};
+
+class HoverLabel : public QWidget {
+ Q_OBJECT
+public:
+ HoverLabel(QWidget *parent=0)
+ : QWidget(parent),
+ m_animating(false),
+ m_percent(0)
+ {
+ m_timer.setInterval(1000/30);
+ m_hideTimer.setInterval(500);
+ m_hideTimer.setSingleShot(true);
+ connect(&m_timer, SIGNAL(timeout()),
+ this, SLOT(update()));
+ connect(&m_hideTimer, SIGNAL(timeout()),
+ this, SLOT(hide()));
+ }
+
+public slots:
+ void setHoverLink(const QString &link) {
+ m_link = link;
+ if (m_link.isEmpty()) {
+ m_hideTimer.start();
+ } else {
+ m_hideTimer.stop();
+ m_oldSize = m_newSize;
+ m_newSize = sizeForFont();
+ resetAnimation();
+ updateSize();
+ show();
+ repaint();
+ }
+ }
+ QSize sizeForFont() const {
+ QFont f = font();
+ QFontMetrics fm(f);
+ return QSize(fm.width(m_link) + 10, fm.height() + 6);
+ }
+ QSize sizeHint() const {
+ if (!m_animating)
+ return sizeForFont();
+ else
+ return (m_newSize.width() > m_oldSize.width()) ? m_newSize : m_oldSize;
+ }
+ void updateSize() {
+ QRect r = geometry();
+ QSize newSize = sizeHint();
+ r = QRect(r.x(), r.y(), newSize.width(), newSize.height());
+ setGeometry(r);
+ }
+ void resetAnimation() {
+ m_animating = true;
+ m_percent = 0;
+ if (!m_timer.isActive())
+ m_timer.start();
+ }
+protected:
+ void paintEvent(QPaintEvent *e) {
+ QPainter p(this);
+ p.setClipRect(e->rect());
+ p.setPen(QPen(Qt::black, 1));
+ QLinearGradient gradient(rect().topLeft(), rect().bottomLeft());
+ gradient.setColorAt(0, QColor(255, 255, 255, 220));
+ gradient.setColorAt(1, QColor(193, 193, 193, 220));
+ p.setBrush(QBrush(gradient));
+ QSize size;
+ {
+ //draw a nicely rounded corner rectangle. to avoid unwanted
+ // borders we move the coordinates outsize the our clip region
+ size = interpolate(m_oldSize, m_newSize, m_percent);
+ QRect r(-1, 0, size.width(), size.height()+2);
+ const int roundness = 20;
+ QPainterPath path;
+ path.moveTo(r.x(), r.y());
+ path.lineTo(r.topRight().x()-roundness, r.topRight().y());
+ path.cubicTo(r.topRight().x(), r.topRight().y(),
+ r.topRight().x(), r.topRight().y(),
+ r.topRight().x(), r.topRight().y() + roundness);
+ path.lineTo(r.bottomRight());
+ path.lineTo(r.bottomLeft());
+ path.closeSubpath();
+ p.setRenderHint(QPainter::Antialiasing);
+ p.drawPath(path);
+ }
+ if (m_animating) {
+ if (qFuzzyCompare(m_percent, 1)) {
+ m_animating = false;
+ m_percent = 0;
+ m_timer.stop();
+ } else {
+ m_percent += 0.1;
+ if (m_percent >= 0.99) {
+ m_percent = 1;
+ }
+ }
+ }
+
+ QString txt;
+ QFontMetrics fm(fontMetrics());
+ txt = fm.elidedText(m_link, Qt::ElideRight, size.width()-5);
+ p.drawText(5, height()-6, txt);
+ }
+
+private:
+ QSize interpolate(const QSize &src, const QSize &dst, qreal percent) {
+ int widthDiff = int((dst.width() - src.width()) * percent);
+ int heightDiff = int((dst.height() - src.height()) * percent);
+ return QSize(src.width() + widthDiff,
+ src.height() + heightDiff);
+ }
+ QString m_link;
+ bool m_animating;
+ QTimer m_timer;
+ QTimer m_hideTimer;
+ QSize m_oldSize;
+ QSize m_newSize;
+ qreal m_percent;
+};
+
+class SearchEdit;
+
+class ClearButton : public QPushButton {
+ Q_OBJECT
+public:
+ ClearButton(QWidget *w)
+ : QPushButton(w)
+ {
+ setMinimumSize(24, 24);
+ setFixedSize(24, 24);
+ setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ }
+ void paintEvent(QPaintEvent *event)
+ {
+ Q_UNUSED(event);
+ QPainter painter(this);
+ int height = parentWidget()->geometry().height();
+ int width = height; //parentWidget()->geometry().width();
+
+ painter.setRenderHint(QPainter::Antialiasing, true);
+ painter.setPen(Qt::lightGray);
+ painter.setBrush(isDown() ?
+ QColor(140, 140, 190) :
+ underMouse() ? QColor(220, 220, 255) : QColor(200, 200, 230)
+ );
+ painter.drawEllipse(4, 4, width - 8, height - 8);
+ painter.setPen(Qt::white);
+ int border = 8;
+ painter.drawLine(border, border, width - border, height - border);
+ painter.drawLine(border, height - border, width - border, border);
+ }
+};
+
+class SearchEdit : public QLineEdit
+{
+ Q_OBJECT
+public:
+ SearchEdit(const QString &str, QWidget *parent = 0)
+ : QLineEdit(str, parent)
+ {
+ setMinimumSize(QSize(400, 24));
+ setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+
+ setStyleSheet(":enabled { padding-right: 27px }");
+ clearButton = new ClearButton(this);
+ clearButton->setGeometry(QRect(geometry().right() - 27,
+ geometry().top() - 2,
+ geometry().right(), geometry().bottom()));
+ clearButton->setVisible(true);
+#ifndef QT_NO_CURSOR
+ clearButton->setCursor(Qt::ArrowCursor);
+#endif
+#ifndef QT_NO_TOOLTIP
+ clearButton->setToolTip("Clear");
+#endif
+ connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
+ }
+ ~SearchEdit() { }
+protected:
+ virtual void paintEvent(QPaintEvent *e) {
+ QLineEdit::paintEvent(e);
+ if(text().isEmpty())
+ clearButton->setVisible(false);
+ else
+ clearButton->setVisible(true);
+ }
+ virtual void resizeEvent(QResizeEvent *) {
+ clearButton->setParent(this);
+ clearButton->setGeometry(QRect(width()-27,
+ 0,
+ 24, 24));
+ }
+ virtual void moveEvent(QMoveEvent *) {
+ clearButton->setParent(this);
+ clearButton->setGeometry(QRect(width()-27, 1,
+ 24, 24));
+ }
+
+ QPushButton *clearButton;
+};
+
+class WebPage : public QWebPage
+{
+public:
+ inline WebPage(QWidget *parent) : QWebPage(parent) {}
+
+ virtual QWebPage *createWindow();
+};
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+public:
+ MainWindow(const QUrl &url = QUrl())
+ {
+ view = new QWebView(this);
+ view->setPage(new WebPage(view));
+ InfoWidget *info = new InfoWidget(view);
+ info->setGeometry(20, 20, info->sizeHint().width(),
+ info->sizeHint().height());
+ connect(view, SIGNAL(loadStarted()),
+ info, SLOT(startLoad()));
+ connect(view, SIGNAL(loadProgressChanged(int)),
+ info, SLOT(changeLoad(int)));
+ connect(view, SIGNAL(loadFinished()),
+ info, SLOT(endLoad()));
+ connect(view, SIGNAL(loadFinished()),
+ this, SLOT(loadFinished()));
+ connect(view, SIGNAL(titleChanged(const QString&)),
+ this, SLOT(setWindowTitle(const QString&)));
+ connect(view->page(), SIGNAL(hoveringOverLink(const QString&, const QString&)),
+ this, SLOT(showLinkHover(const QString&, const QString&)));
+
+
+ setCentralWidget(view);
+
+ QToolBar *bar = addToolBar("Navigation");
+ urlEdit = new SearchEdit(url.toString());
+ urlEdit->setSizePolicy(QSizePolicy::Expanding, urlEdit->sizePolicy().verticalPolicy());
+ connect(urlEdit, SIGNAL(returnPressed()),
+ SLOT(changeLocation()));
+ bar->addAction(view->action(QWebPage::GoBack));
+ bar->addAction(view->action(QWebPage::Stop));
+ bar->addAction(view->action(QWebPage::GoForward));
+ bar->addSeparator();
+ bar->addAction(view->action(QWebPage::Cut));
+ bar->addAction(view->action(QWebPage::Copy));
+ bar->addAction(view->action(QWebPage::Paste));
+ bar->addSeparator();
+ bar->addAction(view->action(QWebPage::Undo));
+ bar->addAction(view->action(QWebPage::Redo));
+
+ addToolBarBreak();
+ bar = addToolBar("Location");
+ bar->addWidget(new QLabel(tr("Location:")));
+ bar->addWidget(urlEdit);
+
+ hoverLabel = new HoverLabel(this);
+ hoverLabel->hide();
+
+ if (url.isValid())
+ view->load(url);
+
+ info->raise();
+ }
+ inline QWebPage *webPage() const { return view->page(); }
+protected slots:
+ void changeLocation()
+ {
+ QUrl url(urlEdit->text());
+ view->load(url);
+ }
+ void loadFinished()
+ {
+ urlEdit->setText(view->url().toString());
+ }
+ void showLinkHover(const QString &link, const QString &toolTip)
+ {
+ //statusBar()->showMessage(link);
+ hoverLabel->setHoverLink(link);
+#ifndef QT_NO_TOOLTIP
+ if (!toolTip.isEmpty())
+ QToolTip::showText(QCursor::pos(), toolTip);
+#endif
+ }
+protected:
+ void resizeEvent(QResizeEvent *) {
+ QSize hoverSize = hoverLabel->sizeHint();
+ hoverLabel->setGeometry(0, height()-hoverSize.height(),
+ 300, hoverSize.height());
+ }
+private:
+ QWebView *view;
+ QLineEdit *urlEdit;
+ HoverLabel *hoverLabel;
+};
+
+QWebPage *WebPage::createWindow()
+{
+ MainWindow *mw = new MainWindow;
+ return mw->webPage();
+}
+
+#include "main.moc"
+
+int main(int argc, char **argv)
+{
+ QString url = QString("%1/%2").arg(QDir::homePath()).arg(QLatin1String("index.html"));
+ QApplication app(argc, argv);
+
+ QWebSettings::defaultSettings()->setAttribute(QWebSettings::PluginsEnabled);
+ QWebSettings::defaultSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled);
+
+ const QStringList args = app.arguments();
+ if (args.count() > 1)
+ url = args.at(1);
+
+ QUrl qurl(url);
+ if (qurl.scheme().isEmpty())
+ qurl = QUrl::fromLocalFile(QFileInfo(url).absoluteFilePath());
+ MainWindow window(qurl);
+ window.show();
+
+ return app.exec();
+}
diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
new file mode 100644
index 0000000..a106f03
--- /dev/null
+++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
@@ -0,0 +1,356 @@
+/*
+ * Copyright (C) 2006 Zack Rusin <zack@kde.org>
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 "ChromeClientQt.h"
+
+#include "Frame.h"
+#include "FrameLoadRequest.h"
+#include "FrameLoader.h"
+#include "FrameLoaderClientQt.h"
+#include "FrameView.h"
+#include "PlatformScrollBar.h"
+#include "HitTestResult.h"
+#include "NotImplemented.h"
+#include "WindowFeatures.h"
+
+#include "qwebpage.h"
+#include "qwebpage_p.h"
+#include "qwebframe_p.h"
+
+namespace WebCore
+{
+
+
+ChromeClientQt::ChromeClientQt(QWebPage* webPage)
+ : m_webPage(webPage)
+{
+
+}
+
+
+ChromeClientQt::~ChromeClientQt()
+{
+
+}
+
+void ChromeClientQt::setWindowRect(const FloatRect& rect)
+{
+ if (!m_webPage)
+ return;
+ emit m_webPage->geometryChangeRequest(QRect(qRound(rect.x()), qRound(rect.y()),
+ qRound(rect.width()), qRound(rect.height())));
+}
+
+
+FloatRect ChromeClientQt::windowRect()
+{
+ if (!m_webPage)
+ return FloatRect();
+
+ QWidget* view = m_webPage->view();
+ if (!view)
+ return FloatRect();
+ return IntRect(view->topLevelWidget()->geometry());
+}
+
+
+FloatRect ChromeClientQt::pageRect()
+{
+ if (!m_webPage)
+ return FloatRect();
+ return FloatRect(QRectF(QPointF(0,0), m_webPage->viewportSize()));
+}
+
+
+float ChromeClientQt::scaleFactor()
+{
+ notImplemented();
+ return 1;
+}
+
+
+void ChromeClientQt::focus()
+{
+ if (!m_webPage)
+ return;
+ QWidget* view = m_webPage->view();
+ if (!view)
+ return;
+
+ view->setFocus();
+}
+
+
+void ChromeClientQt::unfocus()
+{
+ if (!m_webPage)
+ return;
+ QWidget* view = m_webPage->view();
+ if (!view)
+ return;
+ view->clearFocus();
+}
+
+bool ChromeClientQt::canTakeFocus(FocusDirection)
+{
+ // This is called when cycling through links/focusable objects and we
+ // reach the last focusable object. Then we want to claim that we can
+ // take the focus to avoid wrapping.
+ return true;
+}
+
+void ChromeClientQt::takeFocus(FocusDirection)
+{
+ // don't do anything. This is only called when cycling to links/focusable objects,
+ // which in turn is called from focusNextPrevChild. We let focusNextPrevChild
+ // call QWidget::focusNextPrevChild accordingly, so there is no need to do anything
+ // here.
+}
+
+
+Page* ChromeClientQt::createWindow(Frame*, const FrameLoadRequest& request, const WindowFeatures& features)
+{
+ QWebPage *newPage = features.dialog ? m_webPage->createModalDialog() : m_webPage->createWindow();
+ if (!newPage)
+ return 0;
+ newPage->mainFrame()->load(request.resourceRequest().url());
+ return newPage->d->page;
+}
+
+void ChromeClientQt::show()
+{
+ if (!m_webPage)
+ return;
+ QWidget* view = m_webPage->view();
+ if (!view)
+ return;
+ view->topLevelWidget()->show();
+}
+
+
+bool ChromeClientQt::canRunModal()
+{
+ notImplemented();
+ return false;
+}
+
+
+void ChromeClientQt::runModal()
+{
+ notImplemented();
+}
+
+
+void ChromeClientQt::setToolbarsVisible(bool)
+{
+ notImplemented();
+}
+
+
+bool ChromeClientQt::toolbarsVisible()
+{
+ notImplemented();
+ return false;
+}
+
+
+void ChromeClientQt::setStatusbarVisible(bool)
+{
+ notImplemented();
+}
+
+
+bool ChromeClientQt::statusbarVisible()
+{
+ notImplemented();
+ return false;
+}
+
+
+void ChromeClientQt::setScrollbarsVisible(bool)
+{
+ notImplemented();
+}
+
+
+bool ChromeClientQt::scrollbarsVisible()
+{
+ notImplemented();
+ return true;
+}
+
+
+void ChromeClientQt::setMenubarVisible(bool)
+{
+ notImplemented();
+}
+
+bool ChromeClientQt::menubarVisible()
+{
+ notImplemented();
+ return false;
+}
+
+void ChromeClientQt::setResizable(bool)
+{
+ notImplemented();
+}
+
+void ChromeClientQt::addMessageToConsole(const String& message, unsigned int lineNumber,
+ const String& sourceID)
+{
+ QString x = message;
+ QString y = sourceID;
+ m_webPage->javaScriptConsoleMessage(x, lineNumber, y);
+}
+
+void ChromeClientQt::chromeDestroyed()
+{
+ delete this;
+}
+
+bool ChromeClientQt::canRunBeforeUnloadConfirmPanel()
+{
+ return true;
+}
+
+bool ChromeClientQt::runBeforeUnloadConfirmPanel(const String& message, Frame* frame)
+{
+ return runJavaScriptConfirm(frame, message);
+}
+
+void ChromeClientQt::closeWindowSoon()
+{
+ m_webPage->mainFrame()->d->frame->loader()->stopAllLoaders();
+ m_webPage->deleteLater();
+}
+
+void ChromeClientQt::runJavaScriptAlert(Frame* f, const String& msg)
+{
+ QString x = msg;
+ FrameLoaderClientQt *fl = static_cast<FrameLoaderClientQt*>(f->loader()->client());
+ m_webPage->javaScriptAlert(fl->webFrame(), x);
+}
+
+bool ChromeClientQt::runJavaScriptConfirm(Frame* f, const String& msg)
+{
+ QString x = msg;
+ FrameLoaderClientQt *fl = static_cast<FrameLoaderClientQt*>(f->loader()->client());
+ return m_webPage->javaScriptConfirm(fl->webFrame(), x);
+}
+
+bool ChromeClientQt::runJavaScriptPrompt(Frame* f, const String& message, const String& defaultValue, String& result)
+{
+ QString x = result;
+ FrameLoaderClientQt *fl = static_cast<FrameLoaderClientQt*>(f->loader()->client());
+ bool rc = m_webPage->javaScriptPrompt(fl->webFrame(), (QString)message, (QString)defaultValue, &x);
+ result = x;
+ return rc;
+}
+
+void ChromeClientQt::setStatusbarText(const String& msg)
+{
+ QString x = msg;
+ emit m_webPage->statusBarTextChanged(x);
+}
+
+bool ChromeClientQt::shouldInterruptJavaScript()
+{
+ notImplemented();
+ return false;
+}
+
+bool ChromeClientQt::tabsToLinks() const
+{
+ return m_webPage->settings()->testAttribute(QWebSettings::LinksIncludedInFocusChain);
+}
+
+IntRect ChromeClientQt::windowResizerRect() const
+{
+ return IntRect();
+}
+
+void ChromeClientQt::addToDirtyRegion(const IntRect& r)
+{
+ QWidget* view = m_webPage->view();
+ if (view) {
+ QRect rect(r);
+ rect = rect.intersected(QRect(QPoint(0, 0), m_webPage->viewportSize()));
+ if (!r.isEmpty())
+ view->update(r);
+ }
+}
+
+void ChromeClientQt::scrollBackingStore(int dx, int dy, const IntRect& scrollViewRect, const IntRect& clipRect)
+{
+ QWidget* view = m_webPage->view();
+ if (view)
+ view->scroll(dx, dy, scrollViewRect);
+}
+
+void ChromeClientQt::updateBackingStore()
+{
+}
+
+void ChromeClientQt::mouseDidMoveOverElement(const HitTestResult& result, unsigned modifierFlags)
+{
+ if (result.absoluteLinkURL() != lastHoverURL
+ || result.title() != lastHoverTitle
+ || result.textContent() != lastHoverContent) {
+ lastHoverURL = result.absoluteLinkURL();
+ lastHoverTitle = result.title();
+ lastHoverContent = result.textContent();
+ emit m_webPage->hoveringOverLink(lastHoverURL.prettyURL(),
+ lastHoverTitle, lastHoverContent);
+ }
+}
+
+void ChromeClientQt::setToolTip(const String &tip)
+{
+#ifndef QT_NO_TOOLTIP
+ QWidget* view = m_webPage->view();
+ if (view)
+ view->setToolTip(tip);
+#else
+ Q_UNUSED(tip);
+#endif
+}
+
+void ChromeClientQt::print(Frame*)
+{
+ notImplemented();
+}
+
+void ChromeClientQt::exceededDatabaseQuota(Frame*, const String&)
+{
+ notImplemented();
+}
+
+}
+
+
diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.h b/WebKit/qt/WebCoreSupport/ChromeClientQt.h
new file mode 100644
index 0000000..31d492b
--- /dev/null
+++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.h
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2006 Zack Rusin <zack@kde.org>
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 ChromeClientQt_H
+#define ChromeClientQt_H
+
+#include "ChromeClient.h"
+#include "FloatRect.h"
+#include "RefCounted.h"
+#include "KURL.h"
+#include "PlatformString.h"
+
+class QWebPage;
+
+namespace WebCore {
+
+ class FloatRect;
+ class Page;
+ struct FrameLoadRequest;
+
+ class ChromeClientQt : public ChromeClient
+ {
+ public:
+ ChromeClientQt(QWebPage* webPage);
+ virtual ~ChromeClientQt();
+ virtual void chromeDestroyed();
+
+ virtual void setWindowRect(const FloatRect&);
+ virtual FloatRect windowRect();
+
+ virtual FloatRect pageRect();
+
+ virtual float scaleFactor();
+
+ virtual void focus();
+ virtual void unfocus();
+
+ virtual bool canTakeFocus(FocusDirection);
+ virtual void takeFocus(FocusDirection);
+
+ virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&);
+ virtual void show();
+
+ virtual bool canRunModal();
+ virtual void runModal();
+
+ virtual void setToolbarsVisible(bool);
+ virtual bool toolbarsVisible();
+
+ virtual void setStatusbarVisible(bool);
+ virtual bool statusbarVisible();
+
+ virtual void setScrollbarsVisible(bool);
+ virtual bool scrollbarsVisible();
+
+ virtual void setMenubarVisible(bool);
+ virtual bool menubarVisible();
+
+ virtual void setResizable(bool);
+
+ virtual void addMessageToConsole(const String& message, unsigned int lineNumber,
+ const String& sourceID);
+
+ virtual bool canRunBeforeUnloadConfirmPanel();
+ virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame* frame);
+
+ virtual void closeWindowSoon();
+
+ virtual void runJavaScriptAlert(Frame*, const String&);
+ virtual bool runJavaScriptConfirm(Frame*, const String&);
+ virtual bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result);
+ virtual bool shouldInterruptJavaScript();
+
+ virtual void setStatusbarText(const String&);
+
+ virtual bool tabsToLinks() const;
+ virtual IntRect windowResizerRect() const;
+ virtual void addToDirtyRegion(const IntRect&);
+ virtual void scrollBackingStore(int, int, const IntRect&, const IntRect&);
+ virtual void updateBackingStore();
+
+ virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags);
+
+ virtual void setToolTip(const String&);
+
+ virtual void print(Frame*);
+
+ virtual void exceededDatabaseQuota(Frame*, const String&);
+
+ QWebPage* m_webPage;
+ WebCore::KURL lastHoverURL;
+ WebCore::String lastHoverTitle;
+ WebCore::String lastHoverContent;
+ };
+}
+
+#endif
diff --git a/WebKit/qt/WebCoreSupport/ContextMenuClientQt.cpp b/WebKit/qt/WebCoreSupport/ContextMenuClientQt.cpp
new file mode 100644
index 0000000..ae9d718
--- /dev/null
+++ b/WebKit/qt/WebCoreSupport/ContextMenuClientQt.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2006 Zack Rusin <zack@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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 "ContextMenuClientQt.h"
+
+#include "ContextMenu.h"
+#include "HitTestResult.h"
+#include "KURL.h"
+#include "RefCounted.h"
+#include "NotImplemented.h"
+
+#include <stdio.h>
+
+namespace WebCore {
+
+void ContextMenuClientQt::contextMenuDestroyed()
+{
+ delete this;
+}
+
+PlatformMenuDescription ContextMenuClientQt::getCustomMenuFromDefaultItems(ContextMenu* menu)
+{
+ // warning: this transfers the ownership to the caller
+ return menu->releasePlatformDescription();
+}
+
+void ContextMenuClientQt::contextMenuItemSelected(ContextMenuItem*, const ContextMenu*)
+{
+ notImplemented();
+}
+
+void ContextMenuClientQt::downloadURL(const KURL& url)
+{
+ notImplemented();
+}
+
+void ContextMenuClientQt::lookUpInDictionary(Frame*)
+{
+ notImplemented();
+}
+
+void ContextMenuClientQt::speak(const String&)
+{
+ notImplemented();
+}
+
+void ContextMenuClientQt::stopSpeaking()
+{
+ notImplemented();
+}
+
+void ContextMenuClientQt::searchWithGoogle(const Frame*)
+{
+ notImplemented();
+}
+
+}
+
diff --git a/WebKit/qt/WebCoreSupport/ContextMenuClientQt.h b/WebKit/qt/WebCoreSupport/ContextMenuClientQt.h
new file mode 100644
index 0000000..ad6bfae
--- /dev/null
+++ b/WebKit/qt/WebCoreSupport/ContextMenuClientQt.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2006 Zack Rusin <zack@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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 ContextMenuClientQt_h
+#define ContextMenuClientQt_h
+
+#include "ContextMenuClient.h"
+
+#include <RefCounted.h>
+
+namespace WebCore {
+ class ContextMenu;
+
+ class ContextMenuClientQt : public ContextMenuClient
+ {
+ public:
+ virtual void contextMenuDestroyed();
+
+ virtual PlatformMenuDescription getCustomMenuFromDefaultItems(ContextMenu*);
+ virtual void contextMenuItemSelected(ContextMenuItem*, const ContextMenu*);
+
+ virtual void downloadURL(const KURL& url);
+ virtual void lookUpInDictionary(Frame*);
+ virtual void speak(const String&);
+ virtual void stopSpeaking();
+ virtual void searchWithGoogle(const Frame*);
+ };
+}
+
+#endif
diff --git a/WebKit/qt/WebCoreSupport/DragClientQt.cpp b/WebKit/qt/WebCoreSupport/DragClientQt.cpp
new file mode 100644
index 0000000..b719868
--- /dev/null
+++ b/WebKit/qt/WebCoreSupport/DragClientQt.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2007 Apple Inc. All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 "DragClientQt.h"
+
+#include "ClipboardQt.h"
+#include "qwebpage.h"
+
+#include <QDrag>
+#include <QMimeData>
+
+
+namespace WebCore {
+
+DragDestinationAction DragClientQt::actionMaskForDrag(DragData*)
+{
+ return DragDestinationActionAny;
+}
+
+void DragClientQt::willPerformDragDestinationAction(DragDestinationAction, DragData*)
+{
+}
+
+void DragClientQt::dragControllerDestroyed()
+{
+ delete this;
+}
+
+DragSourceAction DragClientQt::dragSourceActionMaskForPoint(const IntPoint&)
+{
+ return DragSourceActionAny;
+}
+
+void DragClientQt::willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*)
+{
+}
+
+void DragClientQt::startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard* clipboard, Frame*, bool)
+{
+#ifndef QT_NO_DRAGANDDROP
+ QMimeData* clipboardData = static_cast<ClipboardQt*>(clipboard)->clipboardData();
+ static_cast<ClipboardQt*>(clipboard)->invalidateWritableData();
+ QWidget* view = m_webPage->view();
+ if (view) {
+ QDrag *drag = new QDrag(view);
+ drag->setMimeData(clipboardData);
+ drag->start();
+ }
+#endif
+}
+
+
+DragImageRef DragClientQt::createDragImageForLink(KURL&, const String&, Frame*)
+{
+ return 0;
+}
+
+} // namespace WebCore
diff --git a/WebKit/qt/WebCoreSupport/DragClientQt.h b/WebKit/qt/WebCoreSupport/DragClientQt.h
new file mode 100644
index 0000000..4c83191
--- /dev/null
+++ b/WebKit/qt/WebCoreSupport/DragClientQt.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2007 Apple Inc. All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 "DragClient.h"
+class QWebPage;
+namespace WebCore {
+
+class DragClientQt : public DragClient {
+public:
+ DragClientQt(QWebPage* webPage) : m_webPage(webPage) {};
+ virtual void willPerformDragDestinationAction(DragDestinationAction,
+ DragData*);
+ virtual WebCore::DragDestinationAction actionMaskForDrag(DragData*);
+ virtual void dragControllerDestroyed();
+ virtual DragSourceAction dragSourceActionMaskForPoint(const IntPoint&);
+ virtual void willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*);
+ virtual void startDrag(DragImageRef dragImage, const IntPoint& dragImageOrigin, const IntPoint& eventPos, Clipboard*, Frame*, bool linkDrag = false);
+ virtual DragImageRef createDragImageForLink(KURL&, const String& label, Frame*);
+private:
+ QWebPage* m_webPage;
+};
+
+}
+
diff --git a/WebKit/qt/WebCoreSupport/EditCommandQt.cpp b/WebKit/qt/WebCoreSupport/EditCommandQt.cpp
new file mode 100644
index 0000000..e316a16
--- /dev/null
+++ b/WebKit/qt/WebCoreSupport/EditCommandQt.cpp
@@ -0,0 +1,52 @@
+/*
+ Copyright (C) 2007 Staikos Computing Services Inc.
+
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <wtf/Platform.h>
+#include "EditCommandQt.h"
+
+using namespace WebCore;
+
+EditCommandQt::EditCommandQt(WTF::RefPtr<EditCommand> cmd, QUndoCommand *parent)
+: QUndoCommand(parent), _cmd(cmd), _first(true) {
+}
+
+
+EditCommandQt::~EditCommandQt() {
+}
+
+
+void EditCommandQt::redo() {
+ if (_first) {
+ _first = false;
+ return;
+ }
+ if (_cmd) {
+ _cmd->reapply();
+ }
+}
+
+
+void EditCommandQt::undo() {
+ if (_cmd) {
+ _cmd->unapply();
+ }
+}
+
+
+// vim: ts=4 sw=4 et
diff --git a/WebKit/qt/WebCoreSupport/EditCommandQt.h b/WebKit/qt/WebCoreSupport/EditCommandQt.h
new file mode 100644
index 0000000..dd7c85a
--- /dev/null
+++ b/WebKit/qt/WebCoreSupport/EditCommandQt.h
@@ -0,0 +1,42 @@
+/*
+ Copyright (C) 2007 Staikos Computing Services Inc.
+
+ 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., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef EDITCOMMANDQT_H
+#define EDITCOMMANDQT_H
+
+
+#include <QUndoCommand>
+#include <EditCommand.h>
+
+class EditCommandQt : public QUndoCommand {
+ public:
+ EditCommandQt(WTF::RefPtr<WebCore::EditCommand> cmd, QUndoCommand *parent = 0);
+ ~EditCommandQt();
+
+ void redo();
+ void undo();
+
+ private:
+ WTF::RefPtr<WebCore::EditCommand> _cmd;
+ bool _first;
+};
+
+#endif
+
+// vim: ts=4 sw=4 et
diff --git a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp
new file mode 100644
index 0000000..fced385
--- /dev/null
+++ b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp
@@ -0,0 +1,551 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ * Copyright (C) 2006 Zack Rusin <zack@kde.org>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 "EditorClientQt.h"
+
+#include "qwebpage.h"
+#include "qwebpage_p.h"
+
+#include "Document.h"
+#include "EditCommandQt.h"
+#include "Page.h"
+#include "Editor.h"
+#include "FocusController.h"
+#include "Frame.h"
+#include "KeyboardCodes.h"
+#include "KeyboardEvent.h"
+#include "Page.h"
+#include "PlatformKeyboardEvent.h"
+#include "NotImplemented.h"
+#include "Node.h"
+#include "Range.h"
+
+#include <stdio.h>
+
+#include <QUndoStack>
+#define methodDebug() qDebug("EditorClientQt: %s", __FUNCTION__);
+
+static bool dumpEditingCallbacks = false;
+static bool drt_run = false;
+static bool acceptsEditing = true;
+void QWEBKIT_EXPORT qt_dump_editing_callbacks(bool b)
+{
+ dumpEditingCallbacks = b;
+}
+void QWEBKIT_EXPORT qt_drt_run(bool b)
+{
+ drt_run = b;
+}
+
+void QWEBKIT_EXPORT qt_dump_set_accepts_editing(bool b)
+{
+ acceptsEditing = b;
+}
+
+
+static QString dumpPath(WebCore::Node *node)
+{
+ QString str = node->nodeName();
+
+ WebCore::Node *parent = node->parentNode();
+ while (parent) {
+ str.append(QLatin1String(" > "));
+ str.append(parent->nodeName());
+ parent = parent->parentNode();
+ }
+ return str;
+}
+
+static QString dumpRange(WebCore::Range *range)
+{
+ if (!range)
+ return QLatin1String("(null)");
+ QString str;
+ WebCore::ExceptionCode code;
+ str.sprintf("range from %ld of %ls to %ld of %ls",
+ range->startOffset(code), dumpPath(range->startContainer(code)).unicode(),
+ range->endOffset(code), dumpPath(range->endContainer(code)).unicode());
+ return str;
+}
+
+
+namespace WebCore {
+
+
+bool EditorClientQt::shouldDeleteRange(Range* range)
+{
+ if (dumpEditingCallbacks)
+ printf("EDITING DELEGATE: shouldDeleteDOMRange:%s\n", dumpRange(range).toUtf8().constData());
+
+ return true;
+}
+
+bool EditorClientQt::shouldShowDeleteInterface(HTMLElement* element)
+{
+ if (drt_run)
+ return element->className() == "needsDeletionUI";
+ return false;
+}
+
+bool EditorClientQt::isContinuousSpellCheckingEnabled()
+{
+ return false;
+}
+
+bool EditorClientQt::isGrammarCheckingEnabled()
+{
+ return false;
+}
+
+int EditorClientQt::spellCheckerDocumentTag()
+{
+ return 0;
+}
+
+bool EditorClientQt::shouldBeginEditing(WebCore::Range* range)
+{
+ if (dumpEditingCallbacks)
+ printf("EDITING DELEGATE: shouldBeginEditingInDOMRange:%s\n", dumpRange(range).toUtf8().constData());
+ return true;
+}
+
+bool EditorClientQt::shouldEndEditing(WebCore::Range* range)
+{
+ if (dumpEditingCallbacks)
+ printf("EDITING DELEGATE: shouldEndEditingInDOMRange:%s\n", dumpRange(range).toUtf8().constData());
+ return true;
+}
+
+bool EditorClientQt::shouldInsertText(String string, Range* range, EditorInsertAction action)
+{
+ if (dumpEditingCallbacks) {
+ static const char *insertactionstring[] = {
+ "WebViewInsertActionTyped",
+ "WebViewInsertActionPasted",
+ "WebViewInsertActionDropped",
+ };
+
+ printf("EDITING DELEGATE: shouldInsertText:%s replacingDOMRange:%s givenAction:%s\n",
+ QString(string).toUtf8().constData(), dumpRange(range).toUtf8().constData(), insertactionstring[action]);
+ }
+ return acceptsEditing;
+}
+
+bool EditorClientQt::shouldChangeSelectedRange(Range* currentRange, Range* proposedRange, EAffinity selectionAffinity, bool stillSelecting)
+{
+ if (dumpEditingCallbacks) {
+ static const char *affinitystring[] = {
+ "NSSelectionAffinityUpstream",
+ "NSSelectionAffinityDownstream"
+ };
+ static const char *boolstring[] = {
+ "FALSE",
+ "TRUE"
+ };
+
+ printf("EDITING DELEGATE: shouldChangeSelectedDOMRange:%s toDOMRange:%s affinity:%s stillSelecting:%s\n",
+ dumpRange(currentRange).toUtf8().constData(),
+ dumpRange(proposedRange).toUtf8().constData(),
+ affinitystring[selectionAffinity], boolstring[stillSelecting]);
+ }
+ return acceptsEditing;
+}
+
+bool EditorClientQt::shouldApplyStyle(WebCore::CSSStyleDeclaration* style,
+ WebCore::Range* range)
+{
+ if (dumpEditingCallbacks)
+ printf("EDITING DELEGATE: shouldApplyStyle:%s toElementsInDOMRange:%s\n",
+ QString(style->cssText()).toUtf8().constData(), dumpRange(range).toUtf8().constData());
+ return acceptsEditing;
+}
+
+bool EditorClientQt::shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range*)
+{
+ notImplemented();
+ return true;
+}
+
+void EditorClientQt::didBeginEditing()
+{
+ if (dumpEditingCallbacks)
+ printf("EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification\n");
+ m_editing = true;
+}
+
+void EditorClientQt::respondToChangedContents()
+{
+ if (dumpEditingCallbacks)
+ printf("EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification\n");
+ m_page->d->modified = true;
+}
+
+void EditorClientQt::respondToChangedSelection()
+{
+ if (dumpEditingCallbacks)
+ printf("EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification\n");
+// const Selection &selection = m_page->d->page->selection();
+// char buffer[1024];
+// selection.formatForDebugger(buffer, sizeof(buffer));
+// printf("%s\n", buffer);
+
+ m_page->d->updateEditorActions();
+ emit m_page->selectionChanged();
+}
+
+void EditorClientQt::didEndEditing()
+{
+ if (dumpEditingCallbacks)
+ printf("EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification\n");
+ m_editing = false;
+}
+
+void EditorClientQt::didWriteSelectionToPasteboard()
+{
+}
+
+void EditorClientQt::didSetSelectionTypesForPasteboard()
+{
+}
+
+bool EditorClientQt::selectWordBeforeMenuEvent()
+{
+ notImplemented();
+ return false;
+}
+
+bool EditorClientQt::isEditable()
+{
+ // FIXME: should be controllable by a setting in QWebPage
+ return false;
+}
+
+void EditorClientQt::registerCommandForUndo(WTF::PassRefPtr<WebCore::EditCommand> cmd)
+{
+ Frame* frame = m_page->d->page->focusController()->focusedOrMainFrame();
+ if (m_inUndoRedo || (frame && !frame->editor()->lastEditCommand() /* HACK!! Don't recreate undos */)) {
+ return;
+ }
+ m_page->undoStack()->push(new EditCommandQt(cmd));
+}
+
+void EditorClientQt::registerCommandForRedo(WTF::PassRefPtr<WebCore::EditCommand>)
+{
+}
+
+void EditorClientQt::clearUndoRedoOperations()
+{
+ return m_page->undoStack()->clear();
+}
+
+bool EditorClientQt::canUndo() const
+{
+ return m_page->undoStack()->canUndo();
+}
+
+bool EditorClientQt::canRedo() const
+{
+ return m_page->undoStack()->canRedo();
+}
+
+void EditorClientQt::undo()
+{
+ m_inUndoRedo = true;
+ m_page->undoStack()->undo();
+ m_inUndoRedo = false;
+}
+
+void EditorClientQt::redo()
+{
+ m_inUndoRedo = true;
+ m_page->undoStack()->redo();
+ m_inUndoRedo = false;
+}
+
+bool EditorClientQt::shouldInsertNode(Node* node, Range* range, EditorInsertAction action)
+{
+ if (dumpEditingCallbacks) {
+ static const char *insertactionstring[] = {
+ "WebViewInsertActionTyped",
+ "WebViewInsertActionPasted",
+ "WebViewInsertActionDropped",
+ };
+
+ printf("EDITING DELEGATE: shouldInsertNode:%s replacingDOMRange:%s givenAction:%s\n", dumpPath(node).toUtf8().constData(),
+ dumpRange(range).toUtf8().constData(), insertactionstring[action]);
+ }
+ return acceptsEditing;
+}
+
+void EditorClientQt::pageDestroyed()
+{
+ delete this;
+}
+
+bool EditorClientQt::smartInsertDeleteEnabled()
+{
+ notImplemented();
+ return false;
+}
+
+void EditorClientQt::toggleContinuousSpellChecking()
+{
+ notImplemented();
+}
+
+void EditorClientQt::toggleGrammarChecking()
+{
+ notImplemented();
+}
+
+void EditorClientQt::handleKeyboardEvent(KeyboardEvent* event)
+{
+ Frame* frame = m_page->d->page->focusController()->focusedOrMainFrame();
+ if (!frame || !frame->document()->focusedNode())
+ return;
+
+ const PlatformKeyboardEvent* kevent = event->keyEvent();
+ if (!kevent || kevent->type() == PlatformKeyboardEvent::KeyUp)
+ return;
+
+ Node* start = frame->selectionController()->start().node();
+ if (!start)
+ return;
+
+ // FIXME: refactor all of this to use Actions or something like them
+ if (start->isContentEditable()) {
+ switch (kevent->windowsVirtualKeyCode()) {
+ case VK_RETURN:
+ frame->editor()->command("InsertLineBreak").execute();
+ break;
+ case VK_BACK:
+ frame->editor()->deleteWithDirection(SelectionController::BACKWARD,
+ CharacterGranularity, false, true);
+ break;
+ case VK_DELETE:
+ frame->editor()->deleteWithDirection(SelectionController::FORWARD,
+ CharacterGranularity, false, true);
+ break;
+ case VK_LEFT:
+ if (kevent->shiftKey())
+ frame->editor()->command("MoveLeftAndModifySelection").execute();
+ else frame->editor()->command("MoveLeft").execute();
+ break;
+ case VK_RIGHT:
+ if (kevent->shiftKey())
+ frame->editor()->command("MoveRightAndModifySelection").execute();
+ else frame->editor()->command("MoveRight").execute();
+ break;
+ case VK_UP:
+ if (kevent->shiftKey())
+ frame->editor()->command("MoveUpAndModifySelection").execute();
+ else frame->editor()->command("MoveUp").execute();
+ break;
+ case VK_DOWN:
+ if (kevent->shiftKey())
+ frame->editor()->command("MoveDownAndModifySelection").execute();
+ else frame->editor()->command("MoveDown").execute();
+ break;
+ case VK_PRIOR: // PageUp
+ frame->editor()->command("MovePageUp").execute();
+ break;
+ case VK_NEXT: // PageDown
+ frame->editor()->command("MovePageDown").execute();
+ break;
+ case VK_TAB:
+ return;
+ default:
+ if (!kevent->ctrlKey() && !kevent->altKey() && !kevent->text().isEmpty()) {
+ frame->editor()->insertText(kevent->text(), event);
+ } else if (kevent->ctrlKey()) {
+ switch (kevent->windowsVirtualKeyCode()) {
+ case VK_A:
+ frame->editor()->command("SelectAll").execute();
+ break;
+ case VK_B:
+ frame->editor()->command("ToggleBold").execute();
+ break;
+ case VK_C:
+ frame->editor()->command("Copy").execute();
+ break;
+ case VK_I:
+ frame->editor()->command("ToggleItalic").execute();
+ break;
+ case VK_V:
+ frame->editor()->command("Paste").execute();
+ break;
+ case VK_X:
+ frame->editor()->command("Cut").execute();
+ break;
+ case VK_Y:
+ frame->editor()->command("Redo").execute();
+ break;
+ case VK_Z:
+ frame->editor()->command("Undo").execute();
+ break;
+ default:
+ return;
+ }
+ } else return;
+ }
+ } else {
+ switch (kevent->windowsVirtualKeyCode()) {
+ case VK_UP:
+ frame->editor()->command("MoveUp").execute();
+ break;
+ case VK_DOWN:
+ frame->editor()->command("MoveDown").execute();
+ break;
+ case VK_PRIOR: // PageUp
+ frame->editor()->command("MovePageUp").execute();
+ break;
+ case VK_NEXT: // PageDown
+ frame->editor()->command("MovePageDown").execute();
+ break;
+ case VK_HOME:
+ if (kevent->ctrlKey())
+ frame->editor()->command("MoveToBeginningOfDocument").execute();
+ break;
+ case VK_END:
+ if (kevent->ctrlKey())
+ frame->editor()->command("MoveToEndOfDocument").execute();
+ break;
+ default:
+ if (kevent->ctrlKey()) {
+ switch (kevent->windowsVirtualKeyCode()) {
+ case VK_A:
+ frame->editor()->command("SelectAll").execute();
+ break;
+ case VK_C: case VK_X:
+ frame->editor()->command("Copy").execute();
+ break;
+ default:
+ return;
+ }
+ } else return;
+ }
+ }
+ event->setDefaultHandled();
+}
+
+void EditorClientQt::handleInputMethodKeydown(KeyboardEvent*)
+{
+}
+
+EditorClientQt::EditorClientQt(QWebPage* page)
+ : m_page(page), m_editing(false), m_inUndoRedo(false)
+{
+}
+
+void EditorClientQt::textFieldDidBeginEditing(Element*)
+{
+ m_editing = true;
+}
+
+void EditorClientQt::textFieldDidEndEditing(Element*)
+{
+ m_editing = false;
+}
+
+void EditorClientQt::textDidChangeInTextField(Element*)
+{
+}
+
+bool EditorClientQt::doTextFieldCommandFromEvent(Element*, KeyboardEvent*)
+{
+ return false;
+}
+
+void EditorClientQt::textWillBeDeletedInTextField(Element*)
+{
+}
+
+void EditorClientQt::textDidChangeInTextArea(Element*)
+{
+}
+
+void EditorClientQt::ignoreWordInSpellDocument(const String&)
+{
+ notImplemented();
+}
+
+void EditorClientQt::learnWord(const String&)
+{
+ notImplemented();
+}
+
+void EditorClientQt::checkSpellingOfString(const UChar*, int, int*, int*)
+{
+ notImplemented();
+}
+
+void EditorClientQt::checkGrammarOfString(const UChar*, int, Vector<GrammarDetail>&, int*, int*)
+{
+ notImplemented();
+}
+
+void EditorClientQt::updateSpellingUIWithGrammarString(const String&, const GrammarDetail&)
+{
+ notImplemented();
+}
+
+void EditorClientQt::updateSpellingUIWithMisspelledWord(const String&)
+{
+ notImplemented();
+}
+
+void EditorClientQt::showSpellingUI(bool)
+{
+ notImplemented();
+}
+
+bool EditorClientQt::spellingUIIsShowing()
+{
+ notImplemented();
+ return false;
+}
+
+void EditorClientQt::getGuessesForWord(const String&, Vector<String>&)
+{
+ notImplemented();
+}
+
+bool EditorClientQt::isEditing() const
+{
+ return m_editing;
+}
+
+void EditorClientQt::setInputMethodState(bool)
+{
+}
+
+}
+
+// vim: ts=4 sw=4 et
diff --git a/WebKit/qt/WebCoreSupport/EditorClientQt.h b/WebKit/qt/WebCoreSupport/EditorClientQt.h
new file mode 100644
index 0000000..41147b6
--- /dev/null
+++ b/WebKit/qt/WebCoreSupport/EditorClientQt.h
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ * Copyright (C) 2006 Zack Rusin <zack@kde.org>
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 EditorClientQt_H
+#define EditorClientQt_H
+
+#include "EditorClient.h"
+#include "RefCounted.h"
+
+#include <wtf/Forward.h>
+
+class QWebPage;
+
+namespace WebCore {
+
+class EditorClientQt : public EditorClient {
+public:
+ EditorClientQt(QWebPage* page);
+
+ virtual void pageDestroyed();
+
+ virtual bool shouldDeleteRange(Range*);
+ virtual bool shouldShowDeleteInterface(HTMLElement*);
+ virtual bool smartInsertDeleteEnabled();
+ virtual bool isContinuousSpellCheckingEnabled();
+ virtual void toggleContinuousSpellChecking();
+ virtual bool isGrammarCheckingEnabled();
+ virtual void toggleGrammarChecking();
+ virtual int spellCheckerDocumentTag();
+
+ virtual bool selectWordBeforeMenuEvent();
+ virtual bool isEditable();
+
+ virtual bool shouldBeginEditing(Range*);
+ virtual bool shouldEndEditing(Range*);
+ virtual bool shouldInsertNode(Node*, Range*, EditorInsertAction);
+ virtual bool shouldInsertText(String, Range*, EditorInsertAction);
+ virtual bool shouldChangeSelectedRange(Range* fromRange, Range* toRange, EAffinity, bool stillSelecting);
+
+ virtual bool shouldApplyStyle(CSSStyleDeclaration*, Range*);
+
+ virtual bool shouldMoveRangeAfterDelete(Range*, Range*);
+
+ virtual void didBeginEditing();
+ virtual void respondToChangedContents();
+ virtual void respondToChangedSelection();
+ virtual void didEndEditing();
+ virtual void didWriteSelectionToPasteboard();
+ virtual void didSetSelectionTypesForPasteboard();
+
+ virtual void registerCommandForUndo(PassRefPtr<EditCommand>);
+ virtual void registerCommandForRedo(PassRefPtr<EditCommand>);
+ virtual void clearUndoRedoOperations();
+
+ virtual bool canUndo() const;
+ virtual bool canRedo() const;
+
+ virtual void undo();
+ virtual void redo();
+
+ virtual void handleKeyboardEvent(KeyboardEvent*);
+ virtual void handleInputMethodKeydown(KeyboardEvent*);
+
+ virtual void textFieldDidBeginEditing(Element*);
+ virtual void textFieldDidEndEditing(Element*);
+ virtual void textDidChangeInTextField(Element*);
+ virtual bool doTextFieldCommandFromEvent(Element*, KeyboardEvent*);
+ virtual void textWillBeDeletedInTextField(Element*);
+ virtual void textDidChangeInTextArea(Element*);
+
+ virtual void ignoreWordInSpellDocument(const String&);
+ virtual void learnWord(const String&);
+ virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength);
+ virtual void checkGrammarOfString(const UChar*, int length, Vector<GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength);
+ virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail&);
+ virtual void updateSpellingUIWithMisspelledWord(const String&);
+ virtual void showSpellingUI(bool show);
+ virtual bool spellingUIIsShowing();
+ virtual void getGuessesForWord(const String&, Vector<String>& guesses);
+ virtual void setInputMethodState(bool enabled);
+
+ bool isEditing() const;
+
+private:
+ QWebPage* m_page;
+ bool m_editing;
+ bool m_inUndoRedo; // our undo stack works differently - don't re-enter!
+};
+
+}
+
+#endif
+
+// vim: ts=4 sw=4 et
diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
new file mode 100644
index 0000000..ed91b86
--- /dev/null
+++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
@@ -0,0 +1,1023 @@
+/*
+ * Copyright (C) 2006 Zack Rusin <zack@kde.org>
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2007 Trolltech ASA
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 "CSSComputedStyleDeclaration.h"
+#include "CSSPropertyNames.h"
+#include "FrameLoaderClientQt.h"
+#include "FrameTree.h"
+#include "FrameView.h"
+#include "DocumentLoader.h"
+#include "MIMETypeRegistry.h"
+#include "ResourceResponse.h"
+#include "Page.h"
+#include "ProgressTracker.h"
+#include "ResourceRequest.h"
+#include "HistoryItem.h"
+#include "HTMLFormElement.h"
+#include "NotImplemented.h"
+#include "QNetworkReplyHandler.h"
+#include "ResourceHandleInternal.h"
+#include "ResourceHandle.h"
+
+#include "qwebpage.h"
+#include "qwebframe.h"
+#include "qwebframe_p.h"
+#include "qwebhistoryinterface.h"
+
+#include <qfileinfo.h>
+
+#include <QCoreApplication>
+#include <QDebug>
+#if QT_VERSION >= 0x040400
+#include <QNetworkRequest>
+#include <QNetworkReply>
+#else
+#include "qwebnetworkinterface_p.h"
+#include "qwebobjectplugin_p.h"
+#endif
+
+namespace WebCore
+{
+
+FrameLoaderClientQt::FrameLoaderClientQt()
+ : m_frame(0)
+ , m_webFrame(0)
+ , m_firstData(false)
+ , m_policyFunction(0)
+{
+ connect(this, SIGNAL(sigCallPolicyFunction(int)), this, SLOT(slotCallPolicyFunction(int)), Qt::QueuedConnection);
+}
+
+
+FrameLoaderClientQt::~FrameLoaderClientQt()
+{
+}
+
+void FrameLoaderClientQt::setFrame(QWebFrame* webFrame, Frame* frame)
+{
+ m_webFrame = webFrame;
+ m_frame = frame;
+ if (!m_webFrame || !m_webFrame->page()) {
+ qWarning("FrameLoaderClientQt::setFrame frame without Page!");
+ return;
+ }
+
+ connect(this, SIGNAL(loadStarted()),
+ m_webFrame, SIGNAL(loadStarted()));
+ connect(this, SIGNAL(loadProgressChanged(int)),
+ m_webFrame->page(), SIGNAL(loadProgressChanged(int)));
+ connect(this, SIGNAL(loadFinished()),
+ m_webFrame, SIGNAL(loadFinished()));
+ connect(this, SIGNAL(titleChanged(const QString&)),
+ m_webFrame, SIGNAL(titleChanged(const QString&)));
+}
+
+QWebFrame* FrameLoaderClientQt::webFrame() const
+{
+ return m_webFrame;
+}
+
+void FrameLoaderClientQt::callPolicyFunction(FramePolicyFunction function, PolicyAction action)
+{
+ ASSERT(!m_policyFunction);
+ ASSERT(function);
+
+ m_policyFunction = function;
+ emit sigCallPolicyFunction(action);
+}
+
+void FrameLoaderClientQt::slotCallPolicyFunction(int action)
+{
+ if (!m_frame || !m_policyFunction)
+ return;
+ FramePolicyFunction function = m_policyFunction;
+ m_policyFunction = 0;
+ (m_frame->loader()->*function)(WebCore::PolicyAction(action));
+}
+
+bool FrameLoaderClientQt::hasWebView() const
+{
+ //notImplemented();
+ return true;
+}
+
+
+bool FrameLoaderClientQt::hasFrameView() const
+{
+ //notImplemented();
+ return true;
+}
+
+
+bool FrameLoaderClientQt::hasBackForwardList() const
+{
+ notImplemented();
+ return false;
+}
+
+
+void FrameLoaderClientQt::resetBackForwardList()
+{
+ notImplemented();
+}
+
+
+bool FrameLoaderClientQt::provisionalItemIsTarget() const
+{
+ notImplemented();
+ return false;
+}
+
+
+bool FrameLoaderClientQt::loadProvisionalItemFromPageCache()
+{
+ notImplemented();
+ return false;
+}
+
+
+void FrameLoaderClientQt::invalidateCurrentItemPageCache()
+{
+ notImplemented();
+}
+
+void FrameLoaderClientQt::savePlatformDataToCachedPage(CachedPage*)
+{
+ notImplemented();
+}
+
+void FrameLoaderClientQt::transitionToCommittedFromCachedPage(CachedPage*)
+{
+ notImplemented();
+}
+
+void FrameLoaderClientQt::transitionToCommittedForNewPage()
+{
+// qDebug() << "FrameLoaderClientQt::makeDocumentView" << m_frame->document();
+
+// if (!m_frame->document())
+// m_frame->loader()->createEmptyDocument();
+}
+
+
+void FrameLoaderClientQt::makeRepresentation(DocumentLoader*)
+{
+ // don't need this for now I think.
+}
+
+
+void FrameLoaderClientQt::forceLayout()
+{
+ m_frame->view()->setNeedsLayout();
+ m_frame->view()->layout();
+}
+
+
+void FrameLoaderClientQt::forceLayoutForNonHTML()
+{
+}
+
+
+void FrameLoaderClientQt::setCopiesOnScroll()
+{
+ // apparently mac specific
+}
+
+
+LoadErrorResetToken* FrameLoaderClientQt::tokenForLoadErrorReset()
+{
+ notImplemented();
+ return 0;
+}
+
+
+void FrameLoaderClientQt::resetAfterLoadError(LoadErrorResetToken*)
+{
+ notImplemented();
+}
+
+
+void FrameLoaderClientQt::doNotResetAfterLoadError(LoadErrorResetToken*)
+{
+ notImplemented();
+}
+
+
+void FrameLoaderClientQt::willCloseDocument()
+{
+ notImplemented();
+}
+
+void FrameLoaderClientQt::detachedFromParent2()
+{
+}
+
+
+void FrameLoaderClientQt::detachedFromParent3()
+{
+}
+
+
+void FrameLoaderClientQt::detachedFromParent4()
+{
+ if (!m_webFrame)
+ return;
+ m_webFrame->d->frame = 0;
+ m_webFrame->d->frameView = 0;
+ m_webFrame = 0;
+ m_frame = 0;
+}
+
+
+void FrameLoaderClientQt::loadedFromCachedPage()
+{
+ notImplemented();
+}
+
+
+void FrameLoaderClientQt::dispatchDidHandleOnloadEvents()
+{
+ // don't need this one
+}
+
+
+void FrameLoaderClientQt::dispatchDidReceiveServerRedirectForProvisionalLoad()
+{
+ notImplemented();
+}
+
+
+void FrameLoaderClientQt::dispatchDidCancelClientRedirect()
+{
+ notImplemented();
+}
+
+
+void FrameLoaderClientQt::dispatchWillPerformClientRedirect(const KURL&,
+ double interval,
+ double fireDate)
+{
+ notImplemented();
+}
+
+
+void FrameLoaderClientQt::dispatchDidChangeLocationWithinPage()
+{
+ notImplemented();
+}
+
+
+void FrameLoaderClientQt::dispatchWillClose()
+{
+}
+
+
+void FrameLoaderClientQt::dispatchDidStartProvisionalLoad()
+{
+ if (m_webFrame)
+ emit m_webFrame->provisionalLoad();
+}
+
+
+void FrameLoaderClientQt::dispatchDidReceiveTitle(const String& title)
+{
+ // ### hack
+ emit m_webFrame->urlChanged(m_webFrame->url());
+ emit titleChanged(title);
+}
+
+
+void FrameLoaderClientQt::dispatchDidCommitLoad()
+{
+ if (m_frame->tree()->parent())
+ return;
+ m_webFrame->page()->d->updateNavigationActions();
+}
+
+
+void FrameLoaderClientQt::dispatchDidFinishDocumentLoad()
+{
+ if (m_frame->tree()->parent())
+ return;
+ m_webFrame->page()->d->updateNavigationActions();
+}
+
+
+void FrameLoaderClientQt::dispatchDidFinishLoad()
+{
+ if (m_webFrame)
+ emit m_webFrame->loadDone(true);
+ if (m_frame->tree()->parent())
+ return;
+ m_webFrame->page()->d->updateNavigationActions();
+}
+
+
+void FrameLoaderClientQt::dispatchDidFirstLayout()
+{
+ if (m_webFrame)
+ emit m_webFrame->initialLayoutComplete();
+}
+
+
+void FrameLoaderClientQt::dispatchShow()
+{
+ notImplemented();
+}
+
+
+void FrameLoaderClientQt::cancelPolicyCheck()
+{
+// qDebug() << "FrameLoaderClientQt::cancelPolicyCheck";
+ m_policyFunction = 0;
+}
+
+
+void FrameLoaderClientQt::dispatchWillSubmitForm(FramePolicyFunction function,
+ PassRefPtr<FormState>)
+{
+ notImplemented();
+ Q_ASSERT(!m_policyFunction);
+ // FIXME: This is surely too simple
+ callPolicyFunction(function, PolicyUse);
+}
+
+
+void FrameLoaderClientQt::dispatchDidLoadMainResource(DocumentLoader*)
+{
+}
+
+
+void FrameLoaderClientQt::clearLoadingFromPageCache(DocumentLoader*)
+{
+ notImplemented();
+}
+
+
+bool FrameLoaderClientQt::isLoadingFromPageCache(DocumentLoader*)
+{
+ notImplemented();
+ return false;
+}
+
+
+void FrameLoaderClientQt::revertToProvisionalState(DocumentLoader*)
+{
+ notImplemented();
+}
+
+
+void FrameLoaderClientQt::clearUnarchivingState(DocumentLoader*)
+{
+ notImplemented();
+}
+
+
+void FrameLoaderClientQt::postProgressStartedNotification()
+{
+ if (m_webFrame && m_frame->page())
+ emit loadStarted();
+ if (m_frame->tree()->parent())
+ return;
+ m_webFrame->page()->d->updateNavigationActions();
+}
+
+void FrameLoaderClientQt::postProgressEstimateChangedNotification()
+{
+ if (m_webFrame && m_frame->page())
+ emit loadProgressChanged(qRound(m_frame->page()->progress()->estimatedProgress() * 100));
+}
+
+void FrameLoaderClientQt::postProgressFinishedNotification()
+{
+ if (m_webFrame && m_frame->page())
+ emit loadFinished();
+}
+
+void FrameLoaderClientQt::setMainFrameDocumentReady(bool b)
+{
+ // this is only interesting once we provide an external API for the DOM
+}
+
+
+void FrameLoaderClientQt::willChangeTitle(DocumentLoader*)
+{
+ // no need for, dispatchDidReceiveTitle is the right callback
+}
+
+
+void FrameLoaderClientQt::didChangeTitle(DocumentLoader *)
+{
+ // no need for, dispatchDidReceiveTitle is the right callback
+}
+
+
+void FrameLoaderClientQt::finishedLoading(DocumentLoader* loader)
+{
+ if (m_firstData) {
+ FrameLoader *fl = loader->frameLoader();
+ fl->setEncoding(m_response.textEncodingName(), false);
+ m_firstData = false;
+ }
+}
+
+
+void FrameLoaderClientQt::finalSetupForReplace(DocumentLoader*)
+{
+ notImplemented();
+}
+
+
+void FrameLoaderClientQt::setDefersLoading(bool)
+{
+ notImplemented();
+}
+
+
+bool FrameLoaderClientQt::isArchiveLoadPending(ResourceLoader*) const
+{
+ return false;
+}
+
+
+void FrameLoaderClientQt::cancelPendingArchiveLoad(ResourceLoader*)
+{
+ notImplemented();
+}
+
+
+void FrameLoaderClientQt::clearArchivedResources()
+{
+ // don't think we need to do anything here currently
+}
+
+
+bool FrameLoaderClientQt::canShowMIMEType(const String& MIMEType) const
+{
+ if (MIMETypeRegistry::isSupportedImageMIMEType(MIMEType))
+ return true;
+
+ if (MIMETypeRegistry::isSupportedNonImageMIMEType(MIMEType))
+ return true;
+
+ return false;
+}
+
+bool FrameLoaderClientQt::representationExistsForURLScheme(const String& URLScheme) const
+{
+ return false;
+}
+
+
+String FrameLoaderClientQt::generatedMIMETypeForURLScheme(const String& URLScheme) const
+{
+ notImplemented();
+ return String();
+}
+
+
+void FrameLoaderClientQt::frameLoadCompleted()
+{
+ // Note: Can be called multiple times.
+ // Even if already complete, we might have set a previous item on a frame that
+ // didn't do any data loading on the past transaction. Make sure to clear these out.
+ m_frame->loader()->setPreviousHistoryItem(0);
+}
+
+
+void FrameLoaderClientQt::restoreViewState()
+{
+ notImplemented();
+}
+
+
+void FrameLoaderClientQt::provisionalLoadStarted()
+{
+ // don't need to do anything here
+}
+
+
+bool FrameLoaderClientQt::shouldTreatURLAsSameAsCurrent(const KURL&) const
+{
+ notImplemented();
+ return false;
+}
+
+
+void FrameLoaderClientQt::addHistoryItemForFragmentScroll()
+{
+ notImplemented();
+}
+
+
+void FrameLoaderClientQt::didFinishLoad()
+{
+// notImplemented();
+}
+
+
+void FrameLoaderClientQt::prepareForDataSourceReplacement()
+{
+ m_frame->loader()->detachChildren();
+}
+
+void FrameLoaderClientQt::setTitle(const String&, const KURL&)
+{
+ // no need for, dispatchDidReceiveTitle is the right callback
+}
+
+
+String FrameLoaderClientQt::userAgent(const KURL& url)
+{
+ if (m_webFrame) {
+ return m_webFrame->page()->userAgentFor(QUrl((QString)url.string()));
+ }
+ return String();
+}
+
+void FrameLoaderClientQt::dispatchDidReceiveIcon()
+{
+ if (m_webFrame) {
+ emit m_webFrame->iconLoaded();
+ }
+}
+
+void FrameLoaderClientQt::frameLoaderDestroyed()
+{
+ Q_ASSERT(m_webFrame == 0);
+ Q_ASSERT(m_frame == 0);
+ delete this;
+}
+
+bool FrameLoaderClientQt::canHandleRequest(const WebCore::ResourceRequest&) const
+{
+ return true;
+}
+
+void FrameLoaderClientQt::windowObjectCleared()
+{
+ if (m_webFrame)
+ emit m_webFrame->cleared();
+}
+
+void FrameLoaderClientQt::didPerformFirstNavigation() const
+{
+ if (m_frame->tree()->parent())
+ return;
+ m_webFrame->page()->d->updateNavigationActions();
+}
+
+void FrameLoaderClientQt::registerForIconNotification(bool)
+{
+ notImplemented();
+}
+
+void FrameLoaderClientQt::updateGlobalHistory(const WebCore::KURL& url)
+{
+ QWebHistoryInterface *history = QWebHistoryInterface::defaultInterface();
+ if (history)
+ history->addHistoryEntry(url.prettyURL());
+}
+
+bool FrameLoaderClientQt::shouldGoToHistoryItem(WebCore::HistoryItem *item) const
+{
+ if (item) {
+ return true;
+ }
+ return false;
+}
+
+void FrameLoaderClientQt::saveViewStateToItem(WebCore::HistoryItem*)
+{
+ notImplemented();
+}
+
+bool FrameLoaderClientQt::canCachePage() const
+{
+ // don't do any caching for now
+ return false;
+}
+
+void FrameLoaderClientQt::setMainDocumentError(WebCore::DocumentLoader* loader, const WebCore::ResourceError& error)
+{
+ if (m_firstData) {
+ loader->frameLoader()->setEncoding(m_response.textEncodingName(), false);
+ m_firstData = false;
+ }
+}
+
+void FrameLoaderClientQt::committedLoad(WebCore::DocumentLoader* loader, const char* data, int length)
+{
+ if (!m_frame)
+ return;
+ FrameLoader *fl = loader->frameLoader();
+ if (m_firstData) {
+ fl->setEncoding(m_response.textEncodingName(), false);
+ m_firstData = false;
+ }
+ fl->addData(data, length);
+}
+
+WebCore::ResourceError FrameLoaderClientQt::cancelledError(const WebCore::ResourceRequest& request)
+{
+ return ResourceError("Error", -999, request.url().prettyURL(),
+ QCoreApplication::translate("QWebFrame", "Request cancelled", 0, QCoreApplication::UnicodeUTF8));
+}
+
+// copied from WebKit/Misc/WebKitErrors[Private].h
+enum {
+ WebKitErrorCannotShowMIMEType = 100,
+ WebKitErrorCannotShowURL = 101,
+ WebKitErrorFrameLoadInterruptedByPolicyChange = 102,
+ WebKitErrorCannotUseRestrictedPort = 103,
+ WebKitErrorCannotFindPlugIn = 200,
+ WebKitErrorCannotLoadPlugIn = 201,
+ WebKitErrorJavaUnavailable = 202,
+};
+
+WebCore::ResourceError FrameLoaderClientQt::blockedError(const WebCore::ResourceRequest& request)
+{
+ return ResourceError("Error", WebKitErrorCannotUseRestrictedPort, request.url().prettyURL(),
+ QCoreApplication::translate("QWebFrame", "Request blocked", 0, QCoreApplication::UnicodeUTF8));
+}
+
+
+WebCore::ResourceError FrameLoaderClientQt::cannotShowURLError(const WebCore::ResourceRequest& request)
+{
+ return ResourceError("Error", WebKitErrorCannotShowURL, request.url().string(),
+ QCoreApplication::translate("QWebFrame", "Cannot show URL", 0, QCoreApplication::UnicodeUTF8));
+}
+
+WebCore::ResourceError FrameLoaderClientQt::interruptForPolicyChangeError(const WebCore::ResourceRequest& request)
+{
+ return ResourceError("Error", WebKitErrorFrameLoadInterruptedByPolicyChange, request.url().string(),
+ QCoreApplication::translate("QWebFrame", "Frame load interruped by policy change", 0, QCoreApplication::UnicodeUTF8));
+}
+
+WebCore::ResourceError FrameLoaderClientQt::cannotShowMIMETypeError(const WebCore::ResourceResponse& response)
+{
+ return ResourceError("Error", WebKitErrorCannotShowMIMEType, response.url().string(),
+ QCoreApplication::translate("QWebFrame", "Cannot show mimetype", 0, QCoreApplication::UnicodeUTF8));
+}
+
+WebCore::ResourceError FrameLoaderClientQt::fileDoesNotExistError(const WebCore::ResourceResponse& response)
+{
+ return ResourceError("Error", -998 /* ### */, response.url().string(),
+ QCoreApplication::translate("QWebFrame", "File does not exist", 0, QCoreApplication::UnicodeUTF8));
+}
+
+bool FrameLoaderClientQt::shouldFallBack(const WebCore::ResourceError&)
+{
+ notImplemented();
+ return false;
+}
+
+WTF::PassRefPtr<WebCore::DocumentLoader> FrameLoaderClientQt::createDocumentLoader(const WebCore::ResourceRequest& request, const SubstituteData& substituteData)
+{
+ RefPtr<DocumentLoader> loader = new DocumentLoader(request, substituteData);
+ return loader.release();
+}
+
+void FrameLoaderClientQt::download(WebCore::ResourceHandle* handle, const WebCore::ResourceRequest&, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&)
+{
+#if QT_VERSION >= 0x040400
+ QNetworkReplyHandler* handler = handle->getInternal()->m_job;
+ QNetworkReply* reply = handler->release();
+ if (reply) {
+ QWebPage *page = m_webFrame->page();
+ if (page->receivers(SIGNAL(handleUnsupportedContent(QNetworkReply *))))
+ emit m_webFrame->page()->handleUnsupportedContent(reply);
+ else
+ reply->abort();
+ }
+#endif
+}
+
+void FrameLoaderClientQt::assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&)
+{
+}
+
+void FrameLoaderClientQt::dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long, WebCore::ResourceRequest& request, const WebCore::ResourceResponse& response)
+{
+ // seems like the Mac code doesn't do anything here by default neither
+ //qDebug() << "FrameLoaderClientQt::dispatchWillSendRequest" << request.isNull() << request.url().string`();
+}
+
+void FrameLoaderClientQt::dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long, const AuthenticationChallenge&)
+{
+ notImplemented();
+}
+
+void FrameLoaderClientQt::dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long, const AuthenticationChallenge&)
+{
+ notImplemented();
+}
+
+void FrameLoaderClientQt::dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long, const WebCore::ResourceResponse& response)
+{
+
+ m_response = response;
+ m_firstData = true;
+ //qDebug() << " got response from" << response.url().string();
+}
+
+void FrameLoaderClientQt::dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long, int)
+{
+}
+
+void FrameLoaderClientQt::dispatchDidFinishLoading(WebCore::DocumentLoader* loader, unsigned long)
+{
+}
+
+void FrameLoaderClientQt::dispatchDidFailLoading(WebCore::DocumentLoader* loader, unsigned long, const WebCore::ResourceError&)
+{
+ if (m_firstData) {
+ FrameLoader *fl = loader->frameLoader();
+ fl->setEncoding(m_response.textEncodingName(), false);
+ m_firstData = false;
+ }
+}
+
+bool FrameLoaderClientQt::dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int)
+{
+ notImplemented();
+ return false;
+}
+
+void FrameLoaderClientQt::dispatchDidFailProvisionalLoad(const WebCore::ResourceError&)
+{
+ if (m_webFrame)
+ emit m_webFrame->loadDone(false);
+}
+
+void FrameLoaderClientQt::dispatchDidFailLoad(const WebCore::ResourceError&)
+{
+ if (m_webFrame)
+ emit m_webFrame->loadDone(false);
+}
+
+WebCore::Frame* FrameLoaderClientQt::dispatchCreatePage()
+{
+ if (!m_webFrame)
+ return 0;
+ QWebPage *newPage = m_webFrame->page()->createWindow();
+ if (!newPage)
+ return 0;
+ return newPage->mainFrame()->d->frame.get();
+}
+
+void FrameLoaderClientQt::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const WebCore::String& MIMEType, const WebCore::ResourceRequest&)
+{
+ // we need to call directly here
+ Q_ASSERT(!m_policyFunction);
+ m_policyFunction = function;
+ if (canShowMIMEType(MIMEType))
+ slotCallPolicyFunction(PolicyUse);
+ else
+ slotCallPolicyFunction(PolicyDownload);
+}
+
+void FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, const WebCore::String&)
+{
+ Q_ASSERT(!m_policyFunction);
+ m_policyFunction = function;
+ slotCallPolicyFunction(PolicyUse);
+}
+
+void FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const WebCore::NavigationAction& action, const WebCore::ResourceRequest& request)
+{
+ Q_ASSERT(!m_policyFunction);
+ m_policyFunction = function;
+ if (m_webFrame) {
+#if QT_VERSION < 0x040400
+ QWebNetworkRequest r(request);
+#else
+ QNetworkRequest r(request.toNetworkRequest());
+#endif
+ QWebPage *page = m_webFrame->page();
+
+ if (page->d->navigationRequested(m_webFrame, r, QWebPage::NavigationType(action.type())) ==
+ QWebPage::IgnoreNavigationRequest) {
+ slotCallPolicyFunction(PolicyIgnore);
+ return;
+ }
+ }
+ slotCallPolicyFunction(PolicyUse);
+ return;
+}
+
+void FrameLoaderClientQt::dispatchUnableToImplementPolicy(const WebCore::ResourceError&)
+{
+ notImplemented();
+}
+
+void FrameLoaderClientQt::startDownload(const WebCore::ResourceRequest& request)
+{
+#if QT_VERSION >= 0x040400
+ QWebPage *page = m_webFrame->page();
+ emit m_webFrame->page()->download(request.toNetworkRequest());
+#endif
+}
+
+bool FrameLoaderClientQt::willUseArchive(WebCore::ResourceLoader*, const WebCore::ResourceRequest&, const WebCore::KURL&) const
+{
+ return false;
+}
+
+PassRefPtr<Frame> FrameLoaderClientQt::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
+ const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight)
+{
+ QWebFrameData frameData;
+ frameData.url = url;
+ frameData.name = name;
+ frameData.ownerElement = ownerElement;
+ frameData.referrer = referrer;
+ frameData.allowsScrolling = allowsScrolling;
+ frameData.marginWidth = marginWidth;
+ frameData.marginHeight = marginHeight;
+
+ QWebFrame* webFrame = new QWebFrame(m_webFrame, &frameData);
+ emit m_webFrame->page()->frameCreated(webFrame);
+
+ RefPtr<Frame> childFrame = adoptRef(webFrame->d->frame.get());
+
+ // FIXME: All of the below should probably be moved over into WebCore
+ childFrame->tree()->setName(name);
+ m_frame->tree()->appendChild(childFrame);
+ // ### set override encoding if we have one
+
+ FrameLoadType loadType = m_frame->loader()->loadType();
+ FrameLoadType childLoadType = FrameLoadTypeRedirectWithLockedHistory;
+
+ childFrame->loader()->load(frameData.url, frameData.referrer, childLoadType,
+ String(), 0, 0);
+
+ // The frame's onload handler may have removed it from the document.
+ if (!childFrame->tree()->parent())
+ return 0;
+
+ return childFrame.release();
+}
+
+ObjectContentType FrameLoaderClientQt::objectContentType(const KURL& url, const String& _mimeType)
+{
+// qDebug()<<" ++++++++++++++++ url is "<<url.prettyURL()<<", mime = "<<_mimeType;
+ if (_mimeType == "application/x-qt-plugin" || _mimeType == "application/x-qt-styled-widget")
+ return ObjectContentOtherPlugin;
+
+ if (url.isEmpty())
+ return ObjectContentNone;
+
+ String mimeType = _mimeType;
+ if (!mimeType.length()) {
+ QFileInfo fi(url.path());
+ mimeType = MIMETypeRegistry::getMIMETypeForExtension(fi.suffix());
+ }
+
+ if (!mimeType.length())
+ return ObjectContentFrame;
+
+ if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType))
+ return ObjectContentImage;
+
+ // ### FIXME Qt 4.4
+#if QT_VERSION < 0x040400
+ if (QWebFactoryLoader::self()->supportsMimeType(mimeType))
+ return ObjectContentNetscapePlugin;
+#endif
+
+ if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType))
+ return ObjectContentFrame;
+
+ if (url.protocol() == "about")
+ return ObjectContentFrame;
+
+ return ObjectContentNone;
+}
+
+static const CSSPropertyID qstyleSheetProperties[] = {
+ CSS_PROP_COLOR,
+ CSS_PROP_FONT_FAMILY,
+ CSS_PROP_FONT_SIZE,
+ CSS_PROP_FONT_STYLE,
+ CSS_PROP_FONT_WEIGHT
+};
+
+const unsigned numqStyleSheetProperties = sizeof(qstyleSheetProperties) / sizeof(qstyleSheetProperties[0]);
+
+Widget* FrameLoaderClientQt::createPlugin(const IntSize&, Element* element, const KURL& url, const Vector<String>& paramNames,
+ const Vector<String>& paramValues, const String& mimeType, bool loadManually)
+{
+// qDebug()<<"------ Creating plugin in FrameLoaderClientQt::createPlugin for "<<url.prettyURL() << mimeType;
+// qDebug()<<"------\t url = "<<url.prettyURL();
+ QStringList params;
+ QStringList values;
+ for (int i = 0; i < paramNames.size(); ++i)
+ params.append(paramNames[i]);
+ for (int i = 0; i < paramValues.size(); ++i)
+ values.append(paramValues[i]);
+
+ QString urlStr(url.string());
+ QUrl qurl = urlStr;
+
+ QObject *object = 0;
+
+ if (mimeType == "application/x-qt-plugin" || mimeType == "application/x-qt-styled-widget") {
+ object = m_webFrame->page()->createPlugin(element->getAttribute("classid"), qurl, params, values);
+ QWidget *widget = qobject_cast<QWidget *>(object);
+ if (widget && mimeType == "application/x-qt-styled-widget") {
+ CSSComputedStyleDeclaration cssDecl(element);
+
+ QString styleSheet = element->getAttribute("style");
+ if (!styleSheet.isEmpty())
+ styleSheet += QLatin1Char(';');
+
+ for (int i = 0; i < numqStyleSheetProperties; ++i) {
+ CSSPropertyID property = qstyleSheetProperties[i];
+
+ styleSheet += ::getPropertyName(property);
+ styleSheet += QLatin1Char(':');
+ styleSheet += cssDecl.getPropertyValue(property);
+ styleSheet += QLatin1Char(';');
+ }
+
+ widget->setStyleSheet(styleSheet);
+ }
+ }
+
+ // ### FIXME: qt 4.4
+#if QT_VERSION < 0x040400
+ if (!object)
+ object = QWebFactoryLoader::self()->create(m_webFrame, qurl, mimeType, params, values);
+#endif
+
+ if (object) {
+ QWidget *widget = qobject_cast<QWidget *>(object);
+ QWidget *view = m_webFrame->page()->view();
+ if (widget && view) {
+ widget->setParent(view);
+ Widget* w= new Widget();
+ w->setNativeWidget(widget);
+ return w;
+ }
+ // FIXME: make things work for widgetless plugins as well
+ delete object;
+ }
+
+ return 0;
+}
+
+void FrameLoaderClientQt::redirectDataToPlugin(Widget* pluginWidget)
+{
+ notImplemented();
+ return;
+}
+
+Widget* FrameLoaderClientQt::createJavaAppletWidget(const IntSize&, Element*, const KURL& baseURL,
+ const Vector<String>& paramNames, const Vector<String>& paramValues)
+{
+ notImplemented();
+ return 0;
+}
+
+String FrameLoaderClientQt::overrideMediaType() const
+{
+ return String();
+}
+
+QString FrameLoaderClientQt::chooseFile(const QString& oldFile)
+{
+ return webFrame()->page()->chooseFile(webFrame(), oldFile);
+}
+
+
+}
+
+#include "moc_FrameLoaderClientQt.cpp"
diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
new file mode 100644
index 0000000..3dd5ac9
--- /dev/null
+++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
@@ -0,0 +1,228 @@
+/*
+ * Copyright (C) 2006 Zack Rusin <zack@kde.org>
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 FrameLoaderClientQt_H
+#define FrameLoaderClientQt_H
+
+#include <qobject.h>
+#include <QUrl>
+
+#include "FrameLoaderClient.h"
+#include "KURL.h"
+#include "Frame.h"
+#include "FrameLoader.h"
+#include "RefCounted.h"
+#include "ResourceResponse.h"
+class QWebFrame;
+
+namespace WebCore {
+
+ class AuthenticationChallenge;
+ class DocumentLoader;
+ class Element;
+ class FormState;
+ class NavigationAction;
+ class String;
+ class ResourceLoader;
+
+ struct LoadErrorResetToken;
+
+ class FrameLoaderClientQt : public QObject, public FrameLoaderClient {
+ Q_OBJECT
+
+ void callPolicyFunction(FramePolicyFunction function, PolicyAction action);
+ private slots:
+ void slotCallPolicyFunction(int);
+ signals:
+ void sigCallPolicyFunction(int);
+ void loadStarted();
+ void loadProgressChanged(int d);
+ void loadFinished();
+ void titleChanged(const QString& title);
+
+ public:
+ FrameLoaderClientQt();
+ ~FrameLoaderClientQt();
+ void setFrame(QWebFrame* webFrame, Frame* frame);
+ QWebFrame* webFrame() const;
+
+ virtual bool hasWebView() const; // mainly for assertions
+ virtual bool hasFrameView() const; // ditto
+
+ virtual bool hasBackForwardList() const;
+ virtual void resetBackForwardList();
+
+ virtual bool provisionalItemIsTarget() const;
+ virtual bool loadProvisionalItemFromPageCache();
+ virtual void invalidateCurrentItemPageCache();
+
+ virtual void makeRepresentation(DocumentLoader*);
+ virtual void forceLayout();
+ virtual void forceLayoutForNonHTML();
+
+ virtual void setCopiesOnScroll();
+
+ virtual LoadErrorResetToken* tokenForLoadErrorReset();
+ virtual void resetAfterLoadError(LoadErrorResetToken*);
+ virtual void doNotResetAfterLoadError(LoadErrorResetToken*);
+
+ virtual void willCloseDocument();
+
+ virtual void detachedFromParent2();
+ virtual void detachedFromParent3();
+ virtual void detachedFromParent4();
+
+ virtual void loadedFromCachedPage();
+
+ virtual void frameLoaderDestroyed();
+ virtual bool canHandleRequest(const WebCore::ResourceRequest&) const;
+
+ virtual void dispatchDidHandleOnloadEvents();
+ virtual void dispatchDidReceiveServerRedirectForProvisionalLoad();
+ virtual void dispatchDidCancelClientRedirect();
+ virtual void dispatchWillPerformClientRedirect(const KURL&, double interval, double fireDate);
+ virtual void dispatchDidChangeLocationWithinPage();
+ virtual void dispatchWillClose();
+ virtual void dispatchDidReceiveIcon();
+ virtual void dispatchDidStartProvisionalLoad();
+ virtual void dispatchDidReceiveTitle(const String& title);
+ virtual void dispatchDidCommitLoad();
+
+ virtual void dispatchDidFinishDocumentLoad();
+ virtual void dispatchDidFinishLoad();
+ virtual void dispatchDidFirstLayout();
+
+ virtual void dispatchShow();
+ virtual void cancelPolicyCheck();
+
+ virtual void dispatchWillSubmitForm(FramePolicyFunction, PassRefPtr<FormState>);
+
+ virtual void dispatchDidLoadMainResource(DocumentLoader*);
+ virtual void clearLoadingFromPageCache(DocumentLoader*);
+ virtual bool isLoadingFromPageCache(DocumentLoader*);
+ virtual void revertToProvisionalState(DocumentLoader*);
+ virtual void clearUnarchivingState(DocumentLoader*);
+
+ virtual void setMainFrameDocumentReady(bool);
+ virtual void willChangeTitle(DocumentLoader*);
+ virtual void didChangeTitle(DocumentLoader*);
+ virtual void finishedLoading(DocumentLoader*);
+ virtual void finalSetupForReplace(DocumentLoader*);
+
+ virtual void setDefersLoading(bool);
+ virtual bool isArchiveLoadPending(ResourceLoader*) const;
+ virtual void cancelPendingArchiveLoad(ResourceLoader*);
+ virtual void clearArchivedResources();
+ virtual bool canShowMIMEType(const String& MIMEType) const;
+ virtual bool representationExistsForURLScheme(const String& URLScheme) const;
+ virtual String generatedMIMETypeForURLScheme(const String& URLScheme) const;
+
+ virtual void frameLoadCompleted();
+ virtual void restoreViewState();
+ virtual void provisionalLoadStarted();
+ virtual bool shouldTreatURLAsSameAsCurrent(const KURL&) const;
+ virtual void addHistoryItemForFragmentScroll();
+ virtual void didFinishLoad();
+ virtual void prepareForDataSourceReplacement();
+ virtual void setTitle(const String& title, const KURL&);
+
+ virtual String userAgent(const WebCore::KURL&);
+
+ virtual void savePlatformDataToCachedPage(WebCore::CachedPage*);
+ virtual void transitionToCommittedFromCachedPage(WebCore::CachedPage*);
+ virtual void transitionToCommittedForNewPage();
+
+ virtual void updateGlobalHistory(const WebCore::KURL&);
+ virtual bool shouldGoToHistoryItem(WebCore::HistoryItem*) const;
+ virtual void saveViewStateToItem(WebCore::HistoryItem*);
+ virtual bool canCachePage() const;
+
+ virtual void setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&);
+ virtual void committedLoad(WebCore::DocumentLoader*, const char*, int);
+ virtual WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&);
+ virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&);
+ virtual WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&);
+ virtual WebCore::ResourceError interruptForPolicyChangeError(const WebCore::ResourceRequest&);
+ virtual WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&);
+ virtual WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&);
+ virtual bool shouldFallBack(const WebCore::ResourceError&);
+ virtual WTF::PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
+ virtual void download(WebCore::ResourceHandle*, const WebCore::ResourceRequest&, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
+
+ virtual void assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&);
+
+ virtual void dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long, WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
+ virtual void dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&);
+ virtual void dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&);
+ virtual void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long, const WebCore::ResourceResponse&);
+ virtual void dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long, int);
+ virtual void dispatchDidFinishLoading(WebCore::DocumentLoader*, unsigned long);
+ virtual void dispatchDidFailLoading(WebCore::DocumentLoader*, unsigned long, const WebCore::ResourceError&);
+
+ virtual bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int);
+ virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&);
+ virtual void dispatchDidFailLoad(const WebCore::ResourceError&);
+ virtual WebCore::Frame* dispatchCreatePage();
+ virtual void dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const WebCore::String&, const WebCore::ResourceRequest&);
+ virtual void dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, const WebCore::String&);
+ virtual void dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const WebCore::NavigationAction&, const WebCore::ResourceRequest&);
+ virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&);
+
+ virtual void startDownload(const WebCore::ResourceRequest&);
+ virtual bool willUseArchive(WebCore::ResourceLoader*, const WebCore::ResourceRequest&, const WebCore::KURL&) const;
+
+ virtual void postProgressStartedNotification();
+ virtual void postProgressEstimateChangedNotification();
+ virtual void postProgressFinishedNotification();
+
+ virtual PassRefPtr<Frame> createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
+ const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) ;
+ virtual Widget* createPlugin(const IntSize&, Element*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool);
+ virtual void redirectDataToPlugin(Widget* pluginWidget);
+ virtual Widget* createJavaAppletWidget(const IntSize&, Element*, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues);
+
+ virtual ObjectContentType objectContentType(const KURL& url, const String& mimeType);
+ virtual String overrideMediaType() const;
+
+ virtual void windowObjectCleared();
+ virtual void didPerformFirstNavigation() const;
+
+ virtual void registerForIconNotification(bool);
+
+ QString chooseFile(const QString& oldFile);
+
+ private:
+ Frame *m_frame;
+ QWebFrame *m_webFrame;
+ ResourceResponse m_response;
+ bool m_firstData;
+ FramePolicyFunction m_policyFunction;
+ };
+
+}
+
+#endif
diff --git a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
new file mode 100644
index 0000000..4e8f5a5
--- /dev/null
+++ b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
@@ -0,0 +1,187 @@
+/*
+ * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * 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 "config.h"
+#include "InspectorClientQt.h"
+
+#include "qwebpage.h"
+#include "qwebpage_p.h"
+#include "qwebview.h"
+
+#include <QtCore/QCoreApplication>
+
+#include "InspectorController.h"
+#include "NotImplemented.h"
+#include "Page.h"
+#include "PlatformString.h"
+
+namespace WebCore {
+
+class InspectorClientWebPage : public QWebPage
+{
+public:
+ QWebPage* createWindow()
+ {
+ QWidget *w = new QWebView(0);
+ QWebPage *page = new QWebPage(w);
+ page->setView(w);
+ connect(page, SIGNAL(destroyed()), w, SLOT(deleteLater()));
+ return page;
+ }
+};
+
+
+class InspectorClientView : public QWebView {
+public:
+ InspectorClientView(InspectorController* controller)
+ : QWebView(0)
+ , m_controller(controller)
+ {
+ setPage(new InspectorClientWebPage);
+ connect(page(), SIGNAL(destroyed()), SLOT(deleteLater()));
+ }
+
+protected:
+ void hideEvent(QHideEvent* ev)
+ {
+ QWidget::hideEvent(ev);
+ m_controller->setWindowVisible(false);
+ }
+
+ void closeEvent(QCloseEvent* ev)
+ {
+ QWidget::closeEvent(ev);
+ m_controller->setWindowVisible(false);
+ }
+
+private:
+ InspectorController* m_controller;
+};
+
+
+InspectorClientQt::InspectorClientQt(QWebPage* page)
+ : m_inspectedWebPage(page)
+ , m_attached(false)
+{}
+
+void InspectorClientQt::inspectorDestroyed()
+{
+ delete this;
+}
+
+Page* InspectorClientQt::createPage()
+{
+ if (m_webPage)
+ return m_webPage->d->page;
+
+ InspectorClientView* view = new InspectorClientView(m_inspectedWebPage->d->page->inspectorController());
+ m_webPage.set(view->page());
+ m_webPage->mainFrame()->load(QString::fromLatin1("qrc:/webkit/inspector/inspector.html"));
+ m_webPage->view()->setMinimumSize(400,300);
+ return m_webPage->d->page;
+}
+
+String InspectorClientQt::localizedStringsURL()
+{
+ notImplemented();
+ return String();
+}
+
+void InspectorClientQt::showWindow()
+{
+ if (!m_webPage)
+ return;
+
+ updateWindowTitle();
+ m_webPage->view()->show();
+ m_inspectedWebPage->d->page->inspectorController()->setWindowVisible(true);
+}
+
+void InspectorClientQt::closeWindow()
+{
+ if (!m_webPage)
+ return;
+
+ m_webPage->view()->hide();
+ m_inspectedWebPage->d->page->inspectorController()->setWindowVisible(false);
+}
+
+bool InspectorClientQt::windowVisible()
+{
+ if (!m_webPage)
+ return false;
+ return m_webPage->view()->isVisible();
+}
+
+void InspectorClientQt::attachWindow()
+{
+ ASSERT(m_inspectedWebPage);
+ ASSERT(m_webPage);
+ ASSERT(!m_attached);
+
+ m_attached = true;
+ notImplemented();
+}
+
+void InspectorClientQt::detachWindow()
+{
+ ASSERT(m_inspectedWebPage);
+ ASSERT(m_webPage);
+ ASSERT(m_attached);
+
+ m_attached = false;
+ notImplemented();
+}
+
+void InspectorClientQt::highlight(Node* node)
+{
+ notImplemented();
+}
+
+void InspectorClientQt::hideHighlight()
+{
+ notImplemented();
+}
+
+void InspectorClientQt::inspectedURLChanged(const String& newURL)
+{
+ m_inspectedURL = newURL;
+ updateWindowTitle();
+}
+
+void InspectorClientQt::updateWindowTitle()
+{
+ if (!m_webPage)
+ return;
+
+ QString caption = QCoreApplication::translate("QWebPage", "Web Inspector - %2");
+ m_webPage->view()->setWindowTitle(caption.arg(m_inspectedURL));
+}
+
+}
diff --git a/WebKit/qt/WebCoreSupport/InspectorClientQt.h b/WebKit/qt/WebCoreSupport/InspectorClientQt.h
new file mode 100644
index 0000000..bc0fccd
--- /dev/null
+++ b/WebKit/qt/WebCoreSupport/InspectorClientQt.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * 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.
+ */
+
+#ifndef InspectorClientQt_h
+#define InspectorClientQt_h
+
+#include "InspectorClient.h"
+#include "OwnPtr.h"
+#include <QtCore/QString>
+
+class QWebPage;
+
+namespace WebCore {
+ class Node;
+ class Page;
+ class String;
+
+ class InspectorClientQt : public InspectorClient {
+ public:
+ InspectorClientQt(QWebPage*);
+
+ virtual void inspectorDestroyed();
+
+ virtual Page* createPage();
+
+ virtual String localizedStringsURL();
+
+ virtual void showWindow();
+ virtual void closeWindow();
+ virtual bool windowVisible();
+
+ virtual void attachWindow();
+ virtual void detachWindow();
+
+ virtual void highlight(Node*);
+ virtual void hideHighlight();
+ virtual void inspectedURLChanged(const String& newURL);
+
+ private:
+ void updateWindowTitle();
+ QWebPage* m_inspectedWebPage;
+ OwnPtr<QWebPage> m_webPage;
+ bool m_attached;
+ QString m_inspectedURL;
+ };
+}
+
+#endif
diff --git a/WebKit/qt/WebKitPart/WebKitFactory.cpp b/WebKit/qt/WebKitPart/WebKitFactory.cpp
new file mode 100644
index 0000000..ac43f86
--- /dev/null
+++ b/WebKit/qt/WebKitPart/WebKitFactory.cpp
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 "WebKitFactory.h"
+
+#include "WebKitPart.h"
+
+#include <klocale.h>
+#include <kinstance.h>
+#include <kaboutdata.h>
+
+WebKitFactory* WebKitFactory::s_self = 0;
+unsigned long int WebKitFactory::s_refCount = 0;
+KInstance* WebKitFactory::s_instance = 0;
+KAboutData* WebKitFactory::s_about = 0;
+
+WebKitFactory::WebKitFactory(bool clone)
+{
+ if (clone)
+ ref();
+}
+
+WebKitFactory::~WebKitFactory()
+{
+ if (s_self == this) {
+ Q_ASSERT(!s_refCount);
+
+ delete s_instance;
+ delete s_about;
+
+ s_instance = 0;
+ s_about = 0;
+ }
+ else
+ deref();
+}
+
+KParts::Part* WebKitFactory::createPartObject(QWidget* parentWidget,
+ QObject* parentObject,
+ const char* className,
+ const QStringList& args)
+{
+ WebKitPart::GUIProfile prof = WebKitPart::DefaultGUI;
+
+ if (strcmp(className, "Browser/View") == 0)
+ prof = WebKitPart::BrowserViewGUI;
+
+ return new WebKitPart(parentWidget, parentObject, prof);
+}
+
+KInstance* WebKitFactory::instance()
+{
+ Q_ASSERT(s_self != 0);
+
+ if (!s_instance) {
+ s_about = new KAboutData("WebKitPart", I18N_NOOP("WebKit"), "0.1",
+ I18N_NOOP("Embeddable HTML/SVG component"),
+ KAboutData::License_LGPL);
+
+ // FIXME: Add copyright information in the KAboutData!
+ s_instance = new KInstance(s_about);
+ }
+
+ return s_instance;
+}
+
+void WebKitFactory::ref()
+{
+ if (!s_refCount && !s_self)
+ s_self = new WebKitFactory();
+
+ s_refCount++;
+}
+
+void WebKitFactory::deref()
+{
+ if(!--s_refCount && s_self) {
+ delete s_self;
+ s_self = 0;
+ }
+}
+
+// Factory entry point
+extern "C" void* init_libWebKitPart()
+{
+ return new WebKitFactory(true);
+}
+
+#include "WebKitFactory.moc"
diff --git a/WebKit/qt/WebKitPart/WebKitFactory.h b/WebKit/qt/WebKitPart/WebKitFactory.h
new file mode 100644
index 0000000..ff83437
--- /dev/null
+++ b/WebKit/qt/WebKitPart/WebKitFactory.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 WebKitFactory_H
+#define WebKitFactory_H
+
+#include <QObject>
+
+#include <kparts/factory.h>
+
+class KInstance;
+class KAboutData;
+
+class WebKitFactory : public KParts::Factory
+{
+Q_OBJECT
+
+public:
+ WebKitFactory(bool clone = false);
+ virtual ~WebKitFactory();
+
+ virtual KParts::Part* createPartObject(QWidget* parentWidget,
+ QObject* parentObject,
+ const char* className,
+ const QStringList& args);
+
+ static KInstance* instance();
+
+
+protected:
+ static void ref();
+ static void deref();
+
+private:
+ static unsigned long s_refCount;
+
+ static WebKitFactory* s_self;
+ static KInstance* s_instance;
+ static KAboutData* s_about;
+};
+
+#endif
diff --git a/WebKit/qt/WebKitPart/WebKitPart.cpp b/WebKit/qt/WebKitPart/WebKitPart.cpp
new file mode 100644
index 0000000..26c2668
--- /dev/null
+++ b/WebKit/qt/WebKitPart/WebKitPart.cpp
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ * Copyright (C) 2006 Zack Rusin <zack@kde.org>
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 "WebKitPart.h"
+
+#include "FrameLoader.h"
+#include "FrameView.h"
+#include "ChromeClientQt.h"
+#include "ContextMenuClientQt.h"
+#include "DragClientQt.h"
+#include "EditorClientQt.h"
+#include "InspectorClientQt.h"
+#include "KURL.h"
+
+#include <QDebug>
+
+#include "Page.h"
+#include "FrameQt.h"
+#include "WebKitFactory.h"
+#include "WebKitPartClient.h"
+#include "WebKitPartBrowserExtension.h"
+
+using namespace WebCore;
+
+WebKitPart::WebKitPart(QWidget* parentWidget, QObject* parentObject, GUIProfile prof)
+ : KParts::ReadOnlyPart(parentObject)
+ , m_frame(0)
+ , m_frameView(0)
+ , m_client(0)
+{
+ setInstance(WebKitFactory::instance(), prof == BrowserViewGUI && !parentPart());
+ initView(parentWidget, prof);
+
+ m_extension = new WebKitPartBrowserExtension(this);
+}
+
+WebKitPart::~WebKitPart()
+{
+ if (m_frame)
+ delete m_frame->page();
+
+ delete m_client;
+ delete m_extension;
+}
+
+bool WebKitPart::openFile()
+{
+ return true;
+}
+
+bool WebKitPart::openUrl(const KUrl& url)
+{
+ if (!m_client)
+ return false;
+
+ emit started(0);
+ m_client->openURL(KURL(url.toEncoded()));
+ return true;
+}
+
+bool WebKitPart::closeUrl()
+{
+ return m_frame->loader()->closeURL();
+}
+
+WebKitPart* WebKitPart::parentPart()
+{
+ return qobject_cast<WebKitPart*>(parent());
+}
+
+Frame* WebKitPart::frame()
+{
+ return m_frame.get();
+}
+
+void WebKitPart::initView(QWidget* parentWidget, GUIProfile prof)
+{
+ if (prof == DefaultGUI)
+ setXMLFile("WebKitPart.rc");
+ else if (prof == BrowserViewGUI)
+ setXMLFile("WebKitPartBrowser.rc");
+
+ m_client = new WebKitPartClient(this);
+
+ // Initialize WebCore in Qt platform mode...
+ Page* page = new Page(new ChromeClientQt(), new ContextMenuClientQt(), new EditorClientQt(), new DragClientQt(), new InspectorClientQt());
+ Frame* frame = new FrameQt(page, 0, m_client);
+
+ m_frame = frame;
+ frame->deref(); // Frames are created with a refcount of 1. Release this ref, since we've assigned it to a RefPtr
+
+ page->setMainFrame(frame);
+
+ FrameView* frameView = new FrameView(frame);
+ m_frameView = frameView;
+ frameView->deref(); // FrameViews are created with a refcount of 1. Release this ref, since we've assigned it to a RefPtr
+
+ m_frame->setView(frameView);
+ m_frameView->setParentWidget(parentWidget);
+
+ m_frame->init();
+
+ // Initialize KParts widget...
+ setWidget(m_frame->view()->qwidget());
+}
+
+#include "WebKitPart.moc"
diff --git a/WebKit/qt/WebKitPart/WebKitPart.desktop b/WebKit/qt/WebKitPart/WebKitPart.desktop
new file mode 100644
index 0000000..a942139
--- /dev/null
+++ b/WebKit/qt/WebKitPart/WebKitPart.desktop
@@ -0,0 +1,12 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=Service
+Comment=Embeddable HTML/SVG viewing component
+Comment[x-test]=xxEmbeddable HTML/SVg viewing componentxx
+MimeType=text/html;text/xml;application/xhtml+xml;image/svg+xml;image/svg-xml
+Icon=konqueror
+Name=WebKit
+Name[x-test]=xxWebKitLxx
+ServiceTypes=KParts/ReadOnlyPart,Browser/View
+X-KDE-Library=libWebKitPart
+InitialPreference=10
diff --git a/WebKit/qt/WebKitPart/WebKitPart.h b/WebKit/qt/WebKitPart/WebKitPart.h
new file mode 100644
index 0000000..6472d44
--- /dev/null
+++ b/WebKit/qt/WebKitPart/WebKitPart.h
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 WebKitPart_H
+#define WebKitPart_H
+
+#include <QObject>
+
+#include <wtf/RefPtr.h>
+#include <kparts/part.h>
+
+namespace WebCore {
+ class Frame;
+ class FrameView;
+}
+
+class WebKitPartClient;
+class WebKitPartBrowserExtension;
+
+class WebKitPart : public KParts::ReadOnlyPart
+{
+Q_OBJECT
+
+public:
+ enum GUIProfile {
+ DefaultGUI,
+ BrowserViewGUI
+ };
+
+ WebKitPart(QWidget* parentWidget = 0,
+ QObject* parentObject = 0,
+ GUIProfile prof = DefaultGUI);
+
+ virtual ~WebKitPart();
+
+ /**
+ * Opens the specified URL @p url.
+ *
+ * Reimplemented from KParts::ReadOnlyPart::openURL .
+ */
+ virtual bool openUrl(const KUrl&);
+
+ /**
+ * Stops loading the document and kills all data requests (for images, etc.)
+ */
+ virtual bool closeUrl();
+
+ /**
+ * Returns a pointer to the parent WebKitPart
+ * if the part is a frame in an HTML frameset.
+ *
+ * Returns 0 otherwise.
+ */
+ WebKitPart* parentPart();
+
+private:
+ friend class WebKitPartClient;
+
+ /**
+ * Returns pointer the current frame.
+ */
+ WebCore::Frame* frame();
+
+ /**
+ * Internal empty reimplementation of KParts::ReadOnlyPart::openFile .
+ */
+ virtual bool openFile();
+
+ /**
+ * Internal helper method
+ */
+ void initView(QWidget*, GUIProfile);
+
+private:
+ WTF::RefPtr<WebCore::Frame> m_frame;
+ WTF::RefPtr<WebCore::FrameView> m_frameView;
+
+ WebKitPartClient* m_client;
+ WebKitPartBrowserExtension* m_extension;
+};
+
+#endif
diff --git a/WebKit/qt/WebKitPart/WebKitPart.rc b/WebKit/qt/WebKitPart/WebKitPart.rc
new file mode 100644
index 0000000..886af21
--- /dev/null
+++ b/WebKit/qt/WebKitPart/WebKitPart.rc
@@ -0,0 +1,16 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartgui name="WebKitPart" version="1">
+<MenuBar>
+ <Menu name="edit"><text>&amp;Edit</text>
+ <Action name="selectAll" />
+ <Separator />
+ <Action name="find" />
+ <Action name="findNext" />
+ <Action name="findPrevious" />
+ <Action name="findAheadText" />
+ <Action name="findAheadLink" />
+ </Menu>
+</MenuBar>
+<ActionProperties>
+</ActionProperties>
+</kpartgui>
diff --git a/WebKit/qt/WebKitPart/WebKitPartBrowser.rc b/WebKit/qt/WebKitPart/WebKitPartBrowser.rc
new file mode 100644
index 0000000..7fcc844
--- /dev/null
+++ b/WebKit/qt/WebKitPart/WebKitPartBrowser.rc
@@ -0,0 +1,46 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartgui name="WebKitPart" version="1">
+<MenuBar>
+ <Menu name="file"><text>&amp;File</text>
+ <Action name="saveBackground" />
+ <Action name="saveDocument" />
+ <Action name="saveFrame" />
+ <Separator />
+ <Action name="printFrame" group="print" />
+ </Menu>
+ <Menu name="edit"><text>&amp;Edit</text>
+ <Action name="selectAll" />
+ <Separator />
+ <Action name="find" />
+ <Action name="findNext" />
+ <Action name="findPrevious" />
+ <Action name="findAheadText" />
+ <Action name="findAheadLink" />
+ </Menu>
+ <Menu name="view"><text>&amp;View</text>
+ <Action name="incFontSizes" />
+ <Action name="decFontSizes" />
+ <Action name="viewDocumentSource" />
+ <Action name="viewPageInfo" />
+ <Action name="setEncoding" />
+ <Action name="useStylesheet" />
+ <ActionList name="debugScriptList" />
+<!--
+<!--
+ <Separator />
+ <Action name="debugRenderTree" />
+ <Action name="debugDOMTree" />
+-->
+ </Menu>
+</MenuBar>
+<ToolBar name="mainToolBar"><text>Main Toolbar</text>
+ <Action name="find" />
+ <Separator />
+ <Action name="incFontSizes" />
+ <Action name="decFontSizes" />
+ <ActionList name="loadImages" />
+</ToolBar>
+<ActionProperties>
+ <Action shortcut="F7" name="caretMode" />
+</ActionProperties>
+</kpartgui>
diff --git a/WebKit/qt/WebKitPart/WebKitPartBrowserExtension.cpp b/WebKit/qt/WebKitPart/WebKitPartBrowserExtension.cpp
new file mode 100644
index 0000000..66bf854
--- /dev/null
+++ b/WebKit/qt/WebKitPart/WebKitPartBrowserExtension.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 "WebKitPartBrowserExtension.h"
+
+WebKitPartBrowserExtension::WebKitPartBrowserExtension(KParts::ReadOnlyPart* part)
+ : KParts::BrowserExtension(part)
+{
+}
+
+WebKitPartBrowserExtension::~WebKitPartBrowserExtension()
+{
+}
+
+// vim: ts=4 sw=4 et
diff --git a/WebKit/qt/WebKitPart/WebKitPartBrowserExtension.h b/WebKit/qt/WebKitPart/WebKitPartBrowserExtension.h
new file mode 100644
index 0000000..5ef4c0a
--- /dev/null
+++ b/WebKit/qt/WebKitPart/WebKitPartBrowserExtension.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 WebKitPartBrowserExtension_H
+#define WebKitPartBrowserExtension_H
+
+#include <kparts/browserextension.h>
+
+class WebKitPartBrowserExtension : public KParts::BrowserExtension
+{
+public:
+ WebKitPartBrowserExtension(KParts::ReadOnlyPart*);
+ virtual ~WebKitPartBrowserExtension();
+};
+
+#endif
+
+// vim: ts=4 sw=4 et
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 WebKitPartBrowserExtension_H
+#define WebKitPartBrowserExtension_H
+
+#include <kparts/browserextension.h>
+
+class WebKitPartBrowserExtension : public KParts::BrowserExtension
+{
+public:
+ WebKitPartBrowserExtension(KParts::ReadOnlyPart*);
+ virtual ~WebKitPartBrowserExtension();
+};
+
+#endif
+
+// vim: ts=4 sw=4 et
diff --git a/WebKit/qt/WebKitPart/WebKitPartClient.cpp b/WebKit/qt/WebKitPart/WebKitPartClient.cpp
new file mode 100644
index 0000000..2c89e7e
--- /dev/null
+++ b/WebKit/qt/WebKitPart/WebKitPartClient.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 "WebKitPartClient.h"
+
+#include "WebKitPart.h"
+
+using namespace WebCore;
+
+WebKitPartClient::WebKitPartClient(WebKitPart* part)
+ : FrameQtClientDefault()
+ , m_part(part)
+{
+}
+
+WebKitPartClient::~WebKitPartClient()
+{
+}
+
+void WebKitPartClient::loadFinished() const
+{
+ emit m_part->completed();
+}
+
+// vim: ts=4 sw=4 et
diff --git a/WebKit/qt/WebKitPart/WebKitPartClient.h b/WebKit/qt/WebKitPart/WebKitPartClient.h
new file mode 100644
index 0000000..8874334
--- /dev/null
+++ b/WebKit/qt/WebKitPart/WebKitPartClient.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 WebKitPartClient_H
+#define WebKitPartClient_H
+
+#include "FrameQt.h"
+
+class WebKitPart;
+class WebKitPartClient : public WebCore::FrameQtClientDefault
+{
+public:
+ WebKitPartClient(WebKitPart*);
+ virtual ~WebKitPartClient();
+
+ virtual void loadFinished() const;
+
+private:
+ WebKitPart* m_part;
+};
+
+#endif
+
+// vim: ts=4 sw=4 et
diff --git a/WebKit/qt/WebKitPart/WebKitPartInterface.cpp b/WebKit/qt/WebKitPart/WebKitPartInterface.cpp
new file mode 100644
index 0000000..ae49b96
--- /dev/null
+++ b/WebKit/qt/WebKitPart/WebKitPartInterface.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 "WebKitPartInterface.h"
+
+#include "WebKitPart.h"
+
+WebKitPartInterface::WebKitPartInterface(WebKitPart* part)
+ : QObject(part)
+ , m_part(part)
+{
+ Q_ASSERT(m_part != 0);
+}
+
+WebKitPartInterface::~WebKitPartInterface()
+{
+}
+
+
+KUrl WebKitPartInterface::url() const
+{
+ return m_part->url();
+}
+
+bool WebKitPartInterface::closeURL()
+{
+ return m_part->closeUrl();
+}
+
+#include "WebKitPartInterface.moc"
diff --git a/WebKit/qt/WebKitPart/WebKitPartInterface.h b/WebKit/qt/WebKitPart/WebKitPartInterface.h
new file mode 100644
index 0000000..a011370
--- /dev/null
+++ b/WebKit/qt/WebKitPart/WebKitPartInterface.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 WebKitPartInterface_H
+#define WebKitPartInterface_H
+
+#include <QObject>
+
+class KUrl;
+class WebKitPart;
+
+// Exposed to DBUS.
+class WebKitPartInterface : public QObject
+{
+Q_OBJECT
+
+public:
+ WebKitPartInterface(WebKitPart*);
+ virtual ~WebKitPartInterface();
+
+public Q_SLOTS:
+ KUrl url() const;
+
+ bool closeURL();
+
+private:
+ WebKitPart* m_part;
+};
+
+#endif
diff --git a/WebKit/qt/WebKitPart/org.kde.WebKitPart.xml b/WebKit/qt/WebKitPart/org.kde.WebKitPart.xml
new file mode 100644
index 0000000..84cacd1
--- /dev/null
+++ b/WebKit/qt/WebKitPart/org.kde.WebKitPart.xml
@@ -0,0 +1,10 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.kde.WebKitPart">
+ <property name="url" type="s" access="read"/>
+ <method name="closeURL">
+ <arg type="b" direction="out"/>
+ </method>
+ </interface>
+</node>
diff --git a/WebKit/qt/WebKit_pch.h b/WebKit/qt/WebKit_pch.h
new file mode 100644
index 0000000..61c8d5b
--- /dev/null
+++ b/WebKit/qt/WebKit_pch.h
@@ -0,0 +1,76 @@
+/*
+ * This file is part of the precompiled header for all of WebKit.
+ *
+ * Copyright (C) 2007 Trolltech
+ *
+ * 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This is a precompiled header file for use in Xcode / Mac GCC /
+ * GCC >= 3.4 / VC to greatly speed the building of QtWebKit.
+ *
+ * The order of the includes appears random and arbitrary. But unfortunately
+ * MSVC is very sensitive and behaves fairly strange when compiling with
+ * precompiled headers. Please be very careful when adding, removing or
+ * changing the order of included header files.
+ */
+
+
+#if defined __cplusplus
+#include "../../JavaScriptCore/kjs/config.h"
+
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <algorithm>
+#include <assert.h>
+#include <ctype.h>
+#include <limits.h>
+
+#include <wtf/HashTable.h>
+#include <wtf/Vector.h>
+#include <wtf/ListHashSet.h>
+#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
+#include <wtf/HashTraits.h>
+#include <wtf/HashIterators.h>
+#include <wtf/TCPageMap.h>
+#include <wtf/Assertions.h>
+#include <wtf/HashCountedSet.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/Platform.h>
+#include <wtf/RefPtr.h>
+#include <wtf/VectorTraits.h>
+#include <wtf/MathExtras.h>
+#include <wtf/HashFunctions.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/OwnArrayPtr.h>
+#include <wtf/ListRefPtr.h>
+#include <wtf/FastMalloc.h>
+#include <wtf/TCSystemAlloc.h>
+#include <wtf/StringExtras.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/Forward.h>
+#include <wtf/UnusedParam.h>
+#include <wtf/AlwaysInline.h>
+#include <wtf/GetPtr.h>
+
+#include "../../WebCore/bindings/js/kjs_binding.h"
+#include "../../JavaScriptCore/kjs/math_object.h"
+#endif