summaryrefslogtreecommitdiffstats
path: root/WebKit/qt
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/qt')
-rw-r--r--WebKit/qt/Api/qwebframe.cpp958
-rw-r--r--WebKit/qt/Api/qwebframe.h134
-rw-r--r--WebKit/qt/Api/qwebframe_p.h56
-rw-r--r--WebKit/qt/Api/qwebhistory.cpp238
-rw-r--r--WebKit/qt/Api/qwebhistory.h33
-rw-r--r--WebKit/qt/Api/qwebhistory_p.h26
-rw-r--r--WebKit/qt/Api/qwebhistoryinterface.cpp65
-rw-r--r--WebKit/qt/Api/qwebhistoryinterface.h28
-rw-r--r--WebKit/qt/Api/qwebkitglobal.h19
-rw-r--r--WebKit/qt/Api/qwebnetworkinterface.cpp75
-rw-r--r--WebKit/qt/Api/qwebnetworkinterface.h36
-rw-r--r--WebKit/qt/Api/qwebnetworkinterface_p.h38
-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.cpp1900
-rw-r--r--WebKit/qt/Api/qwebpage.h148
-rw-r--r--WebKit/qt/Api/qwebpage_p.h101
-rw-r--r--WebKit/qt/Api/qwebpluginfactory.cpp216
-rw-r--r--WebKit/qt/Api/qwebpluginfactory.h74
-rw-r--r--WebKit/qt/Api/qwebsettings.cpp316
-rw-r--r--WebKit/qt/Api/qwebsettings.h47
-rw-r--r--WebKit/qt/Api/qwebview.cpp538
-rw-r--r--WebKit/qt/Api/qwebview.h70
-rw-r--r--WebKit/qt/ChangeLog3553
-rw-r--r--WebKit/qt/Plugins/ICOHandler.cpp2
-rw-r--r--WebKit/qt/QtLauncher/QtLauncher.pro1
-rw-r--r--WebKit/qt/QtLauncher/main.cpp546
-rw-r--r--WebKit/qt/WebCoreSupport/ChromeClientQt.cpp108
-rw-r--r--WebKit/qt/WebCoreSupport/ChromeClientQt.h16
-rw-r--r--WebKit/qt/WebCoreSupport/EditCommandQt.cpp7
-rw-r--r--WebKit/qt/WebCoreSupport/EditCommandQt.h10
-rw-r--r--WebKit/qt/WebCoreSupport/EditorClientQt.cpp76
-rw-r--r--WebKit/qt/WebCoreSupport/EditorClientQt.h2
-rw-r--r--WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp633
-rw-r--r--WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h141
-rw-r--r--WebKit/qt/WebCoreSupport/InspectorClientQt.cpp55
-rw-r--r--WebKit/qt/WebCoreSupport/InspectorClientQt.h12
-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.h11
-rw-r--r--WebKit/qt/tests/qwebframe/qwebframe.pro6
-rw-r--r--WebKit/qt/tests/qwebframe/tst_qwebframe.cpp2072
-rw-r--r--WebKit/qt/tests/qwebpage/qwebpage.pro6
-rw-r--r--WebKit/qt/tests/qwebpage/tst_qwebpage.cpp342
-rw-r--r--WebKit/qt/tests/tests.pro3
60 files changed, 10837 insertions, 3182 deletions
diff --git a/WebKit/qt/Api/qwebframe.cpp b/WebKit/qt/Api/qwebframe.cpp
index 058a283..892949d 100644
--- a/WebKit/qt/Api/qwebframe.cpp
+++ b/WebKit/qt/Api/qwebframe.cpp
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2007 Trolltech ASA
+ Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
Copyright (C) 2007 Staikos Computing Services Inc.
This library is free software; you can redistribute it and/or
@@ -16,10 +16,8 @@
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"
@@ -34,9 +32,12 @@
#include "FrameView.h"
#include "IconDatabase.h"
#include "Page.h"
+#include "PutPropertySlot.h"
#include "ResourceRequest.h"
+#include "RenderView.h"
#include "SelectionController.h"
-#include "PlatformScrollBar.h"
+#include "Scrollbar.h"
+#include "PrintContext.h"
#include "SubstituteData.h"
#include "markup.h"
@@ -44,26 +45,30 @@
#include "Element.h"
#include "Document.h"
#include "DragData.h"
-#include "RenderObject.h"
+#include "RenderView.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 "runtime.h"
+#include "runtime_object.h"
+#include "runtime_root.h"
+#include "JSDOMWindow.h"
+#include "qt_instance.h"
+#include "ScriptController.h"
+#include "JSDOMBinding.h"
#include "ExecState.h"
-#include "object.h"
+#include "JSLock.h"
+#include "JSObject.h"
+#include "qt_runtime.h"
#include "wtf/HashMap.h"
#include <qdebug.h>
#include <qevent.h>
+#include <qfileinfo.h>
#include <qpainter.h>
#if QT_VERSION >= 0x040400
#include <qnetworkrequest.h>
@@ -71,44 +76,57 @@
#include "qwebnetworkinterface.h"
#endif
#include <qregion.h>
+#include <qprinter.h>
using namespace WebCore;
+// from text/qfont.cpp
+QT_BEGIN_NAMESPACE
+extern Q_GUI_EXPORT int qt_defaultDpi();
+QT_END_NAMESPACE
+
void QWebFramePrivate::init(QWebFrame *qframe, WebCore::Page *webcorePage, QWebFrameData *frameData)
{
q = qframe;
+ allowsScrolling = frameData->allowsScrolling;
+ marginWidth = frameData->marginWidth;
+ marginHeight = frameData->marginHeight;
+
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());
+ RefPtr<Frame> newFrame = Frame::create(webcorePage, frameData->ownerElement, frameLoaderClient);
+ frame = newFrame.get();
+ if (frameData->ownerElement)
+ frame->ref(); // balanced by adoptRef in FrameLoaderClientQt::createFrame
+ frameLoaderClient->setFrame(qframe, frame);
frame->init();
+}
- QObject::connect(q, SIGNAL(hoveringOverLink(const QString&, const QString&, const QString&)),
- page, SIGNAL(hoveringOverLink(const QString&, const QString&, const QString&)));
+WebCore::Scrollbar* QWebFramePrivate::horizontalScrollBar() const
+{
+ if (!frame->view())
+ return 0;
+ return frame->view()->horizontalScrollbar();
}
-WebCore::PlatformScrollbar *QWebFramePrivate::horizontalScrollBar() const
+WebCore::Scrollbar* QWebFramePrivate::verticalScrollBar() const
{
- Q_ASSERT(frameView);
- return frameView->horizontalScrollBar();
+ if (!frame->view())
+ return 0;
+ return frame->view()->verticalScrollbar();
}
-WebCore::PlatformScrollbar *QWebFramePrivate::verticalScrollBar() const
+void QWebFramePrivate::updateBackground()
{
- Q_ASSERT(frameView);
- return frameView->verticalScrollBar();
+ WebCore::FrameView *view = frame->view();
+ if (!view)
+ return;
+ QBrush brush = page->palette().brush(QPalette::Background);
+ if (brush.style() == Qt::SolidPattern) {
+ view->setBaseBackgroundColor(brush.color());
+ if (!brush.color().alpha())
+ view->setTransparent(true);
+ }
}
/*!
@@ -117,13 +135,35 @@ WebCore::PlatformScrollbar *QWebFramePrivate::verticalScrollBar() const
\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.
+ object contains at least one frame, the main frame, obtained using
+ QWebPage::mainFrame(). Additional frames will be created for HTML
+ \c{<frame>} or \c{<iframe>} elements.
+
+ A frame can be loaded using load() or setUrl(). Alternatively, if you have
+ the HTML content readily available, you can use setHtml() instead.
+
+ The page() function returns a pointer to the web page object. See
+ \l{Elements of QWebView} for an explanation of how web
+ frames are related to a web page and web view.
+
+ The title of an HTML frame can be accessed with the title() property.
+ Additionally, a frame may also specify an icon, which can be accessed
+ using the icon() property. If the title or the icon changes, the
+ corresponding titleChanged() and iconChanged() signals will be emitted.
+ The zoomFactor() property can be used to change the overall size
+ of the content displayed in the frame.
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.
+ can connect to the web page's \l{QWebPage::}{frameCreated()} signal
+ to be notified when a new frame is created.
+
+ The hitTestContent() function can be used to programmatically examine the
+ contents of a frame.
+
+ A QWebFrame can be printed onto a QPrinter using the print() function.
+ This function is marked as a slot and can be conveniently connected to
+ \l{QPrintPreviewDialog}'s \l{QPrintPreviewDialog::}{paintRequested()}
+ signal.
\sa QWebPage
*/
@@ -136,7 +176,7 @@ QWebFrame::QWebFrame(QWebPage *parent, QWebFrameData *frameData)
d->init(this, parent->d->page, frameData);
if (!frameData->url.isEmpty()) {
- ResourceRequest request(frameData->url, frameData->referrer);
+ WebCore::ResourceRequest request(frameData->url, frameData->referrer);
d->frame->loader()->load(request, frameData->name);
}
}
@@ -151,40 +191,49 @@ QWebFrame::QWebFrame(QWebFrame *parent, QWebFrameData *frameData)
QWebFrame::~QWebFrame()
{
- Q_ASSERT(d->frame == 0);
- Q_ASSERT(d->frameView == 0);
+ if (d->frame && d->frame->loader() && d->frame->loader()->client())
+ static_cast<FrameLoaderClientQt*>(d->frame->loader()->client())->m_webFrame = 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.
+ Make \a object available under \a name from within the frame's JavaScript
+ context. The \a object will be inserted as a child of the frame's window
+ object.
- Qt properties will be exposed as JavaScript properties and slots as
- JavaScript methods.
+ Qt properties will be exposed as JavaScript properties and slots as
+ JavaScript methods.
+
+ If you want to ensure that your QObjects remain accessible after loading a
+ new URL, you should add them in a slot connected to the
+ javaScriptWindowObjectCleared() signal.
*/
-void QWebFrame::addToJSWindowObject(const QString &name, QObject *object)
+void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object)
{
- KJS::JSLock lock;
- KJS::Window *window = KJS::Window::retrieveWindow(d->frame.get());
- KJS::Bindings::RootObject *root = d->frame->bindingRootObject();
+ JSC::JSLock lock(false);
+ JSDOMWindow *window = toJSDOMWindow(d->frame);
+ JSC::Bindings::RootObject *root = d->frame->script()->bindingRootObject();
if (!window) {
qDebug() << "Warning: couldn't get window object";
return;
}
- KJS::JSObject *runtimeObject =
- KJS::Bindings::Instance::createRuntimeObject(KJS::Bindings::Instance::QtLanguage,
- object, root);
+ JSC::ExecState* exec = window->globalExec();
+
+ JSC::JSObject *runtimeObject =
+ JSC::Bindings::Instance::createRuntimeObject(exec, JSC::Bindings::QtInstance::getQtInstance(object, root));
- window->put(window->globalExec(), KJS::Identifier((const KJS::UChar *) name.constData(), name.length()), runtimeObject);
+ JSC::PutPropertySlot slot;
+ window->put(exec, JSC::Identifier(exec, (const UChar *) name.constData(), name.length()), runtimeObject, slot);
}
/*!
- returns the markup (HTML) contained in the current frame.
+ Returns the frame's content, converted to HTML.
+
+ \sa setHtml(), toPlainText()
*/
-QString QWebFrame::markup() const
+QString QWebFrame::toHtml() const
{
if (!d->frame->document())
return QString();
@@ -192,32 +241,38 @@ QString QWebFrame::markup() const
}
/*!
- returns the content of this frame as plain text.
+ Returns the content of this frame converted to plain text.
+
+ \sa toHtml()
*/
-QString QWebFrame::innerText() const
+QString QWebFrame::toPlainText() const
{
- if (d->frameView->layoutPending())
- d->frameView->layout();
+ if (d->frame->view() && d->frame->view()->layoutPending())
+ d->frame->view()->layout();
Element *documentElement = d->frame->document()->documentElement();
return documentElement->innerText();
}
/*!
- returns a dump of the rendering tree. Mainly useful for debugging html.
+ Returns a dump of the rendering tree. This is mainly useful for debugging
+ html.
*/
QString QWebFrame::renderTreeDump() const
{
- if (d->frameView->layoutPending())
- d->frameView->layout();
+ if (d->frame->view() && d->frame->view()->layoutPending())
+ d->frame->view()->layout();
- return externalRepresentation(d->frame->renderer());
+ return externalRepresentation(d->frame->contentRenderer());
}
/*!
- The title of the frame as defined by the HTML &lt;title&gt;
- element.
+ \property QWebFrame::title
+ \brief the title of the frame as defined by the HTML &lt;title&gt; element
+
+ \sa titleChanged()
*/
+
QString QWebFrame::title() const
{
if (d->frame->document())
@@ -225,45 +280,49 @@ QString QWebFrame::title() const
else return QString();
}
-/*!
- The url of this frame.
-*/
-QUrl QWebFrame::url() const
+static inline QUrl ensureAbsoluteUrl(const QUrl &url)
{
- return d->frame->loader()->url();
+ if (!url.isRelative())
+ return url;
+
+ return QUrl::fromLocalFile(QFileInfo(url.toLocalFile()).absoluteFilePath());
}
/*!
- The icon associated with this frame.
+ \property QWebFrame::url
+ \brief the url of the frame currently viewed
+
+ \sa urlChanged()
*/
-QPixmap QWebFrame::icon() const
+
+void QWebFrame::setUrl(const QUrl &url)
{
- String url = d->frame->loader()->url().string();
+ d->frame->loader()->begin(ensureAbsoluteUrl(url));
+ d->frame->loader()->end();
+ load(ensureAbsoluteUrl(url));
+}
- Image* image = 0;
- if (!url.isEmpty()) {
- image = iconDatabase()->iconForPageURL(url, IntSize(16, 16));
- }
+QUrl QWebFrame::url() const
+{
+ return d->frame->loader()->url();
+}
- if (!image || image->isNull()) {
- image = iconDatabase()->defaultIcon(IntSize(16, 16));
- }
+/*!
+ \property QWebFrame::icon
+ \brief the icon associated with this frame
- if (!image) {
- return QPixmap();
- }
+ \sa iconChanged(), QWebSettings::iconForUrl()
+*/
- QPixmap *icon = image->getPixmap();
- if (!icon) {
- return QPixmap();
- }
- return *icon;
+QIcon QWebFrame::icon() const
+{
+ return QWebSettings::iconForUrl(d->frame->loader()->url());
}
/*!
The name of this frame as defined by the parent frame.
*/
-QString QWebFrame::name() const
+QString QWebFrame::frameName() const
{
return d->frame->tree()->name();
}
@@ -277,27 +336,33 @@ QWebPage *QWebFrame::page() const
}
/*!
- Load \a url into this frame.
+ Loads \a url into this frame.
+
+ \note The view remains the same until enough data has arrived to display the new \a url.
+
+ \sa setUrl(), setHtml(), setContent()
*/
void QWebFrame::load(const QUrl &url)
{
#if QT_VERSION < 0x040400
- load(QWebNetworkRequest(url));
+ load(QWebNetworkRequest(ensureAbsoluteUrl(url)));
#else
- load(QNetworkRequest(url));
+ load(QNetworkRequest(ensureAbsoluteUrl(url)));
#endif
}
#if QT_VERSION < 0x040400
/*!
- Load network request \a req into this frame.
+ Loads a network request, \a req, into this frame.
+
+ \note The view remains the same until enough data has arrived to display the new url.
*/
void QWebFrame::load(const QWebNetworkRequest &req)
{
if (d->parentFrame())
d->page->d->insideOpenCall = true;
- QUrl url = req.url();
+ QUrl url = ensureAbsoluteUrl(req.url());
QHttpRequestHeader httpHeader = req.httpHeader();
QByteArray postData = req.postData();
@@ -313,10 +378,8 @@ void QWebFrame::load(const QWebNetworkRequest &req)
request.addHTTPHeaderField(val.first, val.second);
}
- if (!postData.isEmpty()) {
- WTF::RefPtr<WebCore::FormData> formData = new WebCore::FormData(postData.constData(), postData.size());
- request.setHTTPBody(formData);
- }
+ if (!postData.isEmpty())
+ request.setHTTPBody(WebCore::FormData::create(postData.constData(), postData.size()));
d->frame->loader()->load(request);
@@ -327,8 +390,14 @@ void QWebFrame::load(const QWebNetworkRequest &req)
#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.
+ Loads a network request, \a req, into this frame, using the method specified in \a
+ operation.
+
+ \a body is optional and is only used for POST operations.
+
+ \note The view remains the same until enough data has arrived to display the new \a url.
+
+ \sa setUrl()
*/
void QWebFrame::load(const QNetworkRequest &req,
QNetworkAccessManager::Operation operation,
@@ -337,7 +406,7 @@ void QWebFrame::load(const QNetworkRequest &req,
if (d->parentFrame())
d->page->d->insideOpenCall = true;
- QUrl url = req.url();
+ QUrl url = ensureAbsoluteUrl(req.url());
WebCore::ResourceRequest request(url);
@@ -365,10 +434,8 @@ void QWebFrame::load(const QNetworkRequest &req,
request.addHTTPHeaderField(QString::fromLatin1(headerName), QString::fromLatin1(req.rawHeader(headerName)));
}
- if (!body.isEmpty()) {
- WTF::RefPtr<WebCore::FormData> formData = new WebCore::FormData(body.constData(), body.size());
- request.setHTTPBody(formData);
- }
+ if (!body.isEmpty())
+ request.setHTTPBody(WebCore::FormData::create(body.constData(), body.size()));
d->frame->loader()->load(request);
@@ -380,34 +447,38 @@ void QWebFrame::load(const QNetworkRequest &req,
/*!
Sets the content of this frame to \a html. \a baseUrl is optional and used to resolve relative
URLs in the document.
+
+ When using this method WebKit assumes that external resources such as JavaScript programs or style
+ sheets are encoded in UTF-8 unless otherwise specified. For example, the encoding of an external
+ script can be specified through the charset attribute of the HTML script tag. It is also possible
+ for the encoding to be specified by web server.
+
+ \sa toHtml()
*/
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);
+ const QByteArray utf8 = html.toUtf8();
+ WTF::RefPtr<WebCore::SharedBuffer> data = WebCore::SharedBuffer::create(utf8.constData(), utf8.length());
+ WebCore::SubstituteData substituteData(data, WebCore::String("text/html"), WebCore::String("utf-8"), 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 the specified content \a data. If the \a mimeType argument
+ is empty it is currently assumed that the content is HTML but in future versions we may introduce
+ auto-detection.
-/*!
- 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.
+ External objects referenced in the content are located relative to \a baseUrl.
+
+ \sa toHtml()
*/
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());
+ WTF::RefPtr<WebCore::SharedBuffer> buffer = WebCore::SharedBuffer::create(data.constData(), data.length());
QString actualMimeType = mimeType;
if (actualMimeType.isEmpty())
actualMimeType = QLatin1String("text/html");
@@ -421,6 +492,8 @@ void QWebFrame::setContent(const QByteArray &data, const QString &mimeType, cons
main frame.
This is equivalent to qobject_cast<QWebFrame*>(frame->parent()).
+
+ \sa childFrames()
*/
QWebFrame *QWebFrame::parentFrame() const
{
@@ -429,6 +502,8 @@ QWebFrame *QWebFrame::parentFrame() const
/*!
Returns a list of all frames that are direct children of this frame.
+
+ \sa parentFrame()
*/
QList<QWebFrame*> QWebFrame::childFrames() const
{
@@ -447,98 +522,374 @@ QList<QWebFrame*> QWebFrame::childFrames() const
}
/*!
- \property QWebFrame::verticalScrollBarPolicy
-
- This property defines the vertical scrollbar policy.
-
- \sa Qt::ScrollBarPolicy
+ Returns the scrollbar policy for the scrollbar defined by \a orientation.
*/
-Qt::ScrollBarPolicy QWebFrame::verticalScrollBarPolicy() const
+Qt::ScrollBarPolicy QWebFrame::scrollBarPolicy(Qt::Orientation orientation) const
{
- return (Qt::ScrollBarPolicy) d->frameView->vScrollbarMode();
+ if (orientation == Qt::Horizontal)
+ return d->horizontalScrollBarPolicy;
+ return d->verticalScrollBarPolicy;
}
-void QWebFrame::setVerticalScrollBarPolicy(Qt::ScrollBarPolicy policy)
+/*!
+ Sets the scrollbar policy for the scrollbar defined by \a orientation to \a policy.
+*/
+void QWebFrame::setScrollBarPolicy(Qt::Orientation orientation, 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);
+
+ if (orientation == Qt::Horizontal) {
+ d->horizontalScrollBarPolicy = policy;
+ if (d->frame->view())
+ d->frame->view()->setHorizontalScrollbarMode((ScrollbarMode)policy);
+ } else {
+ d->verticalScrollBarPolicy = policy;
+ if (d->frame->view())
+ d->frame->view()->setVerticalScrollbarMode((ScrollbarMode)policy);
+ }
}
/*!
- \property QWebFrame::horizontalScrollBarPolicy
+ Sets the current \a value for the scrollbar with orientation \a orientation.
- This property defines the horizontal scrollbar policy.
+ The scrollbar forces the \a value to be within the legal range: minimum <= value <= maximum.
- \sa Qt::ScrollBarPolicy
+ Changing the value also updates the thumb position.
+
+ \sa scrollBarMinimum(), scrollBarMaximum()
*/
-Qt::ScrollBarPolicy QWebFrame::horizontalScrollBarPolicy() const
+void QWebFrame::setScrollBarValue(Qt::Orientation orientation, int value)
{
- return (Qt::ScrollBarPolicy) d->frameView->hScrollbarMode();
+ Scrollbar *sb;
+ sb = (orientation == Qt::Horizontal) ? d->horizontalScrollBar() : d->verticalScrollBar();
+ if (sb) {
+ if (value < 0)
+ value = 0;
+ else if (value > scrollBarMaximum(orientation))
+ value = scrollBarMaximum(orientation);
+ sb->setValue(value);
+ }
}
-void QWebFrame::setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy policy)
+/*!
+ Returns the current value for the scrollbar with orientation \a orientation, or 0
+ if no scrollbar is found for \a orientation.
+
+ \sa scrollBarMinimum(), scrollBarMaximum()
+*/
+int QWebFrame::scrollBarValue(Qt::Orientation orientation) const
{
- d->frameView->setHScrollbarMode((ScrollbarMode)policy);
+ Scrollbar *sb;
+ sb = (orientation == Qt::Horizontal) ? d->horizontalScrollBar() : d->verticalScrollBar();
+ if (sb) {
+ return sb->value();
+ }
+ return 0;
+}
+
+/*!
+ Returns the maximum value for the scrollbar with orientation \a orientation, or 0
+ if no scrollbar is found for \a orientation.
+
+ \sa scrollBarMinimum()
+*/
+int QWebFrame::scrollBarMaximum(Qt::Orientation orientation) const
+{
+ Scrollbar *sb;
+ sb = (orientation == Qt::Horizontal) ? d->horizontalScrollBar() : d->verticalScrollBar();
+ if (sb)
+ return sb->maximum();
+ return 0;
+}
+
+/*!
+ Returns the minimum value for the scrollbar with orientation \a orientation.
+
+ The minimum value is always 0.
+
+ \sa scrollBarMaximum()
+*/
+int QWebFrame::scrollBarMinimum(Qt::Orientation orientation) const
+{
+ return 0;
+}
+
+/*!
+ \since 4.5
+ Scrolls the frame \a dx pixels to the right and \a dy pixels downward. Both
+ \a dx and \a dy may be negative.
+
+ \sa QWebFrame::scrollOffset
+*/
+
+void QWebFrame::scroll(int dx, int dy) const
+{
+ if (!d->frame->view())
+ return;
+
+ d->frame->view()->scrollBy(IntSize(dx, dy));
+}
+
+/*!
+ \property QWebFrame::scrollOffset
+ \brief The offset from the start this frame is currently scrolled to.
+*/
+
+QSize QWebFrame::scrollOffset() const
+{
+ if (!d->frame->view())
+ return QSize(0,0);
+
+ return d->frame->view()->scrollOffset();
+}
+
+void QWebFrame::setScrollOffset(const QSize &offset) const
+{
+ QSize current = scrollOffset();
+ int dx = offset.width() - current.width();
+ int dy = offset.height() - current.height();
+ scroll(dx, dy);
}
/*!
Render the frame into \a painter clipping to \a clip.
+
+ \sa print()
*/
void QWebFrame::render(QPainter *painter, const QRegion &clip)
{
- if (!d->frameView || !d->frame->renderer())
+ if (!d->frame->view() || !d->frame->contentRenderer())
return;
- layout();
+ d->frame->view()->layoutIfNeededRecursive();
GraphicsContext ctx(painter);
QVector<QRect> vector = clip.rects();
- for (int i = 0; i < vector.size(); ++i)
- d->frameView->paint(&ctx, vector.at(i));
+ WebCore::FrameView* view = d->frame->view();
+ for (int i = 0; i < vector.size(); ++i) {
+ if (i > 0) {
+ painter->save();
+ painter->setClipRect(vector.at(i), Qt::IntersectClip);
+ }
+
+ view->paint(&ctx, vector.at(i));
+
+ if (i > 0)
+ painter->restore();
+ }
}
/*!
- Ensure that the content of the frame and all subframes are correctly layouted.
+ Render the frame into \a painter.
*/
-void QWebFrame::layout()
+void QWebFrame::render(QPainter *painter)
{
- if (!d->frameView)
+ if (!d->frame->view() || !d->frame->contentRenderer())
return;
- d->frameView->layoutIfNeededRecursive();
+ d->frame->view()->layoutIfNeededRecursive();
+
+ GraphicsContext ctx(painter);
+ WebCore::FrameView* view = d->frame->view();
+ view->paint(&ctx, view->frameRect());
+}
+
+/*!
+ \property QWebFrame::textSizeMultiplier
+ \brief the scaling factor for all text in the frame
+ \obsolete
+
+ Use setZoomFactor instead, in combination with the ZoomTextOnly attribute in
+ QWebSettings.
+
+ \note Setting this property also enables the ZoomTextOnly attribute in
+ QWebSettings.
+*/
+
+void QWebFrame::setTextSizeMultiplier(qreal factor)
+{
+ d->frame->setZoomFactor(factor, /*isTextOnly*/true);
+}
+
+qreal QWebFrame::textSizeMultiplier() const
+{
+ return d->frame->zoomFactor();
+}
+
+/*!
+ \property QWebFrame::zoomFactor
+ \since 4.5
+ \brief the zoom factor for the frame
+*/
+
+void QWebFrame::setZoomFactor(qreal factor)
+{
+ d->frame->setZoomFactor(factor, d->frame->isZoomFactorTextOnly());
+}
+
+qreal QWebFrame::zoomFactor() const
+{
+ return d->frame->zoomFactor();
}
/*!
- returns the position of the frame relative to it's parent frame.
+ Returns the position of the frame relative to it's parent frame.
*/
QPoint QWebFrame::pos() const
{
- Q_ASSERT(d->frameView);
- return d->pos();
+ if (!d->frame->view())
+ return QPoint();
+
+ return d->frame->view()->frameRect().topLeft();
}
/*!
- return the geometry of the frame relative to it's parent frame.
+ Return the geometry of the frame relative to it's parent frame.
*/
QRect QWebFrame::geometry() const
{
- Q_ASSERT(d->frameView);
- return d->frameView->frameGeometry();
+ if (!d->frame->view())
+ return QRect();
+ return d->frame->view()->frameRect();
}
/*!
- Evaluate JavaScript defined by \a scriptSource using this frame as context.
+ \property QWebFrame::contentsSize
+ \brief the size of the contents in this frame
*/
-QString QWebFrame::evaluateJavaScript(const QString& scriptSource)
+QSize QWebFrame::contentsSize() const
{
- KJSProxy *proxy = d->frame->scriptProxy();
- QString rc;
+ FrameView *view = d->frame->view();
+ if (!view)
+ return QSize();
+ return QSize(view->contentsWidth(), view->contentsHeight());
+}
+
+/*!
+ Performs a hit test on the frame contents at the given position \a pos and returns the hit test result.
+*/
+QWebHitTestResult QWebFrame::hitTestContent(const QPoint &pos) const
+{
+ if (!d->frame->view() || !d->frame->contentRenderer())
+ return QWebHitTestResult();
+
+ HitTestResult result = d->frame->eventHandler()->hitTestResultAtPoint(d->frame->view()->windowToContents(pos), /*allowShadowContent*/ false);
+ return QWebHitTestResult(new QWebHitTestResultPrivate(result));
+}
+
+/*! \reimp
+*/
+bool QWebFrame::event(QEvent *e)
+{
+ return QObject::event(e);
+}
+
+#ifndef QT_NO_PRINTER
+/*!
+ Prints the frame to the given \a printer.
+
+ \sa render()
+*/
+void QWebFrame::print(QPrinter *printer) const
+{
+ const qreal zoomFactorX = printer->logicalDpiX() / qt_defaultDpi();
+ const qreal zoomFactorY = printer->logicalDpiY() / qt_defaultDpi();
+
+ PrintContext printContext(d->frame);
+ float pageHeight = 0;
+
+ QRect qprinterRect = printer->pageRect();
+
+ IntRect pageRect(0, 0,
+ int(qprinterRect.width() / zoomFactorX),
+ int(qprinterRect.height() / zoomFactorY));
+
+ printContext.begin(pageRect.width());
+
+ printContext.computePageRects(pageRect, /*headerHeight*/0, /*footerHeight*/0, /*userScaleFactor*/1.0, pageHeight);
+
+ int docCopies;
+ int pageCopies;
+ if (printer->collateCopies() == true){
+ docCopies = 1;
+ pageCopies = printer->numCopies();
+ } else {
+ docCopies = printer->numCopies();
+ pageCopies = 1;
+ }
+
+ int fromPage = printer->fromPage();
+ int toPage = printer->toPage();
+ bool ascending = true;
+
+ if (fromPage == 0 && toPage == 0) {
+ fromPage = 1;
+ toPage = printContext.pageCount();
+ }
+ // paranoia check
+ fromPage = qMax(1, fromPage);
+ toPage = qMin(printContext.pageCount(), toPage);
+
+ if (printer->pageOrder() == QPrinter::LastPageFirst) {
+ int tmp = fromPage;
+ fromPage = toPage;
+ toPage = tmp;
+ ascending = false;
+ }
+
+ QPainter painter(printer);
+ painter.scale(zoomFactorX, zoomFactorY);
+ GraphicsContext ctx(&painter);
+
+ for (int i = 0; i < docCopies; ++i) {
+ int page = fromPage;
+ while (true) {
+ for (int j = 0; j < pageCopies; ++j) {
+ if (printer->printerState() == QPrinter::Aborted
+ || printer->printerState() == QPrinter::Error) {
+ printContext.end();
+ return;
+ }
+ printContext.spoolPage(ctx, page - 1, pageRect.width());
+ if (j < pageCopies - 1)
+ printer->newPage();
+ }
+
+ if (page == toPage)
+ break;
+
+ if (ascending)
+ ++page;
+ else
+ --page;
+
+ printer->newPage();
+ }
+
+ if ( i < docCopies - 1)
+ printer->newPage();
+ }
+
+ printContext.end();
+}
+#endif // QT_NO_PRINTER
+
+/*!
+ Evaluate JavaScript defined by \a scriptSource using this frame as context.
+
+ \sa addToJavaScriptWindowObject(), javaScriptWindowObjectCleared()
+*/
+QVariant QWebFrame::evaluateJavaScript(const QString& scriptSource)
+{
+ ScriptController *proxy = d->frame->script();
+ QVariant rc;
if (proxy) {
- KJS::JSValue *v = proxy->evaluate(String(), 0, scriptSource);
+ JSC::JSValue* v = proxy->evaluate(String(), 1, scriptSource);
if (v) {
- rc = String(v->toString(proxy->globalObject()->globalExec()));
+ int distance = 0;
+ rc = JSC::Bindings::convertValueToQVariant(proxy->globalObject()->globalExec(), v, QMetaType::Void, &distance);
}
}
return rc;
@@ -546,7 +897,7 @@ QString QWebFrame::evaluateJavaScript(const QString& scriptSource)
WebCore::Frame* QWebFramePrivate::core(QWebFrame* webFrame)
{
- return webFrame->d->frame.get();
+ return webFrame->d->frame;
}
QWebFrame* QWebFramePrivate::kit(WebCore::Frame* coreFrame)
@@ -556,74 +907,301 @@ QWebFrame* QWebFramePrivate::kit(WebCore::Frame* coreFrame)
/*!
- \fn void QWebFrame::cleared()
+ \fn void QWebFrame::javaScriptWindowObjectCleared()
+
+ This signal is emitted whenever the global window object of the JavaScript
+ environment is cleared, e.g., before starting a new load.
+
+ If you intend to add QObjects to a QWebFrame using
+ addToJavaScriptWindowObject(), you should add them in a slot connected
+ to this signal. This ensures that your objects remain accessible when
+ loading new URLs.
+*/
- This signal is emitted whenever the content of the frame is cleared
- (e.g. before starting a new load).
+/*!
+ \fn void QWebFrame::provisionalLoad()
+ \internal
*/
/*!
- \fn void QWebFrame::loadDone(bool ok)
+ \fn void QWebFrame::titleChanged(const QString &title)
- This signal is emitted when the frame is completely loaded. \a ok will indicate whether the load
- was successful or any error occurred.
+ This signal is emitted whenever the title of the frame changes.
+ The \a title string specifies the new title.
+
+ \sa title()
*/
/*!
- \fn void QWebFrame::provisionalLoad()
+ \fn void QWebFrame::urlChanged(const QUrl &url)
+
+ This signal is emitted with the URL of the frame when the frame's title is
+ received. The new URL is specified by \a url.
- \internal
+ \sa url()
*/
/*!
- \fn void QWebFrame::titleChanged(const QString &title)
+ \fn void QWebFrame::initialLayoutCompleted()
- This signal is emitted whenever the title of the frame changes.
- The \a title string specifies the new title.
+ This signal is emitted when the frame is laid out the first time.
+ This is the first time you will see contents displayed on the frame.
- \sa title()
+ \note A frame can be laid out multiple times.
*/
/*!
- \fn void QWebFrame::urlChanged(const QUrl &url)
+ \fn void QWebFrame::iconChanged()
- This signal is emitted whenever the \a url of the frame changes.
+ This signal is emitted when the icon ("favicon") associated with the frame
+ has been loaded.
- \sa url()
+ \sa icon()
*/
/*!
- \fn void QWebFrame::hoveringOverLink(const QString &link, const QString &title, const QString &textContent)
+ \since 4.5
+ \fn void QWebFrame::aboutToUpdateHistory(QWebHistoryItem* item);
- 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 .
+ This signal is emitted shortly before the history of navigated pages
+ is changed, for example when navigating back in the history.
+
+ A potential use-case for this signal is to store custom data in
+ the QWebHistoryItem associated to the frame, using QWebHistoryItem::setUserData().
*/
+/*!
+ \class QWebHitTestResult
+ \since 4.4
+ \brief The QWebHitTestResult class provides information about the web
+ page content after a hit test.
+
+ QWebHitTestResult is returned by QWebFrame::hitTestContent() to provide
+ information about the content of the web page at the specified position.
+*/
+
+/*!
+ \internal
+*/
+QWebHitTestResult::QWebHitTestResult(QWebHitTestResultPrivate *priv)
+ : d(priv)
+{
+}
+
+QWebHitTestResultPrivate::QWebHitTestResultPrivate(const WebCore::HitTestResult &hitTest)
+ : isContentEditable(false)
+ , isContentSelected(false)
+{
+ if (!hitTest.innerNode())
+ return;
+ pos = hitTest.point();
+ boundingRect = hitTest.boundingBox();
+ title = hitTest.title();
+ linkText = hitTest.textContent();
+ linkUrl = hitTest.absoluteLinkURL();
+ linkTitle = hitTest.titleDisplayString();
+ alternateText = hitTest.altDisplayString();
+ imageUrl = hitTest.absoluteImageURL();
+ innerNonSharedNode = hitTest.innerNonSharedNode();
+ WebCore::Image *img = hitTest.image();
+ if (img) {
+ QPixmap *pix = img->nativeImageForCurrentFrame();
+ if (pix)
+ pixmap = *pix;
+ }
+ WebCore::Frame *wframe = hitTest.targetFrame();
+ if (wframe)
+ linkTargetFrame = QWebFramePrivate::kit(wframe);
+
+ isContentEditable = hitTest.isContentEditable();
+ isContentSelected = hitTest.isSelected();
+
+ if (innerNonSharedNode && innerNonSharedNode->document()
+ && innerNonSharedNode->document()->frame())
+ frame = QWebFramePrivate::kit(innerNonSharedNode->document()->frame());
+}
/*!
- \fn void QWebFrame::loadStarted()
+ Constructs a null hit test result.
+*/
+QWebHitTestResult::QWebHitTestResult()
+ : d(0)
+{
+}
- This signal is emitted when a new load of the frame is started.
+/*!
+ Constructs a hit test result from \a other.
*/
+QWebHitTestResult::QWebHitTestResult(const QWebHitTestResult &other)
+ : d(0)
+{
+ if (other.d)
+ d = new QWebHitTestResultPrivate(*other.d);
+}
/*!
- \fn void QWebFrame::loadFinished()
-
- This signal is emitted when a load of the frame is finished.
+ Assigns the \a other hit test result to this.
*/
+QWebHitTestResult &QWebHitTestResult::operator=(const QWebHitTestResult &other)
+{
+ if (this != &other) {
+ if (other.d) {
+ if (!d)
+ d = new QWebHitTestResultPrivate;
+ *d = *other.d;
+ } else {
+ delete d;
+ d = 0;
+ }
+ }
+ return *this;
+}
/*!
- \fn void QWebFrame::initialLayoutComplete()
+ Destructor.
+*/
+QWebHitTestResult::~QWebHitTestResult()
+{
+ delete d;
+}
- 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.
+/*!
+ Returns true if the hit test result is null; otherwise returns false.
*/
-
+bool QWebHitTestResult::isNull() const
+{
+ return !d;
+}
+
+/*!
+ Returns the position where the hit test occured.
+*/
+QPoint QWebHitTestResult::pos() const
+{
+ if (!d)
+ return QPoint();
+ return d->pos;
+}
+
+/*!
+ \since 4.5
+ Returns the bounding box of the element.
+*/
+QRect QWebHitTestResult::boundingRect() const
+{
+ if (!d)
+ return QRect();
+ return d->boundingRect;
+}
+
/*!
- \fn void QWebFrame::iconLoaded()
+ Returns the title of the nearest enclosing HTML element.
+*/
+QString QWebHitTestResult::title() const
+{
+ if (!d)
+ return QString();
+ return d->title;
+}
- This signal is emitted when the icon ("favicon") associated with the frame has been loaded.
+/*!
+ Returns the text of the link.
*/
+QString QWebHitTestResult::linkText() const
+{
+ if (!d)
+ return QString();
+ return d->linkText;
+}
+
+/*!
+ Returns the url to which the link points to.
+*/
+QUrl QWebHitTestResult::linkUrl() const
+{
+ if (!d)
+ return QUrl();
+ return d->linkUrl;
+}
+
+/*!
+ Returns the title of the link.
+*/
+QUrl QWebHitTestResult::linkTitle() const
+{
+ if (!d)
+ return QUrl();
+ return d->linkTitle;
+}
+
+/*!
+ Returns the frame that will load the link if it is activated.
+*/
+QWebFrame *QWebHitTestResult::linkTargetFrame() const
+{
+ if (!d)
+ return 0;
+ return d->linkTargetFrame;
+}
+
+/*!
+ Returns the alternate text of the element. This corresponds to the HTML alt attribute.
+*/
+QString QWebHitTestResult::alternateText() const
+{
+ if (!d)
+ return QString();
+ return d->alternateText;
+}
+
+/*!
+ Returns the url of the image.
+*/
+QUrl QWebHitTestResult::imageUrl() const
+{
+ if (!d)
+ return QUrl();
+ return d->imageUrl;
+}
+
+/*!
+ Returns a QPixmap containing the image. A null pixmap is returned if the
+ element being tested is not an image.
+*/
+QPixmap QWebHitTestResult::pixmap() const
+{
+ if (!d)
+ return QPixmap();
+ return d->pixmap;
+}
+
+/*!
+ Returns true if the content is editable by the user; otherwise returns false.
+*/
+bool QWebHitTestResult::isContentEditable() const
+{
+ if (!d)
+ return false;
+ return d->isContentEditable;
+}
+
+/*!
+ Returns true if the content tested is part of the selection; otherwise returns false.
+*/
+bool QWebHitTestResult::isContentSelected() const
+{
+ if (!d)
+ return false;
+ return d->isContentSelected;
+}
+
+/*!
+ Returns the frame the hit test was executed in.
+*/
+QWebFrame *QWebHitTestResult::frame() const
+{
+ if (!d)
+ return 0;
+ return d->frame;
+}
+
diff --git a/WebKit/qt/Api/qwebframe.h b/WebKit/qt/Api/qwebframe.h
index a1cdb25..4d37205 100644
--- a/WebKit/qt/Api/qwebframe.h
+++ b/WebKit/qt/Api/qwebframe.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2007 Trolltech ASA
+ Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
Copyright (C) 2007 Staikos Computing Services Inc.
This library is free software; you can redistribute it and/or
@@ -16,9 +16,6 @@
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
@@ -26,23 +23,30 @@
#include <QtCore/qobject.h>
#include <QtCore/qurl.h>
+#include <QtCore/qvariant.h>
+#include <QtGui/qicon.h>
#if QT_VERSION >= 0x040400
#include <QtNetwork/qnetworkaccessmanager.h>
#endif
#include "qwebkitglobal.h"
+QT_BEGIN_NAMESPACE
class QRect;
class QPoint;
class QPainter;
class QPixmap;
class QMouseEvent;
class QWheelEvent;
-class QWebNetworkRequest;
class QNetworkRequest;
+class QRegion;
+class QPrinter;
+QT_END_NAMESPACE
+class QWebNetworkRequest;
class QWebFramePrivate;
class QWebPage;
-class QRegion;
+class QWebHitTestResult;
+class QWebHistoryItem;
namespace WebCore {
class WidgetPrivate;
@@ -50,12 +54,57 @@ namespace WebCore {
class ChromeClientQt;
}
class QWebFrameData;
+class QWebHitTestResultPrivate;
+class QWebFrame;
+
+class QWEBKIT_EXPORT QWebHitTestResult
+{
+public:
+ QWebHitTestResult();
+ QWebHitTestResult(const QWebHitTestResult &other);
+ QWebHitTestResult &operator=(const QWebHitTestResult &other);
+ ~QWebHitTestResult();
+
+ bool isNull() const;
+
+ QPoint pos() const;
+ QRect boundingRect() const;
+ QString title() const;
+
+ QString linkText() const;
+ QUrl linkUrl() const;
+ QUrl linkTitle() const;
+ QWebFrame *linkTargetFrame() const;
+
+ QString alternateText() const; // for img, area, input and applet
+
+ QUrl imageUrl() const;
+ QPixmap pixmap() const;
+
+ bool isContentEditable() const;
+ bool isContentSelected() const;
+
+ QWebFrame *frame() const;
+
+private:
+ QWebHitTestResult(QWebHitTestResultPrivate *priv);
+ QWebHitTestResultPrivate *d;
+
+ friend class QWebFrame;
+ friend class QWebPagePrivate;
+ friend class QWebPage;
+};
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)
+ Q_PROPERTY(qreal textSizeMultiplier READ textSizeMultiplier WRITE setTextSizeMultiplier DESIGNABLE false)
+ Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor)
+ Q_PROPERTY(QString title READ title)
+ Q_PROPERTY(QUrl url READ url WRITE setUrl)
+ Q_PROPERTY(QIcon icon READ icon)
+ Q_PROPERTY(QSize contentsSize READ contentsSize)
+ Q_PROPERTY(QSize scrollOffset READ scrollOffset WRITE setScrollOffset)
private:
QWebFrame(QWebPage *parent, QWebFrameData *frameData);
QWebFrame(QWebFrame *parent, QWebFrameData *frameData);
@@ -73,57 +122,70 @@ public:
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;
+ void addToJavaScriptWindowObject(const QString &name, QObject *object);
+ QString toHtml() const;
+ QString toPlainText() const;
QString renderTreeDump() const;
QString title() const;
+ void setUrl(const QUrl &url);
QUrl url() const;
- QPixmap icon() const;
-
- QString name() const;
+ QIcon icon() const;
+
+ QString frameName() const;
QWebFrame *parentFrame() const;
QList<QWebFrame*> childFrames() const;
- Qt::ScrollBarPolicy verticalScrollBarPolicy() const;
- void setVerticalScrollBarPolicy(Qt::ScrollBarPolicy);
- Qt::ScrollBarPolicy horizontalScrollBarPolicy() const;
- void setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy);
+ Qt::ScrollBarPolicy scrollBarPolicy(Qt::Orientation orientation) const;
+ void setScrollBarPolicy(Qt::Orientation orientation, Qt::ScrollBarPolicy policy);
+
+ void setScrollBarValue(Qt::Orientation orientation, int value);
+ int scrollBarValue(Qt::Orientation orientation) const;
+ int scrollBarMinimum(Qt::Orientation orientation) const;
+ int scrollBarMaximum(Qt::Orientation orientation) const;
+
+ void scroll(int, int) const;
+ QSize scrollOffset() const;
+ void setScrollOffset(const QSize &offset) const;
void render(QPainter *painter, const QRegion &clip);
- void layout();
+ void render(QPainter *painter);
+
+ void setTextSizeMultiplier(qreal factor);
+ qreal textSizeMultiplier() const;
+
+ qreal zoomFactor() const;
+ void setZoomFactor(qreal factor);
QPoint pos() const;
QRect geometry() const;
+ QSize contentsSize() const;
+
+ QWebHitTestResult hitTestContent(const QPoint &pos) const;
+
+ virtual bool event(QEvent *);
public Q_SLOTS:
- QString evaluateJavaScript(const QString& scriptSource);
+ QVariant evaluateJavaScript(const QString& scriptSource);
+#ifndef QT_NO_PRINTER
+ void print(QPrinter *printer) const;
+#endif
Q_SIGNALS:
- void cleared();
- void loadDone(bool ok);
+ void javaScriptWindowObjectCleared();
+
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();
+ void initialLayoutCompleted();
+
+ void iconChanged();
+
+ void aboutToUpdateHistory(QWebHistoryItem* item);
private:
friend class QWebPage;
diff --git a/WebKit/qt/Api/qwebframe_p.h b/WebKit/qt/Api/qwebframe_p.h
index 136cf78..2b497e6 100644
--- a/WebKit/qt/Api/qwebframe_p.h
+++ b/WebKit/qt/Api/qwebframe_p.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2007 Trolltech ASA
+ Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
Copyright (C) 2007 Staikos Computing Services Inc.
This library is free software; you can redistribute it and/or
@@ -16,10 +16,8 @@
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
@@ -27,18 +25,17 @@
#include "qwebpage_p.h"
#include "EventHandler.h"
-#include "FrameView.h"
#include "KURL.h"
#include "PlatformString.h"
#include "wtf/RefPtr.h"
+#include "Frame.h"
namespace WebCore
{
class FrameLoaderClientQt;
- class Frame;
class FrameView;
class HTMLFrameOwnerElement;
- class PlatformScrollbar;
+ class Scrollbar;
}
class QWebPage;
@@ -61,30 +58,61 @@ class QWebFramePrivate
public:
QWebFramePrivate()
: q(0)
+ , horizontalScrollBarPolicy(Qt::ScrollBarAsNeeded)
+ , verticalScrollBarPolicy(Qt::ScrollBarAsNeeded)
, frameLoaderClient(0)
, frame(0)
- , frameView(0)
, page(0)
+ , allowsScrolling(true)
+ , marginWidth(-1)
+ , marginHeight(-1)
{}
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;
+ WebCore::Scrollbar* horizontalScrollBar() const;
+ WebCore::Scrollbar* verticalScrollBar() const;
+
+ Qt::ScrollBarPolicy horizontalScrollBarPolicy;
+ Qt::ScrollBarPolicy verticalScrollBarPolicy;
- inline QPoint pos() const
- { return frameView->frameGeometry().topLeft(); }
+ void updateBackground();
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;
+ WebCore::Frame *frame;
QWebPage *page;
+
+ bool allowsScrolling;
+ int marginWidth;
+ int marginHeight;
+};
+
+class QWebHitTestResultPrivate
+{
+public:
+ QWebHitTestResultPrivate() : isContentEditable(false), isContentSelected(false) {}
+ QWebHitTestResultPrivate(const WebCore::HitTestResult &hitTest);
+
+ QPoint pos;
+ QRect boundingRect;
+ QString title;
+ QString linkText;
+ QUrl linkUrl;
+ QString linkTitle;
+ QPointer<QWebFrame> linkTargetFrame;
+ QString alternateText;
+ QUrl imageUrl;
+ QPixmap pixmap;
+ bool isContentEditable;
+ bool isContentSelected;
+ QPointer<QWebFrame> frame;
+ RefPtr<WebCore::Node> innerNonSharedNode;
};
#endif
diff --git a/WebKit/qt/Api/qwebhistory.cpp b/WebKit/qt/Api/qwebhistory.cpp
index eab7d22..962aeb2 100644
--- a/WebKit/qt/Api/qwebhistory.cpp
+++ b/WebKit/qt/Api/qwebhistory.cpp
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2007 Trolltech ASA
+ Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -15,29 +15,44 @@
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 "qwebhistory.h"
#include "qwebhistory_p.h"
-#include "DeprecatedString.h"
#include "PlatformString.h"
#include "Image.h"
+#include "Page.h"
+#include "PageGroup.h"
#include <QSharedData>
/*!
\class QWebHistoryItem
+ \ingroup explicitly-shared
\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.
+ Each QWebHistoryItem instance represents an entry in the history stack of a Web page,
+ containing information about the page, its location, and when it was last visited.
+
+ The following table shows the properties of the page held by the history item, and
+ the functions used to access them.
+
+ \table
+ \header \o Function \o Description
+ \row \o title() \o The page title.
+ \row \o url() \o The location of the page.
+ \row \o originalUrl() \o The URL used to access the page.
+ \row \o lastVisited() \o The date and time of the user's last visit to the page.
+ \row \o icon() \o The icon associated with the page that was provided by the server.
+ \row \o userData() \o The user specific data that was stored with the history item.
+ \endtable
- \sa QWebPage::history() QWebHistory
+ \note QWebHistoryItem objects are value based and \l{explicitly shared}.
- QWebHistoryItem objects are value based and explicitly shared.
+ \sa QWebHistory, QWebPage::history(), QWebHistoryInterface
*/
/*!
@@ -58,58 +73,104 @@ QWebHistoryItem &QWebHistoryItem::operator=(const QWebHistoryItem &other)
}
/*!
- Destructs a history item.
+ Destroys the history item.
*/
QWebHistoryItem::~QWebHistoryItem()
{
}
/*!
- The original url associated with the history item.
+ Returns the original URL associated with the history item.
+
+ \sa url()
*/
QUrl QWebHistoryItem::originalUrl() const
{
- return QUrl(d->item->originalURL().string());
+ if (d->item)
+ return QUrl(d->item->originalURL().string());
+ return QUrl();
}
/*!
- The current url associated with the history item.
+ Returns the URL associated with the history item.
+
+ \sa originalUrl(), title(), lastVisited()
*/
-QUrl QWebHistoryItem::currentUrl() const
+QUrl QWebHistoryItem::url() const
{
- return QUrl(d->item->url().string());
+ if (d->item)
+ return QUrl(d->item->url().string());
+ return QUrl();
}
/*!
- The title of the page associated with the history item.
+ Returns the title of the page associated with the history item.
+
+ \sa icon(), url(), lastVisited()
*/
QString QWebHistoryItem::title() const
{
- return d->item->title();
+ if (d->item)
+ return d->item->title();
+ return QString();
}
/*!
- The time when the apge associated with the item was last visited.
+ Returns the date and time that the page associated with the item was last visited.
+
+ \sa title(), icon(), url()
*/
QDateTime QWebHistoryItem::lastVisited() const
{
//FIXME : this will be wrong unless we correctly set lastVisitedTime ourselves
- return QDateTime::fromTime_t((uint)d->item->lastVisitedTime());
+ if (d->item)
+ return QDateTime::fromTime_t((uint)d->item->lastVisitedTime());
+ return QDateTime();
}
/*!
- The icon associated with the history item.
+ Returns the icon associated with the history item.
+
+ \sa title(), url(), lastVisited()
+*/
+QIcon QWebHistoryItem::icon() const
+{
+ if (d->item)
+ return *d->item->icon()->nativeImageForCurrentFrame();
+ return QIcon();
+}
+
+/*!
+ \since 4.5
+ Returns the user specific data that was stored with the history item.
+
+ \sa setUserData()
*/
-QPixmap QWebHistoryItem::icon() const
+QVariant QWebHistoryItem::userData() const
{
- return *d->item->icon()->getPixmap();
+ if (d->item)
+ return d->item->userData();
+ return QVariant();
}
/*!
+ \since 4.5
+
+ Stores user specific data with the history item.
+
+ \sa userData()
+*/
+void QWebHistoryItem::setUserData(const QVariant& userData)
+{
+ if (d->item)
+ d->item->setUserData(userData);
+}
+
+/*!*
\internal
*/
QWebHistoryItem::QWebHistoryItem(QWebHistoryItemPrivate *priv)
@@ -118,12 +179,40 @@ QWebHistoryItem::QWebHistoryItem(QWebHistoryItemPrivate *priv)
}
/*!
+ \since 4.5
+ Returns whether this is a valid history item.
+*/
+bool QWebHistoryItem::isValid() const
+{
+ return d->item;
+}
+
+/*!
\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.
+ Each QWebPage instance contains a history of visited pages that can be accessed
+ by QWebPage::history(). QWebHistory represents this history and makes it possible
+ to navigate it.
+
+ The history uses the concept of a \e{current item}, dividing the pages visited
+ into those that can be visited by navigating \e back and \e forward using the
+ back() and forward() functions. The current item can be obtained by calling
+ currentItem(), and an arbitrary item in the history can be made the current
+ item by passing it to goToItem().
+
+ A list of items describing the pages that can be visited by going back can be
+ obtained by calling the backItems() function; similarly, items describing the
+ pages ahead of the current page can be obtained with the forwardItems() function.
+ The total list of items is obtained with the items() function.
+
+ Just as with containers, functions are available to examine the history in terms
+ of a list. Arbitrary items in the history can be obtained with itemAt(), the total
+ number of items is given by count(), and the history can be cleared with the
+ clear() function.
+
+ \sa QWebHistoryItem, QWebHistoryInterface, QWebPage
*/
@@ -139,19 +228,28 @@ QWebHistory::~QWebHistory()
/*!
Clears the history.
+
+ \sa count(), items()
*/
void QWebHistory::clear()
{
RefPtr<WebCore::HistoryItem> current = d->lst->currentItem();
int capacity = d->lst->capacity();
d->lst->setCapacity(0);
+
+ WebCore::Page* page = d->lst->page();
+ if (page && page->groupPtr())
+ page->groupPtr()->removeVisitedLinks();
+
d->lst->setCapacity(capacity);
d->lst->addItem(current.get());
d->lst->goToItem(current.get());
}
/*!
- returns a list of all items currently in the history.
+ Returns a list of all items currently in the history.
+
+ \sa count(), clear()
*/
QList<QWebHistoryItem> QWebHistory::items() const
{
@@ -166,8 +264,10 @@ QList<QWebHistoryItem> QWebHistory::items() const
}
/*!
- Returns the list of items that are in the backwards history.
+ Returns the list of items in the backwards history list.
At most \a maxItems entries are returned.
+
+ \sa forwardItems()
*/
QList<QWebHistoryItem> QWebHistory::backItems(int maxItems) const
{
@@ -183,8 +283,10 @@ QList<QWebHistoryItem> QWebHistory::backItems(int maxItems) const
}
/*!
- Returns the list of items that are in the forward history.
+ Returns the list of items in the forward history list.
At most \a maxItems entries are returned.
+
+ \sa backItems()
*/
QList<QWebHistoryItem> QWebHistory::forwardItems(int maxItems) const
{
@@ -200,7 +302,10 @@ QList<QWebHistoryItem> QWebHistory::forwardItems(int maxItems) const
}
/*!
- returns true if we have an item to go back to.
+ Returns true if there is an item preceding the current item in the history;
+ otherwise returns false.
+
+ \sa canGoForward()
*/
bool QWebHistory::canGoBack() const
{
@@ -208,7 +313,9 @@ bool QWebHistory::canGoBack() const
}
/*!
- returns true if we have an item to go forward to.
+ Returns true if we have an item to go forward to; otherwise returns false.
+
+ \sa canGoBack()
*/
bool QWebHistory::canGoForward() const
{
@@ -216,31 +323,45 @@ bool QWebHistory::canGoForward() const
}
/*!
- goes back one history item.
+ Set the current item to be the previous item in the history and goes to the
+ corresponding page; i.e., goes back one history item.
+
+ \sa forward(), goToItem()
*/
-void QWebHistory::goBack()
+void QWebHistory::back()
{
d->lst->goBack();
+ WebCore::Page* page = d->lst->page();
+ page->goToItem(currentItem().d->item, WebCore::FrameLoadTypeIndexedBackForward);
}
/*!
- goes forward one history item.
+ Sets the current item to be the next item in the history and goes to the
+ corresponding page; i.e., goes forward one history item.
+
+ \sa back(), goToItem()
*/
-void QWebHistory::goForward()
+void QWebHistory::forward()
{
- d->lst->goBack();
+ d->lst->goForward();
+ WebCore::Page* page = d->lst->page();
+ page->goToItem(currentItem().d->item, WebCore::FrameLoadTypeIndexedBackForward);
}
/*!
- goes to item \a item in the history.
+ Sets the current item to be the specified \a item in the history and goes to the page.
+
+ \sa back(), forward()
*/
void QWebHistory::goToItem(const QWebHistoryItem &item)
{
d->lst->goToItem(item.d->item);
+ WebCore::Page* page = d->lst->page();
+ page->goToItem(currentItem().d->item, WebCore::FrameLoadTypeIndexedBackForward);
}
/*!
- returns the item before the current item.
+ Returns the item before the current item in the history.
*/
QWebHistoryItem QWebHistory::backItem() const
{
@@ -250,7 +371,7 @@ QWebHistoryItem QWebHistory::backItem() const
}
/*!
- returns the current item.
+ Returns the current item in the history.
*/
QWebHistoryItem QWebHistory::currentItem() const
{
@@ -260,7 +381,7 @@ QWebHistoryItem QWebHistory::currentItem() const
}
/*!
- returns the item after the current item.
+ Returns the item after the current item in the history.
*/
QWebHistoryItem QWebHistory::forwardItem() const
{
@@ -270,9 +391,18 @@ QWebHistoryItem QWebHistory::forwardItem() const
}
/*!
- returns the item at index \a i.
+ \since 4.5
+ Returns the index of the current item in history.
+*/
+int QWebHistory::currentItemIndex() const
+{
+ return d->lst->backListCount();
+}
+
+/*!
+ Returns the item at index \a i in the history.
*/
-QWebHistoryItem QWebHistory::itemAtIndex(int i) const
+QWebHistoryItem QWebHistory::itemAt(int i) const
{
WebCore::HistoryItem *item = d->lst->itemAtIndex(i);
@@ -280,3 +410,33 @@ QWebHistoryItem QWebHistory::itemAtIndex(int i) const
return QWebHistoryItem(priv);
}
+/*!
+ Returns the total number of items in the history.
+*/
+int QWebHistory::count() const
+{
+ return d->lst->entries().size();
+}
+
+/*!
+ \since 4.5
+ Returns the maximum number of items in the history.
+
+ \sa setMaximumItemCount()
+*/
+int QWebHistory::maximumItemCount() const
+{
+ return d->lst->capacity();
+}
+
+/*!
+ \since 4.5
+ Sets the maximum number of items in the history.
+
+ \sa maximumItemCount()
+*/
+void QWebHistory::setMaximumItemCount(int count)
+{
+ d->lst->setCapacity(count);
+}
+
diff --git a/WebKit/qt/Api/qwebhistory.h b/WebKit/qt/Api/qwebhistory.h
index 6c8a4f4..2747c90 100644
--- a/WebKit/qt/Api/qwebhistory.h
+++ b/WebKit/qt/Api/qwebhistory.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2007 Trolltech ASA
+ Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -15,10 +15,8 @@
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
@@ -32,6 +30,10 @@
class QWebPage;
+namespace WebCore {
+ class FrameLoaderClientQt;
+};
+
class QWebHistoryItemPrivate;
class QWEBKIT_EXPORT QWebHistoryItem
{
@@ -41,17 +43,23 @@ public:
~QWebHistoryItem();
QUrl originalUrl() const;
- QUrl currentUrl() const;
+ QUrl url() const;
QString title() const;
QDateTime lastVisited() const;
- QPixmap icon() const;
+ QIcon icon() const;
+
+ QVariant userData() const;
+ void setUserData(const QVariant& userData);
+
+ bool isValid() const;
private:
QWebHistoryItem(QWebHistoryItemPrivate *priv);
friend class QWebHistory;
friend class QWebPage;
+ friend class WebCore::FrameLoaderClientQt;
QExplicitlySharedDataPointer<QWebHistoryItemPrivate> d;
};
@@ -68,14 +76,21 @@ public:
bool canGoBack() const;
bool canGoForward() const;
- void goBack();
- void goForward();
+ void back();
+ void forward();
void goToItem(const QWebHistoryItem &item);
QWebHistoryItem backItem() const;
QWebHistoryItem currentItem() const;
QWebHistoryItem forwardItem() const;
- QWebHistoryItem itemAtIndex(int i) const;
+ QWebHistoryItem itemAt(int i) const;
+
+ int currentItemIndex() const;
+
+ int count() const;
+
+ int maximumItemCount() const;
+ void setMaximumItemCount(int count);
private:
QWebHistory();
diff --git a/WebKit/qt/Api/qwebhistory_p.h b/WebKit/qt/Api/qwebhistory_p.h
index 5b56667..32e69fe 100644
--- a/WebKit/qt/Api/qwebhistory_p.h
+++ b/WebKit/qt/Api/qwebhistory_p.h
@@ -1,3 +1,22 @@
+/*
+ Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+
+ 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 QWEBHISTORY_P_H
#define QWEBHISTORY_P_H
@@ -9,14 +28,15 @@ class QWebHistoryItemPrivate : public QSharedData
public:
QWebHistoryItemPrivate(WebCore::HistoryItem *i)
{
- i->ref();
+ if (i)
+ i->ref();
item = i;
}
~QWebHistoryItemPrivate()
{
- item->deref();
+ if (item)
+ item->deref();
}
-
WebCore::HistoryItem *item;
};
diff --git a/WebKit/qt/Api/qwebhistoryinterface.cpp b/WebKit/qt/Api/qwebhistoryinterface.cpp
index d3e7efd..8e2d35c 100644
--- a/WebKit/qt/Api/qwebhistoryinterface.cpp
+++ b/WebKit/qt/Api/qwebhistoryinterface.cpp
@@ -1,30 +1,31 @@
/*
- Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net>
+ 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 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.
+ 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.
+ 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.
+ This class provides all functionality needed for tracking global history.
*/
+#include "config.h"
#include "qwebhistoryinterface.h"
#include <QCoreApplication>
-#include <wtf/Platform.h>
-#include "DeprecatedString.h"
+#include "PageGroup.h"
+#include "PlatformString.h"
// FIXME: It's not correct to just implement a WebCore function in WebKit!
// This needs to be fixed to match other platforms.
@@ -47,21 +48,29 @@ static bool gRoutineAdded;
static void gCleanupInterface()
{
- delete default_interface;
+ if (default_interface && default_interface->parent() == 0)
+ delete default_interface;
default_interface = 0;
}
/*!
- Sets a new default interface that will be used by all of WebKit
+ Sets a new default interface, \a defaultInterface, that will be used by all of WebKit
for managing history.
+
+ If an interface without a parent has already been set, the old interface will be deleted.
+ When the application exists QWebHistoryInterface will automatically delete the
+ \a defaultInterface if it does not have a parent.
*/
void QWebHistoryInterface::setDefaultInterface(QWebHistoryInterface *defaultInterface)
{
if (default_interface == defaultInterface)
return;
- if (default_interface)
+ if (default_interface && default_interface->parent() == 0)
delete default_interface;
+
default_interface = defaultInterface;
+ WebCore::PageGroup::removeAllVisitedLinks();
+
if (!gRoutineAdded) {
qAddPostRoutine(gCleanupInterface);
gRoutineAdded = true;
@@ -89,22 +98,32 @@ QWebHistoryInterface *QWebHistoryInterface::defaultInterface()
historyContains() is used to query whether this page has been
visited by the user.
*/
+
+/*!
+ Constructs a new QWebHistoryInterface with parent \a parent.
+*/
QWebHistoryInterface::QWebHistoryInterface(QObject *parent) : QObject(parent)
{
}
+/*!
+ Destructor. If this is currently the default interface it will be unset.
+*/
QWebHistoryInterface::~QWebHistoryInterface()
{
+ if (default_interface == this)
+ default_interface = 0;
}
/*!
- \fn bool QWebHistoryInterface::historyContains(const QString &url) const
+ \fn bool QWebHistoryInterface::historyContains(const QString &url) const = 0
- Called by the WebKit engine to query whether a certain url has been visited by the user already.
+ Called by the WebKit engine to query whether a certain \a url has been visited by the user already.
+ Returns true if the \a url is part of the history of visited links; otherwise returns false.
*/
/*!
- \fn void QWebHistoryInterface::addHistoryEntry(const QString &url) const
+ \fn void QWebHistoryInterface::addHistoryEntry(const QString &url) = 0
- Called by WebKit to add another url to the list of visited pages.
+ Called by WebKit to add another \a url to the list of visited pages.
*/
diff --git a/WebKit/qt/Api/qwebhistoryinterface.h b/WebKit/qt/Api/qwebhistoryinterface.h
index 87dc88c..670fca0 100644
--- a/WebKit/qt/Api/qwebhistoryinterface.h
+++ b/WebKit/qt/Api/qwebhistoryinterface.h
@@ -1,22 +1,22 @@
/*
- Copyright (C) 2007 Staikos Computing Services, Inc. <info@staikos.net>
+ 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 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.
+ 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.
+ 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.
+ This class provides all functionality needed for tracking global history.
*/
#ifndef QWEBHISTORYINTERFACE_H
diff --git a/WebKit/qt/Api/qwebkitglobal.h b/WebKit/qt/Api/qwebkitglobal.h
index 25fe0f9..2486fb6 100644
--- a/WebKit/qt/Api/qwebkitglobal.h
+++ b/WebKit/qt/Api/qwebkitglobal.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2007 Trolltech ASA
+ Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -15,14 +15,12 @@
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>
+#include <QtCore/qglobal.h>
#if defined(Q_OS_WIN)
# if defined(BUILD_WEBKIT)
@@ -36,4 +34,15 @@
#define QWEBKIT_EXPORT Q_DECL_EXPORT
#endif
+#if QT_VERSION < 0x040400
+ #ifndef QT_BEGIN_NAMESPACE
+ #define QT_BEGIN_NAMESPACE
+ #endif
+
+ #ifndef QT_END_NAMESPACE
+ #define QT_END_NAMESPACE
+ #endif
+#endif
+
+
#endif // QWEBKITGLOBAL_H
diff --git a/WebKit/qt/Api/qwebnetworkinterface.cpp b/WebKit/qt/Api/qwebnetworkinterface.cpp
index d68140d..8fba915 100644
--- a/WebKit/qt/Api/qwebnetworkinterface.cpp
+++ b/WebKit/qt/Api/qwebnetworkinterface.cpp
@@ -1,32 +1,29 @@
/*
- 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.
+ Copyright (C) 2006 Enrico Ros <enrico.ros@m31engineering.it>
+ Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ 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.
*/
+
#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>
@@ -135,8 +132,9 @@ void QWebNetworkRequestPrivate::init(const QString &method, const QUrl &url, con
// handle and perform a 'POST' request
if (method == "POST") {
- DeprecatedString pd = resourceRequest->httpBody()->flattenToString().deprecatedString();
- postData = QByteArray(pd.ascii(), pd.length());
+ Vector<char> data;
+ resourceRequest->httpBody()->flatten(data);
+ postData = QByteArray(data.data(), data.size());
httpHeader.setValue(QLatin1String("content-length"), QString::number(postData.size()));
}
}
@@ -360,7 +358,7 @@ void QWebNetworkJob::setErrorString(const QString& errorString)
*/
bool QWebNetworkJob::cancelled() const
{
- return !d->resourceHandle && !d->connector;
+ return !d->resourceHandle;
}
/*!
@@ -449,7 +447,6 @@ bool QWebNetworkManager::add(ResourceHandle *handle, QWebNetworkInterface *inter
handle->getInternal()->m_job = job;
job->d->resourceHandle = handle;
job->d->interface = interface;
- job->d->connector = 0;
job->d->request.init(handle->request());
@@ -478,7 +475,6 @@ void QWebNetworkManager::cancel(ResourceHandle *handle)
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;
}
@@ -495,7 +491,7 @@ void QWebNetworkManager::started(QWebNetworkJob *job)
client = job->d->resourceHandle->client();
if (!client)
return;
- } else if (!job->d->connector) {
+ } else {
return;
}
@@ -560,7 +556,17 @@ void QWebNetworkManager::started(QWebNetworkJob *job)
client->willSendRequest(job->d->resourceHandle, newRequest, response);
}
- job->d->request.httpHeader.setRequest(job->d->request.httpHeader.method(),
+ QString method;
+ if (statusCode == 302 || statusCode == 303) {
+ // this is standard-correct for 303 and practically-correct (no standard-correct) for 302
+ // also, it's required for Yahoo's login process for flickr.com which responds to a POST
+ // with a 302 which must be GET'ed
+ method = "GET";
+ job->d->request.httpHeader.setContentLength(0);
+ } else {
+ method = job->d->request.httpHeader.method();
+ }
+ job->d->request.httpHeader.setRequest(method,
newUrl.toString(QUrl::RemoveScheme|QUrl::RemoveAuthority));
job->d->request.setURL(newUrl);
job->d->redirected = true;
@@ -570,8 +576,6 @@ void QWebNetworkManager::started(QWebNetworkJob *job)
if (client)
client->didReceiveResponse(job->d->resourceHandle, response);
- if (job->d->connector)
- emit job->d->connector->started(job);
}
@@ -586,7 +590,7 @@ void QWebNetworkManager::data(QWebNetworkJob *job, const QByteArray &data)
client = job->d->resourceHandle->client();
if (!client)
return;
- } else if (!job->d->connector) {
+ } else {
return;
}
@@ -596,8 +600,6 @@ void QWebNetworkManager::data(QWebNetworkJob *job, const QByteArray &data)
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);
}
@@ -616,7 +618,7 @@ void QWebNetworkManager::finished(QWebNetworkJob *job, int errorCode)
client = job->d->resourceHandle->client();
if (!client)
return;
- } else if (!job->d->connector) {
+ } else {
job->deref();
return;
}
@@ -644,9 +646,6 @@ void QWebNetworkManager::finished(QWebNetworkJob *job, int errorCode)
}
}
- if (job->d->connector)
- emit job->d->connector->finished(job, errorCode);
-
DEBUG() << "receivedFinished done" << job->d->request.url;
job->deref();
diff --git a/WebKit/qt/Api/qwebnetworkinterface.h b/WebKit/qt/Api/qwebnetworkinterface.h
index fdc38d1..b603e37 100644
--- a/WebKit/qt/Api/qwebnetworkinterface.h
+++ b/WebKit/qt/Api/qwebnetworkinterface.h
@@ -1,24 +1,22 @@
/*
- 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.
+ Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+
+ 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 QWEBNETWORKINTERFACE_H
#define QWEBNETWORKINTERFACE_H
diff --git a/WebKit/qt/Api/qwebnetworkinterface_p.h b/WebKit/qt/Api/qwebnetworkinterface_p.h
index c712ae4..56e8617 100644
--- a/WebKit/qt/Api/qwebnetworkinterface_p.h
+++ b/WebKit/qt/Api/qwebnetworkinterface_p.h
@@ -1,24 +1,22 @@
/*
- 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.
+ Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+
+ 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 QWEBNETWORKINTERFACE_P_H
#define QWEBNETWORKINTERFACE_P_H
@@ -57,7 +55,6 @@ public:
, resourceHandle(0)
, redirected(false)
, interface(0)
- , connector(0)
, jobStatus(QWebNetworkJob::JobCreated)
{}
int ref;
@@ -69,7 +66,6 @@ public:
bool redirected;
QWebNetworkInterface *interface;
- QWebObjectPluginConnector *connector;
QWebNetworkJob::JobStatus jobStatus;
QString errorString;
};
diff --git a/WebKit/qt/Api/qwebobjectplugin.cpp b/WebKit/qt/Api/qwebobjectplugin.cpp
deleted file mode 100644
index b24d604..0000000
--- a/WebKit/qt/Api/qwebobjectplugin.cpp
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- 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
deleted file mode 100644
index 3c7caf7..0000000
--- a/WebKit/qt/Api/qwebobjectplugin.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- 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
deleted file mode 100644
index e20261f..0000000
--- a/WebKit/qt/Api/qwebobjectplugin_p.h
+++ /dev/null
@@ -1,76 +0,0 @@
-#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
deleted file mode 100644
index f53c164..0000000
--- a/WebKit/qt/Api/qwebobjectpluginconnector.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- 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
deleted file mode 100644
index 62251a3..0000000
--- a/WebKit/qt/Api/qwebobjectpluginconnector.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- 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
index 6e5e984..b7285d6 100644
--- a/WebKit/qt/Api/qwebpage.cpp
+++ b/WebKit/qt/Api/qwebpage.cpp
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2007 Trolltech ASA
+ Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
Copyright (C) 2007 Staikos Computing Services Inc.
Copyright (C) 2007 Apple Inc.
@@ -17,10 +17,8 @@
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"
@@ -32,25 +30,31 @@
#include "qwebsettings.h"
#include "Frame.h"
+#include "FrameTree.h"
#include "FrameLoaderClientQt.h"
+#include "FrameView.h"
#include "ChromeClientQt.h"
#include "ContextMenu.h"
#include "ContextMenuClientQt.h"
+#include "DocumentLoader.h"
#include "DragClientQt.h"
#include "DragController.h"
#include "DragData.h"
#include "EditorClientQt.h"
#include "Settings.h"
#include "Page.h"
+#include "PageGroup.h"
+#include "Pasteboard.h"
#include "FrameLoader.h"
#include "FrameLoadRequest.h"
#include "KURL.h"
+#include "Logging.h"
#include "Image.h"
#include "InspectorClientQt.h"
#include "InspectorController.h"
#include "FocusController.h"
#include "Editor.h"
-#include "PlatformScrollBar.h"
+#include "Scrollbar.h"
#include "PlatformKeyboardEvent.h"
#include "PlatformWheelEvent.h"
#include "ProgressTracker.h"
@@ -59,7 +63,11 @@
#include "HitTestResult.h"
#include "WindowFeatures.h"
#include "LocalizedStrings.h"
+#include "runtime/InitializeThreading.h"
+#include <QApplication>
+#include <QBasicTimer>
+#include <QBitArray>
#include <QDebug>
#include <QDragEnterEvent>
#include <QDragLeaveEvent>
@@ -68,11 +76,16 @@
#include <QFileDialog>
#include <QHttpRequestHeader>
#include <QInputDialog>
+#include <QLocale>
#include <QMessageBox>
#include <QNetworkProxy>
#include <QUndoStack>
#include <QUrl>
#include <QPainter>
+#include <QClipboard>
+#include <QSslSocket>
+#include <QStyle>
+#include <QSysInfo>
#if QT_VERSION >= 0x040400
#include <QNetworkAccessManager>
#include <QNetworkRequest>
@@ -82,6 +95,99 @@
using namespace WebCore;
+// Lookup table mapping QWebPage::WebActions to the associated Editor commands
+static const char* editorCommandWebActions[] =
+{
+ 0, // OpenLink,
+
+ 0, // OpenLinkInNewWindow,
+ 0, // OpenFrameInNewWindow,
+
+ 0, // DownloadLinkToDisk,
+ 0, // CopyLinkToClipboard,
+
+ 0, // OpenImageInNewWindow,
+ 0, // DownloadImageToDisk,
+ 0, // CopyImageToClipboard,
+
+ 0, // Back,
+ 0, // Forward,
+ 0, // Stop,
+ 0, // Reload,
+
+ "Cut", // Cut,
+ "Copy", // Copy,
+ "Paste", // Paste,
+
+ "Undo", // Undo,
+ "Redo", // Redo,
+ "MoveForward", // MoveToNextChar,
+ "MoveBackward", // MoveToPreviousChar,
+ "MoveWordForward", // MoveToNextWord,
+ "MoveWordBackward", // MoveToPreviousWord,
+ "MoveDown", // MoveToNextLine,
+ "MoveUp", // MoveToPreviousLine,
+ "MoveToBeginningOfLine", // MoveToStartOfLine,
+ "MoveToEndOfLine", // MoveToEndOfLine,
+ "MoveToBeginningOfParagraph", // MoveToStartOfBlock,
+ "MoveToEndOfParagraph", // MoveToEndOfBlock,
+ "MoveToBeginningOfDocument", // MoveToStartOfDocument,
+ "MoveToEndOfDocument", // MoveToEndOfDocument,
+ "MoveForwardAndModifySelection", // SelectNextChar,
+ "MoveBackwardAndModifySelection", // SelectPreviousChar,
+ "MoveWordForwardAndModifySelection", // SelectNextWord,
+ "MoveWordBackwardAndModifySelection", // SelectPreviousWord,
+ "MoveDownAndModifySelection", // SelectNextLine,
+ "MoveUpAndModifySelection", // SelectPreviousLine,
+ "MoveToBeginningOfLineAndModifySelection", // SelectStartOfLine,
+ "MoveToEndOfLineAndModifySelection", // SelectEndOfLine,
+ "MoveToBeginningOfParagraphAndModifySelection", // SelectStartOfBlock,
+ "MoveToEndOfParagraphAndModifySelection", // SelectEndOfBlock,
+ "MoveToBeginningOfDocumentAndModifySelection", //SelectStartOfDocument,
+ "MoveToEndOfDocumentAndModifySelection", // SelectEndOfDocument,
+ "DeleteWordBackward", // DeleteStartOfWord,
+ "DeleteWordForward", // DeleteEndOfWord,
+
+ 0, // SetTextDirectionDefault,
+ 0, // SetTextDirectionLeftToRight,
+ 0, // SetTextDirectionRightToLeft,
+
+ "ToggleBold", // ToggleBold,
+ "ToggleItalic", // ToggleItalic,
+ "ToggleUnderline", // ToggleUnderline,
+
+ 0, // InspectElement,
+
+ "InsertNewline", // InsertParagraphSeparator
+ "InsertLineBreak", // InsertLineSeparator
+
+ 0 // WebActionCount
+};
+
+// Lookup the appropriate editor command to use for WebAction \a action
+static const char* editorCommandForWebActions(QWebPage::WebAction action)
+{
+ if ((action > QWebPage::NoWebAction) && (action < int(sizeof(editorCommandWebActions) / sizeof(const char*))))
+ return editorCommandWebActions[action];
+
+ return 0;
+}
+
+#ifndef QT_NO_CURSOR
+SetCursorEvent::SetCursorEvent(const QCursor& cursor)
+ : QEvent(static_cast<QEvent::Type>(EventType))
+ , m_cursor(cursor)
+{}
+
+QCursor SetCursorEvent::cursor() const
+{
+ return m_cursor;
+}
+#endif
+
+// If you change this make sure to also adjust the docs for QWebPage::userAgentForUrl
+#define WEBKIT_VERSION "527+"
+
static inline DragOperation dropActionToDragOp(Qt::DropActions actions)
{
unsigned result = 0;
@@ -109,8 +215,12 @@ static inline Qt::DropAction dragOpToDropAction(unsigned actions)
QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
: q(qq)
, view(0)
- , modified(false)
+ , viewportSize(QSize(0,0))
{
+ WebCore::InitializeLoggingChannelsIfNecessary();
+ WebCore::PageGroup::setShouldTrackVisitedLinks(true);
+ JSC::initializeThreading();
+
chromeClient = new ChromeClientQt(q);
contextMenuClient = new ContextMenuClientQt();
editorClient = new EditorClientQt(q);
@@ -122,14 +232,23 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
settings = new QWebSettings(page->settings());
+#ifndef QT_NO_UNDOSTACK
undoStack = 0;
+#endif
mainFrame = 0;
#if QT_VERSION < 0x040400
networkInterface = 0;
#else
networkManager = 0;
#endif
+ pluginFactory = 0;
insideOpenCall = false;
+ forwardUnsupportedContent = false;
+ editable = false;
+ linkPolicy = QWebPage::DontDelegateLinks;
+#ifndef QT_NO_CONTEXTMENU
+ currentContextMenu = 0;
+#endif
history.d = new QWebHistoryPrivate(page->backForwardList());
memset(actions, 0, sizeof(actions));
@@ -137,29 +256,31 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
QWebPagePrivate::~QWebPagePrivate()
{
+#ifndef QT_NO_CONTEXTMENU
+ delete currentContextMenu;
+#endif
+#ifndef QT_NO_UNDOSTACK
delete undoStack;
+#endif
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)
+bool QWebPagePrivate::acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type)
{
if (insideOpenCall
&& frame == mainFrame)
- return QWebPage::AcceptNavigationRequest;
- return q->navigationRequested(frame, request, type);
+ return true;
+ return q->acceptNavigationRequest(frame, request, type);
}
#else
-QWebPage::NavigationRequestResponse QWebPagePrivate::navigationRequested(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
+bool QWebPagePrivate::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
{
if (insideOpenCall
&& frame == mainFrame)
- return QWebPage::AcceptNavigationRequest;
- return q->navigationRequested(frame, request, type);
+ return true;
+ return q->acceptNavigationRequest(frame, request, type);
}
#endif
@@ -172,7 +293,6 @@ void QWebPagePrivate::createMainFrame()
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);
}
@@ -190,8 +310,8 @@ static QWebPage::WebAction webActionForContextMenuAction(WebCore::ContextMenuAct
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::ContextMenuItemTagGoBack: return QWebPage::Back;
+ case WebCore::ContextMenuItemTagGoForward: return QWebPage::Forward;
case WebCore::ContextMenuItemTagStop: return QWebPage::Stop;
case WebCore::ContextMenuItemTagReload: return QWebPage::Reload;
case WebCore::ContextMenuItemTagCut: return QWebPage::Cut;
@@ -208,9 +328,11 @@ static QWebPage::WebAction webActionForContextMenuAction(WebCore::ContextMenuAct
return QWebPage::NoWebAction;
}
-QMenu *QWebPagePrivate::createContextMenu(const WebCore::ContextMenu *webcoreMenu, const QList<WebCore::ContextMenuItem> *items)
+#ifndef QT_NO_CONTEXTMENU
+QMenu *QWebPagePrivate::createContextMenu(const WebCore::ContextMenu *webcoreMenu,
+ const QList<WebCore::ContextMenuItem> *items, QBitArray *visitedWebActions)
{
- QMenu *menu = new QMenu;
+ QMenu* menu = new QMenu(view);
for (int i = 0; i < items->count(); ++i) {
const ContextMenuItem &item = items->at(i);
switch (item.type()) {
@@ -227,6 +349,7 @@ QMenu *QWebPagePrivate::createContextMenu(const WebCore::ContextMenu *webcoreMen
a->setCheckable(item.type() == WebCore::CheckableActionType);
menu->addAction(a);
+ visitedWebActions->setBit(action);
}
break;
}
@@ -234,8 +357,18 @@ QMenu *QWebPagePrivate::createContextMenu(const WebCore::ContextMenu *webcoreMen
menu->addSeparator();
break;
case WebCore::SubmenuType: {
- QMenu *subMenu = createContextMenu(webcoreMenu, item.platformSubMenu());
- if (!subMenu->actions().isEmpty()) {
+ QMenu *subMenu = createContextMenu(webcoreMenu, item.platformSubMenu(), visitedWebActions);
+
+ bool anyEnabledAction = false;
+
+ QList<QAction *> actions = subMenu->actions();
+ for (int i = 0; i < actions.count(); ++i) {
+ if (actions.at(i)->isVisible())
+ anyEnabledAction |= actions.at(i)->isEnabled();
+ }
+
+ // don't show sub-menus with just disabled actions
+ if (anyEnabledAction) {
subMenu->setTitle(item.title());
menu->addAction(subMenu->menuAction());
} else {
@@ -247,6 +380,7 @@ QMenu *QWebPagePrivate::createContextMenu(const WebCore::ContextMenu *webcoreMen
}
return menu;
}
+#endif // QT_NO_CONTEXTMENU
QWebFrame *QWebPagePrivate::frameAt(const QPoint &pos) const
{
@@ -284,12 +418,13 @@ void QWebPagePrivate::updateAction(QWebPage::WebAction action)
WebCore::Editor *editor = page->focusController()->focusedOrMainFrame()->editor();
bool enabled = a->isEnabled();
+ bool checked = a->isChecked();
switch (action) {
- case QWebPage::GoBack:
+ case QWebPage::Back:
enabled = loader->canGoBackOrForward(-1);
break;
- case QWebPage::GoForward:
+ case QWebPage::Forward:
enabled = loader->canGoBackOrForward(1);
break;
case QWebPage::Stop:
@@ -307,20 +442,34 @@ void QWebPagePrivate::updateAction(QWebPage::WebAction action)
case QWebPage::Paste:
enabled = editor->canPaste();
break;
+#ifndef QT_NO_UNDOSTACK
case QWebPage::Undo:
case QWebPage::Redo:
// those two are handled by QUndoStack
break;
+#endif // QT_NO_UNDOSTACK
+ case QWebPage::ToggleBold:
+ case QWebPage::ToggleItalic:
+ case QWebPage::ToggleUnderline:
+ enabled = editor->canEditRichly();
+ if (enabled)
+ checked = editor->command(editorCommandForWebActions(action)).state() != FalseTriState;
+ else
+ checked = false;
+ break;
default: break;
}
a->setEnabled(enabled);
+
+ if (a->isCheckable())
+ a->setChecked(checked);
}
void QWebPagePrivate::updateNavigationActions()
{
- updateAction(QWebPage::GoBack);
- updateAction(QWebPage::GoForward);
+ updateAction(QWebPage::Back);
+ updateAction(QWebPage::Forward);
updateAction(QWebPage::Stop);
updateAction(QWebPage::Reload);
}
@@ -330,214 +479,230 @@ void QWebPagePrivate::updateEditorActions()
updateAction(QWebPage::Cut);
updateAction(QWebPage::Copy);
updateAction(QWebPage::Paste);
+ updateAction(QWebPage::ToggleBold);
+ updateAction(QWebPage::ToggleItalic);
+ updateAction(QWebPage::ToggleUnderline);
+}
+
+void QWebPagePrivate::timerEvent(QTimerEvent *ev)
+{
+ int timerId = ev->timerId();
+ if (timerId == tripleClickTimer.timerId())
+ tripleClickTimer.stop();
+ else
+ q->QObject::timerEvent(ev);
}
void QWebPagePrivate::mouseMoveEvent(QMouseEvent *ev)
{
- QWebFramePrivate::core(mainFrame)->eventHandler()->mouseMoved(PlatformMouseEvent(ev, 0));
+ WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
+ if (!frame->view())
+ return;
+
+ bool accepted = frame->eventHandler()->mouseMoved(PlatformMouseEvent(ev, 0));
+ ev->setAccepted(accepted);
}
void QWebPagePrivate::mousePressEvent(QMouseEvent *ev)
{
- QWebFramePrivate::core(mainFrame)->eventHandler()->handleMousePressEvent(PlatformMouseEvent(ev, 1));
+ WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
+ if (!frame->view())
+ return;
+
+ if (tripleClickTimer.isActive()
+ && (ev->pos() - tripleClick).manhattanLength()
+ < QApplication::startDragDistance()) {
+ mouseTripleClickEvent(ev);
+ return;
+ }
+
+ bool accepted = frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(ev, 1));
+ ev->setAccepted(accepted);
}
void QWebPagePrivate::mouseDoubleClickEvent(QMouseEvent *ev)
{
- QWebFramePrivate::core(mainFrame)->eventHandler()->handleMousePressEvent(PlatformMouseEvent(ev, 2));
+ WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
+ if (!frame->view())
+ return;
+
+ bool accepted = frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(ev, 2));
+ ev->setAccepted(accepted);
+
+ tripleClickTimer.start(QApplication::doubleClickInterval(), q);
+ tripleClick = ev->pos();
}
-void QWebPagePrivate::mouseReleaseEvent(QMouseEvent *ev)
+void QWebPagePrivate::mouseTripleClickEvent(QMouseEvent *ev)
{
- QWebFramePrivate::core(mainFrame)->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(ev, 0));
+ WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
+ if (!frame->view())
+ return;
+
+ bool accepted = frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(ev, 3));
+ ev->setAccepted(accepted);
}
-void QWebPagePrivate::contextMenuEvent(QContextMenuEvent *ev)
+void QWebPagePrivate::mouseReleaseEvent(QMouseEvent *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)
+ WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
+ if (!frame->view())
return;
- QWebPageContext oldContext = currentContext;
- currentContext = QWebPageContext(menu->hitTestResult());
+ bool accepted = frame->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(ev, 0));
+ ev->setAccepted(accepted);
+
+#ifndef QT_NO_CLIPBOARD
+ if (QApplication::clipboard()->supportsSelection()) {
+ bool oldSelectionMode = Pasteboard::generalPasteboard()->isSelectionMode();
+ Pasteboard::generalPasteboard()->setSelectionMode(true);
+ WebCore::Frame* focusFrame = page->focusController()->focusedOrMainFrame();
+ if (ev->button() == Qt::LeftButton) {
+ if(focusFrame && (focusFrame->editor()->canCopy() || focusFrame->editor()->canDHTMLCopy())) {
+ focusFrame->editor()->copy();
+ ev->setAccepted(true);
+ }
+ } else if (ev->button() == Qt::MidButton) {
+ if(focusFrame && (focusFrame->editor()->canPaste() || focusFrame->editor()->canDHTMLPaste())) {
+ focusFrame->editor()->paste();
+ ev->setAccepted(true);
+ }
+ }
+ Pasteboard::generalPasteboard()->setSelectionMode(oldSelectionMode);
+ }
+#endif
+}
- const QList<ContextMenuItem> *items = menu->platformDescription();
- QMenu *qmenu = createContextMenu(menu, items);
- if (qmenu) {
- qmenu->exec(ev->globalPos());
- delete qmenu;
+#ifndef QT_NO_CONTEXTMENU
+void QWebPagePrivate::contextMenuEvent(QContextMenuEvent *ev)
+{
+ QMenu *menu = q->createStandardContextMenu();
+ if (menu) {
+ menu->exec(ev->globalPos());
+ delete menu;
}
- currentContext = oldContext;
+}
+#endif // QT_NO_CONTEXTMENU
+
+/*!
+ \since 4.5
+ This function creates the standard context menu which is shown when
+ the user clicks on the web page with the right mouse button. It is
+ called from the default contextMenuEvent() handler. The popup menu's
+ ownership is transferred to the caller.
+ */
+QMenu *QWebPage::createStandardContextMenu()
+{
+#ifndef QT_NO_CONTEXTMENU
+ QMenu *menu = d->currentContextMenu;
+ d->currentContextMenu = 0;
+ return menu;
+#else
+ return 0;
+#endif
}
+#ifndef QT_NO_WHEELEVENT
void QWebPagePrivate::wheelEvent(QWheelEvent *ev)
{
+ WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
+ if (!frame->view())
+ return;
+
WebCore::PlatformWheelEvent pev(ev);
- bool accepted = QWebFramePrivate::core(mainFrame)->eventHandler()->handleWheelEvent(pev);
+ bool accepted = frame->eventHandler()->handleWheelEvent(pev);
ev->setAccepted(accepted);
}
+#endif // QT_NO_WHEELEVENT
+
+#ifndef QT_NO_SHORTCUT
+static QWebPage::WebAction editorActionForKeyEvent(QKeyEvent* event)
+{
+ static struct {
+ QKeySequence::StandardKey standardKey;
+ QWebPage::WebAction action;
+ } editorActions[] = {
+ { QKeySequence::Cut, QWebPage::Cut },
+ { QKeySequence::Copy, QWebPage::Copy },
+ { QKeySequence::Paste, QWebPage::Paste },
+ { QKeySequence::Undo, QWebPage::Undo },
+ { QKeySequence::Redo, QWebPage::Redo },
+ { QKeySequence::MoveToNextChar, QWebPage::MoveToNextChar },
+ { QKeySequence::MoveToPreviousChar, QWebPage::MoveToPreviousChar },
+ { QKeySequence::MoveToNextWord, QWebPage::MoveToNextWord },
+ { QKeySequence::MoveToPreviousWord, QWebPage::MoveToPreviousWord },
+ { QKeySequence::MoveToNextLine, QWebPage::MoveToNextLine },
+ { QKeySequence::MoveToPreviousLine, QWebPage::MoveToPreviousLine },
+ { QKeySequence::MoveToStartOfLine, QWebPage::MoveToStartOfLine },
+ { QKeySequence::MoveToEndOfLine, QWebPage::MoveToEndOfLine },
+ { QKeySequence::MoveToStartOfBlock, QWebPage::MoveToStartOfBlock },
+ { QKeySequence::MoveToEndOfBlock, QWebPage::MoveToEndOfBlock },
+ { QKeySequence::MoveToStartOfDocument, QWebPage::MoveToStartOfDocument },
+ { QKeySequence::MoveToEndOfDocument, QWebPage::MoveToEndOfDocument },
+ { QKeySequence::SelectNextChar, QWebPage::SelectNextChar },
+ { QKeySequence::SelectPreviousChar, QWebPage::SelectPreviousChar },
+ { QKeySequence::SelectNextWord, QWebPage::SelectNextWord },
+ { QKeySequence::SelectPreviousWord, QWebPage::SelectPreviousWord },
+ { QKeySequence::SelectNextLine, QWebPage::SelectNextLine },
+ { QKeySequence::SelectPreviousLine, QWebPage::SelectPreviousLine },
+ { QKeySequence::SelectStartOfLine, QWebPage::SelectStartOfLine },
+ { QKeySequence::SelectEndOfLine, QWebPage::SelectEndOfLine },
+ { QKeySequence::SelectStartOfBlock, QWebPage::SelectStartOfBlock },
+ { QKeySequence::SelectEndOfBlock, QWebPage::SelectEndOfBlock },
+ { QKeySequence::SelectStartOfDocument, QWebPage::SelectStartOfDocument },
+ { QKeySequence::SelectEndOfDocument, QWebPage::SelectEndOfDocument },
+ { QKeySequence::DeleteStartOfWord, QWebPage::DeleteStartOfWord },
+ { QKeySequence::DeleteEndOfWord, QWebPage::DeleteEndOfWord },
+#if QT_VERSION >= 0x040500
+ { QKeySequence::InsertParagraphSeparator, QWebPage::InsertParagraphSeparator },
+ { QKeySequence::InsertLineSeparator, QWebPage::InsertLineSeparator },
+#endif
+ { QKeySequence::UnknownKey, QWebPage::NoWebAction }
+ };
+
+ for (int i = 0; editorActions[i].standardKey != QKeySequence::UnknownKey; ++i)
+ if (event == editorActions[i].standardKey)
+ return editorActions[i].action;
+
+ return QWebPage::NoWebAction;
+}
+#endif // QT_NO_SHORTCUT
void QWebPagePrivate::keyPressEvent(QKeyEvent *ev)
{
bool handled = false;
- WebCore::Frame *frame = page->focusController()->focusedOrMainFrame();
- WebCore::Editor *editor = frame->editor();
+ WebCore::Frame* frame = page->focusController()->focusedOrMainFrame();
+ WebCore::Editor* editor = frame->editor();
+#ifndef QT_NO_SHORTCUT
if (editor->canEdit()) {
- if (ev == QKeySequence::Cut) {
- q->triggerAction(QWebPage::Cut);
+ QWebPage::WebAction action = editorActionForKeyEvent(ev);
+ if (action != QWebPage::NoWebAction) {
+ q->triggerAction(action);
handled = true;
- } else if (ev == QKeySequence::Copy) {
+ }
+ } 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) {
}
}
+#endif // QT_NO_SHORTCUT
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 {
+ if (!handleScrolling(ev)) {
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);
+ q->triggerAction(QWebPage::Forward);
else
- q->triggerAction(QWebPage::GoBack);
+ q->triggerAction(QWebPage::Back);
default:
handled = false;
break;
@@ -562,14 +727,33 @@ void QWebPagePrivate::keyReleaseEvent(QKeyEvent *ev)
void QWebPagePrivate::focusInEvent(QFocusEvent *ev)
{
- if (ev->reason() != Qt::PopupFocusReason)
- page->focusController()->setFocusedFrame(QWebFramePrivate::core(mainFrame));
+ if (ev->reason() == Qt::PopupFocusReason)
+ return;
+
+ FocusController *focusController = page->focusController();
+ Frame *frame = focusController->focusedFrame();
+ focusController->setActive(true);
+ if (frame) {
+ frame->selection()->setFocused(true);
+ } else {
+ focusController->setFocusedFrame(QWebFramePrivate::core(mainFrame));
+ }
}
void QWebPagePrivate::focusOutEvent(QFocusEvent *ev)
{
- if (ev->reason() != Qt::PopupFocusReason)
- page->focusController()->setFocusedFrame(0);
+ if (ev->reason() == Qt::PopupFocusReason)
+ return;
+
+ // only set the focused frame inactive so that we stop painting the caret
+ // and the focus frame. But don't tell the focus controller so that upon
+ // focusInEvent() we can re-activate the frame.
+ FocusController *focusController = page->focusController();
+ focusController->setActive(false);
+ Frame *frame = focusController->focusedFrame();
+ if (frame) {
+ frame->selection()->setFocused(false);
+ }
}
void QWebPagePrivate::dragEnterEvent(QDragEnterEvent *ev)
@@ -579,7 +763,8 @@ void QWebPagePrivate::dragEnterEvent(QDragEnterEvent *ev)
dropActionToDragOp(ev->possibleActions()));
Qt::DropAction action = dragOpToDropAction(page->dragController()->dragEntered(&dragData));
ev->setDropAction(action);
- ev->accept();
+ if (action != Qt::IgnoreAction)
+ ev->accept();
#endif
}
@@ -599,7 +784,8 @@ void QWebPagePrivate::dragMoveEvent(QDragMoveEvent *ev)
dropActionToDragOp(ev->possibleActions()));
Qt::DropAction action = dragOpToDropAction(page->dragController()->dragUpdated(&dragData));
ev->setDropAction(action);
- ev->accept();
+ if (action != Qt::IgnoreAction)
+ ev->accept();
#endif
}
@@ -609,11 +795,244 @@ void QWebPagePrivate::dropEvent(QDropEvent *ev)
DragData dragData(ev->mimeData(), ev->pos(), QCursor::pos(),
dropActionToDragOp(ev->possibleActions()));
Qt::DropAction action = dragOpToDropAction(page->dragController()->performDrag(&dragData));
+ if (action != Qt::IgnoreAction)
+ ev->accept();
+#endif
+}
+
+void QWebPagePrivate::leaveEvent(QEvent *ev)
+{
+ // Fake a mouse move event just outside of the widget, since all
+ // the interesting mouse-out behavior like invalidating scrollbars
+ // is handled by the WebKit event handler's mouseMoved function.
+ QMouseEvent fakeEvent(QEvent::MouseMove, QCursor::pos(), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
+ mouseMoveEvent(&fakeEvent);
+}
+
+/*!
+ \property QWebPage::palette
+ \brief the page's palette
+
+ The background brush of the palette is used to draw the background of the main frame.
+
+ By default, this property contains the application's default palette.
+*/
+void QWebPage::setPalette(const QPalette &pal)
+{
+ d->palette = pal;
+ if (d->mainFrame)
+ d->mainFrame->d->updateBackground();
+}
+
+QPalette QWebPage::palette() const
+{
+ return d->palette;
+}
+
+void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev)
+{
+ WebCore::Frame *frame = page->focusController()->focusedOrMainFrame();
+ WebCore::Editor *editor = frame->editor();
+
+ if (!editor->canEdit()) {
+ ev->ignore();
+ return;
+ }
+
+ if (!ev->preeditString().isEmpty()) {
+ QString preedit = ev->preeditString();
+ // ### FIXME: use the provided QTextCharFormat (use color at least)
+ Vector<CompositionUnderline> underlines;
+ underlines.append(CompositionUnderline(0, preedit.length(), Color(0,0,0), false));
+ editor->setComposition(preedit, underlines, preedit.length(), 0);
+ } else if (!ev->commitString().isEmpty()) {
+ editor->confirmComposition(ev->commitString());
+ }
ev->accept();
+}
+
+void QWebPagePrivate::shortcutOverrideEvent(QKeyEvent* event)
+{
+ WebCore::Frame* frame = page->focusController()->focusedOrMainFrame();
+ WebCore::Editor* editor = frame->editor();
+ if (editor->canEdit()) {
+ if (event->modifiers() == Qt::NoModifier
+ || event->modifiers() == Qt::ShiftModifier
+ || event->modifiers() == Qt::KeypadModifier) {
+ if (event->key() < Qt::Key_Escape) {
+ event->accept();
+ } else {
+ switch (event->key()) {
+ case Qt::Key_Return:
+ case Qt::Key_Enter:
+ case Qt::Key_Delete:
+ case Qt::Key_Home:
+ case Qt::Key_End:
+ case Qt::Key_Backspace:
+ case Qt::Key_Left:
+ case Qt::Key_Right:
+ case Qt::Key_Up:
+ case Qt::Key_Down:
+ case Qt::Key_Tab:
+ event->accept();
+ default:
+ break;
+ }
+ }
+ }
+#ifndef QT_NO_SHORTCUT
+ else if (editorActionForKeyEvent(event) != QWebPage::NoWebAction) {
+ event->accept();
+ }
#endif
+ }
+}
+
+bool QWebPagePrivate::handleScrolling(QKeyEvent *ev)
+{
+ ScrollDirection direction;
+ ScrollGranularity granularity;
+
+#ifndef QT_NO_SHORTCUT
+ if (ev == QKeySequence::MoveToNextPage
+ || (ev->key() == Qt::Key_Space && !(ev->modifiers() & Qt::ShiftModifier))) {
+ granularity = ScrollByPage;
+ direction = ScrollDown;
+ } else if (ev == QKeySequence::MoveToPreviousPage
+ || (ev->key() == Qt::Key_Space) && (ev->modifiers() & Qt::ShiftModifier)) {
+ granularity = ScrollByPage;
+ direction = ScrollUp;
+ } else
+#endif // QT_NO_SHORTCUT
+ if (ev->key() == Qt::Key_Up && ev->modifiers() & Qt::ControlModifier
+ || ev->key() == Qt::Key_Home) {
+ granularity = ScrollByDocument;
+ direction = ScrollUp;
+ } else if (ev->key() == Qt::Key_Down && ev->modifiers() & Qt::ControlModifier
+ || ev->key() == Qt::Key_End) {
+ granularity = ScrollByDocument;
+ direction = ScrollDown;
+ } else {
+ switch (ev->key()) {
+ case Qt::Key_Up:
+ granularity = ScrollByLine;
+ direction = ScrollUp;
+ break;
+ case Qt::Key_Down:
+ granularity = ScrollByLine;
+ direction = ScrollDown;
+ break;
+ case Qt::Key_Left:
+ granularity = ScrollByLine;
+ direction = ScrollLeft;
+ break;
+ case Qt::Key_Right:
+ granularity = ScrollByLine;
+ direction = ScrollRight;
+ break;
+ default:
+ return false;
+ }
+ }
+
+ if (!mainFrame->d->frame->eventHandler()->scrollOverflow(direction, granularity))
+ mainFrame->d->frame->view()->scroll(direction, granularity);
+
+ return true;
}
/*!
+ This method is used by the input method to query a set of properties of the page
+ to be able to support complex input method operations as support for surrounding
+ text and reconversions.
+
+ \a property specifies which property is queried.
+
+ \sa QWidget::inputMethodEvent(), QInputMethodEvent, QInputContext
+*/
+QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const
+{
+ switch(property) {
+ case Qt::ImMicroFocus: {
+ Frame *frame = d->page->focusController()->focusedFrame();
+ if (frame) {
+ return QVariant(frame->selection()->caretRect());
+ }
+ return QVariant();
+ }
+ case Qt::ImFont: {
+ QWebView *webView = qobject_cast<QWebView *>(d->view);
+ if (webView)
+ return QVariant(webView->font());
+ return QVariant();
+ }
+ case Qt::ImCursorPosition: {
+ Frame *frame = d->page->focusController()->focusedFrame();
+ if (frame) {
+ Selection selection = frame->selection()->selection();
+ if (selection.isCaret()) {
+ return QVariant(selection.start().offset());
+ }
+ }
+ return QVariant();
+ }
+ case Qt::ImSurroundingText: {
+ Frame *frame = d->page->focusController()->focusedFrame();
+ if (frame) {
+ Document *document = frame->document();
+ if (document->focusedNode()) {
+ return QVariant(document->focusedNode()->nodeValue());
+ }
+ }
+ return QVariant();
+ }
+ case Qt::ImCurrentSelection:
+ return QVariant(selectedText());
+ default:
+ return QVariant();
+ }
+}
+
+/*!
+ \enum QWebPage::FindFlag
+
+ This enum describes the options available to QWebPage's findText() function. The options
+ can be OR-ed together from the following list:
+
+ \value FindBackward Searches backwards instead of forwards.
+ \value FindCaseSensitively By default findText() works case insensitive. Specifying this option
+ changes the behaviour to a case sensitive find operation.
+ \value FindWrapsAroundDocument Makes findText() restart from the beginning of the document if the end
+ was reached and the text was not found.
+*/
+
+/*!
+ \enum QWebPage::LinkDelegationPolicy
+
+ This enum defines the delegation policies a webpage can have when activating links and emitting
+ the linkClicked() signal.
+
+ \value DontDelegateLinks No links are delegated. Instead, QWebPage tries to handle them all.
+ \value DelegateExternalLinks When activating links that point to documents not stored on the
+ local filesystem or an equivalent - such as the Qt resource system - then linkClicked() is emitted.
+ \value DelegateAllLinks Whenever a link is activated the linkClicked() signal is emitted.
+*/
+
+/*!
+ \enum QWebPage::NavigationType
+
+ This enum describes the types of navigation available when browsing through hyperlinked
+ documents.
+
+ \value NavigationTypeLinkClicked The user clicked on a link or pressed return on a focused link.
+ \value NavigationTypeFormSubmitted The user activated a submit button for an HTML form.
+ \value NavigationTypeBackOrForward Navigation to a previously shown document in the back or forward history is requested.
+ \value NavigationTypeReload The user activated the reload action.
+ \value NavigationTypeFormResubmitted An HTML form was submitted a second time.
+ \value NavigationTypeOther A navigation to another document using a method not listed above.
+*/
+
+/*!
\enum QWebPage::WebAction
\value NoWebAction No action is triggered.
@@ -625,8 +1044,8 @@ void QWebPagePrivate::dropEvent(QDropEvent *ev)
\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 Back Navigate back in the history of navigated links.
+ \value Forward 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.
@@ -667,18 +1086,71 @@ void QWebPagePrivate::dropEvent(QDropEvent *ev)
\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.
+ \value InsertParagraphSeparator Insert a new paragraph.
+ \value InsertLineSeparator Insert a new line.
\omitvalue WebActionCount
*/
/*!
+ \enum QWebPage::WebWindowType
+
+ \value WebBrowserWindow The window is a regular web browser window.
+ \value WebModalDialog The window acts as modal dialog.
+*/
+
+/*!
\class QWebPage
\since 4.4
- \brief The QWebPage class provides a widget that is used to view and edit web documents.
+ \brief The QWebPage class provides an object 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.
+ of navigated links and actions. This class can be used, together with QWebFrame,
+ to provide functionality like QWebView in a widget-less environment.
+
+ QWebPage's API is very similar to QWebView, as you are still provided with
+ common functions like action() (known as \l{QWebView::}{pageAction()} in
+ QWebView), triggerAction(), findText() and settings(). More QWebView-like
+ functions can be found in the main frame of QWebPage, obtained via
+ QWebPage::mainFrame(). For example, the load(), setUrl() and setHtml()
+ unctions for QWebPage can be accessed using QWebFrame.
+
+ The loadStarted() signal is emitted when the page begins to load.The
+ loadProgress() signal, on the other hand, is emitted whenever an element
+ of the web page completes loading, such as an embedded image, a script,
+ etc. Finally, the loadFinished() signal is emitted when the page has
+ loaded completely. Its argument, either true or false, indicates whether
+ or not the load operation succeeded.
+
+ \section1 Using QWebPage in a Widget-less Environment
+
+ Before you begin painting a QWebPage object, you need to set the size of
+ the viewport by calling setViewportSize(). Then, you invoke the main
+ frame's render function (QWebFrame::render()). An example of this
+ is shown in the code snippet below.
+
+ Suppose we have a \c Thumbnail class as follows:
+
+ \snippet doc/src/snippets/webkit/webpage/main.cpp 0
+
+ The \c Thumbnail's constructor takes in a \a url. We connect our QWebPage
+ object's \l{QWebPage::}{loadFinished()} signal to our private slot,
+ \c render().
+
+ \snippet doc/src/snippets/webkit/webpage/main.cpp 1
+
+ The \c render() function shows how we can paint a thumbnail using a
+ QWebPage object.
+
+ \snippet doc/src/snippets/webkit/webpage/main.cpp 2
+
+ We begin by setting the \l{QWebPage::viewportSize()}{viewportSize} and
+ then we instantiate a QImage object, \c image, with the same size as our
+ \l{QWebPage::viewportSize()}{viewportSize}. This image is then sent
+ as a parameter to \c painter. Next, we render the contents of the main
+ frame and its subframes into \c painter. Finally, we save the scaled image.
+
+ \sa QWebFrame
*/
/*!
@@ -690,11 +1162,11 @@ QWebPage::QWebPage(QObject *parent)
{
setView(qobject_cast<QWidget *>(parent));
- connect(this, SIGNAL(loadProgressChanged(int)), this, SLOT(_q_onLoadProgressChanged(int)));
+ connect(this, SIGNAL(loadProgress(int)), this, SLOT(_q_onLoadProgressChanged(int)));
}
/*!
- Destructor.
+ Destroys the web page.
*/
QWebPage::~QWebPage()
{
@@ -709,6 +1181,8 @@ QWebPage::~QWebPage()
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.
+
+ \sa currentFrame()
*/
QWebFrame *QWebPage::mainFrame() const
{
@@ -718,6 +1192,8 @@ QWebFrame *QWebPage::mainFrame() const
/*!
Returns the frame currently active.
+
+ \sa mainFrame(), frameCreated()
*/
QWebFrame *QWebPage::currentFrame() const
{
@@ -726,7 +1202,6 @@ QWebFrame *QWebPage::currentFrame() const
/*!
Returns a pointer to the view's history of navigated web pages.
-
*/
QWebHistory *QWebPage::history() const
{
@@ -754,32 +1229,56 @@ 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.
+ This function is called whenever a JavaScript program tries to print a \a message to the web browser's console.
+
+ For example in case of evaluation errors the source URL may be provided in \a sourceID as well as the \a lineNumber.
+
+ The default implementation prints nothing.
*/
-void QWebPage::javaScriptConsoleMessage(const QString& message, unsigned int lineNumber, const QString& sourceID)
+void QWebPage::javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID)
{
+ Q_UNUSED(message)
+ Q_UNUSED(lineNumber)
+ Q_UNUSED(sourceID)
}
/*!
- This function is called whenever a JavaScript program calls the alert() function.
+ This function is called whenever a JavaScript program running inside \a frame calls the alert() function with
+ the message \a msg.
+
+ The default implementation shows the message, \a msg, with QMessageBox::information.
*/
void QWebPage::javaScriptAlert(QWebFrame *frame, const QString& msg)
{
+#ifndef QT_NO_MESSAGEBOX
QMessageBox::information(d->view, mainFrame()->title(), msg, QMessageBox::Ok);
+#endif
}
/*!
- This function is called whenever a JavaScript program calls the confirm() function.
+ This function is called whenever a JavaScript program running inside \a frame calls the confirm() function
+ with the message, \a msg. Returns true if the user confirms the message; otherwise returns false.
+
+ The default implementation executes the query using QMessageBox::information with QMessageBox::Yes and QMessageBox::No buttons.
*/
bool QWebPage::javaScriptConfirm(QWebFrame *frame, const QString& msg)
{
- return 0 == QMessageBox::information(d->view, mainFrame()->title(), msg, QMessageBox::Yes, QMessageBox::No);
+#ifdef QT_NO_MESSAGEBOX
+ return true;
+#else
+ return QMessageBox::Yes == QMessageBox::information(d->view, mainFrame()->title(), msg, QMessageBox::Yes, QMessageBox::No);
+#endif
}
/*!
- This function is called whenever a JavaScript program tries to prompt the user of input.
+ This function is called whenever a JavaScript program running inside \a frame tries to prompt the user for input.
+ The program may provide an optional message, \a msg, as well as a default value for the input in \a defaultValue.
+
+ If the prompt was cancelled by the user the implementation should return false; otherwise the
+ result should be written to \a result and true should be returned.
+
+ The default implementation uses QInputDialog::getText.
*/
bool QWebPage::javaScriptPrompt(QWebFrame *frame, const QString& msg, const QString& defaultValue, QString* result)
{
@@ -794,14 +1293,21 @@ bool QWebPage::javaScriptPrompt(QWebFrame *frame, const QString& msg, const QStr
}
/*!
- 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.
+ This function is called whenever WebKit wants to create a new window of the given \a type, for
+ example when a JavaScript program requests to open a document in a new window.
+
+ If the new window can be created, the new window's QWebPage is returned; otherwise a null pointer is returned.
+
+ If the view associated with the web page is a QWebView object, then the default implementation forwards
+ the request to QWebView's createWindow() function; otherwise it returns a null pointer.
+
+ \sa acceptNavigationRequest()
*/
-QWebPage *QWebPage::createWindow()
+QWebPage *QWebPage::createWindow(WebWindowType type)
{
QWebView *webView = qobject_cast<QWebView *>(d->view);
if (webView) {
- QWebView *newView = webView->createWindow();
+ QWebView *newView = webView->createWindow(type);
if (newView)
return newView->page();
}
@@ -809,14 +1315,6 @@ QWebPage *QWebPage::createWindow()
}
/*!
- 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.
@@ -853,49 +1351,59 @@ static void openNewWindow(const QUrl& url, WebCore::Frame* frame)
If \a action is a checkable action then \a checked specified whether the action
is toggled or not.
+
+ \sa action()
*/
void QWebPage::triggerAction(WebAction action, bool checked)
{
WebCore::Frame *frame = d->page->focusController()->focusedOrMainFrame();
+ if (!frame)
+ return;
WebCore::Editor *editor = frame->editor();
const char *command = 0;
switch (action) {
case OpenLink:
- if (QWebFrame *targetFrame = d->currentContext.targetFrame()) {
+ if (QWebFrame *targetFrame = d->hitTestResult.linkTargetFrame()) {
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>());
+ targetFrame->d->frame->loader()->loadFrameRequestWithFormAndValues(frameLoadRequest(d->hitTestResult.linkUrl(), wcFrame.get()),
+ /*lockHistory*/ false, /*event*/ 0,
+ /*HTMLFormElement*/ 0, /*formValues*/
+ WTF::HashMap<String, String>());
break;
- } else {
}
// fall through
case OpenLinkInNewWindow:
- openNewWindow(d->currentContext.linkUrl(), frame);
+ openNewWindow(d->hitTestResult.linkUrl(), frame);
break;
- case OpenFrameInNewWindow:
+ case OpenFrameInNewWindow: {
+ KURL url = frame->loader()->documentLoader()->unreachableURL();
+ if (url.isEmpty())
+ url = frame->loader()->documentLoader()->url();
+ openNewWindow(url, frame);
break;
+ }
case CopyLinkToClipboard:
- editor->copyURL(d->currentContext.linkUrl(), d->currentContext.text());
+ editor->copyURL(d->hitTestResult.linkUrl(), d->hitTestResult.linkText());
break;
case OpenImageInNewWindow:
- openNewWindow(d->currentContext.imageUrl(), frame);
+ openNewWindow(d->hitTestResult.imageUrl(), frame);
break;
case DownloadImageToDisk:
+ frame->loader()->client()->startDownload(WebCore::ResourceRequest(d->hitTestResult.imageUrl(), frame->loader()->outgoingReferrer()));
+ break;
case DownloadLinkToDisk:
- frame->loader()->client()->startDownload(WebCore::ResourceRequest(d->currentContext.linkUrl(), frame->loader()->outgoingReferrer()));
+ frame->loader()->client()->startDownload(WebCore::ResourceRequest(d->hitTestResult.linkUrl(), frame->loader()->outgoingReferrer()));
break;
+#ifndef QT_NO_CLIPBOARD
case CopyImageToClipboard:
+ QApplication::clipboard()->setPixmap(d->hitTestResult.pixmap());
break;
- case GoBack:
+#endif
+ case Back:
d->page->goBack();
break;
- case GoForward:
+ case Forward:
d->page->goForward();
break;
case Stop:
@@ -904,126 +1412,21 @@ void QWebPage::triggerAction(WebAction action, bool checked)
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");
+ editor->setBaseWritingDirection(NaturalWritingDirection);
break;
case SetTextDirectionLeftToRight:
- editor->setBaseWritingDirection("ltr");
+ editor->setBaseWritingDirection(LeftToRightWritingDirection);
break;
case SetTextDirectionRightToLeft:
- editor->setBaseWritingDirection("rtl");
+ editor->setBaseWritingDirection(RightToLeftWritingDirection);
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());
+ d->page->inspectorController()->inspect(d->hitTestResult.d->innerNonSharedNode.get());
+ break;
+ default:
+ command = editorCommandForWebActions(action);
break;
-
- default: break;
}
if (command)
@@ -1032,43 +1435,82 @@ void QWebPage::triggerAction(WebAction action, bool checked)
QSize QWebPage::viewportSize() const
{
- QWebFrame *frame = mainFrame();
- if (frame->d->frame && frame->d->frameView)
- return frame->d->frameView->frameGeometry().size();
- return QSize(0, 0);
+ if (d->mainFrame && d->mainFrame->d->frame->view())
+ return d->mainFrame->d->frame->view()->frameRect().size();
+
+ return d->viewportSize;
}
/*!
\property QWebPage::viewportSize
+ \brief the size of the viewport
- Specifies the size of the viewport. The size affects for example the visibility of scrollbars
+ The size affects for example the visibility of scrollbars
if the document is larger than the viewport.
+
+ By default, for a newly-created Web page, this property contains a size with
+ zero width and height.
*/
void QWebPage::setViewportSize(const QSize &size) const
{
+ d->viewportSize = size;
+
QWebFrame *frame = mainFrame();
- if (frame->d->frame && frame->d->frameView) {
- frame->d->frameView->setFrameGeometry(QRect(QPoint(0, 0), size));
+ if (frame->d->frame && frame->d->frame->view()) {
+ WebCore::FrameView* view = frame->d->frame->view();
+ view->setFrameRect(QRect(QPoint(0, 0), size));
frame->d->frame->forceLayout();
- frame->d->frame->view()->adjustViewSize();
+ view->adjustViewSize();
}
}
-#if QT_VERSION < 0x040400
-QWebPage::NavigationRequestResponse QWebPage::navigationRequested(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type)
+/*!
+ \fn bool QWebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
+
+ This function is called whenever WebKit requests to navigate \a frame to the resource specified by \a request by means of
+ the specified navigation type \a type.
+
+ If \a frame is a null pointer then navigation to a new window is requested. If the request is
+ accepted createWindow() will be called.
+
+ The default implementation interprets the page's linkDelegationPolicy and emits linkClicked accordingly or returns true
+ to let QWebPage handle the navigation itself.
+
+ \sa createWindow()
+*/
+#if QT_VERSION >= 0x040400
+bool QWebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
#else
-QWebPage::NavigationRequestResponse QWebPage::navigationRequested(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
+bool QWebPage::acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type)
#endif
{
- Q_UNUSED(request)
- return AcceptNavigationRequest;
+ if (type == NavigationTypeLinkClicked) {
+ switch (d->linkPolicy) {
+ case DontDelegateLinks:
+ return true;
+
+ case DelegateExternalLinks:
+ if (WebCore::FrameLoader::shouldTreatSchemeAsLocal(request.url().scheme()))
+ return true;
+ emit linkClicked(request.url());
+ return false;
+
+ case DelegateAllLinks:
+ emit linkClicked(request.url());
+ return false;
+ }
+ }
+ return true;
}
/*!
\property QWebPage::selectedText
+ \brief the text currently selected
- Returns the text currently selected.
+ By default, this property contains an empty string.
+
+ \sa selectionChanged()
*/
QString QWebPage::selectedText() const
{
@@ -1083,6 +1525,8 @@ QString QWebPage::selectedText() const
QWebPage also takes care of implementing the action, so that upon
triggering the corresponding action is performed on the page.
+
+ \sa triggerAction()
*/
QAction *QWebPage::action(WebAction action) const
{
@@ -1091,6 +1535,8 @@ QAction *QWebPage::action(WebAction action) const
return d->actions[action];
QString text;
+ QIcon icon;
+ QStyle *style = view() ? view()->style() : qApp->style();
bool checkable = false;
switch (action) {
@@ -1121,17 +1567,29 @@ QAction *QWebPage::action(WebAction action) const
text = contextMenuItemTagCopyImageToClipboard();
break;
- case GoBack:
+ case Back:
text = contextMenuItemTagGoBack();
+#if QT_VERSION >= 0x040400
+ icon = style->standardIcon(QStyle::SP_ArrowBack);
+#endif
break;
- case GoForward:
+ case Forward:
text = contextMenuItemTagGoForward();
+#if QT_VERSION >= 0x040400
+ icon = style->standardIcon(QStyle::SP_ArrowForward);
+#endif
break;
case Stop:
text = contextMenuItemTagStop();
+#if QT_VERSION >= 0x040400
+ icon = style->standardIcon(QStyle::SP_BrowserStop);
+#endif
break;
case Reload:
text = contextMenuItemTagReload();
+#if QT_VERSION >= 0x040400
+ icon = style->standardIcon(QStyle::SP_BrowserReload);
+#endif
break;
case Cut:
@@ -1143,7 +1601,7 @@ QAction *QWebPage::action(WebAction action) const
case Paste:
text = contextMenuItemTagPaste();
break;
-
+#ifndef QT_NO_UNDOSTACK
case Undo: {
QAction *a = undoStack()->createUndoAction(d->q);
d->actions[action] = a;
@@ -1154,6 +1612,7 @@ QAction *QWebPage::action(WebAction action) const
d->actions[action] = a;
return a;
}
+#endif // QT_NO_UNDOSTACK
case MoveToNextChar:
case MoveToPreviousChar:
case MoveToNextWord:
@@ -1222,6 +1681,7 @@ QAction *QWebPage::action(WebAction action) const
a->setText(text);
a->setData(action);
a->setCheckable(checkable);
+ a->setIcon(icon);
connect(a, SIGNAL(triggered(bool)),
this, SLOT(_q_webActionTriggered(bool)));
@@ -1233,15 +1693,22 @@ QAction *QWebPage::action(WebAction action) const
/*!
\property QWebPage::modified
+ \brief whether the page contains unsubmitted form data
- Specifies if the page contains unsubmitted form data.
+ By default, this property is false.
*/
bool QWebPage::isModified() const
{
- return d->modified;
+#ifdef QT_NO_UNDOSTACK
+ return false;
+#else
+ if (!d->undoStack)
+ return false;
+ return d->undoStack->canUndo();
+#endif // QT_NO_UNDOSTACK
}
-
+#ifndef QT_NO_UNDOSTACK
/*!
Returns a pointer to the undo stack used for editable content.
*/
@@ -1252,12 +1719,16 @@ QUndoStack *QWebPage::undoStack() const
return d->undoStack;
}
+#endif // QT_NO_UNDOSTACK
/*! \reimp
*/
bool QWebPage::event(QEvent *ev)
{
switch (ev->type()) {
+ case QEvent::Timer:
+ d->timerEvent(static_cast<QTimerEvent*>(ev));
+ break;
case QEvent::MouseMove:
d->mouseMoveEvent(static_cast<QMouseEvent*>(ev));
break;
@@ -1270,12 +1741,16 @@ bool QWebPage::event(QEvent *ev)
case QEvent::MouseButtonRelease:
d->mouseReleaseEvent(static_cast<QMouseEvent*>(ev));
break;
+#ifndef QT_NO_CONTEXTMENU
case QEvent::ContextMenu:
d->contextMenuEvent(static_cast<QContextMenuEvent*>(ev));
break;
+#endif
+#ifndef QT_NO_WHEELEVENT
case QEvent::Wheel:
d->wheelEvent(static_cast<QWheelEvent*>(ev));
break;
+#endif
case QEvent::KeyPress:
d->keyPressEvent(static_cast<QKeyEvent*>(ev));
break;
@@ -1302,6 +1777,14 @@ bool QWebPage::event(QEvent *ev)
d->dropEvent(static_cast<QDropEvent*>(ev));
break;
#endif
+ case QEvent::InputMethod:
+ d->inputMethodEvent(static_cast<QInputMethodEvent*>(ev));
+ case QEvent::ShortcutOverride:
+ d->shortcutOverrideEvent(static_cast<QKeyEvent*>(ev));
+ break;
+ case QEvent::Leave:
+ d->leaveEvent(ev);
+ break;
default:
return QObject::event(ev);
}
@@ -1311,7 +1794,9 @@ bool QWebPage::event(QEvent *ev)
/*!
Similar to QWidget::focusNextPrevChild it focuses the next focusable web element
- if \a next is true. Otherwise the previous element is focused.
+ if \a next is true; otherwise the previous element is focused.
+
+ Returns true if it can find a new focusable element, or false if it can't.
*/
bool QWebPage::focusNextPrevChild(bool next)
{
@@ -1328,9 +1813,242 @@ bool QWebPage::focusNextPrevChild(bool next)
}
/*!
- Returns a pointe to the page's settings object.
+ \property QWebPage::editable
+ \brief whether the content in this QWebPage is editable or not
+ \since 4.5
+
+ If this property is enabled the contents of the page can be edited by the user through a visible
+ cursor. If disabled (the default) only HTML elements in the web page with their
+ \c{contenteditable} attribute set are editable.
+*/
+void QWebPage::setEditable(bool editable)
+{
+ if (d->editable != editable) {
+ d->editable = editable;
+ d->page->setTabKeyCyclesThroughElements(!editable);
+ if (d->mainFrame) {
+ WebCore::Frame* frame = d->mainFrame->d->frame;
+ if (editable) {
+ frame->applyEditingStyleToBodyElement();
+ // FIXME: mac port calls this if there is no selectedDOMRange
+ //frame->setSelectionFromNone();
+ } else {
+ frame->removeEditingStyleFromBodyElement();
+ }
+ }
+
+ d->updateEditorActions();
+ }
+}
+
+bool QWebPage::isEditable() const
+{
+ return d->editable;
+}
+
+/*!
+ \property QWebPage::forwardUnsupportedContent
+ \brief whether QWebPage should forward unsupported content through the
+ unsupportedContent signal
+
+ If disabled the download of such content is aborted immediately.
+
+ By default unsupported content is not forwarded.
+*/
+
+void QWebPage::setForwardUnsupportedContent(bool forward)
+{
+ d->forwardUnsupportedContent = forward;
+}
+
+bool QWebPage::forwardUnsupportedContent() const
+{
+ return d->forwardUnsupportedContent;
+}
+
+/*!
+ \property QWebPage::linkDelegationPolicy
+ \brief how QWebPage should delegate the handling of links through the
+ linkClicked() signal
+
+ The default is to delegate no links.
+*/
+
+void QWebPage::setLinkDelegationPolicy(LinkDelegationPolicy policy)
+{
+ d->linkPolicy = policy;
+}
+
+QWebPage::LinkDelegationPolicy QWebPage::linkDelegationPolicy() const
+{
+ return d->linkPolicy;
+}
+
+#ifndef QT_NO_CONTEXTMENU
+/*!
+ Filters the context menu event, \a event, through handlers for scrollbars and
+ custom event handlers in the web page. Returns true if the event was handled;
+ otherwise false.
+
+ A web page may swallow a context menu event through a custom event handler, allowing for context
+ menus to be implemented in HTML/JavaScript. This is used by \l{http://maps.google.com/}{Google
+ Maps}, for example.
+*/
+bool QWebPage::swallowContextMenuEvent(QContextMenuEvent *event)
+{
+ d->page->contextMenuController()->clearContextMenu();
+
+ if (QWebFrame* webFrame = d->frameAt(event->pos())) {
+ Frame* frame = QWebFramePrivate::core(webFrame);
+ if (Scrollbar* scrollbar = frame->view()->scrollbarUnderMouse(PlatformMouseEvent(event, 1))) {
+ return scrollbar->contextMenu(PlatformMouseEvent(event, 1));
+ }
+ }
+
+ WebCore::Frame* focusedFrame = d->page->focusController()->focusedOrMainFrame();
+ focusedFrame->eventHandler()->sendContextMenuEvent(PlatformMouseEvent(event, 1));
+ ContextMenu *menu = d->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.
+
+ return !menu;
+}
+#endif // QT_NO_CONTEXTMENU
+
+/*!
+ Updates the page's actions depending on the position \a pos. For example if \a pos is over an image
+ element the CopyImageToClipboard action is enabled.
+*/
+void QWebPage::updatePositionDependentActions(const QPoint &pos)
+{
+ // First we disable all actions, but keep track of which ones were originally enabled.
+ QBitArray originallyEnabledWebActions(QWebPage::WebActionCount);
+ for (int i = ContextMenuItemTagNoAction; i < ContextMenuItemBaseApplicationTag; ++i) {
+ QWebPage::WebAction action = webActionForContextMenuAction(WebCore::ContextMenuAction(i));
+ if (QAction *a = this->action(action)) {
+ originallyEnabledWebActions.setBit(action, a->isEnabled());
+ a->setEnabled(false);
+ }
+ }
+
+ WebCore::Frame* focusedFrame = d->page->focusController()->focusedOrMainFrame();
+ HitTestResult result = focusedFrame->eventHandler()->hitTestResultAtPoint(focusedFrame->view()->windowToContents(pos), /*allowShadowContent*/ false);
+
+ d->hitTestResult = QWebHitTestResult(new QWebHitTestResultPrivate(result));
+ WebCore::ContextMenu menu(result);
+ menu.populate();
+ if (d->page->inspectorController()->enabled())
+ menu.addInspectElementItem();
+
+ QBitArray visitedWebActions(QWebPage::WebActionCount);
+
+#ifndef QT_NO_CONTEXTMENU
+ delete d->currentContextMenu;
+
+ // Then we let createContextMenu() enable the actions that are put into the menu
+ d->currentContextMenu = d->createContextMenu(&menu, menu.platformDescription(), &visitedWebActions);
+#endif // QT_NO_CONTEXTMENU
+
+ // Finally, we restore the original enablement for the actions that were not put into the menu.
+ originallyEnabledWebActions &= ~visitedWebActions; // Mask out visited actions (they're part of the menu)
+ for (int i = 0; i < QWebPage::WebActionCount; ++i) {
+ if (originallyEnabledWebActions.at(i)) {
+ if (QAction *a = this->action(QWebPage::WebAction(i))) {
+ a->setEnabled(true);
+ }
+ }
+ }
+
+ // This whole process ensures that any actions put into to the context menu has the right
+ // enablement, while also keeping the correct enablement for actions that were left out of
+ // the menu.
+
+}
+
+
+
+/*!
+ \enum QWebPage::Extension
+
+ This enum describes the types of extensions that the page can support. Before using these extensions, you
+ should verify that the extension is supported by calling supportsExtension().
+
+ Currently there are no extensions.
+*/
+
+/*!
+ \class QWebPage::ExtensionOption
+ \since 4.4
+ \brief The ExtensionOption class provides an extended input argument to QWebPage's extension support.
+
+ \sa QWebPage::extension()
+*/
+
+/*!
+ \class QWebPage::ExtensionReturn
+ \since 4.4
+ \brief The ExtensionOption class provides an extended output argument to QWebPage's extension support.
+
+ \sa QWebPage::extension()
+*/
+
+/*!
+ This virtual function can be reimplemented in a QWebPage subclass to provide support for extensions. The \a option
+ argument is provided as input to the extension; the output results can be stored in \a output.
+
+ The behavior of this function is determined by \a extension.
+
+ You can call supportsExtension() to check if an extension is supported by the page.
+
+ By default, no extensions are supported, and this function returns false.
+
+ \sa supportsExtension(), Extension
+*/
+bool QWebPage::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output)
+{
+ Q_UNUSED(extension)
+ Q_UNUSED(option)
+ Q_UNUSED(output)
+ return false;
+}
+
+/*!
+ This virtual function returns true if the web page supports \a extension; otherwise false is returned.
+
+ \sa extension()
+*/
+bool QWebPage::supportsExtension(Extension extension) const
+{
+ Q_UNUSED(extension)
+ return false;
+}
+
+/*!
+ Finds the next occurrence of the string, \a subString, in the page, using the given \a options.
+ Returns true of \a subString was found and selects the match visually; otherwise returns false.
*/
-QWebSettings *QWebPage::settings()
+bool QWebPage::findText(const QString &subString, FindFlags options)
+{
+ ::TextCaseSensitivity caseSensitivity = ::TextCaseInsensitive;
+ if (options & FindCaseSensitively)
+ caseSensitivity = ::TextCaseSensitive;
+
+ ::FindDirection direction = ::FindDirectionForward;
+ if (options & FindBackward)
+ direction = ::FindDirectionBackward;
+
+ const bool shouldWrap = options & FindWrapsAroundDocument;
+
+ return d->page->findString(subString, caseSensitivity, direction, shouldWrap);
+}
+
+/*!
+ Returns a pointer to the page's settings object.
+
+ \sa QWebSettings::globalSettings()
+*/
+QWebSettings *QWebPage::settings() const
{
return d->settings;
}
@@ -1338,17 +2056,20 @@ QWebSettings *QWebPage::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.
+
+ A suggested filename may be provided in \a suggestedFile. The frame originating the
+ request is provided as \a parentFrame.
*/
-QString QWebPage::chooseFile(QWebFrame *parentFrame, const QString& oldFile)
+QString QWebPage::chooseFile(QWebFrame *parentFrame, const QString& suggestedFile)
{
#ifndef QT_NO_FILEDIALOG
- return QFileDialog::getOpenFileName(d->view, QString::null, oldFile);
+ return QFileDialog::getOpenFileName(d->view, QString::null, suggestedFile);
#else
return QString::null;
#endif
}
-#if QT_VERSION < 0x040400
+#if QT_VERSION < 0x040400 && !defined qdoc
void QWebPage::setNetworkInterface(QWebNetworkInterface *interface)
{
@@ -1378,24 +2099,25 @@ QNetworkProxy QWebPage::networkProxy() const
#else
/*!
- Sets the QNetworkAccessManager \a manager that is responsible for serving network
- requests for this QWebPage.
+ Sets the QNetworkAccessManager \a manager responsible for serving network requests for this
+ QWebPage.
- \sa networkAccessManager
+ \sa networkAccessManager()
*/
void QWebPage::setNetworkAccessManager(QNetworkAccessManager *manager)
{
if (manager == d->networkManager)
return;
- delete d->networkManager;
+ if (d->networkManager && d->networkManager->parent() == this)
+ delete d->networkManager;
d->networkManager = manager;
}
/*!
- Returns the QNetworkAccessManager \a manager that is responsible for serving network
+ Returns the QNetworkAccessManager that is responsible for serving network
requests for this QWebPage.
- \sa setNetworkAccessManager
+ \sa setNetworkAccessManager()
*/
QNetworkAccessManager *QWebPage::networkAccessManager() const
{
@@ -1409,13 +2131,213 @@ QNetworkAccessManager *QWebPage::networkAccessManager() const
#endif
/*!
+ Sets the QWebPluginFactory \a factory responsible for creating plugins embedded into this
+ QWebPage.
+
+ Note: The plugin factory is only used if the QWebSettings::PluginsEnabled attribute is enabled.
+
+ \sa pluginFactory()
+*/
+void QWebPage::setPluginFactory(QWebPluginFactory *factory)
+{
+ d->pluginFactory = factory;
+}
+
+/*!
+ Returns the QWebPluginFactory that is responsible for creating plugins embedded into
+ this QWebPage. If no plugin factory is installed a null pointer is returned.
+
+ \sa setPluginFactory()
+*/
+QWebPluginFactory *QWebPage::pluginFactory() const
+{
+ return d->pluginFactory;
+}
+
+/*!
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.
+
+ The default implementation returns the following value:
+
+ "Mozilla/5.0 (%Platform%; %Security%; %Subplatform%; %Locale%) AppleWebKit/%WebKitVersion% (KHTML, like Gecko, Safari/419.3) %AppVersion"
+
+ In this string the following values are replaced at run-time:
+ \list
+ \o %Platform% and %Subplatform% are expanded to the windowing system and the operation system.
+ \o %Security% expands to U if SSL is enabled, otherwise N. SSL is enabled if QSslSocket::supportsSsl() returns true.
+ \o %Locale% is replaced with QLocale::name().
+ \o %WebKitVersion% currently expands to 527+
+ \o %AppVersion% expands to QCoreApplication::applicationName()/QCoreApplication::applicationVersion() if they're set; otherwise defaulting to Qt and the current Qt version.
+ \endlist
*/
-QString QWebPage::userAgentFor(const QUrl& url) const
+QString QWebPage::userAgentForUrl(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");
+ QString ua = QLatin1String("Mozilla/5.0 ("
+
+ // Plastform
+#ifdef Q_WS_MAC
+ "Macintosh"
+#elif defined Q_WS_QWS
+ "QtEmbedded"
+#elif defined Q_WS_WIN
+ "Windows"
+#elif defined Q_WS_X11
+ "X11"
+#else
+ "Unknown"
+#endif
+ "; "
+
+ // Placeholder for security strength (N or U)
+ "%1; "
+
+ // Subplatform"
+#ifdef Q_OS_AIX
+ "AIX"
+#elif defined Q_OS_WIN32
+ "%2"
+#elif defined Q_OS_DARWIN
+#ifdef __i386__ || __x86_64__
+ "Intel Mac OS X"
+#else
+ "PPC Mac OS X"
+#endif
+
+#elif defined Q_OS_BSDI
+ "BSD"
+#elif defined Q_OS_BSD4
+ "BSD Four"
+#elif defined Q_OS_CYGWIN
+ "Cygwin"
+#elif defined Q_OS_DGUX
+ "DG/UX"
+#elif defined Q_OS_DYNIX
+ "DYNIX/ptx"
+#elif defined Q_OS_FREEBSD
+ "FreeBSD"
+#elif defined Q_OS_HPUX
+ "HP-UX"
+#elif defined Q_OS_HURD
+ "GNU Hurd"
+#elif defined Q_OS_IRIX
+ "SGI Irix"
+#elif defined Q_OS_LINUX
+ "Linux"
+#elif defined Q_OS_LYNX
+ "LynxOS"
+#elif defined Q_OS_NETBSD
+ "NetBSD"
+#elif defined Q_OS_OS2
+ "OS/2"
+#elif defined Q_OS_OPENBSD
+ "OpenBSD"
+#elif defined Q_OS_OS2EMX
+ "OS/2"
+#elif defined Q_OS_OSF
+ "HP Tru64 UNIX"
+#elif defined Q_OS_QNX6
+ "QNX RTP Six"
+#elif defined Q_OS_QNX
+ "QNX"
+#elif defined Q_OS_RELIANT
+ "Reliant UNIX"
+#elif defined Q_OS_SCO
+ "SCO OpenServer"
+#elif defined Q_OS_SOLARIS
+ "Sun Solaris"
+#elif defined Q_OS_ULTRIX
+ "DEC Ultrix"
+#elif defined Q_OS_UNIX
+ "UNIX BSD/SYSV system"
+#elif defined Q_OS_UNIXWARE
+ "UnixWare Seven, Open UNIX Eight"
+#else
+ "Unknown"
+#endif
+ "; ");
+
+ QChar securityStrength(QLatin1Char('N'));
+#if !defined(QT_NO_OPENSSL)
+ if (QSslSocket::supportsSsl())
+ securityStrength = QLatin1Char('U');
+#endif
+ ua = ua.arg(securityStrength);
+
+#if defined Q_OS_WIN32
+ QString ver;
+ switch(QSysInfo::WindowsVersion) {
+ case QSysInfo::WV_32s:
+ ver = "Windows 3.1";
+ break;
+ case QSysInfo::WV_95:
+ ver = "Windows 95";
+ break;
+ case QSysInfo::WV_98:
+ ver = "Windows 98";
+ break;
+ case QSysInfo::WV_Me:
+ ver = "Windows 98; Win 9x 4.90";
+ break;
+ case QSysInfo::WV_NT:
+ ver = "WinNT4.0";
+ break;
+ case QSysInfo::WV_2000:
+ ver = "Windows NT 5.0";
+ break;
+ case QSysInfo::WV_XP:
+ ver = "Windows NT 5.1";
+ break;
+ case QSysInfo::WV_2003:
+ ver = "Windows NT 5.2";
+ break;
+ case QSysInfo::WV_VISTA:
+ ver = "Windows NT 6.0";
+ break;
+ case QSysInfo::WV_CE:
+ ver = "Windows CE";
+ break;
+ case QSysInfo::WV_CENET:
+ ver = "Windows CE .NET";
+ break;
+ case QSysInfo::WV_CE_5:
+ ver = "Windows CE 5.x";
+ break;
+ case QSysInfo::WV_CE_6:
+ ver = "Windows CE 6.x";
+ break;
+ }
+ ua = QString(ua).arg(ver);
+#endif
+
+ // Language
+ QLocale locale;
+ if (d->view)
+ locale = d->view->locale();
+ QString name = locale.name();
+ name[2] = QLatin1Char('-');
+ ua.append(name);
+ ua.append(QLatin1String(") "));
+
+ // webkit/qt version
+ ua.append(QLatin1String("AppleWebKit/" WEBKIT_VERSION " (KHTML, like Gecko, Safari/419.3) "));
+
+ // Application name/version
+ QString appName = QCoreApplication::applicationName();
+ if (!appName.isEmpty()) {
+ ua.append(QLatin1Char(' ') + appName);
+#if QT_VERSION >= 0x040400
+ QString appVer = QCoreApplication::applicationVersion();
+ if (!appVer.isEmpty())
+ ua.append(QLatin1Char('/') + appVer);
+#endif
+ } else {
+ // Qt version
+ ua.append(QLatin1String("Qt/"));
+ ua.append(QLatin1String(qVersion()));
+ }
+ return ua;
}
@@ -1428,6 +2350,8 @@ void QWebPagePrivate::_q_onLoadProgressChanged(int) {
/*!
Returns the total number of bytes that were received from the network to render the current page,
including extra content such as embedded images.
+
+ \sa bytesReceived()
*/
quint64 QWebPage::totalBytes() const {
return d->m_bytesReceived;
@@ -1436,123 +2360,54 @@ quint64 QWebPage::totalBytes() const {
/*!
Returns the number of bytes that were received from the network to render the current page.
+
+ \sa totalBytes()
*/
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;
-}
+/*!
+ \fn void QWebPage::loadStarted()
-QString QWebPageContext::text() const
-{
- if (!d)
- return QString();
- return d->text;
-}
+ This signal is emitted when a new load of the page is started.
-QUrl QWebPageContext::linkUrl() const
-{
- if (!d)
- return QUrl();
- return d->linkUrl;
-}
+ \sa loadFinished()
+*/
-QUrl QWebPageContext::imageUrl() const
-{
- if (!d)
- return QUrl();
- return d->linkUrl;
-}
+/*!
+ \fn void QWebPage::loadProgress(int progress)
-QPixmap QWebPageContext::image() const
-{
- if (!d)
- return QPixmap();
- return d->image;
-}
+ This signal is emitted when the global progress status changes.
+ The current value is provided by \a progress and scales from 0 to 100,
+ which is the default range of QProgressBar.
+ It accumulates changes from all the child frames.
-QWebFrame *QWebPageContext::targetFrame() const
-{
- if (!d)
- return 0;
- return d->targetFrame;
-}
+ \sa bytesReceived()
+*/
/*!
- \fn void QWebPage::loadProgressChanged(int progress)
+ \fn void QWebPage::loadFinished(bool ok)
- 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.
+ This signal is emitted when a load of the page is finished.
+ \a ok will indicate whether the load was successful or any error occurred.
+
+ \sa loadStarted()
*/
/*!
- \fn void QWebPage::hoveringOverLink(const QString &link, const QString &title, const QString &textContent)
+ \fn void QWebPage::linkHovered(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.
+
+ \sa linkClicked()
*/
/*!
- \fn void QWebPage::statusBarTextChanged(const QString& text)
+ \fn void QWebPage::statusBarMessage(const QString& text)
This signal is emitted when the statusbar \a text is changed by the page.
*/
@@ -1567,27 +2422,122 @@ QWebFrame *QWebPageContext::targetFrame() const
\fn void QWebPage::selectionChanged()
This signal is emitted whenever the selection changes.
+
+ \sa selectedText()
*/
/*!
- \fn void QWebPage::geometryChangeRequest(const QRect& geom)
+ \fn void QWebPage::contentsChanged()
+
+ This signal is emitted whenever the content changes during editing.
+
+ \sa selectedText()
+*/
+
+/*!
+ \fn void QWebPage::geometryChangeRequested(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)
+ \fn void QWebPage::repaintRequested(const QRect& dirtyRect)
+
+ This signal is emitted whenever this QWebPage should be updated and no view was set.
+ \a dirtyRect contains the area that needs to be updated. To paint the QWebPage get
+ the mainFrame() and call the render(QPainter*, const QRegion&) method with the
+ \a dirtyRect as the second parameter.
+
+ \sa mainFrame()
+ \sa view()
+*/
+
+/*!
+ \fn void QWebPage::scrollRequested(int dx, int dy, const QRect& rectToScroll)
+
+ This signal is emitted whenever the content given by \a rectToScroll needs
+ to be scrolled \a dx and \a dy downwards and no view was set.
+
+ \sa view()
+*/
+
+/*!
+ \fn void QWebPage::windowCloseRequested()
+
+ This signal is emitted whenever the page requests the web browser window to be closed,
+ for example through the JavaScript \c{window.close()} call.
+*/
+
+/*!
+ \fn void QWebPage::printRequested(QWebFrame *frame)
+
+ This signal is emitted whenever the page requests the web browser to print \a frame,
+ for example through the JavaScript \c{window.print()} call.
+
+ \sa QWebFrame::print(), QPrintPreviewDialog
+*/
+
+/*!
+ \fn void QWebPage::unsupportedContent(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.
+ At signal emissions time the meta data of the QNetworkReply \a reply is available.
+
+ \note This signal is only emitted if the forwardUnsupportedContent property is set to true.
+
+ \sa downloadRequested()
+*/
+
+/*!
+ \fn void QWebPage::downloadRequested(const QNetworkRequest &request)
+
+ This signal is emitted when the user decides to download a link. The url of
+ the link as well as additional meta-information is contained in \a request.
+
+ \sa unsupportedContent()
+*/
+
+/*!
+ \fn void QWebPage::microFocusChanged()
+
+ This signal is emitted when for example the position of the cursor in an editable form
+ element changes. It is used inform input methods about the new on-screen position where
+ the user is able to enter text. This signal is usually connected to QWidget's updateMicroFocus()
+ slot.
+*/
+
+/*!
+ \fn void QWebPage::linkClicked(const QUrl &url)
+
+ This signal is emitted whenever the user clicks on a link and the page's linkDelegationPolicy
+ property is set to delegate the link handling for the specified \a url.
+
+ By default no links are delegated and are handled by QWebPage instead.
+
+ \sa linkHovered()
+*/
+
+/*!
+ \fn void QWebPage::toolBarVisibilityChangeRequested(bool visible)
+
+ This signal is emitted whenever the visibility of the toolbar in a web browser
+ window that hosts QWebPage should be changed to \a visible.
+*/
+
+/*!
+ \fn void QWebPage::statusBarVisibilityChangeRequested(bool visible)
+
+ This signal is emitted whenever the visibility of the statusbar in a web browser
+ window that hosts QWebPage should be changed to \a visible.
*/
/*!
- \fn void QWebPage::download(const QNetworkRequest &request)
+ \fn void QWebPage::menuBarVisibilityChangeRequested(bool visible)
- This signals is emitted when the user decides to download a link.
+ This signal is emitted whenever the visibility of the menubar in a web browser
+ window that hosts QWebPage should be changed to \a visible.
*/
#include "moc_qwebpage.cpp"
diff --git a/WebKit/qt/Api/qwebpage.h b/WebKit/qt/Api/qwebpage.h
index e76f935..5b978d8 100644
--- a/WebKit/qt/Api/qwebpage.h
+++ b/WebKit/qt/Api/qwebpage.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2007 Trolltech ASA
+ Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
Copyright (C) 2007 Staikos Computing Services Inc.
This library is free software; you can redistribute it and/or
@@ -16,9 +16,6 @@
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
@@ -29,19 +26,26 @@
#include <QtCore/qobject.h>
#include <QtGui/qwidget.h>
+
+QT_BEGIN_NAMESPACE
class QNetworkProxy;
class QUndoStack;
class QUrl;
-class QWebFrame;
-class QWebNetworkRequest;
+class QMenu;
class QNetworkRequest;
class QNetworkReply;
class QNetworkAccessManager;
+QT_END_NAMESPACE
+
+class QWebFrame;
+class QWebNetworkRequest;
class QWebHistory;
class QWebPagePrivate;
class QWebFrameData;
class QWebNetworkInterface;
+class QWebPluginFactory;
+class QWebHitTestResult;
namespace WebCore {
class ChromeClientQt;
@@ -60,16 +64,16 @@ class QWEBKIT_EXPORT QWebPage : public QObject
Q_PROPERTY(bool modified READ isModified)
Q_PROPERTY(QString selectedText READ selectedText)
Q_PROPERTY(QSize viewportSize READ viewportSize WRITE setViewportSize)
+ Q_PROPERTY(bool forwardUnsupportedContent READ forwardUnsupportedContent WRITE setForwardUnsupportedContent)
+ Q_PROPERTY(LinkDelegationPolicy linkDelegationPolicy READ linkDelegationPolicy WRITE setLinkDelegationPolicy)
+ Q_PROPERTY(QPalette palette READ palette WRITE setPalette)
+ Q_PROPERTY(bool editable READ isEditable WRITE setEditable)
+ Q_ENUMS(LinkDelegationPolicy NavigationType WebAction)
public:
- enum NavigationRequestResponse {
- AcceptNavigationRequest,
- IgnoreNavigationRequest
- };
-
enum NavigationType {
NavigationTypeLinkClicked,
NavigationTypeFormSubmitted,
- NavigationTypeBackForward,
+ NavigationTypeBackOrForward,
NavigationTypeReload,
NavigationTypeFormResubmitted,
NavigationTypeOther
@@ -90,8 +94,8 @@ public:
DownloadImageToDisk,
CopyImageToClipboard,
- GoBack, // ###GoBackward instead?
- GoForward,
+ Back,
+ Forward,
Stop,
Reload,
@@ -138,9 +142,29 @@ public:
InspectElement,
+ InsertParagraphSeparator,
+ InsertLineSeparator,
+
WebActionCount
};
+ enum FindFlag {
+ FindBackward = 1,
+ FindCaseSensitively = 2,
+ FindWrapsAroundDocument = 4
+ };
+ Q_DECLARE_FLAGS(FindFlags, FindFlag)
+
+ enum LinkDelegationPolicy {
+ DontDelegateLinks,
+ DelegateExternalLinks,
+ DelegateAllLinks
+ };
+
+ enum WebWindowType {
+ WebBrowserWindow,
+ WebModalDialog
+ };
explicit QWebPage(QObject *parent = 0);
~QWebPage();
@@ -149,16 +173,17 @@ public:
QWebFrame *currentFrame() const;
QWebHistory *history() const;
-
- QWebSettings *settings();
+ QWebSettings *settings() const;
void setView(QWidget *view);
QWidget *view() const;
bool isModified() const;
+#ifndef QT_NO_UNDOSTACK
QUndoStack *undoStack() const;
+#endif
-#if QT_VERSION < 0x040400
+#if QT_VERSION < 0x040400 && !defined(qdoc)
void setNetworkInterface(QWebNetworkInterface *interface);
QWebNetworkInterface *networkInterface() const;
@@ -173,6 +198,9 @@ public:
QNetworkAccessManager *networkAccessManager() const;
#endif
+ void setPluginFactory(QWebPluginFactory *factory);
+ QWebPluginFactory *pluginFactory() const;
+
quint64 totalBytes() const;
quint64 bytesReceived() const;
@@ -185,58 +213,100 @@ public:
void setViewportSize(const QSize &size) const;
virtual bool event(QEvent*);
- virtual bool focusNextPrevChild(bool next);
+ bool focusNextPrevChild(bool next);
+
+ QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
+
+ bool findText(const QString &subString, FindFlags options = 0);
+
+ void setForwardUnsupportedContent(bool forward);
+ bool forwardUnsupportedContent() const;
+
+ void setLinkDelegationPolicy(LinkDelegationPolicy policy);
+ LinkDelegationPolicy linkDelegationPolicy() const;
+
+ void setPalette(const QPalette &palette);
+ QPalette palette() const;
+
+ void setEditable(bool editable);
+ bool isEditable() const;
+
+#ifndef QT_NO_CONTEXTMENU
+ bool swallowContextMenuEvent(QContextMenuEvent *event);
+#endif
+ void updatePositionDependentActions(const QPoint &pos);
+
+ QMenu *createStandardContextMenu();
+
+ enum Extension {
+ };
+ class ExtensionOption
+ {};
+ class ExtensionReturn
+ {};
+ virtual bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0);
+ virtual bool supportsExtension(Extension extension) const;
Q_SIGNALS:
- void loadProgressChanged(int progress);
- void hoveringOverLink(const QString &link, const QString &title, const QString &textContent = QString());
- void statusBarTextChanged(const QString& text);
+ void loadStarted();
+ void loadProgress(int progress);
+ void loadFinished(bool ok);
+
+ void linkHovered(const QString &link, const QString &title, const QString &textContent);
+ void statusBarMessage(const QString& text);
void selectionChanged();
void frameCreated(QWebFrame *frame);
- void geometryChangeRequest(const QRect& geom);
+ void geometryChangeRequested(const QRect& geom);
+ void repaintRequested(const QRect& dirtyRect);
+ void scrollRequested(int dx, int dy, const QRect& scrollViewRect);
+ void windowCloseRequested();
+ void printRequested(QWebFrame *frame);
+ void linkClicked(const QUrl &url);
+
+ void toolBarVisibilityChangeRequested(bool visible);
+ void statusBarVisibilityChangeRequested(bool visible);
+ void menuBarVisibilityChangeRequested(bool visible);
#if QT_VERSION >= 0x040400
- void handleUnsupportedContent(QNetworkReply *reply);
- void download(const QNetworkRequest &request);
+ void unsupportedContent(QNetworkReply *reply);
+ void downloadRequested(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();
+ void microFocusChanged();
+ void contentsChanged();
protected:
- virtual QWebPage *createWindow();
- virtual QWebPage *createModalDialog();
+ virtual QWebPage *createWindow(WebWindowType type);
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);
+#if QT_VERSION >= 0x040400
+ virtual bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type);
#else
- virtual NavigationRequestResponse navigationRequested(QWebFrame *frame, const QNetworkRequest &request, NavigationType type);
+ virtual bool acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &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 void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID);
- virtual QString userAgentFor(const QUrl& url) const;
+ virtual QString userAgentForUrl(const QUrl& url) const;
private:
Q_PRIVATE_SLOT(d, void _q_onLoadProgressChanged(int))
- Q_PRIVATE_SLOT(d, void _q_webActionTriggered(bool checked));
+ Q_PRIVATE_SLOT(d, void _q_webActionTriggered(bool checked))
+ QWebPagePrivate *d;
+
friend class QWebFrame;
friend class QWebPagePrivate;
+ friend class QWebView;
friend class WebCore::ChromeClientQt;
friend class WebCore::EditorClientQt;
friend class WebCore::FrameLoaderClientQt;
friend class WebCore::InspectorClientQt;
friend class WebCore::ResourceHandle;
- QWebPagePrivate *d;
};
-
+Q_DECLARE_OPERATORS_FOR_FLAGS(QWebPage::FindFlags)
#endif
diff --git a/WebKit/qt/Api/qwebpage_p.h b/WebKit/qt/Api/qwebpage_p.h
index 80b1e29..8fae81c 100644
--- a/WebKit/qt/Api/qwebpage_p.h
+++ b/WebKit/qt/Api/qwebpage_p.h
@@ -1,5 +1,6 @@
/*
- Copyright (C) 2007 Trolltech ASA
+ Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2008 Holger Hans Peter Freyther
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -15,15 +16,15 @@
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 <qbasictimer.h>
#include <qnetworkproxy.h>
#include <qpointer.h>
+#include <qevent.h>
#include "qwebpage.h"
#include "qwebhistory.h"
@@ -44,47 +45,25 @@ namespace WebCore
class Element;
class Node;
class Page;
+
+#ifndef QT_NO_CURSOR
+ class SetCursorEvent : public QEvent {
+ public:
+ static const int EventType = 724;
+ SetCursorEvent(const QCursor&);
+
+ QCursor cursor() const;
+ private:
+ QCursor m_cursor;
+ };
+#endif
}
+QT_BEGIN_NAMESPACE
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 QBitArray;
+QT_END_NAMESPACE
class QWebPagePrivate
{
@@ -92,7 +71,9 @@ public:
QWebPagePrivate(QWebPage *);
~QWebPagePrivate();
void createMainFrame();
- QMenu *createContextMenu(const WebCore::ContextMenu *webcoreMenu, const QList<WebCore::ContextMenuItem> *items);
+#ifndef QT_NO_CONTEXTMENU
+ QMenu *createContextMenu(const WebCore::ContextMenu *webcoreMenu, const QList<WebCore::ContextMenuItem> *items, QBitArray *visitedWebActions);
+#endif
QWebFrame *frameAt(const QPoint &pos) const;
@@ -102,12 +83,19 @@ public:
void updateNavigationActions();
void updateEditorActions();
+ void timerEvent(QTimerEvent*);
+
void mouseMoveEvent(QMouseEvent*);
void mousePressEvent(QMouseEvent*);
void mouseDoubleClickEvent(QMouseEvent*);
+ void mouseTripleClickEvent(QMouseEvent*);
void mouseReleaseEvent(QMouseEvent*);
+#ifndef QT_NO_CONTEXTMENU
void contextMenuEvent(QContextMenuEvent*);
+#endif
+#ifndef QT_NO_WHEELEVENT
void wheelEvent(QWheelEvent*);
+#endif
void keyPressEvent(QKeyEvent*);
void keyReleaseEvent(QKeyEvent*);
void focusInEvent(QFocusEvent*);
@@ -118,6 +106,11 @@ public:
void dragMoveEvent(QDragMoveEvent *);
void dropEvent(QDropEvent *);
+ void inputMethodEvent(QInputMethodEvent*);
+
+ void shortcutOverrideEvent(QKeyEvent*);
+ void leaveEvent(QEvent *);
+ bool handleScrolling(QKeyEvent*);
WebCore::ChromeClientQt *chromeClient;
WebCore::ContextMenuClientQt *contextMenuClient;
@@ -127,17 +120,20 @@ public:
QPointer<QWebFrame> mainFrame;
QWebPage *q;
+#ifndef QT_NO_UNDOSTACK
QUndoStack *undoStack;
+#endif
QWidget *view;
- bool modified;
-
bool insideOpenCall;
quint64 m_totalBytes;
quint64 m_bytesReceived;
+ QPoint tripleClick;
+ QBasicTimer tripleClickTimer;
+
#if QT_VERSION < 0x040400
- QWebPage::NavigationRequestResponse navigationRequested(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type);
+ bool acceptNavigationRequest(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type);
QWebNetworkInterface *networkInterface;
#ifndef QT_NO_NETWORKPROXY
@@ -145,15 +141,26 @@ public:
#endif
#else
- QWebPage::NavigationRequestResponse navigationRequested(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type);
+ bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type);
QNetworkAccessManager *networkManager;
#endif
+ bool forwardUnsupportedContent;
+ QWebPage::LinkDelegationPolicy linkPolicy;
+
+ QSize viewportSize;
QWebHistory history;
- QWebPageContext currentContext;
+ QWebHitTestResult hitTestResult;
+#ifndef QT_NO_CONTEXTMENU
+ QPointer<QMenu> currentContextMenu;
+#endif
QWebSettings *settings;
+ QPalette palette;
+ bool editable;
QAction *actions[QWebPage::WebActionCount];
+
+ QWebPluginFactory *pluginFactory;
};
#endif
diff --git a/WebKit/qt/Api/qwebpluginfactory.cpp b/WebKit/qt/Api/qwebpluginfactory.cpp
new file mode 100644
index 0000000..0d2390c
--- /dev/null
+++ b/WebKit/qt/Api/qwebpluginfactory.cpp
@@ -0,0 +1,216 @@
+/*
+ Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+
+ 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 "qwebpluginfactory.h"
+
+/*!
+ \class QWebPluginFactory
+ \since 4.4
+ \brief The QWebPluginFactory class creates plugins to be embedded into web
+ pages.
+
+ QWebPluginFactory is a factory for creating plugins for QWebPage. A plugin
+ factory can be installed on a QWebPage using QWebPage::setPluginFactory().
+
+ \note The plugin factory is only used if plugins are enabled through QWebSettings.
+
+ You can provide a QWebPluginFactory by implementing the plugins() and the
+ create() method. For plugins() it is necessary to describe the plugins the
+ factory can create, including a description and the supported MIME types.
+ The MIME types each plugin can handle should match the ones specified in
+ in the HTML \c{<object>} tag.
+
+ The create() method is called if the requested MIME type is supported. The
+ implementation has to return a new instance of the plugin requested for the
+ given MIME type and the specified URL.
+*/
+
+
+/*!
+ \class QWebPluginFactory::Plugin
+ \since 4.4
+ \brief the QWebPluginFactory::Plugin structure describes the properties of a plugin a QWebPluginFactory can create.
+*/
+
+/*!
+ \variable QWebPluginFactory::Plugin::name
+ The name of the plugin.
+*/
+
+/*!
+ \variable QWebPluginFactory::Plugin::description
+ The description of the plugin.
+*/
+
+/*!
+ \variable QWebPluginFactory::Plugin::mimeTypes
+ The list of mime types supported by the plugin.
+*/
+
+/*!
+ \class QWebPluginFactory::MimeType
+ \since 4.4
+ \brief The QWebPluginFactory::MimeType structure describes a mime type supported by a plugin.
+*/
+
+/*!
+ \variable QWebPluginFactory::MimeType::name
+
+ The full name of the MIME type; e.g., \c{text/plain} or \c{image/png}.
+*/
+
+/*!
+ \variable QWebPluginFactory::MimeType::description
+ The description of the mime type.
+*/
+
+/*!
+ \variable QWebPluginFactory::MimeType::fileExtensions
+ The list of file extensions that are used by this mime type.
+
+ For example, a mime type for PDF documents would return "pdf" as its file extension.
+*/
+
+/*!
+ Constructs a QWebPluginFactory with parent \a parent.
+*/
+QWebPluginFactory::QWebPluginFactory(QObject *parent)
+ : QObject(parent)
+{
+}
+
+/*!
+ Destructor.
+*/
+QWebPluginFactory::~QWebPluginFactory()
+{
+}
+
+/*!
+ \fn QList<Plugin> QWebPluginFactory::plugins() const = 0
+
+ This function is reimplemented in subclasses to return a list of
+ supported plugins the factory can create.
+
+ \note Currently, this function is only called when JavaScript programs
+ access the global \c plugins or \c mimetypes objects.
+*/
+
+/*!
+ This function is called to refresh the list of supported plugins. It may be called after a new plugin
+ has been installed in the system.
+*/
+void QWebPluginFactory::refreshPlugins()
+{
+}
+
+/*!
+ \fn QObject *QWebPluginFactory::create(const QString &mimeType, const QUrl &url,
+ const QStringList &argumentNames, const QStringList &argumentValues) const = 0
+
+ Implemented in subclasses to create a new plugin that can display content of
+ the MIME type given by \a mimeType. The URL of the content is provided in \a url.
+ The returned object should be a QWidget.
+
+ The HTML object element can provide parameters through the \c{<param>} tag.
+ The name and the value attributes of these tags are specified by the
+ \a argumentNames and \a argumentValues string lists.
+
+ For example:
+
+ \code
+ <object type="application/x-pdf" data="http://www.trolltech.com/document.pdf" width="500" height="400">
+ <param name="showTableOfContents" value="true" />
+ <param name="hideThumbnails" value="false" />
+ </object>
+ \endcode
+
+ The above object element will result in a call to create() with the following arguments:
+ \table
+ \header \o Parameter
+ \o Value
+ \row \o mimeType
+ \o "application/x-pdf"
+ \row \o url
+ \o "http://www.trolltech.com/document.pdf"
+ \row \o argumentNames
+ \o "showTableOfContents" "hideThumbnails"
+ \row \o argumentVaues
+ \o "true" "false"
+ \endtable
+
+ \note Ownership of the returned object will be transferred to the caller.
+*/
+
+/*!
+ \enum QWebPluginFactory::Extension
+
+ This enum describes the types of extensions that the plugin factory can support. Before using these extensions, you
+ should verify that the extension is supported by calling supportsExtension().
+
+ Currently there are no extensions.
+*/
+
+/*!
+ \class QWebPluginFactory::ExtensionOption
+ \since 4.4
+ \brief The ExtensionOption class provides an extended input argument to QWebPluginFactory's extension support.
+
+ \sa QWebPluginFactory::extension()
+*/
+
+/*!
+ \class QWebPluginFactory::ExtensionReturn
+ \since 4.4
+ \brief The ExtensionOption class provides an extended output argument to QWebPluginFactory's extension support.
+
+ \sa QWebPluginFactory::extension()
+*/
+
+/*!
+ This virtual function can be reimplemented in a QWebPluginFactory subclass to provide support for extensions. The \a option
+ argument is provided as input to the extension; the output results can be stored in \a output.
+
+ The behaviour of this function is determined by \a extension.
+
+ You can call supportsExtension() to check if an extension is supported by the factory.
+
+ By default, no extensions are supported, and this function returns false.
+
+ \sa supportsExtension(), Extension
+*/
+bool QWebPluginFactory::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output)
+{
+ Q_UNUSED(extension)
+ Q_UNUSED(option)
+ Q_UNUSED(output)
+ return false;
+}
+
+/*!
+ This virtual function returns true if the plugin factory supports \a extension; otherwise false is returned.
+
+ \sa extension()
+*/
+bool QWebPluginFactory::supportsExtension(Extension extension) const
+{
+ Q_UNUSED(extension)
+ return false;
+}
diff --git a/WebKit/qt/Api/qwebpluginfactory.h b/WebKit/qt/Api/qwebpluginfactory.h
new file mode 100644
index 0000000..3531b06
--- /dev/null
+++ b/WebKit/qt/Api/qwebpluginfactory.h
@@ -0,0 +1,74 @@
+/*
+ Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+
+ 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 QWEBPLUGINFACTORY_H
+#define QWEBPLUGINFACTORY_H
+
+#include "qwebkitglobal.h"
+
+#include <QtCore/qobject.h>
+#include <QtCore/qstringlist.h>
+
+QT_BEGIN_NAMESPACE
+class QUrl;
+class QString;
+QT_END_NAMESPACE
+class QWebPluginFactoryPrivate;
+
+class QWEBKIT_EXPORT QWebPluginFactory : public QObject
+{
+ Q_OBJECT
+public:
+ struct MimeType {
+ QString name;
+ QString description;
+ QStringList fileExtensions;
+ };
+
+ struct Plugin {
+ QString name;
+ QString description;
+ QList<MimeType> mimeTypes;
+ };
+
+ explicit QWebPluginFactory(QObject *parent = 0);
+ virtual ~QWebPluginFactory();
+
+ virtual QList<Plugin> plugins() const = 0;
+ virtual void refreshPlugins();
+
+ virtual QObject *create(const QString &mimeType,
+ const QUrl &url,
+ const QStringList &argumentNames,
+ const QStringList &argumentValues) const = 0;
+
+ enum Extension {
+ };
+ class ExtensionOption
+ {};
+ class ExtensionReturn
+ {};
+ virtual bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0);
+ virtual bool supportsExtension(Extension extension) const;
+
+private:
+ QWebPluginFactoryPrivate *d;
+};
+
+#endif
diff --git a/WebKit/qt/Api/qwebsettings.cpp b/WebKit/qt/Api/qwebsettings.cpp
index 8109de1..132eb0c 100644
--- a/WebKit/qt/Api/qwebsettings.cpp
+++ b/WebKit/qt/Api/qwebsettings.cpp
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2007 Trolltech ASA
+ Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -15,9 +15,6 @@
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"
@@ -26,11 +23,15 @@
#include "qwebpage.h"
#include "qwebpage_p.h"
+#include "Cache.h"
#include "Page.h"
+#include "PageCache.h"
#include "Settings.h"
#include "KURL.h"
#include "PlatformString.h"
#include "IconDatabase.h"
+#include "Image.h"
+#include "IntSize.h"
#include <QHash>
#include <QSharedData>
@@ -55,14 +56,30 @@ public:
};
typedef QHash<int, QPixmap> WebGraphicHash;
-Q_GLOBAL_STATIC(WebGraphicHash, graphics)
+Q_GLOBAL_STATIC(WebGraphicHash, _graphics)
+
+static WebGraphicHash* graphics()
+{
+ WebGraphicHash* hash = _graphics();
+
+ if (hash->isEmpty()) {
+ hash->insert(QWebSettings::MissingImageGraphic, QPixmap(QLatin1String(":webkit/resources/missingImage.png")));
+ hash->insert(QWebSettings::MissingPluginGraphic, QPixmap(QLatin1String(":webkit/resources/nullPlugin.png")));
+ hash->insert(QWebSettings::DefaultFrameIconGraphic, QPixmap(QLatin1String(":webkit/resources/urlIcon.png")));
+ hash->insert(QWebSettings::TextAreaSizeGripCornerGraphic, QPixmap(QLatin1String(":webkit/resources/textAreaResizeCorner.png")));
+ }
+
+ return hash;
+}
Q_GLOBAL_STATIC(QList<QWebSettingsPrivate *>, allSettings);
void QWebSettingsPrivate::apply()
{
if (settings) {
- QWebSettingsPrivate *global = QWebSettings::defaultSettings()->d;
+ settings->setTextAreasAreResizable(true);
+
+ QWebSettingsPrivate *global = QWebSettings::globalSettings()->d;
QString family = fontFamilies.value(QWebSettings::StandardFont,
global->fontFamilies.value(QWebSettings::StandardFont));
@@ -138,6 +155,10 @@ void QWebSettingsPrivate::apply()
QUrl location = !userStyleSheetLocation.isEmpty() ? userStyleSheetLocation : global->userStyleSheetLocation;
settings->setUserStyleSheetLocation(WebCore::KURL(location));
+
+ value = attributes.value(QWebSettings::ZoomTextOnly,
+ global->attributes.value(QWebSettings::ZoomTextOnly));
+ settings->setZoomsTextOnly(value);
} else {
QList<QWebSettingsPrivate *> settings = *::allSettings();
for (int i = 0; i < settings.count(); ++i)
@@ -146,12 +167,12 @@ void QWebSettingsPrivate::apply()
}
/*!
- Returns the global default settings object.
+ Returns the global 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()
+QWebSettings *QWebSettings::globalSettings()
{
static QWebSettings *global = 0;
if (!global)
@@ -160,6 +181,94 @@ QWebSettings *QWebSettings::defaultSettings()
}
/*!
+ \class QWebSettings
+ \since 4.4
+ \brief The QWebSettings class provides an object to store the settings used
+ by QWebPage and QWebFrame.
+
+ Each QWebPage object has its own QWebSettings object, which configures the
+ settings for that page. If a setting is not configured, then it is looked
+ up in the global settings object, which can be accessed using
+ QWebSettings::globalSettings().
+
+ QWebSettings allows configuring font properties such as font size and font
+ family, the location of a custom stylesheet, and generic attributes like java
+ script, plugins, etc. The \l{QWebSettings::WebAttribute}{WebAttribute}
+ enum further describes this.
+
+ QWebSettings also configures global properties such as the web page memory
+ cache and the web page icon database.
+
+ \sa QWebPage::settings(), QWebView::settings(), {Browser}
+*/
+
+/*!
+ \enum QWebSettings::FontFamily
+
+ This enum describes the generic font families defined by CSS 2.
+ For more information see the
+ \l{http://www.w3.org/TR/REC-CSS2/fonts.html#generic-font-families}{CSS standard}.
+
+ \value StandardFont
+ \value FixedFont
+ \value SerifFont
+ \value SansSerifFont
+ \value CursiveFont
+ \value FantasyFont
+*/
+
+/*!
+ \enum QWebSettings::FontSize
+
+ This enum describes the font sizes configurable through QWebSettings.
+
+ \value MinimumFontSize The hard minimum font size.
+ \value MinimumLogicalFontSize The minimum logical font size that is applied
+ after zooming with QWebFrame's textSizeMultiplier().
+ \value DefaultFontSize The default font size for regular text.
+ \value DefaultFixedFontSize The default font size for fixed-pitch text.
+*/
+
+/*!
+ \enum QWebSettings::WebGraphic
+
+ This enums describes the standard graphical elements used in webpages.
+
+ \value MissingImageGraphic The replacement graphic shown when an image could not be loaded.
+ \value MissingPluginGraphic The replacement graphic shown when a plugin could not be loaded.
+ \value DefaultFrameIconGraphic The default icon for QWebFrame::icon().
+ \value TextAreaSizeGripCornerGraphic The graphic shown for the size grip of text areas.
+*/
+
+/*!
+ \enum QWebSettings::WebAttribute
+
+ This enum describes various attributes that are configurable through QWebSettings.
+
+ \value AutoLoadImages Specifies whether images are automatically loaded in
+ web pages.
+ \value JavascriptEnabled Enables or disables the running of JavaScript
+ programs.
+ \value JavaEnabled Enables or disables Java applets.
+ Currently Java applets are not supported.
+ \value PluginsEnabled Enables or disables plugins in web pages.
+ Currently Flash and other plugins are not supported.
+ \value PrivateBrowsingEnabled Private browsing prevents WebKit from
+ recording visited pages in the history and storing web page icons.
+ \value JavascriptCanOpenWindows Specifies whether JavaScript programs
+ can open new windows.
+ \value JavascriptCanAccessClipboard Specifies whether JavaScript programs
+ can read or write to the clipboard.
+ \value DeveloperExtrasEnabled Enables extra tools for Web developers.
+ Currently this enables the "Inspect" element in the context menu,
+ which shows the WebKit WebInspector for web site debugging.
+ \value LinksIncludedInFocusChain Specifies whether hyperlinks should be
+ included in the keyboard focus chain.
+ \value ZoomTextOnly Specifies whether the zoom factor on a frame applies to
+ only the text or all content.
+*/
+
+/*!
\internal
*/
QWebSettings::QWebSettings()
@@ -181,6 +290,7 @@ QWebSettings::QWebSettings()
d->attributes.insert(QWebSettings::AutoLoadImages, true);
d->attributes.insert(QWebSettings::JavascriptEnabled, true);
d->attributes.insert(QWebSettings::LinksIncludedInFocusChain, true);
+ d->attributes.insert(QWebSettings::ZoomTextOnly, false);
}
/*!
@@ -221,16 +331,17 @@ int QWebSettings::fontSize(FontSize type) const
{
int defaultValue = 0;
if (d->settings) {
- QWebSettingsPrivate *global = QWebSettings::defaultSettings()->d;
+ QWebSettingsPrivate *global = QWebSettings::globalSettings()->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.
+ Resets the font size for \a type to the size specified in the global
+ settings object.
- This function has not effect on the default QWebSettings instance.
+ This function has no effect on the global QWebSettings instance.
*/
void QWebSettings::resetFontSize(FontSize type)
{
@@ -243,11 +354,11 @@ void QWebSettings::resetFontSize(FontSize type)
/*!
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.
+ The \a location can be a URL or a path on the local filesystem.
- \sa userStyleSheetLocation
+ \sa userStyleSheetUrl()
*/
-void QWebSettings::setUserStyleSheetLocation(const QUrl &location)
+void QWebSettings::setUserStyleSheetUrl(const QUrl &location)
{
d->userStyleSheetLocation = location;
d->apply();
@@ -256,44 +367,92 @@ void QWebSettings::setUserStyleSheetLocation(const QUrl &location)
/*!
Returns the location of the user stylesheet.
- \sa setUserStyleSheetLocation
+ \sa setUserStyleSheetUrl()
*/
-QUrl QWebSettings::userStyleSheetLocation() const
+QUrl QWebSettings::userStyleSheetUrl() const
{
return d->userStyleSheetLocation;
}
/*!
- Enables or disables the icon database. The icon database is used to store favicons
- associated with web sites.
+ Sets the path of the icon database to \a path. The icon database is used
+ to store "favicons" associated with web sites.
+
+ \a path must point to an existing directory where the icons are stored.
- If \a enabled is true then \a location must be specified and point to an existing directory
- where the icons are stored.
+ Setting an empty path disables the icon database.
*/
-void QWebSettings::setIconDatabaseEnabled(bool enabled, const QString &location)
+void QWebSettings::setIconDatabasePath(const QString &path)
{
- WebCore::iconDatabase()->setEnabled(enabled);
- if (enabled) {
- QFileInfo info(location);
+ WebCore::iconDatabase()->delayDatabaseCleanup();
+
+ if (!path.isEmpty()) {
+ WebCore::iconDatabase()->setEnabled(true);
+ QFileInfo info(path);
if (info.isDir() && info.isWritable())
- WebCore::iconDatabase()->open(location);
+ WebCore::iconDatabase()->open(path);
} else {
+ WebCore::iconDatabase()->setEnabled(false);
WebCore::iconDatabase()->close();
}
}
/*!
- Returns whether the icon database is enabled or not.
+ Returns the path of the icon database or an empty string if the icon
+ database is disabled.
+
+ \sa setIconDatabasePath(), clearIconDatabase()
+*/
+QString QWebSettings::iconDatabasePath()
+{
+ if (WebCore::iconDatabase()->isEnabled() && WebCore::iconDatabase()->isOpen()) {
+ return WebCore::iconDatabase()->databasePath();
+ } else {
+ return QString();
+ }
+}
+
+/*!
+ Clears the icon database.
+*/
+void QWebSettings::clearIconDatabase()
+{
+ if (WebCore::iconDatabase()->isEnabled() && WebCore::iconDatabase()->isOpen())
+ WebCore::iconDatabase()->removeAllIcons();
+}
+
+/*!
+ Returns the web site's icon for \a url.
+
+ If the web site does not specify an icon, or the icon is not in the
+ database, a null QIcon is returned.
+
+ \note The returned icon's size is arbitrary.
- \sa setIconDatabaseEnabled
+ \sa setIconDatabasePath()
*/
-bool QWebSettings::iconDatabaseEnabled()
+QIcon QWebSettings::iconForUrl(const QUrl &url)
{
- return WebCore::iconDatabase()->isEnabled() && WebCore::iconDatabase()->isOpen();
+ WebCore::Image* image = WebCore::iconDatabase()->iconForPageURL(WebCore::KURL(url).string(),
+ WebCore::IntSize(16, 16));
+ if (!image) {
+ return QPixmap();
+ }
+ QPixmap *icon = image->nativeImageForCurrentFrame();
+ if (!icon) {
+ return QPixmap();
+ }
+ return *icon;
}
/*!
- Sets \a graphic to be drawn when QtWebKit needs to drawn an image of the given \a type.
+ Sets \a graphic to be drawn when QtWebKit needs to draw an image of the
+ given \a type.
+
+ For example, when an image cannot be loaded the pixmap specified by
+ \l{QWebSettings::WebGraphic}{MissingImageGraphic} is drawn instead.
+
+ \sa webGraphic()
*/
void QWebSettings::setWebGraphic(WebGraphic type, const QPixmap &graphic)
{
@@ -305,7 +464,13 @@ void QWebSettings::setWebGraphic(WebGraphic type, const QPixmap &graphic)
}
/*!
- Returns a previously set pixmap that is used to draw replacement graphics of the specified \a type.
+ Returns a previously set pixmap used to draw replacement graphics of the
+ specified \a type.
+
+ For example, when an image cannot be loaded the pixmap specified by
+ \l{QWebSettings::WebGraphic}{MissingImageGraphic} is drawn instead.
+
+ \sa setWebGraphic()
*/
QPixmap QWebSettings::webGraphic(WebGraphic type)
{
@@ -313,42 +478,90 @@ QPixmap QWebSettings::webGraphic(WebGraphic type)
}
/*!
- Sets the default font family to \a family for the specified \a type of font.
+ Sets the maximum number of pages to hold in the memory cache to \a pages.
+*/
+void QWebSettings::setMaximumPagesInCache(int pages)
+{
+ WebCore::pageCache()->setCapacity(qMax(0, pages));
+}
+
+/*!
+ Returns the maximum number of web pages that are kept in the memory cache.
+*/
+int QWebSettings::maximumPagesInCache()
+{
+ return WebCore::pageCache()->capacity();
+}
+
+/*!
+ Specifies the capacities for the memory cache for dead objects such as
+ stylesheets or scripts.
+
+ The \a cacheMinDeadCapacity specifies the \e minimum number of bytes that
+ dead objects should consume when the cache is under pressure.
+
+ \a cacheMaxDead is the \e maximum number of bytes that dead objects should
+ consume when the cache is \bold not under pressure.
+
+ \a totalCapacity specifies the \e maximum number of bytes that the cache
+ should consume \bold overall.
+
+ The cache is enabled by default. Calling setObjectCacheCapacities(0, 0, 0)
+ will disable the cache. Calling it with one non-zero enables it again.
+*/
+void QWebSettings::setObjectCacheCapacities(int cacheMinDeadCapacity, int cacheMaxDead, int totalCapacity)
+{
+ bool disableCache = cacheMinDeadCapacity == 0 && cacheMaxDead == 0 && totalCapacity == 0;
+ WebCore::cache()->setDisabled(disableCache);
+
+ WebCore::cache()->setCapacities(qMax(0, cacheMinDeadCapacity),
+ qMax(0, cacheMaxDead),
+ qMax(0, totalCapacity));
+}
+
+/*!
+ Sets the actual font family to \a family for the specified generic family,
+ \a which.
*/
-void QWebSettings::setFontFamily(FontType type, const QString &family)
+void QWebSettings::setFontFamily(FontFamily which, const QString &family)
{
- d->fontFamilies.insert(type, family);
+ d->fontFamilies.insert(which, family);
d->apply();
}
/*!
- Returns the default font family to \a family for the specified \a type of font.
+ Returns the actual font family for the specified generic font family,
+ \a which.
*/
-QString QWebSettings::fontFamily(FontType type) const
+QString QWebSettings::fontFamily(FontFamily which) const
{
QString defaultValue;
if (d->settings) {
- QWebSettingsPrivate *global = QWebSettings::defaultSettings()->d;
- defaultValue = global->fontFamilies.value(type);
+ QWebSettingsPrivate *global = QWebSettings::globalSettings()->d;
+ defaultValue = global->fontFamilies.value(which);
}
- return d->fontFamilies.value(type, defaultValue);
+ return d->fontFamilies.value(which, defaultValue);
}
/*!
- Resets the font family for specified \a type of fonts in a web page to the default.
+ Resets the actual font family to the default font family, specified by
+ \a which.
- This function has not effect on the default QWebSettings instance.
+ This function has no effect on the global QWebSettings instance.
*/
-void QWebSettings::resetFontFamily(FontType type)
+void QWebSettings::resetFontFamily(FontFamily which)
{
if (d->settings) {
- d->fontFamilies.remove(type);
+ d->fontFamilies.remove(which);
d->apply();
}
}
/*!
- Enables or disables the specified \a attr feature depending on the value of \a on.
+ \fn void QWebSettings::setAttribute(WebAttribute attribute, bool on)
+
+ Enables or disables the specified \a attribute feature depending on the
+ value of \a on.
*/
void QWebSettings::setAttribute(WebAttribute attr, bool on)
{
@@ -357,24 +570,29 @@ void QWebSettings::setAttribute(WebAttribute attr, bool on)
}
/*!
- Returns true if \a attr is enabled; false otherwise.
+ \fn bool QWebSettings::testAttribute(WebAttribute attribute) const
+
+ Returns true if \a attribute is enabled; otherwise returns false.
*/
bool QWebSettings::testAttribute(WebAttribute attr) const
{
bool defaultValue = false;
if (d->settings) {
- QWebSettingsPrivate *global = QWebSettings::defaultSettings()->d;
+ QWebSettingsPrivate *global = QWebSettings::globalSettings()->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.
+ \fn void QWebSettings::resetAttribute(WebAttribute attribute)
+
+ Resets the setting of \a attribute.
+ This function has no effect on the global QWebSettings instance.
- This function has not effect on the default QWebSettings instance.
+ \sa globalSettings()
*/
-void QWebSettings::clearAttribute(WebAttribute attr)
+void QWebSettings::resetAttribute(WebAttribute attr)
{
if (d->settings) {
d->attributes.remove(attr);
diff --git a/WebKit/qt/Api/qwebsettings.h b/WebKit/qt/Api/qwebsettings.h
index c071e51..9a75dbf 100644
--- a/WebKit/qt/Api/qwebsettings.h
+++ b/WebKit/qt/Api/qwebsettings.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2007 Trolltech ASA
+ Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -15,33 +15,33 @@
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 "qwebkitglobal.h"
#include <QtCore/qstring.h>
#include <QtGui/qpixmap.h>
+#include <QtGui/qicon.h>
#include <QtCore/qshareddata.h>
namespace WebCore
{
class Settings;
-};
+}
class QWebPage;
class QWebSettingsPrivate;
+QT_BEGIN_NAMESPACE
class QUrl;
+QT_END_NAMESPACE
class QWEBKIT_EXPORT QWebSettings
{
public:
- enum FontType {
+ enum FontFamily {
StandardFont,
FixedFont,
SerifFont,
@@ -58,13 +58,14 @@ public:
JavascriptCanOpenWindows,
JavascriptCanAccessClipboard,
DeveloperExtrasEnabled,
- LinksIncludedInFocusChain
+ LinksIncludedInFocusChain,
+ ZoomTextOnly
};
enum WebGraphic {
MissingImageGraphic,
MissingPluginGraphic,
- DefaultFaviconGraphic,
- TextAreaResizeCornerGraphic
+ DefaultFrameIconGraphic,
+ TextAreaSizeGripCornerGraphic
};
enum FontSize {
MinimumFontSize,
@@ -73,29 +74,35 @@ public:
DefaultFixedFontSize
};
- static QWebSettings *defaultSettings();
+ static QWebSettings *globalSettings();
- void setFontFamily(FontType type, const QString &family);
- QString fontFamily(FontType type) const;
- void resetFontFamily(FontType type);
+ void setFontFamily(FontFamily which, const QString &family);
+ QString fontFamily(FontFamily which) const;
+ void resetFontFamily(FontFamily which);
void setFontSize(FontSize type, int size);
int fontSize(FontSize type) const;
void resetFontSize(FontSize type);
- void setAttribute(WebAttribute attr, bool on = true);
+ void setAttribute(WebAttribute attr, bool on);
bool testAttribute(WebAttribute attr) const;
- void clearAttribute(WebAttribute attr);
+ void resetAttribute(WebAttribute attr);
- void setUserStyleSheetLocation(const QUrl &location);
- QUrl userStyleSheetLocation() const;
+ void setUserStyleSheetUrl(const QUrl &location);
+ QUrl userStyleSheetUrl() const;
- static void setIconDatabaseEnabled(bool enabled, const QString &location = QString());
- static bool iconDatabaseEnabled();
+ static void setIconDatabasePath(const QString &location);
+ static QString iconDatabasePath();
+ static void clearIconDatabase();
+ static QIcon iconForUrl(const QUrl &url);
static void setWebGraphic(WebGraphic type, const QPixmap &graphic);
static QPixmap webGraphic(WebGraphic type);
+ static void setMaximumPagesInCache(int pages);
+ static int maximumPagesInCache();
+ static void setObjectCacheCapacities(int cacheMinDeadCapacity, int cacheMaxDead, int totalCapacity);
+
private:
friend class QWebPagePrivate;
friend class QWebSettingsPrivate;
diff --git a/WebKit/qt/Api/qwebview.cpp b/WebKit/qt/Api/qwebview.cpp
index 3d67437..ad0b12a 100644
--- a/WebKit/qt/Api/qwebview.cpp
+++ b/WebKit/qt/Api/qwebview.cpp
@@ -1,5 +1,6 @@
/*
- Copyright (C) 2007 Trolltech ASA
+ Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2008 Holger Hans Peter Freyther
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -20,36 +21,148 @@
#include "config.h"
#include "qwebview.h"
#include "qwebframe.h"
+#include "qwebpage_p.h"
+
+#include "qbitmap.h"
#include "qevent.h"
#include "qpainter.h"
+#include "qprinter.h"
class QWebViewPrivate
{
public:
+ QWebViewPrivate(QWebView *view)
+ : view(view)
+ , page(0)
+#ifndef QT_NO_CURSOR
+ , cursorSetByWebCore(false)
+ , usesWebCoreCursor(true)
+#endif
+ {}
+
+ QWebView *view;
QWebPage *page;
+
+
+#ifndef QT_NO_CURSOR
+ /*
+ * We keep track of if we have called setCursor and if the CursorChange
+ * event is sent due our setCursor call and if we currently use the WebCore
+ * Cursor and use it to decide if we can update to another WebCore Cursor.
+ */
+ bool cursorSetByWebCore;
+ bool usesWebCoreCursor;
+
+ void setCursor(const QCursor& newCursor)
+ {
+ webCoreCursor = newCursor;
+
+ if (usesWebCoreCursor) {
+ cursorSetByWebCore = true;
+ view->setCursor(webCoreCursor);
+ }
+ }
+
+ QCursor webCoreCursor;
+#endif
};
/*!
\class QWebView
\since 4.4
- \brief The QWebView class provides a widget that is used to view and edit web documents.
+ \brief The QWebView class provides a widget that is used to view and edit
+ web documents.
+ \ingroup advanced
QWebView is the main widget component of the QtWebKit web browsing module.
+ It can be used in various applications to display web content live from the
+ Internet.
+
+ The image below shows QWebView previewed in \QD with the Trolltech website.
+
+ \image qwebview-url.png
+
+ A web site can be loaded onto QWebView with the load() function. Like all
+ Qt Widgets, the show() function must be invoked in order to display
+ QWebView. The snippet below illustrates this:
+
+ \snippet doc/src/snippets/webkit/simple/main.cpp Using QWebView
+
+ Alternatively, setUrl() can also be used to load a web site. If you have
+ the HTML content readily available, you can use setHtml() instead.
+
+ The loadStarted() signal is emitted when the view begins loading. The
+ loadProgress() signal, on the other hand, is emitted whenever an element of
+ the web view completes loading, such as an embedded image, a script, etc.
+ Finally, the loadFinished() signal is emitted when the view has loaded
+ completely. It's argument - either \c true or \c false - indicates
+ load success or failure.
+
+ The page() function returns a pointer to the web page object. See
+ \l{Elements of QWebView} for an explanation of how the web page
+ is related to the view. To modify your web view's settings, you can access
+ the QWebSettings object with the settings() function. With QWebSettings,
+ you can change the default fonts, enable or disable features such as
+ JavaScript and plugins.
+
+ The title of an HTML document can be accessed with the title() property.
+ Additionally, a web site may also specify an icon, which can be accessed
+ using the icon() property. If the title or the icon changes, the corresponding
+ titleChanged() and iconChanged() signals will be emitted. The
+ textSizeMultiplier() property can be used to change the overall size of
+ the text displayed in the web view.
+
+ If you require a custom context menu, you can implement it by reimplementing
+ \l{QWidget::}{contextMenuEvent()} and populating your QMenu with the actions
+ obtained from pageAction(). More functionality such as reloading the view,
+ copying selected text to the clipboard, or pasting into the view, is also
+ encapsulated within the QAction objects returned by pageAction(). These
+ actions can be programmatically triggered using triggerPageAction().
+ Alternatively, the actions can be added to a toolbar or a menu directly.
+ QWebView maintains the state of the returned actions but allows
+ modification of action properties such as \l{QAction::}{text} or
+ \l{QAction::}{icon}.
+
+ A QWebView can be printed onto a QPrinter using the print() function.
+ This function is marked as a slot and can be conveniently connected to
+ \l{QPrintPreviewDialog}'s \l{QPrintPreviewDialog::}{paintRequested()}
+ signal.
+
+ If you want to provide support for web sites that allow the user to open
+ new windows, such as pop-up windows, you can subclass QWebView and
+ reimplement the createWindow() function.
+
+ \section1 Elements of QWebView
+
+ QWebView consists of other objects such as QWebFrame and QWebPage. The
+ flowchart below shows these elements are related.
+
+ \image qwebview-diagram.png
+
+ \note It is possible to use QWebPage and QWebFrame, without using QWebView,
+ if you do not require QWidget attributes. Nevertheless, QtWebKit depends
+ on QtGui, so you should use a QApplication instead of QCoreApplication.
+
+ \sa {Previewer Example}, {Browser}
*/
/*!
Constructs an empty QWebView with parent \a parent.
+
+ \sa load()
*/
QWebView::QWebView(QWidget *parent)
: QWidget(parent)
{
- d = new QWebViewPrivate;
- d->page = 0;
+ d = new QWebViewPrivate(this);
QPalette pal = palette();
pal.setBrush(QPalette::Background, Qt::white);
setAttribute(Qt::WA_OpaquePaintEvent);
+#if !defined(Q_WS_QWS)
+ setAttribute(Qt::WA_InputMethodEnabled);
+#endif
setPalette(pal);
setAcceptDrops(true);
@@ -59,10 +172,13 @@ QWebView::QWebView(QWidget *parent)
}
/*!
- Destructor.
+ Destroys the web view.
*/
QWebView::~QWebView()
{
+ if (d->page)
+ d->page->d->view = 0;
+
if (d->page && d->page->parent() == this)
delete d->page;
delete d;
@@ -87,7 +203,7 @@ QWebPage *QWebView::page() const
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.
+ view, it will be deleted.
\sa page()
*/
@@ -105,36 +221,58 @@ void QWebView::setPage(QWebPage *page)
d->page = page;
if (d->page) {
d->page->setView(this);
+ d->page->setPalette(palette());
// #### 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(iconChanged()),
+ this, SIGNAL(iconChanged()));
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 &)));
+ connect(d->page, SIGNAL(loadStarted()),
+ this, SIGNAL(loadStarted()));
+ connect(d->page, SIGNAL(loadProgress(int)),
+ this, SIGNAL(loadProgress(int)));
+ connect(d->page, SIGNAL(loadFinished(bool)),
+ this, SIGNAL(loadFinished(bool)));
+ connect(d->page, SIGNAL(statusBarMessage(const QString &)),
+ this, SIGNAL(statusBarMessage(const QString &)));
+ connect(d->page, SIGNAL(linkClicked(const QUrl &)),
+ this, SIGNAL(linkClicked(const QUrl &)));
+
+ connect(d->page, SIGNAL(microFocusChanged()),
+ this, SLOT(updateMicroFocus()));
}
update();
}
/*!
- Downloads the specified \a url and displays it.
+ Loads the specified \a url and displays it.
+
+ \note The view remains the same until enough data has arrived to display the new \a url.
+
+ \sa setUrl(), url(), urlChanged()
*/
void QWebView::load(const QUrl &url)
{
page()->mainFrame()->load(url);
}
-#if QT_VERSION < 0x040400
+/*!
+ \fn void QWebView::load(const QNetworkRequest &request, QNetworkAccessManager::Operation operation, const QByteArray &body)
+
+ Loads a network request, \a request, using the method specified in \a operation.
+
+ \a body is optional and is only used for POST operations.
+
+ \note The view remains the same until enough data has arrived to display the new url.
+
+ \sa url(), urlChanged()
+*/
+
+#if QT_VERSION < 0x040400 && !defined(qdoc)
void QWebView::load(const QWebNetworkRequest &request)
#else
void QWebView::load(const QNetworkRequest &request,
@@ -152,28 +290,30 @@ void QWebView::load(const QNetworkRequest &request,
/*!
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);
-}
+ External objects referenced in the HTML document are located relative to
+ \a baseUrl.
-/*!
- Sets the content of the web view to the specified \a html.
+ When using this method, WebKit assumes that external resources such as
+ JavaScript programs or style sheets are encoded in UTF-8 unless otherwise
+ specified. For example, the encoding of an external script can be specified
+ through the charset attribute of the HTML script tag. Alternatively, the
+ encoding can also be specified by the web server.
- External objects referenced in the HTML document are located relative to \a baseUrl.
+ \sa load(), setContent(), QWebFrame::toHtml()
*/
-void QWebView::setHtml(const QByteArray &html, const QUrl &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 content \a data. If the \a mimeType argument
- is empty it is assumed that the content is HTML.
+ is empty it is currently assumed that the content is HTML but in future versions we may introduce
+ auto-detection.
- External objects referenced in the HTML document are located relative to \a baseUrl.
+ External objects referenced in the content are located relative to \a baseUrl.
+
+ \sa load(), setHtml(), QWebFrame::toHtml()
*/
void QWebView::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
{
@@ -185,7 +325,7 @@ void QWebView::setContent(const QByteArray &data, const QString &mimeType, const
It is equivalent to
- \snippet doc/src/snippets/code/src.3rdparty.webkit.WebKit.qt.Api.qwebview.cpp 0
+ \snippet doc/src/snippets/code/src_3rdparty_webkit_WebKit_qt_Api_qwebview.cpp 0
*/
QWebHistory *QWebView::history() const
{
@@ -197,7 +337,9 @@ QWebHistory *QWebView::history() const
It is equivalent to
- \snippet doc/src/snippets/code/src.3rdparty.webkit.WebKit.qt.Api.qwebview.cpp 1
+ \snippet doc/src/snippets/code/src_3rdparty_webkit_WebKit_qt_Api_qwebview.cpp 1
+
+ \sa QWebSettings::globalSettings()
*/
QWebSettings *QWebView::settings() const
{
@@ -205,8 +347,12 @@ QWebSettings *QWebView::settings() const
}
/*!
- \property QWebView::title
- \brief the title of the web page currently viewed.
+ \property QWebView::title
+ \brief the title of the web page currently viewed
+
+ By default, this property contains an empty string.
+
+ \sa titleChanged()
*/
QString QWebView::title() const
{
@@ -217,8 +363,20 @@ QString QWebView::title() const
/*!
\property QWebView::url
- \brief the url of the web page currently viewed.
+ \brief the url of the web page currently viewed
+
+ Setting this property clears the view and loads the URL.
+
+ By default, this property contains an empty, invalid URL.
+
+ \sa load(), urlChanged()
*/
+
+void QWebView::setUrl(const QUrl &url)
+{
+ page()->mainFrame()->setUrl(url);
+}
+
QUrl QWebView::url() const
{
if (d->page)
@@ -228,18 +386,26 @@ QUrl QWebView::url() const
/*!
\property QWebView::icon
- \brief the icon associated with the web page currently viewed.
+ \brief the icon associated with the web page currently viewed
+
+ By default, this property contains a null icon.
+
+ \sa iconChanged(), QWebSettings::iconForUrl()
*/
-QPixmap QWebView::icon() const
+QIcon QWebView::icon() const
{
if (d->page)
return d->page->mainFrame()->icon();
- return QPixmap();
+ return QIcon();
}
/*!
\property QWebView::selectedText
- \brief the text currently selected.
+ \brief the text currently selected
+
+ By default, this property contains an empty string.
+
+ \sa findText(), selectionChanged()
*/
QString QWebView::selectedText() const
{
@@ -251,19 +417,23 @@ QString QWebView::selectedText() const
/*!
Returns a pointer to a QAction that encapsulates the specified web action \a action.
*/
-QAction *QWebView::action(QWebPage::WebAction action) const
+QAction *QWebView::pageAction(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.
+ 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.
- 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
- \snippet doc/src/snippets/code/src.3rdparty.webkit.WebKit.qt.Api.qwebview.cpp 2
+ \sa pageAction()
*/
-void QWebView::triggerAction(QWebPage::WebAction action, bool checked)
+void QWebView::triggerPageAction(QWebPage::WebAction action, bool checked)
{
page()->triggerAction(action, checked);
}
@@ -272,8 +442,10 @@ void QWebView::triggerAction(QWebPage::WebAction action, bool 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.
+ Parts of HTML documents can be editable for example through the
+ \c{contenteditable} attribute on HTML elements.
+
+ By default, this property is false.
*/
bool QWebView::isModified() const
{
@@ -282,24 +454,28 @@ bool QWebView::isModified() const
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
@@ -310,11 +486,120 @@ QSize QWebView::sizeHint() const
}
/*!
+ \property QWebView::zoomFactor
+ \since 4.5
+ \brief the zoom factor for the view
+*/
+
+void QWebView::setZoomFactor(qreal factor)
+{
+ page()->mainFrame()->setZoomFactor(factor);
+}
+
+qreal QWebView::zoomFactor() const
+{
+ return page()->mainFrame()->zoomFactor();
+}
+
+/*!
+ \property QWebView::textSizeMultiplier
+ \brief the scaling factor for all text in the frame
+ \obsolete
+
+ Use setZoomFactor instead, in combination with the
+ ZoomTextOnly attribute in QWebSettings.
+
+ \note Setting this property also enables the
+ ZoomTextOnly attribute in QWebSettings.
+
+ By default, this property contains a value of 1.0.
+*/
+
+void QWebView::setTextSizeMultiplier(qreal factor)
+{
+ page()->mainFrame()->setTextSizeMultiplier(factor);
+}
+
+qreal QWebView::textSizeMultiplier() const
+{
+ return page()->mainFrame()->textSizeMultiplier();
+}
+
+/*!
+ Finds the next occurrence of the string, \a subString, in the page, using
+ the given \a options. Returns true of \a subString was found and selects
+ the match visually; otherwise returns false.
+
+ \sa selectedText(), selectionChanged()
+*/
+bool QWebView::findText(const QString &subString, QWebPage::FindFlags options)
+{
+ if (d->page)
+ return d->page->findText(subString, options);
+ return false;
+}
+
+/*! \reimp
+*/
+bool QWebView::event(QEvent *e)
+{
+ if (d->page) {
+#ifndef QT_NO_CONTEXTMENU
+ if (e->type() == QEvent::ContextMenu) {
+ QContextMenuEvent *event = static_cast<QContextMenuEvent *>(e);
+ if (d->page->swallowContextMenuEvent(event)) {
+ e->accept();
+ return true;
+ }
+ d->page->updatePositionDependentActions(event->pos());
+ } else
+#endif // QT_NO_CONTEXTMENU
+ if (e->type() == QEvent::ShortcutOverride) {
+ d->page->event(e);
+#ifndef QT_NO_CURSOR
+ } else if (e->type() == static_cast<QEvent::Type>(WebCore::SetCursorEvent::EventType)) {
+ d->setCursor(static_cast<WebCore::SetCursorEvent*>(e)->cursor());
+#if QT_VERSION >= 0x040400
+ } else if (e->type() == QEvent::CursorChange) {
+ // Okay we might use the WebCore Cursor now.
+ d->usesWebCoreCursor = d->cursorSetByWebCore;
+ d->cursorSetByWebCore = false;
+
+ // Go back to the WebCore Cursor. QWidget::unsetCursor is appromixated with this
+ if (!d->usesWebCoreCursor && cursor().shape() == Qt::ArrowCursor) {
+ d->usesWebCoreCursor = true;
+ d->setCursor(d->webCoreCursor);
+ }
+#endif
+#endif
+ } else if (e->type() == QEvent::Leave) {
+ d->page->event(e);
+ }
+ }
+
+ return QWidget::event(e);
+}
+
+/*!
+ Prints the main frame to the given \a printer.
+
+ \sa QWebFrame::print(), QPrintPreviewDialog
+*/
+void QWebView::print(QPrinter *printer) const
+{
+#ifndef QT_NO_PRINTER
+ page()->mainFrame()->print(printer);
+#endif
+}
+
+/*!
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
+ \snippet doc/src/snippets/code/src_3rdparty_webkit_WebKit_qt_Api_qwebview.cpp 3
+
+ \sa reload(), pageAction(), loadFinished()
*/
void QWebView::stop()
{
@@ -323,37 +608,41 @@ void QWebView::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.
+ 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
+ \snippet doc/src/snippets/code/src_3rdparty_webkit_WebKit_qt_Api_qwebview.cpp 4
+
+ \sa forward(), pageAction()
*/
-void QWebView::backward()
+void QWebView::back()
{
if (d->page)
- d->page->triggerAction(QWebPage::GoBack);
+ d->page->triggerAction(QWebPage::Back);
}
/*!
- Convenience slot that loads the next document in the list of
- documents built by navigating links. Does nothing if there is no
- next document.
+ 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
+ \snippet doc/src/snippets/code/src_3rdparty_webkit_WebKit_qt_Api_qwebview.cpp 5
+
+ \sa back(), pageAction()
*/
void QWebView::forward()
{
if (d->page)
- d->page->triggerAction(QWebPage::GoForward);
+ d->page->triggerAction(QWebPage::Forward);
}
/*!
Reloads the current document.
+
+ \sa stop(), pageAction(), loadStarted()
*/
void QWebView::reload()
{
@@ -392,11 +681,14 @@ void QWebView::paintEvent(QPaintEvent *ev)
}
/*!
- This function is called whenever WebKit wants to create a new window, for example as a result of
+ This function is called whenever WebKit wants to create a new window of the given \a type, for example as a result of
a JavaScript request to open a document in a new window.
+
+ \sa QWebPage::createWindow()
*/
-QWebView *QWebView::createWindow()
+QWebView *QWebView::createWindow(QWebPage::WebWindowType type)
{
+ Q_UNUSED(type)
return 0;
}
@@ -404,52 +696,71 @@ QWebView *QWebView::createWindow()
*/
void QWebView::mouseMoveEvent(QMouseEvent* ev)
{
- if (d->page)
+ if (d->page) {
+ const bool accepted = ev->isAccepted();
d->page->event(ev);
+ ev->setAccepted(accepted);
+ }
}
/*! \reimp
*/
void QWebView::mousePressEvent(QMouseEvent* ev)
{
- if (d->page)
+ if (d->page) {
+ const bool accepted = ev->isAccepted();
d->page->event(ev);
+ ev->setAccepted(accepted);
+ }
}
/*! \reimp
*/
void QWebView::mouseDoubleClickEvent(QMouseEvent* ev)
{
- if (d->page)
+ if (d->page) {
+ const bool accepted = ev->isAccepted();
d->page->event(ev);
+ ev->setAccepted(accepted);
+ }
}
/*! \reimp
*/
void QWebView::mouseReleaseEvent(QMouseEvent* ev)
{
- if (d->page)
+ if (d->page) {
+ const bool accepted = ev->isAccepted();
d->page->event(ev);
+ ev->setAccepted(accepted);
+ }
}
+#ifndef QT_NO_CONTEXTMENU
/*! \reimp
*/
void QWebView::contextMenuEvent(QContextMenuEvent* ev)
{
- if (d->page)
+ if (d->page) {
+ const bool accepted = ev->isAccepted();
d->page->event(ev);
+ ev->setAccepted(accepted);
+ }
}
+#endif // QT_NO_CONTEXTMENU
+#ifndef QT_NO_WHEELEVENT
/*! \reimp
*/
void QWebView::wheelEvent(QWheelEvent* ev)
{
- if (d->page)
+ if (d->page) {
+ const bool accepted = ev->isAccepted();
d->page->event(ev);
-
- if (!ev->isAccepted())
- return QWidget::wheelEvent(ev);
+ ev->setAccepted(accepted);
+ }
}
+#endif // QT_NO_WHEELEVENT
/*! \reimp
*/
@@ -477,16 +788,18 @@ void QWebView::focusInEvent(QFocusEvent* ev)
{
if (d->page)
d->page->event(ev);
- QWidget::focusInEvent(ev);
+ else
+ QWidget::focusInEvent(ev);
}
/*! \reimp
*/
void QWebView::focusOutEvent(QFocusEvent* ev)
{
- QWidget::focusOutEvent(ev);
if (d->page)
d->page->event(ev);
+ else
+ QWidget::focusOutEvent(ev);
}
/*! \reimp
@@ -538,56 +851,107 @@ bool QWebView::focusNextPrevChild(bool next)
return QWidget::focusNextPrevChild(next);
}
+/*!\reimp
+*/
+QVariant QWebView::inputMethodQuery(Qt::InputMethodQuery property) const
+{
+ if (d->page)
+ return d->page->inputMethodQuery(property);
+ return QVariant();
+}
+
+/*!\reimp
+*/
+void QWebView::inputMethodEvent(QInputMethodEvent *e)
+{
+ if (d->page)
+ d->page->event(e);
+}
+
+/*!\reimp
+*/
+void QWebView::changeEvent(QEvent *e)
+{
+ if (d->page && e->type() == QEvent::PaletteChange) {
+ d->page->setPalette(palette());
+ }
+ QWidget::changeEvent(e);
+}
+
/*!
- \fn void QWebView::titleChanged(const QString &title)
+ \fn void QWebView::titleChanged(const QString &title)
- This signal is emitted whenever the \a title of the main frame changes.
+ This signal is emitted whenever the \a title of the main frame changes.
- \sa title()
+ \sa title()
*/
/*!
- \fn void QWebView::urlChanged(const QUrl &url)
+ \fn void QWebView::urlChanged(const QUrl &url)
- This signal is emitted whenever the \a url of the main frame changes.
+ This signal is emitted when the \a url of the view changes.
- \sa url()
+ \sa url(), load()
*/
/*!
- \fn void QWebView::statusBarTextChanged(const QString& text)
+ \fn void QWebView::statusBarMessage(const QString& text)
This signal is emitted when the statusbar \a text is changed by the page.
*/
/*!
- \fn void QWebView::iconLoaded()
+ \fn void QWebView::iconChanged()
This signal is emitted whenever the icon of the page is loaded or changes.
+
+ \sa icon()
*/
/*!
\fn void QWebView::loadStarted()
- This signal is emitted when a new load of the frame is started.
+ This signal is emitted when a new load of the page is started.
+
+ \sa loadProgress(), loadFinished()
*/
/*!
- \fn void QWebView::loadFinished()
+ \fn void QWebView::loadFinished(bool ok)
- This signal is emitted when a load of the frame is finished.
+ This signal is emitted when a load of the page is finished.
+ \a ok will indicate whether the load was successful or any error occurred.
+
+ \sa loadStarted()
*/
/*!
\fn void QWebView::selectionChanged()
This signal is emitted whenever the selection changes.
+
+ \sa selectedText()
+*/
+
+/*!
+ \fn void QWebView::loadProgress(int progress)
+
+ This signal is emitted every time an element in the web page
+ completes loading and the overall loading progress advances.
+
+ This signal tracks the progress of all child frames.
+
+ The current value is provided by \a progress and scales from 0 to 100,
+ which is the default range of QProgressBar.
+
+ \sa loadStarted(), loadFinished()
*/
/*!
- \fn void QWebView::loadProgressChanged(int progress)
+ \fn void QWebView::linkClicked(const QUrl &url)
+
+ This signal is emitted whenever the user clicks on a link and the page's linkDelegationPolicy
+ property is set to delegate the link handling for the specified \a url.
- 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.
+ \sa QWebPage::linkDelegationPolicy()
*/
diff --git a/WebKit/qt/Api/qwebview.h b/WebKit/qt/Api/qwebview.h
index 53043ae..1172f39 100644
--- a/WebKit/qt/Api/qwebview.h
+++ b/WebKit/qt/Api/qwebview.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2007 Trolltech ASA
+ Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
Copyright (C) 2007 Staikos Computing Services Inc.
This library is free software; you can redistribute it and/or
@@ -17,31 +17,39 @@
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 <QtGui/qicon.h>
#include <QtCore/qurl.h>
#if QT_VERSION >= 0x040400
#include <QtNetwork/qnetworkaccessmanager.h>
#endif
+QT_BEGIN_NAMESPACE
+class QNetworkRequest;
+class QPrinter;
+QT_END_NAMESPACE
+
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(QUrl url READ url WRITE setUrl)
+ Q_PROPERTY(QIcon icon READ icon)
Q_PROPERTY(QString selectedText READ selectedText)
Q_PROPERTY(bool modified READ isModified)
- Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
+ //Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
+ Q_PROPERTY(qreal textSizeMultiplier READ textSizeMultiplier WRITE setTextSizeMultiplier DESIGNABLE false)
+ Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor)
public:
explicit QWebView(QWidget *parent = 0);
virtual ~QWebView();
@@ -50,7 +58,7 @@ public:
void setPage(QWebPage *page);
void load(const QUrl &url);
-#if QT_VERSION < 0x040400
+#if QT_VERSION < 0x040400 && !defined(qdoc)
void load(const QWebNetworkRequest &request);
#else
void load(const QNetworkRequest &request,
@@ -58,64 +66,79 @@ public:
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;
+ void setUrl(const QUrl &url);
QUrl url() const;
- QPixmap icon() const;
+ QIcon icon() const;
QString selectedText() const;
- QAction *action(QWebPage::WebAction action) const;
- void triggerAction(QWebPage::WebAction action, bool checked = false);
+ QAction *pageAction(QWebPage::WebAction action) const;
+ void triggerPageAction(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);
+ void setTextInteractionFlag(Qt::TextInteractionFlag flag);
*/
+ QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
+
QSize sizeHint() const;
+
+ qreal zoomFactor() const;
+ void setZoomFactor(qreal factor);
+
+ void setTextSizeMultiplier(qreal factor);
+ qreal textSizeMultiplier() const;
+
+ bool findText(const QString &subString, QWebPage::FindFlags options = 0);
+
+ virtual bool event(QEvent *);
+
public Q_SLOTS:
void stop();
- void backward();
+ void back();
void forward();
void reload();
+ void print(QPrinter *printer) const;
+
Q_SIGNALS:
void loadStarted();
- void loadProgressChanged(int progress);
- void loadFinished();
+ void loadProgress(int progress);
+ void loadFinished(bool);
void titleChanged(const QString& title);
- void statusBarTextChanged(const QString& text);
+ void statusBarMessage(const QString& text);
void linkClicked(const QUrl &url);
void selectionChanged();
- void iconLoaded();
+ void iconChanged();
void urlChanged(const QUrl &url);
protected:
void resizeEvent(QResizeEvent *e);
void paintEvent(QPaintEvent *ev);
- virtual QWebView *createWindow();
+ virtual QWebView *createWindow(QWebPage::WebWindowType type);
+ virtual void changeEvent(QEvent*);
virtual void mouseMoveEvent(QMouseEvent*);
virtual void mousePressEvent(QMouseEvent*);
virtual void mouseDoubleClickEvent(QMouseEvent*);
virtual void mouseReleaseEvent(QMouseEvent*);
+#ifndef QT_NO_CONTEXTMENU
virtual void contextMenuEvent(QContextMenuEvent*);
+#endif
+#ifndef QT_NO_WHEELEVENT
virtual void wheelEvent(QWheelEvent*);
+#endif
virtual void keyPressEvent(QKeyEvent*);
virtual void keyReleaseEvent(QKeyEvent*);
virtual void dragEnterEvent(QDragEnterEvent *);
@@ -124,6 +147,7 @@ protected:
virtual void dropEvent(QDropEvent *);
virtual void focusInEvent(QFocusEvent*);
virtual void focusOutEvent(QFocusEvent*);
+ virtual void inputMethodEvent(QInputMethodEvent*);
virtual bool focusNextPrevChild(bool next);
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index 6caa002..3186068 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,3540 @@
+2008-10-24 Yael Aharon <yael.aharon@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Add userData() and setUserData() to QWebHistoryItem.
+ Add setMaximumItemCount() and maximumItemCount() to QWebHistory.
+ Add currentItemIndex() to QWebHistory.
+
+ See also https://bugs.webkit.org/show_bug.cgi?id=21864
+
+ Small cleanup by Simon (docs and forward declaration of QWebHistoryItem in qwebframe.h)
+
+ * Api/qwebframe.h:
+ * Api/qwebhistory.cpp:
+ (QWebHistoryItem::userData):
+ (QWebHistoryItem::setUserData):
+ (QWebHistory::currentItemIndex):
+ (QWebHistory::maximumItemCount):
+ (QWebHistory::setMaximumItemCount):
+ * Api/qwebhistory.h:
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::saveViewStateToItem):
+ * tests/qwebpage/tst_qwebpage.cpp:
+ (tst_QWebPage::modified):
+
+2008-11-03 Cameron Zwarich <zwarich@apple.com>
+
+ Rubber-stamped by Maciej Stachowiak.
+
+ Move more files into the runtime subdirectory of JavaScriptCore.
+
+ * Api/qwebpage.cpp:
+
+2008-10-25 Jade Han <jade.han@nokia.com>
+
+ Reviewed by Anders.
+
+ Enable custom properties for Qt runtime objects in QtWebKit
+
+ https://bugs.webkit.org/show_bug.cgi?id=21813
+
+ * tests/qwebframe/tst_qwebframe.cpp:
+
+2008-10-24 Sam Weinig <sam@webkit.org>
+
+ Another Qt build fix.
+
+ * WebCoreSupport/ChromeClientQt.cpp:
+
+2008-10-24 Sam Weinig <sam@webkit.org>
+
+ Reviewed by Dan Bernstein.
+
+ Fix https://bugs.webkit.org/show_bug.cgi?id=21759
+ Layering violation: FileChooser should not depend on Document/Frame/Page
+
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::runOpenPanel):
+ * WebCoreSupport/ChromeClientQt.h:
+
+2008-10-24 Timothy Hatcher <timothy@apple.com>
+
+ Stub out new InspectorClient methods.
+
+ https://bugs.webkit.org/show_bug.cgi?id=21856
+
+ Reviewed by Darin Adler.
+
+ * WebCoreSupport/InspectorClientQt.cpp:
+ (WebCore::InspectorClientQt::populateSetting): Not implemented.
+ (WebCore::InspectorClientQt::storeSetting): Ditto.
+ (WebCore::InspectorClientQt::removeSetting): Ditto.
+ * WebCoreSupport/InspectorClientQt.h:
+
+2008-10-24 Darin Adler <darin@apple.com>
+
+ - finish rolling out https://bugs.webkit.org/show_bug.cgi?id=21732
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::evaluateJavaScript): Use JSValue* instead of JSValuePtr.
+
+2008-10-23 Yael Aharon <yael.aharon@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Invalid history entries could cause a crash in QT Webkit
+
+ * Api/qwebhistory.cpp:
+ (QWebHistoryItem::originalUrl):
+ (QWebHistoryItem::url):
+ (QWebHistoryItem::title):
+ (QWebHistoryItem::lastVisited):
+ (QWebHistoryItem::icon):
+ (QWebHistoryItem::isValid):
+ * Api/qwebhistory.h:
+ * Api/qwebhistory_p.h:
+ (QWebHistoryItemPrivate::QWebHistoryItemPrivate):
+ (QWebHistoryItemPrivate::~QWebHistoryItemPrivate):
+ * tests/qwebpage/tst_qwebpage.cpp:
+ (tst_QWebPage::modified):
+
+2008-10-22 Yael Aharon <yael.aharon@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ emit scrollRequested unconditionally when scrolling.
+
+ See https://bugs.webkit.org/show_bug.cgi?id=21790
+
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::scroll):
+
+2008-10-23 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Tor Arne.
+
+ Fix handling of mouse events when embedding QWebView into the
+ QGraphicsView.
+
+ QWebPage accepts or ignores events to indicate whether the web page
+ handled the event. However for QWebView to behave like a good widget
+ it should always accept the mouse events to indicate that it handled
+ them and that they should not be subject to event propagation.
+
+ The graphics view relies on acceptance of the initial mouse click to
+ make the embedded widget the focus item.
+
+ * Api/qwebview.cpp:
+ (QWebView::mouseMoveEvent):
+ (QWebView::mousePressEvent):
+ (QWebView::mouseDoubleClickEvent):
+ (QWebView::mouseReleaseEvent):
+ (QWebView::contextMenuEvent):
+ (QWebView::wheelEvent):
+
+2008-10-22 Ariya Hidayat <ariya.hidayat@trolltech.com>
+
+ Reviewed by Simon Hausmann.
+
+ For public API, use the term boundingRect instead of boundingBox.
+
+ * Api/qwebframe.cpp:
+ (QWebHitTestResultPrivate::QWebHitTestResultPrivate):
+ (QWebHitTestResult::boundingRect):
+ * Api/qwebframe.h:
+ * Api/qwebframe_p.h:
+
+2008-06-03 Siraj Razick <siraj.razick@collabora.co.uk>
+
+ Reviewed by Simon Hausmann.
+
+ https://bugs.webkit.org/show_bug.cgi?id=19374
+
+ Expose boundingBox value in QWebHitTestResult
+
+ Add API function QRect QWebHitResult::boundingBox() const
+
+ API docs by Ariya.
+
+ * Api/qwebframe.cpp:
+ (QWebHitTestResultPrivate::QWebHitTestResultPrivate):
+ (QWebHitTestResult::boundingBox):
+ * Api/qwebframe.h:
+ * Api/qwebframe_p.h:
+
+2008-10-21 Yael Aharon <yael.aharon@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ emit repaintRequested unconditionally when repaint is requested.
+
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::repaint):
+
+2008-10-20 Sam Weinig <sam@webkit.org>
+
+ Reviewed by Anders Carlsson.
+
+ Remove FrameLoaderClient::detachedFromParent4. It is no longer used by any port.
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ * WebCoreSupport/FrameLoaderClientQt.h:
+
+2008-10-19 Darin Adler <darin@apple.com>
+
+ Reviewed by Oliver Hunt.
+
+ - next step of https://bugs.webkit.org/show_bug.cgi?id=21732
+ improve performance by eliminating JSValue as a base class for JSCell
+
+ Remove most uses of JSValue, which will be removed in a future patch.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::evaluateJavaScript): Use JSValuePtr.
+
+2008-10-14 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon.
+
+ Clip painter to dirty rect before passing on to WebKit
+
+ This was previously done in ScrollViewQt, but after the
+ refactoring of ScrollView we need to do it in QWebFrame
+ instead, similar to Safari/Win.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::render):
+
+2008-10-08 Matthias Ettrich <ettrich@nokia.com>
+
+ Reviewed by Simon.
+
+ Make QWebView ignore focus changes with PopupFocusReason to avoid
+ massive updates when menus open and close.
+
+ * Api/qwebview.cpp:
+ (QWebView::focusInEvent):
+ (QWebView::focusOutEvent):
+
+2008-10-08 Kavindra Palaraja <kdpalara@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fixed a qdoc warning and adjusted some spacing
+
+ * Api/qwebframe.cpp:
+
+2008-10-08 Rhys Weatherley <rhys.weatherley@nokia.com>
+
+ Reviewed by Simon.
+
+ Compile for platforms without context menus.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::createStandardContextMenu):
+
+2008-10-08 André Pönitz <apoenitz@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix compilation with Qt namespaces.
+
+ * WebCoreSupport/EditCommandQt.h:
+
+2008-10-07 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ QtWebKit build fix after changes to FrameLoaderClient.h in r37371
+
+ * WebCoreSupport/FrameLoaderClientQt.h:
+
+2008-10-07 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ [qt] Build fix after Scrollbar.h and Widget.h changes.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::swallowContextMenuEvent):
+
+2008-10-06 David Hyatt <hyatt@apple.com>
+
+ Enable viewless Mac WebKit to paint some basic pages.
+
+ Reviewed by Sam Weinig
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::transitionToCommittedForNewPage):
+
+2008-10-03 David Hyatt <hyatt@apple.com>
+
+ Fix scroll method on Qt. The delta was supposed to use .width()/.height() and not .x()/.y().
+
+ Fix the QtPluginWidget to do an invalidate properly.
+
+ Reviewed by ggaren
+
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::scroll):
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::):
+
+2008-10-03 Ariya Hidayat <ariya.hidayat@trolltech.com>
+
+ Build fix. Remove addToDirtyRegion from the header file.
+
+ * WebCoreSupport/ChromeClientQt.h:
+
+2008-10-03 Ariya Hidayat <ariya.hidayat@trolltech.com>
+
+ Build fix.
+
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::scroll):
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::):
+ (WebCore::FrameLoaderClientQt::createPlugin):
+
+2008-10-03 David Hyatt <hyatt@apple.com>
+
+ Remove addToDirtyRegion.
+
+ Reviewed by Oliver Hunt
+
+ * WebCoreSupport/ChromeClientQt.cpp:
+
+2008-10-02 David Hyatt <hyatt@apple.com>
+
+ https://bugs.webkit.org/show_bug.cgi?id=21314
+
+ Make scrollBackingStore cross-platform.
+
+ Reviewed by Sam Weinig
+
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::repaint):
+ (WebCore::ChromeClientQt::scroll):
+ * WebCoreSupport/ChromeClientQt.h:
+
+2008-10-01 David Hyatt <hyatt@apple.com>
+
+ https://bugs.webkit.org/show_bug.cgi?id=21282
+
+ Make contentsToScreen/screenToContents cross-platform. Only implemented by Mac/Win right now.
+
+ Reviewed by Adam Roben
+
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::windowToScreen):
+ (WebCore::ChromeClientQt::screenToWindow):
+ * WebCoreSupport/ChromeClientQt.h:
+
+2008-09-30 Dave Hyatt <hyatt@apple.com>
+
+ http://bugs.webkit.org/show_bug.cgi?id=21250
+
+ Rename updateContents to repaintContentRectangle and make it cross-platform by always sending
+ repaints up through the ChromeClient.
+
+ Reviewed by Darin Adler
+
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::repaint):
+ * WebCoreSupport/ChromeClientQt.h:
+
+2008-09-29 Gunnar Sletta <gunnar@trolltech.com>
+
+ Reviewed by Simon
+
+ Compile on windows using MSVC 2005
+
+ For the PCH We need to define _WIN32_WINNT and include windows.h early on,
+ otherwise we'll miss several functions.
+
+ * WebKit_pch.h:
+
+2008-09-29 Thiago Macieira <thiago.macieira@nokia.com>
+
+ Reviewed by Simon.
+
+ Changed copyright from Trolltech ASA to Nokia.
+
+ Nokia acquired Trolltech ASA, assets were transferred on September 26th 2008.
+
+
+ * Api/qwebframe.cpp:
+ * Api/qwebframe.h:
+ * Api/qwebframe_p.h:
+ * Api/qwebhistory.cpp:
+ * Api/qwebhistory.h:
+ * Api/qwebhistory_p.h:
+ * Api/qwebkitglobal.h:
+ * Api/qwebnetworkinterface.cpp:
+ * Api/qwebnetworkinterface.h:
+ * Api/qwebnetworkinterface_p.h:
+ * Api/qwebpage.cpp:
+ * Api/qwebpage.h:
+ * Api/qwebpage_p.h:
+ * Api/qwebpluginfactory.cpp:
+ * Api/qwebpluginfactory.h:
+ * Api/qwebsettings.cpp:
+ * Api/qwebsettings.h:
+ * Api/qwebview.cpp:
+ * Api/qwebview.h:
+ * Plugins/ICOHandler.cpp:
+ * QtLauncher/main.cpp:
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ * WebCoreSupport/FrameLoaderClientQt.h:
+ * WebCoreSupport/InspectorClientQt.cpp:
+ * WebCoreSupport/InspectorClientQt.h:
+ * tests/qwebframe/tst_qwebframe.cpp:
+ * tests/qwebpage/tst_qwebpage.cpp:
+
+2008-09-28 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by David Hyatt.
+
+ Ensure the mainThreadIdentifier is set as well as other bits and pieces of
+ the threading machinery, by calling JSC::initializeThreading().
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::QWebPagePrivate):
+
+2008-09-27 David Hyatt <hyatt@apple.com>
+
+ Forgot to land renaming changes in WebKit.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::render):
+ (QWebFrame::pos):
+ (QWebFrame::geometry):
+ * Api/qwebpage.cpp:
+ (QWebPage::viewportSize):
+ (QWebPage::setViewportSize):
+
+2008-09-27 Simon Hausmann <hausmann@webkit.org>
+
+ Qt build fix - use frameRect instead of frameGeometry, adapt
+ to renamed scrollbar frameview methods.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::viewportSize):
+ (QWebPage::setViewportSize):
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::transitionToCommittedForNewPage):
+
+2008-09-27 Jan Michael Alonzo <jmalonzo@webkit.org>
+
+ Qt build fix - rename frameGeometry to frameRect per r36995.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::render):
+ (QWebFrame::pos):
+ (QWebFrame::geometry):
+
+2008-09-26 Ariya Hidayat <ahidayat@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fixed potential crash when deleting QWebView instance.
+
+ When deleting the view, sets the page's view to NULL.
+ The reason is that the page is smart and its destructor might lead to a call
+ that operates on a view (which is in the process of being deleted).
+
+ * Api/qwebpage.h:
+ * Api/qwebview.cpp:
+ (QWebView::~QWebView):
+
+2008-09-26 Ariya Hidayat <ahidayat@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fixed using modifiers to type special symbols (e.g '@','$') does not work on Mac OS X.
+
+ * WebCoreSupport/EditorClientQt.cpp:
+ (WebCore::EditorClientQt::handleKeyboardEvent):
+
+2008-09-26 HÃ¥vard Wall <hwall@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix compilation with QT_NO_MESSAGEBOX
+
+ * Api/qwebpage.cpp:
+ (QWebPage::javaScriptAlert):
+ (QWebPage::javaScriptConfirm):
+
+2008-09-23 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon.
+
+ Remove deprecated JS Qt bindings object call/construct code and fix autotests
+
+ * tests/qwebframe/tst_qwebframe.cpp:
+
+2008-09-16 Alp Toker <alp@nuanti.com>
+
+ Prospective Qt build fix. ScrollBar.h -> Scrollbar.h
+
+ * Api/qwebframe.cpp:
+ * Api/qwebpage.cpp:
+
+2008-09-15 Eli Fidler <eli@staikos.net>
+
+ Reviewed by Simon.
+
+ Yahoo assumes non-RFC compliant HTTP redirect behaviour. QtWebKit is (more)
+ compliant, so broken. I think the Yahoo-assumed behaviour is real-world standard.
+
+ Basically, Yahoo's login procedure for flickr looks like this:
+ 1. load flickr.com, click "sign in"
+ 2. this is a Yahoo page with a form
+ (https://login.yahoo.com/config/login?.src=flickr...)
+ when you click the "Sign In" button, the form submits to a yahoo.com POST URL
+ 3. The POST returns with a 302 (redirect) to another yahoo.com URL
+ 4. If you POST the redirected Location:, it all breaks. Yahoo assumes you will
+ convert the method to GET, which works fine but is definitely not
+ RFC-compliant. It would be compliant for 303, and the RFC says that many
+ implementations treat 302 and 303 the same way (for HTTP/1.0 compliance), but
+ converting to GET is explicitly wrong for 302.
+
+ * Api/qwebnetworkinterface.cpp:
+ (QWebNetworkManager::started):
+
+2008-09-15 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon.
+
+ Make QtInstance::create() private and fix caching
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::addToJavaScriptWindowObject):
+
+2008-09-11 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Rubber-stamped by Simon.
+
+ Prevent leaking pages and frames in QWebKit autotest
+
+ * tests/qwebpage/tst_qwebpage.cpp:
+
+2008-09-11 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon
+
+ Fix QtWebKit autotest
+
+ * tests/qwebpage/tst_qwebpage.cpp:
+ (tst_QWebPage::userStyleSheet):
+
+2008-09-09 Joerg Bornemann <joerg.bornemann@trolltech.com>
+
+ Reviewed by Simon.
+
+ Added missing WebCore prefix to ResourceRequest
+
+ This is needed for Windows/CE compilation where there is a conflict
+ with a global ResourceRequest type. Elsewhere in this file ResourceRequest
+ is also prefixed with WebCore::
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::QWebFrame):
+
+2008-09-07 Cameron Zwarich <cwzwarich@uwaterloo.ca>
+
+ Reviewed by Maciej Stachowiak.
+
+ Bug 20704: Replace the KJS namespace
+ <https://bugs.webkit.org/show_bug.cgi?id=20704>
+
+ Rename the KJS namespace to JSC.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::addToJavaScriptWindowObject):
+ (QWebFrame::evaluateJavaScript):
+
+2008-09-04 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon
+
+ Fix the QtWebKit build to match changes in r36016
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::addToJavaScriptWindowObject):
+
+2008-09-04 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon.
+
+ Re-enable support for user stylesheets in QtWebKit
+
+ QtWebKit now follows the FRAME_LOADS_USER_STYLESHEET
+ code path, which allows us to keep API support for
+ loading user style sheets from remote URLs.
+
+ As part of the change UserStyleSheetLoader.cpp/h was
+ moved from WebCore/loader/mac to WebCore/loader.
+
+ * tests/qwebpage/tst_qwebpage.cpp:
+ (tst_QWebPage::userStyleSheet):
+
+2008-08-29 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Reviewed by Eric Seidel.
+
+ [janitor/qt] Start replacing port specific getters with the generic native getter
+ To get the native presentation of an image we currently have platform
+ specific #ifdef's and a generic getter using NativeImagePtr. This patch
+ extends this to the ImageBuffer and updates the Qt platform to get rid
+ of the special #ifdefs.
+
+ https://bugs.webkit.org/attachment.cgi?id=22861
+
+ * Api/qwebframe.cpp:
+ (QWebHitTestResultPrivate::QWebHitTestResultPrivate):
+ * Api/qwebhistory.cpp:
+ * Api/qwebsettings.cpp:
+ (QWebSettings::iconForUrl):
+
+2008-08-29 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Reviewed by Simon.
+
+ Catch up with the introduction of PageGroup in r30840. Enable tracking of
+ visited links, enable this in QWebPage next to the other WebCore init call.
+ Calling this more than once is no issue and a cheap operation, we also do not
+ reset the state. When clearing the history of a page, clear the link state.
+
+ * Api/qwebhistory.cpp:
+ (QWebHistory::clear):
+ * Api/qwebhistoryinterface.cpp:
+ (QWebHistoryInterface::setDefaultInterface):
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::QWebPagePrivate):
+
+2008-08-29 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Reviewed by Simon.
+
+ Revert revision 34348 which removed the global historyContains() function.
+
+ This function was needed to implement the public API of QWebHistoryInterface
+ and will be used again in the near future.
+
+ * Api/qwebhistoryinterface.cpp:
+ (WebCore::historyContains):
+
+2008-08-27 Erik Bunce <elbunce@thehive.com>
+
+ Reviewed by Eric Seidel.
+
+ https://bugs.webkit.org/show_bug.cgi?id=20223
+
+ Add QWebPage::contentsChanged() signal to notify of content changes.
+
+ * Api/qwebpage.cpp:
+ * Api/qwebpage.h:
+ * WebCoreSupport/EditorClientQt.cpp:
+ (WebCore::EditorClientQt::respondToChangedContents):
+
+2008-08-27 Brady Eidson <beidson@apple.com>
+
+ Reviewed by Anders
+
+ <rdar://problem/6134133> - Crash when loading large movie as a standalone document
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::pluginWillHandleLoadError): Stubbed for now
+ * WebCoreSupport/FrameLoaderClientQt.h:
+
+2008-08-25 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Reviewed by Simon.
+
+ [inspector] Emit signals from attachWindow and detachWindow in the Qt platform
+ Allow the user of the API to honor the attachWindow and detachWindow
+ requests and attach the QWebPage/QWebView wherever it is wanted. This needs
+ some more API in QWebPage to be properly exposed.
+
+ * WebCoreSupport/InspectorClientQt.cpp:
+ (WebCore::InspectorClientQt::createPage):
+ (WebCore::InspectorClientQt::attachWindow):
+ (WebCore::InspectorClientQt::detachWindow):
+ * WebCoreSupport/InspectorClientQt.h:
+
+2008-08-19 Alexey Proskuryakov <ap@webkit.org>
+
+ Reviewed by Geoff Garen.
+
+ Bring back shared JSGlobalData and implicit locking, because too many clients rely on it.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::addToJavaScriptWindowObject):
+
+2008-08-15 HÃ¥vard Wall <hwall@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fixes: compile with QT_NO_UNDOCOMMAND/STACK
+
+
+ * Api/qwebpage.cpp:
+ (SetCursorEvent::SetCursorEvent):
+ (QWebPagePrivate::createContextMenu):
+ (QWebPage::action):
+ * Api/qwebpage.h:
+ * Api/qwebpage_p.h:
+ * WebCoreSupport/EditCommandQt.cpp:
+ (EditCommandQt::EditCommandQt):
+ * WebCoreSupport/EditCommandQt.h:
+ * WebCoreSupport/EditorClientQt.cpp:
+ (dumpPath):
+ (WebCore::EditorClientQt::shouldInsertText):
+ (WebCore::EditorClientQt::shouldChangeSelectedRange):
+ (WebCore::EditorClientQt::isEditable):
+ (WebCore::EditorClientQt::registerCommandForUndo):
+ (WebCore::EditorClientQt::clearUndoRedoOperations):
+ (WebCore::EditorClientQt::canUndo):
+ (WebCore::EditorClientQt::canRedo):
+ (WebCore::EditorClientQt::undo):
+ (WebCore::EditorClientQt::redo):
+ (WebCore::EditorClientQt::shouldInsertNode):
+
+2008-08-15 HÃ¥vard Wall <hwall@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fixes: compile with QT_NO_STYLE_STYLESHEET
+
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::postProgressFinishedNotification):
+ (WebCore::FrameLoaderClientQt::createPlugin):
+
+2008-08-15 HÃ¥vard Wall <hwall@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fixes: compile with QT_NO_SHORTCUT
+
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::mouseMoveEvent):
+ (QWebPagePrivate::mouseReleaseEvent):
+ (QWebPagePrivate::dragMoveEvent):
+
+2008-08-15 HÃ¥vard Wall <hwall@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fixes: compile with QT_NO_CONTEXTMENU
+
+
+ * Api/qwebpage.cpp:
+ (editorCommandForWebActions):
+ (QWebPagePrivate::QWebPagePrivate):
+ (QWebPagePrivate::createMainFrame):
+ (QWebPagePrivate::updateEditorActions):
+ (QWebPage::setEditable):
+ * Api/qwebpage.h:
+ * Api/qwebpage_p.h:
+ * Api/qwebview.cpp:
+ * Api/qwebview.h:
+
+2008-08-15 HÃ¥vard Wall <hwall@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fixes: compile with QT_NO_WHEELEVENT
+
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::updateEditorActions):
+ (QWebPage::event):
+ * Api/qwebpage_p.h:
+ * Api/qwebview.cpp:
+ * Api/qwebview.h:
+
+2008-08-15 HÃ¥vard Wall <hwall@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fixes: compile with QT_NO_PRINTER
+
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::print):
+ * Api/qwebframe.h:
+
+2008-08-15 David Boddie <dboddie@trolltech.com>
+
+ Reviewed by Simon.
+
+ Doc: Added documentation for default property values.
+
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::keyPressEvent):
+ (QWebPage::triggerAction):
+ (QWebPage::acceptNavigationRequest):
+ (QWebPage::action):
+ * Api/qwebview.cpp:
+
+2008-08-15 David Boddie <dboddie@trolltech.com>
+
+ Reviewed by Simon.
+
+ Doc: Renamed snippets that appear in the code directory.
+
+
+ * Api/qwebview.cpp:
+ (QWebView::event):
+ (QWebView::print):
+
+2008-08-12 Timothy Hatcher <timothy@apple.com>
+
+ Add a stub for InspectorClient::setAttachedWindowHeight.
+
+ * WebCoreSupport/InspectorClientQt.cpp:
+ (WebCore::InspectorClientQt::setAttachedWindowHeight):
+ Call notImplemented().
+ * WebCoreSupport/InspectorClientQt.h:
+
+2008-08-13 Ariya Hidayat <ariya.hidayat@trolltech.com>
+
+ Reviewed by Simon.
+
+ Use full-page zoom in QtLauncher.
+
+ * QtLauncher/main.cpp:
+ (MainWindow::zoomIn):
+ (MainWindow::zoomOut):
+ (MainWindow::resetZoom):
+ (MainWindow::setupUI):
+
+2008-08-13 Ariya Hidayat <ariya.hidayat@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix linking with QtWebKit.
+
+ * Api/qwebframe.h: remove non-existing function/property.
+
+2008-08-13 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger.
+
+ Based on patch by Siraj razick <siraj.razick@collabora.co.uk>
+
+ https://bugs.webkit.org/show_bug.cgi?id=19125
+
+ Added functions to get/set the zoom factor.
+
+ Added a QWebFrame/QWebView::zoomFactor as well as a boolean
+ ZoomTextOnly attribute in QWebSettings.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::setZoomFactor):
+ (QWebFrame::zoomFactor):
+ * Api/qwebframe.h:
+ * Api/qwebsettings.cpp:
+ (QWebSettingsPrivate::apply):
+ (QWebSettings::QWebSettings):
+ * Api/qwebsettings.h:
+ * Api/qwebview.cpp:
+ (QWebView::setZoomFactor):
+ (QWebView::zoomFactor):
+ * Api/qwebview.h:
+
+2008-08-13 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Lars.
+
+ Fix QWebFrame::setHtml() not setting the new contents immediately.
+
+ Added a setter to the DocumentLoader to toggle the deferred loading of the main
+ resource when it comes from substitute data.
+
+ Disable deferred loading of the main resource when we have valid substitute data,
+ as used by QWebFrame::setHtml.
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::download):
+
+2008-08-13 Simon Hausmann <hausmann@webkit.org>
+
+ Rubber-stamped by Holger.
+
+ Fix QWebPage::isModified().
+
+ isModified() would return true after loading a new page or it would continue to
+ return true after undoing modifications. Fix this by eliminating the
+ QWebPagePrivate::modified variable and use the undoStack's canUndo() property
+ instead.
+
+ https://bugs.webkit.org/show_bug.cgi?id=19252
+
+ * Api/qwebpage.cpp:
+ (QWebPage::action):
+ * Api/qwebpage_p.h:
+ * WebCoreSupport/EditorClientQt.cpp:
+ (WebCore::EditorClientQt::respondToChangedContents):
+
+2008-08-13 David Boddie <dboddie@trolltech.com>
+
+ Reviewed by Simon.
+
+ Updated docs with the signal emission behavior of urlChanged()
+
+ * Api/qwebframe.cpp:
+
+2008-08-13 Ariya Hidayat <ariya.hidayat@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix Ctrl+Y to work again when editing text in contextEditable mode.
+
+ This fixes regression in LayoutTests/editing/pasteboard/emacs-cntl-y-001.html
+
+ * WebCoreSupport/EditorClientQt.cpp:
+ (WebCore::EditorClientQt::handleKeyboardEvent):
+
+2008-08-13 Thiago Macieira <tjmaciei@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix encoding of [ and ] in the host part of the URL
+
+ Until QUrl is fixed (making QUrl's tolerant parser more tolerant), we have to
+ add this workaround to the QUrl <> WebCore::KURL conversion operator so that it
+ doesn't encode [ and ] when they are found in the host part. That is, the
+ following URL:
+ http://[::1]/
+ is valid and should not be reencoded to:
+ http://%5b::1%5d/
+
+ This change adds the automatic test for it.
+
+ * tests/qwebframe/tst_qwebframe.cpp:
+
+2008-08-12 Urs Wolfer <uwolfer@kde.org>
+
+ Reviewed by Simon.
+
+ https://bugs.webkit.org/show_bug.cgi?id=20357
+
+ Fix crash in QWebPage in case contextMenuEvent has been overwritten
+ because context menu has the view as parent and thus is deleted too early.
+
+ Add testcase for this crash.
+
+ * Api/qwebpage_p.h:
+ * tests/qwebpage/tst_qwebpage.cpp:
+ (tst_QWebPage::contextMenuCrash):
+
+2008-08-07 Simon Hausmann <hausmann@webkit.org>
+
+ Rubber-stamped by Lars.
+
+ Added API tests for QWebPage/QWebFrame based on QTestLib.
+
+ * tests/qwebframe/qwebframe.pro: Added.
+ * tests/qwebframe/tst_qwebframe.cpp: Added.
+ * tests/qwebpage/qwebpage.pro: Added.
+ * tests/qwebpage/tst_qwebpage.cpp: Added.
+ * tests/tests.pro: Added.
+
+2008-08-06 Benjamin C Meyer <ben@meyerhome.net>
+
+ Reviewed by Simon.
+
+ During the drag operation only accept the event if the action is not ignore action.
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::dragEnterEvent):
+ (QWebPagePrivate::dragMoveEvent):
+ (QWebPagePrivate::dropEvent):
+
+2008-08-06 Ariya Hidayat <ariya.hidayat@trolltech.com>
+
+ Fix the Qt build due to recent ScriptController refactoring.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::addToJavaScriptWindowObject):
+
+2008-08-05 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon.
+
+ Move event handling of the return-key from EditorClientQt to QWebPage.
+
+ https://bugs.webkit.org/show_bug.cgi?id=20191
+
+ This is a first step in refactoring the big switch block
+ in EditorClientQt::handleKeyboardEvent to using WebActions
+ instead.
+
+ The new logic uses two new StandardKeys from QKeySequence:
+
+ - InsertParagraphSeparator
+ - InsertLineSeparator
+
+ Which translate to the commands InsertNewline and InsertLineBreak
+ respectivly. On Windows/X11 pressing the shift modifier will invoke
+ the latter action. For Mac this is triggered by pressing the meta
+ modifier (Ctrl).
+
+ Initial patch by: Erik Bunce
+
+ * Api/qwebpage.cpp:
+ (editorActionForKeyEvent):
+ * Api/qwebpage.h:
+ * WebCoreSupport/EditorClientQt.cpp:
+ (WebCore::EditorClientQt::handleKeyboardEvent):
+
+2008-08-04 Erik Bunce <elbunce@thehive.com>
+
+ Reviewed by Simon.
+
+ https://bugs.webkit.org/show_bug.cgi?id=20221
+
+ Add updateAction() support to ToggleBold, ToggleItalic, and ToggleUnderline.
+ Add lookup table for mapping web actions to editor commands.
+
+ * Api/qwebpage.cpp:
+ (editorCommandForWebActions):
+ (QWebPagePrivate::updateAction):
+ (QWebPagePrivate::updateEditorActions):
+ (QWebPage::triggerAction):
+ (QWebPage::setEditable):
+
+2008-08-03 Ariya Hidayat <ariya.hidayat@trolltech.com>
+
+ Reviewed by Simon.
+
+ A bunch of improvements to the QtLauncher.
+
+ Among others:
+ - Unify and unclutter the toolbar, use menu for addition actions
+ - Simplify URL edit, just use QLineEdit (no fancy close button etc)
+ - Guess the URL from the command line so now we can run ./QtLauncher www.google.com
+ - Shortcut keys for most actions
+ - Simple autocomplete for the URL edit
+ - Actions for zooming, New Window and Close Window
+ - Show Format menu only when the content is set to editable
+
+ * QtLauncher/main.cpp:
+ (MainWindow::MainWindow):
+ (MainWindow::webPage):
+ (MainWindow::changeLocation):
+ (MainWindow::loadFinished):
+ (MainWindow::showLinkHover):
+ (MainWindow::newWindow):
+ (MainWindow::zoomIn):
+ (MainWindow::zoomOut):
+ (MainWindow::resetZoom):
+ (MainWindow::print):
+ (MainWindow::setEditable):
+ (MainWindow::dumpHtml):
+ (MainWindow::setupUI):
+ (main):
+
+2008-08-04 Erik Bunce <elbunce@thehive.com>
+
+ Reviewed by Simon.
+
+ https://bugs.webkit.org/show_bug.cgi?id=20198
+
+ Allow Copy key sequence to work in non-editable areas.
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::keyPressEvent):
+
+2008-07-31 Erik Bunce <elbunce@thehive.com>
+
+ Reviewed by Simon.
+
+ Make sure edit actions get updated when the contents change.
+
+ * WebCoreSupport/EditorClientQt.cpp:
+ (WebCore::EditorClientQt::respondToChangedContents):
+
+2008-07-31 Erik Bunce <elbunce@thehive.com>
+
+ Reviewed by Simon.
+
+ Add simple edit test abilities to QtLauncher.
+
+ * QtLauncher/main.cpp:
+ (MainWindow::MainWindow):
+ (MainWindow::setEditable):
+ (MainWindow::dumpHtml):
+
+2008-07-31 Alexey Proskuryakov <ap@webkit.org>
+
+ Rubber-stamped by Maciej.
+
+ Eliminate JSLock (it was already disabled, removing the stub implementaion and all
+ call sites now).
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::addToJavaScriptWindowObject):
+
+2008-07-27 David Kilzer <ddkilzer@apple.com>
+
+ Fix Qt build failure.
+
+ * Api/qwebframe.h:
+ (QWebFrame::setScrollOffset): Make argument const.
+
+2008-07-26 Marc Ordinas i Llopis <marc.ordinasillopis@collabora.co.uk>
+
+ Reviewed by Simon Hausmann.
+
+ https://bugs.webkit.org/show_bug.cgi?id=20010
+ [Qt] Add API access to scrolling
+
+ * Api/qwebframe.cpp: Added access to a frame scroll offset.
+ (QWebFrame::scroll):
+ (QWebFrame::scrollOffset):
+ (QWebFrame::setScrollOffset):
+ * Api/qwebframe.h:
+
+2008-07-26 Daniel Jalkut <jalkut@red-sweater.com>
+
+ Build fix. Adjust to updated WebCore FrameLoader method names & signatures.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::triggerAction):
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::createFrame):
+
+2008-07-25 Joerg Bornemann <joerg.bornemann@trolltech.com>
+
+ Reviewed by Simon.
+
+ Compile with QT_NO_PRINTER.
+
+ * QtLauncher/main.cpp:
+ (MainWindow::MainWindow):
+
+2008-07-24 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon
+
+ Don't insert text on keyDown event in EditorClientQt.
+
+ * WebCoreSupport/EditorClientQt.cpp:
+ (WebCore::EditorClientQt::handleKeyboardEvent):
+
+2008-07-04 Benjamin C Meyer <ben@meyerhome.net>
+
+ Reviewed by Simon.
+
+ Update the webkit version in the QtWebKit useragent string to match trunk
+
+ * Api/qwebpage.cpp:
+
+2008-07-02 Simon Hausmann <hausmann@webkit.org>
+
+ Build fix.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::triggerAction): The signature of setBaseWritingDirection
+ changed to take an enum instead of a string.
+
+2008-07-01 Alexey Proskuryakov <ap@webkit.org>
+
+ Reviewed by Darin Adler.
+
+ Disable JSLock for per-thread contexts.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::addToJavaScriptWindowObject):
+ Pass a parameter (false) to JSLock to indicate that WebKit doesn't need locking.
+ Include JSLock.h, as it is no longer brought in implicitly.
+
+2008-07-01 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon.
+
+ Don't show the tooltip instantly in the QtLauncher.
+
+ Let the QWebView handle tooltips by itself, so we get
+ the expected delay as everywhere else.
+
+ * QtLauncher/main.cpp:
+
+2008-06-30 Simon Hausmann <hausmann@webkit.org>
+
+ Rubber-stamped by Niko.
+
+ Removed the obsolete and unmaintained WebKitPart. The integration of
+ QtWebKit into KDE is now done in the webkitkde component inside KDE.
+
+ * WebKitPart/WebKitFactory.cpp: Removed.
+ * WebKitPart/WebKitFactory.h: Removed.
+ * WebKitPart/WebKitPart.cpp: Removed.
+ * WebKitPart/WebKitPart.desktop: Removed.
+ * WebKitPart/WebKitPart.h: Removed.
+ * WebKitPart/WebKitPart.rc: Removed.
+ * WebKitPart/WebKitPartBrowser.rc: Removed.
+ * WebKitPart/WebKitPartBrowserExtension.cpp: Removed.
+ * WebKitPart/WebKitPartBrowserExtension.h: Removed.
+ * WebKitPart/WebKitPartClient.cpp: Removed.
+ * WebKitPart/WebKitPartClient.h: Removed.
+ * WebKitPart/WebKitPartInterface.cpp: Removed.
+ * WebKitPart/WebKitPartInterface.h: Removed.
+ * WebKitPart/org.kde.WebKitPart.xml: Removed.
+
+2008-06-24 Simon Hausmann <hausmann@webkit.org>
+
+ Fix the Qt build, added missing include for RuntimeObjectImp.
+
+ * Api/qwebframe.cpp:
+
+2008-06-23 Benjamin C Meyer <ben@meyerhome.net>
+
+ Reviewed by Simon.
+
+ Add function to retrieve the standard context menu
+
+2008-06-20 Marc Ordinas i Llopis <marc.ordinasillopis@collabora.co.uk>
+
+ Reviewed by Simon.
+
+ https://bugs.webkit.org/show_bug.cgi?id=19082
+ [Qt] Full-page plugins not activated
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::committedLoad): Re-check if there's a
+ plugin present, as it can be created during the function.
+
+2008-06-20 Marco Barisione <marco.barisione@collabora.co.uk>
+
+ Reviewed by Simon.
+
+ https://bugs.webkit.org/show_bug.cgi?id=19082
+ [Qt] Full-page plugins not activated
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::canShowMIMEType): Return true if the
+ MIME type is supported by a plugin.
+
+2008-06-18 Alexey Proskuryakov <ap@webkit.org>
+
+ Reviewed by Darin Adler.
+
+ Prepare JavaScript heap for being per-thread.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::addToJavaScriptWindowObject): Trying not to break the build.
+
+2008-06-18 Julien Chaffraix <jchaffraix@webkit.org>
+
+ Qt Build fix after r34627.
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::createPlugin):
+
+2008-06-15 Darin Adler <darin@apple.com>
+
+ - give Frame object functions shorter names: scriptProxy() -> script(),
+ selectionController() -> selection(), animationController() -> animation()
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::evaluateJavaScript):
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::focusInEvent):
+ (QWebPagePrivate::focusOutEvent):
+ (QWebPage::inputMethodQuery):
+ * WebCoreSupport/EditorClientQt.cpp:
+ (WebCore::EditorClientQt::handleKeyboardEvent):
+
+2008-06-15 Darin Adler <darin@apple.com>
+
+ - new names for more JavaScriptCore files
+
+ * WebKit_pch.h:
+
+2008-06-15 Darin Adler <darin@apple.com>
+
+ - new names for a few key JavaScriptCore files
+
+ * Api/qwebframe.cpp:
+
+2008-06-14 Darin Adler <darin@apple.com>
+
+ Rubber stamped by Sam.
+
+ - new names for kjs_binding.h and kjs_proxy.h
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::evaluateJavaScript):
+ * WebKit_pch.h:
+
+2008-06-14 Darin Adler <darin@apple.com>
+
+ - fix build
+
+ * Api/qwebframe.cpp:
+ (QWebFramePrivate::init): Added a missing semicolon.
+
+2008-06-14 Darin Adler <darin@apple.com>
+
+ Reviewed by Sam.
+
+ - more https://bugs.webkit.org/show_bug.cgi?id=17257
+ start ref counts at 1 instead of 0 for speed
+
+ * Api/qwebframe.cpp:
+ (QWebFramePrivate::init): Use create instead of new.
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::createDocumentLoader): Ditto.
+
+2008-06-13 Darin Adler <darin@apple.com>
+
+ - try to fix build
+
+ * WebCoreSupport/FrameLoaderClientQt.h: Add missing argument.
+
+2008-06-13 Darin Adler <darin@apple.com>
+
+ Reviewed by John Sullivan.
+
+ - updated for addition of FormState argument to action policy functions
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction):
+ (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction):
+
+2008-06-11 Ariya Hidayat <ariya.hidayat@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix left-click and middle-click mouse event are not properly accepted.
+
+ When copying or pasting text using left or middle-click, the event must be
+ accepted so that it will not be potentially processed further by the parent
+ and/or sub-classed widget.
+
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::mouseReleaseEvent):
+
+2008-06-11 Ariya Hidayat <ariya.hidayat@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix input element does not accept character typed in using AltGr.
+
+ EditorClient is modified to catch AltGr and Ctrl+Alt key combination.
+ This fixes http://trolltech.com/developer/task-tracker/index_html?id=207050&method=entry
+
+ * WebCoreSupport/EditorClientQt.cpp:
+ (WebCore::EditorClientQt::handleKeyboardEvent):
+
+2008-05-26 Jonathon Jongsma <jonathon.jongsma@collabora.co.uk>
+
+ Reviewed by Simon.
+
+ https://bugs.webkit.org/show_bug.cgi?id=19323
+
+ Implemented the QWebPage::editable property.
+
+ Small documentation fixes by Simon.
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::QWebPagePrivate):
+ (QWebPage::setEditable):
+ (QWebPage::isEditable):
+ * Api/qwebpage.h:
+ * Api/qwebpage_p.h: implement the editable property and add API so that
+ applications can switch edit mode on and off for a particular QWebPage
+ * WebCoreSupport/EditorClientQt.cpp: retrieve editable property from the
+ QWebPage instead of always returning false
+
+2008-06-09 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon
+
+ Make sure web action in context menus have the right enablement,
+ while not messing up other web actions not included in the menu.
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::createContextMenu):
+ (QWebPage::updatePositionDependentActions):
+ * Api/qwebpage_p.h:
+
+2008-06-09 Benjamin C Meyer <ben@meyerhome.net>
+
+ Reviewed by Simon
+
+ Add Shift-Space shortcut to go up one screen, the opposite of Space
+ which goes down one screen.
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::handleScrolling):
+
+2008-06-04 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix a failing assertion when calling QWebFrame::evaluateJavaScript.
+
+ The starting line number has to be 1 instead of 0.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::evaluateJavaScript):
+
+2008-06-03 Jonathon Jongsma <jonathon.jongsma@collabora.co.uk>
+
+ Reviewed by Darin Adler.
+
+ * Api/qwebhistoryinterface.cpp: Remove WebCore::historyContains(). This
+ function is not used anywhere internally and is only a convenience
+ function that can still be accomplished using
+ QWebHistoryInterface::historyContains();
+
+2008-05-29 Kavindra Devi Palaraja <kdpalara@trolltech.com>
+
+ Reviewed by Simon.
+
+ Doc: Mention the requirement of a QApplication with QtWebKit
+
+
+ * Api/qwebview.cpp:
+
+2008-05-29 David Boddie <dboddie@trolltech.com>
+
+ Reviewed by Simon.
+
+ Some clarifications for the documentation.
+
+
+ * Api/qwebpage.cpp:
+ * Api/qwebpluginfactory.cpp:
+
+2008-05-27 Ariya Hidayat <ariya.hidayat@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix web inspector does not returns its state properly after its window is minimized.
+
+ As hinted by Holger, InspectorClientView::hideEvent is not needed.
+ This fixes bug https://bugs.webkit.org/show_bug.cgi?id=18967
+
+ * WebCoreSupport/InspectorClientQt.cpp:
+
+2008-05-21 Siraj Razick <siraj.razick@collabora.co.uk>
+
+ Reviewed by Simon.
+
+ Add <param name="classid"/> support for application/x-qt-object plugins
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::createPlugin):
+
+2008-05-13 Andy Shaw <andy@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fixes: QWebHistory::forward() should go forwards and not back
+
+ * Api/qwebhistory.cpp:
+
+2008-05-12 Alexey Proskuryakov <ap@webkit.org>
+
+ Roll out recent threading changes (r32807, r32810, r32819, r32822) to simplify
+ SquirrelFish merging.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::addToJavaScriptWindowObject):
+
+2008-05-09 Thiago Macieira <tjmaciei@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix bad includes in QtWebKit public headers.
+
+ Make sure to include qglobal.h using the QtCore prefix so that an explicit
+ include/QtCore is not needed in the application's build system. Also make sure
+ that qwebsettings.h includes the local qwebkitglobal.h.
+
+
+ * Api/qwebkitglobal.h:
+ * Api/qwebsettings.h:
+
+2008-05-08 Marc Ordinas i Llopis <marc.ordinasillopis@collabora.co.uk>
+
+ Reviewed by Simon.
+
+ https://bugs.webkit.org/show_bug.cgi?id=18935
+
+ Based on work by Sriram Neelakandan for the Gtk port.
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp: Initialize
+ m_hasSentResponseToPlugin.
+ (WebCore::FrameLoaderClientQt::FrameLoaderClientQt):
+ (WebCore::FrameLoaderClientQt::redirectDataToPlugin):
+
+2008-05-08 Warwick Allison <warwick@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fixes: WebKit expects initial input method state to be *disabled*.
+
+ At least QWS does not need the initial input method state to be forced to
+ enabled, but other platforms (esp. X11) do. Until fixed/tested on those
+ platforms, this is specific to QWS.
+
+
+ * Api/qwebview.cpp:
+ (QWebView::QWebView):
+
+2008-05-06 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger.
+
+ Fix logic error in QWebHitTestResult::isNull().
+
+ * Api/qwebframe.cpp:
+
+2008-05-02 Benjamin Meyer <bmeyer@trolltech.com>
+
+ Reviewed by Simon.
+
+ Doc: Mention that you have to enable plugins in QWebSettings for them to work.
+
+ * Api/qwebpage.cpp:
+
+2008-05-02 Simon Hausmann <hausmann@webkit.org>
+
+ Fix the Qt build, ExecState is required here.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::addToJavaScriptWindowObject):
+
+2008-05-01 Marc Ordinas i Llopis <marc.ordinasillopis@collabora.co.uk>
+
+ Reviewed by Alp Toker.
+ Qt parts OK'ed by Simon Hausmann.
+
+ https://bugs.webkit.org/show_bug.cgi?id=14750
+ Added support for NPAPI plugins on Gtk and Qt-x11 ports.
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::FrameLoaderClientQt):
+ (WebCore::FrameLoaderClientQt::finishedLoading):
+ (WebCore::FrameLoaderClientQt::setMainDocumentError):
+ (WebCore::FrameLoaderClientQt::committedLoad):
+ (WebCore::FrameLoaderClientQt::objectContentType):
+ (WebCore::FrameLoaderClientQt::createPlugin):
+ (WebCore::FrameLoaderClientQt::redirectDataToPlugin):
+ * WebCoreSupport/FrameLoaderClientQt.h:
+
+2008-04-30 Julien Chaffraix <jchaffraix@webkit.org>
+
+ Qt 4.3 build fix.
+
+ Fixes a brace error that made Qt 4.4 build but not Qt 4.3.
+
+ * Api/qwebview.cpp:
+ (QWebView::event):
+
+2008-04-30 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon.
+
+ In focusIn and focusOut event always update the active state of the
+ focus controller. Fixes ~400 failing layout tests due to missing
+ editing callbacks that relied on the correct focus.
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::focusInEvent):
+ (QWebPagePrivate::focusOutEvent):
+
+2008-04-29 Lincoln Ramsay <lincoln.ramsay@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix compilation with QT_NO_PRINTER
+
+
+ * Api/qwebview.cpp:
+ (QWebView::print):
+
+2008-04-29 Ariya Hidayat <ariya.hidayat@trolltech.com>
+
+ Reviewed by Simon.
+
+ Ensure that relative URL is converted to absolute URL.
+
+ This is necessary because loading a relative URL is not really supported
+ (the web page may load, but the subsequent URLs for images and links will
+ not be resolved properly).
+ This also fixes https://bugs.webkit.org/show_bug.cgi?id=18484
+
+
+ * Api/qwebframe.cpp:
+ (ensureAbsoluteUrl):
+ (QWebFrame::setUrl):
+ (QWebFrame::load):
+
+2008-04-29 Ariya Hidayat <ariya.hidayat@trolltech.com>
+
+ Reviewed by Simon.
+
+ Simplification of Qt Launcher (no animation and use standard progress bar widget)
+
+ Status bar shows the hovered link without any animation. Progress bar just uses the standard QProgressBar (no custom widget). The launcher is leaner and faster to use under the debugger and/or valgrind.
+
+
+ * QtLauncher/main.cpp:
+ (MainWindow::MainWindow):
+
+2008-04-29 Ariya Hidayat <ariya.hidayat@trolltech.com>
+
+ Reviewed by Simon.
+
+ Update the cursor when the frame/page loading is finished.
+
+ This fixes https://bugs.webkit.org/show_bug.cgi?id=18712
+
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::postProgressFinishedNotification):
+ (WebCore::FrameLoaderClientQt::setMainFrameDocumentReady):
+
+2008-04-29 Simon Hausmann <shausman@trolltech.com>
+
+ Reviewed by Holger.
+
+ Fixes: QWebPage::acceptNavigationRequest not being called / linkClicked() not being emitted when clicking on <a href="..." target="_blank"> kind of links.
+
+ Call QWebPage::acceptNavigationRequest when the creation of a new window with
+ URL is requested. The frame pointer is set to null in this case.
+
+
+ * Api/qwebpage.cpp:
+ (QWebPage::setViewportSize):
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::startDownload):
+ (WebCore::FrameLoaderClientQt::createFrame):
+
+2008-04-29 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Reviewed by Simon.
+
+ Use the WebCore facility to do the scrolling. Move some code around.
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::keyPressEvent):
+ (QWebPagePrivate::shortcutOverrideEvent):
+ (QWebPagePrivate::handleScrolling):
+ * Api/qwebpage_p.h:
+
+2008-04-29 Ariya Hidayat <ariya.hidayat@trolltech.com>
+
+ Reviewed by Simon.
+
+ fix potential crash when loading image(s)
+
+ Crash may occur. If compiled with 4.3, the variable is not initialized.
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::QWebPagePrivate):
+
+2008-04-29 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Reviewed by Simon.
+
+ Calling QWebView::setCursor will override the WebCore Cursor.
+ Calling QWebView::setCursor will override the WebCore Cursor using
+ QWidget::unsetCursor will revert to the WebCore Cursor.
+
+ For detecting the unset we have to compare the shape of the
+ cursor to the default arrow. Qt::WA_SetCursor can not be used
+ as it is set unconditionally but conditionally removed.
+
+ Calling QWidget::setCursor will immediately send the CursorChange
+ event. We listen to this event to decide if we currently use a
+ WebCore cursor, got a cursor from outside, or revert to the default.
+
+ This should be race free and work reliable, the manual test for this
+ is WebCore/manual-tests/cursor.html
+
+ * Api/qwebpage.cpp:
+ (SetCursorEvent::SetCursorEvent):
+ * Api/qwebpage_p.h:
+ * Api/qwebview.cpp:
+ (QWebViewPrivate::QWebViewPrivate):
+ (QWebViewPrivate::setCursor):
+ (QWebView::QWebView):
+ (QWebView::event):
+
+2008-04-29 Kavindra Devi Palaraja <kdpalara@trolltech.com>
+
+ Reviewed by Simon.
+
+ Documentation fixes:
+
+ - Fixed a qdoc warning
+ - Mention that fav icons can be of arbitrary size
+ - Fix signature of QWebPage::acceptNavigationRequest show in the documentation
+
+ * Api/qwebframe.cpp:
+ * Api/qwebpage.cpp:
+ * Api/qwebpage.h:
+ * Api/qwebsettings.cpp:
+ * Api/qwebview.cpp:
+
+2008-04-28 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix QWebView::loadFinished isn't always emitted
+
+ Replaced loadDone() with loadFinished(bool) and moved the signals for progress
+ tracking (start, progres, and finish) to the page instead of the frame. This
+ ensures that we emit loadFinished even when a subframe started the actual load.
+
+ This causes a few regressions in the layout tests that we for now accept for
+ the sake of the correct API. Layout tests we can fix any time though, including
+ patch release, the API however we can't change anymore in patch releases.
+
+ * Api/qwebframe.cpp:
+ * Api/qwebframe.h:
+ * Api/qwebpage.cpp:
+ (QWebPage::totalBytes):
+ * Api/qwebpage.h:
+ * Api/qwebview.cpp:
+ (QWebView::setPage):
+ * Api/qwebview.h:
+ * QtLauncher/main.cpp:
+ (MainWindow::MainWindow):
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (drtDescriptionSuitableForTestResult):
+ (WebCore::FrameLoaderClientQt::FrameLoaderClientQt):
+ (WebCore::FrameLoaderClientQt::setFrame):
+ (WebCore::FrameLoaderClientQt::transitionToCommittedFromCachedPage):
+ (WebCore::FrameLoaderClientQt::transitionToCommittedForNewPage):
+ (WebCore::FrameLoaderClientQt::willChangeTitle):
+ (WebCore::FrameLoaderClientQt::createDocumentLoader):
+ (WebCore::FrameLoaderClientQt::download):
+ (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction):
+ * WebCoreSupport/FrameLoaderClientQt.h:
+
+2008-04-28 Kavindra Devi Palaraja <kdpalara@trolltech.com>
+
+ Reviewed by Simon.
+
+ Added more documentation for QWebSettings, QWebPluginFactory and QWebFrame
+
+ * Api/qwebframe.cpp:
+ * Api/qwebpluginfactory.cpp:
+ * Api/qwebsettings.cpp:
+ (QWebSettings::QWebSettings):
+ (QWebSettings::setUserStyleSheetUrl):
+ (QWebSettings::iconForUrl):
+ (QWebSettings::webGraphic):
+ (QWebSettings::maximumPagesInCache):
+ (QWebSettings::setFontFamily):
+ (QWebSettings::resetFontFamily):
+ (QWebSettings::testAttribute):
+ (QWebSettings::resetAttribute):
+
+2008-04-28 Ariya Hidayat <ahidayat@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix document/frame title not reset when loading a new URI
+
+ We should assume first the frame has no title. If it has, then the dispatchDidReceiveTitle()
+ will be called very soon with the correct title.
+ This properly resets the title when we navigate to a URI without a title.
+
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+
+2008-04-28 David Boddie <dboddie@trolltech.com>
+
+ Reviewed by Simon.
+
+ Minor documentation changes.
+
+ * Api/qwebview.cpp:
+
+2008-04-28 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon.
+
+ Prevent middle-click from triggering open URL from clipboard when the event has already been accepted.
+
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::mouseMoveEvent):
+ (QWebPagePrivate::mousePressEvent):
+ (QWebPagePrivate::mouseDoubleClickEvent):
+ (QWebPagePrivate::mouseTripleClickEvent):
+ (QWebPagePrivate::mouseReleaseEvent):
+
+2008-04-28 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix scrollbar behavior in QtWebKit to match QScrollBar.
+
+ Right click context menu is now supported, along with
+ middle click to center slider thumb over mouse cursor.
+
+
+ * Api/qwebpage.cpp:
+ (QWebPage::linkDelegationPolicy):
+
+2008-04-28 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon.
+
+ Implemented channel-based logging for QtWebKit.
+
+ Comma-separated log channels are read from the QT_WEBKIT_LOG environment variable.
+ Warnings for notImplemented() is still output by default, but can be disabled
+ by setting DISABLE_NI_WARNINGS=1.
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::QWebPagePrivate):
+
+2008-04-28 Simon Hausmann <shausman@trolltech.com>
+
+ Rubber-stamped by Lars
+
+ Removed setHtml(const QByteArray &) overload as it breaks the common use of the setHtml() API.
+
+ * Api/qwebframe.cpp:
+ * Api/qwebframe.h:
+ * Api/qwebview.cpp:
+ * Api/qwebview.h:
+
+2008-04-28 Kavindra Devi Palaraja <kdpalara@trolltech.com>
+
+ Reviewed by Simon.
+
+ Doc - adding more documentation to QWebFrame, QWebPage and QWebView
+
+
+ * Api/qwebframe.cpp:
+ * Api/qwebpage.cpp:
+ * Api/qwebview.cpp:
+ (QWebView::stop):
+ (QWebView::back):
+ (QWebView::changeEvent):
+
+2008-04-28 Simon Hausmann <shausman@trolltech.com>
+
+ Reviewed by Holger.
+
+ Fixes: Popups/Context menu in WebKit appearing at the wrong location when embedded in the graphics view or using multiple screens
+
+ Give the popups the right parent widget and the right coordinates relative within the parent.
+
+
+ * Api/qwebpage.cpp:
+
+2008-04-28 Benjamin Meyer <bmeyer@trolltech.com>
+
+ Reviewed by Simon.
+
+ Doc: Add see also's (and a few minor whitespace/typo corrections)
+
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::~QWebFrame):
+ (QWebFrame::setHtml):
+ (QWebFrame::setContent):
+ (QWebFrame::parentFrame):
+ (QWebFrame::childFrames):
+ (QWebFrame::setScrollBarValue):
+ (QWebFrame::scrollBarValue):
+ (QWebFrame::scrollBarMaximum):
+ (QWebFrame::scrollBarMinimum):
+ (QWebFrame::render):
+ (QWebFrame::pos):
+ (QWebFrame::geometry):
+ (QWebFrame::print):
+ (QWebFrame::evaluateJavaScript):
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::mousePressEvent):
+ (QWebPagePrivate::mouseDoubleClickEvent):
+ (QWebPage::~QWebPage):
+ (QWebPage::javaScriptPrompt):
+ (openNewWindow):
+ (QWebPage::setViewportSize):
+ (QWebPage::acceptNavigationRequest):
+ (QWebPage::action):
+ (QWebPage::userAgentForUrl):
+ (QWebPagePrivate::_q_onLoadProgressChanged):
+ * Api/qwebview.cpp:
+ (QWebView::event):
+
+2008-04-28 Kavindra Devi Palaraja <kdpalara@trolltech.com>
+
+ Reviewed by Simon.
+
+ Submitting more documentation for QWebPage
+
+
+ * Api/qwebpage.cpp:
+
+2008-04-28 Lincoln Ramsay <lincoln.ramsay@trolltech.com>
+
+ Reviewed by Simon.
+
+ Compile when QT_NO_CLIPBOARD is defined.
+
+
+ * Api/qwebpage.cpp:
+ (QWebPage::triggerAction):
+
+2008-04-28 David Boddie <dboddie@trolltech.com>
+
+ Reviewed by Simon.
+
+ Minor documentation fix.
+
+
+ * Api/qwebhistory.cpp:
+
+2008-04-28 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Reviewed by Simon.
+
+ Implement QWebPage::createPlugin
+
+ The code is coming from the demo browser and needed here
+ for some manual tests.
+
+
+ * QtLauncher/QtLauncher.pro:
+ * QtLauncher/main.cpp:
+ (WebPage::createPlugin):
+
+2008-04-28 Simon Hausmann <hausmann@webkit.org>
+
+ Qt/Win build fix. Include config.h to get the implicit MathExtras.h
+ inclusion correct with regards to rand_s.
+
+ * Api/qwebhistory.cpp:
+
+2008-04-28 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon.
+
+ https://bugs.webkit.org/show_bug.cgi?id=18713
+
+ Fix scrollbar painting issues in QtWebKit.
+
+ Hovering and click-draging outside of the scrollbar would
+ produce unexpected and inconcistent results. We also didn't
+ pass on leave-events to the underlying WebKit code, which
+ was nessecary to implement the paint fix.
+
+ Note: The event handling of the Leave event should be moved
+ out of QWebView::event() and into a proper override for 4.5.
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::leaveEvent):
+ * Api/qwebpage_p.h:
+ * Api/qwebview.cpp:
+ (QWebView::event):
+
+2008-04-25 Benjamin Meyer <bmeyer@trolltech.com>
+
+ Reviewed by Simon, Holger.
+
+ Fixed focus handling when a node is focused while the corresponding QWebPage does not have the focus.
+
+ * Correctly de- and reactivate the focused frame in focusOut/focusInEvent
+ without telling the focus controller. We don't want to change the focused frame
+ - the controller has to remember it in fact - but instead just deactivate the
+ frame for correct painting as RenderTheme::isFocused() uses the activation
+ state of the frame.
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::focusInEvent):
+ (QWebPagePrivate::focusOutEvent):
+
+2008-04-25 Kavindra Devi Palaraja <kdpalara@trolltech.com>
+
+ Reviewed by Simon.
+
+ completed documentation for the Detailed Description section for QWebView
+
+
+ * Api/qwebview.cpp:
+
+2008-04-25 Denis Dzyubenko <denis.dzyubenko@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fixed the way QWebHistory works - when you call back(), forward() or goToItem() functions it changes the current item in history *and* loads the corresponding page.
+
+
+ * Api/qwebhistory.cpp:
+ (QWebHistory::back):
+ (QWebHistory::forward):
+ (QWebHistory::goToItem):
+
+2008-04-25 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix resubmit of HTML forms when initially denied by QWebPage::acceptNavigationRequest().
+
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::createFrame):
+
+2008-04-25 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger.
+
+ When pressing backspace in a line edit in a webpage we should not go back to the previous page.
+
+ The shortcut for back on Windows is backspace. Implemented shortcut override
+ handling in QWebView/QWebPage to prevent this.
+
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::wheelEvent):
+ (editorActionForKeyEvent):
+ (QWebPagePrivate::keyPressEvent):
+ (QWebPagePrivate::inputMethodEvent):
+ (QWebPagePrivate::shortcutOverrideEvent):
+ (QWebPage::event):
+ * Api/qwebpage_p.h:
+ * Api/qwebview.cpp:
+ (QWebView::event):
+
+2008-04-25 Ariya Hidayat <ariya.hidayat@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix triple-clicking does not work in a web page
+
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::updateEditorActions):
+ (QWebPagePrivate::timerEvent):
+ (QWebPagePrivate::mousePressEvent):
+ (QWebPagePrivate::mouseDoubleClickEvent):
+ (QWebPage::undoStack):
+ * Api/qwebpage_p.h:
+
+2008-04-25 Benjamin Meyer <bmeyer@trolltech.com>
+
+ Reviewed by Simon.
+
+ When pressing Ctrl-Up the keyboard modifiers could include other modifiers
+
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::keyPressEvent):
+
+2008-04-25 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix handling of Javascript's confirm() function in QtWebKit.
+
+
+ * Api/qwebpage.cpp:
+
+2008-04-25 Kavindra Devi Palaraja <kdpalara@trolltech.com>
+
+ Reviewed by Simon.
+
+ Doc - added a screenshot, flowchart, and a snippet to the QWebView documentation to improve clarity
+
+
+ * Api/qwebview.cpp:
+
+2008-04-25 Benjamin Meyer <bmeyer@trolltech.com>
+
+ Reviewed by Simon.
+
+ QWebPage: missing signal when window.print() is requested from javascript
+
+
+ * Api/qwebpage.cpp:
+ * Api/qwebpage.h:
+ * WebCoreSupport/ChromeClientQt.cpp:
+
+2008-04-25 Benjamin Meyer <bmeyer@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fixes: "Save Image" action wasn't doing anything.
+
+
+ * Api/qwebpage.cpp:
+ (QWebPage::triggerAction):
+
+2008-04-25 Benjamin Meyer <bmeyer@trolltech.com>
+
+ Reviewed by Simon.
+
+ Apply key event changes to the current frame, not the main frame.
+
+ Example: hitting space bar should scroll current frame, not the main frame
+ which doesn't even have a scrollbar.
+
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::keyPressEvent):
+
+2008-04-25 Benjamin Meyer <bmeyer@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fixes: QWebFrame crash when fetching the icon
+
+ Just call QWebSettings::iconForUrl to not duplicate code and obey the mutex lock.
+
+ * Api/qwebframe.cpp:
+
+2008-04-25 Warwick Allison <warwick@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fixes: Scrollbars did not report correct maximum.
+
+ * Api/qwebframe.cpp:
+
+2008-04-25 David Boddie <dboddie@trolltech.com>
+
+ Reviewed by Simon.
+
+ Documentation updates for some of the QWeb classes
+
+ * Api/qwebframe.cpp:
+ * Api/qwebhistory.cpp:
+ * Api/qwebsettings.cpp:
+ * Api/qwebview.cpp:
+
+2008-04-25 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Reviewed by Simon.
+
+ Implement dumping of resource load callbacks to pass http/tests/xmlhttprequest/abort-should-cancel-load.html
+
+ Similar to Editing and Frameloading we do the dumping within WebCore
+
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (qt_dump_frame_loader):
+ (qt_dump_resource_load_callbacks):
+ (drtDescriptionSuitableForTestResult):
+ (WebCore::FrameLoaderClientQt::dispatchDidFailLoading):
+ (WebCore::FrameLoaderClientQt::dispatchDidLoadResourceFromMemoryCache):
+ (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForMIMEType):
+
+2008-04-24 Anders Carlsson <andersca@apple.com>
+
+ Reviewed by Sam.
+
+ Change some String arguments to be const references instead.
+
+ * WebCoreSupport/EditorClientQt.cpp:
+ (WebCore::EditorClientQt::shouldInsertText):
+ * WebCoreSupport/EditorClientQt.h:
+
+2008-04-24 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Reviewed by Simon.
+
+ Cosmetic changes to make the code more readable.
+ -Early exit if we don't have a webview
+ -handle the empty tooltip and non-empty tooltip case separately
+
+
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::setToolTip):
+ (WebCore::ChromeClientQt::print):
+
+2008-04-24 Paul Olav Tvete <paul@trolltech.com>
+
+ Reviewed by Simon.
+
+ Automatically wrap tooltip text and hide a shown tooltip when it is empty.
+
+ QWidget::setTooltip("") will still show the old tooltip for up to 10 seconds.
+ Workaround as discussed with Matthias.
+
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::setToolTip):
+
+2008-04-24 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Reviewed by Simon.
+
+ Allow to disable caching completeley by calling setObjectCacheCapacities(0, 0, 0)
+
+ * Api/qwebsettings.cpp:
+ (QWebSettings::setObjectCacheCapacities):
+
+2008-04-24 Benjamin Meyer <bmeyer@trolltech.com>
+
+ Reviewed by Simon.
+
+ Improve keyboard scrolling
+
+ Match Down/Up keys scroll distance with Safari (i.e. faster) and add Home and End shortcuts to scroll to the top/botom.
+
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::keyPressEvent):
+
+2008-04-24 Olivier Goffart <ogoffart@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix various compiler warnings in the Qt port.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::print):
+ * Api/qwebsettings.cpp:
+ (graphics):
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::createPlugin):
+
+2008-04-24 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon.
+
+ Cleaned up copyright headers (removed misplaced class descriptions and
+ fixed inconsistent whitespace and indentation).
+
+ * Api/qwebframe.cpp:
+ * Api/qwebframe.h:
+ * Api/qwebframe_p.h:
+ * Api/qwebhistory.cpp:
+ * Api/qwebhistory.h:
+ * Api/qwebhistory_p.h:
+ * Api/qwebhistoryinterface.cpp:
+ * Api/qwebhistoryinterface.h:
+ * Api/qwebkitglobal.h:
+ * Api/qwebnetworkinterface.cpp:
+ * Api/qwebnetworkinterface.h:
+ * Api/qwebnetworkinterface_p.h:
+ * Api/qwebpage.cpp:
+ * Api/qwebpage.h:
+ * Api/qwebpage_p.h:
+ * Api/qwebpluginfactory.cpp:
+ * Api/qwebpluginfactory.h:
+ * Api/qwebsettings.cpp:
+ * Api/qwebsettings.h:
+ * Api/qwebview.h:
+ * QtLauncher/main.cpp:
+
+2008-04-24 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon.
+
+ Added basic URL guessing to QtLauncher (same as in the demo browser).
+
+
+ * QtLauncher/main.cpp:
+ (MainWindow::changeLocation):
+ (MainWindow::guessUrlFromString):
+
+2008-04-24 Benjamin Meyer <bmeyer@trolltech.com>
+
+ Reviewed by Simon Hausmann <hausmann@webkit.org>.
+
+ Prevent double deletions of the default web interface.
+
+
+ * Api/qwebhistoryinterface.cpp:
+ (gCleanupInterface):
+ (QWebHistoryInterface::QWebHistoryInterface):
+
+2008-04-23 Simon Hausmann <hausmann@webkit.org>
+
+ Fix compilation against Qt 4.3
+
+ * Api/qwebpage.cpp:
+ (QWebPage::userAgentForUrl):
+ * QtLauncher/main.cpp:
+ (main):
+
+2008-04-23 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Reviewed by Simon.
+
+ * Make sure the "Inspect Element" item gets added to the ContextMenu, a call
+ to ContextMenu::populate() is not adding it, the ContextMenuController does
+ add it after the call to populate(). Do that as well.
+
+
+ * Api/qwebpage.cpp:
+ (QWebPage::updatePositionDependentActions):
+
+2008-04-23 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger.
+
+ Fix crashes on window.close().
+
+ We should not delete the QWebPage object in the ChromeClient but leave it up to
+ the application when and whether to delete a browser window. For this we now
+ emit the windowCloseRequested() signal.
+
+ Done with Tor Arne.
+
+ * Api/qwebpage.cpp:
+ * Api/qwebpage.h:
+ * QtLauncher/main.cpp:
+ (MainWindow::MainWindow):
+ * WebCoreSupport/ChromeClientQt.cpp:
+
+2008-04-23 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger.
+
+ Fix parsing of external scripts/stylesheets when using setHtml(const QString &html).
+
+ We used to pass the html string to the frameloader in utf-16, which also meant that the default
+ encoding of external scripts/stylesheets became utf-16. That doesn't make sense, so assume utf-8
+ by default. This is now also documented.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::setHtml):
+ * Api/qwebview.cpp:
+
+2008-04-23 Benjamin Meyer <bmeyer@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fixes background color propagation when using a custom QWebPage
+
+ Set the palette in setPage(), not during the creation on-demand.
+
+
+ * Api/qwebview.cpp:
+ (QWebView::page):
+ (QWebView::setPage):
+
+2008-04-23 Benjamin Meyer <bmeyer@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix the user agent on the mac to be BSD4
+
+ Put Q_OS_DARWIN before Q_OS_BSD4 sense they are both defined on the mac
+
+
+ * Api/qwebpage.cpp:
+ (QWebPage::userAgentForUrl):
+
+2008-04-23 Simon Hausmann <shausman@trolltech.com>
+
+ Reviewed by Holger.
+
+ Added missing copyright notice.
+ Small fixes to the documentation.
+
+ * Api/qwebpluginfactory.cpp:
+
+2008-04-23 Zack Rusin <zack@tungstengraphics.com>
+
+ Reviewed by Simon.
+
+ Added a contentsSize() property.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::contentsSize):
+ (QWebFrame::hitTestContent):
+ * Api/qwebframe.h:
+
+2008-04-22 Benjamin Meyer <bmeyer@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fixes: QWebPage's QNetworkManager's can be shared among webpages.
+
+ Don't force the deletion of the object, but let QObject take care of it.
+
+ * Api/qwebpage.cpp:
+
+2008-04-22 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger.
+
+ Documentation for QWebPluginFactory and documentation updates for QWebPage.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::setLinkDelegationPolicy):
+ (QWebPage::linkDelegationPolicy):
+ (QWebPage::swallowContextMenuEvent):
+ (QWebPage::updatePositionDependentActions):
+ (QWebPage::extension):
+ (QWebPage::networkAccessManager):
+ * Api/qwebpluginfactory.cpp:
+ (QWebPluginFactory::QWebPluginFactory):
+ (QWebPluginFactory::~QWebPluginFactory):
+ (QWebPluginFactory::refreshPlugins):
+
+2008-04-22 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger.
+
+ Added QWebPage::swallowContextMenuEvent and QWebPage::updatePositionDependentActions.
+
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::QWebPagePrivate):
+ (QWebPagePrivate::mouseReleaseEvent):
+ (QWebPage::setLinkDelegationPolicy):
+ (QWebPage::linkDelegationPolicy):
+ (QWebPage::swallowContextMenuEvent):
+ (QWebPage::updatePositionDependentActions):
+ * Api/qwebpage.h:
+ * Api/qwebpage_p.h:
+ * Api/qwebview.cpp:
+ (QWebView::event):
+
+2008-04-22 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger.
+
+ Added Extension APIs for QWebPage.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::setLinkDelegationPolicy):
+ (QWebPage::linkDelegationPolicy):
+ (QWebPage::extension):
+ * Api/qwebpage.h:
+ * Api/qwebpluginfactory.cpp:
+ (QWebPluginFactory::extension):
+
+2008-04-22 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon.
+
+ Emit loadProgress() signal on loadStarted().
+
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::postProgressEstimateChangedNotification):
+
+2008-04-22 Zack Rusin <zack@kde.org>
+
+ Reviewed by Simon.
+
+ Fix background propagation from the QWebView's palette.
+
+ The background brush of the palette needs to be propagated to the WebCore::FrameView.
+
+ * Api/qwebframe.cpp:
+ (QWebFramePrivate::updateBackground):
+ * Api/qwebframe_p.h:
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::dropEvent):
+ (QWebPage::setPalette):
+ * Api/qwebpage.h:
+ * Api/qwebpage_p.h:
+ * Api/qwebview.cpp:
+ (QWebView::page):
+ (QWebView::changeEvent):
+ * Api/qwebview.h:
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+
+2008-04-22 Benjamin Meyer <bmeyer@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix maps.google.com
+
+ We have to include a version in the Safari tag in the user-agent.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::userAgentForUrl):
+
+2008-04-22 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon.
+
+ Add visual focusing hint for clear button and
+ change focus to web page after user enters new URL.
+
+ * QtLauncher/main.cpp:
+ (ClearButton::paintEvent):
+ (MainWindow::changeLocation):
+
+2008-04-22 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger.
+
+ Added QWebFrame::hitTestContent() and QWebHitTestResult.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::hitTestContent):
+ (QWebFrame::event):
+ (QWebHitTestResult::QWebHitTestResult):
+ (QWebHitTestResultPrivate::QWebHitTestResultPrivate):
+ (QWebHitTestResult::operator=):
+ (QWebHitTestResult::~QWebHitTestResult):
+ (QWebHitTestResult::isNull):
+ (QWebHitTestResult::pos):
+ (QWebHitTestResult::title):
+ (QWebHitTestResult::linkText):
+ (QWebHitTestResult::linkUrl):
+ (QWebHitTestResult::linkTitle):
+ (QWebHitTestResult::linkTargetFrame):
+ (QWebHitTestResult::alternateText):
+ (QWebHitTestResult::imageUrl):
+ (QWebHitTestResult::pixmap):
+ (QWebHitTestResult::isContentEditable):
+ (QWebHitTestResult::isContentSelected):
+ (QWebHitTestResult::frame):
+ * Api/qwebframe.h:
+ * Api/qwebframe_p.h:
+ (QWebHitTestResultPrivate::QWebHitTestResultPrivate):
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::contextMenuEvent):
+ (QWebPage::triggerAction):
+ * Api/qwebpage.h:
+ * Api/qwebpage_p.h:
+
+2008-04-22 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger.
+
+ Don't crash if an input method query is done without a page.
+
+
+ * Api/qwebview.cpp:
+ (QWebView::inputMethodQuery):
+
+2008-04-22 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger.
+
+ Added re-implementations of QObject::event for future safety.
+
+ This makes it easier to fix bugs with the event handling even in patch releases
+ and is a general style we follow in Qt.
+
+
+ * Api/qwebframe.cpp:
+ * Api/qwebframe.h:
+ * Api/qwebview.cpp:
+ (QWebView::event):
+ * Api/qwebview.h:
+
+2008-04-22 Benjamin Meyer <bmeyer@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix construction of the user agent.
+
+ The user-agent is now composed of
+ * the platform and subplatform
+ * the Qt version or application name and version (if set)
+ * the locale
+ * the SSL settings
+
+
+ * Api/qwebpage.cpp:
+ (QWebPage::networkAccessManager):
+ (QWebPage::setPluginFactory):
+ (QWebPage::pluginFactory):
+ (QWebPage::userAgentForUrl):
+ * QtLauncher/main.cpp:
+
+2008-04-22 Thiago Macieira <tjmaciei@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fixes: Pedantic compilation fix
+
+ Don't put semi-colons after braces closing namespaces.
+
+ * Api/qwebsettings.h:
+
+2008-04-21 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Lars.
+
+ Changed the return type of QWebFrame::evaluateJavaScript from a QString to a QVariant.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::evaluateJavaScript):
+ * Api/qwebframe.h:
+
+2008-04-21 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger.
+
+ Fixes redundant "Fonts" submenu in default lineedits that has only disabled items.
+
+ Don't show sub-menus that have only actions that are disabled.
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::createContextMenu):
+
+2008-04-21 Kavindra Devi Palaraja <kdpalara@trolltech.com>.
+
+ Reviewed by Simon.
+
+ Lots of documentation fixes, fixed all qdoc warnings.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::setTextSizeMultiplier):
+ * Api/qwebhistoryinterface.cpp:
+ (gCleanupInterface):
+ (QWebHistoryInterface::QWebHistoryInterface):
+ (QWebHistoryInterface::~QWebHistoryInterface):
+ * Api/qwebpage.cpp:
+ (QWebPage::inputMethodQuery):
+ (QWebPage::view):
+ (QWebPage::javaScriptConsoleMessage):
+ (QWebPage::javaScriptAlert):
+ (QWebPage::javaScriptConfirm):
+ (QWebPage::javaScriptPrompt):
+ (QWebPage::viewportSize):
+ (QWebPage::acceptNavigationRequest):
+ (QWebPage::action):
+ (QWebPage::event):
+ (QWebPage::focusNextPrevChild):
+ (QWebPage::setForwardUnsupportedContent):
+ (QWebPage::setLinkDelegationPolicy):
+ (QWebPage::findText):
+ (QWebPage::settings):
+ (QWebPage::networkProxy):
+ (QWebPage::setNetworkAccessManager):
+ * Api/qwebpage.h:
+ * Api/qwebsettings.cpp:
+ (QWebSettings::QWebSettings):
+ (QWebSettings::setIconDatabasePath):
+ (QWebSettings::iconForUrl):
+ (QWebSettings::fontFamily):
+ * Api/qwebview.cpp:
+ (QWebView::load):
+ * Api/qwebview.h:
+
+2008-04-21 Marius Bugge Monsen <mmonsen@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix compile failure on solaris-cc
+
+ * Api/qwebpage.h: Removed trailing semicolons and moved the private
+ d-pointer to not confuse the compiler
+
+2008-04-21 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
+
+ Reviewed by Simon.
+
+ Build fix for Qt 4.3
+
+ * When building WebCore/internal make sure the QT_[BEGIN,END]_NAMESPACE is
+ always defined. Do this by adding defines to the compiler line
+ * For users of our API this is not feasible. Every public header file should
+ include qwebkitglobal.h. Define the QT_BEGIN_NAMESPACE and QT_END_NAMESPACE
+ when we are building everything < 4.4.0 and don't have them defined.
+
+ * Api/qwebkitglobal.h:
+
+2008-04-21 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
+
+ Reviewed by Simon.
+
+ * Initialize the WebGraphics with the one found in WebCore
+
+
+ * Api/qwebsettings.cpp:
+ (QWebSettingsPrivate::apply):
+
+2008-04-21 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
+
+ Reviewed by Simon.
+
+ * Allow TextAreas to be resized.
+ * No QWebSettings for this is introduced.
+
+
+ * Api/qwebsettings.cpp:
+ (QWebSettingsPrivate::apply):
+
+2008-04-21 Simon Hausmann <shausman@trolltech.com>
+
+ Reviewed by Holger.
+
+ Fixes: QWebView::url property behaviour strange in designer
+
+ Added QWebView/QWebFrame::setUrl, which unlike load() clears the view immediately, schedules a load of the url but also makes sure url() returns the set url. This setter is now also used for the url property.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::setUrl):
+ * Api/qwebframe.h:
+ * Api/qwebview.cpp:
+ (QWebView::setUrl):
+ * Api/qwebview.h:
+
+2008-04-21 Andre Poenitz <andre.poenitz@trolltech.com>
+
+ Reviewed by Simon Hausmann <hausmann@webkit.org>.
+
+ Fix compilation with Qt namespaces
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::print):
+ * Api/qwebview.h:
+
+2008-04-21 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger.
+
+ When printing on high resolution printers we need to scale the painter accordingly (for now).
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::print):
+
+2008-04-21 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger.
+
+ Provide a print preview in the QtLauncher
+
+ * QtLauncher/main.cpp:
+ (MainWindow::MainWindow):
+ (MainWindow::showLinkHover):
+ (MainWindow::print):
+
+2008-04-20 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Alp Toker.
+
+ Share the printing code between the Gtk and the Qt port
+ and added printing to the Qt WebKit API.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::print):
+ * Api/qwebframe.h:
+ * Api/qwebview.cpp:
+ (QWebView::print):
+ * Api/qwebview.h:
+
+2008-04-19 Julien Chaffraix <jchaffraix@webkit.org>
+
+ Qt build fix (renderer() -> contentRenderer()).
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::renderTreeDump):
+ (QWebFrame::render):
+
+2008-04-18 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger.
+
+ Many API changes and additions after a full review with Jasmin Blanchette <jasmin@trolltech.com>
+
+ The diff is too big to mention the changes individually, but most of the changes were of cosmetic
+ nature where methods or enums have been renamed or prefixed/suffixed according to the consistency
+ rules of the Qt API.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::addToJavaScriptWindowObject):
+ (QWebFrame::toHtml):
+ (QWebFrame::toPlainText):
+ (QWebFrame::icon):
+ (QWebFrame::setContent):
+ (QWebFrame::setScrollBarPolicy):
+ (QWebFrame::render):
+ (QWebFrame::setTextSizeMultiplier):
+ (QWebFrame::textSizeMultiplier):
+ (QWebFrame::pos):
+ * Api/qwebframe.h:
+ * Api/qwebhistory.cpp:
+ * Api/qwebhistory.h:
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::QWebPagePrivate):
+ (QWebPagePrivate::~QWebPagePrivate):
+ (QWebPagePrivate::acceptNavigationRequest):
+ (webActionForContextMenuAction):
+ (QWebPagePrivate::updateAction):
+ (QWebPagePrivate::keyPressEvent):
+ (QWebPage::view):
+ (QWebPage::javaScriptPrompt):
+ (QWebPage::createWindow):
+ (QWebPage::triggerAction):
+ (QWebPage::setViewportSize):
+ (QWebPage::acceptNavigationRequest):
+ (QWebPage::action):
+ (QWebPage::focusNextPrevChild):
+ (QWebPage::setForwardUnsupportedContent):
+ (QWebPage::forwardUnsupportedContent):
+ (QWebPage::setLinkDelegationPolicy):
+ (QWebPage::findText):
+ (QWebPage::networkAccessManager):
+ (QWebPageContext::imageUrl):
+ (QWebPageContext::image):
+ * Api/qwebpage.h:
+ * Api/qwebpage_p.h:
+ * Api/qwebsettings.cpp:
+ (QWebSettingsPrivate::apply):
+ (QWebSettings::QWebSettings):
+ (QWebSettings::setIconDatabasePath):
+ (QWebSettings::iconDatabasePath):
+ (QWebSettings::clearIconDatabase):
+ (QWebSettings::iconForUrl):
+ (QWebSettings::setWebGraphic):
+ (QWebSettings::fontFamily):
+ (QWebSettings::setAttribute):
+ (QWebSettings::testAttribute):
+ (QWebSettings::resetAttribute):
+ * Api/qwebsettings.h:
+ * Api/qwebview.cpp:
+ (QWebView::setPage):
+ (QWebView::icon):
+ (QWebView::setTextSizeMultiplier):
+ (QWebView::textSizeMultiplier):
+ (QWebView::findText):
+ (QWebView::reload):
+ (QWebView::mouseMoveEvent):
+ * Api/qwebview.h:
+ * QtLauncher/main.cpp:
+ (MainWindow::MainWindow):
+ (main):
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::ChromeClientQt):
+ (WebCore::ChromeClientQt::setWindowRect):
+ (WebCore::ChromeClientQt::toolbarsVisible):
+ (WebCore::ChromeClientQt::setStatusbarVisible):
+ (WebCore::ChromeClientQt::statusbarVisible):
+ (WebCore::ChromeClientQt::setScrollbarsVisible):
+ (WebCore::ChromeClientQt::setResizable):
+ (WebCore::ChromeClientQt::scrollBackingStore):
+ (WebCore::ChromeClientQt::mouseDidMoveOverElement):
+ (WebCore::ChromeClientQt::setToolTip):
+ * WebCoreSupport/ChromeClientQt.h:
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::setFrame):
+ (WebCore::FrameLoaderClientQt::didPerformFirstNavigation):
+ (WebCore::FrameLoaderClientQt::setMainDocumentError):
+ (WebCore::FrameLoaderClientQt::dispatchDidFailLoading):
+ (WebCore::FrameLoaderClientQt::createFrame):
+ (WebCore::FrameLoaderClientQt::objectContentType):
+ * WebCoreSupport/FrameLoaderClientQt.h:
+ * WebCoreSupport/InspectorClientQt.cpp:
+
+2008-04-18 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger.
+
+ Added QWebView::find/QWebFrame::find.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::focusNextPrevChild):
+ (QWebPage::find):
+ * Api/qwebpage.h:
+ * Api/qwebview.cpp:
+ (QWebView::find):
+ * Api/qwebview.h:
+
+2008-04-15 Ariya Hidayat <ariya.hidayat@trolltech.com>
+
+ Reviewed by Simon.
+
+ fix potential crash when loading image(s)
+
+ Crash may occur. If compiled with 4.3, the variable is not initialized.
+ This fix solves https://bugs.webkit.org/show_bug.cgi?id=17174
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::QWebPagePrivate):
+
+2008-04-15 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger.
+
+ Update the micro focus for input methods as soon as the composition mode changes
+ or the caret/selection changes.
+
+
+ * Api/qwebpage.cpp:
+ * Api/qwebpage.h:
+ * Api/qwebview.cpp:
+ (QWebView::setPage):
+ * WebCoreSupport/EditorClientQt.cpp:
+ (WebCore::EditorClientQt::respondToChangedSelection):
+ (WebCore::EditorClientQt::setInputMethodState):
+
+2008-04-15 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger.
+
+ Don't use QDir, QString or any locale sensitive function before constructing Q(Core)Application,
+ it yields undefined behaviour or wrong default codec initialization.
+
+
+ * QtLauncher/main.cpp:
+ (WebPage::createWindow):
+
+2008-04-15 Olivier Goffart <ogoffart@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fixes: copy to clipboard when selecting, and paste when clicking with the middle button
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::mouseReleaseEvent): If the clipboard supports
+ selections then we support copy & paste into the selection.
+
+2008-04-15 Michael Brasser <michael.brasser@trolltech.com>
+
+ Reviewed by Simon.
+
+ Add basic input method support.
+
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::dropEvent):
+ (QWebPagePrivate::inputMethodEvent):
+ (QWebPage::inputMethodQuery):
+ (QWebPage::event):
+ * Api/qwebpage.h:
+ * Api/qwebpage_p.h:
+ * Api/qwebview.cpp:
+ (QWebView::QWebView):
+ (QWebView::inputMethodQuery):
+ (QWebView::inputMethodEvent):
+ * Api/qwebview.h:
+ * WebCoreSupport/EditorClientQt.cpp:
+ (WebCore::EditorClientQt::setInputMethodState):
+
+2008-04-15 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger.
+
+ Added (QWebFrame|QWebView)::textZoomFactor.
+
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::setTextZoomFactor):
+ (QWebFrame::textZoomFactor):
+ * Api/qwebframe.h:
+ * Api/qwebview.cpp:
+ (QWebView::setTextZoomFactor):
+ (QWebView::textZoomFactor):
+ * Api/qwebview.h:
+
+2008-04-15 Michael Brasser <michael.brasser@trolltech.com>
+
+ Reviewed by Simon.
+
+ Added simple scrolling API to QWebFrame.
+
+ The intent is that it works similar to QAbstractScrollArea.
+
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::setScrollBarValue):
+ (QWebFrame::scrollBarValue):
+ (QWebFrame::scrollBarMaximum):
+ (QWebFrame::scrollBarMinimum):
+ * Api/qwebframe.h:
+
+2008-04-15 Olivier Goffart <ogoffart@trolltech.com>
+
+ Reviewed by Holger.
+
+ Fixes: implement the OpenFrameInNewWindow action.
+
+
+ * Api/qwebpage.cpp:
+ (QWebPage::triggerAction):
+
+2008-04-15 Andre Poenitz <andre.poenitz@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fix compilation with Qt namespaces
+
+ Qt can be configured to have all of its classes inside a specified namespaces.
+ This is for example used in plugin/component environments like Eclipse.
+
+ This change makes it possible to let the Qt port compile against a namespaced
+ Qt by the use of macros Qt provides to properly forward declare Qt classes in
+ the namespace.
+
+ * Api/qwebframe.h:
+ * Api/qwebpage.h:
+ * Api/qwebpage_p.h:
+ * Api/qwebpluginfactory.h:
+ * Api/qwebsettings.h:
+ * Api/qwebview.h:
+
+2008-04-05 Olivier Goffart <ogoffart@trolltech.com>
+
+ Reviewed by Holger.
+
+ Fixes: Right clicking an image and choosing "copy image" doesnt put anything in the clipboard.
+
+
+ * Api/qwebpage.cpp:
+ (QWebPage::triggerAction):
+
+2008-04-05 Olivier Goffart <ogoffart@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fixes: Right click, and "Open image" open the link instead of the image.
+
+
+ * Api/qwebpage.cpp:
+
+2008-04-05 Benjamin Meyer <bmeyer@trolltech.com>
+
+ Reviewed by Simon.
+
+ Added doc stub for QWebSettings so class docs are generated
+
+
+ * Api/qwebsettings.cpp:
+ (QWebSettings::QWebSettings):
+
+2008-04-05 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
+
+ Reviewed by Simon.
+
+ * Propose the addition of updateRequest and scrollRequest to the QWebPage.
+
+ * The question is if these signals belong to QWebPage or QWebFrame.
+ -It is more easy to have them in QWebPage because ScrollView is invoking
+ the ChromeClient with the right coordinates
+ -On the other hand someone wants to render frames separately. But this is partly
+ doomed as you can have overlapping frames and what you paint would not relate to
+ what you normally see on webpages.
+
+
+ * Api/qwebpage.cpp:
+ * Api/qwebpage.h:
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::scrollBackingStore):
+ (WebCore::ChromeClientQt::mouseDidMoveOverElement):
+
+2008-04-03 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Mark Rowe.
+
+ Roll out r31599 and r31605 again after discussion with Mark Rowe.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::icon):
+ * Api/qwebsettings.cpp:
+ (QWebSettings::iconForUrl):
+
+2008-04-03 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
+
+ Reviewed by Simon.
+
+ * Change IconDatabase::iconForPageURL to return more information. E.g. if
+ an image has been found, or if the loading of an image has been scheduled.
+ * Update FrameLoader to use another method to trigger reading from disk
+ * Update the QWebFrame and QWebSettings
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::icon):
+ * Api/qwebsettings.cpp:
+ (QWebSettings::iconForUrl):
+
+2008-04-03 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
+
+ Reviewed by Simon.
+
+ * Safari is using the IconDatabase the following way (assumption). Before they
+ call iconDatabase()->open they "retain" all URLs they are interested in, these
+ could come from the history.
+ * When opening the iconDatabase() a thread will be started that is going to import
+ the URLs, all none manually retained URLs are scheduled for removal. The removal
+ is going to happen when the next icon gets stored in the database.
+ * We do not have any IconDatabase code, we can not retain the URLs before opening the
+ database. To disable the automatic pruning of the icons we will ask the IconDatabase
+ to delay this operation. This means our IconDatabase, when used, will grow, so we should
+ try to have a IconDatabase class in 4.4.
+ * The only way to counter the growth is a call to QWebSettings::clearIconDatabase
+
+
+ * Api/qwebsettings.cpp:
+ (QWebSettings::clearIconDatabase):
+ * Api/qwebsettings.h:
+
+2008-04-03 Benjamin Meyer <bmeyer@trolltech.com>
+
+ Reviewed by Simon.
+
+ Add a way to get the site icon for a url
+ static QPixmap iconForUrl(const QUrl &url);
+
+
+ * Api/qwebsettings.cpp:
+ (QWebSettings::iconForUrl):
+ * Api/qwebsettings.h:
+
+2008-04-03 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
+
+ Reviewed by Simon.
+
+ * Update the Copyright info in QWebSettings
+
+
+ * Api/qwebsettings.cpp:
+ * Api/qwebsettings.h:
+
+2008-04-03 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
+
+ Reviewed by Simon.
+
+ * The isEmpty check is not needed anymore with the earlier backport
+
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::icon):
+
+2008-04-03 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
+
+ Reviewed by Simon.
+
+ * For the http tests we need the output of the FrameLoaderClient. The QtWebKit API
+ is not exporting enough to create the output in DRT itself. Settle with the approach
+ Lars has taken for the Editing support and add branches to our FrameLoaderClient code.
+ * run-webkit-tests http/tests(/loading) can now be executed.
+ * For tests in loading/ directories we are going to throw away the dirty
+ QWebPage to start with something clean.
+
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (qt_dump_frame_loader):
+ (drtDescriptionSuitableForTestResult):
+ (WebCore::FrameLoaderClientQt::dispatchDidReceiveServerRedirectForProvisionalLoad):
+ (WebCore::FrameLoaderClientQt::dispatchDidCancelClientRedirect):
+ (WebCore::FrameLoaderClientQt::dispatchWillPerformClientRedirect):
+ (WebCore::FrameLoaderClientQt::dispatchDidChangeLocationWithinPage):
+ (WebCore::FrameLoaderClientQt::dispatchWillClose):
+ (WebCore::FrameLoaderClientQt::dispatchDidStartProvisionalLoad):
+ (WebCore::FrameLoaderClientQt::dispatchDidReceiveTitle):
+ (WebCore::FrameLoaderClientQt::dispatchDidCommitLoad):
+ (WebCore::FrameLoaderClientQt::dispatchDidFinishDocumentLoad):
+ (WebCore::FrameLoaderClientQt::dispatchDidFinishLoad):
+ (WebCore::FrameLoaderClientQt::registerForIconNotification):
+ (WebCore::FrameLoaderClientQt::setMainDocumentError):
+ (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction):
+
+2008-04-02 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
+
+ Reviewed by Simon.
+
+ * Export the PageCache and Cache capacity call one to one. This is only there
+ to allow the QtLauncher to play with caching.
+ * TODO: make API decisions and consider following the windows Api to set a WebCacheModel
+ and determine certain values automatically.
+
+
+ * Api/qwebsettings.cpp:
+ (QWebSettings::setPageCacheCapacity):
+ (QWebSettings::setObjectCacheCapacities):
+ * Api/qwebsettings.h:
+ * QtLauncher/main.cpp:
+
+2008-04-02 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
+
+ Reviewed by Simon.
+
+ Prepapre everything for enabling the PageCache for the Qt Platform:
+ * Claim that we can cache pages
+ * Create the FrameView FrameLoaderClientQt::transitionToCommittedForNewPage using
+ the initial size of the viewport and stop creating it in the QWebFramePrivate::init
+
+ Differences to the Windows port:
+ * attachToWindow/detachFromWindow is not called and is not (yet) part
+ of Widget/ScrollView of the Qt platform. We might need that for plugin
+ support in the future.
+ * We store the margin's and scrolling flag inside QWebFrame and use it when
+ creating the FrameView.
+
+ What is missing:
+ * API to call pageCache()->setCapacity(XYZ);
+
+
+ * Api/qwebframe.cpp:
+ (QWebFramePrivate::init):
+ * Api/qwebframe_p.h:
+ (QWebFramePrivate::QWebFramePrivate):
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::createMainFrame):
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::transitionToCommittedForNewPage):
+ (WebCore::FrameLoaderClientQt::blockedError):
+
+2008-04-02 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
+
+ Reviewed by Simon.
+
+ * For the PageCache support we do not want to create a FrameView in the constructor
+ of QWebFrame. In QWegPage::viewportSize() we currently call mainFrame() and that will
+ create a QWebFrame if no mainFrame is present and this gets called when we try to
+ create a FrameView...
+ * Keep a copy of the initial viewportSize around and use it if we do not have a Frame
+ or FrameView.
+
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::QWebPagePrivate):
+ (QWebPage::triggerAction):
+ * Api/qwebpage_p.h:
+
+2008-04-02 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
+
+ Reviewed by Simon.
+
+ * Always return true in FrameLoaderClientQt::shouldGoToHistoryItem, like the windows port
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::):
+
+2008-04-02 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
+
+ Reviewed by Simon.
+
+ * Attempt to make the m_webFrame null pointer checking consistent. Always check for
+ m_webFrame. It should get set by the QWebFrame with the FramerLoaderClientQt::setFrame
+ call and should stay valid until the destruction of the QWebFrame.
+ * Currently the same checking is not needed for m_frame as it will only set to 0 in
+ FrameLoaderClientQt::frameLoaderDestroyed and should be not 0 because of the setFrame
+ initialisation.
+
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::dispatchDidReceiveTitle):
+ (WebCore::FrameLoaderClientQt::setMainDocumentError):
+ (WebCore::FrameLoaderClientQt::dispatchDidReceiveContentLength):
+ (WebCore::FrameLoaderClientQt::objectContentType):
+ (WebCore::FrameLoaderClientQt::createPlugin):
+
+2008-04-01 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
+
+ Reviewed by Simon.
+
+ * Get the RefCounting of WebCore::Frame right and make sure that both QWebFrame
+ and WebCore::Frame get destroyed if we leave site with subframes and on the
+ end of the application.
+ * Use adoptRef in FrameLoaderClientQt::createFrame to get the refs right for subframes. We
+ do not want to add an extra reference. Without this we are leaking subframes.
+ * Assume that the lifetime of a Frame and FrameLoader are the same, when the Frame is gone
+ we want to destroy the QWebFrame (e.g. on a page with subframes). Add delete m_webFrame
+ in the frameLoaderDestroyed method to do that.
+ * If we happen to delete the QWebFrame before the FrameLoaderClientQt we set m_webFrame to
+ zero in the FrameLoaderClientQt to avoid bad things.
+
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::~QWebFrame):
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::shouldGoToHistoryItem):
+ (WebCore::FrameLoaderClientQt::objectContentType):
+ * WebCoreSupport/FrameLoaderClientQt.h:
+
+2008-04-01 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
+
+ Reviewed by Simon.
+
+ * Do not save a RefPtr to the frame. The FrameLoaderClient, Frame and
+ QWebFrame should have the same lifetime everything else is a leak
+ or issue.
+
+ * Api/qwebframe.cpp:
+ (QWebFramePrivate::init):
+ * Api/qwebframe_p.h:
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+
+2008-04-01 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
+
+ Reviewed by Simon.
+
+ * Do not store the QWebFrame associated with a ScrollView/FrameView
+ in the WebCore::Widget.
+ * Instead of asking the Widget for the QWebFrame use the QWebFramePrivate::core
+ and QWebFramePrivate::kit function to convert from and to QWebFrame.
+
+
+ * Api/qwebframe.cpp:
+ (QWebFramePrivate::init):
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::createMainFrame):
+
+2008-04-01 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
+
+ Reviewed by Simon.
+
+ * Do not store the FrameView in the QWebFrame and cope with the situation when
+ a WebCore::Frame has no WebCore::FrameView.
+
+
+ * Api/qwebframe.cpp:
+ (QWebFramePrivate::init):
+ (QWebFramePrivate::horizontalScrollBar):
+ (QWebFramePrivate::verticalScrollBar):
+ (QWebFrame::innerText):
+ (QWebFrame::renderTreeDump):
+ (QWebFrame::setVerticalScrollBarPolicy):
+ (QWebFrame::setHorizontalScrollBarPolicy):
+ (QWebFrame::render):
+ (QWebFrame::layout):
+ (QWebFrame::pos):
+ * Api/qwebframe_p.h:
+ (QWebFramePrivate::QWebFramePrivate):
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::updateEditorActions):
+ (QWebPagePrivate::mouseMoveEvent):
+ (QWebPagePrivate::mousePressEvent):
+ (QWebPagePrivate::mouseDoubleClickEvent):
+ (QWebPagePrivate::contextMenuEvent):
+ (QWebPagePrivate::wheelEvent):
+ (QWebPage::triggerAction):
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+
+2008-04-01 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
+
+ Reviewed by Simon.
+
+ * Change the order of the methods to match with the FrameLoaderClient.h to ease
+ removing methods in the future.
+
+ * WebCoreSupport/FrameLoaderClientQt.h:
+
+2008-04-01 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
+
+ Reviewed by Simon.
+
+ * Remove virtuals in the FrameLoaderClientQt that don't exist in the base class.
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::detachedFromParent4):
+ * WebCoreSupport/FrameLoaderClientQt.h:
+
+2008-03-25 Brady Eidson <beidson@apple.com>
+
+ Reviewed by Darin
+
+ Remove newly obsolete FrameLoaderClient methods
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ * WebCoreSupport/FrameLoaderClientQt.h:
+
+2008-03-22 Mark Rowe <mrowe@apple.com>
+
+ Qt build fix.
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::):
+
+2008-03-18 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger.
+
+ Fix the Qt build. Don't return void in non-void functions.
+
+ * Api/qwebpluginfactory.cpp:
+ (QWebPluginFactory::extension):
+
+2008-03-16 Thiago Macieira <thiago.macieira@trolltech.com>
+
+ Reviewed by Simon.
+
+ Don't use RefPtr in classes you haven't seen the implementation of.
+
+ Forward-declaration and declaration of RefPtr<Foo> is ok. But you
+ cannot *use* said objects until Foo is defined. This is true even for
+ initialisation with a 0.
+
+ Seems the HP aCC compiler is more strict here than gcc.
+
+ * Api/qwebframe_p.h:
+
+2008-03-14 Simon Hausmann <hausmann@webkit.org>
+
+ Fix the Qt build.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::setHtml):
+ (QWebFrame::setContent):
+
+2008-03-13 Simon Hausmann <hausmann@webkit.org>
+
+ Fix the Qt build.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::addToJSWindowObject):
+
+2008-03-12 Simon Hausmann <hausmann@webkit.org>
+
+ Fix compilation against Qt 4.3
+
+ * Api/qwebpage.cpp:
+ * Api/qwebpage.h:
+ * Api/qwebpage_p.h:
+
+2008-03-11 Rodney Dawes <dobey@wayofthemonkey.com>
+
+ Fix the Qt build.
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (FrameLoaderClientQt::CreatePlugin):
+
+2008-03-11 Simon Hausmann <hausmann@webkit.org>
+
+ Fix the Qt build (silly typo).
+
+ * QtLauncher/main.cpp:
+ (MainWindow::MainWindow):
+
+2008-03-11 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon.
+
+ Moved obscuring progress bar to the lower right corner.
+
+ * QtLauncher/main.cpp:
+ (MainWindow::MainWindow):
+ (MainWindow::resizeEvent):
+
+2008-03-11 Tor Arne Vestbø <tavestbo@trolltech.com>
+
+ Reviewed by Simon.
+
+ Added reload action and grouped stop and reload actions together.
+
+ * QtLauncher/main.cpp:
+ (MainWindow::MainWindow):
+
+2008-03-11 Holger Hans Peter Freyther <holger.freyther@trolltech.com>
+
+ Reviewed by Simon.
+
+ * Set a Icon on the QAction if we have one.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::action):
+
+2008-03-11 Simon Hausmann <hausmann@webkit.org>
+
+ Fix the Qt build.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::addToJSWindowObject):
+
+2008-03-07 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Darin Adler.
+
+ Done with Lars.
+
+ Replaced the QWebObjectPlugin interfaces with QWebPluginFactory.
+
+ * Api/qwebnetworkinterface.cpp:
+ (QWebNetworkManager::add):
+ (QWebNetworkManager::cancel):
+ (QWebNetworkManager::started):
+ (QWebNetworkManager::data):
+ (QWebNetworkManager::finished):
+ * Api/qwebnetworkinterface_p.h:
+ (QWebNetworkJobPrivate::QWebNetworkJobPrivate):
+ * Api/qwebobjectplugin.cpp: Removed.
+ * Api/qwebobjectplugin.h: Removed.
+ * Api/qwebobjectplugin_p.h: Removed.
+ * Api/qwebobjectpluginconnector.cpp: Removed.
+ * Api/qwebobjectpluginconnector.h: Removed.
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::QWebPagePrivate):
+ (QWebPage::setPluginFactory):
+ (QWebPage::pluginFactory):
+ * Api/qwebpage.h:
+ * Api/qwebpage_p.h:
+ * Api/qwebpluginfactory.cpp: Added.
+ (QWebPluginFactory::QWebPluginFactory):
+ (QWebPluginFactory::~QWebPluginFactory):
+ (QWebPluginFactory::refreshPlugins):
+ (QWebPluginFactory::extension):
+ * Api/qwebpluginfactory.h: Added.
+ (MimeType::):
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::objectContentType):
+ (WebCore::FrameLoaderClientQt::createPlugin):
+
+2008-03-07 Simon Hausmann <hausmann@webkit.org>
+
+ Fix the Qt build.
+
+ * Api/qwebframe.cpp:
+
+2008-03-04 Sam Weinig <sam@webkit.org>
+
+ Reviewed by Mark Rowe.
+
+ - Remove all unnecessary includes of JSDOMWindowBase.h, we prefer including
+ JSDOMWindow.h
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::addToJSWindowObject):
+
+2008-03-04 Mark Rowe <mrowe@apple.com>
+
+ Another go at fixing the Qt build.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::addToJSWindowObject):
+
+2008-02-24 Darin Adler <darin@apple.com>
+
+ Reviewed by Sam.
+
+ - remove separate client calls for "standard" and "reload' history
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::updateGlobalHistory):
+ * WebCoreSupport/FrameLoaderClientQt.h:
+
+2008-02-24 Darin Adler <darin@apple.com>
+
+ - another try at fixing the build
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::load): Replace new FormData with FormData::create.
+
+2008-02-22 Sam Weinig <sam@webkit.org>
+
+ Fix Qt build.
+
+ * Api/qwebhistoryinterface.cpp:
+
+2008-02-22 Sam Weinig <sam@webkit.org>
+
+ Rubber-stamped by Adam Roben.
+
+ Rid the project of the Devil known as DeprecatedString!
+
+ * Api/qwebhistory.cpp:
+ * Api/qwebhistoryinterface.cpp:
+
+2008-02-18 Darin Adler <darin@apple.com>
+
+ Reviewed by Sam.
+
+ * Api/qwebnetworkinterface.cpp:
+ (QWebNetworkRequestPrivate::init): Removed use of DeprecatedString.
+
2008-01-24 David Boddie <dboddie@trolltech.com>
Reviewed by Simon.
@@ -1277,7 +4814,7 @@
2007-12-07 Alexey Proskuryakov <ap@webkit.org>
- Reviewed by Darin.
+ Reviewed by Darin Adler.
<rdar://problem/5535636>
Have to press 4 times instead of 2 times to get the expected result of ^^ with german keyboard.
@@ -1772,8 +5309,6 @@
2007-11-07 Simon Hausmann <hausmann@kde.org>
- Build fix, reviewed by nobody.
-
Fix the Qt build by setting up WindowFeatures before calling
createWindow on the Chrome. This is similar to openNewWindow in
page/ContextMenuController.cpp
@@ -3854,7 +7389,7 @@
Updated ChromeClientQt for ChromeClient changes.
- Reviewed by Darin.
+ Reviewed by Darin Adler.
* WebCoreSupport/ChromeClientQt.cpp:
(WebCore::ChromeClientQt::print): Added a Frame* parameter.
@@ -5189,7 +8724,7 @@
2007-03-07 Adele Peterson <adele@apple.com>
- Reviewed by Darin.
+ Reviewed by Darin Adler.
WebKitQT part of fix for:
http://bugs.webkit.org/show_bug.cgi?id=10871
@@ -5428,8 +8963,6 @@
2007-02-18 Oliver Hunt <oliver@apple.com>
- Reviewed by NOBODY (Buildfix).
-
Build fix -- adding DragClientQt method stubs
* WebCoreSupport/DragClientQt.cpp:
@@ -6466,7 +9999,7 @@
2006-10-26 Nikolas Zimmermann <zimmermann@kde.org>
- Reviewed by Darin.
+ Reviewed by Darin Adler.
Fix Qt/Linux build.
@@ -6489,7 +10022,7 @@
2006-10-24 Simon Hausmann <hausmann@kde.org>
- Reviewed by Darin.
+ Reviewed by Darin Adler.
* QtLauncher/CMakeLists.txt, WebKitPart/CMakeLists.txt: Added project name to
kde4_automoc macro, as required by the latest KDE4 cmake module.
@@ -6548,7 +10081,7 @@
2006-09-04 Nikolas Zimmermann <zimmermann@kde.org>
- Reviewed by Darin. Final polish by Sam.
+ Reviewed by Darin Adler. Final polish by Sam.
Fixes parts of: http://bugs.webkit.org/show_bug.cgi?id=10644
Add WebKitPart, an embeddable KPart for the KDE platform.
diff --git a/WebKit/qt/Plugins/ICOHandler.cpp b/WebKit/qt/Plugins/ICOHandler.cpp
index 6f3b2f0..44f3d44 100644
--- a/WebKit/qt/Plugins/ICOHandler.cpp
+++ b/WebKit/qt/Plugins/ICOHandler.cpp
@@ -36,7 +36,7 @@ namespace
}
// Based on qt_read_dib et al. from qimage.cpp
- // (c) 1992-2002 Trolltech AS.
+ // (c) 1992-2002 Nokia Corporation and/or its subsidiary(-ies).
struct BMP_INFOHDR
{
static const quint32 Size = 40;
diff --git a/WebKit/qt/QtLauncher/QtLauncher.pro b/WebKit/qt/QtLauncher/QtLauncher.pro
index eb43f96..d8c9d51 100644
--- a/WebKit/qt/QtLauncher/QtLauncher.pro
+++ b/WebKit/qt/QtLauncher/QtLauncher.pro
@@ -1,6 +1,7 @@
TEMPLATE = app
SOURCES += main.cpp
CONFIG -= app_bundle
+CONFIG += uitools
DESTDIR = ../../../bin
include(../../../WebKit.pri)
diff --git a/WebKit/qt/QtLauncher/main.cpp b/WebKit/qt/QtLauncher/main.cpp
index 7467c6b..4d57e56 100644
--- a/WebKit/qt/QtLauncher/main.cpp
+++ b/WebKit/qt/QtLauncher/main.cpp
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2006 George Staikos <staikos@kde.org>
* Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
* Copyright (C) 2006 Zack Rusin <zack@kde.org>
@@ -27,6 +28,7 @@
* (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>
@@ -34,364 +36,318 @@
#include <QtGui>
#include <QDebug>
+#if QT_VERSION >= 0x040400 && !defined(QT_NO_PRINTER)
+#include <QPrintPreviewDialog>
+#endif
+#include <QtUiTools/QUiLoader>
-
-class InfoWidget :public QProgressBar {
- Q_OBJECT
+class WebPage : public QWebPage
+{
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;
- }
+ WebPage(QWidget *parent) : QWebPage(parent) {}
-protected:
- int m_progress;
+ virtual QWebPage *createWindow(QWebPage::WebWindowType);
+ virtual QObject* createPlugin(const QString&, const QUrl&, const QStringList&, const QStringList&);
};
-class HoverLabel : public QWidget {
+class MainWindow : public QMainWindow
+{
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()));
- }
+ MainWindow(const QString& url = QString()): currentZoom(100) {
+ view = new QWebView(this);
+ setCentralWidget(view);
+
+ view->setPage(new WebPage(view));
+
+ connect(view, SIGNAL(loadFinished(bool)),
+ this, SLOT(loadFinished()));
+ connect(view, SIGNAL(titleChanged(const QString&)),
+ this, SLOT(setWindowTitle(const QString&)));
+ connect(view->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString &)),
+ this, SLOT(showLinkHover(const QString&, const QString&)));
+ connect(view->page(), SIGNAL(windowCloseRequested()), this, SLOT(deleteLater()));
+
+ setupUI();
+
+ QUrl qurl = guessUrlFromString(url);
+ if (qurl.isValid()) {
+ urlEdit->setText(qurl.toString());
+ view->load(qurl);
-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();
+ // the zoom values are chosen to be like in Mozilla Firefox 3
+ zoomLevels << 30 << 50 << 67 << 80 << 90;
+ zoomLevels << 100;
+ zoomLevels << 110 << 120 << 133 << 150 << 170 << 200 << 240 << 300;
}
}
- QSize sizeForFont() const {
- QFont f = font();
- QFontMetrics fm(f);
- return QSize(fm.width(m_link) + 10, fm.height() + 6);
+
+ QWebPage *webPage() const {
+ return view->page();
}
- QSize sizeHint() const {
- if (!m_animating)
- return sizeForFont();
- else
- return (m_newSize.width() > m_oldSize.width()) ? m_newSize : m_oldSize;
+
+protected slots:
+
+ void changeLocation() {
+ QUrl url = guessUrlFromString(urlEdit->text());
+ urlEdit->setText(url.toString());
+ view->load(url);
+ view->setFocus(Qt::OtherFocusReason);
}
- void updateSize() {
- QRect r = geometry();
- QSize newSize = sizeHint();
- r = QRect(r.x(), r.y(), newSize.width(), newSize.height());
- setGeometry(r);
+
+ void loadFinished() {
+ urlEdit->setText(view->url().toString());
+
+ QUrl::FormattingOptions opts;
+ opts |= QUrl::RemoveScheme;
+ opts |= QUrl::RemoveUserInfo;
+ opts |= QUrl::StripTrailingSlash;
+ QString s = view->url().toString(opts);
+ s = s.mid(2);
+ if (s.isEmpty())
+ return;
+
+ if (!urlList.contains(s))
+ urlList += s;
+ urlModel.setStringList(urlList);
}
- void resetAnimation() {
- m_animating = true;
- m_percent = 0;
- if (!m_timer.isActive())
- m_timer.start();
+
+ void showLinkHover(const QString &link, const QString &toolTip) {
+ statusBar()->showMessage(link);
+#ifndef QT_NO_TOOLTIP
+ if (!toolTip.isEmpty())
+ QToolTip::showText(QCursor::pos(), toolTip);
+#endif
}
-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);
+ void newWindow() {
+ MainWindow *mw = new MainWindow;
+ mw->show();
}
-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);
+ void zoomIn() {
+ int i = zoomLevels.indexOf(currentZoom);
+ Q_ASSERT(i >= 0);
+ if (i < zoomLevels.count() - 1)
+ currentZoom = zoomLevels[i + 1];
+
+ view->setZoomFactor(qreal(currentZoom)/100.0);
}
- QString m_link;
- bool m_animating;
- QTimer m_timer;
- QTimer m_hideTimer;
- QSize m_oldSize;
- QSize m_newSize;
- qreal m_percent;
-};
-class SearchEdit;
+ void zoomOut() {
+ int i = zoomLevels.indexOf(currentZoom);
+ Q_ASSERT(i >= 0);
+ if (i > 0)
+ currentZoom = zoomLevels[i - 1];
-class ClearButton : public QPushButton {
- Q_OBJECT
-public:
- ClearButton(QWidget *w)
- : QPushButton(w)
- {
- setMinimumSize(24, 24);
- setFixedSize(24, 24);
- setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ view->setZoomFactor(qreal(currentZoom)/100.0);
}
- void paintEvent(QPaintEvent *event)
+
+ void resetZoom()
{
- 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);
+ currentZoom = 100;
+ view->setZoomFactor(1.0);
}
-};
-class SearchEdit : public QLineEdit
-{
- Q_OBJECT
-public:
- SearchEdit(const QString &str, QWidget *parent = 0)
- : QLineEdit(str, parent)
+ void toggleZoomTextOnly(bool b)
{
- 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);
+ view->page()->settings()->setAttribute(QWebSettings::ZoomTextOnly, b);
}
- virtual void resizeEvent(QResizeEvent *) {
- clearButton->setParent(this);
- clearButton->setGeometry(QRect(width()-27,
- 0,
- 24, 24));
+
+ void print() {
+#if QT_VERSION >= 0x040400 && !defined(QT_NO_PRINTER)
+ QPrintPreviewDialog dlg(this);
+ connect(&dlg, SIGNAL(paintRequested(QPrinter *)),
+ view, SLOT(print(QPrinter *)));
+ dlg.exec();
+#endif
}
- virtual void moveEvent(QMoveEvent *) {
- clearButton->setParent(this);
- clearButton->setGeometry(QRect(width()-27, 1,
- 24, 24));
+
+ void setEditable(bool on) {
+ view->page()->setEditable(on);
+ formatMenuAction->setVisible(on);
}
- QPushButton *clearButton;
-};
+ void dumpHtml() {
+ qDebug() << "HTML: " << view->page()->mainFrame()->toHtml();
+ }
+private:
-class WebPage : public QWebPage
-{
-public:
- inline WebPage(QWidget *parent) : QWebPage(parent) {}
+ QVector<int> zoomLevels;
+ int currentZoom;
- virtual QWebPage *createWindow();
-};
+ // create the status bar, tool bar & menu
+ void setupUI() {
+ progress = new QProgressBar(this);
+ progress->setRange(0, 100);
+ progress->setMinimumSize(100, 20);
+ progress->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
+ progress->hide();
+ statusBar()->addPermanentWidget(progress);
-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);
+ connect(view, SIGNAL(loadProgress(int)), progress, SLOT(show()));
+ connect(view, SIGNAL(loadProgress(int)), progress, SLOT(setValue(int)));
+ connect(view, SIGNAL(loadFinished(bool)), progress, SLOT(hide()));
- QToolBar *bar = addToolBar("Navigation");
- urlEdit = new SearchEdit(url.toString());
+ urlEdit = new QLineEdit(this);
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);
+ QCompleter *completer = new QCompleter(this);
+ urlEdit->setCompleter(completer);
+ completer->setModel(&urlModel);
- hoverLabel = new HoverLabel(this);
- hoverLabel->hide();
-
- if (url.isValid())
- view->load(url);
+ QToolBar *bar = addToolBar("Navigation");
+ bar->addAction(view->pageAction(QWebPage::Back));
+ bar->addAction(view->pageAction(QWebPage::Forward));
+ bar->addAction(view->pageAction(QWebPage::Reload));
+ bar->addAction(view->pageAction(QWebPage::Stop));
+ bar->addWidget(urlEdit);
- 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);
+ QMenu *fileMenu = menuBar()->addMenu("&File");
+ QAction *newWindow = fileMenu->addAction("New Window", this, SLOT(newWindow()));
+#if QT_VERSION >= 0x040400
+ fileMenu->addAction(tr("Print"), this, SLOT(print()));
#endif
+ fileMenu->addAction("Close", this, SLOT(close()));
+
+ QMenu *editMenu = menuBar()->addMenu("&Edit");
+ editMenu->addAction(view->pageAction(QWebPage::Undo));
+ editMenu->addAction(view->pageAction(QWebPage::Redo));
+ editMenu->addSeparator();
+ editMenu->addAction(view->pageAction(QWebPage::Cut));
+ editMenu->addAction(view->pageAction(QWebPage::Copy));
+ editMenu->addAction(view->pageAction(QWebPage::Paste));
+ editMenu->addSeparator();
+ QAction *setEditable = editMenu->addAction("Set Editable", this, SLOT(setEditable(bool)));
+ setEditable->setCheckable(true);
+
+ QMenu *viewMenu = menuBar()->addMenu("&View");
+ viewMenu->addAction(view->pageAction(QWebPage::Stop));
+ viewMenu->addAction(view->pageAction(QWebPage::Reload));
+ viewMenu->addSeparator();
+ QAction *zoomIn = viewMenu->addAction("Zoom &In", this, SLOT(zoomIn()));
+ QAction *zoomOut = viewMenu->addAction("Zoom &Out", this, SLOT(zoomOut()));
+ QAction *resetZoom = viewMenu->addAction("Reset Zoom", this, SLOT(resetZoom()));
+ QAction *zoomTextOnly = viewMenu->addAction("Zoom Text Only", this, SLOT(toggleZoomTextOnly(bool)));
+ zoomTextOnly->setCheckable(true);
+ zoomTextOnly->setChecked(false);
+ viewMenu->addSeparator();
+ viewMenu->addAction("Dump HTML", this, SLOT(dumpHtml()));
+
+ QMenu *formatMenu = new QMenu("F&ormat");
+ formatMenuAction = menuBar()->addMenu(formatMenu);
+ formatMenuAction->setVisible(false);
+ formatMenu->addAction(view->pageAction(QWebPage::ToggleBold));
+ formatMenu->addAction(view->pageAction(QWebPage::ToggleItalic));
+ formatMenu->addAction(view->pageAction(QWebPage::ToggleUnderline));
+ QMenu *writingMenu = formatMenu->addMenu(tr("Writing Direction"));
+ writingMenu->addAction(view->pageAction(QWebPage::SetTextDirectionDefault));
+ writingMenu->addAction(view->pageAction(QWebPage::SetTextDirectionLeftToRight));
+ writingMenu->addAction(view->pageAction(QWebPage::SetTextDirectionRightToLeft));
+
+ newWindow->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_N));
+ view->pageAction(QWebPage::Back)->setShortcut(QKeySequence::Back);
+ view->pageAction(QWebPage::Stop)->setShortcut(Qt::Key_Escape);
+ view->pageAction(QWebPage::Forward)->setShortcut(QKeySequence::Forward);
+ view->pageAction(QWebPage::Reload)->setShortcut(QKeySequence::Refresh);
+ view->pageAction(QWebPage::Undo)->setShortcut(QKeySequence::Undo);
+ view->pageAction(QWebPage::Redo)->setShortcut(QKeySequence::Redo);
+ view->pageAction(QWebPage::Cut)->setShortcut(QKeySequence::Cut);
+ view->pageAction(QWebPage::Copy)->setShortcut(QKeySequence::Copy);
+ view->pageAction(QWebPage::Paste)->setShortcut(QKeySequence::Paste);
+ zoomIn->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Plus));
+ zoomOut->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Minus));
+ resetZoom->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_0));
+ view->pageAction(QWebPage::ToggleBold)->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_B));
+ view->pageAction(QWebPage::ToggleItalic)->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_I));
+ view->pageAction(QWebPage::ToggleUnderline)->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_U));
}
-protected:
- void resizeEvent(QResizeEvent *) {
- QSize hoverSize = hoverLabel->sizeHint();
- hoverLabel->setGeometry(0, height()-hoverSize.height(),
- 300, hoverSize.height());
+
+ QUrl guessUrlFromString(const QString &string) {
+ QString urlStr = string.trimmed();
+ QRegExp test(QLatin1String("^[a-zA-Z]+\\:.*"));
+
+ // Check if it looks like a qualified URL. Try parsing it and see.
+ bool hasSchema = test.exactMatch(urlStr);
+ if (hasSchema) {
+ QUrl url(urlStr, QUrl::TolerantMode);
+ if (url.isValid())
+ return url;
+ }
+
+ // Might be a file.
+ if (QFile::exists(urlStr))
+ return QUrl::fromLocalFile(urlStr);
+
+ // Might be a shorturl - try to detect the schema.
+ if (!hasSchema) {
+ int dotIndex = urlStr.indexOf(QLatin1Char('.'));
+ if (dotIndex != -1) {
+ QString prefix = urlStr.left(dotIndex).toLower();
+ QString schema = (prefix == QLatin1String("ftp")) ? prefix : QLatin1String("http");
+ QUrl url(schema + QLatin1String("://") + urlStr, QUrl::TolerantMode);
+ if (url.isValid())
+ return url;
+ }
+ }
+
+ // Fall back to QUrl's own tolerant parser.
+ return QUrl(string, QUrl::TolerantMode);
}
-private:
+
QWebView *view;
QLineEdit *urlEdit;
- HoverLabel *hoverLabel;
+ QProgressBar *progress;
+
+ QAction *formatMenuAction;
+
+ QStringList urlList;
+ QStringListModel urlModel;
};
-QWebPage *WebPage::createWindow()
+QWebPage *WebPage::createWindow(QWebPage::WebWindowType)
{
MainWindow *mw = new MainWindow;
return mw->webPage();
}
+QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues)
+{
+ Q_UNUSED(url);
+ Q_UNUSED(paramNames);
+ Q_UNUSED(paramValues);
+ QUiLoader loader;
+ return loader.createWidget(classId, view());
+}
+
#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);
+ QString url = QString("%1/%2").arg(QDir::homePath()).arg(QLatin1String("index.html"));
- QWebSettings::defaultSettings()->setAttribute(QWebSettings::PluginsEnabled);
- QWebSettings::defaultSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled);
+ QWebSettings::setMaximumPagesInCache(4);
+
+ app.setApplicationName("QtLauncher");
+#if QT_VERSION >= 0x040400
+ app.setApplicationVersion("0.1");
+#endif
+
+ QWebSettings::setObjectCacheCapacities((16*1024*1024) / 8, (16*1024*1024) / 8, 16*1024*1024);
+
+ QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);
+ QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
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);
+ MainWindow window(url);
window.show();
return app.exec();
}
+
diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
index a106f03..8a4de6b 100644
--- a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
@@ -28,12 +28,12 @@
#include "config.h"
#include "ChromeClientQt.h"
+#include "FileChooser.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"
@@ -42,6 +42,8 @@
#include "qwebpage_p.h"
#include "qwebframe_p.h"
+#include <qtooltip.h>
+
namespace WebCore
{
@@ -49,10 +51,9 @@ namespace WebCore
ChromeClientQt::ChromeClientQt(QWebPage* webPage)
: m_webPage(webPage)
{
-
+ toolBarsVisible = statusBarVisible = menuBarVisible = true;
}
-
ChromeClientQt::~ChromeClientQt()
{
@@ -62,7 +63,7 @@ void ChromeClientQt::setWindowRect(const FloatRect& rect)
{
if (!m_webPage)
return;
- emit m_webPage->geometryChangeRequest(QRect(qRound(rect.x()), qRound(rect.y()),
+ emit m_webPage->geometryChangeRequested(QRect(qRound(rect.x()), qRound(rect.y()),
qRound(rect.width()), qRound(rect.height())));
}
@@ -135,7 +136,7 @@ void ChromeClientQt::takeFocus(FocusDirection)
Page* ChromeClientQt::createWindow(Frame*, const FrameLoadRequest& request, const WindowFeatures& features)
{
- QWebPage *newPage = features.dialog ? m_webPage->createModalDialog() : m_webPage->createWindow();
+ QWebPage *newPage = m_webPage->createWindow(features.dialog ? QWebPage::WebModalDialog : QWebPage::WebBrowserWindow);
if (!newPage)
return 0;
newPage->mainFrame()->load(request.resourceRequest().url());
@@ -166,28 +167,29 @@ void ChromeClientQt::runModal()
}
-void ChromeClientQt::setToolbarsVisible(bool)
+void ChromeClientQt::setToolbarsVisible(bool visible)
{
- notImplemented();
+ toolBarsVisible = visible;
+ emit m_webPage->toolBarVisibilityChangeRequested(visible);
}
bool ChromeClientQt::toolbarsVisible()
{
- notImplemented();
- return false;
+ return toolBarsVisible;
}
-void ChromeClientQt::setStatusbarVisible(bool)
+void ChromeClientQt::setStatusbarVisible(bool visible)
{
- notImplemented();
+ emit m_webPage->statusBarVisibilityChangeRequested(visible);
+ statusBarVisible = visible;
}
bool ChromeClientQt::statusbarVisible()
{
- notImplemented();
+ return statusBarVisible;
return false;
}
@@ -205,15 +207,15 @@ bool ChromeClientQt::scrollbarsVisible()
}
-void ChromeClientQt::setMenubarVisible(bool)
+void ChromeClientQt::setMenubarVisible(bool visible)
{
- notImplemented();
+ menuBarVisible = visible;
+ emit m_webPage->menuBarVisibilityChangeRequested(visible);
}
bool ChromeClientQt::menubarVisible()
{
- notImplemented();
- return false;
+ return menuBarVisible;
}
void ChromeClientQt::setResizable(bool)
@@ -247,7 +249,7 @@ bool ChromeClientQt::runBeforeUnloadConfirmPanel(const String& message, Frame* f
void ChromeClientQt::closeWindowSoon()
{
m_webPage->mainFrame()->d->frame->loader()->stopAllLoaders();
- m_webPage->deleteLater();
+ emit m_webPage->windowCloseRequested();
}
void ChromeClientQt::runJavaScriptAlert(Frame* f, const String& msg)
@@ -276,7 +278,7 @@ bool ChromeClientQt::runJavaScriptPrompt(Frame* f, const String& message, const
void ChromeClientQt::setStatusbarText(const String& msg)
{
QString x = msg;
- emit m_webPage->statusBarTextChanged(x);
+ emit m_webPage->statusBarMessage(x);
}
bool ChromeClientQt::shouldInterruptJavaScript()
@@ -295,26 +297,47 @@ IntRect ChromeClientQt::windowResizerRect() const
return IntRect();
}
-void ChromeClientQt::addToDirtyRegion(const IntRect& r)
+void ChromeClientQt::repaint(const IntRect& windowRect, bool contentChanged, bool immediate, bool repaintContentOnly)
{
- 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);
+ // No double buffer, so only update the QWidget if content changed.
+ if (contentChanged) {
+ QWidget* view = m_webPage->view();
+ if (view) {
+ QRect rect(windowRect);
+ rect = rect.intersected(QRect(QPoint(0, 0), m_webPage->viewportSize()));
+ if (!windowRect.isEmpty())
+ view->update(windowRect);
+ }
+ emit m_webPage->repaintRequested(windowRect);
}
+
+ // FIXME: There is no "immediate" support for window painting. This should be done always whenever the flag
+ // is set.
}
-void ChromeClientQt::scrollBackingStore(int dx, int dy, const IntRect& scrollViewRect, const IntRect& clipRect)
+void ChromeClientQt::scroll(const IntSize& delta, const IntRect& scrollViewRect, const IntRect&)
{
QWidget* view = m_webPage->view();
if (view)
- view->scroll(dx, dy, scrollViewRect);
+ view->scroll(delta.width(), delta.height(), scrollViewRect);
+ emit m_webPage->scrollRequested(delta.width(), delta.height(), scrollViewRect);
}
-void ChromeClientQt::updateBackingStore()
+IntRect ChromeClientQt::windowToScreen(const IntRect& rect) const
{
+ notImplemented();
+ return rect;
+}
+
+IntPoint ChromeClientQt::screenToWindow(const IntPoint& point) const
+{
+ notImplemented();
+ return point;
+}
+
+PlatformWidget ChromeClientQt::platformWindow() const
+{
+ return m_webPage->view();
}
void ChromeClientQt::mouseDidMoveOverElement(const HitTestResult& result, unsigned modifierFlags)
@@ -325,7 +348,7 @@ void ChromeClientQt::mouseDidMoveOverElement(const HitTestResult& result, unsign
lastHoverURL = result.absoluteLinkURL();
lastHoverTitle = result.title();
lastHoverContent = result.textContent();
- emit m_webPage->hoveringOverLink(lastHoverURL.prettyURL(),
+ emit m_webPage->linkHovered(lastHoverURL.prettyURL(),
lastHoverTitle, lastHoverContent);
}
}
@@ -334,16 +357,24 @@ void ChromeClientQt::setToolTip(const String &tip)
{
#ifndef QT_NO_TOOLTIP
QWidget* view = m_webPage->view();
- if (view)
- view->setToolTip(tip);
+ if (!view)
+ return;
+
+ if (tip.isEmpty()) {
+ view->setToolTip(QString());
+ QToolTip::hideText();
+ } else {
+ QString dtip = QLatin1String("<p>") + tip + QLatin1String("</p>");
+ view->setToolTip(dtip);
+ }
#else
Q_UNUSED(tip);
#endif
}
-void ChromeClientQt::print(Frame*)
+void ChromeClientQt::print(Frame *frame)
{
- notImplemented();
+ emit m_webPage->printRequested(QWebFramePrivate::kit(frame));
}
void ChromeClientQt::exceededDatabaseQuota(Frame*, const String&)
@@ -351,6 +382,15 @@ void ChromeClientQt::exceededDatabaseQuota(Frame*, const String&)
notImplemented();
}
-}
+void ChromeClientQt::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> prpFileChooser)
+{
+ // FIXME: Support multiple files.
+ RefPtr<FileChooser> fileChooser = prpFileChooser;
+ QString suggestedFile = fileChooser->filenames()[0];
+ QString file = m_webPage->chooseFile(QWebFramePrivate::kit(frame), suggestedFile);
+ if (!file.isEmpty())
+ fileChooser->chooseFile(file);
+}
+}
diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.h b/WebKit/qt/WebCoreSupport/ChromeClientQt.h
index 31d492b..440f29e 100644
--- a/WebKit/qt/WebCoreSupport/ChromeClientQt.h
+++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.h
@@ -38,6 +38,7 @@ class QWebPage;
namespace WebCore {
+ class FileChooser;
class FloatRect;
class Page;
struct FrameLoadRequest;
@@ -99,9 +100,12 @@ namespace WebCore {
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 repaint(const IntRect&, bool contentChanged, bool immediate = false, bool repaintContentOnly = false);
+ virtual void scroll(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect);
+ virtual IntPoint screenToWindow(const IntPoint&) const;
+ virtual IntRect windowToScreen(const IntRect&) const;
+ virtual PlatformWidget platformWindow() const;
virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags);
@@ -111,10 +115,16 @@ namespace WebCore {
virtual void exceededDatabaseQuota(Frame*, const String&);
+ virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>);
+
QWebPage* m_webPage;
WebCore::KURL lastHoverURL;
WebCore::String lastHoverTitle;
WebCore::String lastHoverContent;
+
+ bool toolBarsVisible;
+ bool statusBarVisible;
+ bool menuBarVisible;
};
}
diff --git a/WebKit/qt/WebCoreSupport/EditCommandQt.cpp b/WebKit/qt/WebCoreSupport/EditCommandQt.cpp
index e316a16..1532388 100644
--- a/WebKit/qt/WebCoreSupport/EditCommandQt.cpp
+++ b/WebKit/qt/WebCoreSupport/EditCommandQt.cpp
@@ -23,7 +23,12 @@
using namespace WebCore;
EditCommandQt::EditCommandQt(WTF::RefPtr<EditCommand> cmd, QUndoCommand *parent)
-: QUndoCommand(parent), _cmd(cmd), _first(true) {
+:
+#ifndef QT_NO_UNDOCOMMAND
+ QUndoCommand(parent),
+#endif
+ _cmd(cmd), _first(true)
+{
}
diff --git a/WebKit/qt/WebCoreSupport/EditCommandQt.h b/WebKit/qt/WebCoreSupport/EditCommandQt.h
index dd7c85a..ae6ea51 100644
--- a/WebKit/qt/WebCoreSupport/EditCommandQt.h
+++ b/WebKit/qt/WebCoreSupport/EditCommandQt.h
@@ -20,11 +20,19 @@
#ifndef EDITCOMMANDQT_H
#define EDITCOMMANDQT_H
+#include <qglobal.h>
+QT_BEGIN_NAMESPACE
+class QUndoCommand;
+QT_END_NAMESPACE
#include <QUndoCommand>
#include <EditCommand.h>
-class EditCommandQt : public QUndoCommand {
+class EditCommandQt
+#ifndef QT_NO_UNDOCOMMAND
+ : public QUndoCommand
+#endif
+{
public:
EditCommandQt(WTF::RefPtr<WebCore::EditCommand> cmd, QUndoCommand *parent = 0);
~EditCommandQt();
diff --git a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp
index fced385..a25ff18 100644
--- a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
* Copyright (C) 2006 Zack Rusin <zack@kde.org>
* Copyright (C) 2006 Apple Computer, Inc.
*
@@ -73,7 +73,7 @@ void QWEBKIT_EXPORT qt_dump_set_accepts_editing(bool b)
static QString dumpPath(WebCore::Node *node)
{
QString str = node->nodeName();
-
+
WebCore::Node *parent = node->parentNode();
while (parent) {
str.append(QLatin1String(" > "));
@@ -94,14 +94,14 @@ static QString dumpRange(WebCore::Range *range)
range->endOffset(code), dumpPath(range->endContainer(code)).unicode());
return str;
}
-
+
namespace WebCore {
bool EditorClientQt::shouldDeleteRange(Range* range)
{
- if (dumpEditingCallbacks)
+ if (dumpEditingCallbacks)
printf("EDITING DELEGATE: shouldDeleteDOMRange:%s\n", dumpRange(range).toUtf8().constData());
return true;
@@ -109,7 +109,7 @@ bool EditorClientQt::shouldDeleteRange(Range* range)
bool EditorClientQt::shouldShowDeleteInterface(HTMLElement* element)
{
- if (drt_run)
+ if (drt_run)
return element->className() == "needsDeletionUI";
return false;
}
@@ -143,7 +143,7 @@ bool EditorClientQt::shouldEndEditing(WebCore::Range* range)
return true;
}
-bool EditorClientQt::shouldInsertText(String string, Range* range, EditorInsertAction action)
+bool EditorClientQt::shouldInsertText(const String& string, Range* range, EditorInsertAction action)
{
if (dumpEditingCallbacks) {
static const char *insertactionstring[] = {
@@ -151,7 +151,7 @@ bool EditorClientQt::shouldInsertText(String string, Range* range, EditorInsertA
"WebViewInsertActionPasted",
"WebViewInsertActionDropped",
};
-
+
printf("EDITING DELEGATE: shouldInsertText:%s replacingDOMRange:%s givenAction:%s\n",
QString(string).toUtf8().constData(), dumpRange(range).toUtf8().constData(), insertactionstring[action]);
}
@@ -169,7 +169,7 @@ bool EditorClientQt::shouldChangeSelectedRange(Range* currentRange, Range* propo
"FALSE",
"TRUE"
};
-
+
printf("EDITING DELEGATE: shouldChangeSelectedDOMRange:%s toDOMRange:%s affinity:%s stillSelecting:%s\n",
dumpRange(currentRange).toUtf8().constData(),
dumpRange(proposedRange).toUtf8().constData(),
@@ -204,7 +204,9 @@ void EditorClientQt::respondToChangedContents()
{
if (dumpEditingCallbacks)
printf("EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification\n");
- m_page->d->modified = true;
+ m_page->d->updateEditorActions();
+
+ emit m_page->contentsChanged();
}
void EditorClientQt::respondToChangedSelection()
@@ -218,6 +220,7 @@ void EditorClientQt::respondToChangedSelection()
m_page->d->updateEditorActions();
emit m_page->selectionChanged();
+ emit m_page->microFocusChanged();
}
void EditorClientQt::didEndEditing()
@@ -243,17 +246,18 @@ bool EditorClientQt::selectWordBeforeMenuEvent()
bool EditorClientQt::isEditable()
{
- // FIXME: should be controllable by a setting in QWebPage
- return false;
+ return m_page->isEditable();
}
void EditorClientQt::registerCommandForUndo(WTF::PassRefPtr<WebCore::EditCommand> cmd)
{
+#ifndef QT_NO_UNDOSTACK
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));
+#endif // QT_NO_UNDOSTACK
}
void EditorClientQt::registerCommandForRedo(WTF::PassRefPtr<WebCore::EditCommand>)
@@ -262,31 +266,45 @@ void EditorClientQt::registerCommandForRedo(WTF::PassRefPtr<WebCore::EditCommand
void EditorClientQt::clearUndoRedoOperations()
{
+#ifndef QT_NO_UNDOSTACK
return m_page->undoStack()->clear();
+#endif
}
bool EditorClientQt::canUndo() const
{
+#ifdef QT_NO_UNDOSTACK
+ return false;
+#else
return m_page->undoStack()->canUndo();
+#endif
}
bool EditorClientQt::canRedo() const
{
+#ifdef QT_NO_UNDOSTACK
+ return false;
+#else
return m_page->undoStack()->canRedo();
+#endif
}
void EditorClientQt::undo()
{
+#ifndef QT_NO_UNDOSTACK
m_inUndoRedo = true;
m_page->undoStack()->undo();
m_inUndoRedo = false;
+#endif
}
void EditorClientQt::redo()
{
+#ifndef QT_NO_UNDOSTACK
m_inUndoRedo = true;
m_page->undoStack()->redo();
m_inUndoRedo = false;
+#endif
}
bool EditorClientQt::shouldInsertNode(Node* node, Range* range, EditorInsertAction action)
@@ -297,7 +315,7 @@ bool EditorClientQt::shouldInsertNode(Node* node, Range* range, EditorInsertActi
"WebViewInsertActionPasted",
"WebViewInsertActionDropped",
};
-
+
printf("EDITING DELEGATE: shouldInsertNode:%s replacingDOMRange:%s givenAction:%s\n", dumpPath(node).toUtf8().constData(),
dumpRange(range).toUtf8().constData(), insertactionstring[action]);
}
@@ -335,16 +353,25 @@ void EditorClientQt::handleKeyboardEvent(KeyboardEvent* event)
if (!kevent || kevent->type() == PlatformKeyboardEvent::KeyUp)
return;
- Node* start = frame->selectionController()->start().node();
+ Node* start = frame->selection()->start().node();
if (!start)
return;
// FIXME: refactor all of this to use Actions or something like them
if (start->isContentEditable()) {
switch (kevent->windowsVirtualKeyCode()) {
+#if QT_VERSION < 0x040500
case VK_RETURN:
- frame->editor()->command("InsertLineBreak").execute();
+#ifdef QT_WS_MAC
+ if (kevent->shiftKey() || kevent->metaKey())
+#else
+ if (kevent->shiftKey())
+#endif
+ frame->editor()->command("InsertLineBreak").execute();
+ else
+ frame->editor()->command("InsertNewline").execute();
break;
+#endif
case VK_BACK:
frame->editor()->deleteWithDirection(SelectionController::BACKWARD,
CharacterGranularity, false, true);
@@ -382,7 +409,12 @@ void EditorClientQt::handleKeyboardEvent(KeyboardEvent* event)
case VK_TAB:
return;
default:
- if (!kevent->ctrlKey() && !kevent->altKey() && !kevent->text().isEmpty()) {
+ if (kevent->type() != PlatformKeyboardEvent::KeyDown && !kevent->ctrlKey()
+#ifndef Q_WS_MAC
+ // We need to exclude checking for Alt because it is just a different Shift
+ && !kevent->altKey()
+#endif
+ && !kevent->text().isEmpty()) {
frame->editor()->insertText(kevent->text(), event);
} else if (kevent->ctrlKey()) {
switch (kevent->windowsVirtualKeyCode()) {
@@ -411,6 +443,11 @@ void EditorClientQt::handleKeyboardEvent(KeyboardEvent* event)
frame->editor()->command("Undo").execute();
break;
default:
+ // catch combination AltGr+key or Ctrl+Alt+key
+ if (kevent->type() != PlatformKeyboardEvent::KeyDown && kevent->altKey() && !kevent->text().isEmpty()) {
+ frame->editor()->insertText(kevent->text(), event);
+ break;
+ }
return;
}
} else return;
@@ -541,9 +578,14 @@ bool EditorClientQt::isEditing() const
{
return m_editing;
}
-
-void EditorClientQt::setInputMethodState(bool)
+
+void EditorClientQt::setInputMethodState(bool active)
{
+ QWidget *view = m_page->view();
+ if (view) {
+ view->setAttribute(Qt::WA_InputMethodEnabled, active);
+ emit m_page->microFocusChanged();
+ }
}
}
diff --git a/WebKit/qt/WebCoreSupport/EditorClientQt.h b/WebKit/qt/WebCoreSupport/EditorClientQt.h
index 41147b6..35020b2 100644
--- a/WebKit/qt/WebCoreSupport/EditorClientQt.h
+++ b/WebKit/qt/WebCoreSupport/EditorClientQt.h
@@ -60,7 +60,7 @@ public:
virtual bool shouldBeginEditing(Range*);
virtual bool shouldEndEditing(Range*);
virtual bool shouldInsertNode(Node*, Range*, EditorInsertAction);
- virtual bool shouldInsertText(String, Range*, EditorInsertAction);
+ virtual bool shouldInsertText(const String&, Range*, EditorInsertAction);
virtual bool shouldChangeSelectedRange(Range* fromRange, Range* toRange, EAffinity, bool stillSelecting);
virtual bool shouldApplyStyle(CSSStyleDeclaration*, Range*);
diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
index bb6fb95..6235ed6 100644
--- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
@@ -1,7 +1,8 @@
/*
* Copyright (C) 2006 Zack Rusin <zack@kde.org>
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2007 Trolltech ASA
+ * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2008 Collabora Ltd. All rights reserved.
*
* All rights reserved.
*
@@ -37,7 +38,10 @@
#include "MIMETypeRegistry.h"
#include "ResourceResponse.h"
#include "Page.h"
+#include "PluginData.h"
+#include "PluginDatabase.h"
#include "ProgressTracker.h"
+#include "RenderPart.h"
#include "ResourceRequest.h"
#include "HistoryItem.h"
#include "HTMLFormElement.h"
@@ -50,6 +54,7 @@
#include "qwebframe.h"
#include "qwebframe_p.h"
#include "qwebhistoryinterface.h"
+#include "qwebpluginfactory.h"
#include <qfileinfo.h>
@@ -60,8 +65,69 @@
#include <QNetworkReply>
#else
#include "qwebnetworkinterface_p.h"
-#include "qwebobjectplugin_p.h"
#endif
+#include "qwebhistory_p.h"
+
+static bool dumpFrameLoaderCallbacks = false;
+static bool dumpResourceLoadCallbacks = false;
+
+static QMap<unsigned long, QString> dumpAssignedUrls;
+
+void QWEBKIT_EXPORT qt_dump_frame_loader(bool b)
+{
+ dumpFrameLoaderCallbacks = b;
+}
+
+void QWEBKIT_EXPORT qt_dump_resource_load_callbacks(bool b)
+{
+ dumpResourceLoadCallbacks = b;
+}
+
+// Compare with WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm
+static QString drtDescriptionSuitableForTestResult(WebCore::Frame* _frame)
+{
+ QWebFrame* frame = QWebFramePrivate::kit(_frame);
+ QString name = frame->frameName();
+
+ bool isMainFrame = frame == frame->page()->mainFrame();
+ if (isMainFrame) {
+ if (!name.isEmpty())
+ return QString::fromLatin1("main frame \"%1\"").arg(name);
+ return QLatin1String("main frame");
+ } else {
+ if (!name.isEmpty())
+ return QString::fromLatin1("frame \"%1\"").arg(name);
+ return QLatin1String("frame (anonymous)");
+ }
+}
+
+static QString drtDescriptionSuitableForTestResult(const WebCore::KURL& _url)
+{
+ QUrl url = _url;
+ return url.toString();
+}
+
+static QString drtDescriptionSuitableForTestResult(const WebCore::ResourceError& error)
+{
+ QString failingURL = error.failingURL();
+ return QString::fromLatin1("<NSError domain NSURLErrorDomain, code %1, failing URL \"%2\">").arg(error.errorCode()).arg(failingURL);
+}
+
+static QString drtDescriptionSuitableForTestResult(const WebCore::ResourceRequest& request)
+{
+ QString url = request.url().string();
+ return QString::fromLatin1("<NSURLRequest %1>").arg(url);
+}
+
+static QString drtDescriptionSuitableForTestResult(const WebCore::ResourceResponse& response)
+{
+ QString text = response.httpStatusText();
+ if (text.isEmpty())
+ return QLatin1String("(null)");
+
+ return text;
+}
+
namespace WebCore
{
@@ -69,8 +135,11 @@ namespace WebCore
FrameLoaderClientQt::FrameLoaderClientQt()
: m_frame(0)
, m_webFrame(0)
+ , m_pluginView(0)
+ , m_hasSentResponseToPlugin(false)
, m_firstData(false)
, m_policyFunction(0)
+ , m_loadSucceeded(false)
{
connect(this, SIGNAL(sigCallPolicyFunction(int)), this, SLOT(slotCallPolicyFunction(int)), Qt::QueuedConnection);
}
@@ -90,11 +159,11 @@ void FrameLoaderClientQt::setFrame(QWebFrame* webFrame, Frame* frame)
}
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()));
+ m_webFrame->page(), SIGNAL(loadStarted()));
+ connect(this, SIGNAL(loadProgress(int)),
+ m_webFrame->page(), SIGNAL(loadProgress(int)));
+ connect(this, SIGNAL(loadFinished(bool)),
+ m_webFrame->page(), SIGNAL(loadFinished(bool)));
connect(this, SIGNAL(titleChanged(const QString&)),
m_webFrame, SIGNAL(titleChanged(const QString&)));
}
@@ -128,62 +197,42 @@ bool FrameLoaderClientQt::hasWebView() const
return true;
}
-
-bool FrameLoaderClientQt::hasFrameView() const
-{
- //notImplemented();
- return true;
-}
-
-
-bool FrameLoaderClientQt::hasBackForwardList() const
+void FrameLoaderClientQt::savePlatformDataToCachedPage(CachedPage*)
{
notImplemented();
- return false;
}
-
-void FrameLoaderClientQt::resetBackForwardList()
+void FrameLoaderClientQt::transitionToCommittedFromCachedPage(CachedPage*)
{
- notImplemented();
}
-
-bool FrameLoaderClientQt::provisionalItemIsTarget() const
+void FrameLoaderClientQt::transitionToCommittedForNewPage()
{
- notImplemented();
- return false;
-}
+ ASSERT(m_frame);
+ ASSERT(m_webFrame);
+ Page* page = m_frame->page();
+ ASSERT(page);
-bool FrameLoaderClientQt::loadProvisionalItemFromPageCache()
-{
- notImplemented();
- return false;
-}
+ bool isMainFrame = m_frame == page->mainFrame();
+ m_frame->setView(0);
-void FrameLoaderClientQt::invalidateCurrentItemPageCache()
-{
- notImplemented();
-}
-
-void FrameLoaderClientQt::savePlatformDataToCachedPage(CachedPage*)
-{
- notImplemented();
-}
+ FrameView* frameView;
+ if (isMainFrame)
+ frameView = new FrameView(m_frame, m_webFrame->page()->viewportSize());
+ else
+ frameView = new FrameView(m_frame);
-void FrameLoaderClientQt::transitionToCommittedFromCachedPage(CachedPage*)
-{
- notImplemented();
-}
+ m_frame->setView(frameView);
+ // FrameViews are created with a ref count of 1. Release this ref since we've assigned it to frame.
+ frameView->deref();
-void FrameLoaderClientQt::transitionToCommittedForNewPage()
-{
-// qDebug() << "FrameLoaderClientQt::makeDocumentView" << m_frame->document();
+ if (m_webFrame && m_webFrame->page())
+ m_webFrame->d->updateBackground();
-// if (!m_frame->document())
-// m_frame->loader()->createEmptyDocument();
+ if (m_frame->ownerRenderer())
+ m_frame->ownerRenderer()->setWidget(frameView);
}
@@ -195,8 +244,7 @@ void FrameLoaderClientQt::makeRepresentation(DocumentLoader*)
void FrameLoaderClientQt::forceLayout()
{
- m_frame->view()->setNeedsLayout();
- m_frame->view()->layout();
+ m_frame->forceLayout(true);
}
@@ -211,30 +259,6 @@ void FrameLoaderClientQt::setCopiesOnScroll()
}
-LoadErrorResetToken* FrameLoaderClientQt::tokenForLoadErrorReset()
-{
- notImplemented();
- return 0;
-}
-
-
-void FrameLoaderClientQt::resetAfterLoadError(LoadErrorResetToken*)
-{
- notImplemented();
-}
-
-
-void FrameLoaderClientQt::doNotResetAfterLoadError(LoadErrorResetToken*)
-{
- notImplemented();
-}
-
-
-void FrameLoaderClientQt::willCloseDocument()
-{
- notImplemented();
-}
-
void FrameLoaderClientQt::detachedFromParent2()
{
}
@@ -244,63 +268,65 @@ 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
+ if (dumpFrameLoaderCallbacks)
+ printf("%s - didHandleOnloadEventsForFrame\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)));
+
}
void FrameLoaderClientQt::dispatchDidReceiveServerRedirectForProvisionalLoad()
{
+ if (dumpFrameLoaderCallbacks)
+ printf("%s - didReceiveServerRedirectForProvisionalLoadForFrame\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)));
+
notImplemented();
}
void FrameLoaderClientQt::dispatchDidCancelClientRedirect()
{
+ if (dumpFrameLoaderCallbacks)
+ printf("%s - didCancelClientRedirectForFrame\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)));
+
notImplemented();
}
-void FrameLoaderClientQt::dispatchWillPerformClientRedirect(const KURL&,
+void FrameLoaderClientQt::dispatchWillPerformClientRedirect(const KURL& url,
double interval,
double fireDate)
{
+ if (dumpFrameLoaderCallbacks)
+ printf("%s - willPerformClientRedirectToURL: %s \n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)), qPrintable(drtDescriptionSuitableForTestResult(url)));
+
notImplemented();
}
void FrameLoaderClientQt::dispatchDidChangeLocationWithinPage()
{
+ if (dumpFrameLoaderCallbacks)
+ printf("%s - didChangeLocationWithinPageForFrame\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)));
+
notImplemented();
}
void FrameLoaderClientQt::dispatchWillClose()
{
+ if (dumpFrameLoaderCallbacks)
+ printf("%s - willCloseFrame\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)));
}
void FrameLoaderClientQt::dispatchDidStartProvisionalLoad()
{
+ if (dumpFrameLoaderCallbacks)
+ printf("%s - didStartProvisionalLoadForFrame\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)));
+
if (m_webFrame)
emit m_webFrame->provisionalLoad();
}
@@ -308,6 +334,14 @@ void FrameLoaderClientQt::dispatchDidStartProvisionalLoad()
void FrameLoaderClientQt::dispatchDidReceiveTitle(const String& title)
{
+ if (dumpFrameLoaderCallbacks)
+ printf("%s - didReceiveTitle: %s\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)), qPrintable(QString(title)));
+
+ if (!m_webFrame)
+ return;
+
+
+
// ### hack
emit m_webFrame->urlChanged(m_webFrame->url());
emit titleChanged(title);
@@ -316,25 +350,41 @@ void FrameLoaderClientQt::dispatchDidReceiveTitle(const String& title)
void FrameLoaderClientQt::dispatchDidCommitLoad()
{
- if (m_frame->tree()->parent())
+ if (dumpFrameLoaderCallbacks)
+ printf("%s - didCommitLoadForFrame\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)));
+
+ if (m_frame->tree()->parent() || !m_webFrame)
return;
+
m_webFrame->page()->d->updateNavigationActions();
+
+ // We should assume first the frame has no title. If it has, then the above dispatchDidReceiveTitle()
+ // will be called very soon with the correct title.
+ // This properly resets the title when we navigate to a URI without a title.
+ emit titleChanged(String());
}
void FrameLoaderClientQt::dispatchDidFinishDocumentLoad()
{
- if (m_frame->tree()->parent())
+ if (dumpFrameLoaderCallbacks)
+ printf("%s - didFinishDocumentLoadForFrame\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)));
+
+ if (m_frame->tree()->parent() || !m_webFrame)
return;
+
m_webFrame->page()->d->updateNavigationActions();
}
void FrameLoaderClientQt::dispatchDidFinishLoad()
{
- if (m_webFrame)
- emit m_webFrame->loadDone(true);
- if (m_frame->tree()->parent())
+ if (dumpFrameLoaderCallbacks)
+ printf("%s - didFinishLoadForFrame\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)));
+
+ m_loadSucceeded = true;
+
+ if (m_frame->tree()->parent() || !m_webFrame)
return;
m_webFrame->page()->d->updateNavigationActions();
}
@@ -343,7 +393,7 @@ void FrameLoaderClientQt::dispatchDidFinishLoad()
void FrameLoaderClientQt::dispatchDidFirstLayout()
{
if (m_webFrame)
- emit m_webFrame->initialLayoutComplete();
+ emit m_webFrame->initialLayoutCompleted();
}
@@ -375,36 +425,19 @@ 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())
+ if (m_webFrame && m_frame->page()) {
emit loadStarted();
- if (m_frame->tree()->parent())
+ postProgressEstimateChangedNotification();
+ }
+ if (m_frame->tree()->parent() || !m_webFrame)
return;
m_webFrame->page()->d->updateNavigationActions();
}
@@ -412,13 +445,27 @@ void FrameLoaderClientQt::postProgressStartedNotification()
void FrameLoaderClientQt::postProgressEstimateChangedNotification()
{
if (m_webFrame && m_frame->page())
- emit loadProgressChanged(qRound(m_frame->page()->progress()->estimatedProgress() * 100));
+ emit loadProgress(qRound(m_frame->page()->progress()->estimatedProgress() * 100));
}
void FrameLoaderClientQt::postProgressFinishedNotification()
{
+ // send a mousemove event to
+ // (1) update the cursor to change according to whatever is underneath the mouse cursor right now
+ // (2) display the tool tip if the mouse hovers a node which has a tool tip
+ if (m_frame && m_frame->eventHandler() && m_webFrame->page()) {
+ QWidget* view = m_webFrame->page()->view();
+ if (view && view->hasFocus()) {
+ QPoint localPos = view->mapFromGlobal(QCursor::pos());
+ if (view->rect().contains(localPos)) {
+ QMouseEvent event(QEvent::MouseMove, localPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier);
+ m_frame->eventHandler()->mouseMoved(PlatformMouseEvent(&event, 0));
+ }
+ }
+ }
+
if (m_webFrame && m_frame->page())
- emit loadFinished();
+ emit loadFinished(m_loadSucceeded);
}
void FrameLoaderClientQt::setMainFrameDocumentReady(bool b)
@@ -441,41 +488,18 @@ void FrameLoaderClientQt::didChangeTitle(DocumentLoader *)
void FrameLoaderClientQt::finishedLoading(DocumentLoader* loader)
{
- if (m_firstData) {
- FrameLoader *fl = loader->frameLoader();
- fl->setEncoding(m_response.textEncodingName(), false);
- m_firstData = false;
+ if (!m_pluginView) {
+ if(m_firstData) {
+ FrameLoader *fl = loader->frameLoader();
+ fl->setEncoding(m_response.textEncodingName(), false);
+ m_firstData = false;
+ }
+ }
+ else {
+ m_pluginView->didFinishLoading();
+ m_pluginView = 0;
+ m_hasSentResponseToPlugin = 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
}
@@ -487,6 +511,9 @@ bool FrameLoaderClientQt::canShowMIMEType(const String& MIMEType) const
if (MIMETypeRegistry::isSupportedNonImageMIMEType(MIMEType))
return true;
+ if (PluginDatabase::installedPlugins()->isMIMETypeRegistered(MIMEType))
+ return true;
+
return false;
}
@@ -524,19 +551,6 @@ void FrameLoaderClientQt::provisionalLoadStarted()
}
-bool FrameLoaderClientQt::shouldTreatURLAsSameAsCurrent(const KURL&) const
-{
- notImplemented();
- return false;
-}
-
-
-void FrameLoaderClientQt::addHistoryItemForFragmentScroll()
-{
- notImplemented();
-}
-
-
void FrameLoaderClientQt::didFinishLoad()
{
// notImplemented();
@@ -557,22 +571,27 @@ void FrameLoaderClientQt::setTitle(const String&, const KURL&)
String FrameLoaderClientQt::userAgent(const KURL& url)
{
if (m_webFrame) {
- return m_webFrame->page()->userAgentFor(QUrl((QString)url.string()));
+ return m_webFrame->page()->userAgentForUrl(url);
}
return String();
}
void FrameLoaderClientQt::dispatchDidReceiveIcon()
{
+ if (dumpFrameLoaderCallbacks)
+ printf("%s - didReceiveIconForFrame\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)));
+
if (m_webFrame) {
- emit m_webFrame->iconLoaded();
+ emit m_webFrame->iconChanged();
}
}
void FrameLoaderClientQt::frameLoaderDestroyed()
{
- Q_ASSERT(m_webFrame == 0);
- Q_ASSERT(m_frame == 0);
+ delete m_webFrame;
+ m_frame = 0;
+ m_webFrame = 0;
+
delete this;
}
@@ -583,13 +602,16 @@ bool FrameLoaderClientQt::canHandleRequest(const WebCore::ResourceRequest&) cons
void FrameLoaderClientQt::windowObjectCleared()
{
+ if (dumpFrameLoaderCallbacks)
+ printf("%s - didClearWindowObjectForFrame\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)));
+
if (m_webFrame)
- emit m_webFrame->cleared();
+ emit m_webFrame->javaScriptWindowObjectCleared();
}
void FrameLoaderClientQt::didPerformFirstNavigation() const
{
- if (m_frame->tree()->parent())
+ if (m_frame->tree()->parent() || !m_webFrame)
return;
m_webFrame->page()->d->updateNavigationActions();
}
@@ -599,55 +621,64 @@ void FrameLoaderClientQt::registerForIconNotification(bool)
notImplemented();
}
-void FrameLoaderClientQt::updateGlobalHistoryForStandardLoad(const WebCore::KURL& url)
+void FrameLoaderClientQt::updateGlobalHistory(const WebCore::KURL& url)
{
QWebHistoryInterface *history = QWebHistoryInterface::defaultInterface();
if (history)
history->addHistoryEntry(url.prettyURL());
}
-void FrameLoaderClientQt::updateGlobalHistoryForReload(const WebCore::KURL&)
-{
- notImplemented();
-}
-
bool FrameLoaderClientQt::shouldGoToHistoryItem(WebCore::HistoryItem *item) const
{
- if (item) {
- return true;
- }
- return false;
+ return true;
}
-void FrameLoaderClientQt::saveViewStateToItem(WebCore::HistoryItem*)
+void FrameLoaderClientQt::saveViewStateToItem(WebCore::HistoryItem* item)
{
- notImplemented();
+ QWebHistoryItem historyItem(new QWebHistoryItemPrivate(item));
+ emit m_webFrame->aboutToUpdateHistory(&historyItem);
}
bool FrameLoaderClientQt::canCachePage() const
{
- // don't do any caching for now
- return false;
+ return true;
}
void FrameLoaderClientQt::setMainDocumentError(WebCore::DocumentLoader* loader, const WebCore::ResourceError& error)
{
- if (m_firstData) {
- loader->frameLoader()->setEncoding(m_response.textEncodingName(), false);
- m_firstData = false;
+ if (!m_pluginView) {
+ if (m_firstData) {
+ loader->frameLoader()->setEncoding(m_response.textEncodingName(), false);
+ m_firstData = false;
+ }
+ } else {
+ m_pluginView->didFail(error);
+ m_pluginView = 0;
+ m_hasSentResponseToPlugin = 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;
+ if (!m_pluginView) {
+ if (!m_frame)
+ return;
+ FrameLoader *fl = loader->frameLoader();
+ if (m_firstData) {
+ fl->setEncoding(m_response.textEncodingName(), false);
+ m_firstData = false;
+ }
+ fl->addData(data, length);
+ }
+
+ // We re-check here as the plugin can have been created
+ if (m_pluginView) {
+ if (!m_hasSentResponseToPlugin) {
+ m_pluginView->didReceiveResponse(loader->response());
+ m_hasSentResponseToPlugin = true;
+ }
+ m_pluginView->didReceiveData(data, length);
}
- fl->addData(data, length);
}
WebCore::ResourceError FrameLoaderClientQt::cancelledError(const WebCore::ResourceRequest& request)
@@ -661,12 +692,12 @@ enum {
WebKitErrorCannotShowMIMEType = 100,
WebKitErrorCannotShowURL = 101,
WebKitErrorFrameLoadInterruptedByPolicyChange = 102,
- WebKitErrorCannotUseRestrictedPort = 103,
+ WebKitErrorCannotUseRestrictedPort = 103,
WebKitErrorCannotFindPlugIn = 200,
WebKitErrorCannotLoadPlugIn = 201,
WebKitErrorJavaUnavailable = 202,
};
-
+
WebCore::ResourceError FrameLoaderClientQt::blockedError(const WebCore::ResourceRequest& request)
{
return ResourceError("Error", WebKitErrorCannotUseRestrictedPort, request.url().prettyURL(),
@@ -698,6 +729,12 @@ WebCore::ResourceError FrameLoaderClientQt::fileDoesNotExistError(const WebCore:
QCoreApplication::translate("QWebFrame", "File does not exist", 0, QCoreApplication::UnicodeUTF8));
}
+WebCore::ResourceError FrameLoaderClientQt::pluginWillHandleLoadError(const WebCore::ResourceResponse& response)
+{
+ notImplemented();
+ return ResourceError();
+}
+
bool FrameLoaderClientQt::shouldFallBack(const WebCore::ResourceError&)
{
notImplemented();
@@ -706,31 +743,44 @@ bool FrameLoaderClientQt::shouldFallBack(const WebCore::ResourceError&)
WTF::PassRefPtr<WebCore::DocumentLoader> FrameLoaderClientQt::createDocumentLoader(const WebCore::ResourceRequest& request, const SubstituteData& substituteData)
{
- RefPtr<DocumentLoader> loader = new DocumentLoader(request, substituteData);
+ RefPtr<DocumentLoader> loader = DocumentLoader::create(request, substituteData);
+ if (substituteData.isValid())
+ loader->setDeferMainResourceDataLoad(false);
return loader.release();
}
void FrameLoaderClientQt::download(WebCore::ResourceHandle* handle, const WebCore::ResourceRequest&, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&)
{
#if QT_VERSION >= 0x040400
+ if (!m_webFrame)
+ return;
+
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);
+ if (page->forwardUnsupportedContent())
+ emit m_webFrame->page()->unsupportedContent(reply);
else
reply->abort();
}
#endif
}
-void FrameLoaderClientQt::assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&)
+void FrameLoaderClientQt::assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader* loader, const WebCore::ResourceRequest& request)
{
+ if (dumpResourceLoadCallbacks)
+ dumpAssignedUrls[identifier] = drtDescriptionSuitableForTestResult(request.url());
}
-void FrameLoaderClientQt::dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long, WebCore::ResourceRequest& request, const WebCore::ResourceResponse& response)
+void FrameLoaderClientQt::dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long identifier, WebCore::ResourceRequest& newRequest, const WebCore::ResourceResponse& redirectResponse)
{
+ if (dumpResourceLoadCallbacks)
+ printf("%s - willSendRequest %s redirectResponse %s\n",
+ qPrintable(dumpAssignedUrls[identifier]),
+ qPrintable(drtDescriptionSuitableForTestResult(newRequest)),
+ qPrintable(drtDescriptionSuitableForTestResult(redirectResponse)));
+
// seems like the Mac code doesn't do anything here by default neither
//qDebug() << "FrameLoaderClientQt::dispatchWillSendRequest" << request.isNull() << request.url().string`();
}
@@ -761,8 +811,11 @@ void FrameLoaderClientQt::dispatchDidFinishLoading(WebCore::DocumentLoader* load
{
}
-void FrameLoaderClientQt::dispatchDidFailLoading(WebCore::DocumentLoader* loader, unsigned long, const WebCore::ResourceError&)
+void FrameLoaderClientQt::dispatchDidFailLoading(WebCore::DocumentLoader* loader, unsigned long identifier, const WebCore::ResourceError& error)
{
+ if (dumpResourceLoadCallbacks)
+ printf("%s - didFailLoadingWithError: %s\n", qPrintable(dumpAssignedUrls[identifier]), qPrintable(drtDescriptionSuitableForTestResult(error)));
+
if (m_firstData) {
FrameLoader *fl = loader->frameLoader();
fl->setEncoding(m_response.textEncodingName(), false);
@@ -778,24 +831,28 @@ bool FrameLoaderClientQt::dispatchDidLoadResourceFromMemoryCache(WebCore::Docume
void FrameLoaderClientQt::dispatchDidFailProvisionalLoad(const WebCore::ResourceError&)
{
- if (m_webFrame)
- emit m_webFrame->loadDone(false);
+ if (dumpFrameLoaderCallbacks)
+ printf("%s - didFailProvisionalLoadWithError\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)));
+
+ m_loadSucceeded = false;
}
void FrameLoaderClientQt::dispatchDidFailLoad(const WebCore::ResourceError&)
{
- if (m_webFrame)
- emit m_webFrame->loadDone(false);
+ if (dumpFrameLoaderCallbacks)
+ printf("%s - didFailLoadWithError\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)));
+
+ m_loadSucceeded = false;
}
WebCore::Frame* FrameLoaderClientQt::dispatchCreatePage()
{
if (!m_webFrame)
return 0;
- QWebPage *newPage = m_webFrame->page()->createWindow();
+ QWebPage *newPage = m_webFrame->page()->createWindow(QWebPage::WebBrowserWindow);
if (!newPage)
return 0;
- return newPage->mainFrame()->d->frame.get();
+ return newPage->mainFrame()->d->frame;
}
void FrameLoaderClientQt::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const WebCore::String& MIMEType, const WebCore::ResourceRequest&)
@@ -809,33 +866,46 @@ void FrameLoaderClientQt::dispatchDecidePolicyForMIMEType(FramePolicyFunction fu
slotCallPolicyFunction(PolicyDownload);
}
-void FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, const WebCore::String&)
+void FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const WebCore::NavigationAction& action, const WebCore::ResourceRequest& request, PassRefPtr<WebCore::FormState>, const WebCore::String&)
{
Q_ASSERT(!m_policyFunction);
+ Q_ASSERT(m_webFrame);
m_policyFunction = function;
+#if QT_VERSION < 0x040400
+ QWebNetworkRequest r(request);
+#else
+ QNetworkRequest r(request.toNetworkRequest());
+#endif
+ QWebPage* page = m_webFrame->page();
+
+ if (!page->d->acceptNavigationRequest(0, r, QWebPage::NavigationType(action.type()))) {
+ if (action.type() == NavigationTypeFormSubmitted || action.type() == NavigationTypeFormResubmitted)
+ m_frame->loader()->resetMultipleFormSubmissionProtection();
+ slotCallPolicyFunction(PolicyIgnore);
+ return;
+ }
slotCallPolicyFunction(PolicyUse);
}
-void FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const WebCore::NavigationAction& action, const WebCore::ResourceRequest& request)
+void FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const WebCore::NavigationAction& action, const WebCore::ResourceRequest& request, PassRefPtr<WebCore::FormState>)
{
Q_ASSERT(!m_policyFunction);
+ Q_ASSERT(m_webFrame);
m_policyFunction = function;
- if (m_webFrame) {
#if QT_VERSION < 0x040400
- QWebNetworkRequest r(request);
+ QWebNetworkRequest r(request);
#else
- QNetworkRequest r(request.toNetworkRequest());
+ QNetworkRequest r(request.toNetworkRequest());
#endif
- QWebPage *page = m_webFrame->page();
+ QWebPage*page = m_webFrame->page();
- if (page->d->navigationRequested(m_webFrame, r, QWebPage::NavigationType(action.type())) ==
- QWebPage::IgnoreNavigationRequest) {
- slotCallPolicyFunction(PolicyIgnore);
- return;
- }
+ if (!page->d->acceptNavigationRequest(m_webFrame, r, QWebPage::NavigationType(action.type()))) {
+ if (action.type() == NavigationTypeFormSubmitted || action.type() == NavigationTypeFormResubmitted)
+ m_frame->loader()->resetMultipleFormSubmissionProtection();
+ slotCallPolicyFunction(PolicyIgnore);
+ return;
}
slotCallPolicyFunction(PolicyUse);
- return;
}
void FrameLoaderClientQt::dispatchUnableToImplementPolicy(const WebCore::ResourceError&)
@@ -846,19 +916,20 @@ void FrameLoaderClientQt::dispatchUnableToImplementPolicy(const WebCore::Resourc
void FrameLoaderClientQt::startDownload(const WebCore::ResourceRequest& request)
{
#if QT_VERSION >= 0x040400
+ if (!m_webFrame)
+ return;
+
QWebPage *page = m_webFrame->page();
- emit m_webFrame->page()->download(request.toNetworkRequest());
+ emit m_webFrame->page()->downloadRequested(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)
{
+ if (!m_webFrame)
+ return 0;
+
QWebFrameData frameData;
frameData.url = url;
frameData.name = name;
@@ -871,7 +942,7 @@ PassRefPtr<Frame> FrameLoaderClientQt::createFrame(const KURL& url, const String
QWebFrame* webFrame = new QWebFrame(m_webFrame, &frameData);
emit m_webFrame->page()->frameCreated(webFrame);
- RefPtr<Frame> childFrame = adoptRef(webFrame->d->frame.get());
+ RefPtr<Frame> childFrame = adoptRef(webFrame->d->frame);
// FIXME: All of the below should probably be moved over into WebCore
childFrame->tree()->setName(name);
@@ -881,8 +952,7 @@ PassRefPtr<Frame> FrameLoaderClientQt::createFrame(const KURL& url, const String
FrameLoadType loadType = m_frame->loader()->loadType();
FrameLoadType childLoadType = FrameLoadTypeRedirectWithLockedHistory;
- childFrame->loader()->load(frameData.url, frameData.referrer, childLoadType,
- String(), 0, 0);
+ childFrame->loader()->loadURL(frameData.url, frameData.referrer, String(), childLoadType, 0, 0);
// The frame's onload handler may have removed it from the document.
if (!childFrame->tree()->parent())
@@ -897,7 +967,7 @@ ObjectContentType FrameLoaderClientQt::objectContentType(const KURL& url, const
if (_mimeType == "application/x-qt-plugin" || _mimeType == "application/x-qt-styled-widget")
return ObjectContentOtherPlugin;
- if (url.isEmpty())
+ if (url.isEmpty() && !_mimeType.length())
return ObjectContentNone;
String mimeType = _mimeType;
@@ -912,11 +982,11 @@ ObjectContentType FrameLoaderClientQt::objectContentType(const KURL& url, const
if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType))
return ObjectContentImage;
- // ### FIXME Qt 4.4
-#if QT_VERSION < 0x040400
- if (QWebFactoryLoader::self()->supportsMimeType(mimeType))
+ if (PluginDatabase::installedPlugins()->isMIMETypeRegistered(mimeType))
return ObjectContentNetscapePlugin;
-#endif
+
+ if (m_frame->page() && m_frame->page()->pluginData()->supportsMimeType(mimeType))
+ return ObjectContentOtherPlugin;
if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType))
return ObjectContentFrame;
@@ -928,24 +998,44 @@ ObjectContentType FrameLoaderClientQt::objectContentType(const KURL& url, const
}
static const CSSPropertyID qstyleSheetProperties[] = {
- CSS_PROP_COLOR,
- CSS_PROP_FONT_FAMILY,
- CSS_PROP_FONT_SIZE,
- CSS_PROP_FONT_STYLE,
- CSS_PROP_FONT_WEIGHT
+ CSSPropertyColor,
+ CSSPropertyFontFamily,
+ CSSPropertyFontSize,
+ CSSPropertyFontStyle,
+ CSSPropertyFontWeight
};
const unsigned numqStyleSheetProperties = sizeof(qstyleSheetProperties) / sizeof(qstyleSheetProperties[0]);
-Widget* FrameLoaderClientQt::createPlugin(const IntSize&, Element* element, const KURL& url, const Vector<String>& paramNames,
+class QtPluginWidget: public Widget
+{
+public:
+ QtPluginWidget(QWidget* w = 0): Widget(w) {}
+ virtual void invalidateRect(const IntRect& r)
+ {
+ if (platformWidget())
+ platformWidget()->update(r);
+ }
+};
+
+Widget* FrameLoaderClientQt::createPlugin(const IntSize& pluginSize, 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();
+
+ if (!m_webFrame)
+ return 0;
+
QStringList params;
QStringList values;
- for (int i = 0; i < paramNames.size(); ++i)
+ QString classid(element->getAttribute("classid"));
+
+ for (int i = 0; i < paramNames.size(); ++i) {
params.append(paramNames[i]);
+ if (paramNames[i] == "classid")
+ classid = paramValues[i];
+ }
for (int i = 0; i < paramValues.size(); ++i)
values.append(paramValues[i]);
@@ -955,10 +1045,10 @@ Widget* FrameLoaderClientQt::createPlugin(const IntSize&, Element* element, cons
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);
+ object = m_webFrame->page()->createPlugin(classid, qurl, params, values);
+#ifndef QT_NO_STYLE_STYLESHEET
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())
@@ -967,33 +1057,40 @@ Widget* FrameLoaderClientQt::createPlugin(const IntSize&, Element* element, cons
for (int i = 0; i < numqStyleSheetProperties; ++i) {
CSSPropertyID property = qstyleSheetProperties[i];
- styleSheet += ::getPropertyName(property);
+ styleSheet += QString::fromLatin1(::getPropertyName(property));
styleSheet += QLatin1Char(':');
- styleSheet += cssDecl.getPropertyValue(property);
+ styleSheet += computedStyle(element)->getPropertyValue(property);
styleSheet += QLatin1Char(';');
}
widget->setStyleSheet(styleSheet);
}
+#endif // QT_NO_STYLE_STYLESHEET
}
- // ### FIXME: qt 4.4
-#if QT_VERSION < 0x040400
- if (!object)
- object = QWebFactoryLoader::self()->create(m_webFrame, qurl, mimeType, params, values);
+#if QT_VERSION >= 0x040400
+ if (!object) {
+ QWebPluginFactory* factory = m_webFrame->page()->pluginFactory();
+ if (factory)
+ object = factory->create(mimeType, qurl, 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;
+ if (object) {
+ QWidget *widget = qobject_cast<QWidget *>(object);
+ QWidget *view = m_webFrame->page()->view();
+ if (widget && view) {
+ widget->setParent(view);
+ QtPluginWidget* w= new QtPluginWidget();
+ w->setPlatformWidget(widget);
+ return w;
+ }
+ // FIXME: make things work for widgetless plugins as well
+ delete object;
+ } else { // NPAPI Plugins
+ PluginView* pluginView = PluginView::create(m_frame, pluginSize, element, url,
+ paramNames, paramValues, mimeType, loadManually);
+ return pluginView;
}
return 0;
@@ -1001,8 +1098,9 @@ Widget* FrameLoaderClientQt::createPlugin(const IntSize&, Element* element, cons
void FrameLoaderClientQt::redirectDataToPlugin(Widget* pluginWidget)
{
- notImplemented();
- return;
+ ASSERT(!m_pluginView);
+ m_pluginView = static_cast<PluginView*>(pluginWidget);
+ m_hasSentResponseToPlugin = false;
}
Widget* FrameLoaderClientQt::createJavaAppletWidget(const IntSize&, Element*, const KURL& baseURL,
@@ -1022,7 +1120,6 @@ 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
index 2eced5d..0156412 100644
--- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
+++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
@@ -1,6 +1,8 @@
/*
* Copyright (C) 2006 Zack Rusin <zack@kde.org>
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2008 Collabora Ltd. All rights reserved.
*
* All rights reserved.
*
@@ -37,6 +39,7 @@
#include "FrameLoader.h"
#include "RefCounted.h"
#include "ResourceResponse.h"
+#include "PluginView.h"
class QWebFrame;
namespace WebCore {
@@ -48,37 +51,32 @@ namespace WebCore {
class NavigationAction;
class String;
class ResourceLoader;
-
+
struct LoadErrorResetToken;
class FrameLoaderClientQt : public QObject, public FrameLoaderClient {
Q_OBJECT
+ friend class ::QWebFrame;
void callPolicyFunction(FramePolicyFunction function, PolicyAction action);
private slots:
void slotCallPolicyFunction(int);
signals:
void sigCallPolicyFunction(int);
void loadStarted();
- void loadProgressChanged(int d);
- void loadFinished();
+ void loadProgress(int d);
+ void loadFinished(bool);
void titleChanged(const QString& title);
public:
FrameLoaderClientQt();
~FrameLoaderClientQt();
+ virtual void frameLoaderDestroyed();
+
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();
@@ -86,20 +84,19 @@ namespace WebCore {
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 assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&);
- virtual void frameLoaderDestroyed();
- virtual bool canHandleRequest(const WebCore::ResourceRequest&) const;
+ 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 dispatchDidHandleOnloadEvents();
virtual void dispatchDidReceiveServerRedirectForProvisionalLoad();
@@ -111,43 +108,69 @@ namespace WebCore {
virtual void dispatchDidStartProvisionalLoad();
virtual void dispatchDidReceiveTitle(const String& title);
virtual void dispatchDidCommitLoad();
-
+ virtual void dispatchDidFailProvisionalLoad(const ResourceError&);
+ virtual void dispatchDidFailLoad(const WebCore::ResourceError&);
virtual void dispatchDidFinishDocumentLoad();
virtual void dispatchDidFinishLoad();
virtual void dispatchDidFirstLayout();
+ virtual WebCore::Frame* dispatchCreatePage();
virtual void dispatchShow();
+
+ virtual void dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const WebCore::String&, const WebCore::ResourceRequest&);
+ virtual void dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<FormState>, const WebCore::String&);
+ virtual void dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<FormState>);
virtual void cancelPolicyCheck();
+ virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&);
+
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 setMainDocumentError(DocumentLoader*, const ResourceError&);
+
+ virtual void postProgressStartedNotification();
+ virtual void postProgressEstimateChangedNotification();
+ virtual void postProgressFinishedNotification();
virtual void setMainFrameDocumentReady(bool);
+
+ virtual void startDownload(const WebCore::ResourceRequest&);
+
virtual void willChangeTitle(DocumentLoader*);
virtual void didChangeTitle(DocumentLoader*);
+
+ virtual void committedLoad(WebCore::DocumentLoader*, const char*, int);
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 void updateGlobalHistory(const KURL&);
+ virtual bool shouldGoToHistoryItem(HistoryItem*) const;
+
+ virtual ResourceError cancelledError(const ResourceRequest&);
+ virtual ResourceError blockedError(const ResourceRequest&);
+ virtual ResourceError cannotShowURLError(const ResourceRequest&);
+ virtual ResourceError interruptForPolicyChangeError(const ResourceRequest&);
+
+ virtual ResourceError cannotShowMIMETypeError(const ResourceResponse&);
+ virtual ResourceError fileDoesNotExistError(const ResourceResponse&);
+ virtual ResourceError pluginWillHandleLoadError(const ResourceResponse&);
+
+ virtual bool shouldFallBack(const ResourceError&);
+
+ virtual bool canHandleRequest(const WebCore::ResourceRequest&) const;
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 saveViewStateToItem(WebCore::HistoryItem*);
virtual void restoreViewState();
virtual void provisionalLoadStarted();
- virtual bool shouldTreatURLAsSameAsCurrent(const KURL&) const;
- virtual void addHistoryItemForFragmentScroll();
virtual void didFinishLoad();
virtual void prepareForDataSourceReplacement();
+
+ virtual WTF::PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
virtual void setTitle(const String& title, const KURL&);
virtual String userAgent(const WebCore::KURL&);
@@ -155,63 +178,23 @@ namespace WebCore {
virtual void savePlatformDataToCachedPage(WebCore::CachedPage*);
virtual void transitionToCommittedFromCachedPage(WebCore::CachedPage*);
virtual void transitionToCommittedForNewPage();
-
- virtual void updateGlobalHistoryForStandardLoad(const WebCore::KURL&);
- virtual void updateGlobalHistoryForReload(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);
@@ -222,6 +205,12 @@ namespace WebCore {
ResourceResponse m_response;
bool m_firstData;
FramePolicyFunction m_policyFunction;
+
+ // Plugin view to redirect data to
+ WebCore::PluginView* m_pluginView;
+ bool m_hasSentResponseToPlugin;
+
+ bool m_loadSucceeded;
};
}
diff --git a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
index 4e8f5a5..7335280 100644
--- a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2007 Trolltech ASA
+ * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2008 Holger Hans Peter Freyther
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -45,8 +46,10 @@ namespace WebCore {
class InspectorClientWebPage : public QWebPage
{
+ Q_OBJECT
+ friend class InspectorClientQt;
public:
- QWebPage* createWindow()
+ QWebPage* createWindow(QWebPage::WebWindowType)
{
QWidget *w = new QWebView(0);
QWebPage *page = new QWebPage(w);
@@ -54,6 +57,10 @@ public:
connect(page, SIGNAL(destroyed()), w, SLOT(deleteLater()));
return page;
}
+
+Q_SIGNALS:
+ void attachRequested();
+ void detachRequested();
};
@@ -68,11 +75,6 @@ public:
}
protected:
- void hideEvent(QHideEvent* ev)
- {
- QWidget::hideEvent(ev);
- m_controller->setWindowVisible(false);
- }
void closeEvent(QCloseEvent* ev)
{
@@ -87,7 +89,6 @@ private:
InspectorClientQt::InspectorClientQt(QWebPage* page)
: m_inspectedWebPage(page)
- , m_attached(false)
{}
void InspectorClientQt::inspectorDestroyed()
@@ -101,7 +102,7 @@ Page* InspectorClientQt::createPage()
return m_webPage->d->page;
InspectorClientView* view = new InspectorClientView(m_inspectedWebPage->d->page->inspectorController());
- m_webPage.set(view->page());
+ m_webPage.set(qobject_cast<InspectorClientWebPage*>(view->page()));
m_webPage->mainFrame()->load(QString::fromLatin1("qrc:/webkit/inspector/inspector.html"));
m_webPage->view()->setMinimumSize(400,300);
return m_webPage->d->page;
@@ -141,21 +142,22 @@ bool InspectorClientQt::windowVisible()
void InspectorClientQt::attachWindow()
{
- ASSERT(m_inspectedWebPage);
- ASSERT(m_webPage);
- ASSERT(!m_attached);
+ if (!m_webPage)
+ return;
- m_attached = true;
- notImplemented();
+ emit m_webPage->attachRequested();
}
void InspectorClientQt::detachWindow()
{
- ASSERT(m_inspectedWebPage);
- ASSERT(m_webPage);
- ASSERT(m_attached);
+ if (!m_webPage)
+ return;
+
+ emit m_webPage->detachRequested();
+}
- m_attached = false;
+void InspectorClientQt::setAttachedWindowHeight(unsigned height)
+{
notImplemented();
}
@@ -184,4 +186,21 @@ void InspectorClientQt::updateWindowTitle()
m_webPage->view()->setWindowTitle(caption.arg(m_inspectedURL));
}
+void InspectorClientQt::populateSetting(const String& key, InspectorController::Setting& setting)
+{
+ notImplemented();
+}
+
+void InspectorClientQt::storeSetting(const String& key, const InspectorController::Setting& setting)
+{
+ notImplemented();
+}
+
+void InspectorClientQt::removeSetting(const String& key)
+{
+ notImplemented();
}
+
+}
+
+#include "InspectorClientQt.moc"
diff --git a/WebKit/qt/WebCoreSupport/InspectorClientQt.h b/WebKit/qt/WebCoreSupport/InspectorClientQt.h
index bc0fccd..49c2d56 100644
--- a/WebKit/qt/WebCoreSupport/InspectorClientQt.h
+++ b/WebKit/qt/WebCoreSupport/InspectorClientQt.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2007 Trolltech ASA
+ * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -40,6 +40,7 @@ namespace WebCore {
class Node;
class Page;
class String;
+ class InspectorClientWebPage;
class InspectorClientQt : public InspectorClient {
public:
@@ -58,15 +59,20 @@ namespace WebCore {
virtual void attachWindow();
virtual void detachWindow();
+ virtual void setAttachedWindowHeight(unsigned height);
+
virtual void highlight(Node*);
virtual void hideHighlight();
virtual void inspectedURLChanged(const String& newURL);
+ virtual void populateSetting(const String& key, InspectorController::Setting&);
+ virtual void storeSetting(const String& key, const InspectorController::Setting&);
+ virtual void removeSetting(const String& key);
+
private:
void updateWindowTitle();
QWebPage* m_inspectedWebPage;
- OwnPtr<QWebPage> m_webPage;
- bool m_attached;
+ OwnPtr<InspectorClientWebPage> m_webPage;
QString m_inspectedURL;
};
}
diff --git a/WebKit/qt/WebKitPart/WebKitFactory.cpp b/WebKit/qt/WebKitPart/WebKitFactory.cpp
deleted file mode 100644
index ac43f86..0000000
--- a/WebKit/qt/WebKitPart/WebKitFactory.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * 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
deleted file mode 100644
index ff83437..0000000
--- a/WebKit/qt/WebKitPart/WebKitFactory.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 26c2668..0000000
--- a/WebKit/qt/WebKitPart/WebKitPart.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 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
deleted file mode 100644
index a942139..0000000
--- a/WebKit/qt/WebKitPart/WebKitPart.desktop
+++ /dev/null
@@ -1,12 +0,0 @@
-[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
deleted file mode 100644
index 6472d44..0000000
--- a/WebKit/qt/WebKitPart/WebKitPart.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 886af21..0000000
--- a/WebKit/qt/WebKitPart/WebKitPart.rc
+++ /dev/null
@@ -1,16 +0,0 @@
-<!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
deleted file mode 100644
index 7fcc844..0000000
--- a/WebKit/qt/WebKitPart/WebKitPartBrowser.rc
+++ /dev/null
@@ -1,46 +0,0 @@
-<!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
deleted file mode 100644
index 66bf854..0000000
--- a/WebKit/qt/WebKitPart/WebKitPartBrowserExtension.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 5ef4c0a..0000000
--- a/WebKit/qt/WebKitPart/WebKitPartBrowserExtension.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 2c89e7e..0000000
--- a/WebKit/qt/WebKitPart/WebKitPartClient.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 8874334..0000000
--- a/WebKit/qt/WebKitPart/WebKitPartClient.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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
deleted file mode 100644
index ae49b96..0000000
--- a/WebKit/qt/WebKitPart/WebKitPartInterface.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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
deleted file mode 100644
index a011370..0000000
--- a/WebKit/qt/WebKitPart/WebKitPartInterface.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 84cacd1..0000000
--- a/WebKit/qt/WebKitPart/org.kde.WebKitPart.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<!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
index 61c8d5b..114121d 100644
--- a/WebKit/qt/WebKit_pch.h
+++ b/WebKit/qt/WebKit_pch.h
@@ -32,6 +32,13 @@
#if defined __cplusplus
+
+#if defined (_WIN32)
+#define _CRT_RAND_S
+#define _WIN32_WINNT 0x0500
+#include <windows.h>
+#endif
+
#include "../../JavaScriptCore/kjs/config.h"
#include <math.h>
@@ -71,6 +78,6 @@
#include <wtf/AlwaysInline.h>
#include <wtf/GetPtr.h>
-#include "../../WebCore/bindings/js/kjs_binding.h"
-#include "../../JavaScriptCore/kjs/math_object.h"
+#include "../../WebCore/bindings/js/JSDOMBinding.h"
+#include "../../JavaScriptCore/kjs/MathObject.h"
#endif
diff --git a/WebKit/qt/tests/qwebframe/qwebframe.pro b/WebKit/qt/tests/qwebframe/qwebframe.pro
new file mode 100644
index 0000000..9715fd6
--- /dev/null
+++ b/WebKit/qt/tests/qwebframe/qwebframe.pro
@@ -0,0 +1,6 @@
+TEMPLATE = app
+TARGET = tst_qwebframe
+include(../../../../WebKit.pri)
+SOURCES += tst_qwebframe.cpp
+QT += testlib network
+QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
diff --git a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
new file mode 100644
index 0000000..3e4657c
--- /dev/null
+++ b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
@@ -0,0 +1,2072 @@
+/*
+ Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+
+ 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 <QtTest/QtTest>
+
+#include <qwebpage.h>
+#include <qwidget.h>
+#include <qwebview.h>
+#include <qwebframe.h>
+#include <qwebhistory.h>
+#include <QRegExp>
+#include <QNetworkRequest>
+//TESTED_CLASS=
+//TESTED_FILES=
+
+// Task 160192
+/**
+ * Starts an event loop that runs until the given signal is received.
+ Optionally the event loop
+ * can return earlier on a timeout.
+ *
+ * \return \p true if the requested signal was received
+ * \p false on timeout
+ */
+static bool waitForSignal(QObject* obj, const char* signal, int timeout = 0)
+{
+ QEventLoop loop;
+ QObject::connect(obj, signal, &loop, SLOT(quit()));
+ QTimer timer;
+ QSignalSpy timeoutSpy(&timer, SIGNAL(timeout()));
+ if (timeout > 0) {
+ QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+ timer.setSingleShot(true);
+ timer.start(timeout);
+ }
+ loop.exec();
+ return timeoutSpy.isEmpty();
+}
+
+/* Mostly a test for the JavaScript related parts of QWebFrame */
+
+
+struct CustomType {
+ QString string;
+};
+Q_DECLARE_METATYPE(CustomType)
+
+Q_DECLARE_METATYPE(QBrush*)
+Q_DECLARE_METATYPE(QObjectList)
+Q_DECLARE_METATYPE(QList<int>)
+Q_DECLARE_METATYPE(Qt::BrushStyle)
+Q_DECLARE_METATYPE(QVariantList)
+Q_DECLARE_METATYPE(QVariantMap)
+
+class MyQObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty)
+ Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty)
+ Q_PROPERTY(QVariantList variantListProperty READ variantListProperty WRITE setVariantListProperty)
+ Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty)
+ Q_PROPERTY(QStringList stringListProperty READ stringListProperty WRITE setStringListProperty)
+ Q_PROPERTY(QByteArray byteArrayProperty READ byteArrayProperty WRITE setByteArrayProperty)
+ Q_PROPERTY(QBrush brushProperty READ brushProperty WRITE setBrushProperty)
+ Q_PROPERTY(double hiddenProperty READ hiddenProperty WRITE setHiddenProperty SCRIPTABLE false)
+ Q_PROPERTY(int writeOnlyProperty WRITE setWriteOnlyProperty)
+ Q_PROPERTY(int readOnlyProperty READ readOnlyProperty)
+ Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut)
+ Q_PROPERTY(CustomType propWithCustomType READ propWithCustomType WRITE setPropWithCustomType)
+ Q_ENUMS(Policy Strategy)
+ Q_FLAGS(Ability)
+
+public:
+ enum Policy {
+ FooPolicy = 0,
+ BarPolicy,
+ BazPolicy
+ };
+
+ enum Strategy {
+ FooStrategy = 10,
+ BarStrategy,
+ BazStrategy
+ };
+
+ enum AbilityFlag {
+ NoAbility = 0x000,
+ FooAbility = 0x001,
+ BarAbility = 0x080,
+ BazAbility = 0x200,
+ AllAbility = FooAbility | BarAbility | BazAbility
+ };
+
+ Q_DECLARE_FLAGS(Ability, AbilityFlag)
+
+ MyQObject(QObject* parent = 0)
+ : QObject(parent),
+ m_intValue(123),
+ m_variantValue(QLatin1String("foo")),
+ m_variantListValue(QVariantList() << QVariant(123) << QVariant(QLatin1String("foo"))),
+ m_stringValue(QLatin1String("bar")),
+ m_stringListValue(QStringList() << QLatin1String("zig") << QLatin1String("zag")),
+ m_brushValue(QColor(10, 20, 30, 40)),
+ m_hiddenValue(456.0),
+ m_writeOnlyValue(789),
+ m_readOnlyValue(987),
+ m_qtFunctionInvoked(-1) { }
+
+ ~MyQObject() { }
+
+ int intProperty() const {
+ return m_intValue;
+ }
+ void setIntProperty(int value) {
+ m_intValue = value;
+ }
+
+ QVariant variantProperty() const {
+ return m_variantValue;
+ }
+ void setVariantProperty(const QVariant &value) {
+ m_variantValue = value;
+ }
+
+ QVariantList variantListProperty() const {
+ return m_variantListValue;
+ }
+ void setVariantListProperty(const QVariantList &value) {
+ m_variantListValue = value;
+ }
+
+ QString stringProperty() const {
+ return m_stringValue;
+ }
+ void setStringProperty(const QString &value) {
+ m_stringValue = value;
+ }
+
+ QStringList stringListProperty() const {
+ return m_stringListValue;
+ }
+ void setStringListProperty(const QStringList &value) {
+ m_stringListValue = value;
+ }
+
+ QByteArray byteArrayProperty() const {
+ return m_byteArrayValue;
+ }
+ void setByteArrayProperty(const QByteArray &value) {
+ m_byteArrayValue = value;
+ }
+
+ QBrush brushProperty() const {
+ return m_brushValue;
+ }
+ Q_INVOKABLE void setBrushProperty(const QBrush &value) {
+ m_brushValue = value;
+ }
+
+ double hiddenProperty() const {
+ return m_hiddenValue;
+ }
+ void setHiddenProperty(double value) {
+ m_hiddenValue = value;
+ }
+
+ int writeOnlyProperty() const {
+ return m_writeOnlyValue;
+ }
+ void setWriteOnlyProperty(int value) {
+ m_writeOnlyValue = value;
+ }
+
+ int readOnlyProperty() const {
+ return m_readOnlyValue;
+ }
+
+ QKeySequence shortcut() const {
+ return m_shortcut;
+ }
+ void setShortcut(const QKeySequence &seq) {
+ m_shortcut = seq;
+ }
+
+ CustomType propWithCustomType() const {
+ return m_customType;
+ }
+ void setPropWithCustomType(const CustomType &c) {
+ m_customType = c;
+ }
+
+ int qtFunctionInvoked() const {
+ return m_qtFunctionInvoked;
+ }
+
+ QVariantList qtFunctionActuals() const {
+ return m_actuals;
+ }
+
+ void resetQtFunctionInvoked() {
+ m_qtFunctionInvoked = -1;
+ m_actuals.clear();
+ }
+
+ Q_INVOKABLE void myInvokable() {
+ m_qtFunctionInvoked = 0;
+ }
+ Q_INVOKABLE void myInvokableWithIntArg(int arg) {
+ m_qtFunctionInvoked = 1;
+ m_actuals << arg;
+ }
+ Q_INVOKABLE void myInvokableWithLonglongArg(qlonglong arg) {
+ m_qtFunctionInvoked = 2;
+ m_actuals << arg;
+ }
+ Q_INVOKABLE void myInvokableWithFloatArg(float arg) {
+ m_qtFunctionInvoked = 3;
+ m_actuals << arg;
+ }
+ Q_INVOKABLE void myInvokableWithDoubleArg(double arg) {
+ m_qtFunctionInvoked = 4;
+ m_actuals << arg;
+ }
+ Q_INVOKABLE void myInvokableWithStringArg(const QString &arg) {
+ m_qtFunctionInvoked = 5;
+ m_actuals << arg;
+ }
+ Q_INVOKABLE void myInvokableWithIntArgs(int arg1, int arg2) {
+ m_qtFunctionInvoked = 6;
+ m_actuals << arg1 << arg2;
+ }
+ Q_INVOKABLE int myInvokableReturningInt() {
+ m_qtFunctionInvoked = 7;
+ return 123;
+ }
+ Q_INVOKABLE qlonglong myInvokableReturningLongLong() {
+ m_qtFunctionInvoked = 39;
+ return 456;
+ }
+ Q_INVOKABLE QString myInvokableReturningString() {
+ m_qtFunctionInvoked = 8;
+ return QLatin1String("ciao");
+ }
+ Q_INVOKABLE void myInvokableWithIntArg(int arg1, int arg2) { // overload
+ m_qtFunctionInvoked = 9;
+ m_actuals << arg1 << arg2;
+ }
+ Q_INVOKABLE void myInvokableWithEnumArg(Policy policy) {
+ m_qtFunctionInvoked = 10;
+ m_actuals << policy;
+ }
+ Q_INVOKABLE void myInvokableWithQualifiedEnumArg(MyQObject::Policy policy) {
+ m_qtFunctionInvoked = 36;
+ m_actuals << policy;
+ }
+ Q_INVOKABLE Policy myInvokableReturningEnum() {
+ m_qtFunctionInvoked = 37;
+ return BazPolicy;
+ }
+ Q_INVOKABLE MyQObject::Policy myInvokableReturningQualifiedEnum() {
+ m_qtFunctionInvoked = 38;
+ return BazPolicy;
+ }
+ Q_INVOKABLE QVector<int> myInvokableReturningVectorOfInt() {
+ m_qtFunctionInvoked = 11;
+ return QVector<int>();
+ }
+ Q_INVOKABLE void myInvokableWithVectorOfIntArg(const QVector<int> &) {
+ m_qtFunctionInvoked = 12;
+ }
+ Q_INVOKABLE QObject* myInvokableReturningQObjectStar() {
+ m_qtFunctionInvoked = 13;
+ return this;
+ }
+ Q_INVOKABLE QObjectList myInvokableWithQObjectListArg(const QObjectList &lst) {
+ m_qtFunctionInvoked = 14;
+ m_actuals << qVariantFromValue(lst);
+ return lst;
+ }
+ Q_INVOKABLE QVariant myInvokableWithVariantArg(const QVariant &v) {
+ m_qtFunctionInvoked = 15;
+ m_actuals << v;
+ return v;
+ }
+ Q_INVOKABLE QVariantMap myInvokableWithVariantMapArg(const QVariantMap &vm) {
+ m_qtFunctionInvoked = 16;
+ m_actuals << vm;
+ return vm;
+ }
+ Q_INVOKABLE QList<int> myInvokableWithListOfIntArg(const QList<int> &lst) {
+ m_qtFunctionInvoked = 17;
+ m_actuals << qVariantFromValue(lst);
+ return lst;
+ }
+ Q_INVOKABLE QObject* myInvokableWithQObjectStarArg(QObject* obj) {
+ m_qtFunctionInvoked = 18;
+ m_actuals << qVariantFromValue(obj);
+ return obj;
+ }
+ Q_INVOKABLE QBrush myInvokableWithQBrushArg(const QBrush &brush) {
+ m_qtFunctionInvoked = 19;
+ m_actuals << qVariantFromValue(brush);
+ return brush;
+ }
+ Q_INVOKABLE void myInvokableWithBrushStyleArg(Qt::BrushStyle style) {
+ m_qtFunctionInvoked = 43;
+ m_actuals << qVariantFromValue(style);
+ }
+ Q_INVOKABLE void myInvokableWithVoidStarArg(void* arg) {
+ m_qtFunctionInvoked = 44;
+ m_actuals << qVariantFromValue(arg);
+ }
+ Q_INVOKABLE void myInvokableWithAmbiguousArg(int arg) {
+ m_qtFunctionInvoked = 45;
+ m_actuals << qVariantFromValue(arg);
+ }
+ Q_INVOKABLE void myInvokableWithAmbiguousArg(uint arg) {
+ m_qtFunctionInvoked = 46;
+ m_actuals << qVariantFromValue(arg);
+ }
+ Q_INVOKABLE void myInvokableWithDefaultArgs(int arg1, const QString &arg2 = "") {
+ m_qtFunctionInvoked = 47;
+ m_actuals << qVariantFromValue(arg1) << qVariantFromValue(arg2);
+ }
+ Q_INVOKABLE QObject& myInvokableReturningRef() {
+ m_qtFunctionInvoked = 48;
+ return *this;
+ }
+ Q_INVOKABLE const QObject& myInvokableReturningConstRef() const {
+ const_cast<MyQObject*>(this)->m_qtFunctionInvoked = 49;
+ return *this;
+ }
+ Q_INVOKABLE void myInvokableWithPointArg(const QPoint &arg) {
+ const_cast<MyQObject*>(this)->m_qtFunctionInvoked = 50;
+ m_actuals << qVariantFromValue(arg);
+ }
+ Q_INVOKABLE void myInvokableWithPointArg(const QPointF &arg) {
+ const_cast<MyQObject*>(this)->m_qtFunctionInvoked = 51;
+ m_actuals << qVariantFromValue(arg);
+ }
+
+ void emitMySignal() {
+ emit mySignal();
+ }
+ void emitMySignalWithIntArg(int arg) {
+ emit mySignalWithIntArg(arg);
+ }
+ void emitMySignal2(bool arg) {
+ emit mySignal2(arg);
+ }
+ void emitMySignal2() {
+ emit mySignal2();
+ }
+ void emitMySignalWithDateTimeArg(QDateTime dt) {
+ emit mySignalWithDateTimeArg(dt);
+ }
+ void emitMySignalWithRegexArg(QRegExp r) {
+ emit mySignalWithRegexArg(r);
+ }
+
+public Q_SLOTS:
+ void mySlot() {
+ m_qtFunctionInvoked = 20;
+ }
+ void mySlotWithIntArg(int arg) {
+ m_qtFunctionInvoked = 21;
+ m_actuals << arg;
+ }
+ void mySlotWithDoubleArg(double arg) {
+ m_qtFunctionInvoked = 22;
+ m_actuals << arg;
+ }
+ void mySlotWithStringArg(const QString &arg) {
+ m_qtFunctionInvoked = 23;
+ m_actuals << arg;
+ }
+
+ void myOverloadedSlot() {
+ m_qtFunctionInvoked = 24;
+ }
+ void myOverloadedSlot(QObject* arg) {
+ m_qtFunctionInvoked = 41;
+ m_actuals << arg;
+ }
+ void myOverloadedSlot(bool arg) {
+ m_qtFunctionInvoked = 25;
+ m_actuals << arg;
+ }
+ void myOverloadedSlot(const QStringList &arg) {
+ m_qtFunctionInvoked = 42;
+ m_actuals << arg;
+ }
+ void myOverloadedSlot(double arg) {
+ m_qtFunctionInvoked = 26;
+ m_actuals << arg;
+ }
+ void myOverloadedSlot(float arg) {
+ m_qtFunctionInvoked = 27;
+ m_actuals << arg;
+ }
+ void myOverloadedSlot(int arg) {
+ m_qtFunctionInvoked = 28;
+ m_actuals << arg;
+ }
+ void myOverloadedSlot(const QString &arg) {
+ m_qtFunctionInvoked = 29;
+ m_actuals << arg;
+ }
+ void myOverloadedSlot(const QColor &arg) {
+ m_qtFunctionInvoked = 30;
+ m_actuals << arg;
+ }
+ void myOverloadedSlot(const QBrush &arg) {
+ m_qtFunctionInvoked = 31;
+ m_actuals << arg;
+ }
+ void myOverloadedSlot(const QDateTime &arg) {
+ m_qtFunctionInvoked = 32;
+ m_actuals << arg;
+ }
+ void myOverloadedSlot(const QDate &arg) {
+ m_qtFunctionInvoked = 33;
+ m_actuals << arg;
+ }
+ void myOverloadedSlot(const QRegExp &arg) {
+ m_qtFunctionInvoked = 34;
+ m_actuals << arg;
+ }
+ void myOverloadedSlot(const QVariant &arg) {
+ m_qtFunctionInvoked = 35;
+ m_actuals << arg;
+ }
+
+ void qscript_call(int arg) {
+ m_qtFunctionInvoked = 40;
+ m_actuals << arg;
+ }
+
+protected Q_SLOTS:
+ void myProtectedSlot() {
+ m_qtFunctionInvoked = 36;
+ }
+
+private Q_SLOTS:
+ void myPrivateSlot() { }
+
+Q_SIGNALS:
+ void mySignal();
+ void mySignalWithIntArg(int arg);
+ void mySignalWithDoubleArg(double arg);
+ void mySignal2(bool arg = false);
+ void mySignalWithDateTimeArg(QDateTime dt);
+ void mySignalWithRegexArg(QRegExp r);
+
+private:
+ int m_intValue;
+ QVariant m_variantValue;
+ QVariantList m_variantListValue;
+ QString m_stringValue;
+ QStringList m_stringListValue;
+ QByteArray m_byteArrayValue;
+ QBrush m_brushValue;
+ double m_hiddenValue;
+ int m_writeOnlyValue;
+ int m_readOnlyValue;
+ QKeySequence m_shortcut;
+ CustomType m_customType;
+ int m_qtFunctionInvoked;
+ QVariantList m_actuals;
+};
+
+class MyOtherQObject : public MyQObject
+{
+public:
+ MyOtherQObject(QObject* parent = 0)
+ : MyQObject(parent) { }
+};
+
+class MyEnumTestQObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString p1 READ p1)
+ Q_PROPERTY(QString p2 READ p2)
+ Q_PROPERTY(QString p3 READ p3 SCRIPTABLE false)
+ Q_PROPERTY(QString p4 READ p4)
+ Q_PROPERTY(QString p5 READ p5 SCRIPTABLE false)
+ Q_PROPERTY(QString p6 READ p6)
+public:
+ MyEnumTestQObject(QObject* parent = 0)
+ : QObject(parent) { }
+ QString p1() const {
+ return QLatin1String("p1");
+ }
+ QString p2() const {
+ return QLatin1String("p2");
+ }
+ QString p3() const {
+ return QLatin1String("p3");
+ }
+ QString p4() const {
+ return QLatin1String("p4");
+ }
+ QString p5() const {
+ return QLatin1String("p5");
+ }
+ QString p6() const {
+ return QLatin1String("p5");
+ }
+public Q_SLOTS:
+ void mySlot() { }
+ void myOtherSlot() { }
+Q_SIGNALS:
+ void mySignal();
+};
+
+class tst_QWebFrame : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QWebFrame();
+ virtual ~tst_QWebFrame();
+
+public slots:
+ void init();
+ void cleanup();
+
+private slots:
+ void getSetStaticProperty();
+ void getSetDynamicProperty();
+ void getSetChildren();
+ void callQtInvokable();
+ void connectAndDisconnect();
+ void classEnums();
+ void classConstructor();
+ void overrideInvokable();
+ void transferInvokable();
+ void findChild();
+ void findChildren();
+ void overloadedSlots();
+ void enumerate_data();
+ void enumerate();
+ void objectDeleted();
+ void typeConversion();
+ void symmetricUrl();
+ void progressSignal();
+ void domCycles();
+ void setHtml();
+ void ipv6HostEncoding();
+private:
+ QString evalJS(const QString&s) {
+ // Convert an undefined return variant to the string "undefined"
+ QVariant ret = evalJSV(s);
+ if (ret.userType() == QMetaType::Void)
+ return "undefined";
+ else
+ return ret.toString();
+ }
+ QVariant evalJSV(const QString &s) {
+ return m_page->mainFrame()->evaluateJavaScript(s);
+ }
+
+ QString evalJS(const QString&s, QString& type) {
+ return evalJSV(s, type).toString();
+ }
+ QVariant evalJSV(const QString &s, QString& type) {
+ // As a special measure, if we get an exception we set the type to 'error'
+ // (in ecma, an Error object has typeof object, but qtscript has a convenience function)
+ // Similarly, an array is an object, but we'd prefer to have a type of 'array'
+ // Also, consider a QMetaType::Void QVariant to be undefined
+ QString escaped = s;
+ escaped.replace('\'', "\\'"); // Don't preescape your single quotes!
+ evalJS("var retvalue;\
+ var typevalue; \
+ try {\
+ retvalue = eval('" + escaped + "'); \
+ typevalue = typeof retvalue; \
+ if (retvalue instanceof Array) \
+ typevalue = 'array'; \
+ } \
+ catch(e) {\
+ retvalue = e.name + ': ' + e.message;\
+ typevalue = 'error';\
+ }");
+ QVariant ret = evalJSV("retvalue");
+ if (ret.userType() != QMetaType::Void)
+ type = evalJS("typevalue");
+ else {
+ ret = QString("undefined");
+ type = sUndefined;
+ }
+ evalJS("delete retvalue; delete typevalue");
+ return ret;
+ }
+
+ const QString sTrue;
+ const QString sFalse;
+ const QString sUndefined;
+ const QString sArray;
+ const QString sFunction;
+ const QString sError;
+ const QString sString;
+ const QString sObject;
+ const QString sNumber;
+
+private:
+ QWebView* m_view;
+ QWebPage* m_page;
+ MyQObject* m_myObject;
+};
+
+tst_QWebFrame::tst_QWebFrame()
+ : sTrue("true"), sFalse("false"), sUndefined("undefined"), sArray("array"), sFunction("function"), sError("error"),
+ sString("string"), sObject("object"), sNumber("number")
+{
+}
+
+tst_QWebFrame::~tst_QWebFrame()
+{
+}
+
+void tst_QWebFrame::init()
+{
+ m_view = new QWebView();
+ m_page = m_view->page();
+ m_myObject = new MyQObject();
+ m_page->mainFrame()->addToJavaScriptWindowObject("myObject", m_myObject);
+}
+
+void tst_QWebFrame::cleanup()
+{
+ delete m_view;
+ delete m_myObject;
+}
+
+void tst_QWebFrame::getSetStaticProperty()
+{
+ QCOMPARE(evalJS("typeof myObject.noSuchProperty"), sUndefined);
+
+ // initial value (set in MyQObject constructor)
+ {
+ QString type;
+ QVariant ret = evalJSV("myObject.intProperty", type);
+ QCOMPARE(type, sNumber);
+ QCOMPARE(ret.type(), QVariant::Double);
+ QCOMPARE(ret.toInt(), 123);
+ }
+ QCOMPARE(evalJS("myObject.intProperty === 123.0"), sTrue);
+
+ {
+ QString type;
+ QVariant ret = evalJSV("myObject.variantProperty", type);
+ QCOMPARE(type, sString);
+ QCOMPARE(ret.type(), QVariant::String);
+ QCOMPARE(ret.toString(), QLatin1String("foo"));
+ }
+ QCOMPARE(evalJS("myObject.variantProperty == 'foo'"), sTrue);
+
+ {
+ QString type;
+ QVariant ret = evalJSV("myObject.stringProperty", type);
+ QCOMPARE(type, sString);
+ QCOMPARE(ret.type(), QVariant::String);
+ QCOMPARE(ret.toString(), QLatin1String("bar"));
+ }
+ QCOMPARE(evalJS("myObject.stringProperty === 'bar'"), sTrue);
+
+ {
+ QString type;
+ QVariant ret = evalJSV("myObject.variantListProperty", type);
+ QCOMPARE(type, sArray);
+ QCOMPARE(ret.type(), QVariant::List);
+ QVariantList vl = ret.value<QVariantList>();
+ QCOMPARE(vl.size(), 2);
+ QCOMPARE(vl.at(0).toInt(), 123);
+ QCOMPARE(vl.at(1).toString(), QLatin1String("foo"));
+ }
+ QCOMPARE(evalJS("myObject.variantListProperty.length === 2"), sTrue);
+ QCOMPARE(evalJS("myObject.variantListProperty[0] === 123"), sTrue);
+ QCOMPARE(evalJS("myObject.variantListProperty[1] === 'foo'"), sTrue);
+
+ {
+ QString type;
+ QVariant ret = evalJSV("myObject.stringListProperty", type);
+ QCOMPARE(type, sArray);
+ QCOMPARE(ret.type(), QVariant::List);
+ QVariantList vl = ret.value<QVariantList>();
+ QCOMPARE(vl.size(), 2);
+ QCOMPARE(vl.at(0).toString(), QLatin1String("zig"));
+ QCOMPARE(vl.at(1).toString(), QLatin1String("zag"));
+ }
+ QCOMPARE(evalJS("myObject.stringListProperty.length === 2"), sTrue);
+ QCOMPARE(evalJS("typeof myObject.stringListProperty[0]"), sString);
+ QCOMPARE(evalJS("myObject.stringListProperty[0]"), QLatin1String("zig"));
+ QCOMPARE(evalJS("typeof myObject.stringListProperty[1]"), sString);
+ QCOMPARE(evalJS("myObject.stringListProperty[1]"), QLatin1String("zag"));
+
+ // property change in C++ should be reflected in script
+ m_myObject->setIntProperty(456);
+ QCOMPARE(evalJS("myObject.intProperty == 456"), sTrue);
+ m_myObject->setIntProperty(789);
+ QCOMPARE(evalJS("myObject.intProperty == 789"), sTrue);
+
+ m_myObject->setVariantProperty(QLatin1String("bar"));
+ QCOMPARE(evalJS("myObject.variantProperty === 'bar'"), sTrue);
+ m_myObject->setVariantProperty(42);
+ QCOMPARE(evalJS("myObject.variantProperty === 42"), sTrue);
+ m_myObject->setVariantProperty(qVariantFromValue(QBrush()));
+//XFAIL
+// QCOMPARE(evalJS("typeof myObject.variantProperty"), sVariant);
+
+ m_myObject->setStringProperty(QLatin1String("baz"));
+ QCOMPARE(evalJS("myObject.stringProperty === 'baz'"), sTrue);
+ m_myObject->setStringProperty(QLatin1String("zab"));
+ QCOMPARE(evalJS("myObject.stringProperty === 'zab'"), sTrue);
+
+ // property change in script should be reflected in C++
+ QCOMPARE(evalJS("myObject.intProperty = 123"), QLatin1String("123"));
+ QCOMPARE(evalJS("myObject.intProperty == 123"), sTrue);
+ QCOMPARE(m_myObject->intProperty(), 123);
+ QCOMPARE(evalJS("myObject.intProperty = 'ciao!';"
+ "myObject.intProperty == 0"), sTrue);
+ QCOMPARE(m_myObject->intProperty(), 0);
+ QCOMPARE(evalJS("myObject.intProperty = '123';"
+ "myObject.intProperty == 123"), sTrue);
+ QCOMPARE(m_myObject->intProperty(), 123);
+
+ QCOMPARE(evalJS("myObject.stringProperty = 'ciao'"), QLatin1String("ciao"));
+ QCOMPARE(evalJS("myObject.stringProperty"), QLatin1String("ciao"));
+ QCOMPARE(m_myObject->stringProperty(), QLatin1String("ciao"));
+ QCOMPARE(evalJS("myObject.stringProperty = 123;"
+ "myObject.stringProperty"), QLatin1String("123"));
+ QCOMPARE(m_myObject->stringProperty(), QLatin1String("123"));
+
+ QCOMPARE(evalJS("myObject.variantProperty = 'foo';"
+ "myObject.variantProperty.valueOf()"), QLatin1String("foo"));
+ QCOMPARE(m_myObject->variantProperty(), QVariant(QLatin1String("foo")));
+ QCOMPARE(evalJS("myObject.variantProperty = 42;"
+ "myObject.variantProperty").toDouble(), 42.0);
+ QCOMPARE(m_myObject->variantProperty().toDouble(), 42.0);
+
+
+ QCOMPARE(evalJS("myObject.variantListProperty = [1, 'two', true];"
+ "myObject.variantListProperty.length == 3"), sTrue);
+ QCOMPARE(evalJS("myObject.variantListProperty[0] === 1"), sTrue);
+ QCOMPARE(evalJS("myObject.variantListProperty[1]"), QLatin1String("two"));
+ QCOMPARE(evalJS("myObject.variantListProperty[2] === true"), sTrue);
+
+ QCOMPARE(evalJS("myObject.stringListProperty = [1, 'two', true];"
+ "myObject.stringListProperty.length == 3"), sTrue);
+ QCOMPARE(evalJS("typeof myObject.stringListProperty[0]"), sString);
+ QCOMPARE(evalJS("myObject.stringListProperty[0] == '1'"), sTrue);
+ QCOMPARE(evalJS("typeof myObject.stringListProperty[1]"), sString);
+ QCOMPARE(evalJS("myObject.stringListProperty[1]"), QLatin1String("two"));
+ QCOMPARE(evalJS("typeof myObject.stringListProperty[2]"), sString);
+ QCOMPARE(evalJS("myObject.stringListProperty[2]"), QLatin1String("true"));
+
+ // try to delete
+ QCOMPARE(evalJS("delete myObject.intProperty"), sFalse);
+ QCOMPARE(evalJS("myObject.intProperty == 123"), sTrue);
+
+ QCOMPARE(evalJS("delete myObject.variantProperty"), sFalse);
+ QCOMPARE(evalJS("myObject.variantProperty").toDouble(), 42.0);
+
+ // custom property
+ QCOMPARE(evalJS("myObject.customProperty"), sUndefined);
+ QCOMPARE(evalJS("myObject.customProperty = 123;"
+ "myObject.customProperty == 123"), sTrue);
+ QVariant v = m_page->mainFrame()->evaluateJavaScript("myObject.customProperty");
+ QCOMPARE(v.type(), QVariant::Double);
+ QCOMPARE(v.toInt(), 123);
+
+ // non-scriptable property
+ QCOMPARE(m_myObject->hiddenProperty(), 456.0);
+ QCOMPARE(evalJS("myObject.hiddenProperty"), sUndefined);
+ QCOMPARE(evalJS("myObject.hiddenProperty = 123;"
+ "myObject.hiddenProperty == 123"), sTrue);
+ QCOMPARE(m_myObject->hiddenProperty(), 456.0);
+
+ // write-only property
+ QCOMPARE(m_myObject->writeOnlyProperty(), 789);
+ QCOMPARE(evalJS("typeof myObject.writeOnlyProperty"), sUndefined);
+ QCOMPARE(evalJS("myObject.writeOnlyProperty = 123;"
+ "typeof myObject.writeOnlyProperty"), sUndefined);
+ QCOMPARE(m_myObject->writeOnlyProperty(), 123);
+
+ // read-only property
+ QCOMPARE(m_myObject->readOnlyProperty(), 987);
+ QCOMPARE(evalJS("myObject.readOnlyProperty == 987"), sTrue);
+ QCOMPARE(evalJS("myObject.readOnlyProperty = 654;"
+ "myObject.readOnlyProperty == 987"), sTrue);
+ QCOMPARE(m_myObject->readOnlyProperty(), 987);
+}
+
+void tst_QWebFrame::getSetDynamicProperty()
+{
+ // initially the object does not have the property
+ // In WebKit, RuntimeObjects do not inherit Object, so don't have hasOwnProperty
+
+ //QCOMPARE(evalJS("myObject.hasOwnProperty('dynamicProperty')"), sFalse);
+ QCOMPARE(evalJS("typeof myObject.dynamicProperty"), sUndefined);
+
+ // add a dynamic property in C++
+ QCOMPARE(m_myObject->setProperty("dynamicProperty", 123), false);
+ //QCOMPARE(evalJS("myObject.hasOwnProperty('dynamicProperty')"), sTrue);
+ QCOMPARE(evalJS("typeof myObject.dynamicProperty != 'undefined'"), sTrue);
+ QCOMPARE(evalJS("myObject.dynamicProperty == 123"), sTrue);
+
+ // property change in script should be reflected in C++
+ QCOMPARE(evalJS("myObject.dynamicProperty = 'foo';"
+ "myObject.dynamicProperty"), QLatin1String("foo"));
+ QCOMPARE(m_myObject->property("dynamicProperty").toString(), QLatin1String("foo"));
+
+ // delete the property (XFAIL - can't delete properties)
+ QEXPECT_FAIL("", "can't delete properties", Continue);
+ QCOMPARE(evalJS("delete myObject.dynamicProperty"), sTrue);
+ /*
+ QCOMPARE(m_myObject->property("dynamicProperty").isValid(), false);
+ QCOMPARE(evalJS("typeof myObject.dynamicProperty"), sUndefined);
+ // QCOMPARE(evalJS("myObject.hasOwnProperty('dynamicProperty')"), sFalse);
+ QCOMPARE(evalJS("typeof myObject.dynamicProperty"), sUndefined);
+ */
+}
+
+void tst_QWebFrame::getSetChildren()
+{
+ // initially the object does not have the child
+ // (again, no hasOwnProperty)
+
+ //QCOMPARE(evalJS("myObject.hasOwnProperty('child')"), sFalse);
+ QCOMPARE(evalJS("typeof myObject.child"), sUndefined);
+
+ // add a child
+ MyQObject* child = new MyQObject(m_myObject);
+ child->setObjectName("child");
+// QCOMPARE(evalJS("myObject.hasOwnProperty('child')"), sTrue);
+ QCOMPARE(evalJS("typeof myObject.child != 'undefined'"), sTrue);
+
+ // add a grandchild
+ MyQObject* grandChild = new MyQObject(child);
+ grandChild->setObjectName("grandChild");
+// QCOMPARE(evalJS("myObject.child.hasOwnProperty('grandChild')"), sTrue);
+ QCOMPARE(evalJS("typeof myObject.child.grandChild != 'undefined'"), sTrue);
+
+ // delete grandchild
+ delete grandChild;
+// QCOMPARE(evalJS("myObject.child.hasOwnProperty('grandChild')"), sFalse);
+ QCOMPARE(evalJS("typeof myObject.child.grandChild == 'undefined'"), sTrue);
+
+ // delete child
+ delete child;
+// QCOMPARE(evalJS("myObject.hasOwnProperty('child')"), sFalse);
+ QCOMPARE(evalJS("typeof myObject.child == 'undefined'"), sTrue);
+}
+
+Q_DECLARE_METATYPE(QVector<int>)
+Q_DECLARE_METATYPE(QVector<double>)
+Q_DECLARE_METATYPE(QVector<QString>)
+
+void tst_QWebFrame::callQtInvokable()
+{
+ qRegisterMetaType<QObjectList>();
+
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("typeof myObject.myInvokable()"), sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 0);
+ QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList());
+
+ // extra arguments should silently be ignored
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("typeof myObject.myInvokable(10, 20, 30)"), sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 0);
+ QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList());
+
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("typeof myObject.myInvokableWithIntArg(123)"), sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 1);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123);
+
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("typeof myObject.myInvokableWithIntArg('123')"), sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 1);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123);
+
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("typeof myObject.myInvokableWithLonglongArg(123)"), sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 2);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0).toLongLong(), qlonglong(123));
+
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("typeof myObject.myInvokableWithFloatArg(123.5)"), sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 3);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDouble(), 123.5);
+
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("typeof myObject.myInvokableWithDoubleArg(123.5)"), sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 4);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDouble(), 123.5);
+
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("typeof myObject.myInvokableWithStringArg('ciao')"), sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 5);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QLatin1String("ciao"));
+
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("typeof myObject.myInvokableWithStringArg(123)"), sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 5);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QLatin1String("123"));
+
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("typeof myObject.myInvokableWithIntArgs(123, 456)"), sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 6);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 2);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(1).toInt(), 456);
+
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("myObject.myInvokableReturningInt()"), QLatin1String("123"));
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 7);
+ QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList());
+
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("myObject.myInvokableReturningLongLong()"), QLatin1String("456"));
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 39);
+ QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList());
+
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("myObject.myInvokableReturningString()"), QLatin1String("ciao"));
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 8);
+ QCOMPARE(m_myObject->qtFunctionActuals(), QVariantList());
+
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("typeof myObject.myInvokableWithIntArg(123, 456)"), sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 9);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 2);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(1).toInt(), 456);
+
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("typeof myObject.myInvokableWithVoidStarArg(null)"), sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 44);
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QString type;
+ QString ret = evalJS("myObject.myInvokableWithVoidStarArg(123)", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("TypeError: incompatible type of argument(s) in call to myInvokableWithVoidStarArg(); candidates were\n myInvokableWithVoidStarArg(void*)"));
+ QCOMPARE(m_myObject->qtFunctionInvoked(), -1);
+ }
+
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QString type;
+ QString ret = evalJS("myObject.myInvokableWithAmbiguousArg(123)", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("TypeError: ambiguous call of overloaded function myInvokableWithAmbiguousArg(); candidates were\n myInvokableWithAmbiguousArg(int)\n myInvokableWithAmbiguousArg(uint)"));
+ }
+
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QString type;
+ QString ret = evalJS("myObject.myInvokableWithDefaultArgs(123, 'hello')", type);
+ QCOMPARE(type, sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 47);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 2);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(1).toString(), QLatin1String("hello"));
+ }
+
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QString type;
+ QString ret = evalJS("myObject.myInvokableWithDefaultArgs(456)", type);
+ QCOMPARE(type, sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 47);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 2);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 456);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(1).toString(), QString());
+ }
+
+ // calling function that returns (const)ref
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QString type;
+ QString ret = evalJS("typeof myObject.myInvokableReturningRef()");
+ QCOMPARE(ret, sUndefined);
+ //QVERIFY(!m_engine->hasUncaughtException());
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 48);
+ }
+
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QString type;
+ QString ret = evalJS("typeof myObject.myInvokableReturningConstRef()");
+ QCOMPARE(ret, sUndefined);
+ //QVERIFY(!m_engine->hasUncaughtException());
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 49);
+ }
+
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QString type;
+ QVariant ret = evalJSV("myObject.myInvokableReturningQObjectStar()", type);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 13);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 0);
+ QCOMPARE(type, sObject);
+ QCOMPARE(ret.userType(), int(QMetaType::QObjectStar));
+ }
+
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QString type;
+ QVariant ret = evalJSV("myObject.myInvokableWithQObjectListArg([myObject])", type);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 14);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QCOMPARE(type, sArray);
+ QCOMPARE(ret.userType(), int(QVariant::List)); // All lists get downgraded to QVariantList
+ QVariantList vl = qvariant_cast<QVariantList>(ret);
+ QCOMPARE(vl.count(), 1);
+ }
+
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QString type;
+ m_myObject->setVariantProperty(QVariant(123));
+ QVariant ret = evalJSV("myObject.myInvokableWithVariantArg(myObject.variantProperty)", type);
+ QCOMPARE(type, sNumber);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 15);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0), m_myObject->variantProperty());
+ QCOMPARE(ret.userType(), int(QMetaType::Double)); // all JS numbers are doubles, even though this started as an int
+ QCOMPARE(ret.toInt(),123);
+ }
+
+ /* XFAIL - variant support
+ m_myObject->resetQtFunctionInvoked();
+ {
+ m_myObject->setVariantProperty(qVariantFromValue(QBrush()));
+ QVariant ret = evalJS("myObject.myInvokableWithVariantArg(myObject.variantProperty)");
+ QVERIFY(ret.isVariant());
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 15);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QCOMPARE(ret.toVariant(), m_myObject->qtFunctionActuals().at(0));
+ QCOMPARE(ret.toVariant(), m_myObject->variantProperty());
+ }
+ */
+
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QString type;
+ QVariant ret = evalJSV("myObject.myInvokableWithVariantArg(123)", type);
+ QCOMPARE(type, sNumber);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 15);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0), QVariant(123));
+ QCOMPARE(ret.userType(), int(QMetaType::Double));
+ QCOMPARE(ret.toInt(),123);
+ }
+
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QString type;
+ QVariant ret = evalJSV("myObject.myInvokableWithVariantMapArg({ a:123, b:'ciao' })", type);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 16);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+
+ QVariant v = m_myObject->qtFunctionActuals().at(0);
+ QCOMPARE(v.userType(), int(QMetaType::QVariantMap));
+
+ QVariantMap vmap = qvariant_cast<QVariantMap>(v);
+ QCOMPARE(vmap.keys().size(), 2);
+ QCOMPARE(vmap.keys().at(0), QLatin1String("a"));
+ QCOMPARE(vmap.value("a"), QVariant(123));
+ QCOMPARE(vmap.keys().at(1), QLatin1String("b"));
+ QCOMPARE(vmap.value("b"), QVariant("ciao"));
+
+ QCOMPARE(type, sObject);
+
+ QCOMPARE(ret.userType(), int(QMetaType::QVariantMap));
+ vmap = qvariant_cast<QVariantMap>(ret);
+ QCOMPARE(vmap.keys().size(), 2);
+ QCOMPARE(vmap.keys().at(0), QLatin1String("a"));
+ QCOMPARE(vmap.value("a"), QVariant(123));
+ QCOMPARE(vmap.keys().at(1), QLatin1String("b"));
+ QCOMPARE(vmap.value("b"), QVariant("ciao"));
+ }
+
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QString type;
+ QVariant ret = evalJSV("myObject.myInvokableWithListOfIntArg([1, 5])", type);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 17);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QVariant v = m_myObject->qtFunctionActuals().at(0);
+ QCOMPARE(v.userType(), qMetaTypeId<QList<int> >());
+ QList<int> ilst = qvariant_cast<QList<int> >(v);
+ QCOMPARE(ilst.size(), 2);
+ QCOMPARE(ilst.at(0), 1);
+ QCOMPARE(ilst.at(1), 5);
+
+ QCOMPARE(type, sArray);
+ QCOMPARE(ret.userType(), int(QMetaType::QVariantList)); // ints get converted to doubles, so this is a qvariantlist
+ QVariantList vlst = qvariant_cast<QVariantList>(ret);
+ QCOMPARE(vlst.size(), 2);
+ QCOMPARE(vlst.at(0).toInt(), 1);
+ QCOMPARE(vlst.at(1).toInt(), 5);
+ }
+
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QString type;
+ QVariant ret = evalJSV("myObject.myInvokableWithQObjectStarArg(myObject)", type);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 18);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QVariant v = m_myObject->qtFunctionActuals().at(0);
+ QCOMPARE(v.userType(), int(QMetaType::QObjectStar));
+ QCOMPARE(qvariant_cast<QObject*>(v), (QObject*)m_myObject);
+
+ QCOMPARE(ret.userType(), int(QMetaType::QObjectStar));
+ QCOMPARE(qvariant_cast<QObject*>(ret), (QObject*)m_myObject);
+
+ QCOMPARE(type, sObject);
+ }
+
+ m_myObject->resetQtFunctionInvoked();
+ {
+ // no implicit conversion from integer to QObject*
+ QString type;
+ evalJS("myObject.myInvokableWithQObjectStarArg(123)", type);
+ QCOMPARE(type, sError);
+ }
+
+ /*
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QString fun = evalJS("myObject.myInvokableWithQBrushArg");
+ Q_ASSERT(fun.isFunction());
+ QColor color(10, 20, 30, 40);
+ // QColor should be converted to a QBrush
+ QVariant ret = fun.call(QString(), QStringList()
+ << qScriptValueFromValue(m_engine, color));
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 19);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QVariant v = m_myObject->qtFunctionActuals().at(0);
+ QCOMPARE(v.userType(), int(QMetaType::QBrush));
+ QCOMPARE(qvariant_cast<QColor>(v), color);
+
+ QCOMPARE(qscriptvalue_cast<QColor>(ret), color);
+ }
+ */
+
+ // private slots should not be part of the QObject binding
+ QCOMPARE(evalJS("typeof myObject.myPrivateSlot"), sUndefined);
+
+ // protected slots should be fine
+ m_myObject->resetQtFunctionInvoked();
+ evalJS("myObject.myProtectedSlot()");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 36);
+
+ // call with too few arguments
+ {
+ QString type;
+ QString ret = evalJS("myObject.myInvokableWithIntArg()", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("SyntaxError: too few arguments in call to myInvokableWithIntArg(); candidates are\n myInvokableWithIntArg(int,int)\n myInvokableWithIntArg(int)"));
+ }
+
+ // call function where not all types have been registered
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QString type;
+ QString ret = evalJS("myObject.myInvokableWithBrushStyleArg(0)", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("TypeError: cannot call myInvokableWithBrushStyleArg(): unknown type `Qt::BrushStyle'"));
+ QCOMPARE(m_myObject->qtFunctionInvoked(), -1);
+ }
+
+ // call function with incompatible argument type
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QString type;
+ QString ret = evalJS("myObject.myInvokableWithQBrushArg(null)", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("TypeError: incompatible type of argument(s) in call to myInvokableWithQBrushArg(); candidates were\n myInvokableWithQBrushArg(QBrush)"));
+ QCOMPARE(m_myObject->qtFunctionInvoked(), -1);
+ }
+}
+
+void tst_QWebFrame::connectAndDisconnect()
+{
+ // connect(function)
+ QCOMPARE(evalJS("typeof myObject.mySignal"), sFunction);
+ QCOMPARE(evalJS("typeof myObject.mySignal.connect"), sFunction);
+ QCOMPARE(evalJS("typeof myObject.mySignal.disconnect"), sFunction);
+
+ {
+ QString type;
+ evalJS("myObject.mySignal.connect(123)", type);
+ QCOMPARE(type, sError);
+ }
+
+ evalJS("myHandler = function() { window.gotSignal = true; window.signalArgs = arguments; window.slotThisObject = this; window.signalSender = __qt_sender__; }");
+
+ QCOMPARE(evalJS("myObject.mySignal.connect(myHandler)"), sUndefined);
+
+ evalJS("gotSignal = false");
+ evalJS("myObject.mySignal()");
+ QCOMPARE(evalJS("gotSignal"), sTrue);
+ QCOMPARE(evalJS("signalArgs.length == 0"), sTrue);
+ QCOMPARE(evalJS("signalSender"),evalJS("myObject"));
+ QCOMPARE(evalJS("slotThisObject == window"), sTrue);
+
+ evalJS("gotSignal = false");
+ m_myObject->emitMySignal();
+ QCOMPARE(evalJS("gotSignal"), sTrue);
+ QCOMPARE(evalJS("signalArgs.length == 0"), sTrue);
+
+ QCOMPARE(evalJS("myObject.mySignalWithIntArg.connect(myHandler)"), sUndefined);
+
+ evalJS("gotSignal = false");
+ m_myObject->emitMySignalWithIntArg(123);
+ QCOMPARE(evalJS("gotSignal"), sTrue);
+ QCOMPARE(evalJS("signalArgs.length == 1"), sTrue);
+ QCOMPARE(evalJS("signalArgs[0] == 123.0"), sTrue);
+
+ QCOMPARE(evalJS("myObject.mySignal.disconnect(myHandler)"), sUndefined);
+ {
+ QString type;
+ evalJS("myObject.mySignal.disconnect(myHandler)", type);
+ QCOMPARE(type, sError);
+ }
+
+ evalJS("gotSignal = false");
+ QCOMPARE(evalJS("myObject.mySignal2.connect(myHandler)"), sUndefined);
+ m_myObject->emitMySignal2(true);
+ QCOMPARE(evalJS("gotSignal"), sTrue);
+ QCOMPARE(evalJS("signalArgs.length == 1"), sTrue);
+ QCOMPARE(evalJS("signalArgs[0]"), sTrue);
+
+ QCOMPARE(evalJS("myObject.mySignal2.disconnect(myHandler)"), sUndefined);
+
+ QCOMPARE(evalJS("typeof myObject['mySignal2()']"), sFunction);
+ QCOMPARE(evalJS("typeof myObject['mySignal2()'].connect"), sFunction);
+ QCOMPARE(evalJS("typeof myObject['mySignal2()'].disconnect"), sFunction);
+
+ QCOMPARE(evalJS("myObject['mySignal2()'].connect(myHandler)"), sUndefined);
+
+ evalJS("gotSignal = false");
+ m_myObject->emitMySignal2();
+ QCOMPARE(evalJS("gotSignal"), sTrue);
+
+ QCOMPARE(evalJS("myObject['mySignal2()'].disconnect(myHandler)"), sUndefined);
+
+ // connect(object, function)
+ evalJS("otherObject = { name:'foo' }");
+ QCOMPARE(evalJS("myObject.mySignal.connect(otherObject, myHandler)"), sUndefined);
+ QCOMPARE(evalJS("myObject.mySignal.disconnect(otherObject, myHandler)"), sUndefined);
+ evalJS("gotSignal = false");
+ m_myObject->emitMySignal();
+ QCOMPARE(evalJS("gotSignal"), sFalse);
+
+ {
+ QString type;
+ evalJS("myObject.mySignal.disconnect(otherObject, myHandler)", type);
+ QCOMPARE(type, sError);
+ }
+
+ QCOMPARE(evalJS("myObject.mySignal.connect(otherObject, myHandler)"), sUndefined);
+ evalJS("gotSignal = false");
+ m_myObject->emitMySignal();
+ QCOMPARE(evalJS("gotSignal"), sTrue);
+ QCOMPARE(evalJS("signalArgs.length == 0"), sTrue);
+ QCOMPARE(evalJS("slotThisObject"),evalJS("otherObject"));
+ QCOMPARE(evalJS("signalSender"),evalJS("myObject"));
+ QCOMPARE(evalJS("slotThisObject.name"), QLatin1String("foo"));
+ QCOMPARE(evalJS("myObject.mySignal.disconnect(otherObject, myHandler)"), sUndefined);
+
+ evalJS("yetAnotherObject = { name:'bar', func : function() { } }");
+ QCOMPARE(evalJS("myObject.mySignal2.connect(yetAnotherObject, myHandler)"), sUndefined);
+ evalJS("gotSignal = false");
+ m_myObject->emitMySignal2(true);
+ QCOMPARE(evalJS("gotSignal"), sTrue);
+ QCOMPARE(evalJS("signalArgs.length == 1"), sTrue);
+ QCOMPARE(evalJS("slotThisObject == yetAnotherObject"), sTrue);
+ QCOMPARE(evalJS("signalSender == myObject"), sTrue);
+ QCOMPARE(evalJS("slotThisObject.name"), QLatin1String("bar"));
+ QCOMPARE(evalJS("myObject.mySignal2.disconnect(yetAnotherObject, myHandler)"), sUndefined);
+
+ QCOMPARE(evalJS("myObject.mySignal2.connect(myObject, myHandler)"), sUndefined);
+ evalJS("gotSignal = false");
+ m_myObject->emitMySignal2(true);
+ QCOMPARE(evalJS("gotSignal"), sTrue);
+ QCOMPARE(evalJS("signalArgs.length == 1"), sTrue);
+ QCOMPARE(evalJS("slotThisObject == myObject"), sTrue);
+ QCOMPARE(evalJS("signalSender == myObject"), sTrue);
+ QCOMPARE(evalJS("myObject.mySignal2.disconnect(myObject, myHandler)"), sUndefined);
+
+ // connect(obj, string)
+ QCOMPARE(evalJS("myObject.mySignal.connect(yetAnotherObject, 'func')"), sUndefined);
+ QCOMPARE(evalJS("myObject.mySignal.connect(myObject, 'mySlot')"), sUndefined);
+ QCOMPARE(evalJS("myObject.mySignal.disconnect(yetAnotherObject, 'func')"), sUndefined);
+ QCOMPARE(evalJS("myObject.mySignal.disconnect(myObject, 'mySlot')"), sUndefined);
+
+ // check that emitting signals from script works
+
+ // no arguments
+ QCOMPARE(evalJS("myObject.mySignal.connect(myObject.mySlot)"), sUndefined);
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("myObject.mySignal()"), sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 20);
+ QCOMPARE(evalJS("myObject.mySignal.disconnect(myObject.mySlot)"), sUndefined);
+
+ // one argument
+ QCOMPARE(evalJS("myObject.mySignalWithIntArg.connect(myObject.mySlotWithIntArg)"), sUndefined);
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("myObject.mySignalWithIntArg(123)"), sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 21);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123);
+ QCOMPARE(evalJS("myObject.mySignalWithIntArg.disconnect(myObject.mySlotWithIntArg)"), sUndefined);
+
+ QCOMPARE(evalJS("myObject.mySignalWithIntArg.connect(myObject.mySlotWithDoubleArg)"), sUndefined);
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("myObject.mySignalWithIntArg(123)"), sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 22);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDouble(), 123.0);
+ QCOMPARE(evalJS("myObject.mySignalWithIntArg.disconnect(myObject.mySlotWithDoubleArg)"), sUndefined);
+
+ QCOMPARE(evalJS("myObject.mySignalWithIntArg.connect(myObject.mySlotWithStringArg)"), sUndefined);
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("myObject.mySignalWithIntArg(123)"), sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 23);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0).toString(), QLatin1String("123"));
+ QCOMPARE(evalJS("myObject.mySignalWithIntArg.disconnect(myObject.mySlotWithStringArg)"), sUndefined);
+
+ // connecting to overloaded slot
+ QCOMPARE(evalJS("myObject.mySignalWithIntArg.connect(myObject.myOverloadedSlot)"), sUndefined);
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("myObject.mySignalWithIntArg(123)"), sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 26); // double overload
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 123);
+ QCOMPARE(evalJS("myObject.mySignalWithIntArg.disconnect(myObject.myOverloadedSlot)"), sUndefined);
+
+ QCOMPARE(evalJS("myObject.mySignalWithIntArg.connect(myObject['myOverloadedSlot(int)'])"), sUndefined);
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("myObject.mySignalWithIntArg(456)"), sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 28); // int overload
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 456);
+ QCOMPARE(evalJS("myObject.mySignalWithIntArg.disconnect(myObject['myOverloadedSlot(int)'])"), sUndefined);
+
+ // erroneous input
+ {
+ // ### QtScript adds .connect to all functions, WebKit does only to signals/slots
+ QString type;
+ QString ret = evalJS("(function() { }).connect()", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("TypeError: Result of expression '(function() { }).connect' [undefined] is not a function."));
+ }
+ {
+ QString type;
+ QString ret = evalJS("var o = { }; o.connect = Function.prototype.connect; o.connect()", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("TypeError: Result of expression 'o.connect' [undefined] is not a function."));
+ }
+
+ {
+ QString type;
+ QString ret = evalJS("(function() { }).connect(123)", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("TypeError: Result of expression '(function() { }).connect' [undefined] is not a function."));
+ }
+ {
+ QString type;
+ QString ret = evalJS("var o = { }; o.connect = Function.prototype.connect; o.connect(123)", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("TypeError: Result of expression 'o.connect' [undefined] is not a function."));
+ }
+
+ {
+ QString type;
+ QString ret = evalJS("myObject.myInvokable.connect(123)", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("TypeError: QtMetaMethod.connect: MyQObject::myInvokable() is not a signal"));
+ }
+ {
+ QString type;
+ QString ret = evalJS("myObject.myInvokable.connect(function() { })", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("TypeError: QtMetaMethod.connect: MyQObject::myInvokable() is not a signal"));
+ }
+
+ {
+ QString type;
+ QString ret = evalJS("myObject.mySignal.connect(123)", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("TypeError: QtMetaMethod.connect: target is not a function"));
+ }
+
+ {
+ QString type;
+ QString ret = evalJS("myObject.mySignal.disconnect()", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.disconnect: no arguments given"));
+ }
+ {
+ QString type;
+ QString ret = evalJS("var o = { }; o.disconnect = myObject.mySignal.disconnect; o.disconnect()", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.disconnect: no arguments given"));
+ }
+
+ /* XFAIL - Function.prototype doesn't get connect/disconnect, just signals/slots
+ {
+ QString type;
+ QString ret = evalJS("(function() { }).disconnect(123)", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("TypeError: QtMetaMethod.disconnect: this object is not a signal"));
+ }
+ */
+
+ {
+ QString type;
+ QString ret = evalJS("var o = { }; o.disconnect = myObject.myInvokable.disconnect; o.disconnect(123)", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("TypeError: QtMetaMethod.disconnect: MyQObject::myInvokable() is not a signal"));
+ }
+
+ {
+ QString type;
+ QString ret = evalJS("myObject.myInvokable.disconnect(123)", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("TypeError: QtMetaMethod.disconnect: MyQObject::myInvokable() is not a signal"));
+ }
+ {
+ QString type;
+ QString ret = evalJS("myObject.myInvokable.disconnect(function() { })", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("TypeError: QtMetaMethod.disconnect: MyQObject::myInvokable() is not a signal"));
+ }
+
+ {
+ QString type;
+ QString ret = evalJS("myObject.mySignal.disconnect(123)", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("TypeError: QtMetaMethod.disconnect: target is not a function"));
+ }
+
+ {
+ QString type;
+ QString ret = evalJS("myObject.mySignal.disconnect(function() { })", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("Error: QtMetaMethod.disconnect: failed to disconnect from MyQObject::mySignal()"));
+ }
+
+ // when the wrapper dies, the connection stays alive
+ QCOMPARE(evalJS("myObject.mySignal.connect(myObject.mySlot)"), sUndefined);
+ m_myObject->resetQtFunctionInvoked();
+ m_myObject->emitMySignal();
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 20);
+ evalJS("myObject = null");
+ evalJS("gc()");
+ m_myObject->resetQtFunctionInvoked();
+ m_myObject->emitMySignal();
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 20);
+}
+
+void tst_QWebFrame::classEnums()
+{
+ // We don't do the meta thing currently, unfortunately!!!
+ /*
+ QString myClass = m_engine->newQMetaObject(m_myObject->metaObject(), m_engine->undefinedValue());
+ m_engine->globalObject().setProperty("MyQObject", myClass);
+
+ QCOMPARE(static_cast<MyQObject::Policy>(evalJS("MyQObject.FooPolicy").toInt()),
+ MyQObject::FooPolicy);
+ QCOMPARE(static_cast<MyQObject::Policy>(evalJS("MyQObject.BarPolicy").toInt()),
+ MyQObject::BarPolicy);
+ QCOMPARE(static_cast<MyQObject::Policy>(evalJS("MyQObject.BazPolicy").toInt()),
+ MyQObject::BazPolicy);
+
+ QCOMPARE(static_cast<MyQObject::Strategy>(evalJS("MyQObject.FooStrategy").toInt()),
+ MyQObject::FooStrategy);
+ QCOMPARE(static_cast<MyQObject::Strategy>(evalJS("MyQObject.BarStrategy").toInt()),
+ MyQObject::BarStrategy);
+ QCOMPARE(static_cast<MyQObject::Strategy>(evalJS("MyQObject.BazStrategy").toInt()),
+ MyQObject::BazStrategy);
+
+ QCOMPARE(MyQObject::Ability(evalJS("MyQObject.NoAbility").toInt()),
+ MyQObject::NoAbility);
+ QCOMPARE(MyQObject::Ability(evalJS("MyQObject.FooAbility").toInt()),
+ MyQObject::FooAbility);
+ QCOMPARE(MyQObject::Ability(evalJS("MyQObject.BarAbility").toInt()),
+ MyQObject::BarAbility);
+ QCOMPARE(MyQObject::Ability(evalJS("MyQObject.BazAbility").toInt()),
+ MyQObject::BazAbility);
+ QCOMPARE(MyQObject::Ability(evalJS("MyQObject.AllAbility").toInt()),
+ MyQObject::AllAbility);
+
+ // enums from Qt are inherited through prototype
+ QCOMPARE(static_cast<Qt::FocusPolicy>(evalJS("MyQObject.StrongFocus").toInt()),
+ Qt::StrongFocus);
+ QCOMPARE(static_cast<Qt::Key>(evalJS("MyQObject.Key_Left").toInt()),
+ Qt::Key_Left);
+
+ QCOMPARE(evalJS("MyQObject.className()"), QLatin1String("MyQObject"));
+
+ qRegisterMetaType<MyQObject::Policy>("Policy");
+
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("myObject.myInvokableWithEnumArg(MyQObject.BazPolicy)"), sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 10);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), int(MyQObject::BazPolicy));
+
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("myObject.myInvokableWithQualifiedEnumArg(MyQObject.BazPolicy)"), sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 36);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), int(MyQObject::BazPolicy));
+
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QVariant ret = evalJS("myObject.myInvokableReturningEnum()");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 37);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 0);
+ QCOMPARE(ret.isVariant());
+ }
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QVariant ret = evalJS("myObject.myInvokableReturningQualifiedEnum()");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 38);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 0);
+ QCOMPARE(ret.isNumber());
+ }
+ */
+}
+
+void tst_QWebFrame::classConstructor()
+{
+ /*
+ QString myClass = qScriptValueFromQMetaObject<MyQObject>(m_engine);
+ m_engine->globalObject().setProperty("MyQObject", myClass);
+
+ QString myObj = evalJS("myObj = MyQObject()");
+ QObject* qobj = myObj.toQObject();
+ QVERIFY(qobj != 0);
+ QCOMPARE(qobj->metaObject()->className(), "MyQObject");
+ QCOMPARE(qobj->parent(), (QObject*)0);
+
+ QString qobjectClass = qScriptValueFromQMetaObject<QObject>(m_engine);
+ m_engine->globalObject().setProperty("QObject", qobjectClass);
+
+ QString otherObj = evalJS("otherObj = QObject(myObj)");
+ QObject* qqobj = otherObj.toQObject();
+ QVERIFY(qqobj != 0);
+ QCOMPARE(qqobj->metaObject()->className(), "QObject");
+ QCOMPARE(qqobj->parent(), qobj);
+
+ delete qobj;
+ */
+}
+
+void tst_QWebFrame::overrideInvokable()
+{
+ m_myObject->resetQtFunctionInvoked();
+ QCOMPARE(evalJS("myObject.myInvokable()"), sUndefined);
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 0);
+
+ /* XFAIL - can't write to functions with RuntimeObject
+ m_myObject->resetQtFunctionInvoked();
+ evalJS("myObject.myInvokable = function() { window.a = 123; }");
+ evalJS("myObject.myInvokable()");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), -1);
+ QCOMPARE(evalJS("window.a").toDouble(), 123.0);
+
+ evalJS("myObject.myInvokable = function() { window.a = 456; }");
+ evalJS("myObject.myInvokable()");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), -1);
+ QCOMPARE(evalJS("window.a").toDouble(), 456.0);
+ */
+
+ evalJS("delete myObject.myInvokable");
+ evalJS("myObject.myInvokable()");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 0);
+
+ /* XFAIL - ditto
+ m_myObject->resetQtFunctionInvoked();
+ evalJS("myObject.myInvokable = myObject.myInvokableWithIntArg");
+ evalJS("myObject.myInvokable(123)");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 1);
+ */
+
+ evalJS("delete myObject.myInvokable");
+ m_myObject->resetQtFunctionInvoked();
+ // this form (with the '()') is read-only
+ evalJS("myObject['myInvokable()'] = function() { window.a = 123; }");
+ evalJS("myObject.myInvokable()");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 0);
+}
+
+void tst_QWebFrame::transferInvokable()
+{
+ /* XFAIL - can't put to functions with RuntimeObject
+ m_myObject->resetQtFunctionInvoked();
+ evalJS("myObject.foozball = myObject.myInvokable");
+ evalJS("myObject.foozball()");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 0);
+ m_myObject->resetQtFunctionInvoked();
+ evalJS("myObject.foozball = myObject.myInvokableWithIntArg");
+ evalJS("myObject.foozball(123)");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 1);
+ m_myObject->resetQtFunctionInvoked();
+ evalJS("myObject.myInvokable = myObject.myInvokableWithIntArg");
+ evalJS("myObject.myInvokable(123)");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 1);
+
+ MyOtherQObject other;
+ m_page->mainFrame()->addToJSWindowObject("myOtherObject", &other);
+ evalJS("myOtherObject.foo = myObject.foozball");
+ other.resetQtFunctionInvoked();
+ evalJS("myOtherObject.foo(456)");
+ QCOMPARE(other.qtFunctionInvoked(), 1);
+ */
+}
+
+void tst_QWebFrame::findChild()
+{
+ /*
+ QObject* child = new QObject(m_myObject);
+ child->setObjectName(QLatin1String("myChildObject"));
+
+ {
+ QString result = evalJS("myObject.findChild('noSuchChild')");
+ QCOMPARE(result.isNull());
+ }
+
+ {
+ QString result = evalJS("myObject.findChild('myChildObject')");
+ QCOMPARE(result.isQObject());
+ QCOMPARE(result.toQObject(), child);
+ }
+
+ delete child;
+ */
+}
+
+void tst_QWebFrame::findChildren()
+{
+ /*
+ QObject* child = new QObject(m_myObject);
+ child->setObjectName(QLatin1String("myChildObject"));
+
+ {
+ QString result = evalJS("myObject.findChildren('noSuchChild')");
+ QCOMPARE(result.isArray());
+ QCOMPARE(result.property(QLatin1String("length")).toDouble(), 0.0);
+ }
+
+ {
+ QString result = evalJS("myObject.findChildren('myChildObject')");
+ QCOMPARE(result.isArray());
+ QCOMPARE(result.property(QLatin1String("length")).toDouble(), 1.0);
+ QCOMPARE(result.property(QLatin1String("0")).toQObject(), child);
+ }
+
+ QObject* namelessChild = new QObject(m_myObject);
+
+ {
+ QString result = evalJS("myObject.findChildren('myChildObject')");
+ QCOMPARE(result.isArray());
+ QCOMPARE(result.property(QLatin1String("length")).toDouble(), 1.0);
+ QCOMPARE(result.property(QLatin1String("0")).toQObject(), child);
+ }
+
+ QObject* anotherChild = new QObject(m_myObject);
+ anotherChild->setObjectName(QLatin1String("anotherChildObject"));
+
+ {
+ QString result = evalJS("myObject.findChildren('anotherChildObject')");
+ QCOMPARE(result.isArray());
+ QCOMPARE(result.property(QLatin1String("length")).toDouble(), 1.0);
+ QCOMPARE(result.property(QLatin1String("0")).toQObject(), anotherChild);
+ }
+
+ anotherChild->setObjectName(QLatin1String("myChildObject"));
+ {
+ QString result = evalJS("myObject.findChildren('myChildObject')");
+ QCOMPARE(result.isArray());
+ QCOMPARE(result.property(QLatin1String("length")).toDouble(), 2.0);
+ QObject* o1 = result.property(QLatin1String("0")).toQObject();
+ QObject* o2 = result.property(QLatin1String("1")).toQObject();
+ if (o1 != child) {
+ QCOMPARE(o1, anotherChild);
+ QCOMPARE(o2, child);
+ } else {
+ QCOMPARE(o1, child);
+ QCOMPARE(o2, anotherChild);
+ }
+ }
+
+ // find all
+ {
+ QString result = evalJS("myObject.findChildren()");
+ QVERIFY(result.isArray());
+ int count = 3;
+ QCOMPARE(result.property("length"), QLatin1String(count);
+ for (int i = 0; i < 3; ++i) {
+ QObject* o = result.property(i).toQObject();
+ if (o == namelessChild || o == child || o == anotherChild)
+ --count;
+ }
+ QVERIFY(count == 0);
+ }
+
+ delete anotherChild;
+ delete namelessChild;
+ delete child;
+ */
+}
+
+void tst_QWebFrame::overloadedSlots()
+{
+ // should pick myOverloadedSlot(double)
+ m_myObject->resetQtFunctionInvoked();
+ evalJS("myObject.myOverloadedSlot(10)");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 26);
+
+ // should pick myOverloadedSlot(double)
+ m_myObject->resetQtFunctionInvoked();
+ evalJS("myObject.myOverloadedSlot(10.0)");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 26);
+
+ // should pick myOverloadedSlot(QString)
+ m_myObject->resetQtFunctionInvoked();
+ evalJS("myObject.myOverloadedSlot('10')");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 29);
+
+ // should pick myOverloadedSlot(bool)
+ m_myObject->resetQtFunctionInvoked();
+ evalJS("myObject.myOverloadedSlot(true)");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 25);
+
+ // should pick myOverloadedSlot(QDateTime)
+ m_myObject->resetQtFunctionInvoked();
+ evalJS("myObject.myOverloadedSlot(new Date())");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 32);
+
+ // should pick myOverloadedSlot(QRegExp)
+ m_myObject->resetQtFunctionInvoked();
+ evalJS("myObject.myOverloadedSlot(new RegExp())");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 34);
+
+ // should pick myOverloadedSlot(QVariant)
+ /* XFAIL
+ m_myObject->resetQtFunctionInvoked();
+ QString f = evalJS("myObject.myOverloadedSlot");
+ f.call(QString(), QStringList() << m_engine->newVariant(QVariant("ciao")));
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 35);
+ */
+ // should pick myOverloadedSlot(QObject*)
+ m_myObject->resetQtFunctionInvoked();
+ evalJS("myObject.myOverloadedSlot(myObject)");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 41);
+
+ // should pick myOverloadedSlot(QObject*)
+ m_myObject->resetQtFunctionInvoked();
+ evalJS("myObject.myOverloadedSlot(null)");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 41);
+
+ // should pick myOverloadedSlot(QStringList)
+ m_myObject->resetQtFunctionInvoked();
+ evalJS("myObject.myOverloadedSlot(['hello'])");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 42);
+}
+
+void tst_QWebFrame::enumerate_data()
+{
+ QTest::addColumn<QStringList>("expectedNames");
+
+ QTest::newRow("enumerate all")
+ << (QStringList()
+ // meta-object-defined properties:
+ // inherited
+ << "objectName"
+ // non-inherited
+ << "p1" << "p2" << "p4" << "p6"
+ // dynamic properties
+ << "dp1" << "dp2" << "dp3"
+ // inherited slots
+ << "destroyed(QObject*)" << "destroyed()"
+ << "deleteLater()"
+ // not included because it's private:
+ // << "_q_reregisterTimers(void*)"
+ // signals
+ << "mySignal()"
+ // slots
+ << "mySlot()" << "myOtherSlot()");
+}
+
+void tst_QWebFrame::enumerate()
+{
+ QFETCH(QStringList, expectedNames);
+
+ MyEnumTestQObject enumQObject;
+ // give it some dynamic properties
+ enumQObject.setProperty("dp1", "dp1");
+ enumQObject.setProperty("dp2", "dp2");
+ enumQObject.setProperty("dp3", "dp3");
+ m_page->mainFrame()->addToJavaScriptWindowObject("myEnumObject", &enumQObject);
+
+ // enumerate in script
+ {
+ evalJS("var enumeratedProperties = []");
+ evalJS("for (var p in myEnumObject) { enumeratedProperties.push(p); }");
+ QStringList result = evalJSV("enumeratedProperties").toStringList();
+ QCOMPARE(result.size(), expectedNames.size());
+ for (int i = 0; i < expectedNames.size(); ++i)
+ QCOMPARE(result.at(i), expectedNames.at(i));
+ }
+}
+
+void tst_QWebFrame::objectDeleted()
+{
+ MyQObject* qobj = new MyQObject();
+ m_page->mainFrame()->addToJavaScriptWindowObject("bar", qobj);
+ evalJS("bar.objectName = 'foo';");
+ QCOMPARE(qobj->objectName(), QLatin1String("foo"));
+ evalJS("bar.intProperty = 123;");
+ QCOMPARE(qobj->intProperty(), 123);
+ qobj->resetQtFunctionInvoked();
+ evalJS("bar.myInvokable.call(bar);");
+ QCOMPARE(qobj->qtFunctionInvoked(), 0);
+
+ // do this, to ensure that we cache that it implements call
+ evalJS("bar()");
+
+ // now delete the object
+ delete qobj;
+
+ QCOMPARE(evalJS("typeof bar"), sObject);
+
+ // any attempt to access properties of the object should result in an exception
+ {
+ QString type;
+ QString ret = evalJS("bar.objectName", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("Error: cannot access member `objectName' of deleted QObject"));
+ }
+ {
+ QString type;
+ QString ret = evalJS("bar.objectName = 'foo'", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("Error: cannot access member `objectName' of deleted QObject"));
+ }
+
+ // myInvokable is stored in member table (since we've accessed it before deletion)
+ {
+ QString type;
+ evalJS("bar.myInvokable", type);
+ QCOMPARE(type, sFunction);
+ }
+
+ {
+ QString type;
+ QString ret = evalJS("bar.myInvokable.call(bar);", type);
+ ret = evalJS("bar.myInvokable(bar)", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("Error: cannot call function of deleted QObject"));
+ }
+ // myInvokableWithIntArg is not stored in member table (since we've not accessed it)
+ {
+ QString type;
+ QString ret = evalJS("bar.myInvokableWithIntArg", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("Error: cannot access member `myInvokableWithIntArg' of deleted QObject"));
+ }
+
+ // access from script
+ evalJS("window.o = bar;");
+ {
+ QString type;
+ QString ret = evalJS("o.objectName", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("Error: cannot access member `objectName' of deleted QObject"));
+ }
+ {
+ QString type;
+ QString ret = evalJS("o.myInvokable()", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("Error: cannot call function of deleted QObject"));
+ }
+ {
+ QString type;
+ QString ret = evalJS("o.myInvokableWithIntArg(10)", type);
+ QCOMPARE(type, sError);
+ QCOMPARE(ret, QLatin1String("Error: cannot access member `myInvokableWithIntArg' of deleted QObject"));
+ }
+}
+
+void tst_QWebFrame::typeConversion()
+{
+ m_myObject->resetQtFunctionInvoked();
+
+ QDateTime localdt(QDate(2008,1,18), QTime(12,31,0));
+ QDateTime utclocaldt = localdt.toUTC();
+ QDateTime utcdt(QDate(2008,1,18), QTime(12,31,0), Qt::UTC);
+
+ // Dates in JS (default to local)
+ evalJS("myObject.myOverloadedSlot(new Date(2008,0,18,12,31,0))");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 32);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDateTime().toUTC(), utclocaldt);
+
+ m_myObject->resetQtFunctionInvoked();
+ evalJS("myObject.myOverloadedSlot(new Date(Date.UTC(2008,0,18,12,31,0)))");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 32);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QCOMPARE(m_myObject->qtFunctionActuals().at(0).toDateTime().toUTC(), utcdt);
+
+ // Pushing QDateTimes into JS
+ // Local
+ evalJS("function checkDate(d) {window.__date_equals = (d.toString() == new Date(2008,0,18,12,31,0))?true:false;}");
+ evalJS("myObject.mySignalWithDateTimeArg.connect(checkDate)");
+ m_myObject->emitMySignalWithDateTimeArg(localdt);
+ QCOMPARE(evalJS("window.__date_equals"), sTrue);
+ evalJS("delete window.__date_equals");
+ m_myObject->emitMySignalWithDateTimeArg(utclocaldt);
+ QCOMPARE(evalJS("window.__date_equals"), sTrue);
+ evalJS("delete window.__date_equals");
+ evalJS("myObject.mySignalWithDateTimeArg.disconnect(checkDate); delete checkDate;");
+
+ // UTC
+ evalJS("function checkDate(d) {window.__date_equals = (d.toString() == new Date(Date.UTC(2008,0,18,12,31,0)))?true:false; }");
+ evalJS("myObject.mySignalWithDateTimeArg.connect(checkDate)");
+ m_myObject->emitMySignalWithDateTimeArg(utcdt);
+ QCOMPARE(evalJS("window.__date_equals"), sTrue);
+ evalJS("delete window.__date_equals");
+ evalJS("myObject.mySignalWithDateTimeArg.disconnect(checkDate); delete checkDate;");
+
+ // ### RegExps
+}
+
+void tst_QWebFrame::symmetricUrl()
+{
+ QVERIFY(m_view->url().isEmpty());
+
+ QCOMPARE(m_view->history()->count(), 0);
+
+ QUrl dataUrl("data:text/html,<h1>Test");
+
+ m_view->setUrl(dataUrl);
+ QCOMPARE(m_view->url(), dataUrl);
+ QCOMPARE(m_view->history()->count(), 0);
+
+ // loading is _not_ immediate, so the text isn't set just yet.
+ QVERIFY(m_view->page()->mainFrame()->toPlainText().isEmpty());
+
+ ::waitForSignal(m_view, SIGNAL(loadFinished(bool)));
+
+ QCOMPARE(m_view->history()->count(), 1);
+ QCOMPARE(m_view->page()->mainFrame()->toPlainText(), QString("Test"));
+
+ QUrl dataUrl2("data:text/html,<h1>Test2");
+ QUrl dataUrl3("data:text/html,<h1>Test3");
+
+ m_view->setUrl(dataUrl2);
+ m_view->setUrl(dataUrl3);
+
+ QCOMPARE(m_view->url(), dataUrl3);
+
+ ::waitForSignal(m_view, SIGNAL(loadFinished(bool)));
+
+ QCOMPARE(m_view->history()->count(), 2);
+
+ QCOMPARE(m_view->page()->mainFrame()->toPlainText(), QString("Test3"));
+}
+
+void tst_QWebFrame::progressSignal()
+{
+ QSignalSpy progressSpy(m_view, SIGNAL(loadProgress(int)));
+
+ QUrl dataUrl("data:text/html,<h1>Test");
+ m_view->setUrl(dataUrl);
+
+ ::waitForSignal(m_view, SIGNAL(loadFinished(bool)));
+
+ QVERIFY(progressSpy.size() >= 2);
+
+ // WebKit defines initialProgressValue as 10%, not 0%
+ QCOMPARE(progressSpy.first().first().toInt(), 10);
+
+ // But we always end at 100%
+ QCOMPARE(progressSpy.last().first().toInt(), 100);
+}
+
+void tst_QWebFrame::domCycles()
+{
+ m_view->setHtml("<html><body>");
+ QVariant v = m_page->mainFrame()->evaluateJavaScript("document");
+ QVERIFY(v.type() == QVariant::Map);
+}
+
+void tst_QWebFrame::setHtml()
+{
+ QString html("<html><body><p>hello world</p></body></html>");
+ m_view->page()->mainFrame()->setHtml(html);
+ QCOMPARE(m_view->page()->mainFrame()->toHtml(), html);
+}
+
+class TestNetworkManager : public QNetworkAccessManager
+{
+public:
+ TestNetworkManager(QObject* parent) : QNetworkAccessManager(parent) {}
+
+ QList<QUrl> requestedUrls;
+
+protected:
+ virtual QNetworkReply* createRequest(Operation op, const QNetworkRequest &request, QIODevice* outgoingData) {
+ requestedUrls.append(request.url());
+ QNetworkRequest redirectedRequest = request;
+ redirectedRequest.setUrl(QUrl("data:text/html,<p>hello"));
+ return QNetworkAccessManager::createRequest(op, redirectedRequest, outgoingData);
+ }
+};
+
+void tst_QWebFrame::ipv6HostEncoding()
+{
+ TestNetworkManager* networkManager = new TestNetworkManager(m_page);
+ m_page->setNetworkAccessManager(networkManager);
+ networkManager->requestedUrls.clear();
+
+ QUrl baseUrl = QUrl::fromEncoded("http://[::1]/index.html");
+ m_view->setHtml("<p>Hi", baseUrl);
+ m_view->page()->mainFrame()->evaluateJavaScript("var r = new XMLHttpRequest();"
+ "r.open('GET', 'http://[::1]/test.xml', false);"
+ "r.send(null);"
+ );
+ QCOMPARE(networkManager->requestedUrls.count(), 1);
+ QCOMPARE(networkManager->requestedUrls.at(0), QUrl::fromEncoded("http://[::1]/test.xml"));
+}
+
+QTEST_MAIN(tst_QWebFrame)
+#include "tst_qwebframe.moc"
diff --git a/WebKit/qt/tests/qwebpage/qwebpage.pro b/WebKit/qt/tests/qwebpage/qwebpage.pro
new file mode 100644
index 0000000..bbd98c6
--- /dev/null
+++ b/WebKit/qt/tests/qwebpage/qwebpage.pro
@@ -0,0 +1,6 @@
+TEMPLATE = app
+TARGET = tst_qwebpage
+include(../../../../WebKit.pri)
+SOURCES += tst_qwebpage.cpp
+QT += testlib network
+QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
diff --git a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
new file mode 100644
index 0000000..13b9bd2
--- /dev/null
+++ b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
@@ -0,0 +1,342 @@
+/*
+ Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+
+ 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 <QtTest/QtTest>
+
+#include <qwebpage.h>
+#include <qwidget.h>
+#include <qwebview.h>
+#include <qwebframe.h>
+#include <qwebhistory.h>
+#include <qnetworkrequest.h>
+#include <QDebug>
+#include <QMenu>
+
+// Will try to wait for the condition while allowing event processing
+#define QTRY_COMPARE(__expr, __expected) \
+ do { \
+ const int __step = 50; \
+ const int __timeout = 5000; \
+ if ((__expr) != (__expected)) { \
+ QTest::qWait(0); \
+ } \
+ for (int __i = 0; __i < __timeout && ((__expr) != (__expected)); __i+=__step) { \
+ QTest::qWait(__step); \
+ } \
+ QCOMPARE(__expr, __expected); \
+ } while(0)
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+// Task 160192
+/**
+ * Starts an event loop that runs until the given signal is received.
+ Optionally the event loop
+ * can return earlier on a timeout.
+ *
+ * \return \p true if the requested signal was received
+ * \p false on timeout
+ */
+static bool waitForSignal(QObject* obj, const char* signal, int timeout = 0)
+{
+ QEventLoop loop;
+ QObject::connect(obj, signal, &loop, SLOT(quit()));
+ QTimer timer;
+ QSignalSpy timeoutSpy(&timer, SIGNAL(timeout()));
+ if (timeout > 0) {
+ QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+ timer.setSingleShot(true);
+ timer.start(timeout);
+ }
+ loop.exec();
+ return timeoutSpy.isEmpty();
+}
+
+class tst_QWebPage : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QWebPage();
+ virtual ~tst_QWebPage();
+
+public slots:
+ void init();
+ void cleanup();
+
+private slots:
+ void acceptNavigationRequest();
+ void loadFinished();
+ void acceptNavigationRequestWithNewWindow();
+ void userStyleSheet();
+ void modified();
+ void contextMenuCrash();
+
+private:
+
+
+private:
+ QWebView* m_view;
+ QWebPage* m_page;
+};
+
+tst_QWebPage::tst_QWebPage()
+{
+}
+
+tst_QWebPage::~tst_QWebPage()
+{
+}
+
+void tst_QWebPage::init()
+{
+ m_view = new QWebView();
+ m_page = m_view->page();
+}
+
+void tst_QWebPage::cleanup()
+{
+ delete m_view;
+}
+
+class NavigationRequestOverride : public QWebPage
+{
+public:
+ NavigationRequestOverride(QWebView* parent, bool initialValue) : QWebPage(parent), m_acceptNavigationRequest(initialValue) {}
+
+ bool m_acceptNavigationRequest;
+protected:
+ virtual bool acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &request, QWebPage::NavigationType type) {
+ Q_UNUSED(frame);
+ Q_UNUSED(request);
+ Q_UNUSED(type);
+
+ return m_acceptNavigationRequest;
+ }
+};
+
+void tst_QWebPage::acceptNavigationRequest()
+{
+ QSignalSpy loadSpy(m_view, SIGNAL(loadFinished(bool)));
+
+ NavigationRequestOverride* newPage = new NavigationRequestOverride(m_view, false);
+ m_view->setPage(newPage);
+
+ m_view->setHtml(QString("<html><body><form name='tstform' action='data:text/html,foo'method='get'>"
+ "<input type='text'><input type='submit'></form></body></html>"), QUrl());
+ QTRY_COMPARE(loadSpy.count(), 1);
+
+ m_view->page()->mainFrame()->evaluateJavaScript("tstform.submit();");
+
+ newPage->m_acceptNavigationRequest = true;
+ m_view->page()->mainFrame()->evaluateJavaScript("tstform.submit();");
+ QTRY_COMPARE(loadSpy.count(), 2);
+
+ QCOMPARE(m_view->page()->mainFrame()->toPlainText(), QString("foo?"));
+
+ // Restore default page
+ m_view->setPage(0);
+}
+
+
+void tst_QWebPage::loadFinished()
+{
+ QSignalSpy spyLoadStarted(m_view, SIGNAL(loadStarted()));
+ QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool)));
+
+ m_view->setHtml(QString("data:text/html,<frameset cols=\"25%,75%\"><frame src=\"data:text/html,"
+ "<head><meta http-equiv='refresh' content='1'></head>foo \">"
+ "<frame src=\"data:text/html,bar\"></frameset>"), QUrl());
+ QTRY_COMPARE(spyLoadFinished.count(), 1);
+
+ QTest::qWait(3000);
+
+ QVERIFY(spyLoadStarted.count() > 1);
+ QVERIFY(spyLoadFinished.count() > 1);
+
+ spyLoadFinished.clear();
+
+ m_view->setHtml(QString("data:text/html,<frameset cols=\"25%,75%\"><frame src=\"data:text/html,"
+ "foo \"><frame src=\"data:text/html,bar\"></frameset>"), QUrl());
+ QTRY_COMPARE(spyLoadFinished.count(), 1);
+ QCOMPARE(spyLoadFinished.count(), 1);
+}
+
+class TestPage : public QWebPage
+{
+public:
+ TestPage(QObject* parent = 0) : QWebPage(parent) {}
+
+ struct Navigation {
+ QPointer<QWebFrame> frame;
+ QNetworkRequest request;
+ NavigationType type;
+ };
+
+ QList<Navigation> navigations;
+ QList<QWebPage*> createdWindows;
+
+ virtual bool acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &request, NavigationType type) {
+ Navigation n;
+ n.frame = frame;
+ n.request = request;
+ n.type = type;
+ navigations.append(n);
+ return true;
+ }
+
+ virtual QWebPage* createWindow(WebWindowType type) {
+ QWebPage* page = new TestPage(this);
+ createdWindows.append(page);
+ return page;
+ }
+};
+
+void tst_QWebPage::acceptNavigationRequestWithNewWindow()
+{
+ TestPage* page = new TestPage(m_view);
+ page->settings()->setAttribute(QWebSettings::LinksIncludedInFocusChain, true);
+ m_page = page;
+ m_view->setPage(m_page);
+
+ m_view->setUrl(QString("data:text/html,<a href=\"data:text/html,Reached\" target=\"_blank\">Click me</a>"));
+ QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool))));
+
+ QFocusEvent fe(QEvent::FocusIn);
+ m_page->event(&fe);
+
+ QVERIFY(m_page->focusNextPrevChild(/*next*/ true));
+
+ QKeyEvent keyEnter(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier);
+ m_page->event(&keyEnter);
+
+ QCOMPARE(page->navigations.count(), 2);
+
+ TestPage::Navigation n = page->navigations.at(1);
+ QVERIFY(n.frame.isNull());
+ QCOMPARE(n.request.url().toString(), QString("data:text/html,Reached"));
+ QVERIFY(n.type == QWebPage::NavigationTypeLinkClicked);
+
+ QCOMPARE(page->createdWindows.count(), 1);
+}
+
+class TestNetworkManager : public QNetworkAccessManager
+{
+public:
+ TestNetworkManager(QObject* parent) : QNetworkAccessManager(parent) {}
+
+ QList<QUrl> requestedUrls;
+
+protected:
+ virtual QNetworkReply* createRequest(Operation op, const QNetworkRequest &request, QIODevice* outgoingData) {
+ requestedUrls.append(request.url());
+ return QNetworkAccessManager::createRequest(op, request, outgoingData);
+ }
+};
+
+void tst_QWebPage::userStyleSheet()
+{
+ TestNetworkManager* networkManager = new TestNetworkManager(m_page);
+ m_page->setNetworkAccessManager(networkManager);
+ networkManager->requestedUrls.clear();
+
+ m_page->settings()->setUserStyleSheetUrl(QUrl("data:text/css,p { background-image: url('http://does.not/exist.png');}"));
+ m_view->setHtml("<p>hello world</p>");
+ QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool))));
+
+ QVERIFY(networkManager->requestedUrls.count() >= 2);
+ QCOMPARE(networkManager->requestedUrls.at(0), QUrl("data:text/css,p { background-image: url('http://does.not/exist.png');}"));
+ QCOMPARE(networkManager->requestedUrls.at(1), QUrl("http://does.not/exist.png"));
+}
+
+void tst_QWebPage::modified()
+{
+ m_page->mainFrame()->setUrl(QUrl("data:text/html,<body>blub"));
+ QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool))));
+
+ m_page->mainFrame()->setUrl(QUrl("data:text/html,<body id=foo contenteditable>blah"));
+ QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool))));
+
+ QVERIFY(!m_page->isModified());
+
+// m_page->mainFrame()->evaluateJavaScript("alert(document.getElementById('foo'))");
+ m_page->mainFrame()->evaluateJavaScript("document.getElementById('foo').focus()");
+ m_page->mainFrame()->evaluateJavaScript("document.execCommand('InsertText', true, 'Test');");
+
+ QVERIFY(m_page->isModified());
+
+ m_page->mainFrame()->evaluateJavaScript("document.execCommand('Undo', true);");
+
+ QVERIFY(!m_page->isModified());
+
+ m_page->mainFrame()->evaluateJavaScript("document.execCommand('Redo', true);");
+
+ QVERIFY(m_page->isModified());
+
+ QVERIFY(m_page->history()->canGoBack());
+ QVERIFY(!m_page->history()->canGoForward());
+ QCOMPARE(m_page->history()->count(), 2);
+ QVERIFY(m_page->history()->backItem().isValid());
+ QVERIFY(!m_page->history()->forwardItem().isValid());
+
+ m_page->history()->back();
+ QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool))));
+
+ QVERIFY(!m_page->history()->canGoBack());
+ QVERIFY(m_page->history()->canGoForward());
+
+ QVERIFY(!m_page->isModified());
+
+ QVERIFY(m_page->history()->currentItemIndex() == 0);
+
+ m_page->history()->setMaximumItemCount(3);
+ QVERIFY(m_page->history()->maximumItemCount() == 3);
+
+ QVariant variant("string test");
+ m_page->history()->currentItem().setUserData(variant);
+ QVERIFY(m_page->history()->currentItem().userData().toString() == "string test");
+
+ m_page->mainFrame()->setUrl(QUrl("data:text/html,<body>This is second page"));
+ m_page->mainFrame()->setUrl(QUrl("data:text/html,<body>This is third page"));
+ QVERIFY(m_page->history()->count() == 2);
+ m_page->mainFrame()->setUrl(QUrl("data:text/html,<body>This is fourth page"));
+ QVERIFY(m_page->history()->count() == 2);
+ m_page->mainFrame()->setUrl(QUrl("data:text/html,<body>This is fifth page"));
+ QVERIFY(::waitForSignal(m_page->mainFrame(), SIGNAL(aboutToUpdateHistory(QWebHistoryItem*))));
+}
+
+void tst_QWebPage::contextMenuCrash()
+{
+ QWebView view;
+ view.setHtml("<p>test");
+ view.page()->updatePositionDependentActions(QPoint(0, 0));
+ QMenu* contextMenu = 0;
+ foreach (QObject* child, view.children()) {
+ contextMenu = qobject_cast<QMenu*>(child);
+ if (contextMenu)
+ break;
+ }
+ QVERIFY(contextMenu);
+ delete contextMenu;
+}
+
+QTEST_MAIN(tst_QWebPage)
+#include "tst_qwebpage.moc"
diff --git a/WebKit/qt/tests/tests.pro b/WebKit/qt/tests/tests.pro
new file mode 100644
index 0000000..f08830d
--- /dev/null
+++ b/WebKit/qt/tests/tests.pro
@@ -0,0 +1,3 @@
+
+TEMPLATE = subdirs
+SUBDIRS = qwebframe qwebpage