summaryrefslogtreecommitdiffstats
path: root/WebKit/qt
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/qt')
-rw-r--r--WebKit/qt/Api/headers.pri7
-rw-r--r--WebKit/qt/Api/qcookiejar.cpp16
-rw-r--r--WebKit/qt/Api/qcookiejar.h9
-rw-r--r--WebKit/qt/Api/qwebdatabase.cpp61
-rw-r--r--WebKit/qt/Api/qwebdatabase.h6
-rw-r--r--WebKit/qt/Api/qwebdatabase_p.h7
-rw-r--r--WebKit/qt/Api/qwebelement.cpp1613
-rw-r--r--WebKit/qt/Api/qwebelement.h152
-rw-r--r--WebKit/qt/Api/qwebframe.cpp408
-rw-r--r--WebKit/qt/Api/qwebframe.h36
-rw-r--r--WebKit/qt/Api/qwebframe_p.h34
-rw-r--r--WebKit/qt/Api/qwebhistory.cpp156
-rw-r--r--WebKit/qt/Api/qwebhistory.h31
-rw-r--r--WebKit/qt/Api/qwebhistory_p.h31
-rw-r--r--WebKit/qt/Api/qwebhistoryinterface.cpp31
-rw-r--r--WebKit/qt/Api/qwebhistoryinterface.h3
-rw-r--r--WebKit/qt/Api/qwebkitglobal.h22
-rw-r--r--WebKit/qt/Api/qwebkitversion.cpp58
-rw-r--r--WebKit/qt/Api/qwebkitversion.h32
-rw-r--r--WebKit/qt/Api/qwebnetworkinterface.cpp214
-rw-r--r--WebKit/qt/Api/qwebnetworkinterface.h22
-rw-r--r--WebKit/qt/Api/qwebnetworkinterface_p.h33
-rw-r--r--WebKit/qt/Api/qwebpage.cpp446
-rw-r--r--WebKit/qt/Api/qwebpage.h40
-rw-r--r--WebKit/qt/Api/qwebpage_p.h16
-rw-r--r--WebKit/qt/Api/qwebplugindatabase.cpp382
-rw-r--r--WebKit/qt/Api/qwebplugindatabase.h94
-rw-r--r--WebKit/qt/Api/qwebplugindatabase_p.h46
-rw-r--r--WebKit/qt/Api/qwebpluginfactory.cpp7
-rw-r--r--WebKit/qt/Api/qwebpluginfactory.h21
-rw-r--r--WebKit/qt/Api/qwebsecurityorigin.cpp28
-rw-r--r--WebKit/qt/Api/qwebsecurityorigin.h3
-rw-r--r--WebKit/qt/Api/qwebsecurityorigin_p.h3
-rw-r--r--WebKit/qt/Api/qwebsettings.cpp224
-rw-r--r--WebKit/qt/Api/qwebsettings.h21
-rw-r--r--WebKit/qt/Api/qwebview.cpp184
-rw-r--r--WebKit/qt/Api/qwebview.h58
-rw-r--r--WebKit/qt/ChangeLog2463
-rw-r--r--WebKit/qt/Plugins/ICOHandler.cpp1
-rw-r--r--WebKit/qt/QtLauncher/QtLauncher.pro3
-rw-r--r--WebKit/qt/QtLauncher/main.cpp142
-rw-r--r--WebKit/qt/WebCoreSupport/ChromeClientQt.cpp28
-rw-r--r--WebKit/qt/WebCoreSupport/ChromeClientQt.h14
-rw-r--r--WebKit/qt/WebCoreSupport/ContextMenuClientQt.cpp6
-rw-r--r--WebKit/qt/WebCoreSupport/ContextMenuClientQt.h1
-rw-r--r--WebKit/qt/WebCoreSupport/DragClientQt.cpp1
-rw-r--r--WebKit/qt/WebCoreSupport/EditCommandQt.cpp1
-rw-r--r--WebKit/qt/WebCoreSupport/EditorClientQt.cpp24
-rw-r--r--WebKit/qt/WebCoreSupport/EditorClientQt.h1
-rw-r--r--WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp108
-rw-r--r--WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h9
-rw-r--r--WebKit/qt/WebCoreSupport/InspectorClientQt.cpp5
-rw-r--r--WebKit/qt/WebCoreSupport/InspectorClientQt.h2
-rw-r--r--WebKit/qt/WebKit_pch.h3
-rw-r--r--WebKit/qt/docs/docs.pri15
-rw-r--r--WebKit/qt/docs/qtwebkit.qdoc197
-rw-r--r--WebKit/qt/docs/qtwebkit.qdocconf197
-rw-r--r--WebKit/qt/docs/qwebview-diagram.pngbin0 -> 9036 bytes
-rw-r--r--WebKit/qt/docs/webkitsnippets/qtwebkit_build_snippet.qdoc8
-rw-r--r--WebKit/qt/docs/webkitsnippets/qtwebkit_qwebview_snippet.cpp35
-rw-r--r--WebKit/qt/docs/webkitsnippets/simple/main.cpp34
-rw-r--r--WebKit/qt/docs/webkitsnippets/simple/simple.pro2
-rw-r--r--WebKit/qt/docs/webkitsnippets/webelement/main.cpp69
-rw-r--r--WebKit/qt/docs/webkitsnippets/webelement/webelement.pro5
-rw-r--r--WebKit/qt/docs/webkitsnippets/webpage/main.cpp81
-rw-r--r--WebKit/qt/docs/webkitsnippets/webpage/webpage.pro3
-rw-r--r--WebKit/qt/tests/benchmarks/loading/tst_loading.cpp105
-rw-r--r--WebKit/qt/tests/benchmarks/loading/tst_loading.pro6
-rw-r--r--WebKit/qt/tests/benchmarks/painting/tst_painting.cpp109
-rw-r--r--WebKit/qt/tests/benchmarks/painting/tst_painting.pro6
-rw-r--r--WebKit/qt/tests/qwebelement/qwebelement.pro7
-rw-r--r--WebKit/qt/tests/qwebelement/qwebelement.qrc6
-rw-r--r--WebKit/qt/tests/qwebelement/style.css1
-rw-r--r--WebKit/qt/tests/qwebelement/style2.css1
-rw-r--r--WebKit/qt/tests/qwebelement/tst_qwebelement.cpp882
-rw-r--r--WebKit/qt/tests/qwebframe/qwebframe.qrc3
-rw-r--r--WebKit/qt/tests/qwebframe/style.css1
-rw-r--r--WebKit/qt/tests/qwebframe/test1.html1
-rw-r--r--WebKit/qt/tests/qwebframe/test2.html1
-rw-r--r--WebKit/qt/tests/qwebframe/tst_qwebframe.cpp308
-rw-r--r--WebKit/qt/tests/qwebhistory/data/page1.html1
-rw-r--r--WebKit/qt/tests/qwebhistory/data/page2.html1
-rw-r--r--WebKit/qt/tests/qwebhistory/data/page3.html1
-rw-r--r--WebKit/qt/tests/qwebhistory/data/page4.html1
-rw-r--r--WebKit/qt/tests/qwebhistory/data/page5.html1
-rw-r--r--WebKit/qt/tests/qwebhistory/data/page6.html1
-rw-r--r--WebKit/qt/tests/qwebhistory/qwebhistory.pro7
-rw-r--r--WebKit/qt/tests/qwebhistory/tst_qwebhistory.cpp326
-rw-r--r--WebKit/qt/tests/qwebhistory/tst_qwebhistory.qrc11
-rw-r--r--WebKit/qt/tests/qwebhistoryinterface/qwebhistoryinterface.pro6
-rw-r--r--WebKit/qt/tests/qwebhistoryinterface/tst_qwebhistoryinterface.cpp94
-rw-r--r--WebKit/qt/tests/qwebpage/frametest/frame_a.html2
-rw-r--r--WebKit/qt/tests/qwebpage/frametest/iframe.html6
-rw-r--r--WebKit/qt/tests/qwebpage/frametest/iframe2.html7
-rw-r--r--WebKit/qt/tests/qwebpage/frametest/iframe3.html5
-rw-r--r--WebKit/qt/tests/qwebpage/frametest/index.html4
-rw-r--r--WebKit/qt/tests/qwebpage/qwebpage.pro1
-rw-r--r--WebKit/qt/tests/qwebpage/tst_qwebpage.cpp238
-rw-r--r--WebKit/qt/tests/qwebpage/tst_qwebpage.qrc10
-rw-r--r--WebKit/qt/tests/qwebplugindatabase/qwebplugindatabase.pro6
-rw-r--r--WebKit/qt/tests/qwebplugindatabase/tst_qwebplugindatabase.cpp401
-rw-r--r--WebKit/qt/tests/qwebview/.gitignore1
-rw-r--r--WebKit/qt/tests/qwebview/qwebview.pro6
-rw-r--r--WebKit/qt/tests/qwebview/tst_qwebview.cpp172
-rw-r--r--WebKit/qt/tests/tests.pro3
105 files changed, 9980 insertions, 782 deletions
diff --git a/WebKit/qt/Api/headers.pri b/WebKit/qt/Api/headers.pri
index 2b3c940..92a120d 100644
--- a/WebKit/qt/Api/headers.pri
+++ b/WebKit/qt/Api/headers.pri
@@ -5,4 +5,9 @@ WEBKIT_API_HEADERS = $$PWD/qwebframe.h \
$$PWD/qwebsettings.h \
$$PWD/qwebhistoryinterface.h \
$$PWD/qwebdatabase.h \
- $$PWD/qwebsecurityorigin.h
+ $$PWD/qwebsecurityorigin.h \
+ $$PWD/qwebelement.h \
+ $$PWD/qwebplugindatabase.h \
+ $$PWD/qwebpluginfactory.h \
+ $$PWD/qwebhistory.h \
+ $$PWD/qwebkitversion.h
diff --git a/WebKit/qt/Api/qcookiejar.cpp b/WebKit/qt/Api/qcookiejar.cpp
index a6cbdab..a02fe78 100644
--- a/WebKit/qt/Api/qcookiejar.cpp
+++ b/WebKit/qt/Api/qcookiejar.cpp
@@ -17,7 +17,7 @@
Boston, MA 02110-1301, USA.
*/
-
+#include "config.h"
#include "qcookiejar.h"
#include <QCoreApplication>
uint qHash(const QUrl&);
@@ -26,7 +26,8 @@ uint qHash(const QUrl&);
class QCookieJarPrivate {
public:
- QCookieJarPrivate() {
+ QCookieJarPrivate()
+ {
enabled = true;
}
bool enabled;
@@ -34,7 +35,8 @@ class QCookieJarPrivate {
};
-uint qHash(const QUrl& url) {
+uint qHash(const QUrl& url)
+{
return qHash(url.toString());
}
@@ -85,7 +87,7 @@ static void gCleanupJar()
}
-void QCookieJar::setCookieJar(QCookieJar *jar)
+void QCookieJar::setCookieJar(QCookieJar* jar)
{
if (!gRoutineAdded) {
qAddPostRoutine(gCleanupJar);
@@ -96,10 +98,10 @@ void QCookieJar::setCookieJar(QCookieJar *jar)
}
-QCookieJar *QCookieJar::cookieJar()
+QCookieJar* QCookieJar::cookieJar()
{
- if (!gJar) {
+ if (!gJar)
setCookieJar(new QCookieJar);
- }
+
return gJar;
}
diff --git a/WebKit/qt/Api/qcookiejar.h b/WebKit/qt/Api/qcookiejar.h
index 0ca00bd..7885cc1 100644
--- a/WebKit/qt/Api/qcookiejar.h
+++ b/WebKit/qt/Api/qcookiejar.h
@@ -26,8 +26,7 @@
class QCookieJarPrivate;
-class QWEBKIT_EXPORT QCookieJar : public QObject
-{
+class QWEBKIT_EXPORT QCookieJar : public QObject {
Q_OBJECT
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
@@ -40,15 +39,15 @@ public:
bool isEnabled() const;
- static void setCookieJar(QCookieJar *jar);
- static QCookieJar *cookieJar();
+ static void setCookieJar(QCookieJar* jar);
+ static QCookieJar* cookieJar();
public slots:
virtual void setEnabled(bool enabled);
private:
friend class QCookieJarPrivate;
- QCookieJarPrivate *d;
+ QCookieJarPrivate* d;
};
diff --git a/WebKit/qt/Api/qwebdatabase.cpp b/WebKit/qt/Api/qwebdatabase.cpp
index 0203d72..d51e4e6 100644
--- a/WebKit/qt/Api/qwebdatabase.cpp
+++ b/WebKit/qt/Api/qwebdatabase.cpp
@@ -20,8 +20,6 @@
#include "config.h"
#include "qwebdatabase.h"
-#if ENABLE(DATABASE)
-
#include "qwebdatabase_p.h"
#include "qwebsecurityorigin.h"
#include "qwebsecurityorigin_p.h"
@@ -36,9 +34,20 @@ using namespace WebCore;
\brief The QWebDatabase class provides access to HTML 5 databases created with JavaScript.
The upcoming HTML 5 standard includes support for SQL databases that web sites can create and
- access on a local computer through JavaScript. QWebDatabase is the C++ interface to these databases.
+ access on a local computer through JavaScript. QWebDatabase is the C++ interface to these
+ databases.
+
+ To get access to all databases defined by a security origin, use QWebSecurityOrigin::databases().
+ Each database has an internal name(), as well as a user-friendly name, provided by displayName().
+
+ WebKit uses SQLite to create and access the local SQL databases. The location of the database
+ file in the local file system is returned by fileName(). You can access the database directly
+ through the QtSql database module.
- For more information refer to the \l{http://www.w3.org/html/wg/html5/#sql}{HTML 5 Draft Standard}.
+ For each database the web site can define an expectedSize(). The current size of the database
+ in bytes is returned by size().
+
+ For more information refer to the \l{http://dev.w3.org/html5/webdatabase/}{HTML 5 Draft Standard}.
\sa QWebSecurityOrigin
*/
@@ -46,7 +55,8 @@ using namespace WebCore;
/*!
Constructs a web database from \a other.
*/
-QWebDatabase::QWebDatabase(const QWebDatabase& other) : d(other.d)
+QWebDatabase::QWebDatabase(const QWebDatabase& other)
+ : d(other.d)
{
}
@@ -72,8 +82,12 @@ QString QWebDatabase::name() const
*/
QString QWebDatabase::displayName() const
{
+#if ENABLE(DATABASE)
DatabaseDetails details = DatabaseTracker::tracker().detailsForNameAndOrigin(d->name, d->origin.get());
return details.displayName();
+#else
+ return QString();
+#endif
}
/*!
@@ -81,8 +95,12 @@ QString QWebDatabase::displayName() const
*/
qint64 QWebDatabase::expectedSize() const
{
+#if ENABLE(DATABASE)
DatabaseDetails details = DatabaseTracker::tracker().detailsForNameAndOrigin(d->name, d->origin.get());
return details.expectedUsage();
+#else
+ return 0;
+#endif
}
/*!
@@ -90,8 +108,12 @@ qint64 QWebDatabase::expectedSize() const
*/
qint64 QWebDatabase::size() const
{
+#if ENABLE(DATABASE)
DatabaseDetails details = DatabaseTracker::tracker().detailsForNameAndOrigin(d->name, d->origin.get());
return details.currentUsage();
+#else
+ return 0;
+#endif
}
/*!
@@ -117,11 +139,15 @@ QWebDatabase::QWebDatabase(QWebDatabasePrivate* priv)
\endcode
\note Concurrent access to a database from multiple threads or processes
- is not very efficient because Sqlite is used as WebKit's database backend.
+ is not very efficient because SQLite is used as WebKit's database backend.
*/
QString QWebDatabase::fileName() const
{
+#if ENABLE(DATABASE)
return DatabaseTracker::tracker().fullPathForDatabase(d->origin.get(), d->name, false);
+#else
+ return QString();
+#endif
}
/*!
@@ -135,12 +161,28 @@ QWebSecurityOrigin QWebDatabase::origin() const
}
/*!
- Removes the database, \a db, from its security origin. All data stored in this database
- will be destroyed.
+ Removes the database \a db from its security origin. All data stored in the
+ database \a db will be destroyed.
*/
-void QWebDatabase::removeDatabase(const QWebDatabase &db)
+void QWebDatabase::removeDatabase(const QWebDatabase& db)
{
+#if ENABLE(DATABASE)
DatabaseTracker::tracker().deleteDatabase(db.d->origin.get(), db.d->name);
+#endif
+}
+
+/*!
+ \since 4.6
+
+ Deletes all web databases in the configured offline storage path.
+
+ \sa QWebSettings::setOfflineStoragePath()
+*/
+void QWebDatabase::removeAllDatabases()
+{
+#if ENABLE(DATABASE)
+ DatabaseTracker::tracker().deleteAllDatabases();
+#endif
}
/*!
@@ -150,4 +192,3 @@ QWebDatabase::~QWebDatabase()
{
}
-#endif
diff --git a/WebKit/qt/Api/qwebdatabase.h b/WebKit/qt/Api/qwebdatabase.h
index 4e832bb..875b2eb 100644
--- a/WebKit/qt/Api/qwebdatabase.h
+++ b/WebKit/qt/Api/qwebdatabase.h
@@ -31,8 +31,7 @@ namespace WebCore {
class QWebDatabasePrivate;
class QWebSecurityOrigin;
-class QWEBKIT_EXPORT QWebDatabase
-{
+class QWEBKIT_EXPORT QWebDatabase {
public:
QWebDatabase(const QWebDatabase& other);
QWebDatabase &operator=(const QWebDatabase& other);
@@ -45,7 +44,8 @@ public:
QString fileName() const;
QWebSecurityOrigin origin() const;
- static void removeDatabase(const QWebDatabase &db);
+ static void removeDatabase(const QWebDatabase&);
+ static void removeAllDatabases();
private:
QWebDatabase(QWebDatabasePrivate* priv);
diff --git a/WebKit/qt/Api/qwebdatabase_p.h b/WebKit/qt/Api/qwebdatabase_p.h
index 145115e..9ae8fc8 100644
--- a/WebKit/qt/Api/qwebdatabase_p.h
+++ b/WebKit/qt/Api/qwebdatabase_p.h
@@ -19,8 +19,6 @@
#ifndef _WEBDATABASE_P_H_
#define _WEBDATABASE_P_H_
-#if ENABLE(DATABASE)
-
#include <QString>
#include <QtCore/qshareddata.h>
@@ -29,8 +27,7 @@
#include "RefPtr.h"
-class QWebDatabasePrivate : public QSharedData
-{
+class QWebDatabasePrivate : public QSharedData {
public:
WebCore::String name;
WTF::RefPtr<WebCore::SecurityOrigin> origin;
@@ -38,5 +35,3 @@ public:
#endif
-#endif
-
diff --git a/WebKit/qt/Api/qwebelement.cpp b/WebKit/qt/Api/qwebelement.cpp
new file mode 100644
index 0000000..14b2811
--- /dev/null
+++ b/WebKit/qt/Api/qwebelement.cpp
@@ -0,0 +1,1613 @@
+/*
+ Copyright (C) 2009 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 "qwebelement.h"
+
+#include "CSSComputedStyleDeclaration.h"
+#include "CSSMutableStyleDeclaration.h"
+#include "CSSParser.h"
+#include "CSSRuleList.h"
+#include "CSSRule.h"
+#include "CSSStyleRule.h"
+#include "CString.h"
+#include "Document.h"
+#include "DocumentFragment.h"
+#include "FrameView.h"
+#include "HTMLElement.h"
+#include "JSGlobalObject.h"
+#include "JSHTMLElement.h"
+#include "JSObject.h"
+#include "NodeList.h"
+#include "PropertyNameArray.h"
+#include "ScriptFunctionCall.h"
+#include "StaticNodeList.h"
+#include "qt_runtime.h"
+#include "qwebframe.h"
+#include "qwebframe_p.h"
+#include "runtime_root.h"
+#include <wtf/Vector.h>
+
+using namespace WebCore;
+
+class QWebElementPrivate {
+public:
+};
+
+/*!
+ \class QWebElement
+ \since 4.6
+ \brief The QWebElement class provides convenient access to DOM elements in a QWebFrame.
+
+ QWebElement is the main class to easily access to the document model.
+ The document model is represented by a tree-like structure of DOM elements.
+ The root of the tree is called the document element and can be accessed using QWebFrame::documentElement().
+
+ You can reach specific elements using findAll() and findFirst(); the elements
+ are identified through CSS selectors.
+
+ \snippet webkitsnippets/webelement/main.cpp FindAll
+
+ The first list contains all \c span elements in the document. The second list contains
+ \c span elements that are children of \c p, classified with \c intro.
+
+ Using findFirst() is more efficient than calling findAll() and extracting the first element
+ only in the returned list.
+
+ Alternatively you can manually traverse the document using firstChild() and nextSibling():
+
+ \snippet webkitsnippets/webelement/main.cpp Traversing with QWebElement
+
+ The underlying content of QWebElement is explicitly shared. Creating a copy of a QWebElement
+ does not create a copy of the content. Instead, both instances point to the same element.
+
+ The element's attributes can be read using attribute() and modified with setAttribute().
+
+ The contents of child elements can be converted to plain text with toPlainText() and to
+ XHTML using toInnerXml(). To also include the element's tag in the output, use toOuterXml().
+
+ It is possible to replace the contents using setPlainText() and setInnerXml(). To replace
+ the element itself and its contents, use setOuterXml().
+
+ In the JavaScript DOM interfaces, elements can have additional functions depending on their
+ type. For example an HTML form element can be triggered to submit the entire form to the
+ web server using the submit() function. A list of these special functions can be obtained
+ in QWebElement using functions(); they can be invoked using callFunction().
+
+ Similarly element specific properties can be obtained using scriptableProperties() and
+ read/written using scriptableProperty()/setScriptableProperty().
+*/
+
+/*!
+ Constructs a null web element.
+*/
+QWebElement::QWebElement()
+ : d(0)
+ , m_element(0)
+{
+}
+
+/*!
+ \internal
+*/
+QWebElement::QWebElement(WebCore::Element* domElement)
+ : d(0)
+ , m_element(domElement)
+{
+ if (m_element)
+ m_element->ref();
+}
+
+/*!
+ \internal
+*/
+QWebElement::QWebElement(WebCore::Node* node)
+ : d(0)
+ , m_element(0)
+{
+ if (node && node->isHTMLElement()) {
+ m_element = static_cast<HTMLElement*>(node);
+ m_element->ref();
+ }
+}
+
+/*!
+ Constructs a copy of \a other.
+*/
+QWebElement::QWebElement(const QWebElement &other)
+ : d(0)
+ , m_element(other.m_element)
+{
+ if (m_element)
+ m_element->ref();
+}
+
+/*!
+ Assigns \a other to this element and returns a reference to this element.
+*/
+QWebElement &QWebElement::operator=(const QWebElement &other)
+{
+ // ### handle "d" assignment
+ if (this != &other) {
+ Element *otherElement = other.m_element;
+ if (otherElement)
+ otherElement->ref();
+ if (m_element)
+ m_element->deref();
+ m_element = otherElement;
+ }
+ return *this;
+}
+
+/*!
+ Destroys the element. The underlying DOM element is not destroyed.
+*/
+QWebElement::~QWebElement()
+{
+ delete d;
+ if (m_element)
+ m_element->deref();
+}
+
+bool QWebElement::operator==(const QWebElement& o) const
+{
+ return m_element == o.m_element;
+}
+
+bool QWebElement::operator!=(const QWebElement& o) const
+{
+ return m_element != o.m_element;
+}
+
+/*!
+ Returns true if the element is a null element; false otherwise.
+*/
+bool QWebElement::isNull() const
+{
+ return !m_element;
+}
+
+/*!
+ Returns a new list of child elements matching the given CSS selector \a selectorQuery.
+ If there are no matching elements, an empty list is returned.
+
+ \l{http://www.w3.org/TR/REC-CSS2/selector.html#q1}{Standard CSS2 selector} syntax is
+ used for the query.
+
+ \note This search is performed recursively.
+*/
+QList<QWebElement> QWebElement::findAll(const QString &selectorQuery) const
+{
+ QList<QWebElement> elements;
+ if (!m_element)
+ return elements;
+
+ ExceptionCode exception = 0; // ###
+ RefPtr<NodeList> nodes = m_element->querySelectorAll(selectorQuery, exception);
+ if (!nodes)
+ return elements;
+
+ for (int i = 0; i < nodes->length(); ++i) {
+ WebCore::Node* n = nodes->item(i);
+ elements.append(QWebElement(static_cast<Element*>(n)));
+ }
+
+ return elements;
+}
+
+/*!
+ Returns the first child element that matches the given CSS selector \a selectorQuery.
+
+ \l{http://www.w3.org/TR/REC-CSS2/selector.html#q1}{Standard CSS2 selector} syntax is
+ used for the query.
+
+ \note This search is performed recursively.
+*/
+QWebElement QWebElement::findFirst(const QString &selectorQuery) const
+{
+ if (!m_element)
+ return QWebElement();
+ ExceptionCode exception = 0; // ###
+ return QWebElement(m_element->querySelector(selectorQuery, exception).get());
+}
+
+/*!
+ Replaces the existing content of this element with \a text.
+
+ This is equivalent to setting the HTML innerText property.
+*/
+void QWebElement::setPlainText(const QString &text)
+{
+ if (!m_element || !m_element->isHTMLElement())
+ return;
+ ExceptionCode exception = 0;
+ static_cast<HTMLElement*>(m_element)->setInnerText(text, exception);
+}
+
+/*!
+ Returns the text between the start and the end tag of this
+ element.
+
+ This is equivalent to reading the HTML innerText property.
+*/
+QString QWebElement::toPlainText() const
+{
+ if (!m_element || !m_element->isHTMLElement())
+ return QString();
+ return static_cast<HTMLElement*>(m_element)->innerText();
+}
+
+/*!
+ Replaces the contents of this element as well as its own tag with \a markup.
+ The string may contain HTML or XML tags, which is parsed and formatted
+ before insertion into the document.
+
+ \note This is currently only implemented for (X)HTML elements.
+*/
+void QWebElement::setOuterXml(const QString &markup)
+{
+ if (!m_element || !m_element->isHTMLElement())
+ return;
+
+ ExceptionCode exception = 0;
+
+ static_cast<HTMLElement*>(m_element)->setOuterHTML(markup, exception);
+}
+
+/*!
+ Returns this element converted to XML, including the start and the end
+ tag of this element and its attributes.
+
+ \note This is currently only implemented for (X)HTML elements.
+*/
+QString QWebElement::toOuterXml() const
+{
+ if (!m_element || !m_element->isHTMLElement())
+ return QString();
+
+ return static_cast<HTMLElement*>(m_element)->outerHTML();
+}
+
+/*!
+ Replaces the content of this element with \a markup.
+ The string may contain HTML or XML tags, which is parsed and formatted
+ before insertion into the document.
+
+ \note This is currently only implemented for (X)HTML elements.
+*/
+void QWebElement::setInnerXml(const QString &markup)
+{
+ if (!m_element || !m_element->isHTMLElement())
+ return;
+
+ ExceptionCode exception = 0;
+
+ static_cast<HTMLElement*>(m_element)->setInnerHTML(markup, exception);
+}
+
+/*!
+ Returns the XML between the start and the end tag of this
+ element.
+
+ \note This is currently only implemented for (X)HTML elements.
+*/
+QString QWebElement::toInnerXml() const
+{
+ if (!m_element || !m_element->isHTMLElement())
+ return QString();
+
+ return static_cast<HTMLElement*>(m_element)->innerHTML();
+}
+
+/*!
+ Adds an attribute called \a name with the value \a value. If an attribute
+ with the same name exists, its value is replaced by \a value.
+*/
+void QWebElement::setAttribute(const QString &name, const QString &value)
+{
+ if (!m_element)
+ return;
+ ExceptionCode exception = 0;
+ m_element->setAttribute(name, value, exception);
+}
+
+/*!
+ Adds an attribute called \a name in the namespace described with \a namespaceUri
+ with the value \a value. If an attribute with the same name exists, its value is
+ replaced by \a value.
+*/
+void QWebElement::setAttributeNS(const QString &namespaceUri, const QString &name, const QString &value)
+{
+ if (!m_element)
+ return;
+ WebCore::ExceptionCode exception = 0;
+ m_element->setAttributeNS(namespaceUri, name, value, exception);
+}
+
+/*!
+ Returns the attributed called \a name. If the attribute does not exist \a defaultValue is
+ returned.
+*/
+QString QWebElement::attribute(const QString &name, const QString &defaultValue) const
+{
+ if (!m_element)
+ return QString();
+ if (m_element->hasAttribute(name))
+ return m_element->getAttribute(name);
+ else
+ return defaultValue;
+}
+
+/*!
+ Returns the attributed called \a name in the namespace described with \a namespaceUri.
+ If the attribute does not exist \a defaultValue is returned.
+*/
+QString QWebElement::attributeNS(const QString &namespaceUri, const QString &name, const QString &defaultValue) const
+{
+ if (!m_element)
+ return QString();
+ if (m_element->hasAttributeNS(namespaceUri, name))
+ return m_element->getAttributeNS(namespaceUri, name);
+ else
+ return defaultValue;
+}
+
+/*!
+ Returns true if this element has an attribute called \a name; otherwise returns false.
+*/
+bool QWebElement::hasAttribute(const QString &name) const
+{
+ if (!m_element)
+ return false;
+ return m_element->hasAttribute(name);
+}
+
+/*!
+ Returns true if this element has an attribute called \a name in the namespace described
+ with \a namespaceUri; otherwise returns false.
+*/
+bool QWebElement::hasAttributeNS(const QString &namespaceUri, const QString &name) const
+{
+ if (!m_element)
+ return false;
+ return m_element->hasAttributeNS(namespaceUri, name);
+}
+
+/*!
+ Removes the attribute called \a name from this element.
+*/
+void QWebElement::removeAttribute(const QString &name)
+{
+ if (!m_element)
+ return;
+ ExceptionCode exception = 0;
+ m_element->removeAttribute(name, exception);
+}
+
+/*!
+ Removes the attribute called \a name in the namespace described with \a namespaceUri
+ from this element.
+*/
+void QWebElement::removeAttributeNS(const QString &namespaceUri, const QString &name)
+{
+ if (!m_element)
+ return;
+ WebCore::ExceptionCode exception = 0;
+ m_element->removeAttributeNS(namespaceUri, name, exception);
+}
+
+/*!
+ Returns true if the element has any attributes defined; otherwise returns false;
+*/
+bool QWebElement::hasAttributes() const
+{
+ if (!m_element)
+ return false;
+ return m_element->hasAttributes();
+}
+
+/*!
+ Returns the geometry of this element, relative to its containing frame.
+*/
+QRect QWebElement::geometry() const
+{
+ if (!m_element)
+ return QRect();
+ return m_element->getRect();
+}
+
+/*!
+ Returns the tag name of this element.
+*/
+QString QWebElement::tagName() const
+{
+ if (!m_element)
+ return QString();
+ return m_element->tagName();
+}
+
+/*!
+ Returns the namespace prefix of the element or an empty string if the element has no namespace prefix.
+*/
+QString QWebElement::prefix() const
+{
+ if (!m_element)
+ return QString();
+ return m_element->prefix();
+}
+
+/*!
+ If the element uses namespaces, this function returns the local name of the element;
+ otherwise it returns an empty string.
+*/
+QString QWebElement::localName() const
+{
+ if (!m_element)
+ return QString();
+ return m_element->localName();
+}
+
+/*!
+ Returns the namespace URI of this element or an empty string if the element has no namespace URI.
+*/
+QString QWebElement::namespaceUri() const
+{
+ if (!m_element)
+ return QString();
+ return m_element->namespaceURI();
+}
+
+/*!
+ Returns the parent element of this element or a null element if this element
+ is the root document element.
+*/
+QWebElement QWebElement::parent() const
+{
+ if (m_element)
+ return QWebElement(m_element->parentElement());
+ return QWebElement();
+}
+
+/*!
+ Returns the first child element of this element.
+
+ \sa lastChild() previousSibling() nextSibling()
+*/
+QWebElement QWebElement::firstChild() const
+{
+ if (!m_element)
+ return QWebElement();
+ for (Node* child = m_element->firstChild(); child; child = child->nextSibling()) {
+ if (!child->isElementNode())
+ continue;
+ Element* e = static_cast<Element*>(child);
+ return QWebElement(e);
+ }
+ return QWebElement();
+}
+
+/*!
+ Returns the last child element of this element.
+
+ \sa firstChild() previousSibling() nextSibling()
+*/
+QWebElement QWebElement::lastChild() const
+{
+ if (!m_element)
+ return QWebElement();
+ for (Node* child = m_element->lastChild(); child; child = child->previousSibling()) {
+ if (!child->isElementNode())
+ continue;
+ Element* e = static_cast<Element*>(child);
+ return QWebElement(e);
+ }
+ return QWebElement();
+}
+
+/*!
+ Returns the next sibling element of this element.
+
+ \sa firstChild() previousSibling() lastChild()
+*/
+QWebElement QWebElement::nextSibling() const
+{
+ if (!m_element)
+ return QWebElement();
+ for (Node* sib = m_element->nextSibling(); sib; sib = sib->nextSibling()) {
+ if (!sib->isElementNode())
+ continue;
+ Element* e = static_cast<Element*>(sib);
+ return QWebElement(e);
+ }
+ return QWebElement();
+}
+
+/*!
+ Returns the previous sibling element of this element.
+
+ \sa firstChild() nextSibling() lastChild()
+*/
+QWebElement QWebElement::previousSibling() const
+{
+ if (!m_element)
+ return QWebElement();
+ for (Node* sib = m_element->previousSibling(); sib; sib = sib->previousSibling()) {
+ if (!sib->isElementNode())
+ continue;
+ Element* e = static_cast<Element*>(sib);
+ return QWebElement(e);
+ }
+ return QWebElement();
+}
+
+/*!
+ Returns the document this element belongs to.
+*/
+QWebElement QWebElement::document() const
+{
+ if (!m_element)
+ return QWebElement();
+ Document* document = m_element->document();
+ if (!document)
+ return QWebElement();
+ return QWebElement(document->documentElement());
+}
+
+/*!
+ Returns the web frame this elements is a part of. If the element is
+ a null element null is returned.
+*/
+QWebFrame *QWebElement::webFrame() const
+{
+ if (!m_element)
+ return 0;
+
+ Document* document = m_element->document();
+ if (!document)
+ return 0;
+
+ Frame* frame = document->frame();
+ if (!frame)
+ return 0;
+ return QWebFramePrivate::kit(frame);
+}
+
+static bool setupScriptContext(WebCore::Element* element, JSC::JSValue& thisValue, ScriptState*& state, ScriptController*& scriptController)
+{
+ if (!element)
+ return false;
+
+ Document* document = element->document();
+ if (!document)
+ return false;
+
+ Frame* frame = document->frame();
+ if (!frame)
+ return false;
+
+ scriptController = frame->script();
+ if (!scriptController)
+ return false;
+
+ state = scriptController->globalObject()->globalExec();
+ if (!state)
+ return false;
+
+ thisValue = toJS(state, element);
+ if (!thisValue)
+ return false;
+
+ return true;
+}
+
+
+static bool setupScriptObject(WebCore::Element* element, ScriptObject& object, ScriptState*& state, ScriptController*& scriptController)
+{
+ if (!element)
+ return false;
+
+ Document* document = element->document();
+ if (!document)
+ return false;
+
+ Frame* frame = document->frame();
+ if (!frame)
+ return false;
+
+ scriptController = frame->script();
+
+ state = scriptController->globalObject()->globalExec();
+
+ JSC::JSValue thisValue = toJS(state, element);
+ if (!thisValue)
+ return false;
+
+ JSC::JSObject* thisObject = thisValue.toObject(state);
+ if (!thisObject)
+ return false;
+
+ object = ScriptObject(state, thisObject);
+ return true;
+}
+
+/*!
+ Executes the \a scriptSource with this element as the `this' object.
+
+ \sa callFunction()
+*/
+QVariant QWebElement::evaluateScript(const QString& scriptSource)
+{
+ if (scriptSource.isEmpty())
+ return QVariant();
+
+ ScriptState* state = 0;
+ JSC::JSValue thisValue;
+ ScriptController* scriptController = 0;
+
+ if (!setupScriptContext(m_element, thisValue, state, scriptController))
+ return QVariant();
+
+ JSC::ScopeChain& scopeChain = state->dynamicGlobalObject()->globalScopeChain();
+ JSC::UString script((const UChar*)scriptSource.data(), scriptSource.length());
+ JSC::Completion completion = JSC::evaluate(state, scopeChain, JSC::makeSource(script), thisValue);
+ if ((completion.complType() != JSC::ReturnValue) && (completion.complType() != JSC::Normal))
+ return QVariant();
+
+ JSC::JSValue result = completion.value();
+ if (!result)
+ return QVariant();
+
+ int distance = 0;
+ return JSC::Bindings::convertValueToQVariant(state, result, QMetaType::Void, &distance);
+}
+
+/*!
+ Calls the function with the given \a name and \a arguments.
+
+ The underlying DOM element that QWebElement wraps may have dedicated functions depending
+ on its type. For example a form element can have the "submit" function, that would submit
+ the form to the destination specified in the HTML.
+
+ \sa functions()
+*/
+QVariant QWebElement::callFunction(const QString &name, const QVariantList &arguments)
+{
+ ScriptState* state = 0;
+ ScriptObject thisObject;
+ ScriptController* scriptController = 0;
+
+ if (!setupScriptObject(m_element, thisObject, state, scriptController))
+ return QVariant();
+
+ ScriptFunctionCall functionCall(state, thisObject, name);
+
+ for (QVariantList::ConstIterator it = arguments.constBegin(), end = arguments.constEnd();
+ it != end; ++it)
+ functionCall.appendArgument(JSC::Bindings::convertQVariantToValue(state, scriptController->bindingRootObject(), *it));
+
+ bool hadException = false;
+ ScriptValue result = functionCall.call(hadException);
+ if (hadException)
+ return QVariant();
+
+ int distance = 0;
+ return JSC::Bindings::convertValueToQVariant(state, result.jsValue(), QMetaType::Void, &distance);
+}
+
+/*!
+ Returns a list of function names this element supports.
+
+ The function names returned are the same functions that are callable from the DOM
+ element's JavaScript binding.
+
+ \sa callFunction()
+*/
+QStringList QWebElement::functions() const
+{
+ ScriptState* state = 0;
+ ScriptObject thisObject;
+ ScriptController* scriptController = 0;
+
+ if (!setupScriptObject(m_element, thisObject, state, scriptController))
+ return QStringList();
+
+ JSC::JSObject* object = thisObject.jsObject();
+ if (!object)
+ return QStringList();
+
+ QStringList names;
+
+ // Enumerate the contents of the object
+ JSC::PropertyNameArray properties(state);
+ object->getPropertyNames(state, properties);
+ for (JSC::PropertyNameArray::const_iterator it = properties.begin();
+ it != properties.end(); ++it) {
+
+ JSC::JSValue property = object->get(state, *it);
+ if (!property)
+ continue;
+
+ JSC::JSObject* function = property.toObject(state);
+ if (!function)
+ continue;
+
+ JSC::CallData callData;
+ JSC::CallType callType = function->getCallData(callData);
+ if (callType == JSC::CallTypeNone)
+ continue;
+
+ JSC::UString ustring = (*it).ustring();
+ names << QString::fromUtf16((const ushort*)ustring.rep()->data(), ustring.size());
+ }
+
+ if (state->hadException())
+ state->clearException();
+
+ return names;
+}
+
+/*!
+ Returns the value of the element's \a name property.
+
+ If no such property exists, the returned variant is invalid.
+
+ The return property has the same value as the corresponding property
+ in the element's JavaScript binding with the same name.
+
+ Information about all available properties is provided through scriptProperties().
+
+ \sa setScriptableProperty(), scriptableProperties()
+*/
+QVariant QWebElement::scriptableProperty(const QString &name) const
+{
+ ScriptState* state = 0;
+ ScriptObject thisObject;
+ ScriptController *scriptController = 0;
+
+ if (!setupScriptObject(m_element, thisObject, state, scriptController))
+ return QVariant();
+
+ String wcName(name);
+ JSC::JSValue property = thisObject.jsObject()->get(state, JSC::Identifier(state, wcName));
+
+ // ###
+ if (state->hadException())
+ state->clearException();
+
+ int distance = 0;
+ return JSC::Bindings::convertValueToQVariant(state, property, QMetaType::Void, &distance);
+}
+
+/*!
+ Sets the value of the element's \a name property to \a value.
+
+ Information about all available properties is provided through scriptProperties().
+
+ Setting the property will affect the corresponding property
+ in the element's JavaScript binding with the same name.
+
+ \sa scriptableProperty(), scriptableProperties()
+*/
+void QWebElement::setScriptableProperty(const QString &name, const QVariant &value)
+{
+ ScriptState* state = 0;
+ ScriptObject thisObject;
+ ScriptController* scriptController = 0;
+
+ if (!setupScriptObject(m_element, thisObject, state, scriptController))
+ return;
+
+ JSC::JSValue jsValue = JSC::Bindings::convertQVariantToValue(state, scriptController->bindingRootObject(), value);
+ if (!jsValue)
+ return;
+
+ String wcName(name);
+ JSC::PutPropertySlot slot;
+ thisObject.jsObject()->put(state, JSC::Identifier(state, wcName), jsValue, slot);
+ if (state->hadException())
+ state->clearException();
+}
+
+/*!
+ Returns a list of property names this element supports.
+
+ The function names returned are the same properties that are accessible from the DOM
+ element's JavaScript binding.
+
+ \sa setScriptableProperty(), scriptableProperty()
+*/
+QStringList QWebElement::scriptableProperties() const
+{
+ if (!m_element)
+ return QStringList();
+
+ Document* document = m_element->document();
+ if (!document)
+ return QStringList();
+
+ Frame* frame = document->frame();
+ if (!frame)
+ return QStringList();
+
+ ScriptController* script = frame->script();
+ JSC::ExecState* exec = script->globalObject()->globalExec();
+
+ JSC::JSValue thisValue = toJS(exec, m_element);
+ if (!thisValue)
+ return QStringList();
+
+ JSC::JSObject* object = thisValue.toObject(exec);
+ if (!object)
+ return QStringList();
+
+ QStringList names;
+
+ // Enumerate the contents of the object
+ JSC::PropertyNameArray properties(exec);
+ object->getPropertyNames(exec, properties);
+ for (JSC::PropertyNameArray::const_iterator it = properties.begin();
+ it != properties.end(); ++it) {
+
+ JSC::JSValue property = object->get(exec, *it);
+ if (!property)
+ continue;
+
+ JSC::JSObject* function = property.toObject(exec);
+ if (!function)
+ continue;
+
+ JSC::CallData callData;
+ JSC::CallType callType = function->getCallData(callData);
+ if (callType != JSC::CallTypeNone)
+ continue;
+
+ JSC::UString ustring = (*it).ustring();
+ names << QString::fromUtf16((const ushort*)ustring.rep()->data(), ustring.size());
+ }
+
+ if (exec->hadException())
+ exec->clearException();
+
+ return names;
+}
+
+/*!
+ \enum QWebElement::ResolveRule
+ \since 4.6
+
+ This enum describes how QWebElement's styleProperty resolves the given
+ property name.
+
+ \value IgnoreCascadingStyles Return the property value as it is defined
+ in the element, without respecting style inheritance and other CSS rules.
+ \value RespectCascadingStyles The property's value is determined using
+ the inheritance and importance rules defined in the document's stylesheet.
+*/
+
+/*!
+ \enum QWebElement::StylePriority
+ \since 4.6
+
+ This enum describes the priority newly set CSS properties should have when
+ set using QWebElement::setStyleProperty().
+
+ \value NormalStylePriority Define the property without important
+ priority even if "!important" is explicitly set in \a value.
+ \value DeclaredStylePriority Define the property respecting the
+ priority specified in \a value.
+ \value ImportantStylePriority Define the property to have
+ an important priority, this is equal to appending "!important" to the value.
+*/
+
+/*!
+ Returns the value of the style named \a name or an empty string if such one
+ does not exist.
+
+ If \a rule is IgnoreCascadingStyles, the value defined inside the element
+ (inline in CSS terminology) is returned.
+
+ if \a rule is RespectCascadingStyles, the actual style applied to the
+ element is returned.
+
+ In CSS, the cascading part has to do with which CSS rule has priority and
+ is thus applied. Generally speaking, the last defined rule has priority,
+ thus an inline style rule has priority over an embedded block style rule,
+ which in return has priority over an external style rule.
+
+ If the !important declaration is set on one of those, the declaration gets
+ highest priority, unless other declarations also use the !important
+ declaration, in which the last !important declaration takes predecence.
+*/
+QString QWebElement::styleProperty(const QString &name, ResolveRule rule) const
+{
+ if (!m_element || !m_element->isStyledElement())
+ return QString();
+
+ int propID = cssPropertyID(name);
+
+ if (!propID)
+ return QString();
+
+ CSSStyleDeclaration* style = static_cast<StyledElement*>(m_element)->style();
+
+ if (rule == IgnoreCascadingStyles)
+ return style->getPropertyValue(propID);
+
+ if (rule == RespectCascadingStyles) {
+ if (style->getPropertyPriority(propID))
+ return style->getPropertyValue(propID);
+
+ // We are going to resolve the style property by walking through the
+ // list of non-inline matched CSS rules for the element, looking for
+ // the highest priority definition.
+
+ // Get an array of matched CSS rules for the given element sorted
+ // by importance and inheritance order. This include external CSS
+ // declarations, as well as embedded and inline style declarations.
+
+ DOMWindow* domWindow = m_element->document()->frame()->domWindow();
+ if (RefPtr<CSSRuleList> rules = domWindow->getMatchedCSSRules(m_element, "")) {
+ for (int i = rules->length(); i > 0; --i) {
+ CSSStyleRule* rule = static_cast<CSSStyleRule*>(rules->item(i - 1));
+
+ if (rule->style()->getPropertyPriority(propID))
+ return rule->style()->getPropertyValue(propID);
+
+ if (style->getPropertyValue(propID).isEmpty())
+ style = rule->style();
+ }
+ }
+
+ return style->getPropertyValue(propID);
+ }
+
+ return QString();
+}
+
+/*!
+ Sets the value of the style named \a name to \a value.
+
+ Setting a value, doesn't necessarily mean that it will become the applied
+ value, due to the fact that the style property's value might have been set
+ earlier with priority in external or embedded style declarations.
+
+ In order to ensure that the value will be applied, ImportantStylePriority
+ should be used as \a priority.
+
+ Following the CSS syntax for property values, this is equal to appending
+ "!important" to the value.
+
+ This syntax is supported when using DeclaredStylePriority as \a priority.
+
+ Using NormalStylePriority as \a priority, the property will have normal
+ priority, and any "!important" declaration will be ignored. On the other
+ hand, using ImportantStylePriority sets the important priority even when
+ not explicit passed in \a value.
+ By using DeclaredStylePriority as \a priority the property will respect the
+ priority specified in \a value.
+*/
+void QWebElement::setStyleProperty(const QString &name, const QString &value, StylePriority priority)
+{
+ if (!m_element || !m_element->isStyledElement())
+ return;
+
+ int propID = cssPropertyID(name);
+ CSSStyleDeclaration* style = static_cast<StyledElement*>(m_element)->style();
+ if (!propID || !style)
+ return;
+
+ ExceptionCode exception = 0;
+
+ const QRegExp hasImportantTest(QLatin1String("!\\s*important"));
+ int index = value.indexOf(hasImportantTest);
+
+ QString newValue = (index != -1) ? value.left(index - 1) : value;
+
+ switch (priority) {
+ case NormalStylePriority:
+ style->setProperty(name, newValue, "", exception);
+ break;
+ case DeclaredStylePriority:
+ style->setProperty(name, newValue, (index != -1) ? "important" : "", exception);
+ break;
+ case ImportantStylePriority:
+ style->setProperty(name, newValue, "important", exception);
+ break;
+ default:
+ break;
+ }
+}
+
+/*!
+ Returns the computed value for style named \a name or an empty string if the style has no such name.
+*/
+QString QWebElement::computedStyleProperty(const QString &name) const
+{
+ if (!m_element || !m_element->isStyledElement())
+ return QString();
+
+ int propID = cssPropertyID(name);
+
+ RefPtr<CSSComputedStyleDeclaration> style = computedStyle(m_element);
+ if (!propID || !style)
+ return QString();
+
+ return style->getPropertyValue(propID);
+}
+
+/*!
+ Returns the list of classes of this element.
+*/
+QStringList QWebElement::classes() const
+{
+ if (!hasAttribute(QLatin1String("class")))
+ return QStringList();
+
+ QStringList classes = attribute(QLatin1String("class")).simplified().split(QLatin1Char(' '), QString::SkipEmptyParts);
+#if QT_VERSION >= 0x040500
+ classes.removeDuplicates();
+#else
+ int n = classes.size();
+ int j = 0;
+ QSet<QString> seen;
+ seen.reserve(n);
+ for (int i = 0; i < n; ++i) {
+ const QString& s = classes.at(i);
+ if (seen.contains(s))
+ continue;
+ seen.insert(s);
+ if (j != i)
+ classes[j] = s;
+ ++j;
+ }
+ if (n != j)
+ classes.erase(classes.begin() + j, classes.end());
+#endif
+ return classes;
+}
+
+/*!
+ Returns true if this element has a class called \a name; otherwise returns false.
+*/
+bool QWebElement::hasClass(const QString &name) const
+{
+ QStringList list = classes();
+ return list.contains(name);
+}
+
+/*!
+ Adds the specified class \a name to the element.
+*/
+void QWebElement::addClass(const QString &name)
+{
+ QStringList list = classes();
+ if (!list.contains(name)) {
+ list.append(name);
+ QString value = list.join(QLatin1String(" "));
+ setAttribute(QLatin1String("class"), value);
+ }
+}
+
+/*!
+ Removes the specified class \a name from the element.
+*/
+void QWebElement::removeClass(const QString &name)
+{
+ QStringList list = classes();
+ if (list.contains(name)) {
+ list.removeAll(name);
+ QString value = list.join(QLatin1String(" "));
+ setAttribute(QLatin1String("class"), value);
+ }
+}
+
+/*!
+ Adds the specified class \a name if it is not present,
+ removes it if it is already present.
+*/
+void QWebElement::toggleClass(const QString &name)
+{
+ QStringList list = classes();
+ if (list.contains(name))
+ list.removeAll(name);
+ else
+ list.append(name);
+
+ QString value = list.join(QLatin1String(" "));
+ setAttribute(QLatin1String("class"), value);
+}
+
+/*!
+ Appends \a element as the element's last child.
+
+ If \a element is the child of another element, it is re-parented
+ to this element. If \a element is a child of this element, then
+ its position in the list of children is changed.
+
+ Calling this function on a null element does nothing.
+
+ \sa prependInside(), prependOutside(), appendOutside()
+*/
+void QWebElement::appendInside(const QWebElement &element)
+{
+ if (!m_element || element.isNull())
+ return;
+
+ ExceptionCode exception = 0;
+ m_element->appendChild(element.m_element, exception);
+}
+
+/*!
+ Appends the result of parsing \a markup as the element's last child.
+
+ Calling this function on a null element does nothing.
+
+ \sa prependInside(), prependOutside(), appendOutside()
+*/
+void QWebElement::appendInside(const QString &markup)
+{
+ if (!m_element)
+ return;
+
+ if (!m_element->isHTMLElement())
+ return;
+
+ HTMLElement* htmlElement = static_cast<HTMLElement*>(m_element);
+ RefPtr<DocumentFragment> fragment = htmlElement->createContextualFragment(markup);
+
+ ExceptionCode exception = 0;
+ m_element->appendChild(fragment, exception);
+}
+
+/*!
+ Prepends \a element as the element's first child.
+
+ If \a element is the child of another element, it is re-parented
+ to this element. If \a element is a child of this element, then
+ its position in the list of children is changed.
+
+ Calling this function on a null element does nothing.
+
+ \sa appendInside(), prependOutside(), appendOutside()
+*/
+void QWebElement::prependInside(const QWebElement &element)
+{
+ if (!m_element || element.isNull())
+ return;
+
+ ExceptionCode exception = 0;
+
+ if (m_element->hasChildNodes())
+ m_element->insertBefore(element.m_element, m_element->firstChild(), exception);
+ else
+ m_element->appendChild(element.m_element, exception);
+}
+
+/*!
+ Prepends the result of parsing \a markup as the element's first child.
+
+ Calling this function on a null element does nothing.
+
+ \sa appendInside(), prependOutside(), appendOutside()
+*/
+void QWebElement::prependInside(const QString &markup)
+{
+ if (!m_element)
+ return;
+
+ if (!m_element->isHTMLElement())
+ return;
+
+ HTMLElement* htmlElement = static_cast<HTMLElement*>(m_element);
+ RefPtr<DocumentFragment> fragment = htmlElement->createContextualFragment(markup);
+
+ ExceptionCode exception = 0;
+
+ if (m_element->hasChildNodes())
+ m_element->insertBefore(fragment, m_element->firstChild(), exception);
+ else
+ m_element->appendChild(fragment, exception);
+}
+
+
+/*!
+ Inserts \a element before this element.
+
+ If \a element is the child of another element, it is re-parented
+ to the parent of this element.
+
+ Calling this function on a null element does nothing.
+
+ \sa appendInside(), prependInside(), appendOutside()
+*/
+void QWebElement::prependOutside(const QWebElement &element)
+{
+ if (!m_element || element.isNull())
+ return;
+
+ if (!m_element->parent())
+ return;
+
+ ExceptionCode exception = 0;
+ m_element->parent()->insertBefore(element.m_element, m_element, exception);
+}
+
+/*!
+ Inserts the result of parsing \a markup before this element.
+
+ Calling this function on a null element does nothing.
+
+ \sa appendInside(), prependInside(), appendOutside()
+*/
+void QWebElement::prependOutside(const QString &markup)
+{
+ if (!m_element)
+ return;
+
+ if (!m_element->parent())
+ return;
+
+ if (!m_element->isHTMLElement())
+ return;
+
+ HTMLElement* htmlElement = static_cast<HTMLElement*>(m_element);
+ RefPtr<DocumentFragment> fragment = htmlElement->createContextualFragment(markup);
+
+ ExceptionCode exception = 0;
+ m_element->parent()->insertBefore(fragment, m_element, exception);
+}
+
+/*!
+ Inserts \a element after this element.
+
+ If \a element is the child of another element, it is re-parented
+ to the parent of this element.
+
+ Calling this function on a null element does nothing.
+
+ \sa appendInside(), prependInside(), prependOutside()
+*/
+void QWebElement::appendOutside(const QWebElement &element)
+{
+ if (!m_element || element.isNull())
+ return;
+
+ if (!m_element->parent())
+ return;
+
+ ExceptionCode exception = 0;
+ if (!m_element->nextSibling())
+ m_element->parent()->appendChild(element.m_element, exception);
+ else
+ m_element->parent()->insertBefore(element.m_element, m_element->nextSibling(), exception);
+}
+
+/*!
+ Inserts the result of parsing \a markup after this element.
+
+ Calling this function on a null element does nothing.
+
+ \sa appendInside(), prependInside(), prependOutside()
+*/
+void QWebElement::appendOutside(const QString &markup)
+{
+ if (!m_element)
+ return;
+
+ if (!m_element->parent())
+ return;
+
+ if (!m_element->isHTMLElement())
+ return;
+
+ HTMLElement* htmlElement = static_cast<HTMLElement*>(m_element);
+ RefPtr<DocumentFragment> fragment = htmlElement->createContextualFragment(markup);
+
+ ExceptionCode exception = 0;
+ if (!m_element->nextSibling())
+ m_element->parent()->appendChild(fragment, exception);
+ else
+ m_element->parent()->insertBefore(fragment, m_element->nextSibling(), exception);
+}
+
+/*!
+ Returns a clone of this element.
+
+ The clone may be inserted at any point in the document.
+
+ \sa appendInside(), prependInside(), prependOutside(), appendOutside()
+*/
+QWebElement QWebElement::clone() const
+{
+ if (!m_element)
+ return QWebElement();
+
+ return QWebElement(m_element->cloneElementWithChildren().get());
+}
+
+/*!
+ Removes this element from the document and returns a reference
+ to this.
+
+ The element is still valid after removal, and can be inserted into
+ other parts of the document.
+
+ \sa removeChildren(), removeFromDocument()
+*/
+QWebElement &QWebElement::takeFromDocument()
+{
+ if (!m_element)
+ return *this;
+
+ ExceptionCode exception = 0;
+ m_element->remove(exception);
+
+ return *this;
+}
+
+/*!
+ Removes this element from the document and makes this
+ a null element.
+
+ \sa removeChildren(), takeFromDocument()
+*/
+void QWebElement::removeFromDocument()
+{
+ if (!m_element)
+ return;
+
+ ExceptionCode exception = 0;
+ m_element->remove(exception);
+ m_element->deref();
+ m_element = 0;
+}
+
+/*!
+ Removes all children from this element.
+
+ \sa removeFromDocument(), takeFromDocument()
+*/
+void QWebElement::removeChildren()
+{
+ if (!m_element)
+ return;
+
+ m_element->removeAllChildren();
+}
+
+static RefPtr<Node> findInsertionPoint(PassRefPtr<Node> root)
+{
+ RefPtr<Node> node = root;
+
+ // Go as far down the tree as possible.
+ while (node->hasChildNodes() && node->firstChild()->isElementNode())
+ node = node->firstChild();
+
+ // TODO: Implement SVG support
+ if (node->isHTMLElement()) {
+ HTMLElement* element = static_cast<HTMLElement*>(node.get());
+
+ // The insert point could be a non-enclosable tag and it can thus
+ // never have children, so go one up. Get the parent element, and not
+ // note as a root note will always exist.
+ if (element->endTagRequirement() == TagStatusForbidden)
+ node = node->parentElement();
+ }
+
+ return node;
+}
+
+/*!
+ Enclose the contents of this element in \a element as the child
+ of the deepest descendant element within the structure of the
+ first element provided.
+
+ \sa encloseWith()
+*/
+void QWebElement::encloseContentsWith(const QWebElement &element)
+{
+ if (!m_element || element.isNull())
+ return;
+
+ RefPtr<Node> insertionPoint = findInsertionPoint(element.m_element);
+
+ if (!insertionPoint)
+ return;
+
+ ExceptionCode exception = 0;
+
+ // reparent children
+ for (RefPtr<Node> child = m_element->firstChild(); child;) {
+ RefPtr<Node> next = child->nextSibling();
+ insertionPoint->appendChild(child, exception);
+ child = next;
+ }
+
+ if (m_element->hasChildNodes())
+ m_element->insertBefore(element.m_element, m_element->firstChild(), exception);
+ else
+ m_element->appendChild(element.m_element, exception);
+}
+
+/*!
+ Enclose the contents of this element in the result of parsing
+ \a markup as the child of the deepest descendant element within
+ the structure of the first element provided.
+
+ \sa encloseWith()
+*/
+void QWebElement::encloseContentsWith(const QString &markup)
+{
+ if (!m_element)
+ return;
+
+ if (!m_element->parent())
+ return;
+
+ if (!m_element->isHTMLElement())
+ return;
+
+ HTMLElement* htmlElement = static_cast<HTMLElement*>(m_element);
+ RefPtr<DocumentFragment> fragment = htmlElement->createContextualFragment(markup);
+
+ if (!fragment || !fragment->firstChild())
+ return;
+
+ RefPtr<Node> insertionPoint = findInsertionPoint(fragment->firstChild());
+
+ if (!insertionPoint)
+ return;
+
+ ExceptionCode exception = 0;
+
+ // reparent children
+ for (RefPtr<Node> child = m_element->firstChild(); child;) {
+ RefPtr<Node> next = child->nextSibling();
+ insertionPoint->appendChild(child, exception);
+ child = next;
+ }
+
+ if (m_element->hasChildNodes())
+ m_element->insertBefore(fragment, m_element->firstChild(), exception);
+ else
+ m_element->appendChild(fragment, exception);
+}
+
+/*!
+ Enclose this element in \a element as the child of the deepest
+ descendant element within the structure of the first element
+ provided.
+
+ \sa replace()
+*/
+void QWebElement::encloseWith(const QWebElement &element)
+{
+ if (!m_element || element.isNull())
+ return;
+
+ RefPtr<Node> insertionPoint = findInsertionPoint(element.m_element);
+
+ if (!insertionPoint)
+ return;
+
+ // Keep reference to these two nodes before pulling out this element and
+ // wrapping it in the fragment. The reason for doing it in this order is
+ // that once the fragment has been added to the document it is empty, so
+ // we no longer have access to the nodes it contained.
+ Node* parentNode = m_element->parent();
+ Node* siblingNode = m_element->nextSibling();
+
+ ExceptionCode exception = 0;
+ insertionPoint->appendChild(m_element, exception);
+
+ if (!siblingNode)
+ parentNode->appendChild(element.m_element, exception);
+ else
+ parentNode->insertBefore(element.m_element, siblingNode, exception);
+}
+
+/*!
+ Enclose this element in the result of parsing \a markup,
+ as the last child.
+
+ \sa replace()
+*/
+void QWebElement::encloseWith(const QString &markup)
+{
+ if (!m_element)
+ return;
+
+ if (!m_element->parent())
+ return;
+
+ if (!m_element->isHTMLElement())
+ return;
+
+ HTMLElement* htmlElement = static_cast<HTMLElement*>(m_element);
+ RefPtr<DocumentFragment> fragment = htmlElement->createContextualFragment(markup);
+
+ if (!fragment || !fragment->firstChild())
+ return;
+
+ RefPtr<Node> insertionPoint = findInsertionPoint(fragment->firstChild());
+
+ if (!insertionPoint)
+ return;
+
+ // Keep reference to these two nodes before pulling out this element and
+ // wrapping it in the fragment. The reason for doing it in this order is
+ // that once the fragment has been added to the document it is empty, so
+ // we no longer have access to the nodes it contained.
+ Node* parentNode = m_element->parent();
+ Node* siblingNode = m_element->nextSibling();
+
+ ExceptionCode exception = 0;
+ insertionPoint->appendChild(m_element, exception);
+
+ if (!siblingNode)
+ parentNode->appendChild(fragment, exception);
+ else
+ parentNode->insertBefore(fragment, siblingNode, exception);
+}
+
+/*!
+ Replaces this element with \a element.
+
+ It is not possible to replace the <html>, <head>, or <body>
+ elements using this method.
+
+ \sa encloseWith()
+*/
+void QWebElement::replace(const QWebElement &element)
+{
+ if (!m_element || element.isNull())
+ return;
+
+ appendOutside(element);
+ takeFromDocument();
+}
+
+/*!
+ Replaces this element with the result of parsing \a markup.
+
+ It is not possible to replace the <html>, <head>, or <body>
+ elements using this method.
+
+ \sa encloseWith()
+*/
+void QWebElement::replace(const QString &markup)
+{
+ if (!m_element)
+ return;
+
+ appendOutside(markup);
+ takeFromDocument();
+}
+
+/*!
+ \fn inline bool QWebElement::operator==(const QWebElement& o) const;
+
+ Returns true if this element points to the same underlying DOM object than \a o; otherwise returns false.
+*/
+
+/*!
+ \fn inline bool QWebElement::operator!=(const QWebElement& o) const;
+
+ Returns true if this element points to a different underlying DOM object than \a o; otherwise returns false.
+*/
diff --git a/WebKit/qt/Api/qwebelement.h b/WebKit/qt/Api/qwebelement.h
new file mode 100644
index 0000000..bc6f8a9
--- /dev/null
+++ b/WebKit/qt/Api/qwebelement.h
@@ -0,0 +1,152 @@
+/*
+ Copyright (C) 2009 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 QWEBELEMENT_H
+#define QWEBELEMENT_H
+
+#include <QString>
+#include <QRect>
+#include <QVariant>
+#include <QExplicitlySharedDataPointer>
+
+#include "qwebkitglobal.h"
+namespace WebCore {
+ class Element;
+ class Node;
+}
+
+class QWebFrame;
+class QWebElementPrivate;
+
+class QWEBKIT_EXPORT QWebElement {
+public:
+ QWebElement();
+ QWebElement(const QWebElement&);
+ QWebElement &operator=(const QWebElement&);
+ ~QWebElement();
+
+ bool operator==(const QWebElement& o) const;
+ bool operator!=(const QWebElement& o) const;
+
+ bool isNull() const;
+
+ QList<QWebElement> findAll(const QString& selectorQuery) const;
+ QWebElement findFirst(const QString& selectorQuery) const;
+
+ void setPlainText(const QString& text);
+ QString toPlainText() const;
+
+ void setOuterXml(const QString& markup);
+ QString toOuterXml() const;
+
+ void setInnerXml(const QString& markup);
+ QString toInnerXml() const;
+
+ void setAttribute(const QString& name, const QString& value);
+ void setAttributeNS(const QString& namespaceUri, const QString& name, const QString& value);
+ QString attribute(const QString& name, const QString& defaultValue = QString()) const;
+ QString attributeNS(const QString& namespaceUri, const QString& name, const QString& defaultValue = QString()) const;
+ bool hasAttribute(const QString& name) const;
+ bool hasAttributeNS(const QString& namespaceUri, const QString& name) const;
+ void removeAttribute(const QString& name);
+ void removeAttributeNS(const QString& namespaceUri, const QString& name);
+ bool hasAttributes() const;
+
+ QStringList classes() const;
+ bool hasClass(const QString& name) const;
+ void addClass(const QString& name);
+ void removeClass(const QString& name);
+ void toggleClass(const QString& name);
+
+ QRect geometry() const;
+
+ QString tagName() const;
+ QString prefix() const;
+ QString localName() const;
+ QString namespaceUri() const;
+
+ QWebElement parent() const;
+ QWebElement firstChild() const;
+ QWebElement lastChild() const;
+ QWebElement nextSibling() const;
+ QWebElement previousSibling() const;
+ QWebElement document() const;
+ QWebFrame *webFrame() const;
+
+ // TODO: Add QList<QWebElement> overloads
+ // docs need example snippet
+ void appendInside(const QString& markup);
+ void appendInside(const QWebElement& element);
+
+ // docs need example snippet
+ void prependInside(const QString& markup);
+ void prependInside(const QWebElement& element);
+
+ // docs need example snippet
+ void appendOutside(const QString& markup);
+ void appendOutside(const QWebElement& element);
+
+ // docs need example snippet
+ void prependOutside(const QString& markup);
+ void prependOutside(const QWebElement& element);
+
+ // docs need example snippet
+ void encloseContentsWith(const QWebElement& element);
+ void encloseContentsWith(const QString& markup);
+ void encloseWith(const QString& markup);
+ void encloseWith(const QWebElement& element);
+
+ void replace(const QString& markup);
+ void replace(const QWebElement& element);
+
+ QWebElement clone() const;
+ QWebElement& takeFromDocument();
+ void removeFromDocument();
+ void removeChildren();
+
+ QVariant evaluateScript(const QString& scriptSource);
+
+ QVariant callFunction(const QString& functionName, const QVariantList& arguments = QVariantList());
+ QStringList functions() const;
+
+ QVariant scriptableProperty(const QString& name) const;
+ void setScriptableProperty(const QString& name, const QVariant& value);
+ QStringList scriptableProperties() const;
+
+ enum ResolveRule { IgnoreCascadingStyles, RespectCascadingStyles };
+ QString styleProperty(const QString& name, ResolveRule = IgnoreCascadingStyles) const;
+
+ enum StylePriority { NormalStylePriority, DeclaredStylePriority, ImportantStylePriority };
+ void setStyleProperty(const QString& name, const QString& value, StylePriority = DeclaredStylePriority);
+
+ QString computedStyleProperty(const QString& name) const;
+
+private:
+ explicit QWebElement(WebCore::Element*);
+ explicit QWebElement(WebCore::Node*);
+
+ friend class QWebFrame;
+ friend class QWebHitTestResult;
+ friend class QWebHitTestResultPrivate;
+
+ QWebElementPrivate* d;
+ WebCore::Element* m_element;
+};
+
+#endif // QWEBELEMENT_H
diff --git a/WebKit/qt/Api/qwebframe.cpp b/WebKit/qt/Api/qwebframe.cpp
index 725a880..c857df2 100644
--- a/WebKit/qt/Api/qwebframe.cpp
+++ b/WebKit/qt/Api/qwebframe.cpp
@@ -20,72 +20,71 @@
#include "config.h"
#include "qwebframe.h"
-#include "qwebpage.h"
-#include "qwebpage_p.h"
-#include "qwebframe_p.h"
-#include "qwebsecurityorigin.h"
-#include "qwebsecurityorigin_p.h"
+#include "CallFrame.h"
+#include "Document.h"
#include "DocumentLoader.h"
+#include "DragData.h"
+#include "Element.h"
#include "FocusController.h"
-#include "FrameLoaderClientQt.h"
#include "Frame.h"
+#include "FrameLoaderClientQt.h"
#include "FrameTree.h"
#include "FrameView.h"
+#include "GCController.h"
+#include "GraphicsContext.h"
+#include "HTMLMetaElement.h"
+#include "HitTestResult.h"
#include "IconDatabase.h"
#include "InspectorController.h"
+#include "JSDOMBinding.h"
+#include "JSDOMWindowBase.h"
+#include "JSLock.h"
+#include "JSObject.h"
+#include "NodeList.h"
#include "Page.h"
+#include "PlatformMouseEvent.h"
+#include "PlatformWheelEvent.h"
+#include "PrintContext.h"
#include "PutPropertySlot.h"
-#include "ResourceRequest.h"
+#include "RenderTreeAsText.h"
#include "RenderView.h"
-#include "SelectionController.h"
+#include "ResourceRequest.h"
+#include "ScriptController.h"
+#include "ScriptSourceCode.h"
+#include "ScriptValue.h"
#include "Scrollbar.h"
-#include "PrintContext.h"
+#include "SelectionController.h"
#include "SubstituteData.h"
-
-#include "markup.h"
#include "htmlediting.h"
-#include "RenderTreeAsText.h"
-#include "Element.h"
-#include "Document.h"
-#include "DragData.h"
-#include "RenderView.h"
-#include "GraphicsContext.h"
-#include "PlatformMouseEvent.h"
-#include "PlatformWheelEvent.h"
-#include "GraphicsContext.h"
-#include "HitTestResult.h"
-
-#include "CallFrame.h"
-#include "JSDOMBinding.h"
-#include "JSDOMWindow.h"
-#include "JSLock.h"
-#include "JSObject.h"
+#include "markup.h"
#include "qt_instance.h"
#include "qt_runtime.h"
+#include "qwebelement.h"
+#include "qwebframe_p.h"
+#include "qwebpage.h"
+#include "qwebpage_p.h"
+#include "qwebsecurityorigin.h"
+#include "qwebsecurityorigin_p.h"
#include "runtime.h"
#include "runtime_object.h"
#include "runtime_root.h"
-#include "ScriptController.h"
-#include "ScriptSourceCode.h"
-#include "ScriptValue.h"
-
#include "wtf/HashMap.h"
-
+#include <QMultiMap>
#include <qdebug.h>
#include <qevent.h>
#include <qfileinfo.h>
#include <qpainter.h>
-#include <QMultiMap>
+#include <qprinter.h>
+#include <qregion.h>
+
+#if QT_VERSION < 0x040400
+#include "qwebnetworkinterface.h"
+#endif
+
#if QT_VERSION >= 0x040400
#include <qnetworkrequest.h>
-#else
-#include "qwebnetworkinterface.h"
#endif
-#include <qregion.h>
-#include <qprinter.h>
-#include "HTMLMetaElement.h"
-#include "NodeList.h"
using namespace WebCore;
@@ -96,6 +95,7 @@ QT_END_NAMESPACE
void QWEBKIT_EXPORT qt_drt_setJavaScriptProfilingEnabled(QWebFrame* qframe, bool enabled)
{
+#if ENABLE(JAVASCRIPT_DEBUGGER)
Frame* frame = QWebFramePrivate::core(qframe);
InspectorController* controller = frame->page()->inspectorController();
if (!controller)
@@ -104,6 +104,7 @@ void QWEBKIT_EXPORT qt_drt_setJavaScriptProfilingEnabled(QWebFrame* qframe, bool
controller->enableProfiler();
else
controller->disableProfiler();
+#endif
}
// Pause a given CSS animation or transition on the target node at a specific time.
@@ -163,27 +164,56 @@ int QWEBKIT_EXPORT qt_drt_numberOfActiveAnimations(QWebFrame *qframe)
return controller->numberOfActiveAnimations();
}
-void QWebFramePrivate::init(QWebFrame *qframe, WebCore::Page *webcorePage, QWebFrameData *frameData)
+void QWEBKIT_EXPORT qt_drt_clearFrameName(QWebFrame* qFrame)
{
- q = qframe;
+ Frame* frame = QWebFramePrivate::core(qFrame);
+ frame->tree()->clearName();
+}
- allowsScrolling = frameData->allowsScrolling;
- marginWidth = frameData->marginWidth;
- marginHeight = frameData->marginHeight;
+int QWEBKIT_EXPORT qt_drt_javaScriptObjectsCount()
+{
+ return JSDOMWindowBase::commonJSGlobalData()->heap.globalObjectCount();
+}
+void QWEBKIT_EXPORT qt_drt_garbageCollector_collect()
+{
+ gcController().garbageCollectNow();
+}
+
+void QWEBKIT_EXPORT qt_drt_garbageCollector_collectOnAlternateThread(bool waitUntilDone)
+{
+ gcController().garbageCollectOnAlternateThreadForDebugging(waitUntilDone);
+}
+
+QWebFrameData::QWebFrameData(WebCore::Page* parentPage, WebCore::Frame* parentFrame,
+ WebCore::HTMLFrameOwnerElement* ownerFrameElement,
+ const WebCore::String& frameName)
+ : name(frameName)
+ , ownerElement(ownerFrameElement)
+ , page(parentPage)
+ , allowsScrolling(true)
+ , marginWidth(0)
+ , marginHeight(0)
+{
frameLoaderClient = new FrameLoaderClientQt();
- RefPtr<Frame> newFrame = Frame::create(webcorePage, frameData->ownerElement, frameLoaderClient);
- frame = newFrame.get();
- frameLoaderClient->setFrame(qframe, frame);
+ frame = Frame::create(page, ownerElement, frameLoaderClient);
// FIXME: All of the below should probably be moved over into WebCore
- frame->tree()->setName(frameData->name);
- if (QWebFrame* _parentFrame = parentFrame())
- QWebFramePrivate::core(_parentFrame)->tree()->appendChild(frame);
+ frame->tree()->setName(name);
+ if (parentFrame)
+ parentFrame->tree()->appendChild(frame);
+}
+
+void QWebFramePrivate::init(QWebFrame *qframe, QWebFrameData *frameData)
+{
+ q = qframe;
- // balanced by adoptRef in FrameLoaderClientQt::createFrame
- if (frameData->ownerElement)
- frame->ref();
+ allowsScrolling = frameData->allowsScrolling;
+ marginWidth = frameData->marginWidth;
+ marginHeight = frameData->marginHeight;
+ frame = frameData->frame.get();
+ frameLoaderClient = frameData->frameLoaderClient;
+ frameLoaderClient->setFrame(qframe, frame);
frame->init();
}
@@ -202,7 +232,7 @@ WebCore::Scrollbar* QWebFramePrivate::verticalScrollBar() const
return frame->view()->verticalScrollbar();
}
-void QWebFramePrivate::renderPrivate(QPainter *painter, const QRegion &clip, bool contents)
+void QWebFramePrivate::renderPrivate(QPainter *painter, const QRegion &clip)
{
if (!frame->view() || !frame->contentRenderer())
return;
@@ -216,7 +246,7 @@ void QWebFramePrivate::renderPrivate(QPainter *painter, const QRegion &clip, boo
GraphicsContext context(painter);
- if (!contents)
+ if (clipRenderToViewport)
view->paint(&context, vector.first());
else
view->paintContents(&context, vector.first());
@@ -225,7 +255,7 @@ void QWebFramePrivate::renderPrivate(QPainter *painter, const QRegion &clip, boo
const QRect& clipRect = vector.at(i);
painter->save();
painter->setClipRect(clipRect, Qt::IntersectClip);
- if (!contents)
+ if (clipRenderToViewport)
view->paint(&context, clipRect);
else
view->paintContents(&context, clipRect);
@@ -250,6 +280,13 @@ void QWebFramePrivate::renderPrivate(QPainter *painter, const QRegion &clip, boo
\l{Elements of QWebView} for an explanation of how web
frames are related to a web page and web view.
+ The QWebFrame class also offers methods to retrieve both the URL currently
+ loaded by the frame (see url()) as well as the URL originally requested
+ to be loaded (see requestedUrl()). These methods make possible the retrieval
+ of the URL before and after a DNS resolution or a redirection occurs during
+ the load process. The requestedUrl() also matches to the URL added to the
+ frame history (\l{QWebHistory}) if load is successful.
+
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
@@ -277,7 +314,7 @@ QWebFrame::QWebFrame(QWebPage *parent, QWebFrameData *frameData)
, d(new QWebFramePrivate)
{
d->page = parent;
- d->init(this, parent->d->page, frameData);
+ d->init(this, frameData);
if (!frameData->url.isEmpty()) {
WebCore::ResourceRequest request(frameData->url, frameData->referrer);
@@ -290,7 +327,7 @@ QWebFrame::QWebFrame(QWebFrame *parent, QWebFrameData *frameData)
, d(new QWebFramePrivate)
{
d->page = parent->d->page;
- d->init(this, parent->d->page->d->page, frameData);
+ d->init(this, frameData);
}
QWebFrame::~QWebFrame()
@@ -313,6 +350,8 @@ QWebFrame::~QWebFrame()
new URL, you should add them in a slot connected to the
javaScriptWindowObjectCleared() signal.
+ If Javascript is not enabled for this page, then this method does nothing.
+
The \a object will never be explicitly deleted by QtWebKit.
*/
void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object)
@@ -335,11 +374,16 @@ void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object
new URL, you should add them in a slot connected to the
javaScriptWindowObjectCleared() signal.
+ If Javascript is not enabled for this page, then this method does nothing.
+
The ownership of \a object is specified using \a own.
*/
void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object, QScriptEngine::ValueOwnership ownership)
{
- JSC::JSLock lock(false);
+ if (!page()->settings()->testAttribute(QWebSettings::JavascriptEnabled))
+ return;
+
+ JSC::JSLock lock(JSC::SilenceAssertionsOnly);
JSDOMWindow* window = toJSDOMWindow(d->frame);
JSC::Bindings::RootObject* root = d->frame->script()->bindingRootObject();
if (!window) {
@@ -357,7 +401,7 @@ void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object
}
/*!
- Returns the frame's content, converted to HTML.
+ Returns the frame's content as HTML, enclosed in HTML and BODY tags.
\sa setHtml(), toPlainText()
*/
@@ -369,7 +413,8 @@ QString QWebFrame::toHtml() const
}
/*!
- Returns the content of this frame converted to plain text.
+ Returns the content of this frame converted to plain text, completely
+ stripped of all HTML formatting.
\sa toHtml()
*/
@@ -405,7 +450,7 @@ QString QWebFrame::title() const
{
if (d->frame->document())
return d->frame->loader()->documentLoader()->title();
- else return QString();
+ return QString();
}
/*!
@@ -441,10 +486,10 @@ QString QWebFrame::title() const
*/
QMultiMap<QString, QString> QWebFrame::metaData() const
{
- if(!d->frame->document())
- return QMap<QString,QString>();
+ if (!d->frame->document())
+ return QMap<QString, QString>();
- QMultiMap<QString,QString> map;
+ QMultiMap<QString, QString> map;
Document* doc = d->frame->document();
RefPtr<NodeList> list = doc->getElementsByTagName("meta");
unsigned len = list->length();
@@ -483,6 +528,39 @@ QUrl QWebFrame::url() const
}
/*!
+ \since 4.6
+ \property QWebFrame::requestedUrl
+
+ The URL requested to loaded by the frame currently viewed. The URL may differ from
+ the one returned by url() if a DNS resolution or a redirection occurs.
+
+ \sa url(), setUrl()
+*/
+QUrl QWebFrame::requestedUrl() const
+{
+ // In the following edge cases (where the failing document
+ // loader does not get commited by the frame loader) it is
+ // safer to rely on outgoingReferrer than originalRequest.
+ if (!d->frame->loader()->activeDocumentLoader()
+ || (!d->frameLoaderClient->m_loadSucceeded
+ && !d->frame->loader()->outgoingReferrer().isEmpty()))
+ return QUrl(d->frame->loader()->outgoingReferrer());
+
+ return d->frame->loader()->originalRequest().url();
+}
+/*!
+ \since 4.6
+ \property QWebFrame::baseUrl
+ \brief the base URL of the frame, can be used to resolve relative URLs
+ \since 4.6
+*/
+
+QUrl QWebFrame::baseUrl() const
+{
+ return d->frame->loader()->baseURL();
+}
+
+/*!
\property QWebFrame::icon
\brief the icon associated with this frame
@@ -623,6 +701,8 @@ 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, such as referenced images or stylesheets.
+ The \a html is loaded immediately; external objects are loaded asynchronously.
+
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
@@ -647,6 +727,8 @@ void QWebFrame::setHtml(const QString &html, const QUrl &baseUrl)
External objects referenced in the content are located relative to \a baseUrl.
+ The \a data is loaded immediately; external objects are loaded asynchronously.
+
\sa toHtml()
*/
void QWebFrame::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
@@ -762,9 +844,8 @@ int QWebFrame::scrollBarValue(Qt::Orientation orientation) const
{
Scrollbar *sb;
sb = (orientation == Qt::Horizontal) ? d->horizontalScrollBar() : d->verticalScrollBar();
- if (sb) {
+ if (sb)
return sb->value();
- }
return 0;
}
@@ -814,7 +895,7 @@ QRect QWebFrame::scrollBarGeometry(Qt::Orientation orientation) const
\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::scrollPosition
*/
@@ -822,7 +903,7 @@ void QWebFrame::scroll(int dx, int dy)
{
if (!d->frame->view())
return;
-
+
d->frame->view()->scrollBy(IntSize(dx, dy));
}
@@ -835,7 +916,7 @@ void QWebFrame::scroll(int dx, int dy)
QPoint QWebFrame::scrollPosition() const
{
if (!d->frame->view())
- return QPoint(0,0);
+ return QPoint(0, 0);
IntSize ofs = d->frame->view()->scrollOffset();
return QPoint(ofs.width(), ofs.height());
@@ -871,12 +952,23 @@ void QWebFrame::render(QPainter *painter)
}
/*!
- \since 4.6
- Render the frame's \a contents into \a painter while clipping to \a contents.
+ \since 4.6
+ \property QWebFrame::clipRenderToViewport
+
+ Returns true if render will clip content to viewport; otherwise returns false.
+*/
+bool QWebFrame::clipRenderToViewport() const
+{
+ return d->clipRenderToViewport;
+}
+
+/*!
+ \since 4.6
+ Sets whether the content of a frame will be clipped to viewport when rendered.
*/
-void QWebFrame::renderContents(QPainter *painter, const QRegion &contents)
+void QWebFrame::setClipRenderToViewport(bool clipRenderToViewport)
{
- d->renderPrivate(painter, contents, true);
+ d->clipRenderToViewport = clipRenderToViewport;
}
/*!
@@ -925,6 +1017,27 @@ qreal QWebFrame::zoomFactor() const
}
/*!
+ \property QWebFrame::focus
+ \since 4.6
+
+ Returns true if this frame has keyboard input focus; otherwise, returns false.
+*/
+bool QWebFrame::hasFocus() const
+{
+ return QWebFramePrivate::kit(d->frame->page()->focusController()->focusedFrame()) == this;
+}
+
+/*!
+ \since 4.6
+
+ Gives keyboard input focus to this frame.
+*/
+void QWebFrame::setFocus()
+{
+ QWebFramePrivate::core(this)->page()->focusController()->setFocusedFrame(QWebFramePrivate::core(this));
+}
+
+/*!
Returns the position of the frame relative to it's parent frame.
*/
QPoint QWebFrame::pos() const
@@ -949,7 +1062,7 @@ QRect QWebFrame::geometry() const
\property QWebFrame::contentsSize
\brief the size of the contents in this frame
- \sa contentsSizeChanged
+ \sa contentsSizeChanged()
*/
QSize QWebFrame::contentsSize() const
{
@@ -960,6 +1073,53 @@ QSize QWebFrame::contentsSize() const
}
/*!
+ \since 4.6
+
+ Returns the document element of this frame.
+
+ The document element provides access to the entire structured
+ content of the frame.
+*/
+QWebElement QWebFrame::documentElement() const
+{
+ WebCore::Document *doc = d->frame->document();
+ if (!doc)
+ return QWebElement();
+ return QWebElement(doc->documentElement());
+}
+
+/*!
+ \since 4.6
+ Returns a new list of elements matching the given CSS selector \a selectorQuery.
+ If there are no matching elements, an empty list is returned.
+
+ \l{http://www.w3.org/TR/REC-CSS2/selector.html#q1}{Standard CSS2 selector} syntax is
+ used for the query.
+
+ \sa QWebElement::findAll()
+*/
+QList<QWebElement> QWebFrame::findAllElements(const QString &selectorQuery) const
+{
+ return documentElement().findAll(selectorQuery);
+}
+
+/*!
+ \since 4.6
+ Returns the first element in the frame's document that matches the
+ given CSS selector \a selectorQuery. If there is no matching element, a
+ null element is returned.
+
+ \l{http://www.w3.org/TR/REC-CSS2/selector.html#q1}{Standard CSS2 selector} syntax is
+ used for the query.
+
+ \sa QWebElement::findFirst()
+*/
+QWebElement QWebFrame::findFirstElement(const QString &selectorQuery) const
+{
+ return documentElement().findFirst(selectorQuery);
+}
+
+/*!
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
@@ -968,6 +1128,10 @@ QWebHitTestResult QWebFrame::hitTestContent(const QPoint &pos) const
return QWebHitTestResult();
HitTestResult result = d->frame->eventHandler()->hitTestResultAtPoint(d->frame->view()->windowToContents(pos), /*allowShadowContent*/ false, /*ignoreClipping*/ true);
+
+ if (result.scrollbar())
+ return QWebHitTestResult();
+
return QWebHitTestResult(new QWebHitTestResultPrivate(result));
}
@@ -1004,11 +1168,11 @@ void QWebFrame::print(QPrinter *printer) const
printContext.begin(pageRect.width());
- printContext.computePageRects(pageRect, /*headerHeight*/0, /*footerHeight*/0, /*userScaleFactor*/1.0, pageHeight);
+ printContext.computePageRects(pageRect, /* headerHeight */ 0, /* footerHeight */ 0, /* userScaleFactor */ 1.0, pageHeight);
int docCopies;
int pageCopies;
- if (printer->collateCopies() == true){
+ if (printer->collateCopies()) {
docCopies = 1;
pageCopies = printer->numCopies();
} else {
@@ -1082,11 +1246,9 @@ QVariant QWebFrame::evaluateJavaScript(const QString& scriptSource)
ScriptController *proxy = d->frame->script();
QVariant rc;
if (proxy) {
- JSC::JSValuePtr v = proxy->evaluate(ScriptSourceCode(scriptSource)).jsValue();
- if (v) {
- int distance = 0;
- rc = JSC::Bindings::convertValueToQVariant(proxy->globalObject()->globalExec(), v, QMetaType::Void, &distance);
- }
+ JSC::JSValue v = proxy->evaluate(ScriptSourceCode(scriptSource)).jsValue();
+ int distance = 0;
+ rc = JSC::Bindings::convertValueToQVariant(proxy->globalObject()->globalExec(), v, QMetaType::Void, &distance);
}
return rc;
}
@@ -1171,12 +1333,32 @@ QWebFrame* QWebFramePrivate::kit(WebCore::Frame* coreFrame)
\fn void QWebFrame::contentsSizeChanged(const QSize &size)
\since 4.6
- This signal is emitted when the frame's contents size changes.
+ This signal is emitted when the frame's contents size changes
+ to \a size.
\sa contentsSize()
*/
/*!
+ \fn void QWebFrame::loadStarted()
+ \since 4.6
+
+ This signal is emitted when a new load of this frame is started.
+
+ \sa loadFinished()
+*/
+
+/*!
+ \fn void QWebFrame::loadFinished(bool ok)
+ \since 4.6
+
+ This signal is emitted when a load of this frame is finished.
+ \a ok will indicate whether the load was successful or any error occurred.
+
+ \sa loadStarted()
+*/
+
+/*!
\class QWebHitTestResult
\since 4.4
\brief The QWebHitTestResult class provides information about the web
@@ -1203,7 +1385,8 @@ QWebHitTestResultPrivate::QWebHitTestResultPrivate(const WebCore::HitTestResult
return;
pos = hitTest.point();
boundingRect = hitTest.boundingBox();
- title = hitTest.title();
+ WebCore::TextDirection dir;
+ title = hitTest.title(dir);
linkText = hitTest.textContent();
linkUrl = hitTest.absoluteLinkURL();
linkTitle = hitTest.titleDisplayString();
@@ -1220,9 +1403,7 @@ QWebHitTestResultPrivate::QWebHitTestResultPrivate(const WebCore::HitTestResult
WebCore::Frame *wframe = hitTest.targetFrame();
if (wframe)
linkTargetFrame = QWebFramePrivate::kit(wframe);
- Element* urlElement = hitTest.URLElement();
- if (urlElement)
- linkTarget = urlElement->target();
+ linkElement = QWebElement(hitTest.URLElement());
isContentEditable = hitTest.isContentEditable();
isContentSelected = hitTest.isSelected();
@@ -1232,14 +1413,7 @@ QWebHitTestResultPrivate::QWebHitTestResultPrivate(const WebCore::HitTestResult
&& innerNonSharedNode->document()->frame())
frame = QWebFramePrivate::kit(innerNonSharedNode->document()->frame());
- if (Node *block = WebCore::enclosingBlock(innerNode.get())) {
- RenderObject *renderBlock = block->renderer();
- while (renderBlock && renderBlock->isListItem())
- renderBlock = renderBlock->containingBlock();
-
- if (renderBlock)
- enclosingBlock = renderBlock->absoluteClippedOverflowRect();
- }
+ enclosingBlock = QWebElement(WebCore::enclosingBlock(innerNode.get()));
}
/*!
@@ -1317,12 +1491,16 @@ QRect QWebHitTestResult::boundingRect() const
/*!
\since 4.6
- Returns the rect of the smallest enclosing block element.
+ Returns the block element that encloses the element hit.
+
+ A block element is an element that is rendered using the
+ CSS "block" style. This includes for example text
+ paragraphs.
*/
-QRect QWebHitTestResult::enclosingBlock() const
+QWebElement QWebHitTestResult::enclosingBlockElement() const
{
if (!d)
- return QRect();
+ return QWebElement();
return d->enclosingBlock;
}
@@ -1368,21 +1546,21 @@ QUrl QWebHitTestResult::linkTitle() const
/*!
\since 4.6
- Returns the name of the target frame that will load the link if it is activated.
+ Returns the element that represents the link.
- \sa linkTargetFrame
+ \sa linkTargetFrame()
*/
-QString QWebHitTestResult::linkTarget() const
+QWebElement QWebHitTestResult::linkElement() const
{
if (!d)
- return 0;
- return d->linkTarget;
+ return QWebElement();
+ return d->linkElement;
}
/*!
Returns the frame that will load the link if it is activated.
- \sa linkTarget
+ \sa linkElement()
*/
QWebFrame *QWebHitTestResult::linkTargetFrame() const
{
@@ -1443,22 +1621,24 @@ bool QWebHitTestResult::isContentSelected() const
}
/*!
- Returns the frame the hit test was executed in.
+ \since 4.6
+ Returns the underlying DOM element as QWebElement.
*/
-QWebFrame *QWebHitTestResult::frame() const
+QWebElement QWebHitTestResult::element() const
{
- if (!d)
- return 0;
- return d->frame;
+ if (!d || !d->innerNonSharedNode || !d->innerNonSharedNode->isElementNode())
+ return QWebElement();
+
+ return QWebElement(static_cast<WebCore::Element*>(d->innerNonSharedNode.get()));
}
/*!
- \since 4.6
- Returns true if the test includes a scrollbar.
+ Returns the frame the hit test was executed in.
*/
-bool QWebHitTestResult::isScrollBar() const
+QWebFrame *QWebHitTestResult::frame() const
{
if (!d)
- return false;
- return d->isScrollBar;
+ return 0;
+ return d->frame;
}
+
diff --git a/WebKit/qt/Api/qwebframe.h b/WebKit/qt/Api/qwebframe.h
index d0fa193..55c73b4 100644
--- a/WebKit/qt/Api/qwebframe.h
+++ b/WebKit/qt/Api/qwebframe.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2008,2009 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
@@ -49,6 +49,7 @@ class QWebPage;
class QWebHitTestResult;
class QWebHistoryItem;
class QWebSecurityOrigin;
+class QWebElement;
namespace WebCore {
class WidgetPrivate;
@@ -59,8 +60,7 @@ class QWebFrameData;
class QWebHitTestResultPrivate;
class QWebFrame;
-class QWEBKIT_EXPORT QWebHitTestResult
-{
+class QWEBKIT_EXPORT QWebHitTestResult {
public:
QWebHitTestResult();
QWebHitTestResult(const QWebHitTestResult &other);
@@ -71,14 +71,14 @@ public:
QPoint pos() const;
QRect boundingRect() const;
- QRect enclosingBlock() const;
+ QWebElement enclosingBlockElement() const;
QString title() const;
QString linkText() const;
QUrl linkUrl() const;
QUrl linkTitle() const;
QWebFrame *linkTargetFrame() const;
- QString linkTarget() const;
+ QWebElement linkElement() const;
QString alternateText() const; // for img, area, input and applet
@@ -88,9 +88,9 @@ public:
bool isContentEditable() const;
bool isContentSelected() const;
- QWebFrame *frame() const;
+ QWebElement element() const;
- bool isScrollBar() const;
+ QWebFrame *frame() const;
private:
QWebHitTestResult(QWebHitTestResultPrivate *priv);
@@ -101,16 +101,19 @@ private:
friend class QWebPage;
};
-class QWEBKIT_EXPORT QWebFrame : public QObject
-{
+class QWEBKIT_EXPORT QWebFrame : public QObject {
Q_OBJECT
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(QUrl requestedUrl READ requestedUrl)
+ Q_PROPERTY(QUrl baseUrl READ baseUrl)
Q_PROPERTY(QIcon icon READ icon)
Q_PROPERTY(QSize contentsSize READ contentsSize)
Q_PROPERTY(QPoint scrollPosition READ scrollPosition WRITE setScrollPosition)
+ Q_PROPERTY(bool clipRenderToViewport READ clipRenderToViewport WRITE setClipRenderToViewport)
+ Q_PROPERTY(bool focus READ hasFocus)
private:
QWebFrame(QWebPage *parent, QWebFrameData *frameData);
QWebFrame(QWebFrame *parent, QWebFrameData *frameData);
@@ -139,6 +142,8 @@ public:
QString title() const;
void setUrl(const QUrl &url);
QUrl url() const;
+ QUrl requestedUrl() const;
+ QUrl baseUrl() const;
QIcon icon() const;
QMultiMap<QString, QString> metaData() const;
@@ -162,7 +167,8 @@ public:
void render(QPainter *painter, const QRegion &clip);
void render(QPainter *painter);
- void renderContents(QPainter *painter, const QRegion &contents);
+ bool clipRenderToViewport() const;
+ void setClipRenderToViewport(bool clipRenderToViewport);
void setTextSizeMultiplier(qreal factor);
qreal textSizeMultiplier() const;
@@ -170,10 +176,17 @@ public:
qreal zoomFactor() const;
void setZoomFactor(qreal factor);
+ bool hasFocus() const;
+ void setFocus();
+
QPoint pos() const;
QRect geometry() const;
QSize contentsSize() const;
+ QWebElement documentElement() const;
+ QList<QWebElement> findAllElements(const QString &selectorQuery) const;
+ QWebElement findFirstElement(const QString &selectorQuery) const;
+
QWebHitTestResult hitTestContent(const QPoint &pos) const;
virtual bool event(QEvent *);
@@ -199,6 +212,9 @@ Q_SIGNALS:
void contentsSizeChanged(const QSize &size);
+ void loadStarted();
+ void loadFinished(bool ok);
+
private:
friend class QWebPage;
friend class QWebPagePrivate;
diff --git a/WebKit/qt/Api/qwebframe_p.h b/WebKit/qt/Api/qwebframe_p.h
index c541cd3..d6afc01 100644
--- a/WebKit/qt/Api/qwebframe_p.h
+++ b/WebKit/qt/Api/qwebframe_p.h
@@ -27,11 +27,11 @@
#include "EventHandler.h"
#include "KURL.h"
#include "PlatformString.h"
+#include "qwebelement.h"
#include "wtf/RefPtr.h"
#include "Frame.h"
-namespace WebCore
-{
+namespace WebCore {
class FrameLoaderClientQt;
class FrameView;
class HTMLFrameOwnerElement;
@@ -39,13 +39,18 @@ namespace WebCore
}
class QWebPage;
-
-class QWebFrameData
-{
+class QWebFrameData {
public:
+ QWebFrameData(WebCore::Page*, WebCore::Frame* parentFrame = 0,
+ WebCore::HTMLFrameOwnerElement* = 0,
+ const WebCore::String& frameName = WebCore::String());
+
WebCore::KURL url;
WebCore::String name;
WebCore::HTMLFrameOwnerElement* ownerElement;
+ WebCore::Page* page;
+ RefPtr<WebCore::Frame> frame;
+ WebCore::FrameLoaderClientQt* frameLoaderClient;
WebCore::String referrer;
bool allowsScrolling;
@@ -53,8 +58,7 @@ public:
int marginHeight;
};
-class QWebFramePrivate
-{
+class QWebFramePrivate {
public:
QWebFramePrivate()
: q(0)
@@ -66,9 +70,9 @@ public:
, allowsScrolling(true)
, marginWidth(-1)
, marginHeight(-1)
+ , clipRenderToViewport(true)
{}
- void init(QWebFrame *qframe, WebCore::Page *page,
- QWebFrameData *frameData);
+ void init(QWebFrame* qframe, QWebFrameData* frameData);
inline QWebFrame *parentFrame() { return qobject_cast<QWebFrame*>(q->parent()); }
@@ -76,12 +80,12 @@ public:
WebCore::Scrollbar* verticalScrollBar() const;
Qt::ScrollBarPolicy horizontalScrollBarPolicy;
- Qt::ScrollBarPolicy verticalScrollBarPolicy;
+ Qt::ScrollBarPolicy verticalScrollBarPolicy;
static WebCore::Frame* core(QWebFrame*);
static QWebFrame* kit(WebCore::Frame*);
- void renderPrivate(QPainter *painter, const QRegion &clip, bool contents = false);
+ void renderPrivate(QPainter *painter, const QRegion &clip);
QWebFrame *q;
WebCore::FrameLoaderClientQt *frameLoaderClient;
@@ -91,23 +95,23 @@ public:
bool allowsScrolling;
int marginWidth;
int marginHeight;
+ bool clipRenderToViewport;
};
-class QWebHitTestResultPrivate
-{
+class QWebHitTestResultPrivate {
public:
QWebHitTestResultPrivate() : isContentEditable(false), isContentSelected(false), isScrollBar(false) {}
QWebHitTestResultPrivate(const WebCore::HitTestResult &hitTest);
QPoint pos;
QRect boundingRect;
- QRect enclosingBlock;
+ QWebElement enclosingBlock;
QString title;
QString linkText;
QUrl linkUrl;
QString linkTitle;
QPointer<QWebFrame> linkTargetFrame;
- QString linkTarget;
+ QWebElement linkElement;
QString alternateText;
QUrl imageUrl;
QPixmap pixmap;
diff --git a/WebKit/qt/Api/qwebhistory.cpp b/WebKit/qt/Api/qwebhistory.cpp
index 07d027d..1c1c72a 100644
--- a/WebKit/qt/Api/qwebhistory.cpp
+++ b/WebKit/qt/Api/qwebhistory.cpp
@@ -28,10 +28,10 @@
#include "PageGroup.h"
#include <QSharedData>
+#include <QDebug>
/*!
\class QWebHistoryItem
- \ingroup explicitly-shared
\since 4.4
\brief The QWebHistoryItem class represents one item in the history of a QWebPage
@@ -51,13 +51,17 @@
\row \o userData() \o The user specific data that was stored with the history item.
\endtable
- \note QWebHistoryItem objects are value based and \l{explicitly shared}.
+ \note QWebHistoryItem objects are value based, but \e{explicitly shared}. Changing
+ a QWebHistoryItem instance by calling setUserData() will change all copies of that
+ instance.
\sa QWebHistory, QWebPage::history(), QWebHistoryInterface
*/
/*!
- Constructs a history item from \a other.
+ Constructs a history item from \a other. The new item and \a other
+ will share their data, and modifying either this item or \a other will
+ modify both instances.
*/
QWebHistoryItem::QWebHistoryItem(const QWebHistoryItem &other)
: d(other.d)
@@ -65,7 +69,9 @@ QWebHistoryItem::QWebHistoryItem(const QWebHistoryItem &other)
}
/*!
- Assigns the \a other history item to this.
+ Assigns the \a other history item to this. This item and \a other
+ will share their data, and modifying either this item or \a other will
+ modify both instances.
*/
QWebHistoryItem &QWebHistoryItem::operator=(const QWebHistoryItem &other)
{
@@ -162,6 +168,8 @@ QVariant QWebHistoryItem::userData() const
\since 4.5
Stores user specific data \a userData with the history item.
+
+ \note All copies of this item will be modified.
\sa userData()
*/
@@ -213,6 +221,8 @@ bool QWebHistoryItem::isValid() const
number of items is given by count(), and the history can be cleared with the
clear() function.
+ QWebHistory's state can be saved with saveState() and loaded with restoreState().
+
\sa QWebHistoryItem, QWebHistoryInterface, QWebPage
*/
@@ -236,7 +246,7 @@ void QWebHistory::clear()
{
RefPtr<WebCore::HistoryItem> current = d->lst->currentItem();
int capacity = d->lst->capacity();
- d->lst->setCapacity(0);
+ d->lst->setCapacity(0);
WebCore::Page* page = d->lst->page();
if (page && page->groupPtr())
@@ -405,9 +415,13 @@ int QWebHistory::currentItemIndex() const
*/
QWebHistoryItem QWebHistory::itemAt(int i) const
{
- WebCore::HistoryItem *item = d->lst->itemAtIndex(i);
-
- QWebHistoryItemPrivate *priv = new QWebHistoryItemPrivate(item);
+ QWebHistoryItemPrivate *priv;
+ if (i < 0 || i >= count())
+ priv = new QWebHistoryItemPrivate(0);
+ else {
+ WebCore::HistoryItem *item = d->lst->entries()[i].get();
+ priv = new QWebHistoryItemPrivate(item);
+ }
return QWebHistoryItem(priv);
}
@@ -441,3 +455,129 @@ void QWebHistory::setMaximumItemCount(int count)
d->lst->setCapacity(count);
}
+/*!
+ \enum QWebHistory::HistoryStateVersion
+
+ This enum describes the versions available for QWebHistory's saveState() function:
+
+ \value HistoryVersion_1 Version 1 (Qt 4.6)
+ \value DefaultHistoryVersion The current default version in 1.
+*/
+
+/*!
+ \since 4.6
+
+ Restores the state of QWebHistory from the given \a buffer. Returns true
+ if the history was successfully restored; otherwise returns false.
+
+ \sa saveState()
+*/
+bool QWebHistory::restoreState(const QByteArray& buffer)
+{
+ QDataStream stream(buffer);
+ int version;
+ bool result = false;
+ stream >> version;
+
+ switch (version) {
+ case HistoryVersion_1: {
+ int count;
+ int currentIndex;
+ stream >> count >> currentIndex;
+
+ clear();
+ // only if there are elements
+ if (count) {
+ // after clear() is new clear HistoryItem (at the end we had to remove it)
+ WebCore::HistoryItem *nullItem = d->lst->currentItem();
+ for (int i = 0;i < count;i++) {
+ WTF::PassRefPtr<WebCore::HistoryItem> item = WebCore::HistoryItem::create();
+ item->restoreState(stream, version);
+ d->lst->addItem(item);
+ }
+ d->lst->removeItem(nullItem);
+ goToItem(itemAt(currentIndex));
+ result = stream.status() == QDataStream::Ok;
+ }
+ break;
+ }
+ default: {} // result is false;
+ }
+
+ return result;
+};
+
+/*!
+ \since 4.6
+ Saves the state of this QWebHistory into a QByteArray.
+
+ Saves the current state of this QWebHistory. The version number, \a version, is
+ stored as part of the data.
+
+ To restore the saved state, pass the return value to restoreState().
+
+ \sa restoreState()
+*/
+QByteArray QWebHistory::saveState(HistoryStateVersion version) const
+{
+ QByteArray buffer;
+ QDataStream stream(&buffer, QIODevice::WriteOnly);
+ stream << version;
+
+ switch (version) {
+ case HistoryVersion_1: {
+ stream << count() << currentItemIndex();
+
+ const WebCore::HistoryItemVector &items = d->lst->entries();
+ for (int i = 0; i < items.size(); i++)
+ items[i].get()->saveState(stream, version);
+
+ if (stream.status() != QDataStream::Ok)
+ buffer = QByteArray(); // make buffer isNull()==true and isEmpty()==true
+ break;
+ }
+ default:
+ buffer.clear();
+
+ }
+
+ return buffer;
+}
+
+/*!
+ \since 4.6
+ \fn QDataStream& operator<<(QDataStream& stream, const QWebHistory& history)
+ \relates QWebHistory
+
+ Saves the given \a history into the specified \a stream. This is a convenience function
+ and is equivalent to calling the saveState() method.
+
+ \sa QWebHistory::saveState()
+*/
+
+QDataStream& operator<<(QDataStream& stream, const QWebHistory& history)
+{
+ return stream << history.saveState();
+}
+
+/*!
+ \fn QDataStream& operator>>(QDataStream& stream, QWebHistory& history)
+ \relates QWebHistory
+ \since 4.6
+
+ Loads a QWebHistory from the specified \a stream into the given \a history.
+ This is a convenience function and it is equivalent to calling the restoreState()
+ method.
+
+ \sa QWebHistory::restoreState()
+*/
+
+QDataStream& operator>>(QDataStream& stream, QWebHistory& history)
+{
+ QByteArray buffer;
+ stream >> buffer;
+ history.restoreState(buffer);
+ return stream;
+}
+
+
diff --git a/WebKit/qt/Api/qwebhistory.h b/WebKit/qt/Api/qwebhistory.h
index c39077d..e46f124 100644
--- a/WebKit/qt/Api/qwebhistory.h
+++ b/WebKit/qt/Api/qwebhistory.h
@@ -35,13 +35,16 @@ namespace WebCore {
}
class QWebHistoryItemPrivate;
-class QWEBKIT_EXPORT QWebHistoryItem
-{
+
+class QWEBKIT_EXPORT QWebHistoryItem {
public:
QWebHistoryItem(const QWebHistoryItem &other);
QWebHistoryItem &operator=(const QWebHistoryItem &other);
~QWebHistoryItem();
+ //bool restoreState(QByteArray& buffer);
+ //QByteArray saveState(QWebHistory::HistoryStateVersion version = DefaultHistoryVersion) const;
+
QUrl originalUrl() const;
QUrl url() const;
@@ -60,13 +63,28 @@ private:
friend class QWebHistory;
friend class QWebPage;
friend class WebCore::FrameLoaderClientQt;
+ friend class QWebHistoryItemPrivate;
+ //friend QDataStream & operator<<(QDataStream& out,const QWebHistoryItem& hist);
+ //friend QDataStream & operator>>(QDataStream& in,QWebHistoryItem& hist);
QExplicitlySharedDataPointer<QWebHistoryItemPrivate> d;
};
+//QWEBKIT_EXPORT QDataStream & operator<<(QDataStream& out,const QWebHistoryItem& hist);
+//QWEBKIT_EXPORT QDataStream & operator>>(QDataStream& in,QWebHistoryItem& hist);
+
+
class QWebHistoryPrivate;
-class QWEBKIT_EXPORT QWebHistory
-{
+class QWEBKIT_EXPORT QWebHistory {
public:
+ enum HistoryStateVersion {
+ HistoryVersion_1,
+ /*, HistoryVersion_2, */
+ DefaultHistoryVersion = HistoryVersion_1
+ };
+
+ bool restoreState(const QByteArray& buffer);
+ QByteArray saveState(HistoryStateVersion version = DefaultHistoryVersion) const;
+
void clear();
QList<QWebHistoryItem> items() const;
@@ -98,10 +116,15 @@ private:
friend class QWebPage;
friend class QWebPagePrivate;
+ friend QWEBKIT_EXPORT QDataStream& operator>>(QDataStream&, QWebHistory&);
+ friend QWEBKIT_EXPORT QDataStream& operator<<(QDataStream&, const QWebHistory&);
Q_DISABLE_COPY(QWebHistory)
QWebHistoryPrivate *d;
};
+QWEBKIT_EXPORT QDataStream& operator<<(QDataStream& stream, const QWebHistory& history);
+QWEBKIT_EXPORT QDataStream& operator>>(QDataStream& stream, QWebHistory& history);
+
#endif
diff --git a/WebKit/qt/Api/qwebhistory_p.h b/WebKit/qt/Api/qwebhistory_p.h
index 32e69fe..e77adef 100644
--- a/WebKit/qt/Api/qwebhistory_p.h
+++ b/WebKit/qt/Api/qwebhistory_p.h
@@ -22,10 +22,15 @@
#include "BackForwardList.h"
#include "HistoryItem.h"
+#include <QtCore/qglobal.h>
+#include <QtCore/qshareddata.h>
-class QWebHistoryItemPrivate : public QSharedData
-{
+class Q_AUTOTEST_EXPORT QWebHistoryItemPrivate : public QSharedData {
public:
+ static QExplicitlySharedDataPointer<QWebHistoryItemPrivate> get(QWebHistoryItem *q)
+ {
+ return q->d;
+ }
QWebHistoryItemPrivate(WebCore::HistoryItem *i)
{
if (i)
@@ -37,11 +42,29 @@ public:
if (item)
item->deref();
}
+
+ /* QByteArray saveStateWithoutVersionControl(QWebHistory::HistoryStateVersion version)
+ {
+ QByteArray buffer;
+ switch(version){
+ case QWebHistory::HistoryVersion1:
+ buffer=item->saveState(version);
+ break;
+ default:{}
+ }
+ return buffer;
+ }
+
+ bool restoreStateWithoutVersionControl(QWebHistory::HistoryStateVersion version,QDataStream& stream)
+ {
+
+ }
+*/
+
WebCore::HistoryItem *item;
};
-class QWebHistoryPrivate : public QSharedData
-{
+class QWebHistoryPrivate : public QSharedData {
public:
QWebHistoryPrivate(WebCore::BackForwardList *l)
{
diff --git a/WebKit/qt/Api/qwebhistoryinterface.cpp b/WebKit/qt/Api/qwebhistoryinterface.cpp
index 8e2d35c..87d52ce 100644
--- a/WebKit/qt/Api/qwebhistoryinterface.cpp
+++ b/WebKit/qt/Api/qwebhistoryinterface.cpp
@@ -27,28 +27,14 @@
#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.
-namespace WebCore {
-
-bool historyContains(const UChar* characters, unsigned length)
-{
- if (!QWebHistoryInterface::defaultInterface())
- return false;
-
- return QWebHistoryInterface::defaultInterface()->historyContains(QString(reinterpret_cast<const QChar*>(characters), length));
-}
-
-} // namespace WebCore
-
-static QWebHistoryInterface *default_interface;
+static QWebHistoryInterface* default_interface;
static bool gRoutineAdded;
static void gCleanupInterface()
{
- if (default_interface && default_interface->parent() == 0)
+ if (default_interface && !default_interface->parent())
delete default_interface;
default_interface = 0;
}
@@ -61,16 +47,20 @@ static void gCleanupInterface()
When the application exists QWebHistoryInterface will automatically delete the
\a defaultInterface if it does not have a parent.
*/
-void QWebHistoryInterface::setDefaultInterface(QWebHistoryInterface *defaultInterface)
+void QWebHistoryInterface::setDefaultInterface(QWebHistoryInterface* defaultInterface)
{
if (default_interface == defaultInterface)
return;
- if (default_interface && default_interface->parent() == 0)
+
+ if (default_interface && !default_interface->parent())
delete default_interface;
default_interface = defaultInterface;
WebCore::PageGroup::removeAllVisitedLinks();
+ //### enable after the introduction of a version
+ //WebCore::PageGroup::setShouldTrackVisitedLinks(true);
+
if (!gRoutineAdded) {
qAddPostRoutine(gCleanupInterface);
gRoutineAdded = true;
@@ -81,7 +71,7 @@ void QWebHistoryInterface::setDefaultInterface(QWebHistoryInterface *defaultInte
Returns the default interface that will be used by WebKit. If no
default interface has been set, QtWebkit will not track history.
*/
-QWebHistoryInterface *QWebHistoryInterface::defaultInterface()
+QWebHistoryInterface* QWebHistoryInterface::defaultInterface()
{
return default_interface;
}
@@ -102,7 +92,8 @@ QWebHistoryInterface *QWebHistoryInterface::defaultInterface()
/*!
Constructs a new QWebHistoryInterface with parent \a parent.
*/
-QWebHistoryInterface::QWebHistoryInterface(QObject *parent) : QObject(parent)
+QWebHistoryInterface::QWebHistoryInterface(QObject* parent)
+ : QObject(parent)
{
}
diff --git a/WebKit/qt/Api/qwebhistoryinterface.h b/WebKit/qt/Api/qwebhistoryinterface.h
index 670fca0..a49c586 100644
--- a/WebKit/qt/Api/qwebhistoryinterface.h
+++ b/WebKit/qt/Api/qwebhistoryinterface.h
@@ -26,8 +26,7 @@
#include "qwebkitglobal.h"
-class QWEBKIT_EXPORT QWebHistoryInterface : public QObject
-{
+class QWEBKIT_EXPORT QWebHistoryInterface : public QObject {
Q_OBJECT
public:
QWebHistoryInterface(QObject *parent = 0);
diff --git a/WebKit/qt/Api/qwebkitglobal.h b/WebKit/qt/Api/qwebkitglobal.h
index 19d9218..0885bdc 100644
--- a/WebKit/qt/Api/qwebkitglobal.h
+++ b/WebKit/qt/Api/qwebkitglobal.h
@@ -22,22 +22,14 @@
#include <QtCore/qglobal.h>
-#if defined(Q_OS_WIN)
-# if defined(QT_NODLL)
-# undef QT_MAKEDLL
-# undef QT_DLL
-# elif defined(QT_MAKEDLL) /* create a Qt DLL library */
-# if defined(QT_DLL)
-# undef QT_DLL
-# endif
-# if defined(BUILD_WEBKIT)
-# define QWEBKIT_EXPORT Q_DECL_EXPORT
-# else
-# define QWEBKIT_EXPORT Q_DECL_IMPORT
-# endif
-# elif defined(QT_DLL) /* use a Qt DLL library */
-# define QWEBKIT_EXPORT Q_DECL_IMPORT
+#if defined(QT_MAKEDLL) /* create a Qt DLL library */
+# if defined(BUILD_WEBKIT)
+# define QWEBKIT_EXPORT Q_DECL_EXPORT
+# else
+# define QWEBKIT_EXPORT Q_DECL_IMPORT
# endif
+#elif defined(QT_DLL) /* use a Qt DLL library */
+# define QWEBKIT_EXPORT Q_DECL_IMPORT
#endif
#if !defined(QWEBKIT_EXPORT)
diff --git a/WebKit/qt/Api/qwebkitversion.cpp b/WebKit/qt/Api/qwebkitversion.cpp
new file mode 100644
index 0000000..062839f
--- /dev/null
+++ b/WebKit/qt/Api/qwebkitversion.cpp
@@ -0,0 +1,58 @@
+/*
+ Copyright (C) 2009 Robert Hogan <robert@roberthogan.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 "config.h"
+#include <qwebkitversion.h>
+#include <WebKitVersion.h>
+
+/*!
+
+ Returns the version number of WebKit at run-time as a string (for
+ example, "531.3"). This is the version of WebKit the application
+ was compiled against.
+
+*/
+QString qWebKitVersion()
+{
+ return QString("%1.%2").arg(WEBKIT_MAJOR_VERSION).arg(WEBKIT_MINOR_VERSION);
+}
+
+/*!
+
+ Returns the 'major' version number of WebKit at run-time as an integer
+ (for example, 531). This is the version of WebKit the application
+ was compiled against.
+
+*/
+int qWebKitMajorVersion()
+{
+ return WEBKIT_MAJOR_VERSION;
+}
+
+/*!
+
+ Returns the 'minor' version number of WebKit at run-time as an integer
+ (for example, 3). This is the version of WebKit the application
+ was compiled against.
+
+*/
+int qWebKitMinorVersion()
+{
+ return WEBKIT_MINOR_VERSION;
+}
diff --git a/WebKit/qt/Api/qwebkitversion.h b/WebKit/qt/Api/qwebkitversion.h
new file mode 100644
index 0000000..f0fbef0
--- /dev/null
+++ b/WebKit/qt/Api/qwebkitversion.h
@@ -0,0 +1,32 @@
+/*
+ Copyright (C) 2009 Robert Hogan <robert@roberthogan.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 <qstring.h>
+
+#ifndef qwebkitversion_h
+#define qwebkitversion_h
+
+#include <QtCore/qstring.h>
+#include "qwebkitglobal.h"
+
+QWEBKIT_EXPORT QString qWebKitVersion();
+QWEBKIT_EXPORT int qWebKitMajorVersion();
+QWEBKIT_EXPORT int qWebKitMinorVersion();
+
+#endif // qwebkitversion_h
diff --git a/WebKit/qt/Api/qwebnetworkinterface.cpp b/WebKit/qt/Api/qwebnetworkinterface.cpp
index 8fba915..cf99183 100644
--- a/WebKit/qt/Api/qwebnetworkinterface.cpp
+++ b/WebKit/qt/Api/qwebnetworkinterface.cpp
@@ -19,6 +19,7 @@
Boston, MA 02110-1301, USA.
*/
+#include "config.h"
#include <qglobal.h>
#if QT_VERSION < 0x040400
#include "qwebframe.h"
@@ -84,11 +85,10 @@ static QByteArray decodePercentEncoding(const QByteArray& input)
for (int i = 0; i < input.length(); ++i)
if (state == State_Begin) {
- if (input.at(i) == '%') {
+ if (input.at(i) == '%')
state = State_FirstChar;
- } else {
+ else
output[actualLength++] = input[i];
- }
} else if (state == State_FirstChar) {
state = State_SecondChar;
tmpVal[0] = input[i];
@@ -109,7 +109,7 @@ void QWebNetworkRequestPrivate::init(const WebCore::ResourceRequest &resourceReq
init(resourceRequest.httpMethod(), qurl, &resourceRequest);
}
-void QWebNetworkRequestPrivate::init(const QString &method, const QUrl &url, const WebCore::ResourceRequest *resourceRequest)
+void QWebNetworkRequestPrivate::init(const QString& method, const QUrl& url, const WebCore::ResourceRequest* resourceRequest)
{
httpHeader = QHttpRequestHeader(method, url.toString(QUrl::RemoveScheme|QUrl::RemoveAuthority));
httpHeader.setValue(QLatin1String("Connection"), QLatin1String("Keep-Alive"));
@@ -140,7 +140,7 @@ void QWebNetworkRequestPrivate::init(const QString &method, const QUrl &url, con
}
}
-void QWebNetworkRequestPrivate::setURL(const QUrl &u)
+void QWebNetworkRequestPrivate::setURL(const QUrl& u)
{
url = u;
int port = url.port();
@@ -153,6 +153,7 @@ void QWebNetworkRequestPrivate::setURL(const QUrl &u)
/*!
\class QWebNetworkRequest
+ \internal
The QWebNetworkRequest class represents a request for data from the network with all the
necessary information needed for retrieval. This includes the url, extra HTTP header fields
@@ -164,7 +165,7 @@ QWebNetworkRequest::QWebNetworkRequest()
{
}
-QWebNetworkRequest::QWebNetworkRequest(const QUrl &url, Method method, const QByteArray &postData)
+QWebNetworkRequest::QWebNetworkRequest(const QUrl& url, Method method, const QByteArray& postData)
: d(new QWebNetworkRequestPrivate)
{
d->init(method == Get ? "GET" : "POST", url);
@@ -176,7 +177,7 @@ QWebNetworkRequest::QWebNetworkRequest(const QWebNetworkRequest &other)
{
}
-QWebNetworkRequest &QWebNetworkRequest::operator=(const QWebNetworkRequest &other)
+QWebNetworkRequest &QWebNetworkRequest::operator=(const QWebNetworkRequest& other)
{
*d = *other.d;
return *this;
@@ -185,7 +186,7 @@ QWebNetworkRequest &QWebNetworkRequest::operator=(const QWebNetworkRequest &othe
/*!
\internal
*/
-QWebNetworkRequest::QWebNetworkRequest(const QWebNetworkRequestPrivate &priv)
+QWebNetworkRequest::QWebNetworkRequest(const QWebNetworkRequestPrivate& priv)
: d(new QWebNetworkRequestPrivate(priv))
{
}
@@ -193,7 +194,7 @@ QWebNetworkRequest::QWebNetworkRequest(const QWebNetworkRequestPrivate &priv)
/*!
\internal
*/
-QWebNetworkRequest::QWebNetworkRequest(const WebCore::ResourceRequest &request)
+QWebNetworkRequest::QWebNetworkRequest(const WebCore::ResourceRequest& request)
: d(new QWebNetworkRequestPrivate)
{
d->init(request);
@@ -205,6 +206,7 @@ QWebNetworkRequest::~QWebNetworkRequest()
}
/*!
+ \internal
The requested URL
*/
QUrl QWebNetworkRequest::url() const
@@ -213,16 +215,18 @@ QUrl QWebNetworkRequest::url() const
}
/*!
+ \internal
Sets the URL to request.
Note that setting the URL also sets the "Host" field in the HTTP header.
*/
-void QWebNetworkRequest::setUrl(const QUrl &url)
+void QWebNetworkRequest::setUrl(const QUrl& url)
{
d->setURL(url);
}
/*!
+ \internal
The http request header information.
*/
QHttpRequestHeader QWebNetworkRequest::httpHeader() const
@@ -230,22 +234,23 @@ QHttpRequestHeader QWebNetworkRequest::httpHeader() const
return d->httpHeader;
}
-void QWebNetworkRequest::setHttpHeader(const QHttpRequestHeader &header) const
+void QWebNetworkRequest::setHttpHeader(const QHttpRequestHeader& header) const
{
d->httpHeader = header;
}
-QString QWebNetworkRequest::httpHeaderField(const QString &key) const
+QString QWebNetworkRequest::httpHeaderField(const QString& key) const
{
return d->httpHeader.value(key);
}
-void QWebNetworkRequest::setHttpHeaderField(const QString &key, const QString &value)
+void QWebNetworkRequest::setHttpHeaderField(const QString& key, const QString& value)
{
d->httpHeader.setValue(key, value);
}
/*!
+ \internal
Post data sent with HTTP POST requests.
*/
QByteArray QWebNetworkRequest::postData() const
@@ -253,13 +258,14 @@ QByteArray QWebNetworkRequest::postData() const
return d->postData;
}
-void QWebNetworkRequest::setPostData(const QByteArray &data)
+void QWebNetworkRequest::setPostData(const QByteArray& data)
{
d->postData = data;
}
/*!
\class QWebNetworkJob
+ \internal
The QWebNetworkJob class represents a network job, that needs to be
processed by the QWebNetworkInterface.
@@ -292,6 +298,7 @@ QWebNetworkJob::~QWebNetworkJob()
}
/*!
+ \internal
The requested URL
*/
QUrl QWebNetworkJob::url() const
@@ -300,6 +307,7 @@ QUrl QWebNetworkJob::url() const
}
/*!
+ \internal
Post data associated with the job
*/
QByteArray QWebNetworkJob::postData() const
@@ -308,6 +316,7 @@ QByteArray QWebNetworkJob::postData() const
}
/*!
+ \internal
The HTTP request header that should be used to download the job.
*/
QHttpRequestHeader QWebNetworkJob::httpHeader() const
@@ -316,6 +325,7 @@ QHttpRequestHeader QWebNetworkJob::httpHeader() const
}
/*!
+ \internal
The complete network request that should be used to download the job.
*/
QWebNetworkRequest QWebNetworkJob::request() const
@@ -324,6 +334,7 @@ QWebNetworkRequest QWebNetworkJob::request() const
}
/*!
+ \internal
The HTTP response header received from the network.
*/
QHttpResponseHeader QWebNetworkJob::response() const
@@ -332,6 +343,7 @@ QHttpResponseHeader QWebNetworkJob::response() const
}
/*!
+ \internal
The last error of the Job.
*/
QString QWebNetworkJob::errorString() const
@@ -340,10 +352,11 @@ QString QWebNetworkJob::errorString() const
}
/*!
+ \internal
Sets the HTTP reponse header. The response header has to be called before
emitting QWebNetworkInterface::started.
*/
-void QWebNetworkJob::setResponse(const QHttpResponseHeader &response)
+void QWebNetworkJob::setResponse(const QHttpResponseHeader& response)
{
d->response = response;
}
@@ -354,6 +367,7 @@ void QWebNetworkJob::setErrorString(const QString& errorString)
}
/*!
+ \internal
returns true if the job has been cancelled by the WebKit framework
*/
bool QWebNetworkJob::cancelled() const
@@ -362,6 +376,7 @@ bool QWebNetworkJob::cancelled() const
}
/*!
+ \internal
reference the job.
*/
void QWebNetworkJob::ref()
@@ -370,6 +385,7 @@ void QWebNetworkJob::ref()
}
/*!
+ \internal
derefence the job.
If the reference count drops to 0 this method also deletes the job.
@@ -386,6 +402,7 @@ bool QWebNetworkJob::deref()
}
/*!
+ \internal
Returns the network interface that is associated with this job.
*/
QWebNetworkInterface *QWebNetworkJob::networkInterface() const
@@ -394,15 +411,15 @@ QWebNetworkInterface *QWebNetworkJob::networkInterface() const
}
/*!
+ \internal
Returns the network interface that is associated with this job.
*/
QWebFrame *QWebNetworkJob::frame() const
{
- if (d->resourceHandle) {
+ if (!d->resourceHandle) {
ResourceHandleInternal *rhi = d->resourceHandle->getInternal();
- if (rhi) {
+ if (rhi)
return rhi->m_frame;
- }
}
return 0;
}
@@ -436,7 +453,7 @@ QWebNetworkManager *QWebNetworkManager::self()
return s_manager;
}
-bool QWebNetworkManager::add(ResourceHandle *handle, QWebNetworkInterface *interface, JobMode jobMode)
+bool QWebNetworkManager::add(ResourceHandle* handle, QWebNetworkInterface* interface, JobMode jobMode)
{
if (!interface)
interface = s_default_interface;
@@ -468,7 +485,7 @@ bool QWebNetworkManager::add(ResourceHandle *handle, QWebNetworkInterface *inter
return true;
}
-void QWebNetworkManager::cancel(ResourceHandle *handle)
+void QWebNetworkManager::cancel(ResourceHandle* handle)
{
QWebNetworkJob *job = handle->getInternal()->m_job;
if (!job)
@@ -479,7 +496,10 @@ void QWebNetworkManager::cancel(ResourceHandle *handle)
handle->getInternal()->m_job = 0;
}
-void QWebNetworkManager::started(QWebNetworkJob *job)
+/*!
+ \internal
+*/
+void QWebNetworkManager::started(QWebNetworkJob* job)
{
Q_ASSERT(job->d);
Q_ASSERT(job->status() == QWebNetworkJob::JobCreated ||
@@ -487,22 +507,23 @@ void QWebNetworkManager::started(QWebNetworkJob *job)
job->setStatus(QWebNetworkJob::JobStarted);
ResourceHandleClient* client = 0;
- if (job->d->resourceHandle) {
- client = job->d->resourceHandle->client();
- if (!client)
- return;
- } else {
+
+ if (!job->d->resourceHandle)
+ return;
+
+ client = job->d->resourceHandle->client();
+ if (!client)
return;
- }
DEBUG() << "ResourceHandleManager::receivedResponse:";
DEBUG() << job->d->response.toString();
QStringList cookies = job->d->response.allValues("Set-Cookie");
KURL url(job->url());
- foreach (QString c, cookies) {
+
+ foreach (QString c, cookies)
QCookieJar::cookieJar()->setCookies(url, url, c);
- }
+
QString contentType = job->d->response.value("Content-Type");
QString encoding;
int idx = contentType.indexOf(QLatin1Char(';'));
@@ -563,9 +584,9 @@ void QWebNetworkManager::started(QWebNetworkJob *job)
// with a 302 which must be GET'ed
method = "GET";
job->d->request.httpHeader.setContentLength(0);
- } else {
+ } else
method = job->d->request.httpHeader.method();
- }
+
job->d->request.httpHeader.setRequest(method,
newUrl.toString(QUrl::RemoveScheme|QUrl::RemoveAuthority));
job->d->request.setURL(newUrl);
@@ -579,31 +600,29 @@ void QWebNetworkManager::started(QWebNetworkJob *job)
}
-void QWebNetworkManager::data(QWebNetworkJob *job, const QByteArray &data)
+void QWebNetworkManager::data(QWebNetworkJob* job, const QByteArray& data)
{
Q_ASSERT(job->status() == QWebNetworkJob::JobStarted ||
job->status() == QWebNetworkJob::JobReceivingData);
job->setStatus(QWebNetworkJob::JobReceivingData);
ResourceHandleClient* client = 0;
- if (job->d->resourceHandle) {
- client = job->d->resourceHandle->client();
- if (!client)
- return;
- } else {
+
+ if (!job->d->resourceHandle)
+ return;
+
+ client = job->d->resourceHandle->client();
+ if (!client)
return;
- }
if (job->d->redirected)
return; // don't emit the "Document has moved here" type of HTML
DEBUG() << "receivedData" << job->d->request.url.path();
- if (client)
- client->didReceiveData(job->d->resourceHandle, data.constData(), data.length(), data.length() /*FixMe*/);
-
+ client->didReceiveData(job->d->resourceHandle, data.constData(), data.length(), data.length() /*FixMe*/);
}
-void QWebNetworkManager::finished(QWebNetworkJob *job, int errorCode)
+void QWebNetworkManager::finished(QWebNetworkJob* job, int errorCode)
{
Q_ASSERT(errorCode == 1 ||
job->status() == QWebNetworkJob::JobStarted ||
@@ -641,9 +660,8 @@ void QWebNetworkManager::finished(QWebNetworkJob *job, int errorCode)
client->didFail(job->d->resourceHandle,
ResourceError(job->d->request.url.host(), job->d->response.statusCode(),
job->d->request.url.toString(), job->d->errorString));
- } else {
+ } else
client->didFinishLoading(job->d->resourceHandle);
- }
}
DEBUG() << "receivedFinished done" << job->d->request.url;
@@ -651,7 +669,7 @@ void QWebNetworkManager::finished(QWebNetworkJob *job, int errorCode)
job->deref();
}
-void QWebNetworkManager::addHttpJob(QWebNetworkJob *job)
+void QWebNetworkManager::addHttpJob(QWebNetworkJob* job)
{
HostInfo hostInfo(job->url());
WebCoreHttp *httpConnection = m_hostMapping.value(hostInfo);
@@ -667,20 +685,20 @@ void QWebNetworkManager::addHttpJob(QWebNetworkJob *job)
httpConnection->request(job);
}
-void QWebNetworkManager::cancelHttpJob(QWebNetworkJob *job)
+void QWebNetworkManager::cancelHttpJob(QWebNetworkJob* job)
{
WebCoreHttp *httpConnection = m_hostMapping.value(job->url());
if (httpConnection)
httpConnection->cancel(job);
}
-void QWebNetworkManager::httpConnectionClosed(const WebCore::HostInfo &info)
+void QWebNetworkManager::httpConnectionClosed(const WebCore::HostInfo& info)
{
WebCoreHttp *connection = m_hostMapping.take(info);
connection->deleteLater();
}
-void QWebNetworkInterfacePrivate::sendFileData(QWebNetworkJob* job, int statusCode, const QByteArray &data)
+void QWebNetworkInterfacePrivate::sendFileData(QWebNetworkJob* job, int statusCode, const QByteArray& data)
{
int error = statusCode >= 400 ? 1 : 0;
if (!job->cancelled()) {
@@ -723,15 +741,13 @@ void QWebNetworkInterfacePrivate::parseDataUrl(QWebNetworkJob* job)
header = header.left(header.length() - 7);
//qDebug() << "mime=" << header;
}
- } else {
+ } else
data = QByteArray();
- }
- if (base64) {
+ if (base64)
data = QByteArray::fromBase64(data);
- } else {
+ else
data = decodePercentEncoding(data);
- }
if (header.isEmpty())
header = "text/plain;charset=US-ASCII";
@@ -830,13 +846,14 @@ void QWebNetworkManager::doWork()
}
m_queueMutex.lock();
- if (hasSyncJobs && m_synchronousJobs.size() == 0)
+ if (hasSyncJobs && !m_synchronousJobs.size())
doScheduleWork();
m_queueMutex.unlock();
}
/*!
\class QWebNetworkInterface
+ \internal
The QWebNetworkInterface class provides an abstraction layer for
WebKit's network interface. It allows to completely replace or
@@ -860,10 +877,11 @@ static void gCleanupInterface()
}
/*!
+ \internal
Sets a new default interface that will be used by all of WebKit
for downloading data from the internet.
*/
-void QWebNetworkInterface::setDefaultInterface(QWebNetworkInterface *defaultInterface)
+void QWebNetworkInterface::setDefaultInterface(QWebNetworkInterface* defaultInterface)
{
if (s_default_interface == defaultInterface)
return;
@@ -877,23 +895,25 @@ void QWebNetworkInterface::setDefaultInterface(QWebNetworkInterface *defaultInte
}
/*!
+ \internal
Returns the default interface that will be used by WebKit. If no
default interface has been set, QtWebkit will create an instance of
QWebNetworkInterface to do the work.
*/
QWebNetworkInterface *QWebNetworkInterface::defaultInterface()
{
- if (!s_default_interface) {
+ if (!s_default_interface)
setDefaultInterface(new QWebNetworkInterface);
- }
+
return s_default_interface;
}
/*!
+ \internal
Constructs a QWebNetworkInterface object.
*/
-QWebNetworkInterface::QWebNetworkInterface(QObject *parent)
+QWebNetworkInterface::QWebNetworkInterface(QObject* parent)
: QObject(parent)
{
d = new QWebNetworkInterfacePrivate;
@@ -904,6 +924,7 @@ QWebNetworkInterface::QWebNetworkInterface(QObject *parent)
}
/*!
+ \internal
Destructs the QWebNetworkInterface object.
*/
QWebNetworkInterface::~QWebNetworkInterface()
@@ -912,6 +933,7 @@ QWebNetworkInterface::~QWebNetworkInterface()
}
/*!
+ \internal
This virtual method gets called whenever QtWebkit needs to add a
new job to download.
@@ -923,7 +945,7 @@ QWebNetworkInterface::~QWebNetworkInterface()
After the finished signal has been emitted, the QWebNetworkInterface
is not allowed to access the job anymore.
*/
-void QWebNetworkInterface::addJob(QWebNetworkJob *job)
+void QWebNetworkInterface::addJob(QWebNetworkJob* job)
{
QString protocol = job->url().scheme();
if (protocol == QLatin1String("http") || protocol == QLatin1String("https")) {
@@ -966,9 +988,8 @@ void QWebNetworkInterface::addJob(QWebNetworkJob *job)
response.setStatusLine(200);
job->setResponse(response);
data = f.readAll();
- } else {
+ } else
statusCode = 404;
- }
}
if (statusCode == 404) {
@@ -981,6 +1002,7 @@ void QWebNetworkInterface::addJob(QWebNetworkJob *job)
}
/*!
+ \internal
This virtual method gets called whenever QtWebkit needs to cancel a
new job.
@@ -989,35 +1011,66 @@ void QWebNetworkInterface::addJob(QWebNetworkJob *job)
the finished signal, the interface should not access the job
anymore.
*/
-void QWebNetworkInterface::cancelJob(QWebNetworkJob *job)
+void QWebNetworkInterface::cancelJob(QWebNetworkJob* job)
{
QString protocol = job->url().scheme();
if (protocol == QLatin1String("http") || protocol == QLatin1String("https"))
QWebNetworkManager::self()->cancelHttpJob(job);
}
+/*!
+ \internal
+*/
void QWebNetworkInterface::started(QWebNetworkJob* job)
{
Q_ASSERT(s_manager);
s_manager->queueStart(job);
}
+/*!
+ \internal
+*/
void QWebNetworkInterface::data(QWebNetworkJob* job, const QByteArray& data)
{
Q_ASSERT(s_manager);
s_manager->queueData(job, data);
}
+/*!
+ \internal
+*/
void QWebNetworkInterface::finished(QWebNetworkJob* job, int errorCode)
{
Q_ASSERT(s_manager);
s_manager->queueFinished(job, errorCode);
}
+/*!
+ \fn void QWebNetworkInterface::sslErrors(QWebFrame *frame, const QUrl& url, const QList<QSslError>& errors, bool *continueAnyway);
+ \internal
+
+ Signal is emitted when an SSL error occurs.
+*/
+
+/*!
+ \fn void QWebNetworkInterface::authenticate(QWebFrame *frame, const QUrl& url, const QString& hostname, quint16 port, QAuthenticator *auth);
+ \internal
+
+ Signal is emitted when network authentication is required.
+*/
+
+/*!
+ \fn void QWebNetworkInterface::authenticateProxy(QWebFrame *frame, const QUrl& url, const QNetworkProxy& proxy, QAuthenticator *auth);
+ \internal
+
+ Signal is emitted when proxy authentication is required.
+*/
+
/////////////////////////////////////////////////////////////////////////////
-WebCoreHttp::WebCoreHttp(QObject* parent, const HostInfo &hi)
- : QObject(parent), info(hi),
- m_inCancel(false)
+WebCoreHttp::WebCoreHttp(QObject* parent, const HostInfo& hi)
+ : QObject(parent)
+ , info(hi)
+ , m_inCancel(false)
{
for (int i = 0; i < 2; ++i) {
connection[i].http = new QHttp(info.host, (hi.protocol == QLatin1String("https")) ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp, info.port);
@@ -1046,7 +1099,7 @@ WebCoreHttp::~WebCoreHttp()
connection[1].http->deleteLater();
}
-void WebCoreHttp::request(QWebNetworkJob *job)
+void WebCoreHttp::request(QWebNetworkJob* job)
{
m_pendingRequests.append(job);
scheduleNextRequest();
@@ -1073,7 +1126,7 @@ void WebCoreHttp::scheduleNextRequest()
if (!job)
return;
- QHttp *http = connection[c].http;
+ QHttp* http = connection[c].http;
connection[c].current = job;
connection[c].id = -1;
@@ -1094,7 +1147,7 @@ void WebCoreHttp::scheduleNextRequest()
int WebCoreHttp::getConnection()
{
- QObject *o = sender();
+ QObject* o = sender();
int c;
if (o == connection[0].http) {
c = 0;
@@ -1106,15 +1159,15 @@ int WebCoreHttp::getConnection()
return c;
}
-void WebCoreHttp::onResponseHeaderReceived(const QHttpResponseHeader &resp)
+void WebCoreHttp::onResponseHeaderReceived(const QHttpResponseHeader& resp)
{
- QHttp *http = qobject_cast<QHttp*>(sender());
- if (http->currentId() == 0) {
+ QHttp* http = qobject_cast<QHttp*>(sender());
+ if (!http->currentId()) {
qDebug() << "ERROR! Invalid job id. Why?"; // foxnews.com triggers this
return;
}
int c = getConnection();
- QWebNetworkJob *job = connection[c].current;
+ QWebNetworkJob* job = connection[c].current;
DEBUG() << "WebCoreHttp::slotResponseHeaderReceived connection=" << c;
DEBUG() << resp.toString();
@@ -1125,13 +1178,13 @@ void WebCoreHttp::onResponseHeaderReceived(const QHttpResponseHeader &resp)
void WebCoreHttp::onReadyRead()
{
- QHttp *http = qobject_cast<QHttp*>(sender());
- if (http->currentId() == 0) {
+ QHttp* http = qobject_cast<QHttp*>(sender());
+ if (!http->currentId()) {
qDebug() << "ERROR! Invalid job id. Why?"; // foxnews.com triggers this
return;
}
int c = getConnection();
- QWebNetworkJob *job = connection[c].current;
+ QWebNetworkJob* job = connection[c].current;
Q_ASSERT(http == connection[c].http);
//DEBUG() << "WebCoreHttp::slotReadyRead connection=" << c;
@@ -1144,17 +1197,16 @@ void WebCoreHttp::onReadyRead()
void WebCoreHttp::onRequestFinished(int id, bool error)
{
int c = getConnection();
- if (connection[c].id != id) {
+ if (connection[c].id != id)
return;
- }
- QWebNetworkJob *job = connection[c].current;
+ QWebNetworkJob* job = connection[c].current;
if (!job) {
scheduleNextRequest();
return;
}
- QHttp *http = connection[c].http;
+ QHttp* http = connection[c].http;
DEBUG() << "WebCoreHttp::slotFinished connection=" << c << error << job;
if (error) {
DEBUG() << " error: " << http->errorString();
@@ -1225,7 +1277,7 @@ void WebCoreHttp::onSslErrors(const QList<QSslError>& errors)
}
}
-void WebCoreHttp::onAuthenticationRequired(const QString& hostname, quint16 port, QAuthenticator *auth)
+void WebCoreHttp::onAuthenticationRequired(const QString& hostname, quint16 port, QAuthenticator* auth)
{
int c = getConnection();
QWebNetworkJob *job = connection[c].current;
@@ -1236,7 +1288,7 @@ void WebCoreHttp::onAuthenticationRequired(const QString& hostname, quint16 port
}
}
-void WebCoreHttp::onProxyAuthenticationRequired(const QNetworkProxy& proxy, QAuthenticator *auth)
+void WebCoreHttp::onProxyAuthenticationRequired(const QNetworkProxy& proxy, QAuthenticator* auth)
{
int c = getConnection();
QWebNetworkJob *job = connection[c].current;
diff --git a/WebKit/qt/Api/qwebnetworkinterface.h b/WebKit/qt/Api/qwebnetworkinterface.h
index b603e37..7f96155 100644
--- a/WebKit/qt/Api/qwebnetworkinterface.h
+++ b/WebKit/qt/Api/qwebnetworkinterface.h
@@ -44,8 +44,7 @@ namespace WebCore {
}
struct QWebNetworkRequestPrivate;
-class QWEBKIT_EXPORT QWebNetworkRequest
-{
+class QWEBKIT_EXPORT QWebNetworkRequest {
public:
enum Method {
Get,
@@ -82,8 +81,7 @@ private:
friend class QWebObjectPluginConnector;
};
-class QWEBKIT_EXPORT QWebNetworkJob
-{
+class QWEBKIT_EXPORT QWebNetworkJob {
public:
QUrl url() const;
@@ -102,7 +100,7 @@ public:
bool deref();
QWebNetworkInterface *networkInterface() const;
-
+
QWebFrame *frame() const;
protected:
@@ -130,8 +128,7 @@ private:
class QWebNetworkInterfacePrivate;
-class QWEBKIT_EXPORT QWebNetworkInterface : public QObject
-{
+class QWEBKIT_EXPORT QWebNetworkInterface : public QObject {
Q_OBJECT
public:
QWebNetworkInterface(QObject *parent = 0);
@@ -147,19 +144,10 @@ protected:
void started(QWebNetworkJob*);
void data(QWebNetworkJob*, const QByteArray &data);
void finished(QWebNetworkJob*, int errorCode);
-
+
signals:
- /**
- * Signal is emitted when an SSL error occurs.
- */
void sslErrors(QWebFrame *frame, const QUrl& url, const QList<QSslError>& errors, bool *continueAnyway);
- /**
- * Signal is emitted when network authentication is required.
- */
void authenticate(QWebFrame *frame, const QUrl& url, const QString& hostname, quint16 port, QAuthenticator *auth);
- /**
- * Signal is emitted when proxy authentication is required.
- */
void authenticateProxy(QWebFrame *frame, const QUrl& url, const QNetworkProxy& proxy, QAuthenticator *auth);
private:
diff --git a/WebKit/qt/Api/qwebnetworkinterface_p.h b/WebKit/qt/Api/qwebnetworkinterface_p.h
index 56e8617..aec104b 100644
--- a/WebKit/qt/Api/qwebnetworkinterface_p.h
+++ b/WebKit/qt/Api/qwebnetworkinterface_p.h
@@ -36,8 +36,7 @@ namespace WebCore {
class ResourceHandle;
}
-struct QWebNetworkRequestPrivate
-{
+struct QWebNetworkRequestPrivate {
QUrl url;
QHttpRequestHeader httpHeader;
QByteArray postData;
@@ -47,8 +46,7 @@ struct QWebNetworkRequestPrivate
void setURL(const QUrl &u);
};
-class QWebNetworkJobPrivate
-{
+class QWebNetworkJobPrivate {
public:
QWebNetworkJobPrivate()
: ref(1)
@@ -70,8 +68,7 @@ public:
QString errorString;
};
-class QWebNetworkManager : public QObject
-{
+class QWebNetworkManager : public QObject {
Q_OBJECT
public:
enum JobMode {
@@ -162,18 +159,17 @@ namespace WebCore {
int port;
};
- class WebCoreHttp : public QObject
- {
+ class WebCoreHttp : public QObject {
Q_OBJECT
public:
- WebCoreHttp(QObject *parent, const HostInfo&);
+ WebCoreHttp(QObject* parent, const HostInfo&);
~WebCoreHttp();
void request(QWebNetworkJob* resource);
void cancel(QWebNetworkJob*);
signals:
- void connectionClosed(const WebCore::HostInfo &);
+ void connectionClosed(const WebCore::HostInfo&);
private slots:
void onResponseHeaderReceived(const QHttpResponseHeader& resp);
@@ -182,8 +178,8 @@ namespace WebCore {
void onDone(bool);
void onStateChanged(int);
void onSslErrors(const QList<QSslError>&);
- void onAuthenticationRequired(const QString& hostname, quint16 port, QAuthenticator *);
- void onProxyAuthenticationRequired(const QNetworkProxy& proxy, QAuthenticator *);
+ void onAuthenticationRequired(const QString& hostname, quint16 port, QAuthenticator*);
+ void onProxyAuthenticationRequired(const QNetworkProxy& proxy, QAuthenticator*);
void scheduleNextRequest();
@@ -192,11 +188,11 @@ namespace WebCore {
public:
HostInfo info;
private:
- QList<QWebNetworkJob *> m_pendingRequests;
+ QList<QWebNetworkJob*> m_pendingRequests;
struct HttpConnection {
HttpConnection() : http(0), current(0), id(-1) {}
- QHttp *http;
- QWebNetworkJob *current;
+ QHttp* http;
+ QWebNetworkJob* current;
int id; // the QHttp id
};
HttpConnection connection[2];
@@ -205,13 +201,12 @@ namespace WebCore {
}
-class QWebNetworkInterfacePrivate
-{
+class QWebNetworkInterfacePrivate {
public:
- void sendFileData(QWebNetworkJob* job, int statusCode, const QByteArray &data);
+ void sendFileData(QWebNetworkJob* job, int statusCode, const QByteArray& data);
void parseDataUrl(QWebNetworkJob* job);
- QWebNetworkInterface *q;
+ QWebNetworkInterface* q;
};
#endif
diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp
index ed94489..8e40339 100644
--- a/WebKit/qt/Api/qwebpage.cpp
+++ b/WebKit/qt/Api/qwebpage.cpp
@@ -28,12 +28,15 @@
#include "qwebhistory.h"
#include "qwebhistory_p.h"
#include "qwebsettings.h"
+#include "qwebkitversion.h"
#include "Frame.h"
#include "FrameTree.h"
#include "FrameLoader.h"
#include "FrameLoaderClientQt.h"
#include "FrameView.h"
+#include "FormState.h"
+#include "ApplicationCacheStorage.h"
#include "ChromeClientQt.h"
#include "ContextMenu.h"
#include "ContextMenuClientQt.h"
@@ -42,9 +45,9 @@
#include "DragController.h"
#include "DragData.h"
#include "EditorClientQt.h"
+#include "SecurityOrigin.h"
#include "Settings.h"
#include "Page.h"
-#include "PageGroup.h"
#include "Pasteboard.h"
#include "FrameLoader.h"
#include "FrameLoadRequest.h"
@@ -58,9 +61,11 @@
#include "Scrollbar.h"
#include "PlatformKeyboardEvent.h"
#include "PlatformWheelEvent.h"
+#include "PluginDatabase.h"
#include "ProgressTracker.h"
#include "RefPtr.h"
#include "HashMap.h"
+#include "HTMLFormElement.h"
#include "HitTestResult.h"
#include "WindowFeatures.h"
#include "LocalizedStrings.h"
@@ -71,6 +76,7 @@
#include <QBasicTimer>
#include <QBitArray>
#include <QDebug>
+#include <QDesktopServices>
#include <QDragEnterEvent>
#include <QDragLeaveEvent>
#include <QDragMoveEvent>
@@ -97,6 +103,18 @@
using namespace WebCore;
+void QWEBKIT_EXPORT qt_drt_overwritePluginDirectories()
+{
+ PluginDatabase* db = PluginDatabase::installedPlugins(/* populate */ false);
+
+ Vector<String> paths;
+ String qtPath(getenv("QTWEBKIT_PLUGIN_PATH"));
+ qtPath.split(UChar(':'), /* allowEmptyEntries */ false, paths);
+
+ db->setPluginDirectories(paths);
+ db->refresh();
+}
+
bool QWebPagePrivate::drtRun = false;
void QWEBKIT_EXPORT qt_drt_run(bool b)
{
@@ -114,29 +132,29 @@ QString QWEBKIT_EXPORT qt_webpage_groupName(QWebPage* page)
}
// Lookup table mapping QWebPage::WebActions to the associated Editor commands
-static const char* editorCommandWebActions[] =
+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,
@@ -165,21 +183,37 @@ static const char* editorCommandWebActions[] =
"MoveToEndOfDocumentAndModifySelection", // SelectEndOfDocument,
"DeleteWordBackward", // DeleteStartOfWord,
"DeleteWordForward", // DeleteEndOfWord,
-
+
0, // SetTextDirectionDefault,
0, // SetTextDirectionLeftToRight,
0, // SetTextDirectionRightToLeft,
-
+
"ToggleBold", // ToggleBold,
"ToggleItalic", // ToggleItalic,
"ToggleUnderline", // ToggleUnderline,
-
+
0, // InspectElement,
"InsertNewline", // InsertParagraphSeparator
"InsertLineBreak", // InsertLineSeparator
"SelectAll", // SelectAll
+ 0, // ReloadAndBypassCache,
+
+ "PasteAndMatchStyle", // PasteAndMatchStyle
+ "RemoveFormat", // RemoveFormat
+ "Strikethrough", // ToggleStrikethrough,
+ "Subscript", // ToggleSubscript
+ "Superscript", // ToggleSuperscript
+ "InsertUnorderedList", // InsertUnorderedList
+ "InsertOrderedList", // InsertOrderedList
+ "Indent", // Indent
+ "Outdent", // Outdent,
+
+ "AlignCenter", // AlignCenter,
+ "AlignJustified", // AlignJustified,
+ "AlignLeft", // AlignLeft,
+ "AlignRight", // AlignRight,
0 // WebActionCount
};
@@ -189,7 +223,6 @@ const char* QWebPagePrivate::editorCommandForWebActions(QWebPage::WebAction acti
{
if ((action > QWebPage::NoWebAction) && (action < int(sizeof(editorCommandWebActions) / sizeof(const char*))))
return editorCommandWebActions[action];
-
return 0;
}
@@ -232,15 +265,39 @@ static inline Qt::DropAction dragOpToDropAction(unsigned actions)
return result;
}
+static void initializeApplicationCachePathIfNecessary()
+{
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+ static bool initialized = false;
+
+ if (initialized)
+ return;
+
+ // Determine the path for HTML5 Application Cache DB
+ QString appCachePath;
+#if QT_VERSION >= 0x040500
+ appCachePath = QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
+#else
+ appCachePath = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
+#endif
+
+ if (appCachePath.isEmpty())
+ appCachePath = QDir::homePath() + QLatin1String("/.") + QCoreApplication::applicationName();
+
+ WebCore::cacheStorage().setCacheDirectory(appCachePath);
+ initialized = true;
+#endif
+}
+
QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
: q(qq)
, view(0)
- , viewportSize(QSize(0,0))
+ , viewportSize(QSize(0, 0))
{
WebCore::InitializeLoggingChannelsIfNecessary();
- WebCore::PageGroup::setShouldTrackVisitedLinks(true);
JSC::initializeThreading();
WebCore::FrameLoader::setLocalLoadPolicy(WebCore::FrameLoader::AllowLocalLoadsForLocalAndSubstituteData);
+ initializeApplicationCachePathIfNecessary();
chromeClient = new ChromeClientQt(q);
contextMenuClient = new ContextMenuClientQt();
@@ -309,11 +366,7 @@ bool QWebPagePrivate::acceptNavigationRequest(QWebFrame *frame, const QNetworkRe
void QWebPagePrivate::createMainFrame()
{
if (!mainFrame) {
- QWebFrameData frameData;
- frameData.ownerElement = 0;
- frameData.allowsScrolling = true;
- frameData.marginWidth = 0;
- frameData.marginHeight = 0;
+ QWebFrameData frameData(page);
mainFrame = new QWebFrame(q, &frameData);
emit q->frameCreated(mainFrame);
@@ -393,9 +446,8 @@ QMenu *QWebPagePrivate::createContextMenu(const WebCore::ContextMenu *webcoreMen
if (anyEnabledAction) {
subMenu->setTitle(item.title());
menu->addAction(subMenu->menuAction());
- } else {
+ } else
delete subMenu;
- }
break;
}
}
@@ -404,23 +456,6 @@ QMenu *QWebPagePrivate::createContextMenu(const WebCore::ContextMenu *webcoreMen
}
#endif // QT_NO_CONTEXTMENU
-QWebFrame *QWebPagePrivate::frameAt(const QPoint &pos) const
-{
- QWebFrame *frame = mainFrame;
-
-redo:
- QList<QWebFrame*> children = frame->childFrames();
- for (int i = 0; i < children.size(); ++i) {
- if (children.at(i)->geometry().contains(pos)) {
- frame = children.at(i);
- goto redo;
- }
- }
- if (frame->geometry().contains(pos))
- return frame;
- return 0;
-}
-
void QWebPagePrivate::_q_webActionTriggered(bool checked)
{
QAction *a = qobject_cast<QAction *>(q->sender());
@@ -461,6 +496,7 @@ void QWebPagePrivate::updateAction(QWebPage::WebAction action)
enabled = loader->isLoading();
break;
case QWebPage::Reload:
+ case QWebPage::ReloadAndBypassCache:
enabled = !loader->isLoading();
break;
#ifndef QT_NO_UNDOSTACK
@@ -506,6 +542,7 @@ void QWebPagePrivate::updateNavigationActions()
updateAction(QWebPage::Forward);
updateAction(QWebPage::Stop);
updateAction(QWebPage::Reload);
+ updateAction(QWebPage::ReloadAndBypassCache);
}
void QWebPagePrivate::updateEditorActions()
@@ -547,6 +584,19 @@ void QWebPagePrivate::updateEditorActions()
updateAction(QWebPage::ToggleUnderline);
updateAction(QWebPage::InsertParagraphSeparator);
updateAction(QWebPage::InsertLineSeparator);
+ updateAction(QWebPage::PasteAndMatchStyle);
+ updateAction(QWebPage::RemoveFormat);
+ updateAction(QWebPage::ToggleStrikethrough);
+ updateAction(QWebPage::ToggleSubscript);
+ updateAction(QWebPage::ToggleSuperscript);
+ updateAction(QWebPage::InsertUnorderedList);
+ updateAction(QWebPage::InsertOrderedList);
+ updateAction(QWebPage::Indent);
+ updateAction(QWebPage::Outdent);
+ updateAction(QWebPage::AlignCenter);
+ updateAction(QWebPage::AlignJustified);
+ updateAction(QWebPage::AlignLeft);
+ updateAction(QWebPage::AlignRight);
}
void QWebPagePrivate::timerEvent(QTimerEvent *ev)
@@ -639,12 +689,12 @@ void QWebPagePrivate::mouseReleaseEvent(QMouseEvent *ev)
Pasteboard::generalPasteboard()->setSelectionMode(true);
WebCore::Frame* focusFrame = page->focusController()->focusedOrMainFrame();
if (ev->button() == Qt::LeftButton) {
- if(focusFrame && (focusFrame->editor()->canCopy() || focusFrame->editor()->canDHTMLCopy())) {
+ 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())) {
+ if (focusFrame && (focusFrame->editor()->canPaste() || focusFrame->editor()->canDHTMLPaste())) {
focusFrame->editor()->paste();
ev->setAccepted(true);
}
@@ -767,13 +817,26 @@ void QWebPagePrivate::keyPressEvent(QKeyEvent *ev)
defaultFont = view->font();
QFontMetrics fm(defaultFont);
int fontHeight = fm.height();
- if (!handleScrolling(ev)) {
+ if (!handleScrolling(ev, frame)) {
switch (ev->key()) {
+ case Qt::Key_Back:
+ q->triggerAction(QWebPage::Back);
+ break;
+ case Qt::Key_Forward:
+ q->triggerAction(QWebPage::Forward);
+ break;
+ case Qt::Key_Stop:
+ q->triggerAction(QWebPage::Stop);
+ break;
+ case Qt::Key_Refresh:
+ q->triggerAction(QWebPage::Reload);
+ break;
case Qt::Key_Backspace:
if (ev->modifiers() == Qt::ShiftModifier)
q->triggerAction(QWebPage::Forward);
else
q->triggerAction(QWebPage::Back);
+ break;
default:
handled = false;
break;
@@ -801,11 +864,10 @@ void QWebPagePrivate::focusInEvent(QFocusEvent *ev)
FocusController *focusController = page->focusController();
Frame *frame = focusController->focusedFrame();
focusController->setActive(true);
- if (frame) {
- frame->selection()->setFocused(true);
- } else {
+ if (frame)
+ focusController->setFocused(true);
+ else
focusController->setFocusedFrame(QWebFramePrivate::core(mainFrame));
- }
}
void QWebPagePrivate::focusOutEvent(QFocusEvent *ev)
@@ -815,10 +877,7 @@ void QWebPagePrivate::focusOutEvent(QFocusEvent *ev)
// focusInEvent() we can re-activate the frame.
FocusController *focusController = page->focusController();
focusController->setActive(false);
- Frame *frame = focusController->focusedFrame();
- if (frame) {
- frame->selection()->setFocused(false);
- }
+ focusController->setFocused(false);
}
void QWebPagePrivate::dragEnterEvent(QDragEnterEvent *ev)
@@ -908,14 +967,14 @@ void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev)
return;
}
- if (!ev->preeditString().isEmpty()) {
+ if (!ev->commitString().isEmpty())
+ editor->confirmComposition(ev->commitString());
+ else {
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));
+ 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();
}
@@ -950,14 +1009,13 @@ void QWebPagePrivate::shortcutOverrideEvent(QKeyEvent* event)
}
}
#ifndef QT_NO_SHORTCUT
- else if (editorActionForKeyEvent(event) != QWebPage::NoWebAction) {
+ else if (editorActionForKeyEvent(event) != QWebPage::NoWebAction)
event->accept();
- }
#endif
}
}
-bool QWebPagePrivate::handleScrolling(QKeyEvent *ev)
+bool QWebPagePrivate::handleScrolling(QKeyEvent *ev, Frame *frame)
{
ScrollDirection direction;
ScrollGranularity granularity;
@@ -1004,10 +1062,7 @@ bool QWebPagePrivate::handleScrolling(QKeyEvent *ev)
}
}
- if (!mainFrame->d->frame->eventHandler()->scrollOverflow(direction, granularity))
- mainFrame->d->frame->view()->scroll(direction, granularity);
-
- return true;
+ return frame->eventHandler()->scrollRecursively(direction, granularity);
}
/*!
@@ -1021,12 +1076,11 @@ bool QWebPagePrivate::handleScrolling(QKeyEvent *ev)
*/
QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const
{
- switch(property) {
+ switch (property) {
case Qt::ImMicroFocus: {
Frame *frame = d->page->focusController()->focusedFrame();
- if (frame) {
+ if (frame)
return QVariant(frame->selection()->absoluteCaretBounds());
- }
return QVariant();
}
case Qt::ImFont: {
@@ -1039,9 +1093,8 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const
Frame *frame = d->page->focusController()->focusedFrame();
if (frame) {
VisibleSelection selection = frame->selection()->selection();
- if (selection.isCaret()) {
- return QVariant(selection.start().m_offset);
- }
+ if (selection.isCaret())
+ return QVariant(selection.start().deprecatedEditingOffset());
}
return QVariant();
}
@@ -1049,9 +1102,8 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const
Frame *frame = d->page->focusController()->focusedFrame();
if (frame) {
Document *document = frame->document();
- if (document->focusedNode()) {
+ if (document->focusedNode())
return QVariant(document->focusedNode()->nodeValue());
- }
}
return QVariant();
}
@@ -1073,6 +1125,7 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const
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.
+ \value HighlightAllOccurrences Highlights all existing occurrences of a specific string.
*/
/*!
@@ -1107,7 +1160,7 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const
This enum describes the types of action which can be performed on the web page.
Actions only have an effect when they are applicable. The availability of
- actions can be be determined by checking \l{QAction::}{enabled()} on the
+ actions can be be determined by checking \l{QAction::}{isEnabled()} on the
action returned by \l{QWebPage::}{action()}.
One method of enabling the text editing, cursor movement, and text selection actions
@@ -1126,6 +1179,7 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const
\value Forward Navigate forward in the history of navigated links.
\value Stop Stop loading the current page.
\value Reload Reload the current page.
+ \value ReloadAndBypassCache Reload the current page, but do not use any local cache. (Added in Qt 4.6)
\value Cut Cut the content currently selected into the clipboard.
\value Copy Copy the content currently selected into the clipboard.
\value Paste Paste content from the clipboard.
@@ -1167,6 +1221,21 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const
\value InsertParagraphSeparator Insert a new paragraph.
\value InsertLineSeparator Insert a new line.
\value SelectAll Selects all content.
+ \value PasteAndMatchStyle Paste content from the clipboard with current style.
+ \value RemoveFormat Removes formatting and style.
+ \value ToggleStrikethrough Toggle the formatting between strikethrough and normal style.
+ \value ToggleSubscript Toggle the formatting between subscript and baseline.
+ \value ToggleSuperscript Toggle the formatting between supercript and baseline.
+ \value InsertUnorderedList Toggles the selection between an ordered list and a normal block.
+ \value InsertOrderedList Toggles the selection between an ordered list and a normal block.
+ \value Indent Increases the indentation of the currently selected format block by one increment.
+ \value Outdent Decreases the indentation of the currently selected format block by one increment.
+ \value AlignCenter Applies center alignment to content.
+ \value AlignJustified Applies full justification to content.
+ \value AlignLeft Applies left justification to content.
+ \value AlignRight Applies right justification to content.
+
+
\omitvalue WebActionCount
*/
@@ -1210,18 +1279,18 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const
Suppose we have a \c Thumbnail class as follows:
- \snippet doc/src/snippets/webkit/webpage/main.cpp 0
+ \snippet webkitsnippets/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
+ \snippet webkitsnippets/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
+ \snippet webkitsnippets/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
@@ -1282,6 +1351,23 @@ QWebFrame *QWebPage::currentFrame() const
return static_cast<WebCore::FrameLoaderClientQt *>(d->page->focusController()->focusedOrMainFrame()->loader()->client())->webFrame();
}
+
+/*!
+ \since 4.6
+
+ Returns the frame at the given point \a pos.
+
+ \sa mainFrame(), currentFrame()
+*/
+QWebFrame* QWebPage::frameAt(const QPoint& pos) const
+{
+ QWebFrame* webFrame = mainFrame();
+ if (!webFrame->geometry().contains(pos))
+ return 0;
+ QWebHitTestResult hitTestResult = webFrame->hitTestContent(pos);
+ return hitTestResult.frame();
+}
+
/*!
Returns a pointer to the view's history of navigated web pages.
*/
@@ -1367,14 +1453,35 @@ bool QWebPage::javaScriptPrompt(QWebFrame *frame, const QString& msg, const QStr
bool ok = false;
#ifndef QT_NO_INPUTDIALOG
QString x = QInputDialog::getText(d->view, tr("JavaScript Prompt - %1").arg(mainFrame()->url().host()), msg, QLineEdit::Normal, defaultValue, &ok);
- if (ok && result) {
+ if (ok && result)
*result = x;
- }
#endif
return ok;
}
/*!
+ \fn bool QWebPage::shouldInterruptJavaScript()
+ \since 4.6
+ This function is called when a JavaScript program is running for a long period of time.
+
+ If the user wanted to stop the JavaScript the implementation should return true; otherwise false.
+
+ The default implementation executes the query using QMessageBox::information with QMessageBox::Yes and QMessageBox::No buttons.
+
+ \warning Because of binary compatibility constraints, this function is not virtual. If you want to
+ provide your own implementation in a QWebPage subclass, reimplement the shouldInterruptJavaScript()
+ slot in your subclass instead. QtWebKit will dynamically detect the slot and call it.
+*/
+bool QWebPage::shouldInterruptJavaScript()
+{
+#ifdef QT_NO_MESSAGEBOX
+ return false;
+#else
+ return QMessageBox::Yes == QMessageBox::information(d->view, tr("JavaScript Problem - %1").arg(mainFrame()->url().host()), tr("The script on this page appears to have a problem. Do you want to stop the script?"), QMessageBox::Yes, QMessageBox::No);
+#endif
+}
+
+/*!
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.
@@ -1448,10 +1555,9 @@ void QWebPage::triggerAction(WebAction action, bool checked)
case OpenLink:
if (QWebFrame *targetFrame = d->hitTestResult.linkTargetFrame()) {
WTF::RefPtr<WebCore::Frame> wcFrame = targetFrame->d->frame;
- targetFrame->d->frame->loader()->loadFrameRequestWithFormAndValues(frameLoadRequest(d->hitTestResult.linkUrl(), wcFrame.get()),
- /*lockHistory*/ false, /*lockBackForwardList*/ false, /*event*/ 0,
- /*HTMLFormElement*/ 0, /*formValues*/
- WTF::HashMap<String, String>());
+ targetFrame->d->frame->loader()->loadFrameRequest(frameLoadRequest(d->hitTestResult.linkUrl(), wcFrame.get()),
+ /*lockHistory*/ false, /*lockBackForwardList*/ false, /*event*/ 0,
+ /*FormState*/ 0);
break;
}
// fall through
@@ -1499,7 +1605,10 @@ void QWebPage::triggerAction(WebAction action, bool checked)
mainFrame()->d->frame->loader()->stopForUserCancel();
break;
case Reload:
- mainFrame()->d->frame->loader()->reload();
+ mainFrame()->d->frame->loader()->reload(/*endtoendreload*/false);
+ break;
+ case ReloadAndBypassCache:
+ mainFrame()->d->frame->loader()->reload(/*endtoendreload*/true);
break;
case SetTextDirectionDefault:
editor->setBaseWritingDirection(NaturalWritingDirection);
@@ -1556,16 +1665,20 @@ void QWebPage::setViewportSize(const QSize &size) const
}
}
-QSize QWebPage::fixedLayoutSize() const
+QSize QWebPage::fixedContentsSize() const
{
- if (d->mainFrame && d->mainFrame->d->frame->view())
- return d->mainFrame->d->frame->view()->fixedLayoutSize();
+ QWebFrame* frame = d->mainFrame;
+ if (frame) {
+ WebCore::FrameView* view = frame->d->frame->view();
+ if (view && view->useFixedLayout())
+ return d->mainFrame->d->frame->view()->fixedLayoutSize();
+ }
return d->fixedLayoutSize;
}
/*!
- \property QWebPage::fixedLayoutSize
+ \property QWebPage::fixedContentsSize
\since 4.6
\brief the size of the fixed layout
@@ -1573,37 +1686,22 @@ QSize QWebPage::fixedLayoutSize() const
1024x768 for example then webkit will layout the page as if the viewport were that size
rather than something different.
*/
-void QWebPage::setFixedLayoutSize(const QSize &size) const
+void QWebPage::setFixedContentsSize(const QSize &size) const
{
d->fixedLayoutSize = size;
QWebFrame *frame = mainFrame();
if (frame->d->frame && frame->d->frame->view()) {
WebCore::FrameView* view = frame->d->frame->view();
- view->setFixedLayoutSize(size);
- view->forceLayout();
- }
-}
-
-bool QWebPage::useFixedLayout() const
-{
- return d->useFixedLayout;
-}
-/*!
- \property QWebPage::usedFixedLayout
- \since 4.6
- \brief whether to use a fixed layout size
-*/
-void QWebPage::setUseFixedLayout(bool useFixedLayout)
-{
- d->useFixedLayout = useFixedLayout;
-
- QWebFrame *frame = mainFrame();
- if (frame->d->frame && frame->d->frame->view()) {
- WebCore::FrameView* view = frame->d->frame->view();
- view->setUseFixedLayout(useFixedLayout);
- view->forceLayout();
+ if (size.isValid()) {
+ view->setUseFixedLayout(true);
+ view->setFixedLayoutSize(size);
+ view->forceLayout();
+ } else if (view->useFixedLayout()) {
+ view->setUseFixedLayout(false);
+ view->forceLayout();
+ }
}
}
@@ -1633,7 +1731,7 @@ bool QWebPage::acceptNavigationRequest(QWebFrame *frame, const QWebNetworkReques
return true;
case DelegateExternalLinks:
- if (WebCore::FrameLoader::shouldTreatURLSchemeAsLocal(request.url().scheme()))
+ if (WebCore::SecurityOrigin::shouldTreatURLSchemeAsLocal(request.url().scheme()))
return true;
emit linkClicked(request.url());
return false;
@@ -1873,6 +1971,52 @@ QAction *QWebPage::action(WebAction action) const
text = tr("Insert a new line");
break;
+ case PasteAndMatchStyle:
+ text = tr("Paste and Match Style");
+ break;
+ case RemoveFormat:
+ text = tr("Remove formatting");
+ break;
+
+ case ToggleStrikethrough:
+ text = tr("Strikethrough");
+ checkable = true;
+ break;
+ case ToggleSubscript:
+ text = tr("Subscript");
+ checkable = true;
+ break;
+ case ToggleSuperscript:
+ text = tr("Superscript");
+ checkable = true;
+ break;
+ case InsertUnorderedList:
+ text = tr("Insert Bulleted List");
+ checkable = true;
+ break;
+ case InsertOrderedList:
+ text = tr("Insert Numbered List");
+ checkable = true;
+ break;
+ case Indent:
+ text = tr("Indent");
+ break;
+ case Outdent:
+ text = tr("Outdent");
+ break;
+ case AlignCenter:
+ text = tr("Center");
+ break;
+ case AlignJustified:
+ text = tr("Justify");
+ break;
+ case AlignLeft:
+ text = tr("Align Left");
+ break;
+ case AlignRight:
+ text = tr("Align Right");
+ break;
+
case NoWebAction:
return 0;
}
@@ -2035,9 +2179,8 @@ void QWebPage::setContentEditable(bool editable)
frame->applyEditingStyleToBodyElement();
// FIXME: mac port calls this if there is no selectedDOMRange
//frame->setSelectionFromNone();
- } else {
+ } else
frame->removeEditingStyleFromBodyElement();
- }
}
d->updateEditorActions();
@@ -2051,10 +2194,12 @@ bool QWebPage::isContentEditable() const
/*!
\property QWebPage::forwardUnsupportedContent
- \brief whether QWebPage should forward unsupported content through the
- unsupportedContent signal
+ \brief whether QWebPage should forward unsupported content
+
+ If enabled, the unsupportedContent() signal is emitted with a network reply that
+ can be used to read the content.
- If disabled the download of such content is aborted immediately.
+ If disabled, the download of such content is aborted immediately.
By default unsupported content is not forwarded.
*/
@@ -2101,11 +2246,10 @@ bool QWebPage::swallowContextMenuEvent(QContextMenuEvent *event)
{
d->page->contextMenuController()->clearContextMenu();
- if (QWebFrame* webFrame = d->frameAt(event->pos())) {
+ if (QWebFrame* webFrame = frameAt(event->pos())) {
Frame* frame = QWebFramePrivate::core(webFrame);
- if (Scrollbar* scrollbar = frame->view()->scrollbarUnderMouse(PlatformMouseEvent(event, 1))) {
+ if (Scrollbar* scrollbar = frame->view()->scrollbarAtPoint(PlatformMouseEvent(event, 1).pos()))
return scrollbar->contextMenu(PlatformMouseEvent(event, 1));
- }
}
WebCore::Frame* focusedFrame = d->page->focusController()->focusedOrMainFrame();
@@ -2138,7 +2282,10 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos)
WebCore::Frame* focusedFrame = d->page->focusController()->focusedOrMainFrame();
HitTestResult result = focusedFrame->eventHandler()->hitTestResultAtPoint(focusedFrame->view()->windowToContents(pos), /*allowShadowContent*/ false);
- d->hitTestResult = QWebHitTestResult(new QWebHitTestResultPrivate(result));
+ if (result.scrollbar())
+ d->hitTestResult = QWebHitTestResult();
+ else
+ d->hitTestResult = QWebHitTestResult(new QWebHitTestResultPrivate(result));
WebCore::ContextMenu menu(result);
menu.populate();
if (d->page->inspectorController()->enabled())
@@ -2157,9 +2304,8 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos)
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))) {
+ if (QAction *a = this->action(QWebPage::WebAction(i)))
a->setEnabled(true);
- }
}
}
@@ -2259,8 +2405,18 @@ bool QWebPage::supportsExtension(Extension extension) const
}
/*!
- 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.
+ Finds the specified string, \a subString, in the page, using the given \a options.
+
+ If the HighlightAllOccurrences flag is passed, the function will highlight all occurrences
+ that exist in the page. All subsequent calls will extend the highlight, rather than
+ replace it, with occurrences of the new string.
+
+ If the HighlightAllOccurrences flag is not passed, the function will select an occurrence
+ and all subsequent calls will replace the current occurrence with the next one.
+
+ To clear the selection, just pass an empty string.
+
+ Returns true if \a subString was found; otherwise returns false.
*/
bool QWebPage::findText(const QString &subString, FindFlags options)
{
@@ -2268,13 +2424,21 @@ bool QWebPage::findText(const QString &subString, FindFlags options)
if (options & FindCaseSensitively)
caseSensitivity = ::TextCaseSensitive;
- ::FindDirection direction = ::FindDirectionForward;
- if (options & FindBackward)
- direction = ::FindDirectionBackward;
+ if (options & HighlightAllOccurrences) {
+ if (subString.isEmpty()) {
+ d->page->unmarkAllTextMatches();
+ return true;
+ } else
+ return d->page->markAllMatchesForText(subString, caseSensitivity, true, 0);
+ } else {
+ ::FindDirection direction = ::FindDirectionForward;
+ if (options & FindBackward)
+ direction = ::FindDirectionBackward;
- const bool shouldWrap = options & FindWrapsAroundDocument;
+ const bool shouldWrap = options & FindWrapsAroundDocument;
- return d->page->findString(subString, caseSensitivity, direction, shouldWrap);
+ return d->page->findString(subString, caseSensitivity, direction, shouldWrap);
+ }
}
/*!
@@ -2394,7 +2558,7 @@ QWebPluginFactory *QWebPage::pluginFactory() const
The default implementation returns the following value:
- "Mozilla/5.0 (%Platform%; %Security%; %Subplatform%; %Locale%) AppleWebKit/%WebKitVersion% (KHTML, like Gecko, Safari/419.3) %AppVersion"
+ "Mozilla/5.0 (%Platform%; %Security%; %Subplatform%; %Locale%) AppleWebKit/%WebKitVersion% (KHTML, like Gecko) %AppVersion Safari/%WebKitVersion%"
In this string the following values are replaced at run-time:
\list
@@ -2402,7 +2566,7 @@ QWebPluginFactory *QWebPage::pluginFactory() const
\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(). The locale is determined from the view of the QWebPage. If no view is set on the QWebPage,
then a default constructed QLocale is used instead.
- \o %WebKitVersion% currently expands to 527+
+ \o %WebKitVersion% is the version of WebKit the application was compiled against.
\o %AppVersion% expands to QCoreApplication::applicationName()/QCoreApplication::applicationVersion() if they're set; otherwise defaulting to Qt and the current Qt version.
\endlist
*/
@@ -2495,14 +2659,18 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const
QChar securityStrength(QLatin1Char('N'));
#if !defined(QT_NO_OPENSSL)
- if (QSslSocket::supportsSsl())
- securityStrength = QLatin1Char('U');
+ // we could check QSslSocket::supportsSsl() here, but this makes
+ // OpenSSL, certificates etc being loaded in all cases were QWebPage
+ // is used. This loading is not needed for non-https.
+ securityStrength = QLatin1Char('U');
+ // this may lead to a false positive: We indicate SSL since it is
+ // compiled in even though supportsSsl() might return false
#endif
ua = ua.arg(securityStrength);
#if defined Q_OS_WIN32
QString ver;
- switch(QSysInfo::WindowsVersion) {
+ switch (QSysInfo::WindowsVersion) {
case QSysInfo::WV_32s:
ver = "Windows 3.1";
break;
@@ -2556,12 +2724,13 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const
ua.append(QLatin1String(") "));
// webkit/qt version
- ua.append(QLatin1String("AppleWebKit/" WEBKIT_VERSION " (KHTML, like Gecko, Safari/419.3) "));
+ ua.append(QString(QLatin1String("AppleWebKit/%1 (KHTML, like Gecko) "))
+ .arg(QString(qWebKitVersion())));
// Application name/version
QString appName = QCoreApplication::applicationName();
if (!appName.isEmpty()) {
- ua.append(QLatin1Char(' ') + appName);
+ ua.append(appName);
#if QT_VERSION >= 0x040400
QString appVer = QCoreApplication::applicationVersion();
if (!appVer.isEmpty())
@@ -2572,11 +2741,16 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const
ua.append(QLatin1String("Qt/"));
ua.append(QLatin1String(qVersion()));
}
+
+ ua.append(QString(QLatin1String(" Safari/%1"))
+ .arg(qWebKitVersion()));
+
return ua;
}
-void QWebPagePrivate::_q_onLoadProgressChanged(int) {
+void QWebPagePrivate::_q_onLoadProgressChanged(int)
+{
m_totalBytes = page->progress()->totalPageAndResourceBytesToLoad();
m_bytesReceived = page->progress()->totalBytesReceived();
}
@@ -2588,7 +2762,8 @@ void QWebPagePrivate::_q_onLoadProgressChanged(int) {
\sa bytesReceived()
*/
-quint64 QWebPage::totalBytes() const {
+quint64 QWebPage::totalBytes() const
+{
return d->m_totalBytes;
}
@@ -2598,7 +2773,8 @@ quint64 QWebPage::totalBytes() const {
\sa totalBytes()
*/
-quint64 QWebPage::bytesReceived() const {
+quint64 QWebPage::bytesReceived() const
+{
return d->m_bytesReceived;
}
diff --git a/WebKit/qt/Api/qwebpage.h b/WebKit/qt/Api/qwebpage.h
index 2853fcc..24741a1 100644
--- a/WebKit/qt/Api/qwebpage.h
+++ b/WebKit/qt/Api/qwebpage.h
@@ -52,21 +52,20 @@ namespace WebCore {
class ChromeClientQt;
class EditorClientQt;
class FrameLoaderClientQt;
- class FrameLoadRequest;
class InspectorClientQt;
class ResourceHandle;
class HitTestResult;
+
+ struct FrameLoadRequest;
}
-class QWEBKIT_EXPORT QWebPage : public QObject
-{
+class QWEBKIT_EXPORT QWebPage : public QObject {
Q_OBJECT
Q_PROPERTY(bool modified READ isModified)
Q_PROPERTY(QString selectedText READ selectedText)
Q_PROPERTY(QSize viewportSize READ viewportSize WRITE setViewportSize)
- Q_PROPERTY(QSize fixedLayoutSize READ fixedLayoutSize WRITE setFixedLayoutSize)
- Q_PROPERTY(bool useFixedLayout READ useFixedLayout WRITE setUseFixedLayout)
+ Q_PROPERTY(QSize fixedContentsSize READ fixedContentsSize WRITE setFixedContentsSize)
Q_PROPERTY(bool forwardUnsupportedContent READ forwardUnsupportedContent WRITE setForwardUnsupportedContent)
Q_PROPERTY(LinkDelegationPolicy linkDelegationPolicy READ linkDelegationPolicy WRITE setLinkDelegationPolicy)
Q_PROPERTY(QPalette palette READ palette WRITE setPalette)
@@ -149,6 +148,23 @@ public:
InsertLineSeparator,
SelectAll,
+ ReloadAndBypassCache,
+
+ PasteAndMatchStyle,
+ RemoveFormat,
+
+ ToggleStrikethrough,
+ ToggleSubscript,
+ ToggleSuperscript,
+ InsertUnorderedList,
+ InsertOrderedList,
+ Indent,
+ Outdent,
+
+ AlignCenter,
+ AlignJustified,
+ AlignLeft,
+ AlignRight,
WebActionCount
};
@@ -156,7 +172,8 @@ public:
enum FindFlag {
FindBackward = 1,
FindCaseSensitively = 2,
- FindWrapsAroundDocument = 4
+ FindWrapsAroundDocument = 4,
+ HighlightAllOccurrences = 8
};
Q_DECLARE_FLAGS(FindFlags, FindFlag)
@@ -176,6 +193,7 @@ public:
QWebFrame *mainFrame() const;
QWebFrame *currentFrame() const;
+ QWebFrame* frameAt(const QPoint& pos) const;
QWebHistory *history() const;
QWebSettings *settings() const;
@@ -217,11 +235,8 @@ public:
QSize viewportSize() const;
void setViewportSize(const QSize &size) const;
- QSize fixedLayoutSize() const;
- void setFixedLayoutSize(const QSize &size) const;
-
- bool useFixedLayout() const;
- void setUseFixedLayout(bool useFixedLayout);
+ QSize fixedContentsSize() const;
+ void setFixedContentsSize(const QSize &size) const;
virtual bool event(QEvent*);
bool focusNextPrevChild(bool next);
@@ -273,6 +288,9 @@ public:
inline QWebPagePrivate* handle() const { return d; }
+public Q_SLOTS:
+ bool shouldInterruptJavaScript();
+
Q_SIGNALS:
void loadStarted();
void loadProgress(int progress);
diff --git a/WebKit/qt/Api/qwebpage_p.h b/WebKit/qt/Api/qwebpage_p.h
index a897bf1..87c624d 100644
--- a/WebKit/qt/Api/qwebpage_p.h
+++ b/WebKit/qt/Api/qwebpage_p.h
@@ -35,8 +35,7 @@
#include <wtf/RefPtr.h>
-namespace WebCore
-{
+namespace WebCore {
class ChromeClientQt;
class ContextMenuClientQt;
class ContextMenuItem;
@@ -45,6 +44,7 @@ namespace WebCore
class Element;
class Node;
class Page;
+ class Frame;
#ifndef QT_NO_CURSOR
class SetCursorEvent : public QEvent {
@@ -65,18 +65,14 @@ class QMenu;
class QBitArray;
QT_END_NAMESPACE
-class QWebPagePrivate
-{
+class QWebPagePrivate {
public:
- QWebPagePrivate(QWebPage *);
+ QWebPagePrivate(QWebPage*);
~QWebPagePrivate();
void createMainFrame();
#ifndef QT_NO_CONTEXTMENU
- QMenu *createContextMenu(const WebCore::ContextMenu *webcoreMenu, const QList<WebCore::ContextMenuItem> *items, QBitArray *visitedWebActions);
+ QMenu* createContextMenu(const WebCore::ContextMenu* webcoreMenu, const QList<WebCore::ContextMenuItem>* items, QBitArray* visitedWebActions);
#endif
-
- QWebFrame *frameAt(const QPoint &pos) const;
-
void _q_onLoadProgressChanged(int);
void _q_webActionTriggered(bool checked);
#ifndef NDEBUG
@@ -113,7 +109,7 @@ public:
void shortcutOverrideEvent(QKeyEvent*);
void leaveEvent(QEvent *);
- bool handleScrolling(QKeyEvent*);
+ bool handleScrolling(QKeyEvent*, WebCore::Frame*);
#ifndef QT_NO_SHORTCUT
static QWebPage::WebAction editorActionForKeyEvent(QKeyEvent* event);
diff --git a/WebKit/qt/Api/qwebplugindatabase.cpp b/WebKit/qt/Api/qwebplugindatabase.cpp
new file mode 100644
index 0000000..8758c60
--- /dev/null
+++ b/WebKit/qt/Api/qwebplugindatabase.cpp
@@ -0,0 +1,382 @@
+/*
+ Copyright (C) 2009 Jakub Wieczorek <faw217@gmail.com>
+
+ 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 "qwebplugindatabase.h"
+#include "qwebplugindatabase_p.h"
+
+#include "PluginDatabase.h"
+#include "PluginPackage.h"
+
+using namespace WebCore;
+
+/*!
+ \typedef QWebPluginInfo::MimeType
+ \since 4.6
+ \brief Represents a single MIME type supported by a plugin.
+*/
+
+QWebPluginInfoPrivate::QWebPluginInfoPrivate(RefPtr<PluginPackage> pluginPackage)
+ : plugin(pluginPackage)
+{
+}
+
+QWebPluginDatabasePrivate::QWebPluginDatabasePrivate(PluginDatabase* pluginDatabase)
+ : database(pluginDatabase)
+{
+}
+
+/*!
+ \class QWebPluginInfo
+ \since 4.6
+ \brief The QWebPluginInfo class represents a single Netscape plugin.
+
+ A QWebPluginInfo object represents a Netscape plugin picked up by WebKit
+ and included in the plugin database. This class contains information about
+ the plugin, such as its name(), description(), a list of MIME types that it
+ supports (can be accessed with mimeTypes()) and the path of the plugin
+ file.
+
+ Plugins can be enabled and disabled with setEnabled(). If a plugin is
+ disabled, it will not be used by WebKit to handle supported MIME types. To
+ check if a plugin is enabled or not, use enabled().
+
+ \sa QWebPluginDatabase
+*/
+
+/*!
+ Constructs a null QWebPluginInfo.
+*/
+QWebPluginInfo::QWebPluginInfo()
+ : d(new QWebPluginInfoPrivate(0))
+{
+}
+
+QWebPluginInfo::QWebPluginInfo(PluginPackage* plugin)
+ : d(new QWebPluginInfoPrivate(plugin))
+{
+}
+
+/*!
+ Contructs a copy of \a other.
+*/
+QWebPluginInfo::QWebPluginInfo(const QWebPluginInfo& other)
+ : d(new QWebPluginInfoPrivate(other.d->plugin))
+{
+}
+
+/*!
+ Destroys the plugin info.
+*/
+QWebPluginInfo::~QWebPluginInfo()
+{
+ delete d;
+}
+
+/*!
+ Returns the name of the plugin.
+
+ \sa description()
+*/
+QString QWebPluginInfo::name() const
+{
+ if (!d->plugin)
+ return QString();
+ return d->plugin->name();
+}
+
+/*!
+ Returns the description of the plugin.
+
+ \sa name()
+*/
+QString QWebPluginInfo::description() const
+{
+ if (!d->plugin)
+ return QString();
+ return d->plugin->description();
+}
+
+/*!
+ Returns a list of MIME types supported by the plugin.
+
+ \sa supportsMimeType()
+*/
+QList<QWebPluginInfo::MimeType> QWebPluginInfo::mimeTypes() const
+{
+ if (!d->plugin)
+ return QList<MimeType>();
+
+ QList<MimeType> mimeTypes;
+ const MIMEToDescriptionsMap& mimeToDescriptions = d->plugin->mimeToDescriptions();
+ MIMEToDescriptionsMap::const_iterator end = mimeToDescriptions.end();
+ for (MIMEToDescriptionsMap::const_iterator it = mimeToDescriptions.begin(); it != end; ++it) {
+ MimeType mimeType;
+ mimeType.name = it->first;
+ mimeType.description = it->second;
+
+ QStringList fileExtensions;
+ Vector<String> extensions = d->plugin->mimeToExtensions().get(mimeType.name);
+
+ for (unsigned i = 0; i < extensions.size(); ++i)
+ fileExtensions.append(extensions[i]);
+
+ mimeType.fileExtensions = fileExtensions;
+ mimeTypes.append(mimeType);
+ }
+
+ return mimeTypes;
+}
+
+/*!
+ Returns true if the plugin supports a specific \a mimeType; otherwise
+ returns false.
+
+ \sa mimeTypes()
+*/
+bool QWebPluginInfo::supportsMimeType(const QString& mimeType) const
+{
+ QList<MimeType> types = mimeTypes();
+ foreach (const MimeType& type, types) {
+ if (type.name == mimeType)
+ return true;
+ }
+
+ return false;
+}
+
+/*!
+ Returns an absolute path to the plugin file.
+*/
+QString QWebPluginInfo::path() const
+{
+ if (!d->plugin)
+ return QString();
+ return d->plugin->path();
+}
+
+/*!
+ Returns true if the plugin is a null plugin; otherwise returns false.
+*/
+bool QWebPluginInfo::isNull() const
+{
+ return !d->plugin;
+}
+
+/*!
+ Enables or disables the plugin, depending on the \a enabled parameter.
+
+ Disabled plugins will not be picked up by WebKit when looking for a plugin
+ supporting a particular MIME type.
+
+ \sa isEnabled()
+*/
+void QWebPluginInfo::setEnabled(bool enabled)
+{
+ if (!d->plugin)
+ return;
+ d->plugin->setEnabled(enabled);
+}
+
+/*!
+ Returns true if the plugin is enabled; otherwise returns false.
+
+ \sa setEnabled()
+*/
+bool QWebPluginInfo::isEnabled() const
+{
+ if (!d->plugin)
+ return false;
+ return d->plugin->isEnabled();
+}
+
+bool QWebPluginInfo::operator==(const QWebPluginInfo& other) const
+{
+ return d->plugin == other.d->plugin;
+}
+
+bool QWebPluginInfo::operator!=(const QWebPluginInfo& other) const
+{
+ return d->plugin != other.d->plugin;
+}
+
+QWebPluginInfo &QWebPluginInfo::operator=(const QWebPluginInfo& other)
+{
+ if (this == &other)
+ return *this;
+
+ d->plugin = other.d->plugin;
+ return *this;
+}
+
+/*!
+ \class QWebPluginDatabase
+ \since 4.6
+ \brief The QWebPluginDatabase class provides an interface for managing
+ Netscape plugins used by WebKit in QWebPages.
+
+ The QWebPluginDatabase class is a database of Netscape plugins that are used
+ by WebKit. The plugins are picked up by WebKit by looking up a set of search paths.
+ The default set can be accessed using defaultSearchPaths(). The search paths
+ can be changed, see searchPaths() and setSearchPaths(). Additional search paths
+ can also be added using addSearchPath().
+
+ The plugins that have been detected are exposed by the plugins() method.
+ The list contains QWebPlugin objects that hold both the metadata and the MIME
+ types that are supported by particular plugins.
+
+ WebKit specifies a plugin for a MIME type by looking for the first plugin that
+ supports the specific MIME type. To get a plugin, that is used by WebKit to
+ handle a specific MIME type, you can use the pluginForMimeType() function.
+
+ To change the way of resolving MIME types ambiguity, you can explicitly set
+ a preferred plugin for a specific MIME type, using setPreferredPluginForMimeType().
+
+ \sa QWebPluginInfo, QWebSettings::pluginDatabase()
+*/
+
+QWebPluginDatabase::QWebPluginDatabase(QObject* parent)
+ : QObject(parent)
+ , d(new QWebPluginDatabasePrivate(PluginDatabase::installedPlugins()))
+{
+}
+
+QWebPluginDatabase::~QWebPluginDatabase()
+{
+ delete d;
+}
+
+/*!
+ Returns a list of plugins installed in the search paths.
+
+ This list will contain disabled plugins, although they will not be used by
+ WebKit.
+
+ \sa pluginForMimeType()
+*/
+QList<QWebPluginInfo> QWebPluginDatabase::plugins() const
+{
+ QList<QWebPluginInfo> qwebplugins;
+ const Vector<PluginPackage*>& plugins = d->database->plugins();
+
+ for (unsigned int i = 0; i < plugins.size(); ++i) {
+ PluginPackage* plugin = plugins[i];
+ qwebplugins.append(QWebPluginInfo(plugin));
+ }
+
+ return qwebplugins;
+}
+
+/*!
+ Returns a default set of search paths.
+
+ \sa searchPaths(), setSearchPaths()
+*/
+QStringList QWebPluginDatabase::defaultSearchPaths()
+{
+ QStringList paths;
+
+ const Vector<String>& directories = PluginDatabase::defaultPluginDirectories();
+ for (unsigned int i = 0; i < directories.size(); ++i)
+ paths.append(directories[i]);
+
+ return paths;
+}
+
+/*!
+ Returns a list of search paths that are used by WebKit to look for plugins.
+
+ \sa defaultSearchPaths(), setSearchPaths()
+*/
+QStringList QWebPluginDatabase::searchPaths() const
+{
+ QStringList paths;
+
+ const Vector<String>& directories = d->database->pluginDirectories();
+ for (unsigned int i = 0; i < directories.size(); ++i)
+ paths.append(directories[i]);
+
+ return paths;
+}
+
+/*!
+ Changes the search paths to \a paths.
+ The database is automatically refreshed.
+
+ \sa searchPaths(), defaultSearchPaths()
+*/
+void QWebPluginDatabase::setSearchPaths(const QStringList& paths)
+{
+ Vector<String> directories;
+
+ for (unsigned int i = 0; i < paths.count(); ++i)
+ directories.append(paths.at(i));
+
+ d->database->setPluginDirectories(directories);
+ // PluginDatabase::setPluginDirectories() does not refresh the database.
+ d->database->refresh();
+}
+
+/*!
+ Adds an additional \a path to the current set.
+ The database is automatically refreshed.
+
+ \sa searchPaths(), setSearchPaths()
+*/
+void QWebPluginDatabase::addSearchPath(const QString& path)
+{
+ d->database->addExtraPluginDirectory(path);
+ // PluginDatabase::addExtraPluginDirectory() does refresh the database.
+}
+
+/*!
+ Refreshes the plugin database, adds new plugins that have been found and removes
+ the ones that are no longer available in the search paths.
+
+ You can call this function when the set of plugins installed in the search paths
+ changes. You do not need to call this function when changing search paths,
+ in that case WebKit automatically refreshes the database.
+*/
+void QWebPluginDatabase::refresh()
+{
+ d->database->refresh();
+}
+
+/*!
+ Returns the plugin that is currently used by WebKit for a given \a mimeType.
+
+ \sa setPreferredPluginForMimeType()
+*/
+QWebPluginInfo QWebPluginDatabase::pluginForMimeType(const QString& mimeType)
+{
+ return QWebPluginInfo(d->database->pluginForMIMEType(mimeType));
+}
+
+/*!
+ Changes the preferred plugin for a given \a mimeType to \a plugin. The \a plugin
+ has to support the given \a mimeType, otherwise the setting will have no effect.
+
+ Calling the function with a null \a plugin resets the setting.
+
+ \sa pluginForMimeType()
+*/
+void QWebPluginDatabase::setPreferredPluginForMimeType(const QString& mimeType, const QWebPluginInfo& plugin)
+{
+ d->database->setPreferredPluginForMIMEType(mimeType, plugin.d->plugin.get());
+}
diff --git a/WebKit/qt/Api/qwebplugindatabase.h b/WebKit/qt/Api/qwebplugindatabase.h
new file mode 100644
index 0000000..4b50119
--- /dev/null
+++ b/WebKit/qt/Api/qwebplugindatabase.h
@@ -0,0 +1,94 @@
+/*
+ Copyright (C) 2009 Jakub Wieczorek <faw217@gmail.com>
+
+ 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 QWEBPLUGINDATABASE_H
+#define QWEBPLUGINDATABASE_H
+
+#include "qwebkitglobal.h"
+#include "qwebpluginfactory.h"
+
+#include <QtCore/qobject.h>
+#include <QtCore/qstringlist.h>
+
+namespace WebCore {
+ class PluginPackage;
+}
+
+class QWebPluginInfoPrivate;
+class QWEBKIT_EXPORT QWebPluginInfo {
+public:
+ QWebPluginInfo();
+ QWebPluginInfo(const QWebPluginInfo& other);
+ QWebPluginInfo &operator=(const QWebPluginInfo& other);
+ ~QWebPluginInfo();
+
+private:
+ QWebPluginInfo(WebCore::PluginPackage* plugin);
+
+public:
+ typedef QWebPluginFactory::MimeType MimeType;
+
+ QString name() const;
+ QString description() const;
+ QList<MimeType> mimeTypes() const;
+ bool supportsMimeType(const QString& mimeType) const;
+ QString path() const;
+
+ bool isNull() const;
+
+ void setEnabled(bool enabled);
+ bool isEnabled() const;
+
+ bool operator==(const QWebPluginInfo& other) const;
+ bool operator!=(const QWebPluginInfo& other) const;
+
+ friend class QWebPluginDatabase;
+
+private:
+ QWebPluginInfoPrivate *d;
+};
+
+class QWebPluginDatabasePrivate;
+class QWEBKIT_EXPORT QWebPluginDatabase : public QObject {
+ Q_OBJECT
+
+private:
+ QWebPluginDatabase(QObject* parent = 0);
+ ~QWebPluginDatabase();
+
+public:
+ QList<QWebPluginInfo> plugins() const;
+
+ static QStringList defaultSearchPaths();
+ QStringList searchPaths() const;
+ void setSearchPaths(const QStringList& paths);
+ void addSearchPath(const QString& path);
+
+ void refresh();
+
+ QWebPluginInfo pluginForMimeType(const QString& mimeType);
+ void setPreferredPluginForMimeType(const QString& mimeType, const QWebPluginInfo& plugin);
+
+ friend class QWebSettings;
+
+private:
+ QWebPluginDatabasePrivate *d;
+};
+
+#endif // QWEBPLUGINDATABASE_H
diff --git a/WebKit/qt/Api/qwebplugindatabase_p.h b/WebKit/qt/Api/qwebplugindatabase_p.h
new file mode 100644
index 0000000..714458f
--- /dev/null
+++ b/WebKit/qt/Api/qwebplugindatabase_p.h
@@ -0,0 +1,46 @@
+/*
+ Copyright (C) 2009 Jakub Wieczorek <faw217@gmail.com>
+
+ 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 QWEBPLUGINDATABASE_P_H
+#define QWEBPLUGINDATABASE_P_H
+
+#include "qwebkitglobal.h"
+
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+ class PluginPackage;
+ class PluginDatabase;
+};
+
+class QWebPluginInfoPrivate {
+public:
+ QWebPluginInfoPrivate(RefPtr<WebCore::PluginPackage> pluginPackage);
+
+ RefPtr<WebCore::PluginPackage> plugin;
+};
+
+class QWebPluginDatabasePrivate {
+public:
+ QWebPluginDatabasePrivate(WebCore::PluginDatabase* pluginDatabase);
+
+ WebCore::PluginDatabase* database;
+};
+
+#endif // QWEBPLUGINDATABASE_P_H
diff --git a/WebKit/qt/Api/qwebpluginfactory.cpp b/WebKit/qt/Api/qwebpluginfactory.cpp
index d2bb124..7a8cabe 100644
--- a/WebKit/qt/Api/qwebpluginfactory.cpp
+++ b/WebKit/qt/Api/qwebpluginfactory.cpp
@@ -70,6 +70,13 @@
\brief The QWebPluginFactory::MimeType structure describes a mime type supported by a plugin.
*/
+bool QWebPluginFactory::MimeType::operator==(const MimeType& other) const
+{
+ return name == other.name
+ && description == other.description
+ && fileExtensions == other.fileExtensions;
+}
+
/*!
\variable QWebPluginFactory::MimeType::name
diff --git a/WebKit/qt/Api/qwebpluginfactory.h b/WebKit/qt/Api/qwebpluginfactory.h
index 3531b06..4a06b59 100644
--- a/WebKit/qt/Api/qwebpluginfactory.h
+++ b/WebKit/qt/Api/qwebpluginfactory.h
@@ -31,14 +31,15 @@ class QString;
QT_END_NAMESPACE
class QWebPluginFactoryPrivate;
-class QWEBKIT_EXPORT QWebPluginFactory : public QObject
-{
+class QWEBKIT_EXPORT QWebPluginFactory : public QObject {
Q_OBJECT
public:
- struct MimeType {
+ struct QWEBKIT_EXPORT MimeType {
QString name;
QString description;
QStringList fileExtensions;
+ bool operator==(const MimeType& other) const;
+ inline bool operator!=(const MimeType& other) const { return !operator==(other); }
};
struct Plugin {
@@ -47,16 +48,16 @@ public:
QList<MimeType> mimeTypes;
};
- explicit QWebPluginFactory(QObject *parent = 0);
+ 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;
+ virtual QObject *create(const QString& mimeType,
+ const QUrl&,
+ const QStringList& argumentNames,
+ const QStringList& argumentValues) const = 0;
enum Extension {
};
@@ -64,11 +65,11 @@ public:
{};
class ExtensionReturn
{};
- virtual bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0);
+ virtual bool extension(Extension extension, const ExtensionOption* option = 0, ExtensionReturn* output = 0);
virtual bool supportsExtension(Extension extension) const;
private:
- QWebPluginFactoryPrivate *d;
+ QWebPluginFactoryPrivate* d;
};
#endif
diff --git a/WebKit/qt/Api/qwebsecurityorigin.cpp b/WebKit/qt/Api/qwebsecurityorigin.cpp
index c08785f..d2eaf10 100644
--- a/WebKit/qt/Api/qwebsecurityorigin.cpp
+++ b/WebKit/qt/Api/qwebsecurityorigin.cpp
@@ -36,10 +36,9 @@ using namespace WebCore;
\brief The QWebSecurityOrigin class defines a security boundary for web sites.
QWebSecurityOrigin provides access to the security domains defined by web sites.
- An origin consists of a host name, a scheme, and a port number. Web sites with the same
- security origin can access each other's resources for client-side scripting or databases.
-
- ### diagram
+ An origin consists of a host name, a scheme, and a port number. Web sites
+ with the same security origin can access each other's resources for client-side
+ scripting or databases.
For example the site \c{http://www.example.com/my/page.html} is allowed to share the same
database as \c{http://www.example.com/my/overview.html}, or access each other's
@@ -47,7 +46,13 @@ using namespace WebCore;
\c{http://www.malicious.com/evil.html} from accessing \c{http://www.example.com/}'s resources,
because they are of a different security origin.
- QWebSecurity also provides access to all databases defined within a security origin.
+ Call QWebFrame::securityOrigin() to get the QWebSecurityOrigin for a frame in a
+ web page, and use host(), scheme() and port() to identify the security origin.
+
+ Use databases() to access the databases defined within a security origin. The
+ disk usage of the origin's databases can be limited with setDatabaseQuota().
+ databaseQuota() and databaseUsage() report the current limit as well as the
+ current usage.
For more information refer to the
\l{http://en.wikipedia.org/wiki/Same_origin_policy}{"Same origin policy" Wikipedia Article}.
@@ -154,14 +159,18 @@ QWebSecurityOrigin::QWebSecurityOrigin(QWebSecurityOriginPrivate* priv)
*/
QList<QWebSecurityOrigin> QWebSecurityOrigin::allOrigins()
{
+ QList<QWebSecurityOrigin> webOrigins;
+
+#if ENABLE(DATABASE)
Vector<RefPtr<SecurityOrigin> > coreOrigins;
DatabaseTracker::tracker().origins(coreOrigins);
- QList<QWebSecurityOrigin> webOrigins;
for (unsigned i = 0; i < coreOrigins.size(); ++i) {
QWebSecurityOriginPrivate* priv = new QWebSecurityOriginPrivate(coreOrigins[i].get());
webOrigins.append(priv);
}
+#endif
+
return webOrigins;
}
@@ -170,8 +179,11 @@ QList<QWebSecurityOrigin> QWebSecurityOrigin::allOrigins()
*/
QList<QWebDatabase> QWebSecurityOrigin::databases() const
{
- Vector<String> nameVector;
QList<QWebDatabase> databases;
+
+#if ENABLE(DATABASE)
+ Vector<String> nameVector;
+
if (!DatabaseTracker::tracker().databaseNamesForOrigin(d->origin.get(), nameVector))
return databases;
for (unsigned i = 0; i < nameVector.size(); ++i) {
@@ -181,6 +193,8 @@ QList<QWebDatabase> QWebSecurityOrigin::databases() const
QWebDatabase webDatabase(priv);
databases.append(webDatabase);
}
+#endif
+
return databases;
}
diff --git a/WebKit/qt/Api/qwebsecurityorigin.h b/WebKit/qt/Api/qwebsecurityorigin.h
index b52194d..3cfb0f4 100644
--- a/WebKit/qt/Api/qwebsecurityorigin.h
+++ b/WebKit/qt/Api/qwebsecurityorigin.h
@@ -34,8 +34,7 @@ class QWebSecurityOriginPrivate;
class QWebDatabase;
class QWebFrame;
-class QWEBKIT_EXPORT QWebSecurityOrigin
-{
+class QWEBKIT_EXPORT QWebSecurityOrigin {
public:
static QList<QWebSecurityOrigin> allOrigins();
diff --git a/WebKit/qt/Api/qwebsecurityorigin_p.h b/WebKit/qt/Api/qwebsecurityorigin_p.h
index 73fe8ed..cdc93bd 100644
--- a/WebKit/qt/Api/qwebsecurityorigin_p.h
+++ b/WebKit/qt/Api/qwebsecurityorigin_p.h
@@ -23,8 +23,7 @@
#include "SecurityOrigin.h"
#include "RefPtr.h"
-class QWebSecurityOriginPrivate : public QSharedData
-{
+class QWebSecurityOriginPrivate : public QSharedData {
public:
QWebSecurityOriginPrivate(WebCore::SecurityOrigin* o)
{
diff --git a/WebKit/qt/Api/qwebsettings.cpp b/WebKit/qt/Api/qwebsettings.cpp
index f6acc42..47b2818 100644
--- a/WebKit/qt/Api/qwebsettings.cpp
+++ b/WebKit/qt/Api/qwebsettings.cpp
@@ -22,8 +22,11 @@
#include "qwebpage.h"
#include "qwebpage_p.h"
+#include "qwebplugindatabase.h"
#include "Cache.h"
+#include "CrossOriginPreflightResultCache.h"
+#include "FontCache.h"
#include "Page.h"
#include "PageCache.h"
#include "Settings.h"
@@ -40,10 +43,9 @@
#include <QUrl>
#include <QFileInfo>
-class QWebSettingsPrivate
-{
+class QWebSettingsPrivate {
public:
- QWebSettingsPrivate(WebCore::Settings *wcSettings = 0)
+ QWebSettingsPrivate(WebCore::Settings* wcSettings = 0)
: settings(wcSettings)
{
}
@@ -52,12 +54,13 @@ public:
QHash<int, int> fontSizes;
QHash<int, bool> attributes;
QUrl userStyleSheetLocation;
+ QString defaultTextEncoding;
QString localStorageDatabasePath;
QString offlineWebApplicationCachePath;
qint64 offlineStorageDefaultQuota;
void apply();
- WebCore::Settings *settings;
+ WebCore::Settings* settings;
};
typedef QHash<int, QPixmap> WebGraphicHash;
@@ -77,14 +80,14 @@ static WebGraphicHash* graphics()
return hash;
}
-Q_GLOBAL_STATIC(QList<QWebSettingsPrivate *>, allSettings);
+Q_GLOBAL_STATIC(QList<QWebSettingsPrivate*>, allSettings);
void QWebSettingsPrivate::apply()
{
if (settings) {
settings->setTextAreasAreResizable(true);
- QWebSettingsPrivate *global = QWebSettings::globalSettings()->d;
+ QWebSettingsPrivate* global = QWebSettings::globalSettings()->d;
QString family = fontFamilies.value(QWebSettings::StandardFont,
global->fontFamilies.value(QWebSettings::StandardFont));
@@ -161,6 +164,9 @@ void QWebSettingsPrivate::apply()
QUrl location = !userStyleSheetLocation.isEmpty() ? userStyleSheetLocation : global->userStyleSheetLocation;
settings->setUserStyleSheetLocation(WebCore::KURL(location));
+ QString encoding = !defaultTextEncoding.isEmpty() ? defaultTextEncoding: global->defaultTextEncoding;
+ settings->setDefaultTextEncodingName(encoding);
+
QString localStoragePath = !localStorageDatabasePath.isEmpty() ? localStorageDatabasePath : global->localStorageDatabasePath;
settings->setLocalStorageDatabasePath(localStoragePath);
@@ -184,11 +190,11 @@ void QWebSettingsPrivate::apply()
global->attributes.value(QWebSettings::LocalStorageDatabaseEnabled));
settings->setLocalStorageEnabled(value);
- value = attributes.value(QWebSettings::AllowUniversalAccessFromFileUrls,
- global->attributes.value(QWebSettings::AllowUniversalAccessFromFileUrls));
+ value = attributes.value(QWebSettings::LocalContentCanAccessRemoteUrls,
+ global->attributes.value(QWebSettings::LocalContentCanAccessRemoteUrls));
settings->setAllowUniversalAccessFromFileURLs(value);
} else {
- QList<QWebSettingsPrivate *> settings = *::allSettings();
+ QList<QWebSettingsPrivate*> settings = *::allSettings();
for (int i = 0; i < settings.count(); ++i)
settings[i]->apply();
}
@@ -200,9 +206,9 @@ void QWebSettingsPrivate::apply()
Any setting changed on the default object is automatically applied to all
QWebPage instances where the particular setting is not overriden already.
*/
-QWebSettings *QWebSettings::globalSettings()
+QWebSettings* QWebSettings::globalSettings()
{
- static QWebSettings *global = 0;
+ static QWebSettings* global = 0;
if (!global)
global = new QWebSettings;
return global;
@@ -217,17 +223,25 @@ QWebSettings *QWebSettings::globalSettings()
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().
+ 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 allows configuration of browser properties, such as font sizes and
+ families, the location of a custom style sheet, and generic attributes like
+ JavaScript and plugins. Individual attributes are set using the setAttribute()
+ function. The \l{QWebSettings::WebAttribute}{WebAttribute} enum further describes
+ each attribute.
- QWebSettings also configures global properties such as the web page memory
- cache and the web page icon database, local database storage and offline
+ QWebSettings also configures global properties such as the Web page memory
+ cache and the Web page icon database, local database storage and offline
applications storage.
+ \section1 Enabling Plugins
+
+ Support for browser plugins can enabled by setting the
+ \l{QWebSettings::PluginsEnabled}{PluginsEnabled} attribute. For many applications,
+ this attribute is enabled for all pages by setting it on the
+ \l{globalSettings()}{global settings object}.
+
\section1 Web Application Support
WebKit provides support for features specified in \l{HTML 5} that improve the
@@ -314,8 +328,7 @@ QWebSettings *QWebSettings::globalSettings()
web application cache feature is enabled or not.
\value LocalStorageDatabaseEnabled Specifies whether support for the HTML 5
local storage feature is enabled or not.
- \value AllowUniversalAccessFromFileUrls Specifies whether documents from file
- Urls should be granted universal access (e.g., to HTTP and HTTPS documents).
+ \value LocalContentCanAccessRemoteUrls Specifies whether locally loaded documents are allowed to access remote urls.
*/
/*!
@@ -344,15 +357,14 @@ QWebSettings::QWebSettings()
d->attributes.insert(QWebSettings::OfflineStorageDatabaseEnabled, true);
d->attributes.insert(QWebSettings::OfflineWebApplicationCacheEnabled, true);
d->attributes.insert(QWebSettings::LocalStorageDatabaseEnabled, true);
- d->attributes.insert(QWebSettings::AllowUniversalAccessFromFileUrls, true);
+ d->attributes.insert(QWebSettings::LocalContentCanAccessRemoteUrls, true);
d->offlineStorageDefaultQuota = 5 * 1024 * 1024;
-
}
/*!
\internal
*/
-QWebSettings::QWebSettings(WebCore::Settings *settings)
+QWebSettings::QWebSettings(WebCore::Settings* settings)
: d(new QWebSettingsPrivate(settings))
{
d->settings = settings;
@@ -387,7 +399,7 @@ int QWebSettings::fontSize(FontSize type) const
{
int defaultValue = 0;
if (d->settings) {
- QWebSettingsPrivate *global = QWebSettings::globalSettings()->d;
+ QWebSettingsPrivate* global = QWebSettings::globalSettings()->d;
defaultValue = global->fontSizes.value(type);
}
return d->fontSizes.value(type, defaultValue);
@@ -414,7 +426,7 @@ void QWebSettings::resetFontSize(FontSize type)
\sa userStyleSheetUrl()
*/
-void QWebSettings::setUserStyleSheetUrl(const QUrl &location)
+void QWebSettings::setUserStyleSheetUrl(const QUrl& location)
{
d->userStyleSheetLocation = location;
d->apply();
@@ -431,6 +443,33 @@ QUrl QWebSettings::userStyleSheetUrl() const
}
/*!
+ \since 4.6
+ Specifies the default text encoding system.
+
+ The \a encoding, must be a string describing an encoding such as "utf-8",
+ "iso-8859-1", etc. If left empty a default value will be used. For a more
+ extensive list of encoding names see \l{QTextCodec}
+
+ \sa defaultTextEncoding()
+*/
+void QWebSettings::setDefaultTextEncoding(const QString& encoding)
+{
+ d->defaultTextEncoding = encoding;
+ d->apply();
+}
+
+/*!
+ \since 4.6
+ Returns the default text encoding.
+
+ \sa setDefaultTextEncoding()
+*/
+QString QWebSettings::defaultTextEncoding() const
+{
+ return d->defaultTextEncoding;
+}
+
+/*!
Sets the path of the icon database to \a path. The icon database is used
to store "favicons" associated with web sites.
@@ -438,7 +477,7 @@ QUrl QWebSettings::userStyleSheetUrl() const
Setting an empty path disables the icon database.
*/
-void QWebSettings::setIconDatabasePath(const QString &path)
+void QWebSettings::setIconDatabasePath(const QString& path)
{
WebCore::iconDatabase()->delayDatabaseCleanup();
@@ -461,11 +500,10 @@ void QWebSettings::setIconDatabasePath(const QString &path)
*/
QString QWebSettings::iconDatabasePath()
{
- if (WebCore::iconDatabase()->isEnabled() && WebCore::iconDatabase()->isOpen()) {
+ if (WebCore::iconDatabase()->isEnabled() && WebCore::iconDatabase()->isOpen())
return WebCore::iconDatabase()->databasePath();
- } else {
+ else
return QString();
- }
}
/*!
@@ -487,18 +525,29 @@ void QWebSettings::clearIconDatabase()
\sa setIconDatabasePath()
*/
-QIcon QWebSettings::iconForUrl(const QUrl &url)
+QIcon QWebSettings::iconForUrl(const QUrl& url)
{
WebCore::Image* image = WebCore::iconDatabase()->iconForPageURL(WebCore::KURL(url).string(),
WebCore::IntSize(16, 16));
- if (!image) {
+ if (!image)
return QPixmap();
- }
- QPixmap *icon = image->nativeImageForCurrentFrame();
- if (!icon) {
+
+ QPixmap* icon = image->nativeImageForCurrentFrame();
+ if (!icon)
return QPixmap();
- }
- return *icon;
+
+ return* icon;
+}
+
+/*!
+ Returns the plugin database object.
+*/
+QWebPluginDatabase *QWebSettings::pluginDatabase()
+{
+ static QWebPluginDatabase* database = 0;
+ if (!database)
+ database = new QWebPluginDatabase();
+ return database;
}
/*!
@@ -510,9 +559,9 @@ QIcon QWebSettings::iconForUrl(const QUrl &url)
\sa webGraphic()
*/
-void QWebSettings::setWebGraphic(WebGraphic type, const QPixmap &graphic)
+void QWebSettings::setWebGraphic(WebGraphic type, const QPixmap& graphic)
{
- WebGraphicHash *h = graphics();
+ WebGraphicHash* h = graphics();
if (graphic.isNull())
h->remove(type);
else
@@ -534,6 +583,40 @@ QPixmap QWebSettings::webGraphic(WebGraphic type)
}
/*!
+ Frees up as much memory as possible by cleaning all memory caches such
+ as page, object and font cache.
+
+ \since 4.6
+ */
+void QWebSettings::clearMemoryCaches()
+{
+ // Turn the cache on and off. Disabling the object cache will remove all
+ // resources from the cache. They may still live on if they are referenced
+ // by some Web page though.
+ if (!WebCore::cache()->disabled()) {
+ WebCore::cache()->setDisabled(true);
+ WebCore::cache()->setDisabled(false);
+ }
+
+ int pageCapacity = WebCore::pageCache()->capacity();
+ // Setting size to 0, makes all pages be released.
+ WebCore::pageCache()->setCapacity(0);
+ WebCore::pageCache()->releaseAutoreleasedPagesNow();
+ WebCore::pageCache()->setCapacity(pageCapacity);
+
+ // Invalidating the font cache and freeing all inactive font data.
+ WebCore::fontCache()->invalidate();
+
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+ // Empty the application cache.
+ WebCore::cacheStorage().empty();
+#endif
+
+ // Empty the Cross-Origin Preflight cache
+ WebCore::CrossOriginPreflightResultCache::shared().empty();
+}
+
+/*!
Sets the maximum number of pages to hold in the memory cache to \a pages.
*/
void QWebSettings::setMaximumPagesInCache(int pages)
@@ -555,7 +638,7 @@ int QWebSettings::maximumPagesInCache()
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.
@@ -567,7 +650,7 @@ int QWebSettings::maximumPagesInCache()
*/
void QWebSettings::setObjectCacheCapacities(int cacheMinDeadCapacity, int cacheMaxDead, int totalCapacity)
{
- bool disableCache = cacheMinDeadCapacity == 0 && cacheMaxDead == 0 && totalCapacity == 0;
+ bool disableCache = !cacheMinDeadCapacity && !cacheMaxDead && !totalCapacity;
WebCore::cache()->setDisabled(disableCache);
WebCore::cache()->setCapacities(qMax(0, cacheMinDeadCapacity),
@@ -579,7 +662,7 @@ void QWebSettings::setObjectCacheCapacities(int cacheMinDeadCapacity, int cacheM
Sets the actual font family to \a family for the specified generic family,
\a which.
*/
-void QWebSettings::setFontFamily(FontFamily which, const QString &family)
+void QWebSettings::setFontFamily(FontFamily which, const QString& family)
{
d->fontFamilies.insert(which, family);
d->apply();
@@ -593,7 +676,7 @@ QString QWebSettings::fontFamily(FontFamily which) const
{
QString defaultValue;
if (d->settings) {
- QWebSettingsPrivate *global = QWebSettings::globalSettings()->d;
+ QWebSettingsPrivate* global = QWebSettings::globalSettings()->d;
defaultValue = global->fontFamilies.value(which);
}
return d->fontFamilies.value(which, defaultValue);
@@ -615,7 +698,7 @@ void QWebSettings::resetFontFamily(FontFamily which)
/*!
\fn void QWebSettings::setAttribute(WebAttribute attribute, bool on)
-
+
Enables or disables the specified \a attribute feature depending on the
value of \a on.
*/
@@ -634,7 +717,7 @@ bool QWebSettings::testAttribute(WebAttribute attr) const
{
bool defaultValue = false;
if (d->settings) {
- QWebSettingsPrivate *global = QWebSettings::globalSettings()->d;
+ QWebSettingsPrivate* global = QWebSettings::globalSettings()->d;
defaultValue = global->attributes.value(attr);
}
return d->attributes.value(attr, defaultValue);
@@ -712,35 +795,43 @@ qint64 QWebSettings::offlineStorageDefaultQuota()
return QWebSettings::globalSettings()->d->offlineStorageDefaultQuota;
}
-/*
- \internal
+/*!
+ \since 4.6
\relates QWebSettings
-
+
Sets the path for HTML5 offline web application cache storage to \a path.
+ An application cache acts like an HTTP cache in some sense. For documents
+ that use the application cache via JavaScript, the loader mechinery will
+ first ask the application cache for the contents, before hitting the
+ network.
+
+ The feature is described in details at:
+ http://dev.w3.org/html5/spec/Overview.html#appcache
+
\a path must point to an existing directory where the cache is stored.
Setting an empty path disables the feature.
\sa offlineWebApplicationCachePath()
*/
-void QWEBKIT_EXPORT qt_websettings_setOfflineWebApplicationCachePath(const QString& path)
+void QWebSettings::setOfflineWebApplicationCachePath(const QString& path)
{
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
WebCore::cacheStorage().setCacheDirectory(path);
#endif
}
-/*
- \internal
+/*!
+ \since 4.6
\relates QWebSettings
-
+
Returns the path of the HTML5 offline web application cache storage
or an empty string if the feature is disabled.
\sa setOfflineWebApplicationCachePath()
*/
-QString QWEBKIT_EXPORT qt_websettings_offlineWebApplicationCachePath()
+QString QWebSettings::offlineWebApplicationCachePath()
{
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
return WebCore::cacheStorage().cacheDirectory();
@@ -749,6 +840,33 @@ QString QWEBKIT_EXPORT qt_websettings_offlineWebApplicationCachePath()
#endif
}
+/*!
+ \since 4.6
+
+ Sets the value of the quota for the offline web application cache
+ to \a maximumSize.
+*/
+void QWebSettings::setOfflineWebApplicationCacheQuota(qint64 maximumSize)
+{
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+ WebCore::cacheStorage().setMaximumSize(maximumSize);
+#endif
+}
+
+/*!
+ \since 4.6
+
+ Returns the value of the quota for the offline web application cache.
+*/
+qint64 QWebSettings::offlineWebApplicationCacheQuota()
+{
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+ return WebCore::cacheStorage().maximumSize();
+#else
+ return 0;
+#endif
+}
+
/*
\since 4.5
\relates QWebSettings
@@ -763,7 +881,7 @@ QString QWEBKIT_EXPORT qt_websettings_offlineWebApplicationCachePath()
*/
void QWEBKIT_EXPORT qt_websettings_setLocalStorageDatabasePath(QWebSettings* settings, const QString& path)
{
- QWebSettingsPrivate *d = settings->handle();
+ QWebSettingsPrivate* d = settings->handle();
d->localStorageDatabasePath = path;
d->apply();
}
diff --git a/WebKit/qt/Api/qwebsettings.h b/WebKit/qt/Api/qwebsettings.h
index 5610797..b7ea54b 100644
--- a/WebKit/qt/Api/qwebsettings.h
+++ b/WebKit/qt/Api/qwebsettings.h
@@ -27,19 +27,18 @@
#include <QtGui/qicon.h>
#include <QtCore/qshareddata.h>
-namespace WebCore
-{
+namespace WebCore {
class Settings;
}
class QWebPage;
+class QWebPluginDatabase;
class QWebSettingsPrivate;
QT_BEGIN_NAMESPACE
class QUrl;
QT_END_NAMESPACE
-class QWEBKIT_EXPORT QWebSettings
-{
+class QWEBKIT_EXPORT QWebSettings {
public:
enum FontFamily {
StandardFont,
@@ -64,7 +63,7 @@ public:
OfflineStorageDatabaseEnabled,
OfflineWebApplicationCacheEnabled,
LocalStorageDatabaseEnabled,
- AllowUniversalAccessFromFileUrls
+ LocalContentCanAccessRemoteUrls
};
enum WebGraphic {
MissingImageGraphic,
@@ -96,11 +95,16 @@ public:
void setUserStyleSheetUrl(const QUrl &location);
QUrl userStyleSheetUrl() const;
+ void setDefaultTextEncoding(const QString &encoding);
+ QString defaultTextEncoding() const;
+
static void setIconDatabasePath(const QString &location);
static QString iconDatabasePath();
static void clearIconDatabase();
static QIcon iconForUrl(const QUrl &url);
+ static QWebPluginDatabase *pluginDatabase();
+
static void setWebGraphic(WebGraphic type, const QPixmap &graphic);
static QPixmap webGraphic(WebGraphic type);
@@ -113,6 +117,13 @@ public:
static void setOfflineStorageDefaultQuota(qint64 maximumSize);
static qint64 offlineStorageDefaultQuota();
+ static void setOfflineWebApplicationCachePath(const QString& path);
+ static QString offlineWebApplicationCachePath();
+ static void setOfflineWebApplicationCacheQuota(qint64 maximumSize);
+ static qint64 offlineWebApplicationCacheQuota();
+
+ static void clearMemoryCaches();
+
inline QWebSettingsPrivate* handle() const { return d; }
private:
diff --git a/WebKit/qt/Api/qwebview.cpp b/WebKit/qt/Api/qwebview.cpp
index ea503a1..e1a0c98 100644
--- a/WebKit/qt/Api/qwebview.cpp
+++ b/WebKit/qt/Api/qwebview.cpp
@@ -27,13 +27,15 @@
#include "qevent.h"
#include "qpainter.h"
#include "qprinter.h"
+#include "qdir.h"
+#include "qfile.h"
-class QWebViewPrivate
-{
+class QWebViewPrivate {
public:
QWebViewPrivate(QWebView *view)
: view(view)
, page(0)
+ , renderHints(QPainter::TextAntialiasing)
#ifndef QT_NO_CURSOR
, cursorSetByWebCore(false)
, usesWebCoreCursor(true)
@@ -43,6 +45,7 @@ public:
QWebView *view;
QWebPage *page;
+ QPainter::RenderHints renderHints;
#ifndef QT_NO_CURSOR
/*
@@ -83,10 +86,10 @@ public:
\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
+ 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
+ \snippet webkitsnippets/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.
@@ -143,7 +146,8 @@ public:
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}
+ \sa {Previewer Example}, {Web Browser}, {Form Extractor Example},
+ {Google Chat Example}, {Fancy Browser Example}
*/
/*!
@@ -202,16 +206,15 @@ QWebPage *QWebView::page() const
\sa page()
*/
-void QWebView::setPage(QWebPage *page)
+void QWebView::setPage(QWebPage* page)
{
if (d->page == page)
return;
if (d->page) {
- if (d->page->parent() == this) {
+ if (d->page->parent() == this)
delete d->page;
- } else {
+ else
d->page->disconnect(this);
- }
}
d->page = page;
if (d->page) {
@@ -245,11 +248,84 @@ void QWebView::setPage(QWebPage *page)
}
/*!
+ Returns a valid URL from a user supplied \a string if one can be deducted.
+ In the case that is not possible, an invalid QUrl() is returned.
+
+ \since 4.6
+
+ Most applications that can browse the web, allow the user to input a URL
+ in the form of a plain string. This string can be manually typed into
+ a location bar, obtained from the clipboard, or passed in via command
+ line arguments.
+
+ When the string is not already a valid URL, a best guess is performed,
+ making various web related assumptions.
+
+ In the case the string corresponds to a valid file path on the system,
+ a file:// URL is constructed, using QUrl::fromLocalFile().
+
+ If that is not the case, an attempt is made to turn the string into a
+ http:// or ftp:// URL. The latter in the case the string starts with
+ 'ftp'. The result is then passed through QUrl's tolerant parser, and
+ in the case or success, a valid QUrl is returned, or else a QUrl().
+
+ \section1 Examples:
+
+ \list
+ \o webkit.org becomes http://webkit.org
+ \o ftp.webkit.org becomes ftp://ftp.webkit.org
+ \o localhost becomes http://localhost
+ \o /home/user/test.html becomes file:///home/user/test.html (if exists)
+ \endlist
+
+ \section2 Tips when dealing with URLs and strings:
+
+ \list
+ \o When creating a QString from a QByteArray or a char*, always use
+ QString::fromUtf8().
+ \o Do not use QUrl(string), nor QUrl::toString() anywhere where the URL might
+ be used, such as in the location bar, as those functions loose data.
+ Instead use QUrl::fromEncoded() and QUrl::toEncoded(), respectively.
+ \endlist
+ */
+QUrl QWebView::guessUrlFromString(const QString &string)
+{
+ QString trimmedString = string.trimmed();
+
+ // Check the most common case of a valid url with scheme and host first
+ QUrl url = QUrl::fromEncoded(trimmedString.toUtf8(), QUrl::TolerantMode);
+ if (url.isValid() && !url.scheme().isEmpty() && !url.host().isEmpty())
+ return url;
+
+ // Absolute files that exists
+ if (QDir::isAbsolutePath(trimmedString) && QFile::exists(trimmedString))
+ return QUrl::fromLocalFile(trimmedString);
+
+ // If the string is missing the scheme or the scheme is not valid prepend a scheme
+ QString scheme = url.scheme();
+ if (scheme.isEmpty() || scheme.contains(QLatin1Char('.')) || scheme == QLatin1String("localhost")) {
+ // Do not do anything for strings such as "foo", only "foo.com"
+ int dotIndex = trimmedString.indexOf(QLatin1Char('.'));
+ if (dotIndex != -1 || trimmedString.startsWith(QLatin1String("localhost"))) {
+ const QString hostscheme = trimmedString.left(dotIndex).toLower();
+ QByteArray scheme = (hostscheme == QLatin1String("ftp")) ? "ftp" : "http";
+ trimmedString = QLatin1String(scheme) + QLatin1String("://") + trimmedString;
+ }
+ url = QUrl::fromEncoded(trimmedString.toUtf8(), QUrl::TolerantMode);
+ }
+
+ if (url.isValid())
+ return url;
+
+ return QUrl();
+}
+
+/*!
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()
+ \sa setUrl(), url(), urlChanged(), guessUrlFromString()
*/
void QWebView::load(const QUrl &url)
{
@@ -289,6 +365,8 @@ void QWebView::load(const QNetworkRequest &request,
External objects such as stylesheets or images referenced in the HTML
document are located relative to \a baseUrl.
+ The \a html is loaded immediately; external objects are loaded asynchronously.
+
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
@@ -309,6 +387,8 @@ void QWebView::setHtml(const QString &html, const QUrl &baseUrl)
External objects referenced in the content are located relative to \a baseUrl.
+ The \a data is loaded immediately; external objects are loaded asynchronously.
+
\sa load(), setHtml(), QWebFrame::toHtml()
*/
void QWebView::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
@@ -321,7 +401,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 webkitsnippets/qtwebkit_qwebview_snippet.cpp 0
*/
QWebHistory *QWebView::history() const
{
@@ -333,7 +413,7 @@ QWebHistory *QWebView::history() const
It is equivalent to
- \snippet doc/src/snippets/code/src_3rdparty_webkit_WebKit_qt_Api_qwebview.cpp 1
+ \snippet webkitsnippets/qtwebkit_qwebview_snippet.cpp 1
\sa QWebSettings::globalSettings()
*/
@@ -425,7 +505,7 @@ QAction *QWebView::pageAction(QWebPage::WebAction action) const
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 webkitsnippets/qtwebkit_qwebview_snippet.cpp 2
\sa pageAction()
*/
@@ -529,9 +609,61 @@ qreal QWebView::textSizeMultiplier() const
}
/*!
- 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.
+ \property QWebView::renderHints
+ \since 4.6
+ \brief the default render hints for the view
+
+ These hints are used to initialize QPainter before painting the web page.
+
+ QPainter::TextAntialiasing is enabled by default.
+
+ \sa QPainter::renderHints()
+*/
+QPainter::RenderHints QWebView::renderHints() const
+{
+ return d->renderHints;
+}
+
+void QWebView::setRenderHints(QPainter::RenderHints hints)
+{
+ if (hints == d->renderHints)
+ return;
+ d->renderHints = hints;
+ update();
+}
+
+/*!
+ If \a enabled is true, the render hint \a hint is enabled; otherwise it
+ is disabled.
+
+ \since 4.6
+ \sa renderHints
+*/
+void QWebView::setRenderHint(QPainter::RenderHint hint, bool enabled)
+{
+ QPainter::RenderHints oldHints = d->renderHints;
+ if (enabled)
+ d->renderHints |= hint;
+ else
+ d->renderHints &= ~hint;
+ if (oldHints != d->renderHints)
+ update();
+}
+
+
+/*!
+ Finds the specified string, \a subString, in the page, using the given \a options.
+
+ If the HighlightAllOccurrences flag is passed, the function will highlight all occurrences
+ that exist in the page. All subsequent calls will extend the highlight, rather than
+ replace it, with occurrences of the new string.
+
+ If the HighlightAllOccurrences flag is not passed, the function will select an occurrence
+ and all subsequent calls will replace the current occurrence with the next one.
+
+ To clear the selection, just pass an empty string.
+
+ Returns true if \a subString was found; otherwise returns false.
\sa selectedText(), selectionChanged()
*/
@@ -577,9 +709,8 @@ bool QWebView::event(QEvent *e)
}
#endif
#endif
- } else if (e->type() == QEvent::Leave) {
+ } else if (e->type() == QEvent::Leave)
d->page->event(e);
- }
}
return QWidget::event(e);
@@ -602,7 +733,7 @@ void QWebView::print(QPrinter *printer) const
It is equivalent to
- \snippet doc/src/snippets/code/src_3rdparty_webkit_WebKit_qt_Api_qwebview.cpp 3
+ \snippet webkitsnippets/qtwebkit_qwebview_snippet.cpp 3
\sa reload(), pageAction(), loadFinished()
*/
@@ -618,7 +749,7 @@ void QWebView::stop()
It is equivalent to
- \snippet doc/src/snippets/code/src_3rdparty_webkit_WebKit_qt_Api_qwebview.cpp 4
+ \snippet webkitsnippets/qtwebkit_qwebview_snippet.cpp 4
\sa forward(), pageAction()
*/
@@ -634,7 +765,7 @@ void QWebView::back()
It is equivalent to
- \snippet doc/src/snippets/code/src_3rdparty_webkit_WebKit_qt_Api_qwebview.cpp 5
+ \snippet webkitsnippets/qtwebkit_qwebview_snippet.cpp 5
\sa back(), pageAction()
*/
@@ -676,12 +807,13 @@ void QWebView::paintEvent(QPaintEvent *ev)
QWebFrame *frame = d->page->mainFrame();
QPainter p(this);
+ p.setRenderHints(d->renderHints);
frame->render(&p, ev->region());
#ifdef QWEBKIT_TIME_RENDERING
int elapsed = time.elapsed();
- qDebug()<<"paint event on "<<ev->region()<<", took to render = "<<elapsed;
+ qDebug() << "paint event on " << ev->region() << ", took to render = " << elapsed;
#endif
}
@@ -877,9 +1009,8 @@ void QWebView::inputMethodEvent(QInputMethodEvent *e)
*/
void QWebView::changeEvent(QEvent *e)
{
- if (d->page && e->type() == QEvent::PaletteChange) {
+ if (d->page && e->type() == QEvent::PaletteChange)
d->page->setPalette(palette());
- }
QWidget::changeEvent(e);
}
@@ -910,7 +1041,10 @@ void QWebView::changeEvent(QEvent *e)
This signal is emitted whenever the icon of the page is loaded or changes.
- \sa icon()
+ In order for icons to be loaded, you will need to set an icon database path
+ using QWebSettings::setIconDatabasePath().
+
+ \sa icon(), QWebSettings::setIconDatabasePath()
*/
/*!
diff --git a/WebKit/qt/Api/qwebview.h b/WebKit/qt/Api/qwebview.h
index 1172f39..e886144 100644
--- a/WebKit/qt/Api/qwebview.h
+++ b/WebKit/qt/Api/qwebview.h
@@ -25,6 +25,7 @@
#include "qwebpage.h"
#include <QtGui/qwidget.h>
#include <QtGui/qicon.h>
+#include <QtGui/qpainter.h>
#include <QtCore/qurl.h>
#if QT_VERSION >= 0x040400
#include <QtNetwork/qnetworkaccessmanager.h>
@@ -39,8 +40,7 @@ class QWebPage;
class QWebViewPrivate;
class QWebNetworkRequest;
-class QWEBKIT_EXPORT QWebView : public QWidget
-{
+class QWEBKIT_EXPORT QWebView : public QWidget {
Q_OBJECT
Q_PROPERTY(QString title READ title)
Q_PROPERTY(QUrl url READ url WRITE setUrl)
@@ -50,26 +50,30 @@ class QWEBKIT_EXPORT QWebView : public QWidget
//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)
+ Q_PROPERTY(QPainter::RenderHints renderHints READ renderHints WRITE setRenderHints)
+ Q_FLAGS(QPainter::RenderHints)
public:
- explicit QWebView(QWidget *parent = 0);
+ explicit QWebView(QWidget* parent = 0);
virtual ~QWebView();
- QWebPage *page() const;
- void setPage(QWebPage *page);
+ QWebPage* page() const;
+ void setPage(QWebPage* page);
- void load(const QUrl &url);
+ static QUrl guessUrlFromString(const QString& string);
+
+ void load(const QUrl& url);
#if QT_VERSION < 0x040400 && !defined(qdoc)
- void load(const QWebNetworkRequest &request);
+ void load(const QWebNetworkRequest& request);
#else
- void load(const QNetworkRequest &request,
+ void load(const QNetworkRequest& request,
QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation,
const QByteArray &body = QByteArray());
#endif
- void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
- void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl());
+ void setHtml(const QString& html, const QUrl& baseUrl = QUrl());
+ void setContent(const QByteArray& data, const QString& mimeType = QString(), const QUrl& baseUrl = QUrl());
- QWebHistory *history() const;
- QWebSettings *settings() const;
+ QWebHistory* history() const;
+ QWebSettings* settings() const;
QString title() const;
void setUrl(const QUrl &url);
@@ -78,7 +82,7 @@ public:
QString selectedText() const;
- QAction *pageAction(QWebPage::WebAction action) const;
+ QAction* pageAction(QWebPage::WebAction action) const;
void triggerPageAction(QWebPage::WebAction action, bool checked = false);
bool isModified() const;
@@ -99,9 +103,13 @@ public:
void setTextSizeMultiplier(qreal factor);
qreal textSizeMultiplier() const;
- bool findText(const QString &subString, QWebPage::FindFlags options = 0);
+ QPainter::RenderHints renderHints() const;
+ void setRenderHints(QPainter::RenderHints hints);
+ void setRenderHint(QPainter::RenderHint hint, bool enabled = true);
+
+ bool findText(const QString& subString, QWebPage::FindFlags options = 0);
- virtual bool event(QEvent *);
+ virtual bool event(QEvent*);
public Q_SLOTS:
void stop();
@@ -109,7 +117,7 @@ public Q_SLOTS:
void forward();
void reload();
- void print(QPrinter *printer) const;
+ void print(QPrinter*) const;
Q_SIGNALS:
void loadStarted();
@@ -117,14 +125,14 @@ Q_SIGNALS:
void loadFinished(bool);
void titleChanged(const QString& title);
void statusBarMessage(const QString& text);
- void linkClicked(const QUrl &url);
+ void linkClicked(const QUrl&);
void selectionChanged();
void iconChanged();
- void urlChanged(const QUrl &url);
+ void urlChanged(const QUrl&);
protected:
- void resizeEvent(QResizeEvent *e);
- void paintEvent(QPaintEvent *ev);
+ void resizeEvent(QResizeEvent*);
+ void paintEvent(QPaintEvent*);
virtual QWebView *createWindow(QWebPage::WebWindowType type);
@@ -141,10 +149,10 @@ protected:
#endif
virtual void keyPressEvent(QKeyEvent*);
virtual void keyReleaseEvent(QKeyEvent*);
- virtual void dragEnterEvent(QDragEnterEvent *);
- virtual void dragLeaveEvent(QDragLeaveEvent *);
- virtual void dragMoveEvent(QDragMoveEvent *);
- virtual void dropEvent(QDropEvent *);
+ virtual void dragEnterEvent(QDragEnterEvent*);
+ virtual void dragLeaveEvent(QDragLeaveEvent*);
+ virtual void dragMoveEvent(QDragMoveEvent*);
+ virtual void dropEvent(QDropEvent*);
virtual void focusInEvent(QFocusEvent*);
virtual void focusOutEvent(QFocusEvent*);
virtual void inputMethodEvent(QInputMethodEvent*);
@@ -153,7 +161,7 @@ protected:
private:
friend class QWebPage;
- QWebViewPrivate *d;
+ QWebViewPrivate* d;
};
#endif // QWEBVIEW_H
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index ba6d3ae..6b05b18 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,2466 @@
+2009-08-10 Kavindra Palaraja <kavindra.palaraja@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Various fixes and improvements to the QWebPluginInfo, QWebPluginDatabase and QWebSettings documentation.
+
+ * Api/qwebplugindatabase.cpp:
+ * Api/qwebsettings.cpp:
+
+2009-08-08 Volker Hilsheimer <volker.hilsheimer@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Doc: there is no group of explicitly shared classes, only one class uses this.
+
+ Explain the implications in the QWebHistoryItem documentation, and get rid
+ of the "group".
+
+ * Api/qwebhistory.cpp:
+
+2009-08-05 Csaba Osztrogonac <oszi@inf.u-szeged.hu>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Fix build error caused by http://trac.webkit.org/changeset/46763
+
+ * Api/qwebpluginfactory.h: Export macro added.
+
+2009-08-04 Antonio Gomes <antonio.gomes@openbossa.org>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] QWebFrame::requestedUrl method can mis-behave in case of unhandled sslErrors.
+ https://bugs.webkit.org/show_bug.cgi?id=27804
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::requestedUrl):
+ * tests/qwebframe/tst_qwebframe.cpp:
+
+2009-08-04 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Reviewed by Tor Arne Vestbø.
+
+ Rename QWebPlugin to QWebPluginInfo, as discussed on IRC.
+
+ * Api/qwebplugindatabase.cpp:
+ (QWebPluginInfoPrivate::QWebPluginInfoPrivate):
+ (QWebPluginInfo::QWebPluginInfo):
+ (QWebPluginInfo::~QWebPluginInfo):
+ (QWebPluginInfo::name):
+ (QWebPluginInfo::description):
+ (QWebPluginInfo::mimeTypes):
+ (QWebPluginInfo::supportsMimeType):
+ (QWebPluginInfo::path):
+ (QWebPluginInfo::isNull):
+ (QWebPluginInfo::setEnabled):
+ (QWebPluginInfo::isEnabled):
+ (QWebPluginInfo::operator==):
+ (QWebPluginInfo::operator!=):
+ (QWebPluginInfo::operator=):
+ (QWebPluginDatabase::plugins):
+ (QWebPluginDatabase::pluginForMimeType):
+ (QWebPluginDatabase::setPreferredPluginForMimeType):
+ * Api/qwebplugindatabase.h:
+ * Api/qwebplugindatabase_p.h:
+ * tests/qwebplugindatabase/tst_qwebplugindatabase.cpp:
+ (tst_QWebPluginDatabase::installedPlugins):
+ (tst_QWebPluginDatabase::searchPaths):
+ (tst_QWebPluginDatabase::null_data):
+ (tst_QWebPluginDatabase::null):
+ (tst_QWebPluginDatabase::pluginForMimeType):
+ (tst_QWebPluginDatabase::enabled):
+ (tst_QWebPluginDatabase::operatorequal_data):
+ (tst_QWebPluginDatabase::operatorequal):
+ (tst_QWebPluginDatabase::preferredPlugin):
+
+2009-08-04 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Reviewed by Adam Treat.
+
+ Replace QWebPlugin::MimeType with a typedef to
+ QWebPluginFactory::MimeType.
+
+ * Api/qwebplugindatabase.cpp:
+ * Api/qwebplugindatabase.h:
+ * Api/qwebpluginfactory.cpp:
+ (QWebPluginFactory::MimeType::operator==):
+ * Api/qwebpluginfactory.h:
+
+2009-08-04 Jakub Wieczorek <faw217@gmail.com>
+
+ Reviewed by Simon Hausmann.
+
+ Add QWebPluginDatabase API to the Qt API.
+
+ https://bugs.webkit.org/show_bug.cgi?id=27651
+
+ * Api/headers.pri:
+ * Api/qwebplugindatabase.cpp: Added.
+ (QWebPluginPrivate::QWebPluginPrivate):
+ (QWebPluginDatabasePrivate::QWebPluginDatabasePrivate):
+ (QWebPlugin::MimeType::operator==):
+ (QWebPlugin::QWebPlugin):
+ (QWebPlugin::~QWebPlugin):
+ (QWebPlugin::name):
+ (QWebPlugin::description):
+ (QWebPlugin::mimeTypes):
+ (QWebPlugin::supportsMimeType):
+ (QWebPlugin::path):
+ (QWebPlugin::isNull):
+ (QWebPlugin::setEnabled):
+ (QWebPlugin::isEnabled):
+ (QWebPlugin::operator==):
+ (QWebPlugin::operator!=):
+ (QWebPlugin::operator=):
+ (QWebPluginDatabase::QWebPluginDatabase):
+ (QWebPluginDatabase::~QWebPluginDatabase):
+ (QWebPluginDatabase::plugins):
+ (QWebPluginDatabase::defaultSearchPaths):
+ (QWebPluginDatabase::searchPaths):
+ (QWebPluginDatabase::setSearchPaths):
+ (QWebPluginDatabase::addSearchPath):
+ (QWebPluginDatabase::refresh):
+ (QWebPluginDatabase::pluginForMimeType):
+ (QWebPluginDatabase::setPreferredPluginForMimeType):
+ * Api/qwebplugindatabase.h: Added.
+ * Api/qwebplugindatabase_p.h: Added.
+ * Api/qwebsettings.cpp:
+ (QWebSettings::pluginDatabase):
+ * Api/qwebsettings.h:
+ * tests/qwebplugindatabase/qwebplugindatabase.pro: Added.
+ * tests/qwebplugindatabase/tst_qwebplugindatabase.cpp: Added.
+ (tst_QWebPluginDatabase::installedPlugins):
+ (tst_QWebPluginDatabase::searchPaths):
+ (tst_QWebPluginDatabase::null_data):
+ (tst_QWebPluginDatabase::null):
+ (tst_QWebPluginDatabase::pluginForMimeType):
+ (tst_QWebPluginDatabase::enabled):
+ (tst_QWebPluginDatabase::operatorequal_data):
+ (tst_QWebPluginDatabase::operatorequal):
+ (tst_QWebPluginDatabase::preferredPlugin):
+ * tests/tests.pro:
+
+2009-08-03 Balazs Kelemen <kelemen.balazs.3@stud.u-szeged.hu>
+
+ Reviewed by Simon Hausmann.
+
+ Do memory cleanup when running robotized QtLauncher in debug as well.
+
+ * QtLauncher/main.cpp:
+ (launcherMain):
+ (main):
+
+2009-07-30 Laszlo Gombos <laszlo.1.gombos@nokia.com>
+
+ Reviewed by Tor Arne Vestbø.
+
+ [Qt] Initialize HTML5 Application Cache for QtWebKit to a sensible default
+ https://bugs.webkit.org/show_bug.cgi?id=27866
+
+ * Api/qwebpage.cpp:
+ (initializeApplicationCachePathIfNecessary):
+ (QWebPagePrivate::QWebPagePrivate):
+
+2009-07-31 Jakob Petsovits <jakob.petsovits@torchmobile.com>
+
+ Reviewed by Adam Treat.
+
+ Build QtWebKit without benchmark tests for Qt < 4.5.
+ https://bugs.webkit.org/show_bug.cgi?id=27886
+
+ The QBENCHMARK macro is only available from 4.5 on,
+ so builds for Qt < 4.5 shouldn't try to build those.
+
+ * tests/tests.pro:
+
+2009-07-31 Kenneth Rohde Christiansen <kenneth@webkit.org>
+
+ Reviewed by Adam Treat.
+
+ Fix warning by migrating use of QString.sprintf(...) to
+ QString.arg().arg()...
+
+ * WebCoreSupport/EditorClientQt.cpp:
+ (dumpRange):
+
+2009-07-31 Kenneth Rohde Christiansen <kenneth@webkit.org>
+
+ Reviewed by Tor Arne Vestbø.
+
+ Expose the Offline Web Application Cache in the Qt API.
+
+ * Api/qwebsettings.cpp:
+ (QWebSettings::QWebSettings):
+ (QWebSettings::setOfflineWebApplicationCachePath):
+ (QWebSettings::offlineWebApplicationCachePath):
+ (QWebSettings::setOfflineWebApplicationCacheQuota):
+ (QWebSettings::offlineWebApplicationCacheQuota):
+ * Api/qwebsettings.h:
+
+2009-07-30 Kenneth Rohde Christiansen <kenneth@webkit.org>
+
+ Reviewed by Adam Treat.
+
+ Add missing Q_OBJECT to class inheriting from QObject.
+
+ * tests/qwebframe/tst_qwebframe.cpp:
+
+2009-07-30 Kenneth Rohde Christiansen <kenneth@webkit.org>
+
+ Reviewed by Adam Treat.
+
+ Fix indentation.
+
+ * tests/qwebframe/tst_qwebframe.cpp:
+
+2009-07-30 Volker Hilsheimer <volker.hilsheimer@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Fix documentation links to examples.
+
+ * Api/qwebview.cpp:
+
+2009-07-30 Balazs Kelemen <kelemen.balazs.3@stud.u-szeged.hu>
+
+ Reviewed by Simon Hausmann.
+
+ Allocate MainWindow on heap in robotized QtLauncher as well.
+
+ * QtLauncher/main.cpp:
+ (main):
+
+2009-07-29 Kevin McCullough <kmccullough@apple.com>
+
+ Reviewed by Darin Adler.
+
+ Added foundation work to allow a testing infrastructure for the Web
+ Inspector.
+
+ * WebCoreSupport/InspectorClientQt.cpp:
+ (WebCore::InspectorClientQt::inspectorWindowObjectCleared):
+ * WebCoreSupport/InspectorClientQt.h:
+
+2009-07-29 Zoltan Herczeg <zherczeg@inf.u-szeged.hu>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] In debug mode, this fix frees cached resources
+ and other unreferenced objects (by calling the
+ garbage collector) to remove the LEAK messages.
+ https://bugs.webkit.org/show_bug.cgi?id=27767
+
+ * Api/qwebframe.cpp:
+ (qt_drt_cache_clear):
+ * QtLauncher/main.cpp:
+ (main):
+
+2009-07-28 Kenneth Rohde Christiansen <kenneth@webkit.org>
+
+ Fix the Qt build by adapting to the changes of ScriptObject.
+
+ * Api/qwebelement.cpp:
+ (setupScriptObject):
+
+2009-07-28 Robert Hogan <robert@roberthogan.net>
+
+ Reviewed by Simon Hausmann.
+
+ Add WebKit version API to Qt.
+
+ Get the current version of WebKit from WebKit/mac/Configurations/Version.xcconfig
+ at compile time and make it available to Qt applications through
+ qWebKitVersion().
+
+ Also amend the User Agent string to place the Safari clause outside
+ the final bracket and to the end of the UA string.
+
+ https://bugs.webkit.org/show_bug.cgi?id=27158
+
+ Minor build tweak by Simon Hausmann (adding export macros to new functions).
+
+ * Api/headers.pri:
+ * Api/qwebkitversion.cpp: Added.
+ (webKitVersion):
+ (webKitMajorVersion):
+ (webKitMinorVersion):
+ * Api/qwebkitversion.h: Added.
+ * Api/qwebpage.cpp:
+ (QWebPage::userAgentForUrl):
+ * tests/qwebview/tst_qwebview.cpp:
+ (tst_QWebView::getWebKitVersion):
+
+2009-07-28 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Rubber-stamped by Ariya Hidayat.
+
+ Fix compilation with the precompiled header.
+
+ * WebKit_pch.h: Don't include JSDOMBinding.h and MathObject.h,
+ as they include AtomicString.h. AtomicString.cpp needs to enable
+ a #define before including AtomicString.h, which breaks if the PCH
+ forces the inclusion beforehand.
+
+2009-07-28 Ariya Hidayat <ariya.hidayat@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Added tests to ensure that scroll position can be changed
+ programmatically, even when the scroll bar policy is set to off.
+
+ * tests/qwebframe/tst_qwebframe.cpp:
+
+2009-07-28 Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Fix a few compilation warnings in the QWebFrame tests.
+
+ * tests/qwebframe/tst_qwebframe.cpp:
+
+2009-07-28 Andre Pedralho <andre.pedralho@openbossa.org>
+
+ Reviewed by Simon Hausmann.
+
+ Fixed tst_QWebFrame::hasSetFocus test which was using
+ an undefined resource.
+ https://bugs.webkit.org/show_bug.cgi?id=27512
+
+ * tests/qwebframe/tst_qwebframe.cpp:
+
+2009-07-28 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Reviewed by Ariya Hidayat.
+
+ Make it possible to pass relative file names to QtLauncher.
+
+ * QtLauncher/main.cpp:
+ (MainWindow::MainWindow):
+
+2009-07-27 Alexey Proskuryakov <ap@webkit.org>
+
+ Reviewed by Darin Adler.
+
+ https://bugs.webkit.org/show_bug.cgi?id=27735
+ Give a helpful name to JSLock constructor argument
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::addToJavaScriptWindowObject):
+
+2009-07-27 Volker Hilsheimer <volker.hilsheimer@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ QWebView's "enabled" parameter should default to true, as with QGraphicsView and
+ QPainter.
+
+ * Api/qwebview.cpp: Add reference to QPainter::renderHints().
+ * Api/qwebview.h: Add default for enabled argument.
+
+2009-07-26 Kavindra Palaraja <kavindra.palaraja@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ More documentation cleanups in the QWebElement class overview.
+
+ * Api/qwebelement.cpp:
+
+2009-07-26 Kavindra Palaraja <kavindra.palaraja@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Clean up documentation of QWebElement's findFirst and findAll functions,
+ as well as their QWebFrame counterparts.
+
+ * Api/qwebelement.cpp:
+ * Api/qwebframe.cpp:
+
+2009-07-26 Kavindra Palaraja <kavindra.palaraja@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Various documentation cleanups
+
+ * Fixed qdoc warnings
+ * Hide QWebNetworkInterface from the class overview
+ * Mention QWebElement in the module overview
+ * More cleanups
+
+ * Api/qwebframe.cpp:
+ * Api/qwebnetworkinterface.cpp:
+ * Api/qwebview.cpp:
+ * docs/qtwebkit.qdoc:
+
+2009-07-26 Kavindra Palaraja <kavindra.palaraja@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Added missing class diagram referenced from the docs, taken from the Qt
+ documentation.
+
+ * docs/qtwebkit.qdocconf: Register the image directory with
+ qdoc.
+ * docs/qwebview-diagram.png: Added.
+
+2009-07-24 Antonio Gomes <antonio.gomes@openbossa.org>
+
+ Reviewed by Adam Treat.
+
+ As per discussion on IRC, changed originalUrl by requestedUrl.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::requestedUrl):
+ * Api/qwebframe.h:
+ * tests/qwebframe/tst_qwebframe.cpp:
+
+2009-07-24 Andre Pedralho <andre.pedralho@openbossa.org>
+
+ Reviewed by Adam Treat.
+
+ Removed void QWebFrame::renderContents(...) and added the Q_PROPERTY
+ clipRenderToViewport to control whether QWebFrame::render would call
+ FrameView::paintContents rather than FrameView::paint and do not clip
+ the frame content to viewport.
+
+
+ * Api/qwebframe.cpp:
+ (QWebFramePrivate::renderPrivate):
+ (QWebFrame::clipRenderToViewport):
+ (QWebFrame::setClipRenderToViewport):
+ * Api/qwebframe.h:
+ * Api/qwebframe_p.h:
+ (QWebFramePrivate::QWebFramePrivate):
+ * tests/qwebframe/tst_qwebframe.cpp:
+
+2009-07-24 Antonio Gomes <antonio.gomes@openbossa.org>
+
+ Reviewed by Simon Hausmann.
+
+ [QT] Implement originalUrl getter method to the API
+ https://bugs.webkit.org/show_bug.cgi?id=25867
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::originalUrl):
+ * Api/qwebframe.h:
+ * tests/qwebframe/qwebframe.qrc:
+ * tests/qwebframe/test1.html: Added.
+ * tests/qwebframe/test2.html: Added.
+ * tests/qwebframe/tst_qwebframe.cpp:
+
+2009-07-24 Kenneth Rohde Christiansen <kenneth@webkit.org>
+
+ Build fix for Qt.
+
+ Fix build issue introduced in 46344
+ ([Bug 22700] ApplicationCache should have size limit)
+
+ Remove method only added to the Qt ChromeClient.
+
+ * WebCoreSupport/ChromeClientQt.h:
+
+2009-07-24 Andrei Popescu <andreip@google.com>
+
+ Reviewed by Anders Carlsson.
+
+ ApplicationCache should have size limit
+ https://bugs.webkit.org/show_bug.cgi?id=22700
+
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::reachedMaxAppCacheSize):
+ Adds empty implementation of the reachedMaxAppCacheSize callback.
+ * WebCoreSupport/ChromeClientQt.h:
+
+2009-07-23 Laszlo Gombos <laszlo.1.gombos@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Add simple proxy support for QtLauncher
+ https://bugs.webkit.org/show_bug.cgi?id=27495
+
+ Picks up proxy settings from the http_proxy environment
+ variable.
+
+ * QtLauncher/QtLauncher.pro: Add QtNetwork dependency for all
+ platforms.
+ * QtLauncher/main.cpp:
+ (MainWindow::MainWindow):
+
+2009-07-23 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Reviewed by Holger Freyther.
+
+ Added a testcase to verify that cached methods in the QOBject bindings
+ remain alife even after garbage collection.
+
+ * tests/qwebpage/tst_qwebpage.cpp:
+ (tst_QWebPage::protectBindingsRuntimeObjectsFromCollector):
+
+2009-07-23 Zoltan Herczeg <zherczeg@inf.u-szeged.hu>
+
+ Reviewed by Simon Hausmann.
+
+ Fixing two issues related to QtLauncher
+ - MainWindow objects are not always freed after close
+ - JavaScript window.close() sometimes crashes
+ https://bugs.webkit.org/show_bug.cgi?id=27601
+
+ * QtLauncher/main.cpp:
+ (MainWindow::MainWindow):
+ (main):
+
+2009-07-21 Volker Hilsheimer <volker.hilsheimer@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Various improvements to the API documentation.
+
+ * Updated link to W3c Database spec
+ * Formatting fixes, cleanups
+ * Add missing \since 4.6 tags to QWebPage::frameAt
+ * Extend QWebDatabase and QWebSecurityOrigin docs.
+
+ * Api/qwebdatabase.cpp:
+ * Api/qwebpage.cpp:
+ * Api/qwebsecurityorigin.cpp:
+ * Api/qwebview.cpp:
+
+2009-07-21 Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
+
+ Rubber-stamped by Simon Hausmann.
+
+ Remove preliminary-tag from QWebElement
+
+ * Api/qwebelement.cpp:
+
+2009-07-20 Kenneth Rohde Christiansen <kenneth@webkit.org>
+
+ Reviewed by Eric Seidel.
+
+ Fix Qt code to follow the WebKit Coding Style.
+
+ * Api/qcookiejar.cpp:
+ (QCookieJar::setCookieJar):
+ (QCookieJar::cookieJar):
+ * Api/qcookiejar.h:
+ * Api/qwebdatabase.cpp:
+ (QWebDatabase::QWebDatabase):
+ (QWebDatabase::removeDatabase):
+ * Api/qwebdatabase.h:
+ * Api/qwebdatabase_p.h:
+ * Api/qwebelement.h:
+ * Api/qwebframe.cpp:
+ (QWebFrame::title):
+ (QWebFrame::print):
+ * Api/qwebframe.h:
+ * Api/qwebframe_p.h:
+ * Api/qwebhistory.cpp:
+ (QWebHistory::clear):
+ * Api/qwebhistory.h:
+ * Api/qwebhistory_p.h:
+ * Api/qwebhistoryinterface.cpp:
+ (gCleanupInterface):
+ (QWebHistoryInterface::setDefaultInterface):
+ (QWebHistoryInterface::defaultInterface):
+ (QWebHistoryInterface::QWebHistoryInterface):
+ * Api/qwebhistoryinterface.h:
+ * Api/qwebnetworkinterface.cpp:
+ (QWebNetworkManager::started):
+ (QWebNetworkManager::finished):
+ (QWebNetworkInterfacePrivate::parseDataUrl):
+ (QWebNetworkInterface::addJob):
+ (WebCoreHttp::onResponseHeaderReceived):
+ (WebCoreHttp::onReadyRead):
+ * Api/qwebnetworkinterface.h:
+ * Api/qwebnetworkinterface_p.h:
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::editorCommandForWebActions):
+ (QWebPagePrivate::createContextMenu):
+ (QWebPagePrivate::focusInEvent):
+ (QWebPage::fixedContentsSize):
+ (QWebPage::setContentEditable):
+ (QWebPage::swallowContextMenuEvent):
+ (QWebPage::findText):
+ * Api/qwebpage.h:
+ * Api/qwebpage_p.h:
+ * Api/qwebpluginfactory.h:
+ * Api/qwebsecurityorigin.h:
+ * Api/qwebsecurityorigin_p.h:
+ * Api/qwebsettings.cpp:
+ (QWebSettingsPrivate::QWebSettingsPrivate):
+ (QWebSettingsPrivate::apply):
+ (QWebSettings::globalSettings):
+ (QWebSettings::QWebSettings):
+ (QWebSettings::fontSize):
+ (QWebSettings::setUserStyleSheetUrl):
+ (QWebSettings::setDefaultTextEncoding):
+ (QWebSettings::setIconDatabasePath):
+ (QWebSettings::iconDatabasePath):
+ (QWebSettings::iconForUrl):
+ (QWebSettings::setWebGraphic):
+ (QWebSettings::setFontFamily):
+ (QWebSettings::fontFamily):
+ (QWebSettings::testAttribute):
+ (qt_websettings_setLocalStorageDatabasePath):
+ * Api/qwebsettings.h:
+ * Api/qwebview.cpp:
+ (QWebView::setPage):
+ (QWebView::event):
+ * Api/qwebview.h:
+
+2009-07-20 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Add test for loading webpages...
+
+ Performance test for loading webpages. Wait for the loadFinished
+ signal to be fired. This should include a non empty layout.
+
+ * tests/benchmarks/loading/tst_loading.cpp: Added.
+ (waitForSignal):
+ (tst_Loading::init):
+ (tst_Loading::cleanup):
+ (tst_Loading::load_data):
+ (tst_Loading::load):
+ * tests/benchmarks/loading/tst_loading.pro: Added.
+ * tests/tests.pro:
+
+2009-07-20 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Add a test case for drawing a simple viewrect to a QPixmap
+
+ * tests/benchmarks/painting/tst_painting.cpp: Added.
+ (waitForSignal):
+ (tst_Painting::init):
+ (tst_Painting::cleanup):
+ (tst_Painting::paint_data):
+ (tst_Painting::paint):
+ * tests/benchmarks/painting/tst_painting.pro: Added.
+ * tests/tests.pro:
+
+2009-07-20 Laszlo Gombos <laszlo.1.gombos@nokia.com>
+
+ Reviewed by Holger Freyther.
+
+ [Qt] Add an option for QtLauncher to build without QtUiTools dependency
+ https://bugs.webkit.org/show_bug.cgi?id=27438
+
+ Based on Norbert Leser's work.
+
+ * QtLauncher/main.cpp:
+ (WebPage::createPlugin):
+
+2009-07-17 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org>
+
+ Reviewed by Adam Treat.
+
+ Coding style fixes.
+
+ * Api/qcookiejar.cpp:
+ (QCookieJarPrivate::QCookieJarPrivate):
+ (qHash):
+ (QCookieJar::cookieJar):
+ * Api/qwebelement.cpp:
+ (QWebElement::functions):
+ (QWebElement::scriptableProperties):
+ * Api/qwebframe.cpp:
+ (QWebFrame::metaData):
+ (QWebFrame::scrollBarValue):
+ (QWebFrame::scroll):
+ (QWebFrame::scrollPosition):
+ (QWebFrame::print):
+ * Api/qwebnetworkinterface.cpp:
+ (decodePercentEncoding):
+ (QWebNetworkRequestPrivate::init):
+ (QWebNetworkRequestPrivate::setURL):
+ (QWebNetworkRequest::QWebNetworkRequest):
+ (QWebNetworkRequest::operator=):
+ (QWebNetworkRequest::setUrl):
+ (QWebNetworkRequest::setHttpHeader):
+ (QWebNetworkRequest::httpHeaderField):
+ (QWebNetworkRequest::setHttpHeaderField):
+ (QWebNetworkRequest::setPostData):
+ (QWebNetworkJob::setResponse):
+ (QWebNetworkJob::frame):
+ (QWebNetworkManager::add):
+ (QWebNetworkManager::cancel):
+ (QWebNetworkManager::started):
+ (QWebNetworkManager::data):
+ (QWebNetworkManager::finished):
+ (QWebNetworkManager::addHttpJob):
+ (QWebNetworkManager::cancelHttpJob):
+ (QWebNetworkManager::httpConnectionClosed):
+ (QWebNetworkInterfacePrivate::sendFileData):
+ (QWebNetworkInterfacePrivate::parseDataUrl):
+ (QWebNetworkManager::doWork):
+ (QWebNetworkInterface::setDefaultInterface):
+ (QWebNetworkInterface::defaultInterface):
+ (QWebNetworkInterface::QWebNetworkInterface):
+ (QWebNetworkInterface::addJob):
+ (QWebNetworkInterface::cancelJob):
+ (WebCoreHttp::WebCoreHttp):
+ (WebCoreHttp::request):
+ (WebCoreHttp::scheduleNextRequest):
+ (WebCoreHttp::getConnection):
+ (WebCoreHttp::onResponseHeaderReceived):
+ (WebCoreHttp::onReadyRead):
+ (WebCoreHttp::onRequestFinished):
+ (WebCoreHttp::onAuthenticationRequired):
+ (WebCoreHttp::onProxyAuthenticationRequired):
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::QWebPagePrivate):
+ (QWebPagePrivate::mouseReleaseEvent):
+ (QWebPagePrivate::inputMethodEvent):
+ (QWebPagePrivate::shortcutOverrideEvent):
+ (QWebPage::inputMethodQuery):
+ (QWebPage::javaScriptPrompt):
+ (QWebPage::updatePositionDependentActions):
+ (QWebPage::userAgentForUrl):
+ (QWebPagePrivate::_q_onLoadProgressChanged):
+ (QWebPage::totalBytes):
+ (QWebPage::bytesReceived):
+ * Api/qwebsettings.cpp:
+ (QWebSettings::iconForUrl):
+ (QWebSettings::setObjectCacheCapacities):
+ * Api/qwebview.cpp:
+ (QWebView::paintEvent):
+ (QWebView::changeEvent):
+
+2009-07-17 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org>
+
+ Reviewed by Simon Hausmann.
+
+ Overwrite the plugin directories for the DRT.
+ Part of https://bugs.webkit.org/show_bug.cgi?id=27215
+
+ * Api/qwebpage.cpp:
+ (qt_drt_overwritePluginDirectories): Only set the plugin directories
+ to the ones in the QTWEBKIT_PLUGIN_PATH environment variable.
+
+2009-07-16 Xiaomei Ji <xji@chromium.org>
+
+ Reviewed by Dan Bernstein.
+
+ This is the 2nd part of fixing "RTL: tooltip does not get its directionlity from its element's."
+ https://bugs.webkit.org/show_bug.cgi?id=24187
+
+ Add one extra parameter to the callee of HitTestResult::title() due to the signature change.
+
+ * Api/qwebframe.cpp:
+ (QWebHitTestResultPrivate::QWebHitTestResultPrivate): Add direction as a parameter to the callee of HitTestResult::title().
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::mouseDidMoveOverElement): Add direction as a parameter to the callee of HitTestResult::title().
+
+2009-07-16 Benjamin C Meyer <benjamin.meyer@torchmobile.com>
+
+ Reviewed by Adam Treat.
+
+ Add new action to qwebpage to reload without cache.
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::updateAction):
+ (QWebPagePrivate::updateNavigationActions):
+ (QWebPage::triggerAction):
+ * Api/qwebpage.h:
+
+2009-07-16 Xiaomei Ji <xji@chromium.org>
+
+ Reviewed by Darin Adler.
+
+ Fix tooltip does not get its directionality from its element's directionality.
+ https://bugs.webkit.org/show_bug.cgi?id=24187
+
+ Per mitz's suggestion in comment #6, while getting the plain-text
+ title, we also get the directionality of the title. How to handle
+ the directionality is up to clients. Clients could ignore it,
+ or use attribute or unicode control characters to display the title
+ as what they want.
+
+
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::setToolTip): Add directionality as 2nd parameter to setToopTip() (without handling it yet).
+ * WebCoreSupport/ChromeClientQt.h: Add directionality as 2nd parameter to setToolTip().
+
+2009-07-15 Yael Aharon <yael.aharon@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ https://bugs.webkit.org/show_bug.cgi?id=27285
+
+ When the user clicks a link with a target attribute, the newly created window should be visible.
+ Make new windows created in Qtlauncher visible.
+
+ * QtLauncher/main.cpp:
+ (WebPage::createWindow):
+
+2009-07-14 Adam Treat <adam.treat@torchmobile.com>
+
+ Reviewed by Zack Rusin.
+
+ https://bugs.webkit.org/show_bug.cgi?id=26983
+
+ The default constructed values for QSize and WebCore::IntSize are different. The former
+ produces an invalid size whereas the latter produces a size of zero. This was causing
+ a layout to be triggered when constructing a view and an assert to be hit. This patch fixes
+ the crash by taking care not to cause an unnecessary layout triggered by ScrollView::setFixedLayoutSize.
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::transitionToCommittedForNewPage):
+
+2009-07-13 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Reviewed by Ariya Hidayat.
+
+ Fix qdoc warnings for QWebPage::shouldInterruptJavaScript() and mention
+ how to re-implement it.
+
+ * Api/qwebpage.cpp:
+
+2009-07-13 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Ariya Hidayat.
+
+ Fix crash with plugins when the plugin stream is cancelled.
+
+ Similar to r26667 handle the case where didReceiveResponse on the
+ plugin view results in failure to set up the stream and
+ setMainDocumentError being called instead. This will set the
+ m_pluginView back to 0 and we need check for it before calling
+ didReceiveData.
+
+ This was triggered by consecutive execution of
+ LayoutTests/plugins/return-error-from-new-stream-callback-in-full-frame-plugin.html
+ followed by LayoutTests/scrollbars/scrollbar-crash-on-refresh.html
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::committedLoad):
+
+2009-07-13 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Ariya Hidayat.
+
+ Added QWebDatabase::removeAllDatabases, as a way to delete all
+ databases from the offline storage path.
+
+ Used by the Qt DRT.
+
+ * Api/qwebdatabase.cpp:
+ (QWebDatabase::removeAllDatabases):
+ * Api/qwebdatabase.h:
+
+2009-07-13 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Ariya Hidayat.
+
+ Added loadStarted() and loadFinished() signals to QWebFrame,
+ to allow load tracking of individual frames, as opposed to
+ QWebPage's loadStarted/loadFinished signals that are emitted
+ whenever _any_ child frame loads/finishes.
+
+ * Api/qwebframe.cpp: Document new signals.
+ * Api/qwebframe.h: Add new signals.
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::setFrame): Connect new signals.
+
+2009-07-13 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Ariya Hidayat.
+
+ Add hooks for the GCController JavaScript interface needed by the
+ Qt DRT.
+
+ Fixed sort order of includes in qwebframe.cpp.
+
+ * Api/qwebframe.cpp:
+ (qt_drt_javaScriptObjectsCount):
+ (qt_drt_garbageCollector_collect):
+ (qt_drt_garbageCollector_collectOnAlternateThread):
+
+2009-07-13 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Ariya Hidayat.
+
+ Add hooks for the GCController JavaScript interface needed by the
+ Qt DRT.
+
+ Fixed sort order of includes in qwebframe.cpp.
+
+ * Api/qwebframe.cpp:
+ (qt_drt_javaScriptObjectsCount):
+ (qt_drt_garbageCollector_collect):
+ (qt_drt_garbageCollector_collectOnAlternateThread):
+
+2009-07-12 Brent Fulgham <bfulgham@gmail.com>
+
+ Speculative build fix after http://trac.webkit.org/changeset/45786.
+
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::addMessageToConsole):
+ * WebCoreSupport/ChromeClientQt.h:
+
+2009-07-10 Yael Aharon <yael.aharon@nokia.com>
+
+ Reviewed by Holger Freyther.
+
+ https://bugs.webkit.org/show_bug.cgi?id=27136
+
+ Fix a bug where webkit hangs when executing infinite JavaScript loop.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::shouldInterruptJavaScript):
+ * Api/qwebpage.h:
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::shouldInterruptJavaScript):
+ * tests/qwebpage/tst_qwebpage.cpp:
+ (JSTestPage::JSTestPage):
+ (JSTestPage::shouldInterruptJavaScript):
+ (tst_QWebPage::infiniteLoopJS):
+
+2009-07-10 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Reviewed by Holger Freyther.
+
+ https://bugs.webkit.org/show_bug.cgi?id=27108
+
+ Fix crash when in frame tree of a new frame before the new frame
+ has been installed in the frame tree, similar to r35088.
+
+ After calling Frame::init() the frame it may have been removed from the
+ frame tree again through JavaScript. Detect this by checking the page()
+ afterwards.
+
+ To make this check safe the Frame::init() code was moved into
+ QWebFrameData's constructor, where a RefPtr holds a reference to the frame.
+ After the check back in FrameLoaderClientQt we would hold the single
+ reference left and after release() the frame, its frame loader, its
+ client as well as the QWebFrame should have disappeared then.
+
+ * Api/qwebframe.cpp:
+ (QWebFramePrivate::init): Only call Frame::init here, the rest is
+ done in QWebFrameData's constructor.
+ (QWebFrame::QWebFrame):
+ * Api/qwebframe_p.h: Adjust declaration.
+ (QWebFrameData::QWebFrameData): Create the Frame here.
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::createMainFrame): Adjust and simplify
+ to new QWebFrame constructor.
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::createFrame): Adjust to
+ new QWebFrame construction using QWebFrameData and add the
+ check like in r35088.
+
+2009-07-09 Beth Dakin <bdakin@apple.com>
+
+ Reviewed by Dave Hyatt.
+
+ Make Widget RefCounted to fix:
+
+ <rdar://problem/7038831> REGRESSION (TOT): In Mail, a crash occurs
+ at WebCore::Widget::afterMouseDown() after clicking To Do's close
+ box
+ <rdar://problem/6978804> WER #16: Repro Access Violation in
+ WebCore::PluginView::bindingInstance (1310178023)
+ -and-
+ <rdar://problem/6991251> WER #13: Crash in WebKit!
+ WebCore::PluginView::performRequest+203 (1311461169)
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::createPlugin):
+ (WebCore::FrameLoaderClientQt::createJavaAppletWidget):
+ * WebCoreSupport/FrameLoaderClientQt.h:
+
+2009-07-08 Pradeepto Bhattacharya <pradeepto@kde.org>
+
+ Reviewed by Ariya Hidayat.
+
+ Build fix.
+
+ * WebCoreSupport/FrameLoaderClientQt.h: Removed the slot slotCallPolicyFunction().
+
+2009-07-08 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Tor Arne Vestbø.
+
+ https://bugs.webkit.org/show_bug.cgi?id=27080
+
+ Fix DRT instability issues with fast/loader/submit-form-while-parsing-2.html
+
+ When the form is submitted we call the policy function in the frame
+ loader delayed with a queued connection. That queued connection
+ sometimes interferes with the javascript timeout set in the testcase.
+
+ Eliminate the entire delayed policy function mechanism and instead always
+ call back directly, like in the other ports. In most other places we called
+ the slot directly anyway.
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::FrameLoaderClientQt): Remove m_policyFunction.
+ (WebCore::FrameLoaderClientQt::callPolicyFunction): Call the policy function directly instead
+ of emitting the queued signal.
+ (WebCore::FrameLoaderClientQt::cancelPolicyCheck): Call callPolicyFunction directly.
+ (WebCore::FrameLoaderClientQt::dispatchWillSubmitForm): Ditto.
+ (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForMIMEType): Ditto.
+ (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction): Ditto.
+ (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction): Ditto.
+ * WebCoreSupport/FrameLoaderClientQt.h: Remove m_policyFunction as well as the associated
+ signal.
+
+2009-07-07 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger Freyther.
+
+ Add Qt DRT hook for clearing the frame name.
+
+ * Api/qwebframe.cpp:
+ (qt_drt_clearFrameName):
+
+2009-07-05 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger Freyther.
+
+ Fix two qdoc warnings.
+
+ Added missing \property for QWebFrame::hasFocus and added \a
+ tag for pos of QWebPage::frameAt.
+
+ * Api/qwebframe.cpp:
+ * Api/qwebpage.cpp:
+
+2009-07-04 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Reviewed by Simon Hausmann.
+
+ Use the recently introduced FocusController::setFocused
+
+ Use the recently introduced FocusController::setFocused
+ in the Qt platform. The SelectionController will be updated
+ from within the FocusController now.
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::focusInEvent):
+ (QWebPagePrivate::focusOutEvent):
+
+2009-07-02 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Reviewed by Ariya Hidayat.
+
+ Improve documentation of QWebFrame::setFocus and hasFocus()
+ Added missing Q_PROPERTY for QWebFrame::hasFocus.
+
+ * Api/qwebframe.cpp: Clarify the docs.
+ * Api/qwebframe.h: add Q_PROPERTY(focus).
+
+2009-07-02 Joe Ligman <joseph.ligman@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Bug 26855: [Qt] New methods for QWebFrame to check and set focus.
+
+ Added new public methods QWebFrame::hasFocus() and QWebFrame::setFocus()
+ Added auto test.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::hasFocus):
+ (QWebFrame::setFocus):
+ * Api/qwebframe.h:
+ * tests/qwebframe/tst_qwebframe.cpp:
+
+2009-07-01 Robert Hogan <robert@roberthogan.net>
+
+ Reviewed by NOBODY.
+
+ Fix Qt segfault when javascript disabled.
+ If clients call addToJavaScriptWindowObject even though JavascriptEnabled is false
+ webkit will segfault on the assert:
+ ASSERTION FAILED: _rootObject
+ (../../../WebCore/bridge/runtime.cpp:52
+ JSC::Bindings::Instance::Instance(WTF::PassRefPtr<JSC::Bindings::RootObject>))
+ Fix is to ensure JavaScript is enabled when client calls addToJavaScriptWindowObject.
+
+ https://bugs.webkit.org/show_bug.cgi?id=26906
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::addToJavaScriptWindowObject):
+
+2009-07-01 Jakub Wieczorek <faw217@gmail.com>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Move some API headers from WebCore.pro to headers.pri so that they
+ get installed when running make install from the build directory.
+
+ * Api/headers.pri:
+
+2009-07-01 Balazs Kelemen <kelemen.balazs.3@stud.u-szeged.hu>
+
+ Reviewed by Simon Hausmann.
+
+ Fixed robotized QtLauncher to work when there is no index.html in the user's home.
+
+ * QtLauncher/main.cpp:
+ (main):
+
+2009-06-30 Brian Weinstein <bweinstein@apple.com>
+
+ Reviewed by Adam Roben.
+
+ Renamed scrollbarUnderPoint to scrollbarAtPoint to follow conventions.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::swallowContextMenuEvent):
+
+2009-06-30 Joe Ligman <joseph.ligman@nokia.com>
+
+ Reviewed by Adam Treat.
+
+ Bug 26422: [Qt] QWebPagePrivate::frameAt calculates wrong frame
+
+ Added a public method QWebPage::frameAt
+ Removed QWebPagePrivate::frameAt, which calcuated the wrong frame
+ Modified QWebPage::swallowContextMenuEvent to use the new frameAt method
+ New test case for frameAt added to tst_qwebpage.cpp
+
+ * Api/qwebpage.cpp:
+ (QWebPage::frameAt):
+ (QWebPage::swallowContextMenuEvent):
+ * Api/qwebpage.h:
+ * Api/qwebpage_p.h:
+ * tests/qwebpage/frametest/iframe.html: Added.
+ * tests/qwebpage/frametest/iframe2.html: Added.
+ * tests/qwebpage/frametest/iframe3.html: Added.
+ * tests/qwebpage/tst_qwebpage.cpp:
+ (frameAtHelper):
+ (tst_QWebPage::frameAt):
+ * tests/qwebpage/tst_qwebpage.qrc:
+
+2009-06-30 Jakub Wieczorek <faw217@gmail.com>
+
+ Reviewed by Simon Hausmann.
+
+ Add QWebFrame::baseUrl() function that exposes the base URL of a frame.
+ Autotests included.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::baseUrl):
+ * Api/qwebframe.h:
+ * tests/qwebframe/tst_qwebframe.cpp:
+
+2009-06-29 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Fix the Qt build, add missing isSpeaking() implementation to
+ ContextMenuClient.
+
+ * WebCoreSupport/ContextMenuClientQt.cpp:
+ (WebCore::ContextMenuClientQt::isSpeaking):
+ * WebCoreSupport/ContextMenuClientQt.h:
+
+2009-06-28 Sriram Yadavalli <sriram.yadavalli@nokia.com>
+
+ Reviewed by Eric Seidel.
+
+ [Qt] Fix build break for Qt
+ https://bugs.webkit.org/show_bug.cgi?id=26779
+
+ * Api/qwebpage.cpp:
+ (QWebPage::swallowContextMenuEvent):
+
+2009-06-27 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Build fix for Qt under Windows.
+
+ * Api/qwebhistory.h: Use consistent export linkage for the datastream operators.
+
+2009-06-26 Brian Weinstein <bweinstein@apple.com>
+
+ Reviewed by Simon Fraser.
+
+ Changed call of scrollbarUnderMouse to scrollbarUnderPoint to match new API.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::swallowContextMenuEvent):
+
+2009-06-26 Jedrzej Nowacki <jedrzej.nowacki@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Add support for saving and loading of QWebHistory to and from a QByteArray.
+
+ This includes streaming operators for QWebHistory. for convenience.
+
+ New autotests that test QWebHistory and QWebHistoryItem serialization.
+
+ * Api/qwebhistory.cpp:
+ (QWebHistory::restoreState):
+ (QWebHistory::saveState):
+ (operator<<):
+ (operator>>):
+ * Api/qwebhistory.h:
+ * Api/qwebhistory_p.h:
+ * tests/qwebhistory/tst_qwebhistory.cpp:
+ (tst_QWebHistory::):
+ (tst_QWebHistory::init):
+ (tst_QWebHistory::title):
+ (tst_QWebHistory::count):
+ (tst_QWebHistory::back):
+ (tst_QWebHistory::forward):
+ (tst_QWebHistory::itemAt):
+ (tst_QWebHistory::goToItem):
+ (tst_QWebHistory::items):
+ (tst_QWebHistory::serialize_1):
+ (tst_QWebHistory::serialize_2):
+ (tst_QWebHistory::serialize_3):
+ (tst_QWebHistory::saveAndRestore_1):
+ (tst_QWebHistory::saveAndRestore_2):
+ (tst_QWebHistory::saveAndRestore_3):
+
+2009-06-26 Jedrzej Nowacki <jedrzej.nowacki@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Fix the behaviour of QWebHistory::itemAt to interpret the specified index as absolute index.
+
+ Returns an invalid QWebHistoryItem if the index is out of range.
+
+ * Api/qwebhistory.cpp:
+ (QWebHistory::itemAt):
+ * tests/qwebhistory/tst_qwebhistory.cpp:
+ (tst_QWebHistory::itemAt):
+
+2009-06-26 Jedrzej Nowacki <jedrzej.nowacki@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Added a few autotest to QWebHistory.
+
+ * tests/qwebhistory/data/page1.html: Added.
+ * tests/qwebhistory/data/page2.html: Added.
+ * tests/qwebhistory/data/page3.html: Added.
+ * tests/qwebhistory/data/page4.html: Added.
+ * tests/qwebhistory/data/page5.html: Added.
+ * tests/qwebhistory/data/page6.html: Added.
+ * tests/qwebhistory/qwebhistory.pro: Added.
+ * tests/qwebhistory/tst_qwebhistory.cpp: Added.
+ (tst_QWebHistory::):
+ (tst_QWebHistory::tst_QWebHistory):
+ (tst_QWebHistory::~tst_QWebHistory):
+ (tst_QWebHistory::init):
+ (tst_QWebHistory::cleanup):
+ (tst_QWebHistory::title):
+ (tst_QWebHistory::count):
+ (tst_QWebHistory::back):
+ (tst_QWebHistory::forward):
+ (tst_QWebHistory::goToItem):
+ (tst_QWebHistory::items):
+ * tests/qwebhistory/tst_qwebhistory.qrc: Added.
+ * tests/tests.pro:
+
+2009-06-26 Jedrzej Nowacki <jedrzej.nowacki@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Fix support for documenting functions prefixed with QWEBKIT_EXPORT
+
+ Add QWEBKIT_EXPORT to the list of macros to ignore by qdoc.
+
+ * docs/qtwebkit.qdocconf:
+
+2009-06-26 Yongjun Zhang <yongjun.zhang@nokia.com>
+
+ Reviewed by Eric Seidel.
+
+ Bug 20303: [Qt] Key events are not working in frames.
+
+ Send scrolling events to current focused frame, bubble the event
+ up to parent frame if it is not handled. Use EventHandler's new
+ shared scrolling code.
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::keyPressEvent):
+ (QWebPagePrivate::handleScrolling):
+ * Api/qwebpage_p.h:
+
+2009-06-25 Jakub Wieczorek <faw217@gmail.com>
+
+ Reviewed by Adam Treat.
+
+ Add highlight functionality to the QWebPage::findText() method. Introduced is
+ new HighlightAllOccurrences flag which passed to the function will make it mark
+ all existing occurrences of specified string in the page.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::findText):
+ * Api/qwebpage.h:
+ * Api/qwebview.cpp:
+
+2009-06-19 Daniel Teske <qt-info@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Remove warnings for QString() constructions from const char *
+
+ By explicitly wrapping it with QLatin1String() / QLatin1Char()
+
+ * Api/qwebelement.cpp:
+ (QWebElement::classes): Use QLatin1String.
+ (QWebElement::addClass): Ditto.
+ (QWebElement::removeClass): Ditto.
+ (QWebElement::toggleClass): Ditto.
+
+2009-06-18 Friedemann Kleint <Friedemann.Kleint@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Fixed MinGW compilation.
+
+ * Api/qwebelement.cpp:
+ (QWebElement::evaluateScript):
+
+2009-06-18 Markus Goetz <Markus.Goetz@nokia.com>
+
+ Reviewed by Simon Hausman.
+
+ Clarify in docs how to compile with debug information.
+
+ * docs/qtwebkit.qdoc:
+
+2009-06-17 Markus Goetz <Markus.Goetz@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ QWebPage: Don't call supportsSsl()
+
+ This stops QWebPage from loading the OpenSSL libs,
+ certificates etc. when they are not needed for the non-HTTPS case.
+
+ Loading the SSL libraries can be a very slow operation.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::userAgentForUrl):
+
+2009-06-16 David Boddie <dboddie@trolltech.com>
+
+ Reviewed by Simon Hausmann.
+
+ Doc: Fixed QWebPage::forwardUnsupportedContent documentation and added
+ more information about Web plugins.
+
+ * Api/qwebpage.cpp:
+ * Api/qwebsettings.cpp:
+ * docs/qtwebkit.qdoc:
+
+2009-06-16 Morten Engvoldsen <morten.engvoldsen@nokia.com>
+
+ Reviewed by Ariya Hidayat.
+
+ Clearifying QWebFrame docs
+
+ Adding docs to toHtml() and toPlainText()
+
+ * Api/qwebframe.cpp:
+
+2009-06-15 Benjamin C Meyer <benjamin.meyer@torchmobile.com>
+
+ Reviewed by Adam Treat.
+
+ Support the back/forward/stop/refresh multimedia keys and accept the
+ event when handling backspace and shift backspace as we should.
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::keyPressEvent):
+
+2009-06-15 Andre Pedralho <andre.pedralho@openbossa.org>
+
+ Reviewed by Adam Treat.
+
+ https://bugs.webkit.org/show_bug.cgi?id=26351
+ Remove bool QWebHitTestResult::isScrollBar() const and make sure a null QWebHitTestResult is returned instead.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::hitTestContent):
+ * Api/qwebframe.h:
+ * Api/qwebpage.cpp:
+ (QWebPage::updatePositionDependentActions):
+
+2009-06-15 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Reviewed by Adam Treat.
+
+ Fix the logic for disabling the fixed layout feature, when an invalid
+ QSize is set.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::setFixedContentsSize):
+
+2009-06-13 Adam Barth <abarth@webkit.org>
+
+ Reviewed by Darin Fisher.
+
+ https://bugs.webkit.org/show_bug.cgi?id=24492
+
+ Move registerURLSchemeAsLocal from FrameLoader to SecurityOrigin.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::acceptNavigationRequest):
+
+2009-06-10 Antonio Gomes <antonio.gomes@openbossa.org>
+
+ Reviewed by Ariya Hidayat.
+
+ Documented ResolveRule and StylePriority enum values as well as their use in
+ QWebElement::styleProperty and QWebElement::setStyleProperty methods.
+
+ Based on the work of Simon Hausmann.
+
+ * Api/qwebelement.cpp:
+ (QWebElement::styleProperty):
+ (QWebElement::setStyleProperty):
+ * Api/qwebelement.h:
+
+2009-06-09 Ariya Hidayat <ariya.hidayat@nokia.com>
+
+ Rubber-stamped by Simon Hausmann.
+
+ Fix qdoc warning, function parameter string must be referred.
+
+ * Api/qwebview.cpp:
+
+2009-06-09 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Reviewed by Ariya Hidayat.
+
+ Renamed QWebSettings::AllowUniversalAccessFromFileUrls to
+ LocalContentCanAccessRemoteUrls, as discussed in the API review.
+
+ * Api/qwebsettings.cpp:
+ (QWebSettingsPrivate::apply):
+ (QWebSettings::QWebSettings):
+ * Api/qwebsettings.h:
+
+2009-06-09 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Reviewed by Ariya Hidayat.
+
+ Merged useFixedLayout property with fixedLayoutSize and
+ renamed the latter to fixedContentsSize.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::fixedContentsSize):
+ (QWebPage::setFixedContentsSize):
+ * Api/qwebpage.h:
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::transitionToCommittedForNewPage):
+
+2009-06-09 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Reviewed by Ariya Hidayat.
+
+ Renamed QWebHitTestResult::linkTarget to linkElement() and made it return
+ a QWebElement. The link target itself is always the target DOM attribute.
+
+ * Api/qwebframe.cpp:
+ (QWebHitTestResultPrivate::QWebHitTestResultPrivate):
+ (QWebHitTestResult::linkElement):
+ * Api/qwebframe.h:
+ * Api/qwebframe_p.h:
+ * tests/qwebframe/tst_qwebframe.cpp:
+
+2009-06-08 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Reviewed by Holger Freyther.
+
+ Renamed QWebElement::enclosingBlock to enclosingBlockElement
+ and changed the return type to QWebElement, as discussed in
+ the API review. This API is more generic and through
+ QWebElement's geometry() it is possible to retrieve the
+ same information.
+
+ * Api/qwebelement.cpp:
+ (QWebElement::QWebElement):
+ * Api/qwebelement.h:
+ * Api/qwebframe.cpp:
+ (QWebHitTestResultPrivate::QWebHitTestResultPrivate):
+ (QWebHitTestResult::enclosingBlockElement):
+ * Api/qwebframe.h:
+ * Api/qwebframe_p.h:
+
+2009-06-05 Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Add missing includes of config.h
+
+ * Api/qcookiejar.cpp:
+ * Api/qwebnetworkinterface.cpp:
+ * Plugins/ICOHandler.cpp:
+ * WebCoreSupport/DragClientQt.cpp:
+ * WebCoreSupport/EditCommandQt.cpp:
+
+2009-06-03 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org>
+
+ Reviewed by Simon Hausmann.
+
+ Add API to make it possible to clear all memory caches used by
+ QtWebKit.
+
+ * Api/qwebsettings.cpp:
+ (QWebSettings::clearMemoryCaches):
+ * Api/qwebsettings.h:
+
+2009-06-01 Benjamin C Meyer <benjamin.meyer@torchmobile.com>
+
+ Rubber-stamped by Gustavo Noronha.
+
+ Before guessing the url trim the string to remove whitespace added to the start/end by the user.
+
+ * Api/qwebview.cpp:
+ (QWebView::guessUrlFromString):
+ * tests/qwebview/tst_qwebview.cpp:
+ (tst_QWebView::guessUrlFromString_data):
+
+2009-06-01 Benjamin C Meyer <benjamin.meyer@torchmobile.com>
+
+ Rubber-stamped by Gustavo Noronha.
+
+ Use QLatin1Char() to compile when QT_NO_CAST_FROM_ASCII and QT_NO_CAST_TO_ASCII is defined
+
+ * Api/qwebview.cpp:
+ (QWebView::guessUrlFromString):
+
+2009-06-01 Benjamin C Meyer <benjamin.meyer@torchmobile.com>
+
+ Rubber-stamped by Gustavo Noronha.
+
+ Cleanup autotest file
+ - use proper includes
+ - remove useless constructor and destructor
+ - add missing newline at the end of the file
+
+ * tests/qwebview/tst_qwebview.cpp:
+
+2009-06-01 Benjamin C Meyer <benjamin.meyer@torchmobile.com>
+
+ Rubber-stamped by Gustavo Noronha.
+
+ Add a missing space between two words in the documentation.
+
+ * Api/qwebview.cpp:
+
+2009-05-26 Benjamin C Meyer <benjamin.meyer@torchmobile.com>
+
+ Reviewed by Holger Freyther.
+
+ https://bugs.webkit.org/show_bug.cgi?id=25823
+
+ Add an API to generate a QUrl out of a string correcting for errors and missing information.
+ See the API documentation for more details about the function.
+
+ Autotests: included
+
+ * Api/qwebview.cpp:
+ (QWebView::guessUrlFromString):
+ * Api/qwebview.h:
+ * QtLauncher/main.cpp:
+ (MainWindow::MainWindow):
+ (MainWindow::changeLocation):
+ * tests/qwebview/.gitignore: Added.
+ * tests/qwebview/qwebview.pro:
+ (tst_QWebView::initTestCase):
+ (tst_QWebView::cleanupTestCase):
+ (tst_QWebView::init):
+ (tst_QWebView::cleanup):
+ (tst_QWebView::guessUrlFromString_data):
+ (tst_QWebView::guessUrlFromString):
+
+2009-05-23 David Kilzer <ddkilzer@apple.com>
+
+ Part 2 of 2: Bug 25495: Implement PassOwnPtr and replace uses of std::auto_ptr
+
+ <https://bugs.webkit.org/show_bug.cgi?id=25495>
+
+ Reviewed by Oliver Hunt.
+
+ * WebCoreSupport/ChromeClientQt.h:
+ (WebCore::ChromeClientQt::createHTMLParserQuirks): Return a
+ PassOwnPtr<> instead of a raw HTMLParserQuirks pointer.
+
+2009-05-23 Jakob Truelsen <antialize@gmail.com>
+
+ Reviewed by Holger Freyther.
+
+ https://bugs.webkit.org/show_bug.cgi?id=25863
+
+ Expose the default text encoding property to Qt.
+
+ * Api/qwebsettings.cpp:
+ (QWebSettingsPrivate::apply):
+ (QWebSettings::setDefaultTextEncoding):
+ (QWebSettings::defaultTextEncoding):
+ * Api/qwebsettings.h:
+
+2009-05-21 Antonio Gomes <antonio.gomes@openbossa.org>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Additional test for resource load (CSS file) for QWebFrame.
+
+ * tests/qwebframe/qwebframe.qrc:
+ * tests/qwebframe/style.css: Added.
+ * tests/qwebframe/tst_qwebframe.cpp:
+
+2009-05-22 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Unreviewed Qt build fix.
+
+ Provide dummy implementation of pure virtual EditorClient method.
+
+ * WebCoreSupport/EditorClientQt.cpp:
+ (WebCore::EditorClientQt::getAutoCorrectSuggestionForMisspelledWord):
+ * WebCoreSupport/EditorClientQt.h:
+
+2009-05-20 Ariya Hidayat <ariya.hidayat@nokia.com>
+
+ Reviewed by Simon Hausmann and Holger Freyther.
+
+ [Qt] Add renderHints property to QWebView.
+
+ * Api/qwebview.cpp:
+ (QWebViewPrivate::QWebViewPrivate):
+ (QWebView::renderHints):
+ (QWebView::setRenderHints):
+ (QWebView::setRenderHint):
+ (QWebView::paintEvent):
+ * Api/qwebview.h:
+ * tests/qwebview/qwebview.pro: Added.
+ * tests/qwebview/tst_qwebview.cpp: Added.
+ (tst_QWebView::tst_QWebView):
+ (tst_QWebView::~tst_QWebView):
+ (tst_QWebView::init):
+ (tst_QWebView::cleanup):
+ (tst_QWebView::renderHints):
+ * tests/tests.pro:
+
+2009-05-20 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Reviewed by Darin Adler.
+
+ https://bugs.webkit.org/show_bug.cgi?id=25834
+
+ Make ChromeClient a interface again
+
+ With recent additions to ChromeClient.h empty defaults were
+ added. This is bad for porters as these changes go unnoticed
+ and at runtime no notImplemented warning is logged and grepping
+ for notImplemented will not show anything. Change this Client
+ to be like the other Clients again and always have pure virtuals
+ (but for stuff inside #ifdef PLATFORM(MAC)).
+
+ Update the various WebKit/* implementations to compile again.
+
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::setCursor):
+ (WebCore::ChromeClientQt::requestGeolocationPermissionForFrame):
+ * WebCoreSupport/ChromeClientQt.h:
+ (WebCore::ChromeClientQt::scrollRectIntoView):
+
+2009-05-19 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org>
+
+ Reviewed by Simon Hausmann.
+
+ Fix a plugin bug in the WebKit code, similar to the one in WebCore.
+
+ The problem is when a non visible QtPluginWidget would show it self
+ in a sibling frame. The problem was due to our clipping. In Qt,
+ if setMask is set with an empty QRegion, no clipping will
+ be performed, so in that case we hide the PluginContainer
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::):
+
+2009-05-18 Zoltan Horvath <horvath.zoltan.6@stud.u-szeged.hu>
+
+ Reviewed by Ariya Hidayat.
+
+ Makes QtLauncher to accept multiple urls in command line and opens these in separate windows.
+
+ * QtLauncher/main.cpp:
+ (MainWindow::newWindow):
+ (main):
+
+2009-05-14 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org>
+
+ Reviewed by Ariya Hidayat.
+
+ Add a comment to QWebView::iconChanged(), mentioning that you will
+ need to set the icon database path for icons to be loaded, and thus
+ receive the signal.
+
+ * Api/qwebview.cpp:
+
+2009-05-14 Yael Aharon <yael.aharon@nokia.com>
+
+ Reviewed by Ariya Hidayat.
+
+ Fix setHtml test case by adding <head> tag to the expected result. This tag is automatically added by WebKit.
+
+ * tests/qwebframe/tst_qwebframe.cpp:
+
+2009-05-14 Yael Aharon <yael.aharon@nokia.com>
+
+ Reviewed by Ariya Hidayat.
+
+ Add a test case for the signal urlChanged().
+ * tests/qwebframe/tst_qwebframe.cpp:
+
+2009-05-13 Yael Aharon <yael.aharon@nokia.com>
+
+ Reviewed by Ariya Hidayat.
+
+ Move emitting the signal QWebFrame::urlChanged to FrameLoaderClientQt::dispatchDidCommitLoad().
+ This is to ensure that urlChanged() is emitted even if the frame has no title.
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::dispatchDidReceiveTitle):
+ (WebCore::FrameLoaderClientQt::dispatchDidCommitLoad):
+
+2009-05-13 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org>
+
+ Rubberstamped by Ariya Hidayat.
+
+ Fix coding style: Add {} to contents of if, containing a for loop.
+
+ * Api/qwebelement.cpp:
+ (QWebElement::styleProperty):
+
+2009-05-12 Antonio Gomes <antonio.gomes@openbossa.org>
+
+ Reviewed by Ariya Hidayat.
+
+ Fixed a possible crash @styleProperty when there is no embedded/external CSS set.
+
+ * Api/qwebelement.cpp:
+ (QWebElement::styleProperty):
+ * tests/qwebelement/tst_qwebelement.cpp:
+ (tst_QWebElement::style):
+
+2009-05-12 Antonio Gomes <antonio.gomes@openbossa.org>
+
+ Reviewed by Ariya Hidayat.
+
+ Added external CSS test cases to QWebElement::styleProperty() method.
+
+ Also some ::styleProperty() tests cleanup.
+
+ * tests/qwebelement/tst_qwebelement.cpp:
+ (tst_QWebElement::style):
+
+2009-05-12 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org>
+
+ Reviewed by Ariya Hidayat.
+
+ Many methods were not considering the case of the element not having
+ siblings or children when inserting nodes, and thus broke in some
+ situations. This patch fixes that.
+
+ * Api/qwebelement.cpp:
+ (QWebElement::prependInside):
+ (QWebElement::appendOutside):
+ (QWebElement::encloseWith):
+
+2009-05-08 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org>
+
+ Reviewed by Ariya Hidayat.
+
+ Make is possible to mark a style property as important while setting
+ it. Also support the normal CSS property syntax "!important", while
+ accepting spaces between the ! and the important keyword.
+
+ * Api/qwebelement.cpp:
+ (QWebElement::setStyleProperty):
+ * Api/qwebelement.h:
+ * tests/qwebelement/tst_qwebelement.cpp:
+ (tst_QWebElement::style):
+
+2009-05-08 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org>
+
+ Reviewed by Ariya Hidayat.
+
+ Working with Antonio Gomes.
+
+ Add support for finding the style property actually applied to the element.
+
+ * Api/qwebelement.cpp:
+ (QWebElement::styleProperty):
+ * Api/qwebelement.h:
+ * tests/qwebelement/tst_qwebelement.cpp:
+ (tst_QWebElement::style):
+
+2009-05-11 Norbert Leser <norbert.leser@nokia.com>
+
+ Reviewed by Darin Adler.
+
+ Bug 24538: class/struct mixup in forward declarations
+ https://bugs.webkit.org/show_bug.cgi?id=24538
+
+ * Api/qwebpage.h:
+
+2009-05-11 Laszlo Gombos <laszlo.1.gombos@nokia.com>
+
+ Reviewed by Holger Freyther.
+
+ Fix Qt build when ENABLE_DATABASE is turned off
+
+ https://bugs.webkit.org/show_bug.cgi?id=25587
+
+ * Api/qwebdatabase.cpp:
+ (QWebDatabase::displayName):
+ (QWebDatabase::expectedSize):
+ (QWebDatabase::size):
+ (QWebDatabase::fileName):
+ (QWebDatabase::removeDatabase):
+ * Api/qwebdatabase_p.h:
+ * Api/qwebsecurityorigin.cpp:
+ (QWebSecurityOrigin::allOrigins):
+ (QWebSecurityOrigin::databases):
+
+2009-05-05 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org>
+
+ Reviewed by Simon Hausmann.
+
+ Improve behaviour of the QWebElement enclose* functions, to work
+ similar to the jQuery wrap functions. We now enclose the contents
+ of the element in the child of the deepest descendant element
+ within the structure of the enclose element structure given.
+
+ * Api/qwebelement.cpp:
+ (findInsertionPoint):
+ (QWebElement::encloseContentsWith):
+ (QWebElement::encloseWith):
+ (QWebElement::replace):
+ * tests/qwebelement/tst_qwebelement.cpp:
+ (tst_QWebElement::encloseContentsWith):
+ (tst_QWebElement::encloseWith):
+
+2009-05-06 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org>
+
+ Reviewed by Simon Hausmann.
+
+ After commit rev @43215, setHtml() without a <head> tag,
+ automatically adds it, so update our test case to respect this.
+
+ * tests/qwebelement/tst_qwebelement.cpp:
+ (tst_QWebElement::textHtml):
+
+2009-05-06 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Unreviewed Qt build fix.
+
+ Dont' use ENABLE() in Qt API headers, as they are not available when building
+ against the API.
+
+ * Api/qwebdatabase.h:
+ * Api/qwebsecurityorigin.h:
+
+2009-05-05 Ben Murdoch <benm@google.com>
+
+ Reviewed by Eric Seidel.
+
+ Add #if ENABLE(DATABASE) guards around database code so toggling ENABLE_DATABASE off does not break builds.
+ https://bugs.webkit.org/show_bug.cgi?id=24776
+
+ * Api/qwebdatabase.cpp:
+ * Api/qwebdatabase.h:
+ * Api/qwebdatabase_p.h:
+ * Api/qwebsecurityorigin.cpp:
+ (QWebSecurityOrigin::databaseUsage):
+ (QWebSecurityOrigin::databaseQuota):
+ (QWebSecurityOrigin::setDatabaseQuota):
+ * Api/qwebsecurityorigin.h:
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::exceededDatabaseQuota):
+ * WebCoreSupport/ChromeClientQt.h:
+
+2009-05-05 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Reviewed by Tor Arne Vestbø.
+
+ Various improvements to the class documentation, including a simple snippet for QWebElement.
+
+ * Api/qwebelement.cpp:
+ * Api/qwebframe.cpp:
+ * docs/webkitsnippets/webelement/main.cpp: Added.
+ * docs/webkitsnippets/webelement/webelement.pro: Added.
+
+2009-05-05 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Reviewed by Ariya Hidayat.
+
+ Simplify variant conversion by moving the null check into
+ convertValueToQVariant.
+
+ * Api/qwebframe.cpp:
+ (QWebFrame::evaluateJavaScript): Moved null check into conversion function.
+ * tests/qwebframe/tst_qwebframe.cpp:
+ Added test to verify the correct conversion of null values to QVariant.
+
+2009-05-01 Geoffrey Garen <ggaren@apple.com>
+
+ Rubber Stamped by Sam Weinig.
+
+ Renamed JSValuePtr => JSValue.
+
+ * Api/qwebelement.cpp:
+ (setupScriptContext):
+ (setupScriptObject):
+ (QWebElement::evaluateScript):
+ (QWebElement::functions):
+ (QWebElement::scriptableProperty):
+ (QWebElement::setScriptableProperty):
+ (QWebElement::scriptableProperties):
+
+2009-05-01 Pavel Feldman <pfeldman@chromium.org>
+
+ Reviewed by Timothy Hatcher.
+
+ Add a FrameLoaderClient callback for the ResourceRetrievedByXMLHttpRequest.
+
+ https://bugs.webkit.org/show_bug.cgi?id=25347
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::dispatchDidLoadResourceByXMLHttpRequest):
+ * WebCoreSupport/FrameLoaderClientQt.h:
+
+2009-04-30 David Kilzer <ddkilzer@apple.com>
+
+ Provide a mechanism to create a quirks delegate for HTMLParser
+
+ Reviewed by David Hyatt.
+
+ * WebCoreSupport/ChromeClientQt.h:
+ (WebCore::ChromeClientQt::createHTMLParserQuirks): Added. The
+ default implementation of this factory method returns 0.
+
+2009-04-30 Ariya Hidayat <ariya.hidayat@nokia.com>
+
+ Unreviewed build fix after r43072.
+
+ * Api/qwebframe.cpp:
+ (qt_drt_setJavaScriptProfilingEnabled): Enclose with JAVASCRIPT_DEBUGGER.
+
+2009-04-30 Ariya Hidayat <ariya.hidayat@nokia.com>
+
+ Unreviewed build fix after r43063.
+
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::addMessageToConsole):
+ * WebCoreSupport/ChromeClientQt.h:
+
+2009-04-30 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org>
+
+ Reviewed by Simon Hausmann.
+
+ Implement encloseContentsWith and rename wrap to encloseWith.
+
+ Also in encloseWith, make sure that you cannot enclose with
+ non-enclosable elements.
+
+ * Api/qwebelement.cpp:
+ (QWebElement::encloseContentsWith):
+ (QWebElement::encloseWith):
+ * Api/qwebelement.h:
+ * tests/qwebelement/tst_qwebelement.cpp:
+ (tst_QWebElement::encloseContentsWith):
+ (tst_QWebElement::encloseWith):
+
+2009-04-30 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Reviewed by Darin Adler.
+
+ The Qt API exposes a global history patch CSSStyleSelector to make API consumers work again
+
+ https://bugs.webkit.org/show_bug.cgi?id=20952
+
+ The QtWebKit port made the mistake of exposing a global history. This broke
+ with the addition of PageGroup and LinkHash. This needs to be repaired
+ for Qt4.5.
+
+ Add a function to LinkHash.cpp that is resolving a URL. Use this
+ function from within CSSStyleSelector to forward the url to the
+ QWebHistoryInterface API.
+
+ It is sad that there is a path within visitedLinkHash which is now
+ doing a memcpy, it is sad to add a PLATFORM(QT) define to CSSStyleSelector
+ and using QtWebKit types within WebCore is a layering violation as well.
+
+ PageGroup::setShouldTrackVisitedLinks is currently not enabled. For
+ Qt4.6 a second version of the QWebHistoryInterface is going to be
+ added which will fix things up.
+
+ * Api/qwebhistoryinterface.cpp:
+ (QWebHistoryInterface::setDefaultInterface): Add note for Qt4.6
+ * Api/qwebpage.cpp: Remove PageGroup::setShouldTrackVisitedLinks(true)
+ (QWebPagePrivate::QWebPagePrivate):
+ * tests/qwebhistoryinterface/qwebhistoryinterface.pro: Added unit test.
+ * tests/qwebhistoryinterface/tst_qwebhistoryinterface.cpp: Added unit test.
+ (tst_QWebHistoryInterface::tst_QWebHistoryInterface):
+ (tst_QWebHistoryInterface::~tst_QWebHistoryInterface):
+ (tst_QWebHistoryInterface::init):
+ (tst_QWebHistoryInterface::cleanup):
+ (FakeHistoryImplementation::addHistoryEntry):
+ (FakeHistoryImplementation::historyContains):
+ (tst_QWebHistoryInterface::visitedLinks): Check the Qt4.4 behaviour.
+ * tests/tests.pro:
+
+2009-04-30 Ariya Hidayat <ariya.hidayat@nokia.com>
+
+ Unreviewed build fix, after r43035.
+
+ Temporarily use Position::deprecatedEditingOffset().
+
+ * Api/qwebpage.cpp:
+ (QWebPage::inputMethodQuery):
+
+2009-03-27 Benjamin C Meyer <benjamin.meyer@torchmobile.com>
+
+ Reviewed by Simon Hausmann.
+
+ Update the page actions when a finishing loading even if the frame is
+ not the top frame such as when browsing inside of a website with frames.
+ https://bugs.webkit.org/show_bug.cgi?id=24890
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::FrameLoaderClientQt::dispatchDidFinishLoad):
+ * tests/qwebpage/frametest/frame_a.html: Added.
+ * tests/qwebpage/frametest/index.html: Added.
+ * tests/qwebpage/tst_qwebpage.cpp:
+ (tst_QWebPage::backActionUpdate):
+
+2009-04-29 Ariya Hidayat <ariya.hidayat@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Implement QWebElement::evaluateScript.
+
+ * Api/qwebelement.cpp:
+ (setupScriptContext):
+ (QWebElement::evaluateScript):
+ * Api/qwebelement.h:
+ * tests/qwebelement/tst_qwebelement.cpp:
+ (tst_QWebElement::evaluateScript):
+
+2009-04-29 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Reviewed by Ariya Hidayat.
+
+ Replaced QWebElementCollection with QList<QWebElement>.
+
+ * Api/qwebelement.cpp:
+ (QWebElement::findAll):
+ * Api/qwebelement.h:
+ * Api/qwebframe.cpp:
+ (QWebFrame::findAllElements):
+ * Api/qwebframe.h:
+ * QtLauncher/main.cpp:
+ (MainWindow::selectElements):
+ * tests/qwebelement/tst_qwebelement.cpp:
+ (tst_QWebElement::simpleCollection):
+ (tst_QWebElement::namespaceURI):
+ (tst_QWebElement::nullSelect):
+
+2009-04-28 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Reviewed by Tor Arne Vestbø.
+
+ QWebElement API changes after another round of API review:
+
+ * Fix argument names of findAll/findFirst
+ * Split up toXml into innerXml and outerXml
+ * Removed confusing toggleClass overload
+ * Fixed casing of namespaceUri to follow QXmlStreamReader
+ * Removed tagName from firstChild/nextSibling/etc.
+ * Renamed append/prepend/insertAfter/insertBefore to [append|prepend][Inside|Outside]
+ * Renamed wrapWith() back to wrap()
+ * Made clone() const
+ * Renamed remove() to takeFromDocument(), added removeFromDocument()
+ * Renamed clear() to removeChildren()
+ * Renamed scriptsFunctions/callScriptFunction to functions()/callFunction()
+ * Renamed scriptProperty to scriptableProperty
+
+ * Api/qwebelement.cpp:
+ (QWebElement::findAll):
+ (QWebElement::findFirst):
+ (QWebElement::setOuterXml):
+ (QWebElement::toOuterXml):
+ (QWebElement::setInnerXml):
+ (QWebElement::toInnerXml):
+ (QWebElement::namespaceUri):
+ (QWebElement::firstChild):
+ (QWebElement::lastChild):
+ (QWebElement::nextSibling):
+ (QWebElement::previousSibling):
+ (QWebElement::callFunction):
+ (QWebElement::functions):
+ (QWebElement::scriptableProperty):
+ (QWebElement::setScriptableProperty):
+ (QWebElement::scriptableProperties):
+ (QWebElement::appendInside):
+ (QWebElement::prependInside):
+ (QWebElement::prependOutside):
+ (QWebElement::appendOutside):
+ (QWebElement::clone):
+ (QWebElement::takeFromDocument):
+ (QWebElement::removeFromDocument):
+ (QWebElement::removeChildren):
+ (QWebElement::wrap):
+ (QWebElement::replace):
+ * Api/qwebelement.h:
+ * Api/qwebframe.cpp:
+ (QWebFrame::findAllElements):
+ (QWebFrame::findFirstElement):
+ * Api/qwebframe.h:
+ * tests/qwebelement/tst_qwebelement.cpp:
+ (tst_QWebElement::textHtml):
+ (tst_QWebElement::classes):
+ (tst_QWebElement::namespaceURI):
+ (tst_QWebElement::foreachManipulation):
+ (tst_QWebElement::callFunction):
+ (tst_QWebElement::callFunctionSubmitForm):
+ (tst_QWebElement::functionNames):
+ (tst_QWebElement::properties):
+ (tst_QWebElement::appendAndPrepend):
+ (tst_QWebElement::insertBeforeAndAfter):
+ (tst_QWebElement::remove):
+ (tst_QWebElement::clear):
+ (tst_QWebElement::replaceWith):
+
+2009-04-28 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Reviewed by Tor Arne Vestbø.
+
+ Fix some qdoc warnings.
+
+ * Api/qwebframe.cpp: Fix links.
+ * Api/qwebnetworkinterface.cpp: Make docs internal.
+ * Api/qwebnetworkinterface.h: Ditto.
+ * Api/qwebpage.cpp: Fix property name in \property.
+
+2009-04-24 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Rubber-stamped by Ariya Hidayat.
+
+ Fix qdoc warning about link to QAction::isEnabled.
+
+ * Api/qwebpage.cpp:
+
+2009-04-24 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Reviewed by Ariya Hidayat.
+
+ Added support for generating API docs in the Qt build using "make docs"
+
+ Added code snippets and overview from the Qt sources references in the API docs.
+
+ * Api/qwebpage.cpp: Adjust paths to snippets.
+ * Api/qwebview.cpp: Ditto.
+ * docs/docs.pri: Added.
+ * docs/qtwebkit.qdoc: Added.
+ * docs/qtwebkit.qdocconf: Added.
+ * docs/webkitsnippets/qtwebkit_build_snippet.qdoc: Added.
+ * docs/webkitsnippets/qtwebkit_qwebview_snippet.cpp: Added.
+ * docs/webkitsnippets/simple/main.cpp: Added.
+ * docs/webkitsnippets/simple/simple.pro: Added.
+ * docs/webkitsnippets/webpage/main.cpp: Added.
+ * docs/webkitsnippets/webpage/webpage.pro: Added.
+
+2009-04-23 Antonio Gomes <antonio.gomes@openbossa.org>
+
+ Reviewed by Ariya Hidayat.
+
+ [Qt] Added QWebElement::computedStyleProperty method.
+
+ * Api/qwebelement.cpp:
+ (QWebElement::computedStyleProperty):
+ * Api/qwebelement.h:
+ * tests/qwebelement/tst_qwebelement.cpp:
+ (tst_QWebElement::computedStyle):
+
+2009-04-23 Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
+
+ Rubber-stamped by Ariya Hidayat.
+
+ [Qt] Rename QWebElement arguments from html to markup
+
+ * Api/qwebelement.cpp:
+ (QWebElement::append):
+ (QWebElement::prepend):
+ (QWebElement::insertBefore):
+ (QWebElement::insertAfter):
+ * Api/qwebelement.h:
+
+2009-04-21 Antonio Gomes <antonio.gomes@openbossa.org>
+
+ Reviewed by Ariya Hidayat.
+
+ QWebElementSelection renamed to QWebElementCollection.
+
+ * Api/qwebelement.cpp:
+ (QWebElement::findAll):
+ (QWebElementCollectionPrivate::QWebElementCollectionPrivate):
+ (QWebElementCollectionPrivate::create):
+ (QWebElementCollection::QWebElementCollection):
+ (QWebElementCollection::operator=):
+ (QWebElementCollection::~QWebElementCollection):
+ (QWebElementCollection::operator+):
+ (QWebElementCollection::append):
+ (QWebElementCollection::count):
+ (QWebElementCollection::at):
+ (QWebElementCollection::toList):
+ * Api/qwebelement.h:
+ * Api/qwebframe.cpp:
+ (QWebFrame::findAllElements):
+ * Api/qwebframe.h:
+ * QtLauncher/main.cpp:
+ (MainWindow::selectElements):
+ * tests/qwebelement/tst_qwebelement.cpp:
+ (tst_QWebElement::simpleCollection):
+ (tst_QWebElement::iteration):
+ (tst_QWebElement::emptyCollection):
+ (tst_QWebElement::appendCollection):
+ (tst_QWebElement::nullSelect):
+
+2009-04-17 Laszlo Gombos <laszlo.1.gombos@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ https://bugs.webkit.org/show_bug.cgi?id=25242
+
+ Remove QtCore 4.5 dependency from QWebElement test
+
+ * tests/qwebelement/tst_qwebelement.cpp:
+ (tst_QWebElement::iteration): Use QList::count() instead of QList::length()
+
+2009-04-16 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Rubber-stamped by Simon Hausmann.
+
+ Make the operator== and operator!= non inline to
+ allow looking at the d-pointer in the future.
+
+ * Api/qwebelement.cpp:
+ (QWebElement::operator==):
+ (QWebElement::operator!=):
+ * Api/qwebelement.h:
+
+2009-04-15 Antonio Gomes <antonio.gomes@openbossa.org>
+
+ Reviewed by Ariya Hidayat.
+
+ Rename extend() method in QWebElementSelection to append().
+
+ * Api/qwebelement.cpp:
+ (QWebElementSelection::append):
+ * Api/qwebelement.h:
+ * tests/qwebelement/tst_qwebelement.cpp:
+ (tst_QWebElement::appendSelection):
+
+2009-04-15 Antonio Gomes <antonio.gomes@openbossa.org>
+
+ Reviewed by Simon Hausmann.
+
+ Fixed nit/typo in QWebElement documentation.
+
+ * Api/qwebelement.cpp:
+
+2009-04-14 Laszlo Gombos <laszlo.1.gombos@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ https://bugs.webkit.org/show_bug.cgi?id=24841
+
+ Fix linking against QtWebKit for Symbian and other platforms
+ where the OS ABI distinguishes between an import or an export situation.
+
+ * Api/qwebkitglobal.h: Instead of white-listing Win, remove the test.
+
+2009-04-14 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org>
+
+ Reviewed by Tor Arne Vestbø.
+
+ Rename QWebElement::setHtml and html to setXml and toXml respectivily.
+
+ Also add a mean to define the scope (inner or other).
+
+ * Api/qwebelement.cpp:
+ (QWebElement::setXml):
+ (QWebElement::toXml):
+ * Api/qwebelement.h:
+ * tests/qwebelement/tst_qwebelement.cpp:
+ (tst_QWebElement::textHtml):
+ (tst_QWebElement::foreachManipulation):
+
+2009-04-14 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org>
+
+ Reviewed by Tor Arne Vestbø.
+
+ Rename QWebElement::setText() and text() to ::setPlainText and
+ ::toPlainText, respectively.
+
+ * Api/qwebelement.cpp:
+ (QWebElement::setPlainText):
+ (QWebElement::toPlainText):
+ * Api/qwebelement.h:
+ * tests/qwebelement/tst_qwebelement.cpp:
+ (tst_QWebElement::textHtml):
+ (tst_QWebElement::simpleSelection):
+ (tst_QWebElement::appendAndPrepend):
+ (tst_QWebElement::insertBeforeAndAfter):
+ (tst_QWebElement::replaceWith):
+ (tst_QWebElement::wrap):
+ (tst_QWebElement::firstChildNextSiblingWithTag):
+ (tst_QWebElement::lastChildPreviousSiblingWithTag):
+
+2009-04-06 Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Rename DOM API select function to findFirst, findAll, etc.
+
+ * Api/qwebelement.cpp:
+ (QWebElement::findAll):
+ (QWebElement::findFirst):
+ * Api/qwebelement.h:
+ * Api/qwebframe.cpp:
+ (QWebFrame::findAllElements):
+ (QWebFrame::findFirstElement):
+ * Api/qwebframe.h:
+ * QtLauncher/main.cpp:
+ (MainWindow::selectElements):
+ * tests/qwebelement/tst_qwebelement.cpp:
+ (tst_QWebElement::simpleSelection):
+ (tst_QWebElement::attributesNS):
+ (tst_QWebElement::classes):
+ (tst_QWebElement::namespaceURI):
+ (tst_QWebElement::iteration):
+ (tst_QWebElement::foreachManipulation):
+ (tst_QWebElement::callFunctionSubmitForm):
+ (tst_QWebElement::documentElement):
+ (tst_QWebElement::frame):
+ (tst_QWebElement::style):
+ (tst_QWebElement::extendSelection):
+ (tst_QWebElement::properties):
+ (tst_QWebElement::appendAndPrepend):
+ (tst_QWebElement::insertBeforeAndAfter):
+ (tst_QWebElement::remove):
+ (tst_QWebElement::clear):
+ (tst_QWebElement::replaceWith):
+ (tst_QWebElement::wrap):
+ (tst_QWebElement::nullSelect):
+ (tst_QWebElement::firstChildNextSibling):
+ (tst_QWebElement::firstChildNextSiblingWithTag):
+ (tst_QWebElement::lastChildPreviousSibling):
+ (tst_QWebElement::lastChildPreviousSiblingWithTag):
+
+2009-04-06 Simon Hausmann <simon.hausmann@nokia.com>
+ Ariya Hidayat <ariya.hidayat@nokia.com>
+ Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
+ Genevieve Mak <gen@staikos.net>
+
+ Reviewed by Tor Arne Vestbø, Simon Hausmann
+
+ First revision of new API in the Qt port to access the DOM.
+
+ * Api/headers.pri: Added qwebelement.h to the API headers.
+ * Api/qwebelement.cpp: Added.
+ * Api/qwebelement.h: Added.
+ * Api/qwebframe.cpp:
+ (QWebFrame::documentElement): Added accessor for the document element.
+ (QWebFrame::selectElements): Added convenienc query method.
+ (QWebFrame::selectElement): Ditto.
+ (QWebHitTestResult::element): Added accessor for underlying DOM element.
+ * Api/qwebframe.h:
+ * QtLauncher/main.cpp: Simple test gui for element selections.
+ * tests/qwebelement/qwebelement.pro: Added.
+ * tests/qwebelement/tst_qwebelement.cpp: Added.
+ * tests/tests.pro: Added QWebElement & QWebElementSelection unit tests.
+
+2009-04-02 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Fix the Qt build.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::triggerAction): Adapted code to renamed loadFrameRequest function.
+
+2009-04-02 Takumi Asaki <takumi.asaki@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Fix pre-edit handling of text fields with input methods.
+
+ The input method sends an empty preeditString() if all characters of
+ the preedit should be deleted. So inputMethodEvent() has to use
+ preeditString() if it's empty.
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::inputMethodEvent):
+
+2009-03-30 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Rubber-stamped by Tor Arne Vestbø.
+
+ Document that setHtml/setContent loads only the html/data immediately, not external objects.
+
+ * Api/qwebframe.cpp:
+ * Api/qwebview.cpp:
+
+2009-03-29 Darin Adler <darin@apple.com>
+
+ Try to fix Qt build.
+
+ * WebCoreSupport/EditorClientQt.cpp: Added include of HTMLElement.h.
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp: Added include of FormState.h.
+ (WebCore::FrameLoaderClientQt::prepareForDataSourceReplacement):
+ Removed unneeded call to detachChildren, which is called by FrameLoader
+ right after this.
+ (WebCore::FrameLoaderClientQt::createFrame): Use loadURLIntoChildFrame
+ as other platforms do in the corresponding functions.
+
+2009-03-27 Erik L. Bunce <elbunce@xendom.com>
+
+ Reviewed by Simon Hausmann.
+
+ https://bugs.webkit.org/show_bug.cgi?id=24869
+
+ Fixes an incorrect case in tst_qwebpage.
+
+ * tests/qwebpage/tst_qwebpage.cpp:
+ (tst_QWebPage::cursorMovements):
+
+2009-03-27 Erik L. Bunce <elbunce@xendom.com>
+
+ Reviewed by Simon Hausmann.
+
+ https://bugs.webkit.org/show_bug.cgi?id=24746
+
+ Add new editing related QWebPage::WebActions
+ * Clipboard: PasteAndMatchStyle
+ * Formatting: RemoveFormat, ToggleStrikethrough, ToggleSubscript, and
+ ToggleSuperscript
+ * List Editing: InsertUnorderedList, InsertOrderedList, Indent, Outdent
+ * Paragraph Justification: AlignCenter, AlignJustified, AlignLeft, AlignRight
+
+ Improved selection and editing tests.
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::updateEditorActions):
+ (QWebPage::action):
+ * Api/qwebpage.h:
+ * tests/qwebpage/tst_qwebpage.cpp:
+ (tst_QWebPage::textSelection):
+ (tst_QWebPage::textEditing):
+
2009-03-26 Simon Hausmann <simon.hausmann@nokia.com>
Rubber-stamped by Tor Arne Vestbø.
diff --git a/WebKit/qt/Plugins/ICOHandler.cpp b/WebKit/qt/Plugins/ICOHandler.cpp
index 44f3d44..d7fae07 100644
--- a/WebKit/qt/Plugins/ICOHandler.cpp
+++ b/WebKit/qt/Plugins/ICOHandler.cpp
@@ -6,6 +6,7 @@
*
*/
+#include "config.h"
#include "ICOHandler.h"
#include <cstring>
diff --git a/WebKit/qt/QtLauncher/QtLauncher.pro b/WebKit/qt/QtLauncher/QtLauncher.pro
index d8c9d51..42138c8 100644
--- a/WebKit/qt/QtLauncher/QtLauncher.pro
+++ b/WebKit/qt/QtLauncher/QtLauncher.pro
@@ -6,5 +6,6 @@ DESTDIR = ../../../bin
include(../../../WebKit.pri)
-macx:QT+=xml network
+QT += network
+macx:QT+=xml
QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
diff --git a/WebKit/qt/QtLauncher/main.cpp b/WebKit/qt/QtLauncher/main.cpp
index 5d9fef6..9cbab53 100644
--- a/WebKit/qt/QtLauncher/main.cpp
+++ b/WebKit/qt/QtLauncher/main.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2009 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>
@@ -33,20 +33,28 @@
#include <qwebview.h>
#include <qwebframe.h>
#include <qwebsettings.h>
+#include <qwebelement.h>
#include <QtGui>
#include <QDebug>
+#include <QtNetwork/QNetworkProxy>
#if QT_VERSION >= 0x040400 && !defined(QT_NO_PRINTER)
#include <QPrintPreviewDialog>
#endif
+#ifndef QT_NO_UITOOLS
#include <QtUiTools/QUiLoader>
+#endif
#include <QVector>
#include <QTextStream>
#include <QFile>
#include <cstdio>
+#ifndef NDEBUG
+void QWEBKIT_EXPORT qt_drt_garbageCollector_collect();
+#endif
+
class WebPage : public QWebPage
{
public:
@@ -60,25 +68,39 @@ class MainWindow : public QMainWindow
{
Q_OBJECT
public:
- MainWindow(const QString& url = QString()): currentZoom(100) {
+ MainWindow(QString url = QString()): currentZoom(100) {
+ setAttribute(Qt::WA_DeleteOnClose);
+
view = new QWebView(this);
setCentralWidget(view);
- view->setPage(new WebPage(view));
-
+ WebPage* page = new WebPage(view);
+ view->setPage(page);
+
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()));
+ connect(view->page(), SIGNAL(windowCloseRequested()), this, SLOT(close()));
setupUI();
- QUrl qurl = guessUrlFromString(url);
+ // set the proxy to the http_proxy env variable - if present
+ QUrl proxyUrl = view->guessUrlFromString(qgetenv("http_proxy"));
+ if (proxyUrl.isValid() && !proxyUrl.host().isEmpty()) {
+ int proxyPort = (proxyUrl.port() > 0) ? proxyUrl.port() : 8080;
+ page->networkAccessManager()->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, proxyUrl.host(), proxyPort));
+ }
+
+ QFileInfo fi(url);
+ if (fi.exists() && fi.isRelative())
+ url = fi.absoluteFilePath();
+
+ QUrl qurl = view->guessUrlFromString(url);
if (qurl.isValid()) {
- urlEdit->setText(qurl.toString());
+ urlEdit->setText(qurl.toEncoded());
view->load(qurl);
// the zoom values are chosen to be like in Mozilla Firefox 3
@@ -99,8 +121,11 @@ public:
protected slots:
void changeLocation() {
- QUrl url = guessUrlFromString(urlEdit->text());
- urlEdit->setText(url.toString());
+ QString string = urlEdit->text();
+ QUrl url = view->guessUrlFromString(string);
+ if (!url.isValid())
+ url = QUrl("http://" + string + "/");
+ urlEdit->setText(url.toEncoded());
view->load(url);
view->setFocus(Qt::OtherFocusReason);
}
@@ -130,11 +155,6 @@ protected slots:
#endif
}
- void newWindow() {
- MainWindow *mw = new MainWindow;
- mw->show();
- }
-
void zoomIn() {
int i = zoomLevels.indexOf(currentZoom);
Q_ASSERT(i >= 0);
@@ -181,6 +201,26 @@ protected slots:
void dumpHtml() {
qDebug() << "HTML: " << view->page()->mainFrame()->toHtml();
}
+
+ void selectElements() {
+ bool ok;
+ QString str = QInputDialog::getText(this, "Select elements", "Choose elements",
+ QLineEdit::Normal, "a", &ok);
+ if (ok && !str.isEmpty()) {
+ QList<QWebElement> result = view->page()->mainFrame()->findAllElements(str);
+ foreach (QWebElement e, result)
+ e.setStyleProperty("background-color", "yellow");
+ statusBar()->showMessage(QString("%1 element(s) selected").arg(result.count()), 5000);
+ }
+ }
+
+public slots:
+
+ void newWindow(const QString &url = QString()) {
+ MainWindow *mw = new MainWindow(url);
+ mw->show();
+ }
+
private:
QVector<int> zoomLevels;
@@ -272,38 +312,10 @@ private:
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));
- }
-
- 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;
- }
- }
+ QMenu *toolsMenu = menuBar()->addMenu("&Tools");
+ toolsMenu->addAction("Select elements...", this, SLOT(selectElements()));
- // Fall back to QUrl's own tolerant parser.
- return QUrl(string, QUrl::TolerantMode);
}
QWebView *view;
@@ -319,6 +331,7 @@ private:
QWebPage *WebPage::createWindow(QWebPage::WebWindowType)
{
MainWindow *mw = new MainWindow;
+ mw->show();
return mw->webPage();
}
@@ -327,8 +340,13 @@ QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QS
Q_UNUSED(url);
Q_UNUSED(paramNames);
Q_UNUSED(paramValues);
+#ifndef QT_NO_UITOOLS
QUiLoader loader;
return loader.createWidget(classId, view());
+#else
+ Q_UNUSED(classId);
+ return 0;
+#endif
}
class URLLoader : public QObject
@@ -396,6 +414,18 @@ private:
#include "main.moc"
+int launcherMain(const QApplication& app)
+{
+#ifndef NDEBUG
+ int retVal = app.exec();
+ qt_drt_garbageCollector_collect();
+ QWebSettings::clearMemoryCaches();
+ return retVal;
+#else
+ return app.exec();
+#endif
+}
+
int main(int argc, char **argv)
{
QApplication app(argc, argv);
@@ -415,25 +445,31 @@ int main(int argc, char **argv)
const QStringList args = app.arguments();
- // robotized
if (args.contains(QLatin1String("-r"))) {
+ // robotized
QString listFile = args.at(2);
if (!(args.count() == 3) && QFile::exists(listFile)) {
qDebug() << "Usage: QtLauncher -r listfile";
exit(0);
}
- MainWindow window(url);
- QWebView *view = window.webView();
+ MainWindow* window = new MainWindow;
+ QWebView *view = window->webView();
URLLoader loader(view, listFile);
QObject::connect(view, SIGNAL(loadFinished(bool)), &loader, SLOT(loadNext()));
- window.show();
- return app.exec();
+ loader.loadNext();
+ window->show();
+ launcherMain(app);
} else {
if (args.count() > 1)
url = args.at(1);
-
- MainWindow window(url);
- window.show();
- return app.exec();
+
+ MainWindow* window = new MainWindow(url);
+
+ // Opens every given urls in new windows
+ for (int i = 2; i < args.count(); i++)
+ window->newWindow(args.at(i));
+
+ window->show();
+ launcherMain(app);
}
}
diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
index 5199a5a..d659833 100644
--- a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
@@ -228,8 +228,8 @@ void ChromeClientQt::setResizable(bool)
notImplemented();
}
-void ChromeClientQt::addMessageToConsole(const String& message, unsigned int lineNumber,
- const String& sourceID)
+void ChromeClientQt::addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message,
+ unsigned int lineNumber, const String& sourceID)
{
QString x = message;
QString y = sourceID;
@@ -288,8 +288,9 @@ void ChromeClientQt::setStatusbarText(const String& msg)
bool ChromeClientQt::shouldInterruptJavaScript()
{
- notImplemented();
- return false;
+ bool shouldInterrupt = false;
+ QMetaObject::invokeMethod(m_webPage, "shouldInterruptJavaScript", Qt::DirectConnection, Q_RETURN_ARG(bool, shouldInterrupt));
+ return shouldInterrupt;
}
bool ChromeClientQt::tabsToLinks() const
@@ -352,18 +353,19 @@ void ChromeClientQt::contentsSizeChanged(Frame* frame, const IntSize& size) cons
void ChromeClientQt::mouseDidMoveOverElement(const HitTestResult& result, unsigned modifierFlags)
{
+ TextDirection dir;
if (result.absoluteLinkURL() != lastHoverURL
- || result.title() != lastHoverTitle
+ || result.title(dir) != lastHoverTitle
|| result.textContent() != lastHoverContent) {
lastHoverURL = result.absoluteLinkURL();
- lastHoverTitle = result.title();
+ lastHoverTitle = result.title(dir);
lastHoverContent = result.textContent();
emit m_webPage->linkHovered(lastHoverURL.prettyURL(),
lastHoverTitle, lastHoverContent);
}
}
-void ChromeClientQt::setToolTip(const String &tip)
+void ChromeClientQt::setToolTip(const String &tip, TextDirection)
{
#ifndef QT_NO_TOOLTIP
QWidget* view = m_webPage->view();
@@ -439,4 +441,16 @@ void ChromeClientQt::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> prpFileC
}
}
+bool ChromeClientQt::setCursor(PlatformCursorHandle)
+{
+ notImplemented();
+ return false;
+}
+
+void ChromeClientQt::requestGeolocationPermissionForFrame(Frame*, Geolocation*)
+{
+ // See the comment in WebCore/page/ChromeClient.h
+ notImplemented();
+}
+
}
diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.h b/WebKit/qt/WebCoreSupport/ChromeClientQt.h
index 7922000..96c7fab 100644
--- a/WebKit/qt/WebCoreSupport/ChromeClientQt.h
+++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.h
@@ -83,8 +83,8 @@ namespace WebCore {
virtual void setResizable(bool);
- virtual void addMessageToConsole(const String& message, unsigned int lineNumber,
- const String& sourceID);
+ virtual void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message,
+ unsigned int lineNumber, const String& sourceID);
virtual bool canRunBeforeUnloadConfirmPanel();
virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame* frame);
@@ -110,7 +110,7 @@ namespace WebCore {
virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags);
- virtual void setToolTip(const String&);
+ virtual void setToolTip(const String&, TextDirection);
virtual void print(Frame*);
#if ENABLE(DATABASE)
@@ -123,6 +123,14 @@ namespace WebCore {
virtual void formStateDidChange(const Node*) { }
+ virtual PassOwnPtr<HTMLParserQuirks> createHTMLParserQuirks() { return 0; }
+
+ virtual bool setCursor(PlatformCursorHandle);
+
+ virtual void scrollRectIntoView(const IntRect&, const ScrollView*) const {}
+
+ virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*);
+
QWebPage* m_webPage;
WebCore::KURL lastHoverURL;
WebCore::String lastHoverTitle;
diff --git a/WebKit/qt/WebCoreSupport/ContextMenuClientQt.cpp b/WebKit/qt/WebCoreSupport/ContextMenuClientQt.cpp
index ae9d718..ed79946 100644
--- a/WebKit/qt/WebCoreSupport/ContextMenuClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/ContextMenuClientQt.cpp
@@ -67,6 +67,12 @@ void ContextMenuClientQt::speak(const String&)
notImplemented();
}
+bool ContextMenuClientQt::isSpeaking()
+{
+ notImplemented();
+ return false;
+}
+
void ContextMenuClientQt::stopSpeaking()
{
notImplemented();
diff --git a/WebKit/qt/WebCoreSupport/ContextMenuClientQt.h b/WebKit/qt/WebCoreSupport/ContextMenuClientQt.h
index ad6bfae..8440ff5 100644
--- a/WebKit/qt/WebCoreSupport/ContextMenuClientQt.h
+++ b/WebKit/qt/WebCoreSupport/ContextMenuClientQt.h
@@ -44,6 +44,7 @@ namespace WebCore {
virtual void downloadURL(const KURL& url);
virtual void lookUpInDictionary(Frame*);
virtual void speak(const String&);
+ virtual bool isSpeaking();
virtual void stopSpeaking();
virtual void searchWithGoogle(const Frame*);
};
diff --git a/WebKit/qt/WebCoreSupport/DragClientQt.cpp b/WebKit/qt/WebCoreSupport/DragClientQt.cpp
index b719868..0df0768 100644
--- a/WebKit/qt/WebCoreSupport/DragClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/DragClientQt.cpp
@@ -23,6 +23,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "config.h"
#include "DragClientQt.h"
#include "ClipboardQt.h"
diff --git a/WebKit/qt/WebCoreSupport/EditCommandQt.cpp b/WebKit/qt/WebCoreSupport/EditCommandQt.cpp
index 1532388..a166840 100644
--- a/WebKit/qt/WebCoreSupport/EditCommandQt.cpp
+++ b/WebKit/qt/WebCoreSupport/EditCommandQt.cpp
@@ -17,6 +17,7 @@
Boston, MA 02110-1301, USA.
*/
+#include "config.h"
#include <wtf/Platform.h>
#include "EditCommandQt.h"
diff --git a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp
index a688779..995d61d 100644
--- a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
* Copyright (C) 2006 Zack Rusin <zack@kde.org>
- * Copyright (C) 2006, 2008 Apple Computer, Inc.
+ * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
*
* All rights reserved.
@@ -34,18 +34,19 @@
#include "qwebpage.h"
#include "qwebpage_p.h"
+#include "CSSStyleDeclaration.h"
#include "Document.h"
#include "EditCommandQt.h"
-#include "Page.h"
#include "Editor.h"
#include "FocusController.h"
#include "Frame.h"
+#include "HTMLElement.h"
#include "KeyboardCodes.h"
#include "KeyboardEvent.h"
+#include "NotImplemented.h"
+#include "Page.h"
#include "Page.h"
#include "PlatformKeyboardEvent.h"
-#include "NotImplemented.h"
-#include "Node.h"
#include "Range.h"
#include <stdio.h>
@@ -83,11 +84,12 @@ static QString dumpRange(WebCore::Range *range)
{
if (!range)
return QLatin1String("(null)");
- QString str;
WebCore::ExceptionCode code;
- str.sprintf("range from %ld of %ls to %ld of %ls",
- range->startOffset(code), dumpPath(range->startContainer(code)).unicode(),
- range->endOffset(code), dumpPath(range->endContainer(code)).unicode());
+
+ QString str = QString("range from %1 of %2 to %3 of %4")
+ .arg(range->startOffset(code)).arg(dumpPath(range->startContainer(code)))
+ .arg(range->endOffset(code)).arg(dumpPath(range->endContainer(code)));
+
return str;
}
@@ -546,6 +548,12 @@ void EditorClientQt::checkSpellingOfString(const UChar*, int, int*, int*)
notImplemented();
}
+String EditorClientQt::getAutoCorrectSuggestionForMisspelledWord(const String&)
+{
+ notImplemented();
+ return String();
+}
+
void EditorClientQt::checkGrammarOfString(const UChar*, int, Vector<GrammarDetail>&, int*, int*)
{
notImplemented();
diff --git a/WebKit/qt/WebCoreSupport/EditorClientQt.h b/WebKit/qt/WebCoreSupport/EditorClientQt.h
index b39f02b..42a402f 100644
--- a/WebKit/qt/WebCoreSupport/EditorClientQt.h
+++ b/WebKit/qt/WebCoreSupport/EditorClientQt.h
@@ -98,6 +98,7 @@ public:
virtual void ignoreWordInSpellDocument(const String&);
virtual void learnWord(const String&);
virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength);
+ virtual String getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord);
virtual void checkGrammarOfString(const UChar*, int length, Vector<GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength);
virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail&);
virtual void updateSpellingUIWithMisspelledWord(const String&);
diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
index 025bd4f..5cf86b1 100644
--- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
@@ -32,6 +32,7 @@
#include "config.h"
#include "CSSComputedStyleDeclaration.h"
#include "CSSPropertyNames.h"
+#include "FormState.h"
#include "FrameLoaderClientQt.h"
#include "FrameTree.h"
#include "FrameView.h"
@@ -53,6 +54,7 @@
#include "ResourceHandleInternal.h"
#include "ResourceHandle.h"
#include "Settings.h"
+#include "ScriptString.h"
#include "qwebpage.h"
#include "qwebframe.h"
@@ -142,10 +144,8 @@ FrameLoaderClientQt::FrameLoaderClientQt()
, 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);
}
@@ -164,10 +164,14 @@ void FrameLoaderClientQt::setFrame(QWebFrame* webFrame, Frame* frame)
connect(this, SIGNAL(loadStarted()),
m_webFrame->page(), SIGNAL(loadStarted()));
+ connect(this, SIGNAL(loadStarted()),
+ m_webFrame, 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(loadFinished(bool)),
+ m_webFrame, SIGNAL(loadFinished(bool)));
connect(this, SIGNAL(titleChanged(const QString&)),
m_webFrame, SIGNAL(titleChanged(const QString&)));
}
@@ -179,20 +183,7 @@ QWebFrame* FrameLoaderClientQt::webFrame() const
void FrameLoaderClientQt::callPolicyFunction(FramePolicyFunction function, PolicyAction action)
{
- ASSERT(!m_policyFunction);
- ASSERT(function);
-
- m_policyFunction = function;
- emit sigCallPolicyFunction(action);
-}
-
-void FrameLoaderClientQt::slotCallPolicyFunction(int action)
-{
- if (!m_frame || !m_policyFunction)
- return;
- FramePolicyFunction function = m_policyFunction;
- m_policyFunction = 0;
- (m_frame->loader()->*function)(WebCore::PolicyAction(action));
+ (m_frame->loader()->*function)(action);
}
bool FrameLoaderClientQt::hasWebView() const
@@ -217,10 +208,14 @@ void FrameLoaderClientQt::transitionToCommittedForNewPage()
QBrush brush = m_webFrame->page()->palette().brush(QPalette::Base);
QColor backgroundColor = brush.style() == Qt::SolidPattern ? brush.color() : QColor();
+
+ QWebPage* page = m_webFrame->page();
+ const QSize fixedLayoutSize = page->fixedContentsSize();
+
m_frame->createView(m_webFrame->page()->viewportSize(),
backgroundColor, !backgroundColor.alpha(),
- m_webFrame->page()->fixedLayoutSize(),
- m_webFrame->page()->useFixedLayout(),
+ fixedLayoutSize.isValid() ? IntSize(fixedLayoutSize) : IntSize(),
+ fixedLayoutSize.isValid(),
(ScrollbarMode)m_webFrame->scrollBarPolicy(Qt::Horizontal),
(ScrollbarMode)m_webFrame->scrollBarPolicy(Qt::Vertical));
}
@@ -336,10 +331,6 @@ void FrameLoaderClientQt::dispatchDidReceiveTitle(const String& title)
if (!m_webFrame)
return;
-
-
- // ### hack
- emit m_webFrame->urlChanged(m_webFrame->url());
emit titleChanged(title);
}
@@ -352,6 +343,7 @@ void FrameLoaderClientQt::dispatchDidCommitLoad()
if (m_frame->tree()->parent() || !m_webFrame)
return;
+ emit m_webFrame->urlChanged(m_webFrame->url());
m_webFrame->page()->d->updateNavigationActions();
// We should assume first the frame has no title. If it has, then the above dispatchDidReceiveTitle()
@@ -367,7 +359,7 @@ void FrameLoaderClientQt::dispatchDidFinishDocumentLoad()
printf("%s - didFinishDocumentLoadForFrame\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)));
if (QWebPagePrivate::drtRun) {
- int unloadEventCount = m_frame->eventHandler()->pendingFrameUnloadEventCount();
+ int unloadEventCount = m_frame->domWindow()->pendingUnloadEventListeners();
if (unloadEventCount)
printf("%s - has %u onunload handler(s)\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)), unloadEventCount);
}
@@ -386,7 +378,7 @@ void FrameLoaderClientQt::dispatchDidFinishLoad()
m_loadSucceeded = true;
- if (m_frame->tree()->parent() || !m_webFrame)
+ if (!m_webFrame)
return;
m_webFrame->page()->d->updateNavigationActions();
}
@@ -412,7 +404,6 @@ void FrameLoaderClientQt::dispatchShow()
void FrameLoaderClientQt::cancelPolicyCheck()
{
// qDebug() << "FrameLoaderClientQt::cancelPolicyCheck";
- m_policyFunction = 0;
}
@@ -420,7 +411,6 @@ void FrameLoaderClientQt::dispatchWillSubmitForm(FramePolicyFunction function,
PassRefPtr<FormState>)
{
notImplemented();
- Q_ASSERT(!m_policyFunction);
// FIXME: This is surely too simple
callPolicyFunction(function, PolicyUse);
}
@@ -565,7 +555,6 @@ void FrameLoaderClientQt::didFinishLoad()
void FrameLoaderClientQt::prepareForDataSourceReplacement()
{
- m_frame->loader()->detachChildren();
}
void FrameLoaderClientQt::setTitle(const String&, const KURL&)
@@ -690,6 +679,11 @@ void FrameLoaderClientQt::committedLoad(WebCore::DocumentLoader* loader, const c
if (m_pluginView) {
if (!m_hasSentResponseToPlugin) {
m_pluginView->didReceiveResponse(loader->response());
+ // didReceiveResponse sets up a new stream to the plug-in. on a full-page plug-in, a failure in
+ // setting up this stream can cause the main document load to be cancelled, setting m_pluginView
+ // to null
+ if (!m_pluginView)
+ return;
m_hasSentResponseToPlugin = true;
}
m_pluginView->didReceiveData(data, length);
@@ -851,6 +845,11 @@ bool FrameLoaderClientQt::dispatchDidLoadResourceFromMemoryCache(WebCore::Docume
return false;
}
+void FrameLoaderClientQt::dispatchDidLoadResourceByXMLHttpRequest(unsigned long, const WebCore::ScriptString&)
+{
+ notImplemented();
+}
+
void FrameLoaderClientQt::dispatchDidFailProvisionalLoad(const WebCore::ResourceError&)
{
if (dumpFrameLoaderCallbacks)
@@ -880,19 +879,15 @@ WebCore::Frame* FrameLoaderClientQt::dispatchCreatePage()
void FrameLoaderClientQt::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const WebCore::String& MIMEType, const WebCore::ResourceRequest&)
{
// we need to call directly here
- Q_ASSERT(!m_policyFunction);
- m_policyFunction = function;
if (canShowMIMEType(MIMEType))
- slotCallPolicyFunction(PolicyUse);
+ callPolicyFunction(function, PolicyUse);
else
- slotCallPolicyFunction(PolicyDownload);
+ callPolicyFunction(function, PolicyDownload);
}
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
@@ -909,17 +904,15 @@ void FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction(FramePolicyFunc
m_frame->loader()->activeDocumentLoader()->setLastCheckedRequest(emptyRequest);
}
- slotCallPolicyFunction(PolicyIgnore);
+ callPolicyFunction(function, PolicyIgnore);
return;
}
- slotCallPolicyFunction(PolicyUse);
+ callPolicyFunction(function, PolicyUse);
}
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 QT_VERSION < 0x040400
QWebNetworkRequest r(request);
#else
@@ -936,10 +929,10 @@ void FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction(FramePolicyFun
m_frame->loader()->activeDocumentLoader()->setLastCheckedRequest(emptyRequest);
}
- slotCallPolicyFunction(PolicyIgnore);
+ callPolicyFunction(function, PolicyIgnore);
return;
}
- slotCallPolicyFunction(PolicyUse);
+ callPolicyFunction(function, PolicyUse);
}
void FrameLoaderClientQt::dispatchUnableToImplementPolicy(const WebCore::ResourceError&)
@@ -964,32 +957,35 @@ PassRefPtr<Frame> FrameLoaderClientQt::createFrame(const KURL& url, const String
if (!m_webFrame)
return 0;
- QWebFrameData frameData;
+ QWebFrameData frameData(m_frame->page(), m_frame, ownerElement, name);
frameData.url = url;
- frameData.name = name;
- frameData.ownerElement = ownerElement;
frameData.referrer = referrer;
frameData.allowsScrolling = allowsScrolling;
frameData.marginWidth = marginWidth;
frameData.marginHeight = marginHeight;
- QWebFrame* webFrame = new QWebFrame(m_webFrame, &frameData);
- emit m_webFrame->page()->frameCreated(webFrame);
+ QPointer<QWebFrame> webFrame = new QWebFrame(m_webFrame, &frameData);
+ // The creation of the frame may have run arbitrary JavaScript that removed it from the page already.
+ if (!webFrame->d->frame->page()) {
+ frameData.frame.release();
+ ASSERT(webFrame.isNull());
+ return 0;
+ }
- RefPtr<Frame> childFrame = adoptRef(webFrame->d->frame);
+ emit m_webFrame->page()->frameCreated(webFrame);
// ### set override encoding if we have one
FrameLoadType loadType = m_frame->loader()->loadType();
FrameLoadType childLoadType = FrameLoadTypeRedirectWithLockedBackForwardList;
- childFrame->loader()->loadURL(frameData.url, frameData.referrer, String(), false, childLoadType, 0, 0);
+ frameData.frame->loader()->loadURLIntoChildFrame(frameData.url, frameData.referrer, frameData.frame.get());
// The frame's onload handler may have removed it from the document.
- if (!childFrame->tree()->parent())
+ if (!frameData.frame->tree()->parent())
return 0;
- return childFrame.release();
+ return frameData.frame.release();
}
ObjectContentType FrameLoaderClientQt::objectContentType(const KURL& url, const String& _mimeType)
@@ -1068,11 +1064,17 @@ public:
IntRect clipRect(static_cast<FrameView*>(parentScrollView)->windowClipRect());
clipRect.move(-windowRect.x(), -windowRect.y());
clipRect.intersect(platformWidget()->rect());
- platformWidget()->setMask(QRegion(clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height()));
+
+ QRegion clipRegion = QRegion(clipRect);
+ platformWidget()->setMask(clipRegion);
+
+ // if setMask is set with an empty QRegion, no clipping will
+ // be performed, so in that case we hide the platformWidget
+ platformWidget()->setVisible(!clipRegion.isEmpty());
}
};
-Widget* FrameLoaderClientQt::createPlugin(const IntSize& pluginSize, HTMLPlugInElement* element, const KURL& url, const Vector<String>& paramNames,
+PassRefPtr<Widget> FrameLoaderClientQt::createPlugin(const IntSize& pluginSize, HTMLPlugInElement* 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;
@@ -1136,7 +1138,7 @@ Widget* FrameLoaderClientQt::createPlugin(const IntSize& pluginSize, HTMLPlugInE
QWidget* view = m_webFrame->page()->view();
if (view)
widget->setParent(view);
- QtPluginWidget* w = new QtPluginWidget();
+ RefPtr<QtPluginWidget> w = adoptRef(new QtPluginWidget());
w->setPlatformWidget(widget);
// Make sure it's invisible until properly placed into the layout
w->setFrameRect(IntRect(0, 0, 0, 0));
@@ -1145,7 +1147,7 @@ Widget* FrameLoaderClientQt::createPlugin(const IntSize& pluginSize, HTMLPlugInE
// FIXME: make things work for widgetless plugins as well
delete object;
} else { // NPAPI Plugins
- PluginView* pluginView = PluginView::create(m_frame, pluginSize, element, url,
+ RefPtr<PluginView> pluginView = PluginView::create(m_frame, pluginSize, element, url,
paramNames, paramValues, mimeType, loadManually);
return pluginView;
}
@@ -1160,7 +1162,7 @@ void FrameLoaderClientQt::redirectDataToPlugin(Widget* pluginWidget)
m_hasSentResponseToPlugin = false;
}
-Widget* FrameLoaderClientQt::createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL,
+PassRefPtr<Widget> FrameLoaderClientQt::createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL,
const Vector<String>& paramNames, const Vector<String>& paramValues)
{
notImplemented();
diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
index c49bb62..754d8bc 100644
--- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
+++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
@@ -59,10 +59,7 @@ namespace WebCore {
friend class ::QWebFrame;
void callPolicyFunction(FramePolicyFunction function, PolicyAction action);
- private slots:
- void slotCallPolicyFunction(int);
signals:
- void sigCallPolicyFunction(int);
void loadStarted();
void loadProgress(int d);
void loadFinished(bool);
@@ -98,6 +95,7 @@ namespace WebCore {
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 dispatchDidLoadResourceByXMLHttpRequest(unsigned long identifier, const WebCore::ScriptString& sourceString);
virtual void dispatchDidHandleOnloadEvents();
virtual void dispatchDidReceiveServerRedirectForProvisionalLoad();
@@ -187,10 +185,10 @@ namespace WebCore {
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&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool);
+ virtual PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool);
virtual void redirectDataToPlugin(Widget* pluginWidget);
- virtual Widget* createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues);
+ virtual PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues);
virtual ObjectContentType objectContentType(const KURL& url, const String& mimeType);
virtual String overrideMediaType() const;
@@ -208,7 +206,6 @@ namespace WebCore {
QWebFrame *m_webFrame;
ResourceResponse m_response;
bool m_firstData;
- FramePolicyFunction m_policyFunction;
// Plugin view to redirect data to
WebCore::PluginView* m_pluginView;
diff --git a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
index fe4d43a..d7f03d1 100644
--- a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
@@ -183,6 +183,11 @@ void InspectorClientQt::inspectedURLChanged(const String& newURL)
updateWindowTitle();
}
+void InspectorClientQt::inspectorWindowObjectCleared()
+{
+ notImplemented();
+}
+
void InspectorClientQt::updateWindowTitle()
{
if (!m_webPage)
diff --git a/WebKit/qt/WebCoreSupport/InspectorClientQt.h b/WebKit/qt/WebCoreSupport/InspectorClientQt.h
index 60ed77a..03c684a 100644
--- a/WebKit/qt/WebCoreSupport/InspectorClientQt.h
+++ b/WebKit/qt/WebCoreSupport/InspectorClientQt.h
@@ -71,6 +71,8 @@ namespace WebCore {
virtual void storeSetting(const String& key, const InspectorController::Setting&);
virtual void removeSetting(const String& key);
+ virtual void inspectorWindowObjectCleared();
+
private:
void updateWindowTitle();
QWebPage* m_inspectedWebPage;
diff --git a/WebKit/qt/WebKit_pch.h b/WebKit/qt/WebKit_pch.h
index ae8ec88..1dd4d52 100644
--- a/WebKit/qt/WebKit_pch.h
+++ b/WebKit/qt/WebKit_pch.h
@@ -77,7 +77,4 @@
#include <wtf/UnusedParam.h>
#include <wtf/AlwaysInline.h>
#include <wtf/GetPtr.h>
-
-#include "../../WebCore/bindings/js/JSDOMBinding.h"
-#include "../../JavaScriptCore/runtime/MathObject.h"
#endif
diff --git a/WebKit/qt/docs/docs.pri b/WebKit/qt/docs/docs.pri
new file mode 100644
index 0000000..4a8c165
--- /dev/null
+++ b/WebKit/qt/docs/docs.pri
@@ -0,0 +1,15 @@
+include(../../../WebKit.pri)
+
+unix {
+ QDOC = SRCDIR=$$PWD/../../.. OUTPUT_DIR=$$OUTPUT_DIR $$(QTDIR)/tools/qdoc3/qdoc3
+} else {
+ QDOC = $$(QTDIR)\tools\qdoc3\release\qdoc3.exe
+}
+
+unix {
+docs.commands = $$QDOC $$PWD/qtwebkit.qdocconf
+} else {
+docs.commands = \"$$QDOC $$PWD/qtwebkit.qdocconf\"
+}
+
+QMAKE_EXTRA_TARGETS += docs
diff --git a/WebKit/qt/docs/qtwebkit.qdoc b/WebKit/qt/docs/qtwebkit.qdoc
new file mode 100644
index 0000000..f3681ee
--- /dev/null
+++ b/WebKit/qt/docs/qtwebkit.qdoc
@@ -0,0 +1,197 @@
+/*!
+ \module QtWebKit
+ \title QtWebKit Module
+ \contentspage Qt's Modules
+ \previouspage QtSvg
+ \nextpage QtXml
+ \ingroup architecture
+ \ingroup modules
+ \brief An introduction to the QtWebKit module.
+
+ \keyword Browser
+ \keyword Web Browser
+
+ \since 4.4
+
+ QtWebKit provides a Web browser engine that makes it easy to embed content
+ from the World Wide Web into your Qt application. At the same time Web
+ content can be enhanced with native controls.
+
+ QtWebKit provides facilities for rendering of HyperText Markup Language
+ (HTML), Extensible HyperText Markup Language (XHTML) and Scalable Vector
+ Graphics (SVG) documents, styled using Cascading Style Sheets (CSS) and
+ scripted with JavaScript.
+
+ A bridge between the JavaScript execution environment and the Qt object
+ model makes it possible for custom QObjects to be scripted. Integration
+ with the Qt networking module enables Web pages to be transparently loaded
+ from Web servers, the local file system or even the Qt resource system.
+
+ In addition to providing pure rendering features, HTML documents can be
+ made fully editable to the user through the use of the \c{contenteditable}
+ attribute on HTML elements.
+
+ QtWebKit is based on the Open Source WebKit engine. More information about
+ WebKit itself can be found on the \l{WebKit Open Source Project} Web site.
+
+ The QtWebKit module is part of the \l{Qt Full Framework Edition}, and the
+ \l{Open Source Versions of Qt}.
+
+ \note Building the QtWebKit module with debugging symbols is problematic
+ on many platforms due to the size of the WebKit engine. We recommend
+ building the module only in release mode for embedded platforms.
+ Currently QtWebKit will always be compiled without debugging symbols
+ when using gcc. Take a look at the last lines of
+ \c{src/3rdparty/webkit/WebCore/WebCore.pro} if you need to change this.
+
+ \note Web site icons, also known as "FavIcons", are currently not supported
+ on Windows. We plan to address this in a future release.
+
+ \note WebKit has certain minimum requirements that must be met on
+ Embedded Linux systems. See the \l{Qt for Embedded Linux Requirements}
+ document for more information.
+
+ Topics:
+
+ \tableofcontents
+
+ \section1 Configuring the Build Process
+
+ Applications using QtWebKit's classes need to be configured to be built
+ against the QtWebKit module. The following declaration in a \c qmake
+ project file ensures that an application is compiled and linked
+ appropriately:
+
+ \snippet webkitsnippets/qtwebkit_build_snippet.qdoc 0
+
+ To include the definitions of the module's classes, use the following
+ directive:
+
+ \snippet webkitsnippets/qtwebkit_build_snippet.qdoc 1
+
+ \section1 Architecture
+
+ The easiest way to render content is through the QWebView class. As a
+ widget it can be embedded into your forms or a graphics view, and it
+ provides convenience functions for downloading and rendering web sites.
+
+ \snippet webkitsnippets/simple/main.cpp Using QWebView
+
+ QWebView is used to view Web pages. An instance of QWebView has one
+ QWebPage. QWebPage provides access to the document structure in a page,
+ describing features such as frames, the navigation history, and the
+ undo/redo stack for editable content.
+
+ HTML documents can be nested using frames in a frameset. An individual
+ frame in HTML is represented using the QWebFrame class. This class includes the
+ bridge to the JavaScript window object and can be painted using QPainter.
+ Each QWebPage has one QWebFrame object as its main frame, and the main frame
+ may contain many child frames.
+
+ Individual elements of an HTML document can be accessed via DOM JavaScript
+ interfaces from within a web page. The equivalent of this API in QtWebKit
+ is represented by QWebElement. QWebElement objects are obtained using QWebFrame's
+ \l{QWebFrame::}{findAllElements()} and \l{QWebFrame::}{findFirstElement()}
+ functions with CSS selector queries.
+
+ Common web browser features, defaults and other settings can be configured
+ through the QWebSettings class. It is possible to provide defaults for all
+ QWebPage instances through the default settings. Individual attributes
+ can be overidden by the page specific settings object.
+
+ \section1 Netscape Plugin Support
+
+ Since WebKit supports the Netscape Plugin API, Qt applications can display
+ Web pages that embed common plugins, as long as the user has the appropriate
+ binary files for those plugins installed and the \l{QWebSettings::PluginsEnabled}
+ attribute is enabled for the application.
+
+ The following locations are searched for plugins:
+
+ \table
+ \header \o Linux/Unix \o Windows
+ \row \o{1,3}
+ \list
+ \o \c{.mozilla/plugins} in the user's home directory
+ \o \c{.netscape/plugins} in the user's home directory
+ \o System locations, such as
+ \list
+ \o \c{/usr/lib/browser/plugins}
+ \o \c{/usr/local/lib/mozilla/plugins}
+ \o \c{/usr/lib/firefox/plugins}
+ \o \c{/usr/lib64/browser-plugins}
+ \o \c{/usr/lib/browser-plugins}
+ \o \c{/usr/lib/mozilla/plugins}
+ \o \c{/usr/local/netscape/plugins}
+ \o \c{/opt/mozilla/plugins}
+ \o \c{/opt/mozilla/lib/plugins}
+ \o \c{/opt/netscape/plugins}
+ \o \c{/opt/netscape/communicator/plugins}
+ \o \c{/usr/lib/netscape/plugins}
+ \o \c{/usr/lib/netscape/plugins-libc5}
+ \o \c{/usr/lib/netscape/plugins-libc6}
+ \o \c{/usr/lib64/netscape/plugins}
+ \o \c{/usr/lib64/mozilla/plugins}
+ \endlist
+ \o Locations specified by environment variables:
+ \list
+ \o \c{$MOZILLA_HOME/plugins}
+ \o \c{$MOZ_PLUGIN_PATH}
+ \o \c{$QTWEBKIT_PLUGIN_PATH}
+ \endlist
+ \endlist
+
+ \o
+ \list
+ \o The user's \c{Application Data\Mozilla\plugins} directory
+ \o Standard system locations of plugins for Quicktime, Flash, etc.
+ \endlist
+
+ \row
+ \raw HTML
+ <th class="qt-style">Mac OS X</th>
+ \endraw
+ \row
+ \o
+ \list
+ \o \c{Library/Internet Plug-Ins} in the user's home directory
+ \o The system \c{/Library/Internet Plug-Ins} directory
+ \endlist
+ \endtable
+
+ \section1 License Information
+
+ This is a snapshot of the Qt port of WebKit. The exact version information
+ can be found in the \c{src/3rdparty/webkit/VERSION} file supplied with Qt.
+
+ Qt Commercial Edition licensees that wish to distribute applications that
+ use the QtWebKit module need to be aware of their obligations under the
+ GNU Lesser General Public License (LGPL).
+
+ Developers using the Open Source Edition can choose to redistribute
+ the module under the appropriate version of the GNU LGPL; version 2.1
+ for applications and libraries licensed under the GNU GPL version 2,
+ or version 3 for applications and libraries licensed under the GNU
+ GPL version 2.
+
+ \legalese
+ WebKit is licensed under the GNU Library General Public License.
+ Individual contributor names and copyright dates can be found
+ inline in the code.
+
+ 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.
+ \endlegalese
+*/
diff --git a/WebKit/qt/docs/qtwebkit.qdocconf b/WebKit/qt/docs/qtwebkit.qdocconf
new file mode 100644
index 0000000..8ee8f69
--- /dev/null
+++ b/WebKit/qt/docs/qtwebkit.qdocconf
@@ -0,0 +1,197 @@
+# Run qdoc from the directory that contains this file.
+
+project = qtwebkit
+description = "Qt WebKit API Documentation"
+
+headerdirs = $SRCDIR/WebKit/qt/Api
+sourcedirs = $SRCDIR/WebKit/qt/Api $SRCDIR/WebKit/qt/docs
+outputdir = $OUTPUT_DIR/doc/html
+outputformats = HTML
+sources.fileextensions = "*.cpp *.doc *.qdoc *.h"
+exampledirs = $SRCDIR/WebKit/qt/docs
+imagedirs = $SRCDIR/WebKit/qt/docs
+
+indexes = $QTDIR/doc/html/qt.index
+
+# macros.qdocconf
+
+macro.aring.HTML = "&aring;"
+macro.Auml.HTML = "&Auml;"
+macro.author = "\\bold{Author:}"
+macro.br.HTML = "<br />"
+macro.BR.HTML = "<br />"
+macro.aacute.HTML = "&aacute;"
+macro.eacute.HTML = "&eacute;"
+macro.iacute.HTML = "&iacute;"
+macro.gui = "\\bold"
+macro.hr.HTML = "<hr />"
+macro.key = "\\bold"
+macro.menu = "\\bold"
+macro.note = "\\bold{Note:}"
+macro.oslash.HTML = "&oslash;"
+macro.ouml.HTML = "&ouml;"
+macro.QA = "\\e{Qt Assistant}"
+macro.QD = "\\e{Qt Designer}"
+macro.QL = "\\e{Qt Linguist}"
+macro.param = "\\e"
+macro.raisedaster.HTML = "<sup>*</sup>"
+macro.reg.HTML = "<sup>&reg;</sup>"
+macro.return = "Returns"
+macro.starslash = "\\c{*/}"
+macro.uuml.HTML = "&uuml;"
+macro.mdash.HTML = "&mdash;"
+
+# compat.qdocconf
+
+alias.i = e
+alias.include = input
+
+macro.0 = "\\\\0"
+macro.b = "\\\\b"
+macro.n = "\\\\n"
+macro.r = "\\\\r"
+macro.i = "\\o"
+macro.i11 = "\\o{1,1}"
+macro.i12 = "\\o{1,2}"
+macro.i13 = "\\o{1,3}"
+macro.i14 = "\\o{1,4}"
+macro.i15 = "\\o{1,5}"
+macro.i16 = "\\o{1,6}"
+macro.i17 = "\\o{1,7}"
+macro.i18 = "\\o{1,8}"
+macro.i19 = "\\o{1,9}"
+macro.i21 = "\\o{2,1}"
+macro.i31 = "\\o{3,1}"
+macro.i41 = "\\o{4,1}"
+macro.i51 = "\\o{5,1}"
+macro.i61 = "\\o{6,1}"
+macro.i71 = "\\o{7,1}"
+macro.i81 = "\\o{8,1}"
+macro.i91 = "\\o{9,1}"
+macro.img = "\\image"
+macro.endquote = "\\endquotation"
+
+spurious = "Missing comma in .*" \
+ "Missing pattern .*"
+
+# Doxygen compatibility commands
+
+macro.see = "\\sa"
+macro.function = "\\fn"
+
+# qt-cpp-ignore.qdocconf
+
+Cpp.ignoretokens = QAXFACTORY_EXPORT \
+ QDESIGNER_COMPONENTS_LIBRARY \
+ QDESIGNER_EXTENSION_LIBRARY \
+ QDESIGNER_SDK_LIBRARY \
+ QDESIGNER_SHARED_LIBRARY \
+ QDESIGNER_UILIB_LIBRARY \
+ QM_EXPORT_CANVAS \
+ QM_EXPORT_DNS \
+ QM_EXPORT_DOM \
+ QM_EXPORT_FTP \
+ QM_EXPORT_HTTP \
+ QM_EXPORT_ICONVIEW \
+ QM_EXPORT_NETWORK \
+ QM_EXPORT_OPENGL \
+ QM_EXPORT_SQL \
+ QM_EXPORT_TABLE \
+ QM_EXPORT_WORKSPACE \
+ QM_EXPORT_XML \
+ QT_ASCII_CAST_WARN \
+ QT_ASCII_CAST_WARN_CONSTRUCTOR \
+ QT_BEGIN_HEADER \
+ QT_DESIGNER_STATIC \
+ QT_END_HEADER \
+ QT_FASTCALL \
+ QT_WIDGET_PLUGIN_EXPORT \
+ Q_COMPAT_EXPORT \
+ Q_CORE_EXPORT \
+ Q_EXPLICIT \
+ Q_EXPORT \
+ Q_EXPORT_CODECS_CN \
+ Q_EXPORT_CODECS_JP \
+ Q_EXPORT_CODECS_KR \
+ Q_EXPORT_PLUGIN \
+ Q_GFX_INLINE \
+ Q_GUI_EXPORT \
+ Q_GUI_EXPORT_INLINE \
+ Q_GUI_EXPORT_STYLE_CDE \
+ Q_GUI_EXPORT_STYLE_COMPACT \
+ Q_GUI_EXPORT_STYLE_MAC \
+ Q_GUI_EXPORT_STYLE_MOTIF \
+ Q_GUI_EXPORT_STYLE_MOTIFPLUS \
+ Q_GUI_EXPORT_STYLE_PLATINUM \
+ Q_GUI_EXPORT_STYLE_POCKETPC \
+ Q_GUI_EXPORT_STYLE_SGI \
+ Q_GUI_EXPORT_STYLE_WINDOWS \
+ Q_GUI_EXPORT_STYLE_WINDOWSXP \
+ QHELP_EXPORT \
+ Q_INLINE_TEMPLATE \
+ Q_INTERNAL_WIN_NO_THROW \
+ Q_NETWORK_EXPORT \
+ Q_OPENGL_EXPORT \
+ Q_OUTOFLINE_TEMPLATE \
+ Q_SQL_EXPORT \
+ Q_SVG_EXPORT \
+ Q_SCRIPT_EXPORT \
+ Q_TESTLIB_EXPORT \
+ Q_TYPENAME \
+ Q_XML_EXPORT \
+ Q_XMLSTREAM_EXPORT \
+ Q_XMLPATTERNS_EXPORT \
+ QDBUS_EXPORT \
+ QT_BEGIN_NAMESPACE \
+ QT_BEGIN_INCLUDE_NAMESPACE \
+ QT_END_NAMESPACE \
+ QT_END_INCLUDE_NAMESPACE \
+ PHONON_EXPORT \
+ EXTENSIONSYSTEM_EXPORT \
+ QWEBKIT_EXPORT
+Cpp.ignoredirectives = Q_DECLARE_HANDLE \
+ Q_DECLARE_INTERFACE \
+ Q_DECLARE_METATYPE \
+ Q_DECLARE_OPERATORS_FOR_FLAGS \
+ Q_DECLARE_PRIVATE \
+ Q_DECLARE_PUBLIC \
+ Q_DECLARE_SHARED \
+ Q_DECLARE_TR_FUNCTIONS \
+ Q_DECLARE_TYPEINFO \
+ Q_DISABLE_COPY \
+ QT_FORWARD_DECLARE_CLASS \
+ Q_DUMMY_COMPARISON_OPERATOR \
+ Q_ENUMS \
+ Q_FLAGS \
+ Q_INTERFACES \
+ __attribute__ \
+ K_DECLARE_PRIVATE \
+ PHONON_OBJECT \
+ PHONON_HEIR
+
+
+
+HTML.style = "" \
+ "h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }"\
+ "a:link { color: #004faf; text-decoration: none }"\
+ "a:visited { color: #672967; text-decoration: none }"\
+ "td.postheader { font-family: sans-serif }"\
+ "tr.address { font-family: sans-serif }"\
+ "body { background: #ffffff; color: black }"\
+ "table tr.odd { background: #f0f0f0; color: black; }"\
+ "table tr.even { background: #e4e4e4; color: black; }"\
+ "table.annotated th { padding: 3px; text-align: left }"\
+ "table.annotated td { padding: 3px; } "\
+ "table tr pre { padding-top: none; padding-bottom: none; padding-left: none; padding-right: none; border: none; background: none }"\
+ "tr.qt-style { background: #a2c511; color: black }"\
+ "body pre { padding: 0.2em; border: #e7e7e7 1px solid; background: #f1f1f1; color: black }"\
+ "span.preprocessor, span.preprocessor a { color: darkblue; }"\
+ "span.comment { color: darkred; font-style: italic }"\
+ "span.string,span.char { color: darkgreen; }"\
+ ".title { text-align: center }"\
+ ".subtitle { font-size: 0.8em }"\
+ ".small-subtitle { font-size: 0.65em }"
+
+HTML.postheader = ""
+
+HTML.footer = ""
diff --git a/WebKit/qt/docs/qwebview-diagram.png b/WebKit/qt/docs/qwebview-diagram.png
new file mode 100644
index 0000000..ada865e
--- /dev/null
+++ b/WebKit/qt/docs/qwebview-diagram.png
Binary files differ
diff --git a/WebKit/qt/docs/webkitsnippets/qtwebkit_build_snippet.qdoc b/WebKit/qt/docs/webkitsnippets/qtwebkit_build_snippet.qdoc
new file mode 100644
index 0000000..d4fc2bd
--- /dev/null
+++ b/WebKit/qt/docs/webkitsnippets/qtwebkit_build_snippet.qdoc
@@ -0,0 +1,8 @@
+//! [0]
+QT += webkit
+//! [0]
+
+
+//! [1]
+#include <QtWebKit>
+//! [1]
diff --git a/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebview_snippet.cpp b/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebview_snippet.cpp
new file mode 100644
index 0000000..f04cd29
--- /dev/null
+++ b/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebview_snippet.cpp
@@ -0,0 +1,35 @@
+
+void wrapInFunction()
+{
+
+//! [0]
+ view->page()->history();
+//! [0]
+
+
+//! [1]
+ view->page()->settings();
+//! [1]
+
+
+//! [2]
+ view->triggerAction(QWebPage::Copy);
+//! [2]
+
+
+//! [3]
+ view->page()->triggerPageAction(QWebPage::Stop);
+//! [3]
+
+
+//! [4]
+ view->page()->triggerPageAction(QWebPage::GoBack);
+//! [4]
+
+
+//! [5]
+ view->page()->triggerPageAction(QWebPage::GoForward);
+//! [5]
+
+}
+
diff --git a/WebKit/qt/docs/webkitsnippets/simple/main.cpp b/WebKit/qt/docs/webkitsnippets/simple/main.cpp
new file mode 100644
index 0000000..82f5b6c
--- /dev/null
+++ b/WebKit/qt/docs/webkitsnippets/simple/main.cpp
@@ -0,0 +1,34 @@
+/*
+ Copyright (C) 2009 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 <QApplication>
+#include <QUrl>
+#include <QWebView>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QWidget *parent = 0;
+//! [Using QWebView]
+ QWebView *view = new QWebView(parent);
+ view->load(QUrl("http://qtsoftware.com/"));
+ view->show();
+//! [Using QWebView]
+ return app.exec();
+}
diff --git a/WebKit/qt/docs/webkitsnippets/simple/simple.pro b/WebKit/qt/docs/webkitsnippets/simple/simple.pro
new file mode 100644
index 0000000..61cd3bf
--- /dev/null
+++ b/WebKit/qt/docs/webkitsnippets/simple/simple.pro
@@ -0,0 +1,2 @@
+QT += webkit
+SOURCES = main.cpp
diff --git a/WebKit/qt/docs/webkitsnippets/webelement/main.cpp b/WebKit/qt/docs/webkitsnippets/webelement/main.cpp
new file mode 100644
index 0000000..d437a6f
--- /dev/null
+++ b/WebKit/qt/docs/webkitsnippets/webelement/main.cpp
@@ -0,0 +1,69 @@
+/*
+ Copyright (C) 2009 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 <QApplication>
+#include <QUrl>
+#include <qwebview.h>
+#include <qwebframe.h>
+#include <qwebelement.h>
+#include <qdebug.h>
+
+static QWebFrame *frame;
+
+static void traverse()
+{
+//! [Traversing with QWebElement]
+ frame->setHtml("<html><body><p>First Paragraph</p><p>Second Paragraph</p></body></html>");
+ QWebElement doc = frame->documentElement();
+ QWebElement body = doc.firstChild();
+ QWebElement firstParagraph = body.firstChild();
+ QWebElement secondParagraph = firstParagraph.nextSibling();
+//! [Traversing with QWebElement]
+}
+
+static void findAll()
+{
+//! [FindAll]
+ QWebElement document = frame->documentElement();
+ /* Assume the document has the following structure:
+
+ <p class=intro>
+ <span>Intro</span>
+ <span>Snippets</span>
+ </p>
+ <p>
+ <span>Content</span>
+ <span>Here</span>
+ </p>
+ */
+
+ QList<QWebElement> allSpans = document.findAll("span");
+ QList<QWebElement> introSpans = document.findAll("p.intro span");
+//! [FindAll]
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QWebView *view = new QWebView(0);
+ frame = view->page()->mainFrame();
+ traverse();
+ findAll();
+ return 0;
+}
diff --git a/WebKit/qt/docs/webkitsnippets/webelement/webelement.pro b/WebKit/qt/docs/webkitsnippets/webelement/webelement.pro
new file mode 100644
index 0000000..f9b403b
--- /dev/null
+++ b/WebKit/qt/docs/webkitsnippets/webelement/webelement.pro
@@ -0,0 +1,5 @@
+TEMPLATE = app
+CONFIG -= app_bundle
+SOURCES = main.cpp
+include(../../../../../WebKit.pri)
+QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
diff --git a/WebKit/qt/docs/webkitsnippets/webpage/main.cpp b/WebKit/qt/docs/webkitsnippets/webpage/main.cpp
new file mode 100644
index 0000000..b91bc30
--- /dev/null
+++ b/WebKit/qt/docs/webkitsnippets/webpage/main.cpp
@@ -0,0 +1,81 @@
+/*
+ Copyright (C) 2009 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 <QtGui>
+#include <QWebPage>
+#include <QWebFrame>
+
+//! [0]
+class Thumbnailer : public QObject
+{
+ Q_OBJECT
+
+public:
+ Thumbnailer(const QUrl &url);
+
+signals:
+ void finished();
+
+private slots:
+ void render();
+
+private:
+ QWebPage page;
+
+};
+//! [0]
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ Thumbnailer thumbnail(QUrl("http://qtsoftware.com"));
+
+ QObject::connect(&thumbnail, SIGNAL(finished()),
+ &app, SLOT(quit()));
+
+ return app.exec();
+}
+
+//! [1]
+Thumbnailer::Thumbnailer(const QUrl &url)
+{
+ page.mainFrame()->load(url);
+ connect(&page, SIGNAL(loadFinished(bool)),
+ this, SLOT(render()));
+}
+//! [1]
+
+//! [2]
+void Thumbnailer::render()
+{
+ page.setViewportSize(page.mainFrame()->contentsSize());
+ QImage image(page.viewportSize(), QImage::Format_ARGB32);
+ QPainter painter(&image);
+
+ page.mainFrame()->render(&painter);
+ painter.end();
+
+ QImage thumbnail = image.scaled(400, 400);
+ thumbnail.save("thumbnail.png");
+
+ emit finished();
+}
+//! [2]
+#include "main.moc"
diff --git a/WebKit/qt/docs/webkitsnippets/webpage/webpage.pro b/WebKit/qt/docs/webkitsnippets/webpage/webpage.pro
new file mode 100644
index 0000000..fcad03b
--- /dev/null
+++ b/WebKit/qt/docs/webkitsnippets/webpage/webpage.pro
@@ -0,0 +1,3 @@
+CONFIG += console
+QT += webkit
+SOURCES = main.cpp \ No newline at end of file
diff --git a/WebKit/qt/tests/benchmarks/loading/tst_loading.cpp b/WebKit/qt/tests/benchmarks/loading/tst_loading.cpp
new file mode 100644
index 0000000..0bc87f7
--- /dev/null
+++ b/WebKit/qt/tests/benchmarks/loading/tst_loading.cpp
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2009 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
+ * 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 <qwebframe.h>
+#include <qwebview.h>
+#include <qpainter.h>
+
+/**
+ * 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_Loading : public QObject
+{
+ Q_OBJECT
+
+public:
+
+public Q_SLOTS:
+ void init();
+ void cleanup();
+
+private Q_SLOTS:
+ void load_data();
+ void load();
+
+private:
+ QWebView* m_view;
+ QWebPage* m_page;
+};
+
+void tst_Loading::init()
+{
+ m_view = new QWebView;
+ m_page = m_view->page();
+
+ QSize viewportSize(1024, 768);
+ m_view->setFixedSize(viewportSize);
+ m_page->setViewportSize(viewportSize);
+}
+
+void tst_Loading::cleanup()
+{
+ delete m_view;
+}
+
+void tst_Loading::load_data()
+{
+ QTest::addColumn<QUrl>("url");
+ QTest::newRow("amazon") << QUrl("http://www.amazon.com");
+ QTest::newRow("kde") << QUrl("http://www.kde.org");
+ QTest::newRow("apple") << QUrl("http://www.apple.com");
+}
+
+void tst_Loading::load()
+{
+ QFETCH(QUrl, url);
+
+
+ QBENCHMARK {
+ m_view->load(url);
+
+ // really wait for loading, painting is in another test
+ ::waitForSignal(m_view, SIGNAL(loadFinished(bool)));
+ }
+}
+
+QTEST_MAIN(tst_Loading)
+#include "tst_loading.moc"
diff --git a/WebKit/qt/tests/benchmarks/loading/tst_loading.pro b/WebKit/qt/tests/benchmarks/loading/tst_loading.pro
new file mode 100644
index 0000000..af0387e
--- /dev/null
+++ b/WebKit/qt/tests/benchmarks/loading/tst_loading.pro
@@ -0,0 +1,6 @@
+TEMPLATE = app
+TARGET = tst_loading
+include(../../../../../WebKit.pri)
+SOURCES += tst_loading.cpp
+QT += testlib network
+QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
diff --git a/WebKit/qt/tests/benchmarks/painting/tst_painting.cpp b/WebKit/qt/tests/benchmarks/painting/tst_painting.cpp
new file mode 100644
index 0000000..f4531fd
--- /dev/null
+++ b/WebKit/qt/tests/benchmarks/painting/tst_painting.cpp
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2009 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
+ * 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 <qwebframe.h>
+#include <qwebview.h>
+#include <qpainter.h>
+
+/**
+ * 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_Painting : public QObject
+{
+ Q_OBJECT
+
+public:
+
+public Q_SLOTS:
+ void init();
+ void cleanup();
+
+private Q_SLOTS:
+ void paint_data();
+ void paint();
+
+private:
+ QWebView* m_view;
+ QWebPage* m_page;
+};
+
+void tst_Painting::init()
+{
+ m_view = new QWebView;
+ m_page = m_view->page();
+
+ QSize viewportSize(1024, 768);
+ m_view->setFixedSize(viewportSize);
+ m_page->setViewportSize(viewportSize);
+}
+
+void tst_Painting::cleanup()
+{
+ delete m_view;
+}
+
+void tst_Painting::paint_data()
+{
+ QTest::addColumn<QUrl>("url");
+ QTest::newRow("amazon") << QUrl("http://www.amazon.com");
+}
+
+void tst_Painting::paint()
+{
+ QFETCH(QUrl, url);
+
+ m_view->load(url);
+ ::waitForSignal(m_view, SIGNAL(loadFinished(bool)));
+
+ /* force a layout */
+ QWebFrame* mainFrame = m_page->mainFrame();
+ mainFrame->toPlainText();
+
+ QPixmap pixmap(m_page->viewportSize());
+ QBENCHMARK {
+ QPainter painter(&pixmap);
+ mainFrame->render(&painter, QRect(QPoint(0, 0), m_page->viewportSize()));
+ painter.end();
+ }
+}
+
+QTEST_MAIN(tst_Painting)
+#include "tst_painting.moc"
diff --git a/WebKit/qt/tests/benchmarks/painting/tst_painting.pro b/WebKit/qt/tests/benchmarks/painting/tst_painting.pro
new file mode 100644
index 0000000..496210e
--- /dev/null
+++ b/WebKit/qt/tests/benchmarks/painting/tst_painting.pro
@@ -0,0 +1,6 @@
+TEMPLATE = app
+TARGET = tst_painting
+include(../../../../../WebKit.pri)
+SOURCES += tst_painting.cpp
+QT += testlib network
+QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
diff --git a/WebKit/qt/tests/qwebelement/qwebelement.pro b/WebKit/qt/tests/qwebelement/qwebelement.pro
new file mode 100644
index 0000000..dd0b88a
--- /dev/null
+++ b/WebKit/qt/tests/qwebelement/qwebelement.pro
@@ -0,0 +1,7 @@
+TEMPLATE = app
+TARGET = tst_qwebelement
+include(../../../../WebKit.pri)
+SOURCES += tst_qwebelement.cpp
+RESOURCES += qwebelement.qrc
+QT += testlib network
+QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
diff --git a/WebKit/qt/tests/qwebelement/qwebelement.qrc b/WebKit/qt/tests/qwebelement/qwebelement.qrc
new file mode 100644
index 0000000..ed01440
--- /dev/null
+++ b/WebKit/qt/tests/qwebelement/qwebelement.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/">
+<file>style.css</file>
+<file>style2.css</file>
+</qresource>
+</RCC>
diff --git a/WebKit/qt/tests/qwebelement/style.css b/WebKit/qt/tests/qwebelement/style.css
new file mode 100644
index 0000000..2713dfd
--- /dev/null
+++ b/WebKit/qt/tests/qwebelement/style.css
@@ -0,0 +1 @@
+#idP {color: black !important}
diff --git a/WebKit/qt/tests/qwebelement/style2.css b/WebKit/qt/tests/qwebelement/style2.css
new file mode 100644
index 0000000..6575dcb
--- /dev/null
+++ b/WebKit/qt/tests/qwebelement/style2.css
@@ -0,0 +1 @@
+#idP {color: green ! important}
diff --git a/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp b/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp
new file mode 100644
index 0000000..0819a3a
--- /dev/null
+++ b/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp
@@ -0,0 +1,882 @@
+/*
+ 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 <qwebelement.h>
+//TESTED_CLASS=
+//TESTED_FILES=
+
+/**
+ * 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_QWebElement : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QWebElement();
+ virtual ~tst_QWebElement();
+
+public slots:
+ void init();
+ void cleanup();
+
+private slots:
+ void textHtml();
+ void simpleCollection();
+ void attributes();
+ void attributesNS();
+ void classes();
+ void namespaceURI();
+ void foreachManipulation();
+ void evaluateScript();
+ void callFunction();
+ void callFunctionSubmitForm();
+ void functionNames();
+ void documentElement();
+ void frame();
+ void style();
+ void computedStyle();
+ void properties();
+ void appendAndPrepend();
+ void insertBeforeAndAfter();
+ void remove();
+ void clear();
+ void replaceWith();
+ void encloseWith();
+ void encloseContentsWith();
+ void nullSelect();
+ void firstChildNextSibling();
+ void lastChildPreviousSibling();
+
+private:
+ QWebView* m_view;
+ QWebPage* m_page;
+ QWebFrame* m_mainFrame;
+};
+
+tst_QWebElement::tst_QWebElement()
+{
+}
+
+tst_QWebElement::~tst_QWebElement()
+{
+}
+
+void tst_QWebElement::init()
+{
+ m_view = new QWebView();
+ m_page = m_view->page();
+ m_mainFrame = m_page->mainFrame();
+}
+
+void tst_QWebElement::cleanup()
+{
+ delete m_view;
+}
+
+void tst_QWebElement::textHtml()
+{
+ QString html = "<head></head><body><p>test</p></body>";
+ m_mainFrame->setHtml(html);
+ QWebElement body = m_mainFrame->documentElement();
+ QVERIFY(!body.isNull());
+
+ QCOMPARE(body.toPlainText(), QString("test"));
+ QCOMPARE(body.toPlainText(), m_mainFrame->toPlainText());
+
+ QCOMPARE(body.toInnerXml(), html);
+}
+
+void tst_QWebElement::simpleCollection()
+{
+ QString html = "<body><p>first para</p><p>second para</p></body>";
+ m_mainFrame->setHtml(html);
+ QWebElement body = m_mainFrame->documentElement();
+
+ QList<QWebElement> list = body.findAll("p");
+ QCOMPARE(list.count(), 2);
+ QCOMPARE(list.at(0).toPlainText(), QString("first para"));
+ QCOMPARE(list.at(1).toPlainText(), QString("second para"));
+}
+
+void tst_QWebElement::attributes()
+{
+ m_mainFrame->setHtml("<body><p>Test");
+ QWebElement body = m_mainFrame->documentElement();
+
+ QVERIFY(!body.hasAttribute("title"));
+ QVERIFY(!body.hasAttributes());
+
+ body.setAttribute("title", "test title");
+
+ QVERIFY(body.hasAttributes());
+ QVERIFY(body.hasAttribute("title"));
+
+ QCOMPARE(body.attribute("title"), QString("test title"));
+
+ body.removeAttribute("title");
+
+ QVERIFY(!body.hasAttribute("title"));
+ QVERIFY(!body.hasAttributes());
+
+ QCOMPARE(body.attribute("does-not-exist", "testvalue"), QString("testvalue"));
+}
+
+void tst_QWebElement::attributesNS()
+{
+ QString content = "<html xmlns=\"http://www.w3.org/1999/xhtml\" "
+ "xmlns:svg=\"http://www.w3.org/2000/svg\">"
+ "<body><svg:svg id=\"foobar\" width=\"400px\" height=\"300px\">"
+ "</svg:svg></body></html>";
+
+ m_mainFrame->setContent(content.toUtf8(), "application/xhtml+xml");
+
+ QWebElement svg = m_mainFrame->findFirstElement("svg");
+ QVERIFY(!svg.isNull());
+
+ QVERIFY(!svg.hasAttributeNS("http://www.w3.org/2000/svg", "foobar"));
+ QCOMPARE(svg.attributeNS("http://www.w3.org/2000/svg", "foobar", "defaultblah"), QString("defaultblah"));
+ svg.setAttributeNS("http://www.w3.org/2000/svg", "svg:foobar", "true");
+ QVERIFY(svg.hasAttributeNS("http://www.w3.org/2000/svg", "foobar"));
+ QCOMPARE(svg.attributeNS("http://www.w3.org/2000/svg", "foobar", "defaultblah"), QString("true"));
+}
+
+void tst_QWebElement::classes()
+{
+ m_mainFrame->setHtml("<body><p class=\"a b c d a c\">Test");
+
+ QWebElement body = m_mainFrame->documentElement();
+ QCOMPARE(body.classes().count(), 0);
+
+ QWebElement p = m_mainFrame->documentElement().findAll("p").at(0);
+ QStringList classes = p.classes();
+ QCOMPARE(classes.count(), 4);
+ QCOMPARE(classes[0], QLatin1String("a"));
+ QCOMPARE(classes[1], QLatin1String("b"));
+ QCOMPARE(classes[2], QLatin1String("c"));
+ QCOMPARE(classes[3], QLatin1String("d"));
+ QVERIFY(p.hasClass("a"));
+ QVERIFY(p.hasClass("b"));
+ QVERIFY(p.hasClass("c"));
+ QVERIFY(p.hasClass("d"));
+ QVERIFY(!p.hasClass("e"));
+
+ p.addClass("f");
+ QVERIFY(p.hasClass("f"));
+ p.addClass("a");
+ QCOMPARE(p.classes().count(), 5);
+ QVERIFY(p.hasClass("a"));
+ QVERIFY(p.hasClass("b"));
+ QVERIFY(p.hasClass("c"));
+ QVERIFY(p.hasClass("d"));
+
+ p.toggleClass("a");
+ QVERIFY(!p.hasClass("a"));
+ QVERIFY(p.hasClass("b"));
+ QVERIFY(p.hasClass("c"));
+ QVERIFY(p.hasClass("d"));
+ QVERIFY(p.hasClass("f"));
+ QCOMPARE(p.classes().count(), 4);
+ p.toggleClass("f");
+ QVERIFY(!p.hasClass("f"));
+ QCOMPARE(p.classes().count(), 3);
+ p.toggleClass("a");
+ p.toggleClass("f");
+ QVERIFY(p.hasClass("a"));
+ QVERIFY(p.hasClass("f"));
+ QCOMPARE(p.classes().count(), 5);
+
+ p.removeClass("f");
+ QVERIFY(!p.hasClass("f"));
+ QCOMPARE(p.classes().count(), 4);
+ p.removeClass("d");
+ QVERIFY(!p.hasClass("d"));
+ QCOMPARE(p.classes().count(), 3);
+ p.removeClass("not-exist");
+ QCOMPARE(p.classes().count(), 3);
+ p.removeClass("c");
+ QVERIFY(!p.hasClass("c"));
+ QCOMPARE(p.classes().count(), 2);
+ p.removeClass("b");
+ QVERIFY(!p.hasClass("b"));
+ QCOMPARE(p.classes().count(), 1);
+ p.removeClass("a");
+ QVERIFY(!p.hasClass("a"));
+ QCOMPARE(p.classes().count(), 0);
+ p.removeClass("foobar");
+ QCOMPARE(p.classes().count(), 0);
+}
+
+void tst_QWebElement::namespaceURI()
+{
+ QString content = "<html xmlns=\"http://www.w3.org/1999/xhtml\" "
+ "xmlns:svg=\"http://www.w3.org/2000/svg\">"
+ "<body><svg:svg id=\"foobar\" width=\"400px\" height=\"300px\">"
+ "</svg:svg></body></html>";
+
+ m_mainFrame->setContent(content.toUtf8(), "application/xhtml+xml");
+ QWebElement body = m_mainFrame->documentElement();
+ QCOMPARE(body.namespaceUri(), QLatin1String("http://www.w3.org/1999/xhtml"));
+
+ QWebElement svg = body.findAll("*#foobar").at(0);
+ QCOMPARE(svg.prefix(), QLatin1String("svg"));
+ QCOMPARE(svg.localName(), QLatin1String("svg"));
+ QCOMPARE(svg.tagName(), QLatin1String("svg:svg"));
+ QCOMPARE(svg.namespaceUri(), QLatin1String("http://www.w3.org/2000/svg"));
+
+}
+
+void tst_QWebElement::foreachManipulation()
+{
+ QString html = "<body><p>first para</p><p>second para</p></body>";
+ m_mainFrame->setHtml(html);
+ QWebElement body = m_mainFrame->documentElement();
+
+ foreach(QWebElement p, body.findAll("p")) {
+ p.setInnerXml("<div>foo</div><div>bar</div>");
+ }
+
+ QCOMPARE(body.findAll("div").count(), 4);
+}
+
+void tst_QWebElement::evaluateScript()
+{
+ QVariant result;
+ m_mainFrame->setHtml("<body><p>test");
+ QWebElement para = m_mainFrame->findFirstElement("p");
+
+ result = para.evaluateScript("this.tagName");
+ QVERIFY(result.isValid());
+ QVERIFY(result.type() == QVariant::String);
+ QCOMPARE(result.toString(), QLatin1String("P"));
+
+ QVERIFY(para.functions().contains("hasAttributes"));
+ result = para.evaluateScript("this.hasAttributes()");
+ QVERIFY(result.isValid());
+ QVERIFY(result.type() == QVariant::Bool);
+ QVERIFY(!result.toBool());
+
+ para.evaluateScript("this.setAttribute('align', 'left');");
+ QCOMPARE(para.attribute("align"), QLatin1String("left"));
+
+ result = para.evaluateScript("this.hasAttributes()");
+ QVERIFY(result.isValid());
+ QVERIFY(result.type() == QVariant::Bool);
+ QVERIFY(result.toBool());
+}
+
+void tst_QWebElement::callFunction()
+{
+ m_mainFrame->setHtml("<body><p>test");
+ QWebElement body = m_mainFrame->documentElement();
+ QVERIFY(body.functions().contains("hasChildNodes"));
+ QVariant result = body.callFunction("hasChildNodes");
+ QVERIFY(result.isValid());
+ QVERIFY(result.type() == QVariant::Bool);
+ QVERIFY(result.toBool());
+
+ body.callFunction("setAttribute", QVariantList() << "foo" << "bar");
+ QCOMPARE(body.attribute("foo"), QString("bar"));
+}
+
+void tst_QWebElement::callFunctionSubmitForm()
+{
+ m_mainFrame->setHtml(QString("<html><body><form name='tstform' action='data:text/html,foo'method='get'>"
+ "<input type='text'><input type='submit'></form></body></html>"), QUrl());
+
+ QWebElement form = m_mainFrame->documentElement().findAll("form").at(0);
+ QVERIFY(form.functions().contains("submit"));
+ QVERIFY(!form.isNull());
+ form.callFunction("submit");
+
+ waitForSignal(m_page, SIGNAL(loadFinished(bool)));
+ QCOMPARE(m_mainFrame->url().toString(), QString("data:text/html,foo?"));
+}
+
+void tst_QWebElement::functionNames()
+{
+ m_mainFrame->setHtml("<body><p>Test");
+
+ QWebElement body = m_mainFrame->documentElement();
+
+ QVERIFY(body.functions().contains("setAttribute"));
+}
+
+void tst_QWebElement::documentElement()
+{
+ m_mainFrame->setHtml("<body><p>Test");
+
+ QWebElement para = m_mainFrame->documentElement().findAll("p").at(0);
+ QVERIFY(para.parent().parent() == m_mainFrame->documentElement());
+ QVERIFY(para.document() == m_mainFrame->documentElement());
+}
+
+void tst_QWebElement::frame()
+{
+ m_mainFrame->setHtml("<body><p>test");
+
+ QWebElement doc = m_mainFrame->documentElement();
+ QVERIFY(doc.webFrame() == m_mainFrame);
+
+ m_view->setHtml(QString("data:text/html,<frameset cols=\"25%,75%\"><frame src=\"data:text/html,"
+ "<p>frame1\">"
+ "<frame src=\"data:text/html,<p>frame2\"></frameset>"), QUrl());
+
+ waitForSignal(m_page, SIGNAL(loadFinished(bool)));
+
+ QCOMPARE(m_mainFrame->childFrames().count(), 2);
+
+ QWebFrame* firstFrame = m_mainFrame->childFrames().at(0);
+ QWebFrame* secondFrame = m_mainFrame->childFrames().at(1);
+
+ QCOMPARE(firstFrame->toPlainText(), QString("frame1"));
+ QCOMPARE(secondFrame->toPlainText(), QString("frame2"));
+
+ QWebElement firstPara = firstFrame->documentElement().findAll("p").at(0);
+ QWebElement secondPara = secondFrame->documentElement().findAll("p").at(0);
+
+ QVERIFY(firstPara.webFrame() == firstFrame);
+ QVERIFY(secondPara.webFrame() == secondFrame);
+}
+
+void tst_QWebElement::style()
+{
+ QString html = "<head>"
+ "<style type='text/css'>"
+ "p { color: green !important }"
+ "#idP { color: red }"
+ ".classP { color : yellow ! important }"
+ "</style>"
+ "</head>"
+ "<body>"
+ "<p id='idP' class='classP' style='color: blue;'>some text</p>"
+ "</body>";
+
+ m_mainFrame->setHtml(html);
+
+ QWebElement p = m_mainFrame->documentElement().findAll("p").at(0);
+ QCOMPARE(p.styleProperty("color"), QLatin1String("blue"));
+ QVERIFY(p.styleProperty("cursor").isEmpty());
+
+ p.setStyleProperty("color", "red");
+ p.setStyleProperty("cursor", "auto");
+
+ QCOMPARE(p.styleProperty("color"), QLatin1String("red"));
+ QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("yellow"));
+ QCOMPARE(p.styleProperty("cursor"), QLatin1String("auto"));
+
+ p.setStyleProperty("color", "green !important");
+ QCOMPARE(p.styleProperty("color"), QLatin1String("green"));
+ QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("green"));
+
+ p.setStyleProperty("color", "blue");
+ QCOMPARE(p.styleProperty("color"), QLatin1String("green"));
+ QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("green"));
+
+ p.setStyleProperty("color", "blue", QWebElement::ImportantStylePriority);
+ QCOMPARE(p.styleProperty("color"), QLatin1String("blue"));
+ QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("blue"));
+
+ QString html2 = "<head>"
+ "<style type='text/css'>"
+ "p { color: green }"
+ "#idP { color: red }"
+ ".classP { color: yellow }"
+ "</style>"
+ "</head>"
+ "<body>"
+ "<p id='idP' class='classP' style='color: blue;'>some text</p>"
+ "</body>";
+
+ m_mainFrame->setHtml(html2);
+ p = m_mainFrame->documentElement().findAll("p").at(0);
+
+ QCOMPARE(p.styleProperty("color"), QLatin1String("blue"));
+ QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("blue"));
+
+ QString html3 = "<head>"
+ "<style type='text/css'>"
+ "p { color: green !important }"
+ "#idP { color: red !important}"
+ ".classP { color: yellow !important}"
+ "</style>"
+ "</head>"
+ "<body>"
+ "<p id='idP' class='classP' style='color: blue !important;'>some text</p>"
+ "</body>";
+
+ m_mainFrame->setHtml(html3);
+ p = m_mainFrame->documentElement().findAll("p").at(0);
+
+ QCOMPARE(p.styleProperty("color"), QLatin1String("blue"));
+ QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("blue"));
+
+ QString html5 = "<head>"
+ "<style type='text/css'>"
+ "p { color: green }"
+ "#idP { color: red }"
+ ".classP { color: yellow }"
+ "</style>"
+ "</head>"
+ "<body>"
+ "<p id='idP' class='classP'>some text</p>"
+ "</body>";
+
+ m_mainFrame->setHtml(html5);
+ p = m_mainFrame->documentElement().findAll("p").at(0);
+
+ QCOMPARE(p.styleProperty("color"), QLatin1String(""));
+ QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("red"));
+
+ QString html6 = "<head>"
+ "<link rel='stylesheet' href='qrc:/style.css' type='text/css' />"
+ "<style type='text/css'>"
+ "p { color: green }"
+ "#idP { color: red }"
+ ".classP { color: yellow ! important}"
+ "</style>"
+ "</head>"
+ "<body>"
+ "<p id='idP' class='classP' style='color: blue;'>some text</p>"
+ "</body>";
+
+ // in few seconds, the CSS should be completey loaded
+ QSignalSpy spy(m_page, SIGNAL(loadFinished(bool)));
+ m_mainFrame->setHtml(html6);
+ QTest::qWait(200);
+
+ p = m_mainFrame->documentElement().findAll("p").at(0);
+ QCOMPARE(p.styleProperty("color"), QLatin1String("blue"));
+ QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("black"));
+
+ QString html7 = "<head>"
+ "<style type='text/css'>"
+ "@import url(qrc:/style2.css);"
+ "</style>"
+ "<link rel='stylesheet' href='qrc:/style.css' type='text/css' />"
+ "</head>"
+ "<body>"
+ "<p id='idP' style='color: blue;'>some text</p>"
+ "</body>";
+
+ // in few seconds, the style should be completey loaded
+ m_mainFrame->setHtml(html7);
+ QTest::qWait(200);
+
+ p = m_mainFrame->documentElement().findAll("p").at(0);
+ QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("black"));
+
+ QString html8 = "<body><p>some text</p></body>";
+
+ m_mainFrame->setHtml(html8);
+ p = m_mainFrame->documentElement().findAll("p").at(0);
+
+ QCOMPARE(p.styleProperty("color"), QLatin1String(""));
+ QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String(""));
+}
+
+void tst_QWebElement::computedStyle()
+{
+ QString html = "<body><p>some text</p></body>";
+ m_mainFrame->setHtml(html);
+
+ QWebElement p = m_mainFrame->documentElement().findAll("p").at(0);
+ QCOMPARE(p.computedStyleProperty("cursor"), QLatin1String("auto"));
+ QVERIFY(!p.computedStyleProperty("cursor").isEmpty());
+ QVERIFY(p.styleProperty("cursor").isEmpty());
+
+ p.setStyleProperty("cursor", "text");
+ p.setStyleProperty("color", "red");
+
+ QCOMPARE(p.computedStyleProperty("cursor"), QLatin1String("text"));
+ QCOMPARE(p.computedStyleProperty("color"), QLatin1String("rgb(255, 0, 0)"));
+ QCOMPARE(p.styleProperty("color"), QLatin1String("red"));
+}
+
+void tst_QWebElement::properties()
+{
+ m_mainFrame->setHtml("<body><form><input type=checkbox id=ourcheckbox checked=true>");
+
+ QWebElement checkBox = m_mainFrame->findFirstElement("#ourcheckbox");
+ QVERIFY(!checkBox.isNull());
+
+ QVERIFY(checkBox.scriptableProperties().contains("checked"));
+
+ QCOMPARE(checkBox.scriptableProperty("checked"), QVariant(true));
+ checkBox.setScriptableProperty("checked", false);
+ QCOMPARE(checkBox.scriptableProperty("checked"), QVariant(false));
+
+ QVERIFY(!checkBox.scriptableProperties().contains("non_existant"));
+ QCOMPARE(checkBox.scriptableProperty("non_existant"), QVariant());
+
+ checkBox.setScriptableProperty("non_existant", "test");
+
+ QCOMPARE(checkBox.scriptableProperty("non_existant"), QVariant("test"));
+ QVERIFY(checkBox.scriptableProperties().contains("non_existant"));
+
+ // removing scriptableProperties is currently not supported. We should look into this
+ // and consider the option of just allowing through the QtScript API only.
+#if 0
+ checkBox.setScriptableProperty("non_existant", QVariant());
+
+ QCOMPARE(checkBox.scriptableProperty("non_existant"), QVariant());
+ QVERIFY(!checkBox.scriptableProperties().contains("non_existant"));
+#endif
+}
+
+void tst_QWebElement::appendAndPrepend()
+{
+ QString html = "<body>"
+ "<p>"
+ "foo"
+ "</p>"
+ "<p>"
+ "bar"
+ "</p>"
+ "</body>";
+
+ m_mainFrame->setHtml(html);
+ QWebElement body = m_mainFrame->documentElement().findFirst("body");
+
+ QCOMPARE(body.findAll("p").count(), 2);
+ body.appendInside(body.findFirst("p"));
+ QCOMPARE(body.findAll("p").count(), 2);
+ QCOMPARE(body.findFirst("p").toPlainText(), QString("bar"));
+ QCOMPARE(body.findAll("p").last().toPlainText(), QString("foo"));
+
+ body.appendInside(body.findFirst("p").clone());
+ QCOMPARE(body.findAll("p").count(), 3);
+ QCOMPARE(body.findFirst("p").toPlainText(), QString("bar"));
+ QCOMPARE(body.findAll("p").last().toPlainText(), QString("bar"));
+
+ body.prependInside(body.findAll("p").at(1).clone());
+ QCOMPARE(body.findAll("p").count(), 4);
+ QCOMPARE(body.findFirst("p").toPlainText(), QString("foo"));
+
+ body.findFirst("p").appendInside("<div>booyakasha</div>");
+ QCOMPARE(body.findAll("p div").count(), 1);
+ QCOMPARE(body.findFirst("p div").toPlainText(), QString("booyakasha"));
+
+ body.findFirst("div").prependInside("<code>yepp</code>");
+ QCOMPARE(body.findAll("p div code").count(), 1);
+ QCOMPARE(body.findFirst("p div code").toPlainText(), QString("yepp"));
+}
+
+void tst_QWebElement::insertBeforeAndAfter()
+{
+ QString html = "<body>"
+ "<p>"
+ "foo"
+ "</p>"
+ "<div>"
+ "yeah"
+ "</div>"
+ "<p>"
+ "bar"
+ "</p>"
+ "</body>";
+
+ m_mainFrame->setHtml(html);
+ QWebElement body = m_mainFrame->documentElement().findFirst("body");
+ QWebElement div = body.findFirst("div");
+
+ QCOMPARE(body.findAll("p").count(), 2);
+ QCOMPARE(body.findAll("div").count(), 1);
+
+ div.prependOutside(body.findAll("p").last().clone());
+ QCOMPARE(body.findAll("p").count(), 3);
+ QCOMPARE(body.findAll("p").at(0).toPlainText(), QString("foo"));
+ QCOMPARE(body.findAll("p").at(1).toPlainText(), QString("bar"));
+ QCOMPARE(body.findAll("p").at(2).toPlainText(), QString("bar"));
+
+ div.appendOutside(body.findFirst("p").clone());
+ QCOMPARE(body.findAll("p").count(), 4);
+ QCOMPARE(body.findAll("p").at(0).toPlainText(), QString("foo"));
+ QCOMPARE(body.findAll("p").at(1).toPlainText(), QString("bar"));
+ QCOMPARE(body.findAll("p").at(2).toPlainText(), QString("foo"));
+ QCOMPARE(body.findAll("p").at(3).toPlainText(), QString("bar"));
+
+ div.prependOutside("<span>hey</span>");
+ QCOMPARE(body.findAll("span").count(), 1);
+
+ div.appendOutside("<span>there</span>");
+ QCOMPARE(body.findAll("span").count(), 2);
+ QCOMPARE(body.findAll("span").at(0).toPlainText(), QString("hey"));
+ QCOMPARE(body.findAll("span").at(1).toPlainText(), QString("there"));
+}
+
+void tst_QWebElement::remove()
+{
+ QString html = "<body>"
+ "<p>"
+ "foo"
+ "</p>"
+ "<div>"
+ "<p>yeah</p>"
+ "</div>"
+ "<p>"
+ "bar"
+ "</p>"
+ "</body>";
+
+ m_mainFrame->setHtml(html);
+ QWebElement body = m_mainFrame->documentElement().findFirst("body");
+
+ QCOMPARE(body.findAll("div").count(), 1);
+ QCOMPARE(body.findAll("p").count(), 3);
+
+ QWebElement div = body.findFirst("div");
+ div.takeFromDocument();
+
+ QCOMPARE(div.isNull(), false);
+ QCOMPARE(body.findAll("div").count(), 0);
+ QCOMPARE(body.findAll("p").count(), 2);
+
+ body.appendInside(div);
+
+ QCOMPARE(body.findAll("div").count(), 1);
+ QCOMPARE(body.findAll("p").count(), 3);
+}
+
+void tst_QWebElement::clear()
+{
+ QString html = "<body>"
+ "<p>"
+ "foo"
+ "</p>"
+ "<div>"
+ "<p>yeah</p>"
+ "</div>"
+ "<p>"
+ "bar"
+ "</p>"
+ "</body>";
+
+ m_mainFrame->setHtml(html);
+ QWebElement body = m_mainFrame->documentElement().findFirst("body");
+
+ QCOMPARE(body.findAll("div").count(), 1);
+ QCOMPARE(body.findAll("p").count(), 3);
+ body.findFirst("div").removeChildren();
+ QCOMPARE(body.findAll("div").count(), 1);
+ QCOMPARE(body.findAll("p").count(), 2);
+}
+
+
+void tst_QWebElement::replaceWith()
+{
+ QString html = "<body>"
+ "<p>"
+ "foo"
+ "</p>"
+ "<div>"
+ "yeah"
+ "</div>"
+ "<p>"
+ "<span>haba</span>"
+ "</p>"
+ "</body>";
+
+ m_mainFrame->setHtml(html);
+ QWebElement body = m_mainFrame->documentElement().findFirst("body");
+
+ QCOMPARE(body.findAll("div").count(), 1);
+ QCOMPARE(body.findAll("span").count(), 1);
+ body.findFirst("div").replace(body.findFirst("span").clone());
+ QCOMPARE(body.findAll("div").count(), 0);
+ QCOMPARE(body.findAll("span").count(), 2);
+ QCOMPARE(body.findAll("p").count(), 2);
+
+ body.findFirst("span").replace("<p><code>wow</code></p>");
+ QCOMPARE(body.findAll("p").count(), 3);
+ QCOMPARE(body.findAll("p code").count(), 1);
+ QCOMPARE(body.findFirst("p code").toPlainText(), QString("wow"));
+}
+
+void tst_QWebElement::encloseContentsWith()
+{
+ QString html = "<body>"
+ "<div>"
+ "<i>"
+ "yeah"
+ "</i>"
+ "<i>"
+ "hello"
+ "</i>"
+ "</div>"
+ "<p>"
+ "<span>foo</span>"
+ "<span>bar</span>"
+ "</p>"
+ "<u></u>"
+ "<b></b>"
+ "<em>hey</em>"
+ "</body>";
+
+ m_mainFrame->setHtml(html);
+ QWebElement body = m_mainFrame->documentElement().findFirst("body");
+
+ body.findFirst("p").encloseContentsWith(body.findFirst("b"));
+ QCOMPARE(body.findAll("p b span").count(), 2);
+ QCOMPARE(body.findFirst("p b span").toPlainText(), QString("foo"));
+
+ body.findFirst("u").encloseContentsWith("<i></i>");
+ QCOMPARE(body.findAll("u i").count(), 1);
+ QCOMPARE(body.findFirst("u i").toPlainText(), QString());
+
+ body.findFirst("div").encloseContentsWith("<span></span>");
+ QCOMPARE(body.findAll("div span i").count(), 2);
+ QCOMPARE(body.findFirst("div span i").toPlainText(), QString("yeah"));
+
+ QString snippet = ""
+ "<table>"
+ "<tbody>"
+ "<tr>"
+ "<td></td>"
+ "<td></td>"
+ "</tr>"
+ "<tr>"
+ "<td></td>"
+ "<td></td>"
+ "<tr>"
+ "</tbody>"
+ "</table>";
+
+ body.findFirst("em").encloseContentsWith(snippet);
+ QCOMPARE(body.findFirst("em table tbody tr td").toPlainText(), QString("hey"));
+}
+
+void tst_QWebElement::encloseWith()
+{
+ QString html = "<body>"
+ "<p>"
+ "foo"
+ "</p>"
+ "<div>"
+ "yeah"
+ "</div>"
+ "<p>"
+ "<span>bar</span>"
+ "</p>"
+ "<em>hey</em>"
+ "<h1>hello</h1>"
+ "</body>";
+
+ m_mainFrame->setHtml(html);
+ QWebElement body = m_mainFrame->documentElement().findFirst("body");
+
+ body.findFirst("p").encloseWith("<br>");
+ QCOMPARE(body.findAll("br").count(), 0);
+
+ QCOMPARE(body.findAll("div").count(), 1);
+ body.findFirst("div").encloseWith(body.findFirst("span").clone());
+ QCOMPARE(body.findAll("div").count(), 1);
+ QCOMPARE(body.findAll("span").count(), 2);
+ QCOMPARE(body.findAll("p").count(), 2);
+
+ body.findFirst("div").encloseWith("<code></code>");
+ QCOMPARE(body.findAll("code").count(), 1);
+ QCOMPARE(body.findAll("code div").count(), 1);
+ QCOMPARE(body.findFirst("code div").toPlainText(), QString("yeah"));
+
+ QString snippet = ""
+ "<table>"
+ "<tbody>"
+ "<tr>"
+ "<td></td>"
+ "<td></td>"
+ "</tr>"
+ "<tr>"
+ "<td></td>"
+ "<td></td>"
+ "<tr>"
+ "</tbody>"
+ "</table>";
+
+ body.findFirst("em").encloseWith(snippet);
+ QCOMPARE(body.findFirst("table tbody tr td em").toPlainText(), QString("hey"));
+}
+
+void tst_QWebElement::nullSelect()
+{
+ m_mainFrame->setHtml("<body><p>Test");
+
+ QList<QWebElement> collection = m_mainFrame->findAllElements("invalid{syn(tax;;%#$f223e>>");
+ QVERIFY(collection.count() == 0);
+}
+
+void tst_QWebElement::firstChildNextSibling()
+{
+ m_mainFrame->setHtml("<body><!--comment--><p>Test</p><!--another commend><table>");
+
+ QWebElement body = m_mainFrame->findFirstElement("body");
+ QVERIFY(!body.isNull());
+ QWebElement p = body.firstChild();
+ QVERIFY(!p.isNull());
+ QCOMPARE(p.tagName(), QString("P"));
+ QWebElement table = p.nextSibling();
+ QVERIFY(!table.isNull());
+ QCOMPARE(table.tagName(), QString("TABLE"));
+ QVERIFY(table.nextSibling().isNull());
+}
+
+void tst_QWebElement::lastChildPreviousSibling()
+{
+ m_mainFrame->setHtml("<body><!--comment--><p>Test</p><!--another commend><table>");
+
+ QWebElement body = m_mainFrame->findFirstElement("body");
+ QVERIFY(!body.isNull());
+ QWebElement table = body.lastChild();
+ QVERIFY(!table.isNull());
+ QCOMPARE(table.tagName(), QString("TABLE"));
+ QWebElement p = table.previousSibling();
+ QVERIFY(!p.isNull());
+ QCOMPARE(p.tagName(), QString("P"));
+ QVERIFY(p.previousSibling().isNull());
+}
+
+QTEST_MAIN(tst_QWebElement)
+#include "tst_qwebelement.moc"
diff --git a/WebKit/qt/tests/qwebframe/qwebframe.qrc b/WebKit/qt/tests/qwebframe/qwebframe.qrc
index 69e62d9..9615e27 100644
--- a/WebKit/qt/tests/qwebframe/qwebframe.qrc
+++ b/WebKit/qt/tests/qwebframe/qwebframe.qrc
@@ -1,5 +1,8 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/">
<file>image.png</file>
+<file>style.css</file>
+<file>test1.html</file>
+<file>test2.html</file>
</qresource>
</RCC>
diff --git a/WebKit/qt/tests/qwebframe/style.css b/WebKit/qt/tests/qwebframe/style.css
new file mode 100644
index 0000000..c05b747
--- /dev/null
+++ b/WebKit/qt/tests/qwebframe/style.css
@@ -0,0 +1 @@
+#idP {color: red !important}
diff --git a/WebKit/qt/tests/qwebframe/test1.html b/WebKit/qt/tests/qwebframe/test1.html
new file mode 100644
index 0000000..b323f96
--- /dev/null
+++ b/WebKit/qt/tests/qwebframe/test1.html
@@ -0,0 +1 @@
+<html><body><p>Some text 1</p></body></html>
diff --git a/WebKit/qt/tests/qwebframe/test2.html b/WebKit/qt/tests/qwebframe/test2.html
new file mode 100644
index 0000000..63ac1f6
--- /dev/null
+++ b/WebKit/qt/tests/qwebframe/test2.html
@@ -0,0 +1 @@
+<html><body> <p>Some text 2</p></body></html>
diff --git a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
index d9c97c8..17dea99 100644
--- a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
+++ b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
@@ -21,6 +21,7 @@
#include <QtTest/QtTest>
#include <qwebpage.h>
+#include <qwebelement.h>
#include <qwidget.h>
#include <qwebview.h>
#include <qwebframe.h>
@@ -28,8 +29,12 @@
#include <QAbstractItemView>
#include <QApplication>
#include <QComboBox>
+#include <QPicture>
#include <QRegExp>
#include <QNetworkRequest>
+#include <QNetworkReply>
+#include <qsslerror.h>
+
//TESTED_CLASS=
//TESTED_FILES=
@@ -570,7 +575,9 @@ private slots:
void typeConversion();
void symmetricUrl();
void progressSignal();
+ void urlChange();
void domCycles();
+ void requestedUrl();
void setHtml();
void setHtmlWithResource();
void ipv6HostEncoding();
@@ -579,6 +586,13 @@ private slots:
void hitTestContent();
void jsByteArray();
void ownership();
+ void nullValue();
+ void baseUrl_data();
+ void baseUrl();
+ void hasSetFocus();
+ void render();
+ void scrollPosition();
+
private:
QString evalJS(const QString&s) {
// Convert an undefined return variant to the string "undefined"
@@ -2125,6 +2139,26 @@ void tst_QWebFrame::progressSignal()
QCOMPARE(progressSpy.last().first().toInt(), 100);
}
+void tst_QWebFrame::urlChange()
+{
+ QSignalSpy urlSpy(m_page->mainFrame(), SIGNAL(urlChanged(QUrl)));
+
+ QUrl dataUrl("data:text/html,<h1>Test");
+ m_view->setUrl(dataUrl);
+
+ ::waitForSignal(m_page->mainFrame(), SIGNAL(urlChanged(QUrl)));
+
+ QCOMPARE(urlSpy.size(), 1);
+
+ QUrl dataUrl2("data:text/html,<html><head><title>title</title></head><body><h1>Test</body></html>");
+ m_view->setUrl(dataUrl2);
+
+ ::waitForSignal(m_page->mainFrame(), SIGNAL(urlChanged(QUrl)));
+
+ QCOMPARE(urlSpy.size(), 2);
+}
+
+
void tst_QWebFrame::domCycles()
{
m_view->setHtml("<html><body>");
@@ -2132,9 +2166,120 @@ void tst_QWebFrame::domCycles()
QVERIFY(v.type() == QVariant::Map);
}
+class FakeReply : public QNetworkReply {
+ Q_OBJECT
+
+public:
+ FakeReply(const QNetworkRequest& request, QObject* parent = 0)
+ : QNetworkReply(parent)
+ {
+ setOperation(QNetworkAccessManager::GetOperation);
+ setRequest(request);
+ if (request.url() == QUrl("qrc:/test1.html")) {
+ setHeader(QNetworkRequest::LocationHeader, QString("qrc:/test2.html"));
+ setAttribute(QNetworkRequest::RedirectionTargetAttribute, QUrl("qrc:/test2.html"));
+ } else if (request.url() == QUrl("qrc:/fake-ssl-error.html"))
+ setError(QNetworkReply::SslHandshakeFailedError, tr("Fake error !")); // force a ssl error
+ else if (request.url() == QUrl("http://abcdef.abcdef/"))
+ setError(QNetworkReply::HostNotFoundError, tr("Invalid URL"));
+
+ open(QIODevice::ReadOnly);
+ QTimer::singleShot(0, this, SLOT(timeout()));
+ }
+ ~FakeReply()
+ {
+ close();
+ }
+ virtual void abort() {}
+ virtual void close() {}
+
+protected:
+ qint64 readData(char*, qint64)
+ {
+ return 0;
+ }
+
+private slots:
+ void timeout()
+ {
+ if (request().url() == QUrl("qrc://test1.html"))
+ emit error(this->error());
+ else if (request().url() == QUrl("http://abcdef.abcdef/"))
+ emit metaDataChanged();
+ else if (request().url() == QUrl("qrc:/fake-ssl-error.html"))
+ return;
+
+ emit readyRead();
+ emit finished();
+ }
+};
+
+class FakeNetworkManager : public QNetworkAccessManager {
+ Q_OBJECT
+
+public:
+ FakeNetworkManager(QObject* parent) : QNetworkAccessManager(parent) { }
+
+protected:
+ virtual QNetworkReply* createRequest(Operation op, const QNetworkRequest& request, QIODevice* outgoingData)
+ {
+ QString url = request.url().toString();
+ if (op == QNetworkAccessManager::GetOperation)
+ if (url == "qrc:/test1.html" || url == "http://abcdef.abcdef/")
+ return new FakeReply(request, this);
+ else if (url == "qrc:/fake-ssl-error.html") {
+ FakeReply* reply = new FakeReply(request, this);
+ QList<QSslError> errors;
+ emit sslErrors(reply, errors << QSslError(QSslError::UnspecifiedError));
+ return reply;
+ }
+
+ return QNetworkAccessManager::createRequest(op, request, outgoingData);
+ }
+};
+
+void tst_QWebFrame::requestedUrl()
+{
+ QWebPage page;
+ QWebFrame* frame = page.mainFrame();
+
+ // in few seconds, the image should be completely loaded
+ QSignalSpy spy(&page, SIGNAL(loadFinished(bool)));
+ FakeNetworkManager* networkManager = new FakeNetworkManager(&page);
+ page.setNetworkAccessManager(networkManager);
+
+ frame->setUrl(QUrl("qrc:/test1.html"));
+ QTest::qWait(200);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(frame->requestedUrl(), QUrl("qrc:/test1.html"));
+ QCOMPARE(frame->url(), QUrl("qrc:/test2.html"));
+
+ frame->setUrl(QUrl("qrc:/non-existent.html"));
+ QTest::qWait(200);
+ QCOMPARE(spy.count(), 2);
+ QCOMPARE(frame->requestedUrl(), QUrl("qrc:/non-existent.html"));
+ QCOMPARE(frame->url(), QUrl("qrc:/non-existent.html"));
+
+ frame->setUrl(QUrl("http://abcdef.abcdef"));
+ QTest::qWait(200);
+ QCOMPARE(spy.count(), 3);
+ QCOMPARE(frame->requestedUrl(), QUrl("http://abcdef.abcdef/"));
+ QCOMPARE(frame->url(), QUrl("http://abcdef.abcdef/"));
+
+ qRegisterMetaType<QList<QSslError> >("QList<QSslError>");
+ qRegisterMetaType<QNetworkReply* >("QNetworkReply*");
+
+ QSignalSpy spy2(page.networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)));
+ frame->setUrl(QUrl("qrc:/fake-ssl-error.html"));
+ QTest::qWait(200);
+ QCOMPARE(spy2.count(), 1);
+ QCOMPARE(frame->requestedUrl(), QUrl("qrc:/fake-ssl-error.html"));
+ QCOMPARE(frame->url(), QUrl("qrc:/fake-ssl-error.html"));
+}
+
void tst_QWebFrame::setHtml()
{
- QString html("<html><body><p>hello world</p></body></html>");
+ QString html("<html><head></head><body><p>hello world</p></body></html>");
m_view->page()->mainFrame()->setHtml(html);
QCOMPARE(m_view->page()->mainFrame()->toHtml(), html);
}
@@ -2155,6 +2300,24 @@ void tst_QWebFrame::setHtmlWithResource()
QCOMPARE(frame->evaluateJavaScript("document.images.length").toInt(), 1);
QCOMPARE(frame->evaluateJavaScript("document.images[0].width").toInt(), 128);
QCOMPARE(frame->evaluateJavaScript("document.images[0].height").toInt(), 128);
+
+ QString html2 =
+ "<html>"
+ "<head>"
+ "<link rel='stylesheet' href='qrc:/style.css' type='text/css' />"
+ "</head>"
+ "<body>"
+ "<p id='idP'>some text</p>"
+ "</body>"
+ "</html>";
+
+ // in few seconds, the CSS should be completey loaded
+ frame->setHtml(html2);
+ QTest::qWait(200);
+ QCOMPARE(spy.size(), 2);
+
+ QWebElement p = frame->documentElement().findAll("p").at(0);
+ QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("red"));
}
class TestNetworkManager : public QNetworkAccessManager
@@ -2285,7 +2448,8 @@ void tst_QWebFrame::hitTestContent()
page.setViewportSize(QSize(200, 0)); //no height so link is not visible
QWebHitTestResult result = frame->hitTestContent(QPoint(10, 100));
QCOMPARE(result.linkText(), QString("link text"));
- QCOMPARE(result.linkTarget(), QString("_foo"));
+ QWebElement link = result.linkElement();
+ QCOMPARE(link.attribute("target"), QString("_foo"));
}
void tst_QWebFrame::jsByteArray()
@@ -2365,5 +2529,145 @@ void tst_QWebFrame::ownership()
}
}
+void tst_QWebFrame::nullValue()
+{
+ QVariant v = m_view->page()->mainFrame()->evaluateJavaScript("null");
+ QVERIFY(v.isNull());
+}
+
+void tst_QWebFrame::baseUrl_data()
+{
+ QTest::addColumn<QString>("html");
+ QTest::addColumn<QUrl>("loadUrl");
+ QTest::addColumn<QUrl>("url");
+ QTest::addColumn<QUrl>("baseUrl");
+
+ QTest::newRow("null") << QString() << QUrl()
+ << QUrl("about:blank") << QUrl("about:blank");
+
+ QTest::newRow("foo") << QString() << QUrl("http://foobar.baz/")
+ << QUrl("http://foobar.baz/") << QUrl("http://foobar.baz/");
+
+ QString html = "<html>"
+ "<head>"
+ "<base href=\"http://foobaz.bar/\" />"
+ "</head>"
+ "</html>";
+ QTest::newRow("customBaseUrl") << html << QUrl("http://foobar.baz/")
+ << QUrl("http://foobar.baz/") << QUrl("http://foobaz.bar/");
+}
+
+void tst_QWebFrame::baseUrl()
+{
+ QFETCH(QString, html);
+ QFETCH(QUrl, loadUrl);
+ QFETCH(QUrl, url);
+ QFETCH(QUrl, baseUrl);
+
+ m_page->mainFrame()->setHtml(html, loadUrl);
+ QCOMPARE(m_page->mainFrame()->url(), url);
+ QCOMPARE(m_page->mainFrame()->baseUrl(), baseUrl);
+}
+
+void tst_QWebFrame::hasSetFocus()
+{
+ QString html("<html><body><p>top</p>" \
+ "<iframe width='80%' height='30%'/>" \
+ "</body></html>");
+
+ QSignalSpy loadSpy(m_page, SIGNAL(loadFinished(bool)));
+ m_page->mainFrame()->setHtml(html);
+
+ QTest::qWait(200);
+ QCOMPARE(loadSpy.size(), 1);
+
+ QList<QWebFrame*> children = m_page->mainFrame()->childFrames();
+ QWebFrame* frame = children.at(0);
+ QString innerHtml("<html><body><p>another iframe</p>" \
+ "<iframe width='80%' height='30%'/>" \
+ "</body></html>");
+ frame->setHtml(innerHtml);
+
+ QTest::qWait(200);
+ QCOMPARE(loadSpy.size(), 2);
+
+ m_page->mainFrame()->setFocus();
+ QVERIFY(m_page->mainFrame()->hasFocus());
+
+ for (int i = 0; i < children.size(); ++i) {
+ children.at(i)->setFocus();
+ QVERIFY(children.at(i)->hasFocus());
+ QVERIFY(!m_page->mainFrame()->hasFocus());
+ }
+
+ m_page->mainFrame()->setFocus();
+ QVERIFY(m_page->mainFrame()->hasFocus());
+}
+
+void tst_QWebFrame::render()
+{
+ QString html("<html>" \
+ "<head><style>" \
+ "body, iframe { margin: 0px; border: none; }" \
+ "</style></head>" \
+ "<body><iframe width='100px' height='100px'/></body>" \
+ "</html>");
+
+ QWebPage page;
+ page.mainFrame()->setHtml(html);
+
+ QList<QWebFrame*> frames = page.mainFrame()->childFrames();
+ QWebFrame *frame = frames.at(0);
+ QString innerHtml("<body style='margin: 0px;'><img src='qrc:/image.png'/></body>");
+ frame->setHtml(innerHtml);
+
+ QPicture picture;
+
+ // render clipping to Viewport
+ frame->setClipRenderToViewport(true);
+ QPainter painter1(&picture);
+ frame->render(&painter1);
+ painter1.end();
+
+ QSize size = page.mainFrame()->contentsSize();
+ page.setViewportSize(size);
+ QCOMPARE(size.width(), picture.boundingRect().width()); // 100px
+ QCOMPARE(size.height(), picture.boundingRect().height()); // 100px
+
+ // render without clipping to Viewport
+ frame->setClipRenderToViewport(false);
+ QPainter painter2(&picture);
+ frame->render(&painter2);
+ painter2.end();
+
+ QImage resource(":/image.png");
+ QCOMPARE(resource.width(), picture.boundingRect().width()); // resource width: 128px
+ QCOMPARE(resource.height(), picture.boundingRect().height()); // resource height: 128px
+}
+
+void tst_QWebFrame::scrollPosition()
+{
+ // enlarged image in a small viewport, to provoke the scrollbars to appear
+ QString html("<html><body><img src='qrc:/image.png' height=500 width=500/></body></html>");
+
+ QWebPage page;
+ page.setViewportSize(QSize(200, 200));
+
+ QWebFrame* frame = page.mainFrame();
+ frame->setHtml(html);
+ frame->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
+ frame->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
+
+ // try to set the scroll offset programmatically
+ frame->setScrollPosition(QPoint(23, 29));
+ QCOMPARE(frame->scrollPosition().x(), 23);
+ QCOMPARE(frame->scrollPosition().y(), 29);
+
+ int x = frame->evaluateJavaScript("window.scrollX").toInt();
+ int y = frame->evaluateJavaScript("window.scrollY").toInt();
+ QCOMPARE(x, 23);
+ QCOMPARE(y, 29);
+}
+
QTEST_MAIN(tst_QWebFrame)
#include "tst_qwebframe.moc"
diff --git a/WebKit/qt/tests/qwebhistory/data/page1.html b/WebKit/qt/tests/qwebhistory/data/page1.html
new file mode 100644
index 0000000..82fa4af
--- /dev/null
+++ b/WebKit/qt/tests/qwebhistory/data/page1.html
@@ -0,0 +1 @@
+<title>page1</title><body><h1>page1</h1></body>
diff --git a/WebKit/qt/tests/qwebhistory/data/page2.html b/WebKit/qt/tests/qwebhistory/data/page2.html
new file mode 100644
index 0000000..5307bdc
--- /dev/null
+++ b/WebKit/qt/tests/qwebhistory/data/page2.html
@@ -0,0 +1 @@
+<title>page2</title><body><h1>page2</h1></body>
diff --git a/WebKit/qt/tests/qwebhistory/data/page3.html b/WebKit/qt/tests/qwebhistory/data/page3.html
new file mode 100644
index 0000000..4e5547c
--- /dev/null
+++ b/WebKit/qt/tests/qwebhistory/data/page3.html
@@ -0,0 +1 @@
+<title>page3</title><body><h1>page3</h1></body>
diff --git a/WebKit/qt/tests/qwebhistory/data/page4.html b/WebKit/qt/tests/qwebhistory/data/page4.html
new file mode 100644
index 0000000..3c57aed
--- /dev/null
+++ b/WebKit/qt/tests/qwebhistory/data/page4.html
@@ -0,0 +1 @@
+<title>page4</title><body><h1>page4</h1></body>
diff --git a/WebKit/qt/tests/qwebhistory/data/page5.html b/WebKit/qt/tests/qwebhistory/data/page5.html
new file mode 100644
index 0000000..8593552
--- /dev/null
+++ b/WebKit/qt/tests/qwebhistory/data/page5.html
@@ -0,0 +1 @@
+<title>page5</title><body><h1>page5</h1></body>
diff --git a/WebKit/qt/tests/qwebhistory/data/page6.html b/WebKit/qt/tests/qwebhistory/data/page6.html
new file mode 100644
index 0000000..c5bbc6f
--- /dev/null
+++ b/WebKit/qt/tests/qwebhistory/data/page6.html
@@ -0,0 +1 @@
+<title>page6</title><body><h1>page6</h1></body>
diff --git a/WebKit/qt/tests/qwebhistory/qwebhistory.pro b/WebKit/qt/tests/qwebhistory/qwebhistory.pro
new file mode 100644
index 0000000..fd1074c
--- /dev/null
+++ b/WebKit/qt/tests/qwebhistory/qwebhistory.pro
@@ -0,0 +1,7 @@
+TEMPLATE = app
+TARGET = tst_qwebhistory
+include(../../../../WebKit.pri)
+SOURCES += tst_qwebhistory.cpp
+RESOURCES += tst_qwebhistory.qrc
+QT += testlib network
+QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
diff --git a/WebKit/qt/tests/qwebhistory/tst_qwebhistory.cpp b/WebKit/qt/tests/qwebhistory/tst_qwebhistory.cpp
new file mode 100644
index 0000000..5b55613
--- /dev/null
+++ b/WebKit/qt/tests/qwebhistory/tst_qwebhistory.cpp
@@ -0,0 +1,326 @@
+/*
+ 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
+ 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 "qwebview.h"
+#include "qwebframe.h"
+#include "qwebhistory.h"
+#include "qdebug.h"
+
+class tst_QWebHistory : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QWebHistory();
+ virtual ~tst_QWebHistory();
+
+protected :
+ void loadPage(int nr)
+ {
+ frame->load(QUrl("qrc:/data/page" + QString::number(nr) + ".html"));
+ waitForLoadFinished.exec();
+ }
+
+public slots:
+ void init();
+ void cleanup();
+
+private slots:
+ void title();
+ void count();
+ void back();
+ void forward();
+ void itemAt();
+ void goToItem();
+ void items();
+ void serialize_1(); //QWebHistory countity
+ void serialize_2(); //QWebHistory index
+ void serialize_3(); //QWebHistoryItem
+ void saveAndRestore_1(); //simple checks saveState and restoreState
+ void saveAndRestore_2(); //bad parameters saveState and restoreState
+ void saveAndRestore_3(); //try use different version
+
+private:
+ QWebPage* page;
+ QWebFrame* frame;
+ QWebHistory* hist;
+ QEventLoop waitForLoadFinished; //operation on history are asynchronous!
+ int histsize;
+};
+
+tst_QWebHistory::tst_QWebHistory()
+{
+}
+
+tst_QWebHistory::~tst_QWebHistory()
+{
+}
+
+void tst_QWebHistory::init()
+{
+ page = new QWebPage(this);
+ frame = page->mainFrame();
+ connect(page, SIGNAL(loadFinished(bool)), &waitForLoadFinished, SLOT(quit()));
+
+ for (int i = 1;i < 6;i++) {
+ loadPage(i);
+ }
+ hist = page->history();
+ histsize = 5;
+}
+
+void tst_QWebHistory::cleanup()
+{
+ delete page;
+}
+
+/**
+ * Check QWebHistoryItem::title() method
+ */
+void tst_QWebHistory::title()
+{
+ QCOMPARE(hist->currentItem().title(), QString("page5"));
+}
+
+/**
+ * Check QWebHistory::count() method
+ */
+void tst_QWebHistory::count()
+{
+ QCOMPARE(hist->count(), histsize);
+}
+
+/**
+ * Check QWebHistory::back() method
+ */
+void tst_QWebHistory::back()
+{
+ for (int i = histsize;i > 1;i--) {
+ QCOMPARE(page->mainFrame()->toPlainText(), QString("page") + QString::number(i));
+ hist->back();
+ waitForLoadFinished.exec();
+ }
+}
+
+/**
+ * Check QWebHistory::forward() method
+ */
+void tst_QWebHistory::forward()
+{
+ //rewind history :-)
+ while (hist->canGoBack()) {
+ hist->back();
+ waitForLoadFinished.exec();
+ }
+
+ for (int i = 1;i < histsize;i++) {
+ QCOMPARE(page->mainFrame()->toPlainText(), QString("page") + QString::number(i));
+ hist->forward();
+ waitForLoadFinished.exec();
+ }
+}
+
+/**
+ * Check QWebHistory::itemAt() method
+ */
+void tst_QWebHistory::itemAt()
+{
+ for (int i = 1;i < histsize;i++) {
+ QCOMPARE(hist->itemAt(i - 1).title(), QString("page") + QString::number(i));
+ QVERIFY(hist->itemAt(i - 1).isValid());
+ }
+ //check out of range values
+ QVERIFY(!hist->itemAt(-1).isValid());
+ QVERIFY(!hist->itemAt(histsize).isValid());
+}
+
+/**
+ * Check QWebHistory::goToItem() method
+ */
+void tst_QWebHistory::goToItem()
+{
+ QWebHistoryItem current = hist->currentItem();
+ hist->back();
+ waitForLoadFinished.exec();
+ hist->back();
+ waitForLoadFinished.exec();
+ QVERIFY(hist->currentItem().title() != current.title());
+ hist->goToItem(current);
+ waitForLoadFinished.exec();
+ QCOMPARE(hist->currentItem().title(), current.title());
+}
+
+/**
+ * Check QWebHistory::items() method
+ */
+void tst_QWebHistory::items()
+{
+ QList<QWebHistoryItem> items = hist->items();
+ //check count
+ QCOMPARE(histsize, items.count());
+
+ //check order
+ for (int i = 1;i <= histsize;i++) {
+ QCOMPARE(items.at(i - 1).title(), QString("page") + QString::number(i));
+ }
+}
+
+/**
+ * Check history state after serialization (pickle, persistent..) method
+ * Checks history size, history order
+ */
+void tst_QWebHistory::serialize_1()
+{
+ QByteArray tmp; //buffer
+ QDataStream save(&tmp, QIODevice::WriteOnly); //here data will be saved
+ QDataStream load(&tmp, QIODevice::ReadOnly); //from here data will be loaded
+
+ save << *hist;
+ QVERIFY(save.status() == QDataStream::Ok);
+ QCOMPARE(hist->count(), histsize);
+
+ //check size of history
+ //load next page to find differences
+ loadPage(6);
+ QCOMPARE(hist->count(), histsize + 1);
+ load >> *hist;
+ QVERIFY(load.status() == QDataStream::Ok);
+ QCOMPARE(hist->count(), histsize);
+
+ //check order of historyItems
+ QList<QWebHistoryItem> items = hist->items();
+ for (int i = 1;i <= histsize;i++) {
+ QCOMPARE(items.at(i - 1).title(), QString("page") + QString::number(i));
+ }
+}
+
+/**
+ * Check history state after serialization (pickle, persistent..) method
+ * Checks history currentIndex value
+ */
+void tst_QWebHistory::serialize_2()
+{
+ QByteArray tmp; //buffer
+ QDataStream save(&tmp, QIODevice::WriteOnly); //here data will be saved
+ QDataStream load(&tmp, QIODevice::ReadOnly); //from here data will be loaded
+
+ int oldCurrentIndex = hist->currentItemIndex();
+
+ hist->back();
+ waitForLoadFinished.exec();
+ hist->back();
+ waitForLoadFinished.exec();
+ //check if current index was changed (make sure that it is not last item)
+ QVERIFY(hist->currentItemIndex() != oldCurrentIndex);
+ //save current index
+ oldCurrentIndex = hist->currentItemIndex();
+
+ save << *hist;
+ QVERIFY(save.status() == QDataStream::Ok);
+ load >> *hist;
+ QVERIFY(load.status() == QDataStream::Ok);
+
+ //check current index
+ QCOMPARE(hist->currentItemIndex(), oldCurrentIndex);
+}
+
+/**
+ * Check history state after serialization (pickle, persistent..) method
+ * Checks QWebHistoryItem public property after serialization
+ */
+void tst_QWebHistory::serialize_3()
+{
+ QByteArray tmp; //buffer
+ QDataStream save(&tmp, QIODevice::WriteOnly); //here data will be saved
+ QDataStream load(&tmp, QIODevice::ReadOnly); //from here data will be loaded
+
+ //prepare two different history items
+ QWebHistoryItem a = hist->currentItem();
+ a.setUserData("A - user data");
+
+ //check properties BEFORE serialization
+ QString title(a.title());
+ QDateTime lastVisited(a.lastVisited());
+ QUrl originalUrl(a.originalUrl());
+ QUrl url(a.url());
+ QVariant userData(a.userData());
+
+ save << *hist;
+ QVERIFY(save.status() == QDataStream::Ok);
+ QVERIFY(!load.atEnd());
+ hist->clear();
+ QVERIFY(hist->count() == 1);
+ load >> *hist;
+ QVERIFY(load.status() == QDataStream::Ok);
+ QWebHistoryItem b = hist->currentItem();
+
+ //check properties AFTER serialization
+ QCOMPARE(b.title(), title);
+ QCOMPARE(b.lastVisited(), lastVisited);
+ QCOMPARE(b.originalUrl(), originalUrl);
+ QCOMPARE(b.url(), url);
+ QCOMPARE(b.userData(), userData);
+
+ //Check if all data was read
+ QVERIFY(load.atEnd());
+}
+
+/** Simple checks should be a bit redundant to streaming operators */
+void tst_QWebHistory::saveAndRestore_1()
+{
+ hist->back();
+ waitForLoadFinished.exec();
+ QByteArray buffer(hist->saveState());
+ hist->clear();
+ QVERIFY(hist->count() == 1);
+ hist->restoreState(buffer);
+
+ //check only few values, do not make full test
+ //because most of the code is shared with streaming operators
+ //and these are checked before
+ QCOMPARE(hist->count(), histsize);
+ QCOMPARE(hist->currentItemIndex(), histsize - 2);
+ QCOMPARE(hist->itemAt(0).title(), QString("page1"));
+ QCOMPARE(hist->itemAt(histsize - 1).title(), QString("page") + QString::number(histsize));
+}
+
+/** Check returns value if there are bad parameters. Actually, result
+ * is no so importent. The test shouldn't crash :-) */
+void tst_QWebHistory::saveAndRestore_2()
+{
+ QByteArray buffer;
+ hist->restoreState(buffer);
+ QVERIFY(hist->count() == 1);
+ QVERIFY(hist->itemAt(0).isValid());
+}
+
+/** Try to use bad version value */
+void tst_QWebHistory::saveAndRestore_3()
+{
+ QByteArray tmp = hist->saveState((QWebHistory::HistoryStateVersion)29999);
+ QVERIFY(hist->saveState((QWebHistory::HistoryStateVersion)29999).isEmpty());
+ QVERIFY(hist->count() == histsize);
+ QVERIFY(hist->itemAt(3).isValid());
+}
+
+QTEST_MAIN(tst_QWebHistory)
+#include "tst_qwebhistory.moc"
diff --git a/WebKit/qt/tests/qwebhistory/tst_qwebhistory.qrc b/WebKit/qt/tests/qwebhistory/tst_qwebhistory.qrc
new file mode 100644
index 0000000..7c5ff0e
--- /dev/null
+++ b/WebKit/qt/tests/qwebhistory/tst_qwebhistory.qrc
@@ -0,0 +1,11 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>data/page1.html</file>
+ <file>data/page2.html</file>
+ <file>data/page3.html</file>
+ <file>data/page4.html</file>
+ <file>data/page5.html</file>
+ <file>data/page6.html</file>
+</qresource>
+</RCC>
+
diff --git a/WebKit/qt/tests/qwebhistoryinterface/qwebhistoryinterface.pro b/WebKit/qt/tests/qwebhistoryinterface/qwebhistoryinterface.pro
new file mode 100644
index 0000000..af3b348
--- /dev/null
+++ b/WebKit/qt/tests/qwebhistoryinterface/qwebhistoryinterface.pro
@@ -0,0 +1,6 @@
+TEMPLATE = app
+TARGET = tst_qwebhistoryinterface
+include(../../../../WebKit.pri)
+SOURCES += tst_qwebhistoryinterface.cpp
+QT += testlib network
+QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
diff --git a/WebKit/qt/tests/qwebhistoryinterface/tst_qwebhistoryinterface.cpp b/WebKit/qt/tests/qwebhistoryinterface/tst_qwebhistoryinterface.cpp
new file mode 100644
index 0000000..435cada
--- /dev/null
+++ b/WebKit/qt/tests/qwebhistoryinterface/tst_qwebhistoryinterface.cpp
@@ -0,0 +1,94 @@
+/*
+ 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
+ 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 <qwebview.h>
+#include <qwebframe.h>
+#include <qwebhistoryinterface.h>
+#include <QDebug>
+
+class tst_QWebHistoryInterface : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QWebHistoryInterface();
+ virtual ~tst_QWebHistoryInterface();
+
+public slots:
+ void init();
+ void cleanup();
+
+private slots:
+ void visitedLinks();
+
+private:
+
+
+private:
+ QWebView* m_view;
+ QWebPage* m_page;
+};
+
+tst_QWebHistoryInterface::tst_QWebHistoryInterface()
+{
+}
+
+tst_QWebHistoryInterface::~tst_QWebHistoryInterface()
+{
+}
+
+void tst_QWebHistoryInterface::init()
+{
+ m_view = new QWebView();
+ m_page = m_view->page();
+}
+
+void tst_QWebHistoryInterface::cleanup()
+{
+ delete m_view;
+}
+
+class FakeHistoryImplementation : public QWebHistoryInterface {
+public:
+ void addHistoryEntry(const QString&) {}
+ bool historyContains(const QString& url) const {
+ return url == QLatin1String("http://www.trolltech.com/");
+ }
+};
+
+
+/*
+ * Test that visited links are properly colored. http://www.trolltech.com is marked
+ * as visited, so the below website should have exactly one element in the a:visited
+ * state.
+ */
+void tst_QWebHistoryInterface::visitedLinks()
+{
+ QWebHistoryInterface::setDefaultInterface(new FakeHistoryImplementation);
+ m_view->setHtml("<html><body><a href='http://www.trolltech.com'>Trolltech</a></body></html>");
+ QCOMPARE(m_page->mainFrame()->evaluateJavaScript("document.querySelectorAll(':visited').length;").toString(),
+ QString::fromLatin1("1"));
+}
+
+QTEST_MAIN(tst_QWebHistoryInterface)
+#include "tst_qwebhistoryinterface.moc"
diff --git a/WebKit/qt/tests/qwebpage/frametest/frame_a.html b/WebKit/qt/tests/qwebpage/frametest/frame_a.html
new file mode 100644
index 0000000..9ff68f1
--- /dev/null
+++ b/WebKit/qt/tests/qwebpage/frametest/frame_a.html
@@ -0,0 +1,2 @@
+<a href="http://google.com" target="frame_b"><img src="" width=100 height=100 alt="Google"></a>
+<a href="http://yahoo.com" target="frame_b"><img src="" width=100 height=100 alt="Yahoo"></a>
diff --git a/WebKit/qt/tests/qwebpage/frametest/iframe.html b/WebKit/qt/tests/qwebpage/frametest/iframe.html
new file mode 100644
index 0000000..f17027c
--- /dev/null
+++ b/WebKit/qt/tests/qwebpage/frametest/iframe.html
@@ -0,0 +1,6 @@
+<html>
+<body>
+<p>top</p>
+<iframe src="iframe2.html" width="80%" height="30%"/>
+</body>
+</html>
diff --git a/WebKit/qt/tests/qwebpage/frametest/iframe2.html b/WebKit/qt/tests/qwebpage/frametest/iframe2.html
new file mode 100644
index 0000000..5017435
--- /dev/null
+++ b/WebKit/qt/tests/qwebpage/frametest/iframe2.html
@@ -0,0 +1,7 @@
+<html>
+<body>
+<p>another iframe</p>
+<iframe src="iframe3.html" width="80%" height="30%"></iframe>
+</body>
+</html>
+
diff --git a/WebKit/qt/tests/qwebpage/frametest/iframe3.html b/WebKit/qt/tests/qwebpage/frametest/iframe3.html
new file mode 100644
index 0000000..ed6ac5b
--- /dev/null
+++ b/WebKit/qt/tests/qwebpage/frametest/iframe3.html
@@ -0,0 +1,5 @@
+<html>
+<body>
+<p>inner</p>
+</body>
+</html>
diff --git a/WebKit/qt/tests/qwebpage/frametest/index.html b/WebKit/qt/tests/qwebpage/frametest/index.html
new file mode 100644
index 0000000..c53ad09
--- /dev/null
+++ b/WebKit/qt/tests/qwebpage/frametest/index.html
@@ -0,0 +1,4 @@
+<frameset cols="25%,75%">
+ <frame src="frame_a.html" name="frame_a">
+ <frame src="frame_b.html" name="frame_b">
+</frameset>
diff --git a/WebKit/qt/tests/qwebpage/qwebpage.pro b/WebKit/qt/tests/qwebpage/qwebpage.pro
index bbd98c6..2f3a108 100644
--- a/WebKit/qt/tests/qwebpage/qwebpage.pro
+++ b/WebKit/qt/tests/qwebpage/qwebpage.pro
@@ -2,5 +2,6 @@ TEMPLATE = app
TARGET = tst_qwebpage
include(../../../../WebKit.pri)
SOURCES += tst_qwebpage.cpp
+RESOURCES += tst_qwebpage.qrc
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
index d85e880..966f049 100644
--- a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
+++ b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
@@ -92,6 +92,7 @@ private slots:
void cleanupTestCase();
void acceptNavigationRequest();
+ void infiniteLoopJS();
void loadFinished();
void acceptNavigationRequestWithNewWindow();
void userStyleSheet();
@@ -105,6 +106,10 @@ private slots:
void cursorMovements();
void textSelection();
void textEditing();
+ void backActionUpdate();
+ void frameAt();
+ void requestCache();
+ void protectBindingsRuntimeObjectsFromCollector();
private:
@@ -189,6 +194,26 @@ void tst_QWebPage::acceptNavigationRequest()
m_view->setPage(0);
}
+class JSTestPage : public QWebPage
+{
+Q_OBJECT
+public:
+ JSTestPage(QObject* parent = 0)
+ : QWebPage(parent) {}
+
+public slots:
+ bool shouldInterruptJavaScript() {
+ return true;
+ }
+};
+
+void tst_QWebPage::infiniteLoopJS()
+{
+ JSTestPage* newPage = new JSTestPage(m_view);
+ m_view->setPage(newPage);
+ m_view->setHtml(QString("<html><bodytest</body></html>"), QUrl());
+ m_view->page()->mainFrame()->evaluateJavaScript("var run = true;var a = 1;while(run){a++;}");
+}
void tst_QWebPage::loadFinished()
{
@@ -832,7 +857,7 @@ void tst_QWebPage::cursorMovements()
// cursor will be before the word "be"
page->triggerAction(QWebPage::MoveToStartOfBlock);
QVERIFY(page->isSelectionCollapsed());
- QCOMPARE(page->selectionStartOffset(), 2);
+ QCOMPARE(page->selectionStartOffset(), 0);
// cursor will be after the word "you!"
page->triggerAction(QWebPage::MoveToEndOfBlock);
@@ -870,14 +895,6 @@ void tst_QWebPage::textSelection()
"<p>May the source<br/>be with you!</p></body></html>");
page->mainFrame()->setHtml(content);
- // this will select the first paragraph
- QString script = "var range = document.createRange(); " \
- "var node = document.getElementById(\"one\"); " \
- "range.selectNode(node); " \
- "getSelection().addRange(range);";
- page->mainFrame()->evaluateJavaScript(script);
- QCOMPARE(page->selectedText().trimmed(), QString::fromLatin1("The quick brown fox"));
-
// these actions must exist
QVERIFY(page->action(QWebPage::SelectAll) != 0);
QVERIFY(page->action(QWebPage::SelectNextChar) != 0);
@@ -893,7 +910,8 @@ void tst_QWebPage::textSelection()
QVERIFY(page->action(QWebPage::SelectStartOfDocument) != 0);
QVERIFY(page->action(QWebPage::SelectEndOfDocument) != 0);
- // right now they are disabled because contentEditable is false
+ // right now they are disabled because contentEditable is false and
+ // there isn't an existing selection to modify
QCOMPARE(page->action(QWebPage::SelectNextChar)->isEnabled(), false);
QCOMPARE(page->action(QWebPage::SelectPreviousChar)->isEnabled(), false);
QCOMPARE(page->action(QWebPage::SelectNextWord)->isEnabled(), false);
@@ -910,11 +928,37 @@ void tst_QWebPage::textSelection()
// ..but SelectAll is awalys enabled
QCOMPARE(page->action(QWebPage::SelectAll)->isEnabled(), true);
+ // this will select the first paragraph
+ QString selectScript = "var range = document.createRange(); " \
+ "var node = document.getElementById(\"one\"); " \
+ "range.selectNode(node); " \
+ "getSelection().addRange(range);";
+ page->mainFrame()->evaluateJavaScript(selectScript);
+ QCOMPARE(page->selectedText().trimmed(), QString::fromLatin1("The quick brown fox"));
+
+ // here the actions are enabled after a selection has been created
+ QCOMPARE(page->action(QWebPage::SelectNextChar)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::SelectPreviousChar)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::SelectNextWord)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::SelectPreviousWord)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::SelectNextLine)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::SelectPreviousLine)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::SelectStartOfLine)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::SelectEndOfLine)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::SelectStartOfBlock)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::SelectEndOfBlock)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::SelectStartOfDocument)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::SelectEndOfDocument)->isEnabled(), true);
+
// make it editable before navigating the cursor
page->setContentEditable(true);
+ // cursor will be before the word "The", this makes sure there is a charet
+ page->triggerAction(QWebPage::MoveToStartOfDocument);
+ QVERIFY(page->isSelectionCollapsed());
+ QCOMPARE(page->selectionStartOffset(), 0);
+
// here the actions are enabled after contentEditable is true
- QCOMPARE(page->action(QWebPage::SelectAll)->isEnabled(), true);
QCOMPARE(page->action(QWebPage::SelectNextChar)->isEnabled(), true);
QCOMPARE(page->action(QWebPage::SelectPreviousChar)->isEnabled(), true);
QCOMPARE(page->action(QWebPage::SelectNextWord)->isEnabled(), true);
@@ -939,15 +983,10 @@ void tst_QWebPage::textEditing()
"<p>May the source<br/>be with you!</p></body></html>");
page->mainFrame()->setHtml(content);
- // this will select the first paragraph
- QString script = "var range = document.createRange(); " \
- "var node = document.getElementById(\"one\"); " \
- "range.selectNode(node); " \
- "getSelection().addRange(range);";
- page->mainFrame()->evaluateJavaScript(script);
- QCOMPARE(page->selectedText().trimmed(), QString::fromLatin1("The quick brown fox"));
-
// these actions must exist
+ QVERIFY(page->action(QWebPage::Cut) != 0);
+ QVERIFY(page->action(QWebPage::Copy) != 0);
+ QVERIFY(page->action(QWebPage::Paste) != 0);
QVERIFY(page->action(QWebPage::DeleteStartOfWord) != 0);
QVERIFY(page->action(QWebPage::DeleteEndOfWord) != 0);
QVERIFY(page->action(QWebPage::SetTextDirectionDefault) != 0);
@@ -958,8 +997,23 @@ void tst_QWebPage::textEditing()
QVERIFY(page->action(QWebPage::ToggleUnderline) != 0);
QVERIFY(page->action(QWebPage::InsertParagraphSeparator) != 0);
QVERIFY(page->action(QWebPage::InsertLineSeparator) != 0);
+ QVERIFY(page->action(QWebPage::PasteAndMatchStyle) != 0);
+ QVERIFY(page->action(QWebPage::RemoveFormat) != 0);
+ QVERIFY(page->action(QWebPage::ToggleStrikethrough) != 0);
+ QVERIFY(page->action(QWebPage::ToggleSubscript) != 0);
+ QVERIFY(page->action(QWebPage::ToggleSuperscript) != 0);
+ QVERIFY(page->action(QWebPage::InsertUnorderedList) != 0);
+ QVERIFY(page->action(QWebPage::InsertOrderedList) != 0);
+ QVERIFY(page->action(QWebPage::Indent) != 0);
+ QVERIFY(page->action(QWebPage::Outdent) != 0);
+ QVERIFY(page->action(QWebPage::AlignCenter) != 0);
+ QVERIFY(page->action(QWebPage::AlignJustified) != 0);
+ QVERIFY(page->action(QWebPage::AlignLeft) != 0);
+ QVERIFY(page->action(QWebPage::AlignRight) != 0);
// right now they are disabled because contentEditable is false
+ QCOMPARE(page->action(QWebPage::Cut)->isEnabled(), false);
+ QCOMPARE(page->action(QWebPage::Paste)->isEnabled(), false);
QCOMPARE(page->action(QWebPage::DeleteStartOfWord)->isEnabled(), false);
QCOMPARE(page->action(QWebPage::DeleteEndOfWord)->isEnabled(), false);
QCOMPARE(page->action(QWebPage::SetTextDirectionDefault)->isEnabled(), false);
@@ -970,11 +1024,39 @@ void tst_QWebPage::textEditing()
QCOMPARE(page->action(QWebPage::ToggleUnderline)->isEnabled(), false);
QCOMPARE(page->action(QWebPage::InsertParagraphSeparator)->isEnabled(), false);
QCOMPARE(page->action(QWebPage::InsertLineSeparator)->isEnabled(), false);
+ QCOMPARE(page->action(QWebPage::PasteAndMatchStyle)->isEnabled(), false);
+ QCOMPARE(page->action(QWebPage::RemoveFormat)->isEnabled(), false);
+ QCOMPARE(page->action(QWebPage::ToggleStrikethrough)->isEnabled(), false);
+ QCOMPARE(page->action(QWebPage::ToggleSubscript)->isEnabled(), false);
+ QCOMPARE(page->action(QWebPage::ToggleSuperscript)->isEnabled(), false);
+ QCOMPARE(page->action(QWebPage::InsertUnorderedList)->isEnabled(), false);
+ QCOMPARE(page->action(QWebPage::InsertOrderedList)->isEnabled(), false);
+ QCOMPARE(page->action(QWebPage::Indent)->isEnabled(), false);
+ QCOMPARE(page->action(QWebPage::Outdent)->isEnabled(), false);
+ QCOMPARE(page->action(QWebPage::AlignCenter)->isEnabled(), false);
+ QCOMPARE(page->action(QWebPage::AlignJustified)->isEnabled(), false);
+ QCOMPARE(page->action(QWebPage::AlignLeft)->isEnabled(), false);
+ QCOMPARE(page->action(QWebPage::AlignRight)->isEnabled(), false);
+
+ // Select everything
+ page->triggerAction(QWebPage::SelectAll);
+
+ // make sure it is enabled since there is a selection
+ QCOMPARE(page->action(QWebPage::Copy)->isEnabled(), true);
// make it editable before navigating the cursor
page->setContentEditable(true);
+ // clear the selection
+ page->triggerAction(QWebPage::MoveToStartOfDocument);
+ QVERIFY(page->isSelectionCollapsed());
+ QCOMPARE(page->selectionStartOffset(), 0);
+
+ // make sure it is disabled since there isn't a selection
+ QCOMPARE(page->action(QWebPage::Copy)->isEnabled(), false);
+
// here the actions are enabled after contentEditable is true
+ QCOMPARE(page->action(QWebPage::Paste)->isEnabled(), true);
QCOMPARE(page->action(QWebPage::DeleteStartOfWord)->isEnabled(), true);
QCOMPARE(page->action(QWebPage::DeleteEndOfWord)->isEnabled(), true);
QCOMPARE(page->action(QWebPage::SetTextDirectionDefault)->isEnabled(), true);
@@ -985,10 +1067,128 @@ void tst_QWebPage::textEditing()
QCOMPARE(page->action(QWebPage::ToggleUnderline)->isEnabled(), true);
QCOMPARE(page->action(QWebPage::InsertParagraphSeparator)->isEnabled(), true);
QCOMPARE(page->action(QWebPage::InsertLineSeparator)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::PasteAndMatchStyle)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::ToggleStrikethrough)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::ToggleSubscript)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::ToggleSuperscript)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::InsertUnorderedList)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::InsertOrderedList)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::Indent)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::Outdent)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::AlignCenter)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::AlignJustified)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::AlignLeft)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::AlignRight)->isEnabled(), true);
+
+ // make sure these are disabled since there isn't a selection
+ QCOMPARE(page->action(QWebPage::Cut)->isEnabled(), false);
+ QCOMPARE(page->action(QWebPage::RemoveFormat)->isEnabled(), false);
+
+ // make sure everything is selected
+ page->triggerAction(QWebPage::SelectAll);
+
+ // this is only true if there is an editable selection
+ QCOMPARE(page->action(QWebPage::Cut)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::RemoveFormat)->isEnabled(), true);
delete page;
}
+void tst_QWebPage::requestCache()
+{
+ TestPage page;
+ QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool)));
+
+ page.mainFrame()->setUrl(QString("data:text/html,<a href=\"data:text/html,Reached\" target=\"_blank\">Click me</a>"));
+ QTRY_COMPARE(loadSpy.count(), 1);
+ QTRY_COMPARE(page.navigations.count(), 1);
+
+ page.mainFrame()->setUrl(QString("data:text/html,<a href=\"data:text/html,Reached\" target=\"_blank\">Click me2</a>"));
+ QTRY_COMPARE(loadSpy.count(), 2);
+ QTRY_COMPARE(page.navigations.count(), 2);
+
+ page.triggerAction(QWebPage::Stop);
+ QVERIFY(page.history()->canGoBack());
+ page.triggerAction(QWebPage::Back);
+
+ QTRY_COMPARE(loadSpy.count(), 3);
+ QTRY_COMPARE(page.navigations.count(), 3);
+ QCOMPARE(page.navigations.at(0).request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt(),
+ (int)QNetworkRequest::PreferNetwork);
+ QCOMPARE(page.navigations.at(1).request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt(),
+ (int)QNetworkRequest::PreferNetwork);
+ QCOMPARE(page.navigations.at(2).request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt(),
+ (int)QNetworkRequest::PreferCache);
+}
+
+void tst_QWebPage::backActionUpdate()
+{
+ QWebView view;
+ QWebPage *page = view.page();
+ QAction *action = page->action(QWebPage::Back);
+ QVERIFY(!action->isEnabled());
+ QSignalSpy loadSpy(page, SIGNAL(loadFinished(bool)));
+ QUrl url = QUrl("qrc:///frametest/index.html");
+ page->mainFrame()->load(url);
+ QTRY_COMPARE(loadSpy.count(), 1);
+ QVERIFY(!action->isEnabled());
+ QTest::mouseClick(&view, Qt::LeftButton, 0, QPoint(10, 10));
+ QTRY_COMPARE(loadSpy.count(), 2);
+
+ QVERIFY(action->isEnabled());
+}
+
+void frameAtHelper(QWebPage* webPage, QWebFrame* webFrame, QPoint framePosition)
+{
+ if (!webFrame)
+ return;
+
+ framePosition += QPoint(webFrame->pos());
+ QList<QWebFrame*> children = webFrame->childFrames();
+ for (int i = 0; i < children.size(); ++i) {
+ if (children.at(i)->childFrames().size() > 0)
+ frameAtHelper(webPage, children.at(i), framePosition);
+
+ QRect frameRect(children.at(i)->pos() + framePosition, children.at(i)->geometry().size());
+ QVERIFY(children.at(i) == webPage->frameAt(frameRect.topLeft()));
+ }
+}
+
+void tst_QWebPage::frameAt()
+{
+ QWebView webView;
+ QWebPage* webPage = webView.page();
+ QSignalSpy loadSpy(webPage, SIGNAL(loadFinished(bool)));
+ QUrl url = QUrl("qrc:///frametest/iframe.html");
+ webPage->mainFrame()->load(url);
+ QTRY_COMPARE(loadSpy.count(), 1);
+ frameAtHelper(webPage, webPage->mainFrame(), webPage->mainFrame()->pos());
+}
+
+// import a little DRT helper function to trigger the garbage collector
+void QWEBKIT_EXPORT qt_drt_garbageCollector_collect();
+
+void tst_QWebPage::protectBindingsRuntimeObjectsFromCollector()
+{
+ QSignalSpy loadSpy(m_view, SIGNAL(loadFinished(bool)));
+
+ PluginPage* newPage = new PluginPage(m_view);
+ m_view->setPage(newPage);
+
+ m_view->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
+
+ m_view->setHtml(QString("<html><body><object type='application/x-qt-plugin' classid='lineedit' id='mylineedit'/></body></html>"));
+ QTRY_COMPARE(loadSpy.count(), 1);
+
+ newPage->mainFrame()->evaluateJavaScript("function testme(text) { var lineedit = document.getElementById('mylineedit'); lineedit.setText(text); lineedit.selectAll(); }");
+
+ newPage->mainFrame()->evaluateJavaScript("testme('foo')");
+
+ qt_drt_garbageCollector_collect();
+
+ // don't crash!
+ newPage->mainFrame()->evaluateJavaScript("testme('bar')");
+}
QTEST_MAIN(tst_QWebPage)
#include "tst_qwebpage.moc"
diff --git a/WebKit/qt/tests/qwebpage/tst_qwebpage.qrc b/WebKit/qt/tests/qwebpage/tst_qwebpage.qrc
new file mode 100644
index 0000000..3085ce2
--- /dev/null
+++ b/WebKit/qt/tests/qwebpage/tst_qwebpage.qrc
@@ -0,0 +1,10 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>frametest/index.html</file>
+ <file>frametest/frame_a.html</file>
+ <file>frametest/iframe.html</file>
+ <file>frametest/iframe2.html</file>
+ <file>frametest/iframe3.html</file>
+</qresource>
+</RCC>
+
diff --git a/WebKit/qt/tests/qwebplugindatabase/qwebplugindatabase.pro b/WebKit/qt/tests/qwebplugindatabase/qwebplugindatabase.pro
new file mode 100644
index 0000000..5d10993
--- /dev/null
+++ b/WebKit/qt/tests/qwebplugindatabase/qwebplugindatabase.pro
@@ -0,0 +1,6 @@
+TEMPLATE = app
+TARGET = tst_qwebplugindatabase
+include(../../../../WebKit.pri)
+SOURCES += tst_qwebplugindatabase.cpp
+QT += testlib network
+QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
diff --git a/WebKit/qt/tests/qwebplugindatabase/tst_qwebplugindatabase.cpp b/WebKit/qt/tests/qwebplugindatabase/tst_qwebplugindatabase.cpp
new file mode 100644
index 0000000..c0533ad
--- /dev/null
+++ b/WebKit/qt/tests/qwebplugindatabase/tst_qwebplugindatabase.cpp
@@ -0,0 +1,401 @@
+/*
+ Copyright (C) 2009 Jakub Wieczorek <faw217@gmail.com>
+
+ 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 <qdir.h>
+#include <qwebframe.h>
+#include <qwebpage.h>
+#include <qwebplugindatabase.h>
+#include <qwebsettings.h>
+#include <qvariant.h>
+
+class tst_QWebPluginDatabase : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void installedPlugins();
+ void searchPaths();
+ void null_data();
+ void null();
+ void pluginForMimeType();
+ void enabled();
+ void operatorequal_data();
+ void operatorequal();
+ void preferredPlugin();
+};
+
+typedef QWebPluginInfo::MimeType MimeType;
+
+void tst_QWebPluginDatabase::installedPlugins()
+{
+ QWebPage page;
+ page.settings()->setAttribute(QWebSettings::PluginsEnabled, true);
+ QWebFrame* frame = page.mainFrame();
+
+ QVariantMap jsPluginsMap = frame->evaluateJavaScript("window.navigator.plugins").toMap();
+ QList<QWebPluginInfo> plugins = QWebSettings::pluginDatabase()->plugins();
+ QCOMPARE(plugins, QWebSettings::pluginDatabase()->plugins());
+
+ int length = jsPluginsMap["length"].toInt();
+ QCOMPARE(length, plugins.count());
+
+ for (int i = 0; i < length; ++i) {
+ QWebPluginInfo plugin = plugins.at(i);
+
+ QVariantMap jsPlugin = frame->evaluateJavaScript(QString("window.navigator.plugins[%1]").arg(i)).toMap();
+ QString name = jsPlugin["name"].toString();
+ QString description = jsPlugin["description"].toString();
+ QString fileName = jsPlugin["filename"].toString();
+
+ QCOMPARE(plugin.name(), name);
+ QCOMPARE(plugin.description(), description);
+ QCOMPARE(QFileInfo(plugin.path()).fileName(), fileName);
+
+ QList<MimeType> mimeTypes;
+ int mimeTypesCount = jsPlugin["length"].toInt();
+
+ for (int j = 0; j < mimeTypesCount; ++j) {
+ QVariantMap jsMimeType = frame->evaluateJavaScript(QString("window.navigator.plugins[%1][%2]").arg(i).arg(j)).toMap();
+
+ MimeType mimeType;
+ mimeType.name = jsMimeType["type"].toString();
+ mimeType.description = jsMimeType["description"].toString();
+ mimeType.fileExtensions = jsMimeType["suffixes"].toString().split(',', QString::SkipEmptyParts);
+
+ mimeTypes.append(mimeType);
+ QVERIFY(plugin.supportsMimeType(mimeType.name));
+ }
+
+ QCOMPARE(plugin.mimeTypes(), mimeTypes);
+
+ QVERIFY(!plugin.isNull());
+ QVERIFY(plugin.isEnabled());
+ }
+}
+
+void tst_QWebPluginDatabase::searchPaths()
+{
+ QWebPluginDatabase* database = QWebSettings::pluginDatabase();
+ QList<QWebPluginInfo> plugins = database->plugins();
+ QStringList directories = database->searchPaths();
+ QCOMPARE(QWebPluginDatabase::defaultSearchPaths(), directories);
+
+ database->setSearchPaths(directories);
+ QCOMPARE(QWebPluginDatabase::defaultSearchPaths(), directories);
+ QCOMPARE(database->searchPaths(), directories);
+ QCOMPARE(database->plugins(), plugins);
+ database->refresh();
+ QCOMPARE(database->plugins(), plugins);
+
+ database->setSearchPaths(QStringList());
+ QCOMPARE(QWebPluginDatabase::defaultSearchPaths(), directories);
+ QCOMPARE(database->searchPaths(), QStringList());
+ QCOMPARE(database->plugins().count(), 0);
+
+ database->setSearchPaths(directories);
+ QCOMPARE(database->searchPaths(), directories);
+ database->addSearchPath(QDir::tempPath());
+ QCOMPARE(database->searchPaths().count(), directories.count() + 1);
+ QVERIFY(database->searchPaths().contains(QDir::tempPath()));
+ directories.append(QDir::tempPath());
+ QCOMPARE(database->searchPaths(), directories);
+
+ // As an empty set of search paths has been set, the database has been rebuilt
+ // from scratch after bringing the old path set back.
+ // Because the QWebPlugins no longer point to the same PluginPackages,
+ // the list is also no longer equal to the older one, even though it contains
+ // the same information.
+ QCOMPARE(database->plugins().count(), plugins.count());
+ plugins = database->plugins();
+ QCOMPARE(database->plugins(), plugins);
+
+ for (int i = (directories.count() - 1); i >= 0; --i) {
+ QDir directory(directories.at(i));
+ if (!directory.exists() || !directory.count())
+ directories.removeAt(i);
+ }
+
+ database->setSearchPaths(directories);
+ QCOMPARE(database->plugins(), plugins);
+ database->refresh();
+ QCOMPARE(database->plugins(), plugins);
+
+ database->setSearchPaths(QWebPluginDatabase::defaultSearchPaths());
+ directories = QWebPluginDatabase::defaultSearchPaths();
+ QCOMPARE(QWebPluginDatabase::defaultSearchPaths(), directories);
+ QCOMPARE(database->searchPaths(), directories);
+ QCOMPARE(database->plugins(), plugins);
+}
+
+Q_DECLARE_METATYPE(QWebPluginInfo)
+void tst_QWebPluginDatabase::null_data()
+{
+ QTest::addColumn<QWebPluginInfo>("plugin");
+ QTest::addColumn<bool>("null");
+
+ QTest::newRow("null") << QWebPluginInfo() << true;
+ QTest::newRow("foo") << QWebSettings::pluginDatabase()->pluginForMimeType("foobarbaz") << true;
+
+ QList<QWebPluginInfo> plugins = QWebSettings::pluginDatabase()->plugins();
+ for (int i = 0; i < plugins.count(); ++i)
+ QTest::newRow(QString::number(i).toUtf8().constData()) << plugins.at(i) << false;
+}
+
+void tst_QWebPluginDatabase::null()
+{
+ QFETCH(QWebPluginInfo, plugin);
+ QFETCH(bool, null);
+
+ QCOMPARE(plugin.isNull(), null);
+}
+
+void tst_QWebPluginDatabase::pluginForMimeType()
+{
+ QMultiMap<QString, QWebPluginInfo> pluginsMap;
+ QWebPluginDatabase* database = QWebSettings::pluginDatabase();
+ QList<QWebPluginInfo> plugins = database->plugins();
+
+ for (int i = 0; i < plugins.count(); ++i) {
+ QWebPluginInfo plugin = plugins.at(i);
+
+ QList<MimeType> mimeTypes = plugin.mimeTypes();
+ for (int j = 0; j < mimeTypes.count(); ++j) {
+ QString mimeType = mimeTypes.at(j).name;
+ pluginsMap.insert(mimeType, plugin);
+ QVERIFY(plugin.supportsMimeType(mimeType));
+ }
+ }
+
+ for (int i = 0; i < plugins.count(); ++i) {
+ QWebPluginInfo plugin = plugins.at(i);
+
+ QList<MimeType> mimeTypes = plugin.mimeTypes();
+ for (int j = 0; j < mimeTypes.count(); ++j) {
+ QString mimeType = mimeTypes.at(j).name;
+
+ QVERIFY(pluginsMap.count(mimeType) > 0);
+ if (pluginsMap.count(mimeType) > 1)
+ continue;
+
+ QWebPluginInfo pluginForMimeType = database->pluginForMimeType(mimeType);
+ QCOMPARE(pluginForMimeType, plugin);
+ database->setSearchPaths(database->searchPaths());
+ QCOMPARE(pluginForMimeType, plugin);
+ QCOMPARE(pluginForMimeType, database->pluginForMimeType(mimeType.toUpper()));
+ QCOMPARE(pluginForMimeType, database->pluginForMimeType(mimeType.toLower()));
+ QVERIFY(plugin.supportsMimeType(mimeType));
+ QVERIFY(!pluginForMimeType.isNull());
+ QVERIFY(!plugin.isNull());
+ }
+ }
+}
+
+void tst_QWebPluginDatabase::enabled()
+{
+ QMultiMap<QString, QWebPluginInfo> pluginsMap;
+ QWebPluginDatabase* database = QWebSettings::pluginDatabase();
+ QList<QWebPluginInfo> plugins = database->plugins();
+
+ for (int i = 0; i < plugins.count(); ++i) {
+ QWebPluginInfo plugin = plugins.at(i);
+
+ QList<MimeType> mimeTypes = plugin.mimeTypes();
+ for (int j = 0; j < mimeTypes.count(); ++j) {
+ QString mimeType = mimeTypes.at(j).name;
+ pluginsMap.insert(mimeType, plugin);
+ QVERIFY(plugin.supportsMimeType(mimeType));
+ }
+ }
+
+ QMultiMap<QString, QWebPluginInfo>::iterator it = pluginsMap.begin();
+ while (it != pluginsMap.end()) {
+ QString mimeType = it.key();
+ QWebPluginInfo plugin = it.value();
+ QWebPluginInfo pluginForMimeType = database->pluginForMimeType(mimeType);
+
+ QVERIFY(pluginsMap.count(mimeType) > 0);
+
+ if (pluginsMap.count(mimeType) == 1) {
+ QCOMPARE(plugin, pluginForMimeType);
+
+ QVERIFY(plugin.isEnabled());
+ QVERIFY(pluginForMimeType.isEnabled());
+ plugin.setEnabled(false);
+ QVERIFY(!plugin.isEnabled());
+ QVERIFY(!pluginForMimeType.isEnabled());
+ } else {
+ QVERIFY(plugin.isEnabled());
+ QVERIFY(pluginForMimeType.isEnabled());
+ plugin.setEnabled(false);
+ QVERIFY(!plugin.isEnabled());
+ }
+
+ QVERIFY(!plugin.isNull());
+ QVERIFY(!pluginForMimeType.isNull());
+
+ QWebPluginInfo pluginForMimeType2 = database->pluginForMimeType(mimeType);
+ if (pluginsMap.count(mimeType) == 1) {
+ QVERIFY(pluginForMimeType2 != plugin);
+ QVERIFY(pluginForMimeType2.isNull());
+ } else {
+ QVERIFY(pluginForMimeType2 != plugin);
+ QVERIFY(!pluginForMimeType2.isNull());
+ }
+
+ plugin.setEnabled(true);
+
+ ++it;
+ }
+}
+
+void tst_QWebPluginDatabase::operatorequal_data()
+{
+ QTest::addColumn<QWebPluginInfo>("first");
+ QTest::addColumn<QWebPluginInfo>("second");
+ QTest::addColumn<bool>("equal");
+
+ QWebPluginDatabase* database = QWebSettings::pluginDatabase();
+ QTest::newRow("null") << QWebPluginInfo() << QWebPluginInfo() << true;
+ QTest::newRow("application/x-shockwave-flash") << database->pluginForMimeType("application/x-shockwave-flash")
+ << database->pluginForMimeType("application/x-shockwave-flash") << true;
+ QTest::newRow("foo/bar-baz") << database->pluginForMimeType("foo/bar-baz")
+ << database->pluginForMimeType("foo/bar-baz") << true;
+
+ QList<QWebPluginInfo> plugins = database->plugins();
+ for (int i = 0; i < (plugins.count() - 1); ++i) {
+ QWebPluginInfo first = plugins.at(i);
+ QWebPluginInfo second = plugins.at(i + 1);
+
+ QTest::newRow(QString("%1==%2").arg(first.name(), second.name()).toUtf8().constData())
+ << first << second << false;
+ }
+}
+
+void tst_QWebPluginDatabase::operatorequal()
+{
+ QFETCH(QWebPluginInfo, first);
+ QFETCH(QWebPluginInfo, second);
+ QFETCH(bool, equal);
+
+ QCOMPARE(first == second, equal);
+}
+
+void tst_QWebPluginDatabase::preferredPlugin()
+{
+ QMultiMap<QString, QWebPluginInfo> pluginsMap;
+ QWebPluginDatabase* database = QWebSettings::pluginDatabase();
+ QList<QWebPluginInfo> plugins = database->plugins();
+
+ for (int i = 0; i < plugins.count(); ++i) {
+ QWebPluginInfo plugin = plugins.at(i);
+
+ QList<MimeType> mimeTypes = plugin.mimeTypes();
+ for (int j = 0; j < mimeTypes.count(); ++j) {
+ QString mimeType = mimeTypes.at(j).name;
+ pluginsMap.insert(mimeType, plugin);
+ }
+ }
+
+ QMultiMap<QString, QWebPluginInfo>::iterator it = pluginsMap.begin();
+ while (it != pluginsMap.end()) {
+ QString mimeType = it.key();
+
+ if (pluginsMap.count(mimeType) > 1) {
+ QList<QWebPluginInfo> pluginsForMimeType = pluginsMap.values(mimeType);
+ QWebPluginInfo plugin = database->pluginForMimeType(mimeType);
+ QVERIFY(plugin.supportsMimeType(mimeType));
+
+ pluginsForMimeType.removeAll(plugin);
+ for (int i = 0; i < pluginsForMimeType.count(); ++i) {
+ QWebPluginInfo anotherPlugin = pluginsForMimeType.at(i);
+ QVERIFY(plugin.supportsMimeType(mimeType));
+ QVERIFY(plugin != anotherPlugin);
+
+ QCOMPARE(database->pluginForMimeType(mimeType), plugin);
+ database->setPreferredPluginForMimeType(mimeType, anotherPlugin);
+ QCOMPARE(database->pluginForMimeType(mimeType), anotherPlugin);
+
+ anotherPlugin.setEnabled(false);
+ QCOMPARE(database->pluginForMimeType(mimeType), plugin);
+
+ anotherPlugin.setEnabled(true);
+ QCOMPARE(database->pluginForMimeType(mimeType), anotherPlugin);
+ database->setSearchPaths(database->searchPaths());
+ QCOMPARE(database->pluginForMimeType(mimeType), anotherPlugin);
+
+ database->setPreferredPluginForMimeType(mimeType, QWebPluginInfo());
+ QCOMPARE(database->pluginForMimeType(mimeType), plugin);
+ }
+ } else {
+ QWebPluginInfo plugin = database->pluginForMimeType(mimeType);
+ QCOMPARE(pluginsMap.value(mimeType), plugin);
+
+ database->setPreferredPluginForMimeType(mimeType, plugin);
+ QCOMPARE(database->pluginForMimeType(mimeType), plugin);
+
+ plugin.setEnabled(false);
+ QCOMPARE(database->pluginForMimeType(mimeType), QWebPluginInfo());
+ plugin.setEnabled(true);
+
+ database->setPreferredPluginForMimeType(mimeType, QWebPluginInfo());
+ QCOMPARE(database->pluginForMimeType(mimeType), plugin);
+ }
+
+ ++it;
+ }
+
+ if (pluginsMap.keys().count() >= 2) {
+ QStringList mimeTypes = pluginsMap.uniqueKeys();
+
+ QString mimeType1 = mimeTypes.at(0);
+ QString mimeType2 = mimeTypes.at(1);
+ QWebPluginInfo plugin1 = database->pluginForMimeType(mimeType1);
+ QWebPluginInfo plugin2 = database->pluginForMimeType(mimeType2);
+
+ int i = 2;
+ while (plugin2.supportsMimeType(mimeType1)
+ && !mimeType2.isEmpty()
+ && i < mimeTypes.count()) {
+ mimeType2 = mimeTypes.at(i);
+ plugin2 = database->pluginForMimeType(mimeType2);
+ ++i;
+ }
+
+ plugin1 = database->pluginForMimeType(mimeType1);
+ QVERIFY(plugin1.supportsMimeType(mimeType1));
+ QVERIFY(!plugin1.isNull());
+ plugin2 = database->pluginForMimeType(mimeType2);
+ QVERIFY(plugin2.supportsMimeType(mimeType2));
+ QVERIFY(!plugin2.isNull());
+
+ database->setPreferredPluginForMimeType(mimeType2, plugin1);
+ QVERIFY(!plugin1.supportsMimeType(mimeType2));
+ QCOMPARE(database->pluginForMimeType(mimeType2), plugin2);
+
+ database->setPreferredPluginForMimeType(mimeType1, plugin1);
+ QVERIFY(!plugin2.supportsMimeType(mimeType1));
+ QCOMPARE(database->pluginForMimeType(mimeType2), plugin2);
+ }
+}
+
+QTEST_MAIN(tst_QWebPluginDatabase)
+
+#include "tst_qwebplugindatabase.moc"
diff --git a/WebKit/qt/tests/qwebview/.gitignore b/WebKit/qt/tests/qwebview/.gitignore
new file mode 100644
index 0000000..444afe6
--- /dev/null
+++ b/WebKit/qt/tests/qwebview/.gitignore
@@ -0,0 +1 @@
+qwebview
diff --git a/WebKit/qt/tests/qwebview/qwebview.pro b/WebKit/qt/tests/qwebview/qwebview.pro
new file mode 100644
index 0000000..799ccfb
--- /dev/null
+++ b/WebKit/qt/tests/qwebview/qwebview.pro
@@ -0,0 +1,6 @@
+TEMPLATE = app
+TARGET = tst_qwebview
+include(../../../../WebKit.pri)
+SOURCES += tst_qwebview.cpp
+QT += testlib network
+QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
diff --git a/WebKit/qt/tests/qwebview/tst_qwebview.cpp b/WebKit/qt/tests/qwebview/tst_qwebview.cpp
new file mode 100644
index 0000000..01d0e92
--- /dev/null
+++ b/WebKit/qt/tests/qwebview/tst_qwebview.cpp
@@ -0,0 +1,172 @@
+/*
+ Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2009 Torch Mobile Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <qtest.h>
+
+#include <qpainter.h>
+#include <qwebview.h>
+#include <qwebpage.h>
+#include <qnetworkrequest.h>
+#include <qdiriterator.h>
+#include <qwebkitversion.h>
+
+class tst_QWebView : public QObject
+{
+ Q_OBJECT
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+private slots:
+ void renderHints();
+ void guessUrlFromString_data();
+ void guessUrlFromString();
+ void getWebKitVersion();
+};
+
+// This will be called before the first test function is executed.
+// It is only called once.
+void tst_QWebView::initTestCase()
+{
+}
+
+// This will be called after the last test function is executed.
+// It is only called once.
+void tst_QWebView::cleanupTestCase()
+{
+}
+
+// This will be called before each test function is executed.
+void tst_QWebView::init()
+{
+}
+
+// This will be called after every test function.
+void tst_QWebView::cleanup()
+{
+}
+
+void tst_QWebView::renderHints()
+{
+ QWebView webView;
+
+ // default is only text antialiasing
+ QVERIFY(!(webView.renderHints() & QPainter::Antialiasing));
+ QVERIFY(webView.renderHints() & QPainter::TextAntialiasing);
+ QVERIFY(!(webView.renderHints() & QPainter::SmoothPixmapTransform));
+ QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing));
+
+ webView.setRenderHint(QPainter::Antialiasing, true);
+ QVERIFY(webView.renderHints() & QPainter::Antialiasing);
+ QVERIFY(webView.renderHints() & QPainter::TextAntialiasing);
+ QVERIFY(!(webView.renderHints() & QPainter::SmoothPixmapTransform));
+ QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing));
+
+ webView.setRenderHint(QPainter::Antialiasing, false);
+ QVERIFY(!(webView.renderHints() & QPainter::Antialiasing));
+ QVERIFY(webView.renderHints() & QPainter::TextAntialiasing);
+ QVERIFY(!(webView.renderHints() & QPainter::SmoothPixmapTransform));
+ QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing));
+
+ webView.setRenderHint(QPainter::SmoothPixmapTransform, true);
+ QVERIFY(!(webView.renderHints() & QPainter::Antialiasing));
+ QVERIFY(webView.renderHints() & QPainter::TextAntialiasing);
+ QVERIFY(webView.renderHints() & QPainter::SmoothPixmapTransform);
+ QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing));
+
+ webView.setRenderHint(QPainter::SmoothPixmapTransform, false);
+ QVERIFY(webView.renderHints() & QPainter::TextAntialiasing);
+ QVERIFY(!(webView.renderHints() & QPainter::SmoothPixmapTransform));
+ QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing));
+}
+
+void tst_QWebView::guessUrlFromString_data()
+{
+ QTest::addColumn<QString>("string");
+ QTest::addColumn<QUrl>("guessUrlFromString");
+
+ // Null
+ QTest::newRow("null") << QString() << QUrl();
+
+ // File
+ QDirIterator it(QDir::homePath());
+ QString fileString;
+ int c = 0;
+ while (it.hasNext()) {
+ it.next();
+ QTest::newRow(QString("file-%1").arg(c++).toLatin1()) << it.filePath() << QUrl::fromLocalFile(it.filePath());
+ }
+
+ // basic latin1
+ QTest::newRow("unicode-0") << QString::fromUtf8("å.com/") << QUrl::fromEncoded(QString::fromUtf8("http://å.com/").toUtf8(), QUrl::TolerantMode);
+ // unicode
+ QTest::newRow("unicode-1") << QString::fromUtf8("λ.com/") << QUrl::fromEncoded(QString::fromUtf8("http://λ.com/").toUtf8(), QUrl::TolerantMode);
+
+ // no scheme
+ QTest::newRow("add scheme-0") << "webkit.org" << QUrl("http://webkit.org");
+ QTest::newRow("add scheme-1") << "www.webkit.org" << QUrl("http://www.webkit.org");
+ QTest::newRow("add scheme-2") << "ftp.webkit.org" << QUrl("ftp://ftp.webkit.org");
+ QTest::newRow("add scheme-3") << "webkit" << QUrl("webkit");
+
+ // QUrl's tolerant parser should already handle this
+ QTest::newRow("not-encoded-0") << "http://webkit.org/test page.html" << QUrl("http://webkit.org/test%20page.html");
+
+ // Make sure the :80, i.e. port doesn't screw anything up
+ QUrl portUrl("http://webkit.org");
+ portUrl.setPort(80);
+ QTest::newRow("port-0") << "webkit.org:80" << portUrl;
+ QTest::newRow("port-1") << "http://webkit.org:80" << portUrl;
+
+ // mailto doesn't have a ://, but is valid
+ QUrl mailto("ben@meyerhome.net");
+ mailto.setScheme("mailto");
+ QTest::newRow("mailto") << "mailto:ben@meyerhome.net" << mailto;
+
+ // misc
+ QTest::newRow("localhost-0") << "localhost" << QUrl("http://localhost");
+ QTest::newRow("localhost-1") << "localhost:80" << QUrl("http://localhost:80");
+ QTest::newRow("spaces-0") << " http://webkit.org/test page.html " << QUrl("http://webkit.org/test%20page.html");
+
+ // FYI: The scheme in the resulting url user
+ QUrl authUrl("user:pass@domain.com");
+ QTest::newRow("misc-1") << "user:pass@domain.com" << authUrl;
+}
+
+// public static QUrl guessUrlFromString(QString const& string)
+void tst_QWebView::guessUrlFromString()
+{
+ QFETCH(QString, string);
+ QFETCH(QUrl, guessUrlFromString);
+
+ QUrl url = QWebView::guessUrlFromString(string);
+ QCOMPARE(url, guessUrlFromString);
+}
+
+void tst_QWebView::getWebKitVersion()
+{
+ QVERIFY(qWebKitVersion().toDouble() > 0);
+}
+
+QTEST_MAIN(tst_QWebView)
+#include "tst_qwebview.moc"
+
diff --git a/WebKit/qt/tests/tests.pro b/WebKit/qt/tests/tests.pro
index f08830d..b5f66ee 100644
--- a/WebKit/qt/tests/tests.pro
+++ b/WebKit/qt/tests/tests.pro
@@ -1,3 +1,4 @@
TEMPLATE = subdirs
-SUBDIRS = qwebframe qwebpage
+SUBDIRS = qwebframe qwebpage qwebelement qwebhistoryinterface qwebplugindatabase qwebview qwebhistory
+greaterThan(QT_MINOR_VERSION, 4): SUBDIRS += benchmarks/painting/tst_painting.pro benchmarks/loading/tst_loading.pro