diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-05 14:34:32 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-05 14:34:32 -0800 |
commit | 635860845790a19bf50bbc51ba8fb66a96dde068 (patch) | |
tree | ef6ad9ff73a5b57f65249d4232a202fa77e6a140 /WebKit/qt/Api | |
parent | 8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2 (diff) | |
download | external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.zip external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.gz external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.bz2 |
auto import from //depot/cupcake/@136594
Diffstat (limited to 'WebKit/qt/Api')
-rw-r--r-- | WebKit/qt/Api/headers.pri | 11 | ||||
-rw-r--r-- | WebKit/qt/Api/qtwebkit.prf | 4 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebdatabase.cpp | 148 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebdatabase.h | 59 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebdatabase_p.h | 38 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebframe.cpp | 282 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebframe.h | 19 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebframe_p.h | 9 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebhistory.cpp | 5 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebhistory.h | 2 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebkitglobal.h | 16 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebpage.cpp | 363 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebpage.h | 36 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebpage_p.h | 11 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebpluginfactory.cpp | 4 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebsecurityorigin.cpp | 176 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebsecurityorigin.h | 67 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebsecurityorigin_p.h | 40 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebsettings.cpp | 191 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebsettings.h | 16 | ||||
-rw-r--r-- | WebKit/qt/Api/qwebview.cpp | 19 |
21 files changed, 1358 insertions, 158 deletions
diff --git a/WebKit/qt/Api/headers.pri b/WebKit/qt/Api/headers.pri index 1e70072..2b3c940 100644 --- a/WebKit/qt/Api/headers.pri +++ b/WebKit/qt/Api/headers.pri @@ -1,11 +1,8 @@ -WEBKIT_API_HEADERS = $$PWD/qcookiejar.h \ - $$PWD/qwebframe.h \ +WEBKIT_API_HEADERS = $$PWD/qwebframe.h \ $$PWD/qwebkitglobal.h \ - $$PWD/qwebnetworkinterface.h \ - $$PWD/qwebobjectplugin.h \ - $$PWD/qwebobjectpluginconnector.h \ $$PWD/qwebpage.h \ $$PWD/qwebview.h \ - $$PWD/qwebpagehistory.h \ $$PWD/qwebsettings.h \ - $$PWD/qwebhistoryinterface.h + $$PWD/qwebhistoryinterface.h \ + $$PWD/qwebdatabase.h \ + $$PWD/qwebsecurityorigin.h diff --git a/WebKit/qt/Api/qtwebkit.prf b/WebKit/qt/Api/qtwebkit.prf deleted file mode 100644 index 37417c6..0000000 --- a/WebKit/qt/Api/qtwebkit.prf +++ /dev/null @@ -1,4 +0,0 @@ - -qtAddLibrary(QtWebKit) - -QT += network diff --git a/WebKit/qt/Api/qwebdatabase.cpp b/WebKit/qt/Api/qwebdatabase.cpp new file mode 100644 index 0000000..489ab17 --- /dev/null +++ b/WebKit/qt/Api/qwebdatabase.cpp @@ -0,0 +1,148 @@ +/* + Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" +#include "qwebdatabase.h" +#include "qwebdatabase_p.h" +#include "qwebsecurityorigin.h" +#include "qwebsecurityorigin_p.h" +#include "DatabaseDetails.h" +#include "DatabaseTracker.h" + +using namespace WebCore; + +/*! + \class QWebDatabase + \since 4.5 + \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. + + For more information refer to the \l{http://www.w3.org/html/wg/html5/#sql}{HTML 5 Draft Standard}. + + \sa QWebSecurityOrigin +*/ + +/*! + Constructs a web database from \a other. +*/ +QWebDatabase::QWebDatabase(const QWebDatabase& other) : d(other.d) +{ +} + +/*! + Assigns the \a other web database to this. +*/ +QWebDatabase& QWebDatabase::operator=(const QWebDatabase& other) +{ + d = other.d; + return *this; +} + +/*! + Returns the name of the database. +*/ +QString QWebDatabase::name() const +{ + return d->name; +} + +/*! + Returns the name of the database as seen by the user. +*/ +QString QWebDatabase::displayName() const +{ + DatabaseDetails details = DatabaseTracker::tracker().detailsForNameAndOrigin(d->name, d->origin.get()); + return details.displayName(); +} + +/*! + Returns the expected size of the database in bytes as defined by the web author. +*/ +qint64 QWebDatabase::expectedSize() const +{ + DatabaseDetails details = DatabaseTracker::tracker().detailsForNameAndOrigin(d->name, d->origin.get()); + return details.expectedUsage(); +} + +/*! + Returns the current size of the database in bytes. +*/ +qint64 QWebDatabase::size() const +{ + DatabaseDetails details = DatabaseTracker::tracker().detailsForNameAndOrigin(d->name, d->origin.get()); + return details.currentUsage(); +} + +/*! + \internal +*/ +QWebDatabase::QWebDatabase(QWebDatabasePrivate* priv) +{ + d = priv; +} + +/*! + Returns the file name of the web database. + + The name can be used to access the database through the QtSql database module, for example: + \code + QWebDatabase webdb = ... + QSqlDatabase sqldb = QSqlDatabase::addDatabase("QSQLITE", "myconnection"); + sqldb.setDatabaseName(webdb.fileName()); + if (sqldb.open()) { + QStringList tables = sqldb.tables(); + ... + } + \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. +*/ +QString QWebDatabase::fileName() const +{ + return DatabaseTracker::tracker().fullPathForDatabase(d->origin.get(), d->name, false); +} + +/*! + Returns the databases's security origin. +*/ +QWebSecurityOrigin QWebDatabase::origin() const +{ + QWebSecurityOriginPrivate* priv = new QWebSecurityOriginPrivate(d->origin.get()); + QWebSecurityOrigin origin(priv); + return origin; +} + +/*! + Removes the database, \a db, from its security origin. All data stored in this database + will be destroyed. +*/ +void QWebDatabase::removeDatabase(const QWebDatabase &db) +{ + DatabaseTracker::tracker().deleteDatabase(db.d->origin.get(), db.d->name); +} + +/*! + Destroys the web database object. The data within this database is \b not destroyed. +*/ +QWebDatabase::~QWebDatabase() +{ +} diff --git a/WebKit/qt/Api/qwebdatabase.h b/WebKit/qt/Api/qwebdatabase.h new file mode 100644 index 0000000..f4c368a --- /dev/null +++ b/WebKit/qt/Api/qwebdatabase.h @@ -0,0 +1,59 @@ +/* + Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#ifndef _WEBDATABASE_H_ +#define _WEBDATABASE_H_ + +#include <QtCore/qstring.h> +#include <QtCore/qshareddata.h> + +#include "qwebkitglobal.h" + +namespace WebCore { + class DatabaseDetails; +}; + +class QWebDatabasePrivate; +class QWebSecurityOrigin; + +class QWEBKIT_EXPORT QWebDatabase +{ +public: + QWebDatabase(const QWebDatabase& other); + QWebDatabase &operator=(const QWebDatabase& other); + ~QWebDatabase(); + + QString name() const; + QString displayName() const; + qint64 expectedSize() const; + qint64 size() const; + QString fileName() const; + QWebSecurityOrigin origin() const; + + static void removeDatabase(const QWebDatabase &db); + +private: + QWebDatabase(QWebDatabasePrivate* priv); + friend class QWebSecurityOrigin; + +private: + QExplicitlySharedDataPointer<QWebDatabasePrivate> d; +}; + +#endif + diff --git a/WebKit/qt/Api/qwebdatabase_p.h b/WebKit/qt/Api/qwebdatabase_p.h new file mode 100644 index 0000000..988fb16 --- /dev/null +++ b/WebKit/qt/Api/qwebdatabase_p.h @@ -0,0 +1,38 @@ +/* + Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#ifndef _WEBDATABASE_P_H_ +#define _WEBDATABASE_P_H_ + +#include <QString> +#include <QtCore/qshareddata.h> + +#include "PlatformString.h" +#include "SecurityOrigin.h" +#include "RefPtr.h" + + +class QWebDatabasePrivate : public QSharedData +{ +public: + WebCore::String name; + WTF::RefPtr<WebCore::SecurityOrigin> origin; +}; + +#endif + diff --git a/WebKit/qt/Api/qwebframe.cpp b/WebKit/qt/Api/qwebframe.cpp index 892949d..4e82d54 100644 --- a/WebKit/qt/Api/qwebframe.cpp +++ b/WebKit/qt/Api/qwebframe.cpp @@ -23,6 +23,8 @@ #include "qwebpage.h" #include "qwebpage_p.h" #include "qwebframe_p.h" +#include "qwebsecurityorigin.h" +#include "qwebsecurityorigin_p.h" #include "DocumentLoader.h" #include "FocusController.h" @@ -31,6 +33,7 @@ #include "FrameTree.h" #include "FrameView.h" #include "IconDatabase.h" +#include "InspectorController.h" #include "Page.h" #include "PutPropertySlot.h" #include "ResourceRequest.h" @@ -41,6 +44,7 @@ #include "SubstituteData.h" #include "markup.h" +#include "htmlediting.h" #include "RenderTreeAsText.h" #include "Element.h" #include "Document.h" @@ -52,17 +56,19 @@ #include "GraphicsContext.h" #include "HitTestResult.h" -#include "runtime.h" -#include "runtime_object.h" -#include "runtime_root.h" -#include "JSDOMWindow.h" -#include "qt_instance.h" -#include "ScriptController.h" +#include "CallFrame.h" #include "JSDOMBinding.h" -#include "ExecState.h" +#include "JSDOMWindow.h" #include "JSLock.h" #include "JSObject.h" +#include "qt_instance.h" #include "qt_runtime.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" @@ -70,6 +76,7 @@ #include <qevent.h> #include <qfileinfo.h> #include <qpainter.h> +#include <QMultiMap> #if QT_VERSION >= 0x040400 #include <qnetworkrequest.h> #else @@ -77,6 +84,8 @@ #endif #include <qregion.h> #include <qprinter.h> +#include "HTMLMetaElement.h" +#include "NodeList.h" using namespace WebCore; @@ -85,6 +94,18 @@ QT_BEGIN_NAMESPACE extern Q_GUI_EXPORT int qt_defaultDpi(); QT_END_NAMESPACE +void QWEBKIT_EXPORT qt_drt_setJavaScriptProfilingEnabled(QWebFrame* qframe, bool enabled) +{ + Frame* frame = QWebFramePrivate::core(qframe); + InspectorController* controller = frame->page()->inspectorController(); + if (!controller) + return; + if (enabled) + controller->enableProfiler(); + else + controller->disableProfiler(); +} + void QWebFramePrivate::init(QWebFrame *qframe, WebCore::Page *webcorePage, QWebFrameData *frameData) { q = qframe; @@ -96,9 +117,17 @@ void QWebFramePrivate::init(QWebFrame *qframe, WebCore::Page *webcorePage, QWebF frameLoaderClient = new FrameLoaderClientQt(); RefPtr<Frame> newFrame = Frame::create(webcorePage, frameData->ownerElement, frameLoaderClient); frame = newFrame.get(); - if (frameData->ownerElement) - frame->ref(); // balanced by adoptRef in FrameLoaderClientQt::createFrame frameLoaderClient->setFrame(qframe, frame); + + // 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); + + // balanced by adoptRef in FrameLoaderClientQt::createFrame + if (frameData->ownerElement) + frame->ref(); + frame->init(); } @@ -116,16 +145,34 @@ WebCore::Scrollbar* QWebFramePrivate::verticalScrollBar() const return frame->view()->verticalScrollbar(); } -void QWebFramePrivate::updateBackground() +void QWebFramePrivate::renderPrivate(QPainter *painter, const QRegion &clip, bool contents) { - WebCore::FrameView *view = frame->view(); - if (!view) + if (!frame->view() || !frame->contentRenderer()) return; - QBrush brush = page->palette().brush(QPalette::Background); - if (brush.style() == Qt::SolidPattern) { - view->setBaseBackgroundColor(brush.color()); - if (!brush.color().alpha()) - view->setTransparent(true); + + QVector<QRect> vector = clip.rects(); + if (vector.isEmpty()) + return; + + WebCore::FrameView* view = frame->view(); + view->layoutIfNeededRecursive(); + + GraphicsContext context(painter); + + if (!contents) + view->paint(&context, vector.first()); + else + view->paintContents(&context, vector.first()); + + for (int i = 1; i < vector.size(); ++i) { + const QRect& clipRect = vector.at(i); + painter->save(); + painter->setClipRect(clipRect, Qt::IntersectClip); + if (!contents) + view->paint(&context, clipRect); + else + view->paintContents(&context, clipRect); + painter->restore(); } } @@ -222,7 +269,7 @@ void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object JSC::ExecState* exec = window->globalExec(); JSC::JSObject *runtimeObject = - JSC::Bindings::Instance::createRuntimeObject(exec, JSC::Bindings::QtInstance::getQtInstance(object, root)); + JSC::Bindings::QtInstance::getQtInstance(object, root)->createRuntimeObject(exec); JSC::PutPropertySlot slot; window->put(exec, JSC::Identifier(exec, (const UChar *) name.constData(), name.length()), runtimeObject, slot); @@ -280,6 +327,53 @@ QString QWebFrame::title() const else return QString(); } +/*! + \since 4.5 + \brief Returns the meta data in this frame as a QMultiMap + + The meta data consists of the name and content attributes of the + of the \c{<meta>} tags in the HTML document. + + For example: + + \code + <html> + <head> + <meta name="description" content="This document is a tutorial about Qt development"> + <meta name="keywords" content="Qt, WebKit, Programming"> + </head> + ... + </html> + \endcode + + Given the above HTML code the metaData() function will return a map with two entries: + \table + \header \o Key + \o Value + \row \o "description" + \o "This document is a tutorial about Qt development" + \row \o "keywords" + \o "Qt, WebKit, Programming" + \endtable + + This function returns a multi map to support multiple meta tags with the same attribute name. +*/ +QMultiMap<QString, QString> QWebFrame::metaData() const +{ + if(!d->frame->document()) + return QMap<QString,QString>(); + + QMultiMap<QString,QString> map; + Document* doc = d->frame->document(); + RefPtr<NodeList> list = doc->getElementsByTagName("meta"); + unsigned len = list->length(); + for (unsigned i = 0; i < len; i++) { + HTMLMetaElement* meta = static_cast<HTMLMetaElement*>(list->item(i)); + map.insert(meta->name(), meta->content()); + } + return map; +} + static inline QUrl ensureAbsoluteUrl(const QUrl &url) { if (!url.isRelative()) @@ -446,7 +540,7 @@ 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. + URLs in the document, such as referenced images or stylesheets. 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 @@ -542,12 +636,16 @@ void QWebFrame::setScrollBarPolicy(Qt::Orientation orientation, Qt::ScrollBarPol if (orientation == Qt::Horizontal) { d->horizontalScrollBarPolicy = policy; - if (d->frame->view()) + if (d->frame->view()) { d->frame->view()->setHorizontalScrollbarMode((ScrollbarMode)policy); + d->frame->view()->updateDefaultScrollbarState(); + } } else { d->verticalScrollBarPolicy = policy; - if (d->frame->view()) + if (d->frame->view()) { d->frame->view()->setVerticalScrollbarMode((ScrollbarMode)policy); + d->frame->view()->updateDefaultScrollbarState(); + } } } @@ -617,14 +715,29 @@ int QWebFrame::scrollBarMinimum(Qt::Orientation orientation) const } /*! + \since 4.6 + Returns the geometry for the scrollbar with orientation \a orientation. + + If the scrollbar does not exist an empty rect is returned. +*/ +QRect QWebFrame::scrollBarGeometry(Qt::Orientation orientation) const +{ + Scrollbar *sb; + sb = (orientation == Qt::Horizontal) ? d->horizontalScrollBar() : d->verticalScrollBar(); + if (sb) + return sb->frameRect(); + return QRect(); +} + +/*! \since 4.5 Scrolls the frame \a dx pixels to the right and \a dy pixels downward. Both \a dx and \a dy may be negative. - \sa QWebFrame::scrollOffset + \sa QWebFrame::scrollPosition */ -void QWebFrame::scroll(int dx, int dy) const +void QWebFrame::scroll(int dx, int dy) { if (!d->frame->view()) return; @@ -633,23 +746,25 @@ void QWebFrame::scroll(int dx, int dy) const } /*! - \property QWebFrame::scrollOffset - \brief The offset from the start this frame is currently scrolled to. + \property QWebFrame::scrollPosition + \since 4.5 + \brief the position the frame is currently scrolled to. */ -QSize QWebFrame::scrollOffset() const +QPoint QWebFrame::scrollPosition() const { if (!d->frame->view()) - return QSize(0,0); + return QPoint(0,0); - return d->frame->view()->scrollOffset(); + IntSize ofs = d->frame->view()->scrollOffset(); + return QPoint(ofs.width(), ofs.height()); } -void QWebFrame::setScrollOffset(const QSize &offset) const +void QWebFrame::setScrollPosition(const QPoint &pos) { - QSize current = scrollOffset(); - int dx = offset.width() - current.width(); - int dy = offset.height() - current.height(); + QPoint current = scrollPosition(); + int dx = pos.x() - current.x(); + int dy = pos.y() - current.y(); scroll(dx, dy); } @@ -660,25 +775,7 @@ void QWebFrame::setScrollOffset(const QSize &offset) const */ void QWebFrame::render(QPainter *painter, const QRegion &clip) { - if (!d->frame->view() || !d->frame->contentRenderer()) - return; - - d->frame->view()->layoutIfNeededRecursive(); - - GraphicsContext ctx(painter); - QVector<QRect> vector = clip.rects(); - WebCore::FrameView* view = d->frame->view(); - for (int i = 0; i < vector.size(); ++i) { - if (i > 0) { - painter->save(); - painter->setClipRect(vector.at(i), Qt::IntersectClip); - } - - view->paint(&ctx, vector.at(i)); - - if (i > 0) - painter->restore(); - } + d->renderPrivate(painter, clip); } /*! @@ -686,14 +783,19 @@ void QWebFrame::render(QPainter *painter, const QRegion &clip) */ void QWebFrame::render(QPainter *painter) { - if (!d->frame->view() || !d->frame->contentRenderer()) + if (!d->frame->view()) return; - d->frame->view()->layoutIfNeededRecursive(); + d->renderPrivate(painter, QRegion(d->frame->view()->frameRect())); +} - GraphicsContext ctx(painter); - WebCore::FrameView* view = d->frame->view(); - view->paint(&ctx, view->frameRect()); +/*! + \since 4.6 + Render the frame's \a contents into \a painter while clipping to \a contents. +*/ +void QWebFrame::renderContents(QPainter *painter, const QRegion &contents) +{ + d->renderPrivate(painter, contents, true); } /*! @@ -708,11 +810,18 @@ void QWebFrame::render(QPainter *painter) QWebSettings. */ +/*! + Sets the value of the multiplier used to scale the text in a Web frame to + the \a factor specified. +*/ void QWebFrame::setTextSizeMultiplier(qreal factor) { d->frame->setZoomFactor(factor, /*isTextOnly*/true); } +/*! + Returns the value of the multiplier used to scale the text in a Web frame. +*/ qreal QWebFrame::textSizeMultiplier() const { return d->frame->zoomFactor(); @@ -758,6 +867,8 @@ QRect QWebFrame::geometry() const /*! \property QWebFrame::contentsSize \brief the size of the contents in this frame + + \sa contentsSizeChanged */ QSize QWebFrame::contentsSize() const { @@ -886,7 +997,7 @@ QVariant QWebFrame::evaluateJavaScript(const QString& scriptSource) ScriptController *proxy = d->frame->script(); QVariant rc; if (proxy) { - JSC::JSValue* v = proxy->evaluate(String(), 1, scriptSource); + JSC::JSValuePtr v = proxy->evaluate(ScriptSourceCode(scriptSource)).jsValue(); if (v) { int distance = 0; rc = JSC::Bindings::convertValueToQVariant(proxy->globalObject()->globalExec(), v, QMetaType::Void, &distance); @@ -895,6 +1006,18 @@ QVariant QWebFrame::evaluateJavaScript(const QString& scriptSource) return rc; } +/*! + \since 4.5 + + Returns the frame's security origin. +*/ +QWebSecurityOrigin QWebFrame::securityOrigin() const +{ + QWebFrame* that = const_cast<QWebFrame*>(this); + QWebSecurityOriginPrivate* priv = new QWebSecurityOriginPrivate(QWebFramePrivate::core(that)->document()->securityOrigin()); + return QWebSecurityOrigin(priv); +} + WebCore::Frame* QWebFramePrivate::core(QWebFrame* webFrame) { return webFrame->d->frame; @@ -960,14 +1083,12 @@ QWebFrame* QWebFramePrivate::kit(WebCore::Frame* coreFrame) */ /*! - \since 4.5 - \fn void QWebFrame::aboutToUpdateHistory(QWebHistoryItem* item); + \fn void QWebFrame::contentsSizeChanged(const QSize &size) + \since 4.6 - This signal is emitted shortly before the history of navigated pages - is changed, for example when navigating back in the history. + This signal is emitted when the frame's contents size changes. - A potential use-case for this signal is to store custom data in - the QWebHistoryItem associated to the frame, using QWebHistoryItem::setUserData(). + \sa contentsSize() */ /*! @@ -991,6 +1112,7 @@ QWebHitTestResult::QWebHitTestResult(QWebHitTestResultPrivate *priv) QWebHitTestResultPrivate::QWebHitTestResultPrivate(const WebCore::HitTestResult &hitTest) : isContentEditable(false) , isContentSelected(false) + , isScrollBar(false) { if (!hitTest.innerNode()) return; @@ -1002,6 +1124,7 @@ QWebHitTestResultPrivate::QWebHitTestResultPrivate(const WebCore::HitTestResult linkTitle = hitTest.titleDisplayString(); alternateText = hitTest.altDisplayString(); imageUrl = hitTest.absoluteImageURL(); + innerNode = hitTest.innerNode(); innerNonSharedNode = hitTest.innerNonSharedNode(); WebCore::Image *img = hitTest.image(); if (img) { @@ -1015,10 +1138,20 @@ QWebHitTestResultPrivate::QWebHitTestResultPrivate(const WebCore::HitTestResult isContentEditable = hitTest.isContentEditable(); isContentSelected = hitTest.isSelected(); + isScrollBar = hitTest.scrollbar(); if (innerNonSharedNode && innerNonSharedNode->document() && 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(); + } } /*! @@ -1085,7 +1218,7 @@ QPoint QWebHitTestResult::pos() const /*! \since 4.5 - Returns the bounding box of the element. + Returns the bounding rect of the element. */ QRect QWebHitTestResult::boundingRect() const { @@ -1095,6 +1228,17 @@ QRect QWebHitTestResult::boundingRect() const } /*! + \since 4.6 + Returns the rect of the smallest enclosing block element. +*/ +QRect QWebHitTestResult::enclosingBlock() const +{ + if (!d) + return QRect(); + return d->enclosingBlock; +} + +/*! Returns the title of the nearest enclosing HTML element. */ QString QWebHitTestResult::title() const @@ -1205,3 +1349,13 @@ QWebFrame *QWebHitTestResult::frame() const return d->frame; } +/*! + \since 4.6 + Returns true if the test includes a scrollbar. +*/ +bool QWebHitTestResult::isScrollBar() const +{ + if (!d) + return false; + return d->isScrollBar; +} diff --git a/WebKit/qt/Api/qwebframe.h b/WebKit/qt/Api/qwebframe.h index 4d37205..e53e2b5 100644 --- a/WebKit/qt/Api/qwebframe.h +++ b/WebKit/qt/Api/qwebframe.h @@ -47,6 +47,7 @@ class QWebFramePrivate; class QWebPage; class QWebHitTestResult; class QWebHistoryItem; +class QWebSecurityOrigin; namespace WebCore { class WidgetPrivate; @@ -69,6 +70,7 @@ public: QPoint pos() const; QRect boundingRect() const; + QRect enclosingBlock() const; QString title() const; QString linkText() const; @@ -86,6 +88,8 @@ public: QWebFrame *frame() const; + bool isScrollBar() const; + private: QWebHitTestResult(QWebHitTestResultPrivate *priv); QWebHitTestResultPrivate *d; @@ -104,7 +108,7 @@ class QWEBKIT_EXPORT QWebFrame : public QObject Q_PROPERTY(QUrl url READ url WRITE setUrl) Q_PROPERTY(QIcon icon READ icon) Q_PROPERTY(QSize contentsSize READ contentsSize) - Q_PROPERTY(QSize scrollOffset READ scrollOffset WRITE setScrollOffset) + Q_PROPERTY(QPoint scrollPosition READ scrollPosition WRITE setScrollPosition) private: QWebFrame(QWebPage *parent, QWebFrameData *frameData); QWebFrame(QWebFrame *parent, QWebFrameData *frameData); @@ -133,6 +137,7 @@ public: void setUrl(const QUrl &url); QUrl url() const; QIcon icon() const; + QMultiMap<QString, QString> metaData() const; QString frameName() const; @@ -146,13 +151,15 @@ public: int scrollBarValue(Qt::Orientation orientation) const; int scrollBarMinimum(Qt::Orientation orientation) const; int scrollBarMaximum(Qt::Orientation orientation) const; + QRect scrollBarGeometry(Qt::Orientation orientation) const; - void scroll(int, int) const; - QSize scrollOffset() const; - void setScrollOffset(const QSize &offset) const; + void scroll(int, int); + QPoint scrollPosition() const; + void setScrollPosition(const QPoint &pos); void render(QPainter *painter, const QRegion &clip); void render(QPainter *painter); + void renderContents(QPainter *painter, const QRegion &contents); void setTextSizeMultiplier(qreal factor); qreal textSizeMultiplier() const; @@ -168,6 +175,8 @@ public: virtual bool event(QEvent *); + QWebSecurityOrigin securityOrigin() const; + public Q_SLOTS: QVariant evaluateJavaScript(const QString& scriptSource); #ifndef QT_NO_PRINTER @@ -185,7 +194,7 @@ Q_SIGNALS: void iconChanged(); - void aboutToUpdateHistory(QWebHistoryItem* item); + void contentsSizeChanged(const QSize &size); private: friend class QWebPage; diff --git a/WebKit/qt/Api/qwebframe_p.h b/WebKit/qt/Api/qwebframe_p.h index 2b497e6..30f94cf 100644 --- a/WebKit/qt/Api/qwebframe_p.h +++ b/WebKit/qt/Api/qwebframe_p.h @@ -78,11 +78,11 @@ public: Qt::ScrollBarPolicy horizontalScrollBarPolicy; Qt::ScrollBarPolicy verticalScrollBarPolicy; - void updateBackground(); - static WebCore::Frame* core(QWebFrame*); static QWebFrame* kit(WebCore::Frame*); + void renderPrivate(QPainter *painter, const QRegion &clip, bool contents = false); + QWebFrame *q; WebCore::FrameLoaderClientQt *frameLoaderClient; WebCore::Frame *frame; @@ -96,11 +96,12 @@ public: class QWebHitTestResultPrivate { public: - QWebHitTestResultPrivate() : isContentEditable(false), isContentSelected(false) {} + QWebHitTestResultPrivate() : isContentEditable(false), isContentSelected(false), isScrollBar(false) {} QWebHitTestResultPrivate(const WebCore::HitTestResult &hitTest); QPoint pos; QRect boundingRect; + QRect enclosingBlock; QString title; QString linkText; QUrl linkUrl; @@ -111,7 +112,9 @@ public: QPixmap pixmap; bool isContentEditable; bool isContentSelected; + bool isScrollBar; QPointer<QWebFrame> frame; + RefPtr<WebCore::Node> innerNode; RefPtr<WebCore::Node> innerNonSharedNode; }; diff --git a/WebKit/qt/Api/qwebhistory.cpp b/WebKit/qt/Api/qwebhistory.cpp index 962aeb2..07d027d 100644 --- a/WebKit/qt/Api/qwebhistory.cpp +++ b/WebKit/qt/Api/qwebhistory.cpp @@ -23,6 +23,7 @@ #include "PlatformString.h" #include "Image.h" +#include "KURL.h" #include "Page.h" #include "PageGroup.h" @@ -160,7 +161,7 @@ QVariant QWebHistoryItem::userData() const /*! \since 4.5 - Stores user specific data with the history item. + Stores user specific data \a userData with the history item. \sa userData() */ @@ -431,7 +432,7 @@ int QWebHistory::maximumItemCount() const /*! \since 4.5 - Sets the maximum number of items in the history. + Sets the maximum number of items in the history to \a count. \sa maximumItemCount() */ diff --git a/WebKit/qt/Api/qwebhistory.h b/WebKit/qt/Api/qwebhistory.h index 2747c90..c39077d 100644 --- a/WebKit/qt/Api/qwebhistory.h +++ b/WebKit/qt/Api/qwebhistory.h @@ -32,7 +32,7 @@ class QWebPage; namespace WebCore { class FrameLoaderClientQt; -}; +} class QWebHistoryItemPrivate; class QWEBKIT_EXPORT QWebHistoryItem diff --git a/WebKit/qt/Api/qwebkitglobal.h b/WebKit/qt/Api/qwebkitglobal.h index 2486fb6..19d9218 100644 --- a/WebKit/qt/Api/qwebkitglobal.h +++ b/WebKit/qt/Api/qwebkitglobal.h @@ -23,15 +23,29 @@ #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 +# endif #endif #if !defined(QWEBKIT_EXPORT) -#define QWEBKIT_EXPORT Q_DECL_EXPORT +# if defined(QT_SHARED) +# define QWEBKIT_EXPORT Q_DECL_EXPORT +# else +# define QWEBKIT_EXPORT +# endif #endif #if QT_VERSION < 0x040400 diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp index b7285d6..df40fa6 100644 --- a/WebKit/qt/Api/qwebpage.cpp +++ b/WebKit/qt/Api/qwebpage.cpp @@ -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. Copyright (C) 2007 Apple Inc. @@ -31,6 +31,7 @@ #include "Frame.h" #include "FrameTree.h" +#include "FrameLoader.h" #include "FrameLoaderClientQt.h" #include "FrameView.h" #include "ChromeClientQt.h" @@ -95,6 +96,22 @@ using namespace WebCore; +bool QWebPagePrivate::drtRun = false; +void QWEBKIT_EXPORT qt_drt_run(bool b) +{ + QWebPagePrivate::drtRun = b; +} + +void QWEBKIT_EXPORT qt_webpage_setGroupName(QWebPage* page, const QString& groupName) +{ + page->handle()->page->setGroupName(groupName); +} + +QString QWEBKIT_EXPORT qt_webpage_groupName(QWebPage* page) +{ + return page->handle()->page->groupName(); +} + // Lookup table mapping QWebPage::WebActions to the associated Editor commands static const char* editorCommandWebActions[] = { @@ -161,11 +178,13 @@ static const char* editorCommandWebActions[] = "InsertNewline", // InsertParagraphSeparator "InsertLineBreak", // InsertLineSeparator + "SelectAll", // SelectAll + 0 // WebActionCount }; // Lookup the appropriate editor command to use for WebAction \a action -static const char* editorCommandForWebActions(QWebPage::WebAction action) +const char* QWebPagePrivate::editorCommandForWebActions(QWebPage::WebAction action) { if ((action > QWebPage::NoWebAction) && (action < int(sizeof(editorCommandWebActions) / sizeof(const char*)))) return editorCommandWebActions[action]; @@ -220,6 +239,7 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq) WebCore::InitializeLoggingChannelsIfNecessary(); WebCore::PageGroup::setShouldTrackVisitedLinks(true); JSC::initializeThreading(); + WebCore::FrameLoader::setLocalLoadPolicy(WebCore::FrameLoader::AllowLocalLoadsForLocalAndSubstituteData); chromeClient = new ChromeClientQt(q); contextMenuClient = new ContextMenuClientQt(); @@ -245,6 +265,7 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq) insideOpenCall = false; forwardUnsupportedContent = false; editable = false; + useFixedLayout = false; linkPolicy = QWebPage::DontDelegateLinks; #ifndef QT_NO_CONTEXTMENU currentContextMenu = 0; @@ -448,6 +469,35 @@ void QWebPagePrivate::updateAction(QWebPage::WebAction action) // those two are handled by QUndoStack break; #endif // QT_NO_UNDOSTACK + case QWebPage::MoveToNextChar: + case QWebPage::MoveToPreviousChar: + case QWebPage::MoveToNextWord: + case QWebPage::MoveToPreviousWord: + case QWebPage::MoveToNextLine: + case QWebPage::MoveToPreviousLine: + case QWebPage::MoveToStartOfLine: + case QWebPage::MoveToEndOfLine: + case QWebPage::MoveToStartOfBlock: + case QWebPage::MoveToEndOfBlock: + case QWebPage::MoveToStartOfDocument: + case QWebPage::MoveToEndOfDocument: + case QWebPage::SelectNextChar: + case QWebPage::SelectPreviousChar: + case QWebPage::SelectNextWord: + case QWebPage::SelectPreviousWord: + case QWebPage::SelectNextLine: + case QWebPage::SelectPreviousLine: + case QWebPage::SelectStartOfLine: + case QWebPage::SelectEndOfLine: + case QWebPage::SelectStartOfBlock: + case QWebPage::SelectEndOfBlock: + case QWebPage::SelectStartOfDocument: + case QWebPage::SelectEndOfDocument: + case QWebPage::DeleteStartOfWord: + case QWebPage::DeleteEndOfWord: + case QWebPage::SetTextDirectionDefault: + case QWebPage::SetTextDirectionLeftToRight: + case QWebPage::SetTextDirectionRightToLeft: case QWebPage::ToggleBold: case QWebPage::ToggleItalic: case QWebPage::ToggleUnderline: @@ -479,6 +529,35 @@ void QWebPagePrivate::updateEditorActions() updateAction(QWebPage::Cut); updateAction(QWebPage::Copy); updateAction(QWebPage::Paste); + updateAction(QWebPage::MoveToNextChar); + updateAction(QWebPage::MoveToPreviousChar); + updateAction(QWebPage::MoveToNextWord); + updateAction(QWebPage::MoveToPreviousWord); + updateAction(QWebPage::MoveToNextLine); + updateAction(QWebPage::MoveToPreviousLine); + updateAction(QWebPage::MoveToStartOfLine); + updateAction(QWebPage::MoveToEndOfLine); + updateAction(QWebPage::MoveToStartOfBlock); + updateAction(QWebPage::MoveToEndOfBlock); + updateAction(QWebPage::MoveToStartOfDocument); + updateAction(QWebPage::MoveToEndOfDocument); + updateAction(QWebPage::SelectNextChar); + updateAction(QWebPage::SelectPreviousChar); + updateAction(QWebPage::SelectNextWord); + updateAction(QWebPage::SelectPreviousWord); + updateAction(QWebPage::SelectNextLine); + updateAction(QWebPage::SelectPreviousLine); + updateAction(QWebPage::SelectStartOfLine); + updateAction(QWebPage::SelectEndOfLine); + updateAction(QWebPage::SelectStartOfBlock); + updateAction(QWebPage::SelectEndOfBlock); + updateAction(QWebPage::SelectStartOfDocument); + updateAction(QWebPage::SelectEndOfDocument); + updateAction(QWebPage::DeleteStartOfWord); + updateAction(QWebPage::DeleteEndOfWord); + updateAction(QWebPage::SetTextDirectionDefault); + updateAction(QWebPage::SetTextDirectionLeftToRight); + updateAction(QWebPage::SetTextDirectionRightToLeft); updateAction(QWebPage::ToggleBold); updateAction(QWebPage::ToggleItalic); updateAction(QWebPage::ToggleUnderline); @@ -516,7 +595,11 @@ void QWebPagePrivate::mousePressEvent(QMouseEvent *ev) return; } - bool accepted = frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(ev, 1)); + bool accepted = false; + PlatformMouseEvent mev(ev, 1); + // ignore the event if we can't map Qt's mouse buttons to WebCore::MouseButton + if (mev.button() != NoButton) + accepted = frame->eventHandler()->handleMousePressEvent(mev); ev->setAccepted(accepted); } @@ -526,7 +609,11 @@ void QWebPagePrivate::mouseDoubleClickEvent(QMouseEvent *ev) if (!frame->view()) return; - bool accepted = frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(ev, 2)); + bool accepted = false; + PlatformMouseEvent mev(ev, 2); + // ignore the event if we can't map Qt's mouse buttons to WebCore::MouseButton + if (mev.button() != NoButton) + accepted = frame->eventHandler()->handleMousePressEvent(mev); ev->setAccepted(accepted); tripleClickTimer.start(QApplication::doubleClickInterval(), q); @@ -539,7 +626,11 @@ void QWebPagePrivate::mouseTripleClickEvent(QMouseEvent *ev) if (!frame->view()) return; - bool accepted = frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(ev, 3)); + bool accepted = false; + PlatformMouseEvent mev(ev, 3); + // ignore the event if we can't map Qt's mouse buttons to WebCore::MouseButton + if (mev.button() != NoButton) + accepted = frame->eventHandler()->handleMousePressEvent(mev); ev->setAccepted(accepted); } @@ -549,7 +640,11 @@ void QWebPagePrivate::mouseReleaseEvent(QMouseEvent *ev) if (!frame->view()) return; - bool accepted = frame->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(ev, 0)); + bool accepted = false; + PlatformMouseEvent mev(ev, 0); + // ignore the event if we can't map Qt's mouse buttons to WebCore::MouseButton + if (mev.button() != NoButton) + accepted = frame->eventHandler()->handleMouseReleaseEvent(mev); ev->setAccepted(accepted); #ifndef QT_NO_CLIPBOARD @@ -616,7 +711,7 @@ void QWebPagePrivate::wheelEvent(QWheelEvent *ev) #endif // QT_NO_WHEELEVENT #ifndef QT_NO_SHORTCUT -static QWebPage::WebAction editorActionForKeyEvent(QKeyEvent* event) +QWebPage::WebAction QWebPagePrivate::editorActionForKeyEvent(QKeyEvent* event) { static struct { QKeySequence::StandardKey standardKey; @@ -657,6 +752,7 @@ static QWebPage::WebAction editorActionForKeyEvent(QKeyEvent* event) { QKeySequence::InsertParagraphSeparator, QWebPage::InsertParagraphSeparator }, { QKeySequence::InsertLineSeparator, QWebPage::InsertLineSeparator }, #endif + { QKeySequence::SelectAll, QWebPage::SelectAll }, { QKeySequence::UnknownKey, QWebPage::NoWebAction } }; @@ -673,20 +769,9 @@ void QWebPagePrivate::keyPressEvent(QKeyEvent *ev) bool handled = false; WebCore::Frame* frame = page->focusController()->focusedOrMainFrame(); WebCore::Editor* editor = frame->editor(); -#ifndef QT_NO_SHORTCUT - if (editor->canEdit()) { - QWebPage::WebAction action = editorActionForKeyEvent(ev); - if (action != QWebPage::NoWebAction) { - q->triggerAction(action); - handled = true; - } - } else { - if (ev == QKeySequence::Copy) { - q->triggerAction(QWebPage::Copy); - handled = true; - } - } -#endif // QT_NO_SHORTCUT + // we forward the key event to WebCore first to handle potential DOM + // defined event handlers and later on end up in EditorClientQt::handleKeyboardEvent + // to trigger editor commands via triggerAction(). if (!handled) handled = frame->eventHandler()->keyEvent(ev); if (!handled) { @@ -727,9 +812,6 @@ void QWebPagePrivate::keyReleaseEvent(QKeyEvent *ev) void QWebPagePrivate::focusInEvent(QFocusEvent *ev) { - if (ev->reason() == Qt::PopupFocusReason) - return; - FocusController *focusController = page->focusController(); Frame *frame = focusController->focusedFrame(); focusController->setActive(true); @@ -742,9 +824,6 @@ void QWebPagePrivate::focusInEvent(QFocusEvent *ev) void QWebPagePrivate::focusOutEvent(QFocusEvent *ev) { - if (ev->reason() == Qt::PopupFocusReason) - return; - // only set the focused frame inactive so that we stop painting the caret // and the focus frame. But don't tell the focus controller so that upon // focusInEvent() we can re-activate the frame. @@ -813,15 +892,19 @@ void QWebPagePrivate::leaveEvent(QEvent *ev) \property QWebPage::palette \brief the page's palette - The background brush of the palette is used to draw the background of the main frame. + The base brush of the palette is used to draw the background of the main frame. By default, this property contains the application's default palette. */ void QWebPage::setPalette(const QPalette &pal) { d->palette = pal; - if (d->mainFrame) - d->mainFrame->d->updateBackground(); + if (!d->mainFrame || !d->mainFrame->d->frame->view()) + return; + + QBrush brush = pal.brush(QPalette::Base); + QColor backgroundColor = brush.style() == Qt::SolidPattern ? brush.color() : QColor(); + QWebFramePrivate::core(d->mainFrame)->view()->updateBackgroundRecursively(backgroundColor, !backgroundColor.alpha()); } QPalette QWebPage::palette() const @@ -956,7 +1039,7 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const case Qt::ImMicroFocus: { Frame *frame = d->page->focusController()->focusedFrame(); if (frame) { - return QVariant(frame->selection()->caretRect()); + return QVariant(frame->selection()->absoluteCaretBounds()); } return QVariant(); } @@ -1035,6 +1118,10 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const /*! \enum QWebPage::WebAction + This enum describes the types of action which can be performed on the web page. + Actions which are related to text editing, cursor movement, and text selection + only have an effect if \l contentEditable is true. + \value NoWebAction No action is triggered. \value OpenLink Open the current link. \value OpenLinkInNewWindow Open the current link in a new window. @@ -1088,6 +1175,7 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const \value InspectElement Show the Web Inspector with the currently highlighted HTML element. \value InsertParagraphSeparator Insert a new paragraph. \value InsertLineSeparator Insert a new line. + \value SelectAll Selects all content. \omitvalue WebActionCount */ @@ -1367,7 +1455,7 @@ void QWebPage::triggerAction(WebAction action, bool checked) 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, /*event*/ 0, + /*lockHistory*/ false, /*lockBackForwardList*/ false, /*event*/ 0, /*HTMLFormElement*/ 0, /*formValues*/ WTF::HashMap<String, String>()); break; @@ -1422,10 +1510,13 @@ void QWebPage::triggerAction(WebAction action, bool checked) editor->setBaseWritingDirection(RightToLeftWritingDirection); break; case InspectElement: - d->page->inspectorController()->inspect(d->hitTestResult.d->innerNonSharedNode.get()); + if (!d->hitTestResult.isNull()) + d->page->inspectorController()->inspect(d->hitTestResult.d->innerNonSharedNode.get()); + else + d->page->inspectorController()->show(); break; default: - command = editorCommandForWebActions(action); + command = QWebPagePrivate::editorCommandForWebActions(action); break; } @@ -1464,6 +1555,56 @@ void QWebPage::setViewportSize(const QSize &size) const } } +QSize QWebPage::fixedLayoutSize() const +{ + if (d->mainFrame && d->mainFrame->d->frame->view()) + return d->mainFrame->d->frame->view()->fixedLayoutSize(); + + return d->fixedLayoutSize; +} + +/*! + \property QWebPage::fixedLayoutSize + \since 4.6 + \brief the size of the fixed layout + + The size affects the layout of the page in the viewport. If set to a fixed size of + 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 +{ + d->fixedLayoutSize = size; + + QWebFrame *frame = mainFrame(); + if (frame->d->frame && frame->d->frame->view()) { + WebCore::FrameView* view = frame->d->frame->view(); + view->setFixedLayoutSize(size); + frame->d->frame->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); + frame->d->frame->forceLayout(); + } +} /*! \fn bool QWebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type) @@ -1614,32 +1755,83 @@ QAction *QWebPage::action(WebAction action) const } #endif // QT_NO_UNDOSTACK case MoveToNextChar: + text = tr("Move the cursor to the next character"); + break; case MoveToPreviousChar: + text = tr("Move the cursor to the previous character"); + break; case MoveToNextWord: + text = tr("Move the cursor to the next word"); + break; case MoveToPreviousWord: + text = tr("Move the cursor to the previous word"); + break; case MoveToNextLine: + text = tr("Move the cursor to the next line"); + break; case MoveToPreviousLine: + text = tr("Move the cursor to the previous line"); + break; case MoveToStartOfLine: + text = tr("Move the cursor to the start of the line"); + break; case MoveToEndOfLine: + text = tr("Move the cursor to the end of the line"); + break; case MoveToStartOfBlock: + text = tr("Move the cursor to the start of the block"); + break; case MoveToEndOfBlock: + text = tr("Move the cursor to the end of the block"); + break; case MoveToStartOfDocument: + text = tr("Move the cursor to the start of the document"); + break; case MoveToEndOfDocument: + text = tr("Move the cursor to the end of the document"); + break; case SelectNextChar: + text = tr("Select to the next character"); + break; case SelectPreviousChar: + text = tr("Select to the previous character"); + break; case SelectNextWord: + text = tr("Select to the next word"); + break; case SelectPreviousWord: + text = tr("Select to the previous word"); + break; case SelectNextLine: + text = tr("Select to the next line"); + break; case SelectPreviousLine: + text = tr("Select to the previous line"); + break; case SelectStartOfLine: + text = tr("Select to the start of the line"); + break; case SelectEndOfLine: + text = tr("Select to the end of the line"); + break; case SelectStartOfBlock: + text = tr("Select to the start of the block"); + break; case SelectEndOfBlock: + text = tr("Select to the end of the block"); + break; case SelectStartOfDocument: + text = tr("Select to the start of the document"); + break; case SelectEndOfDocument: + text = tr("Select to the end of the document"); + break; case DeleteStartOfWord: + text = tr("Delete to the start of the word"); + break; case DeleteEndOfWord: - break; // #### + text = tr("Delete to the end of the word"); + break; case SetTextDirectionDefault: text = contextMenuItemTagDefaultDirection(); @@ -1813,7 +2005,7 @@ bool QWebPage::focusNextPrevChild(bool next) } /*! - \property QWebPage::editable + \property QWebPage::contentEditable \brief whether the content in this QWebPage is editable or not \since 4.5 @@ -1821,7 +2013,7 @@ bool QWebPage::focusNextPrevChild(bool next) cursor. If disabled (the default) only HTML elements in the web page with their \c{contenteditable} attribute set are editable. */ -void QWebPage::setEditable(bool editable) +void QWebPage::setContentEditable(bool editable) { if (d->editable != editable) { d->editable = editable; @@ -1841,7 +2033,7 @@ void QWebPage::setEditable(bool editable) } } -bool QWebPage::isEditable() const +bool QWebPage::isContentEditable() const { return d->editable; } @@ -1974,7 +2166,11 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) This enum describes the types of extensions that the page can support. Before using these extensions, you should verify that the extension is supported by calling supportsExtension(). - Currently there are no extensions. + \value ChooseMultipleFilesExtension Whether the web page supports multiple file selection. + This extension is invoked when the web content requests one or more file names, for example + as a result of the user clicking on a "file upload" button in a HTML form where multiple + file selection is allowed. + */ /*! @@ -1986,11 +2182,27 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) */ /*! - \class QWebPage::ExtensionReturn - \since 4.4 - \brief The ExtensionOption class provides an extended output argument to QWebPage's extension support. + \class QWebPage::ChooseMultipleFilesExtensionOption + \since 4.5 + \brief The ChooseMultipleFilesExtensionOption class describes the option + for the multiple files selection extension. - \sa QWebPage::extension() + The ChooseMultipleFilesExtensionOption class holds the frame originating the request + and the suggested filenames which might be provided. + + \sa QWebPage::chooseFile(), QWebPage::ChooseMultipleFilesExtensionReturn +*/ + +/*! + \class QWebPage::ChooseMultipleFilesExtensionReturn + \since 4.5 + \brief The ChooseMultipleFilesExtensionReturn describes the return value + for the multiple files selection extension. + + The ChooseMultipleFilesExtensionReturn class holds the filenames selected by the user + when the extension is invoked. + + \sa QWebPage::ChooseMultipleFilesExtensionOption */ /*! @@ -2001,15 +2213,22 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) You can call supportsExtension() to check if an extension is supported by the page. - By default, no extensions are supported, and this function returns false. + Returns true if the extension was called successfully; otherwise returns false. \sa supportsExtension(), Extension */ bool QWebPage::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output) { - Q_UNUSED(extension) - Q_UNUSED(option) - Q_UNUSED(output) +#ifndef QT_NO_FILEDIALOG + if (extension == ChooseMultipleFilesExtension) { + // FIXME: do not ignore suggestedFiles + QStringList suggestedFiles = static_cast<const ChooseMultipleFilesExtensionOption*>(option)->suggestedFileNames; + QStringList names = QFileDialog::getOpenFileNames(d->view, QString::null); + static_cast<ChooseMultipleFilesExtensionReturn*>(output)->fileNames = names; + return true; + } +#endif + return false; } @@ -2020,8 +2239,12 @@ bool QWebPage::extension(Extension extension, const ExtensionOption *option, Ext */ bool QWebPage::supportsExtension(Extension extension) const { - Q_UNUSED(extension) +#ifndef QT_NO_FILEDIALOG + return extension == ChooseMultipleFilesExtension; +#else + Q_UNUSED(extension); return false; +#endif } /*! @@ -2155,8 +2378,8 @@ QWebPluginFactory *QWebPage::pluginFactory() const } /*! - This function is called when a user agent for HTTP requests is needed. You can re-implement this - function to dynamically return different user agent's for different urls, based on the \a url parameter. + This function is called when a user agent for HTTP requests is needed. You can reimplement this + function to dynamically return different user agents for different URLs, based on the \a url parameter. The default implementation returns the following value: @@ -2428,10 +2651,12 @@ quint64 QWebPage::bytesReceived() const { /*! \fn void QWebPage::contentsChanged() + \since 4.5 - This signal is emitted whenever the content changes during editing. + This signal is emitted whenever the text in form elements changes + as well as other editable content. - \sa selectedText() + \sa contentEditable, QWebFrame::toHtml(), QWebFrame::toPlainText() */ /*! @@ -2540,4 +2765,38 @@ quint64 QWebPage::bytesReceived() const { window that hosts QWebPage should be changed to \a visible. */ +/*! + \fn void QWebPage::databaseQuotaExceeded(QWebFrame* frame, QString databaseName); + \since 4.5 + + This signal is emitted whenever the web site shown in \a frame is asking to store data + to the database \a databaseName and the quota allocated to that web site is exceeded. +*/ + +/*! + \since 4.5 + \fn void QWebPage::saveFrameStateRequested(QWebFrame* frame, QWebHistoryItem* item); + + This signal is emitted shortly before the history of navigated pages + in \a frame is changed, for example when navigating back in the history. + + The provided QWebHistoryItem, \a item, holds the history entry of the frame before + the change. + + A potential use-case for this signal is to store custom data in + the QWebHistoryItem associated to the frame, using QWebHistoryItem::setUserData(). +*/ + +/*! + \since 4.5 + \fn void QWebPage::restoreFrameStateRequested(QWebFrame* frame); + + This signal is emitted when the load of \a frame is finished and the application may now update its state accordingly. +*/ + +/*! + \fn QWebPagePrivate* QWebPage::handle() const + \internal +*/ + #include "moc_qwebpage.cpp" diff --git a/WebKit/qt/Api/qwebpage.h b/WebKit/qt/Api/qwebpage.h index 5b978d8..2bbbc2a 100644 --- a/WebKit/qt/Api/qwebpage.h +++ b/WebKit/qt/Api/qwebpage.h @@ -46,6 +46,7 @@ class QWebFrameData; class QWebNetworkInterface; class QWebPluginFactory; class QWebHitTestResult; +class QWebHistoryItem; namespace WebCore { class ChromeClientQt; @@ -64,10 +65,12 @@ class QWEBKIT_EXPORT QWebPage : public QObject Q_PROPERTY(bool modified READ isModified) Q_PROPERTY(QString selectedText READ selectedText) Q_PROPERTY(QSize viewportSize READ viewportSize WRITE setViewportSize) + Q_PROPERTY(QSize fixedLayoutSize READ fixedLayoutSize WRITE setFixedLayoutSize) + Q_PROPERTY(bool useFixedLayout READ useFixedLayout WRITE setUseFixedLayout) Q_PROPERTY(bool forwardUnsupportedContent READ forwardUnsupportedContent WRITE setForwardUnsupportedContent) Q_PROPERTY(LinkDelegationPolicy linkDelegationPolicy READ linkDelegationPolicy WRITE setLinkDelegationPolicy) Q_PROPERTY(QPalette palette READ palette WRITE setPalette) - Q_PROPERTY(bool editable READ isEditable WRITE setEditable) + Q_PROPERTY(bool contentEditable READ isContentEditable WRITE setContentEditable) Q_ENUMS(LinkDelegationPolicy NavigationType WebAction) public: enum NavigationType { @@ -145,6 +148,8 @@ public: InsertParagraphSeparator, InsertLineSeparator, + SelectAll, + WebActionCount }; @@ -212,6 +217,12 @@ 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); + virtual bool event(QEvent*); bool focusNextPrevChild(bool next); @@ -228,8 +239,8 @@ public: void setPalette(const QPalette &palette); QPalette palette() const; - void setEditable(bool editable); - bool isEditable() const; + void setContentEditable(bool editable); + bool isContentEditable() const; #ifndef QT_NO_CONTEXTMENU bool swallowContextMenuEvent(QContextMenuEvent *event); @@ -239,14 +250,29 @@ public: QMenu *createStandardContextMenu(); enum Extension { + ChooseMultipleFilesExtension }; class ExtensionOption {}; class ExtensionReturn {}; + + class ChooseMultipleFilesExtensionOption : public ExtensionOption { + public: + QWebFrame *parentFrame; + QStringList suggestedFileNames; + }; + + class ChooseMultipleFilesExtensionReturn : public ExtensionReturn { + public: + QStringList fileNames; + }; + virtual bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0); virtual bool supportsExtension(Extension extension) const; + inline QWebPagePrivate* handle() const { return d; } + Q_SIGNALS: void loadStarted(); void loadProgress(int progress); @@ -274,6 +300,10 @@ Q_SIGNALS: void microFocusChanged(); void contentsChanged(); + void databaseQuotaExceeded(QWebFrame* frame, QString databaseName); + + void saveFrameStateRequested(QWebFrame* frame, QWebHistoryItem* item); + void restoreFrameStateRequested(QWebFrame* frame); protected: virtual QWebPage *createWindow(WebWindowType type); diff --git a/WebKit/qt/Api/qwebpage_p.h b/WebKit/qt/Api/qwebpage_p.h index 8fae81c..fd915a2 100644 --- a/WebKit/qt/Api/qwebpage_p.h +++ b/WebKit/qt/Api/qwebpage_p.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) 2008 Holger Hans Peter Freyther This library is free software; you can redistribute it and/or @@ -112,6 +112,11 @@ public: void leaveEvent(QEvent *); bool handleScrolling(QKeyEvent*); +#ifndef QT_NO_SHORTCUT + static QWebPage::WebAction editorActionForKeyEvent(QKeyEvent* event); +#endif + static const char* editorCommandForWebActions(QWebPage::WebAction action); + WebCore::ChromeClientQt *chromeClient; WebCore::ContextMenuClientQt *contextMenuClient; WebCore::EditorClientQt *editorClient; @@ -149,6 +154,7 @@ public: QWebPage::LinkDelegationPolicy linkPolicy; QSize viewportSize; + QSize fixedLayoutSize; QWebHistory history; QWebHitTestResult hitTestResult; #ifndef QT_NO_CONTEXTMENU @@ -157,10 +163,13 @@ public: QWebSettings *settings; QPalette palette; bool editable; + bool useFixedLayout; QAction *actions[QWebPage::WebActionCount]; QWebPluginFactory *pluginFactory; + + static bool drtRun; }; #endif diff --git a/WebKit/qt/Api/qwebpluginfactory.cpp b/WebKit/qt/Api/qwebpluginfactory.cpp index 0d2390c..d2bb124 100644 --- a/WebKit/qt/Api/qwebpluginfactory.cpp +++ b/WebKit/qt/Api/qwebpluginfactory.cpp @@ -136,7 +136,7 @@ void QWebPluginFactory::refreshPlugins() For example: \code - <object type="application/x-pdf" data="http://www.trolltech.com/document.pdf" width="500" height="400"> + <object type="application/x-pdf" data="http://qtsoftware.com/document.pdf" width="500" height="400"> <param name="showTableOfContents" value="true" /> <param name="hideThumbnails" value="false" /> </object> @@ -149,7 +149,7 @@ void QWebPluginFactory::refreshPlugins() \row \o mimeType \o "application/x-pdf" \row \o url - \o "http://www.trolltech.com/document.pdf" + \o "http://qtsoftware.com/document.pdf" \row \o argumentNames \o "showTableOfContents" "hideThumbnails" \row \o argumentVaues diff --git a/WebKit/qt/Api/qwebsecurityorigin.cpp b/WebKit/qt/Api/qwebsecurityorigin.cpp new file mode 100644 index 0000000..5217362 --- /dev/null +++ b/WebKit/qt/Api/qwebsecurityorigin.cpp @@ -0,0 +1,176 @@ +/* + Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" +#include "qwebsecurityorigin.h" +#include "qwebsecurityorigin_p.h" +#include "qwebdatabase.h" +#include "qwebdatabase_p.h" + +#include "DatabaseTracker.h" +#include "KURL.h" +#include "SecurityOrigin.h" +#include <QStringList> + +using namespace WebCore; + +/*! + \class QWebSecurityOrigin + \since 4.5 + \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 + + 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 + documents when used in HTML frame sets and JavaScript. At the same time it prevents + \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. + + For more information refer to the + \l{http://en.wikipedia.org/wiki/Same_origin_policy}{"Same origin policy" Wikipedia Article}. + + \sa QWebFrame::securityOrigin() +*/ + +/*! + Constructs a security origin from \a other. +*/ +QWebSecurityOrigin::QWebSecurityOrigin(const QWebSecurityOrigin& other) : d(other.d) +{ +} + +/*! + Assigns the \a other security origin to this. +*/ +QWebSecurityOrigin& QWebSecurityOrigin::operator=(const QWebSecurityOrigin& other) +{ + d = other.d; + return *this; +} + +/*! + Returns the scheme defining the security origin. +*/ +QString QWebSecurityOrigin::scheme() const +{ + return d->origin->protocol(); +} + +/*! + Returns the host name defining the security origin. +*/ +QString QWebSecurityOrigin::host() const +{ + return d->origin->host(); +} + +/*! + Returns the port number defining the security origin. +*/ +int QWebSecurityOrigin::port() const +{ + return d->origin->port(); +} + +/*! + Returns the number of bytes all databases in the security origin + use on the disk. +*/ +qint64 QWebSecurityOrigin::databaseUsage() const +{ + return DatabaseTracker::tracker().usageForOrigin(d->origin.get()); +} + +/*! + Returns the quota for the databases in the security origin. +*/ +qint64 QWebSecurityOrigin::databaseQuota() const +{ + return DatabaseTracker::tracker().quotaForOrigin(d->origin.get()); +} + +/*! + Sets the quota for the databases in the security origin to \a quota bytes. + + If the quota is set to a value less than the current usage, the quota will remain + and no data will be purged to meet the new quota. However, no new data can be added + to databases in this origin. +*/ +void QWebSecurityOrigin::setDatabaseQuota(qint64 quota) +{ + DatabaseTracker::tracker().setQuota(d->origin.get(), quota); +} + +/*! + Destroys the security origin. +*/ +QWebSecurityOrigin::~QWebSecurityOrigin() +{ +} + +/*! + \internal +*/ +QWebSecurityOrigin::QWebSecurityOrigin(QWebSecurityOriginPrivate* priv) +{ + d = priv; +} + +/*! + Returns a list of all security origins with a database quota defined. +*/ +QList<QWebSecurityOrigin> QWebSecurityOrigin::allOrigins() +{ + 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); + } + return webOrigins; +} + +/*! + Returns a list of all databases defined in the security origin. +*/ +QList<QWebDatabase> QWebSecurityOrigin::databases() const +{ + Vector<String> nameVector; + QList<QWebDatabase> databases; + if (!DatabaseTracker::tracker().databaseNamesForOrigin(d->origin.get(), nameVector)) + return databases; + for (unsigned i = 0; i < nameVector.size(); ++i) { + QWebDatabasePrivate* priv = new QWebDatabasePrivate(); + priv->name = nameVector[i]; + priv->origin = this->d->origin; + QWebDatabase webDatabase(priv); + databases.append(webDatabase); + } + return databases; +} + diff --git a/WebKit/qt/Api/qwebsecurityorigin.h b/WebKit/qt/Api/qwebsecurityorigin.h new file mode 100644 index 0000000..ebe4a77 --- /dev/null +++ b/WebKit/qt/Api/qwebsecurityorigin.h @@ -0,0 +1,67 @@ +/* + Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef _WEBSECURITYORIGIN_H_ +#define _WEBSECURITYORIGIN_H_ + +#include <QtCore/qurl.h> +#include <QtCore/qshareddata.h> + +#include "qwebkitglobal.h" + +namespace WebCore { + class SecurityOrigin; + class ChromeClientQt; +}; + +class QWebSecurityOriginPrivate; +class QWebDatabase; +class QWebFrame; + +class QWEBKIT_EXPORT QWebSecurityOrigin +{ +public: + static QList<QWebSecurityOrigin> allOrigins(); + + ~QWebSecurityOrigin(); + + QString scheme() const; + QString host() const; + int port() const; + + qint64 databaseUsage() const; + qint64 databaseQuota() const; + + void setDatabaseQuota(qint64 quota); + + QList<QWebDatabase> databases() const; + + QWebSecurityOrigin(const QWebSecurityOrigin& other); + QWebSecurityOrigin &operator=(const QWebSecurityOrigin& other); +private: + friend class QWebDatabase; + friend class QWebFrame; + friend class WebCore::ChromeClientQt; + QWebSecurityOrigin(QWebSecurityOriginPrivate* priv); + +private: + QExplicitlySharedDataPointer<QWebSecurityOriginPrivate> d; +}; + +#endif diff --git a/WebKit/qt/Api/qwebsecurityorigin_p.h b/WebKit/qt/Api/qwebsecurityorigin_p.h new file mode 100644 index 0000000..73fe8ed --- /dev/null +++ b/WebKit/qt/Api/qwebsecurityorigin_p.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef _WEBSECURITYORIGIN_P_H_ +#define _WEBSECURITYORIGIN_P_H_ + +#include "SecurityOrigin.h" +#include "RefPtr.h" + +class QWebSecurityOriginPrivate : public QSharedData +{ +public: + QWebSecurityOriginPrivate(WebCore::SecurityOrigin* o) + { + Q_ASSERT(o); + origin = o; + } + ~QWebSecurityOriginPrivate() + { + } + WTF::RefPtr<WebCore::SecurityOrigin> origin; +}; + +#endif diff --git a/WebKit/qt/Api/qwebsettings.cpp b/WebKit/qt/Api/qwebsettings.cpp index 132eb0c..42baf93 100644 --- a/WebKit/qt/Api/qwebsettings.cpp +++ b/WebKit/qt/Api/qwebsettings.cpp @@ -32,6 +32,8 @@ #include "IconDatabase.h" #include "Image.h" #include "IntSize.h" +#include "ApplicationCacheStorage.h" +#include "DatabaseTracker.h" #include <QHash> #include <QSharedData> @@ -50,6 +52,9 @@ public: QHash<int, int> fontSizes; QHash<int, bool> attributes; QUrl userStyleSheetLocation; + QString localStorageDatabasePath; + QString offlineWebApplicationCachePath; + qint64 offlineStorageDefaultQuota; void apply(); WebCore::Settings *settings; @@ -156,9 +161,28 @@ void QWebSettingsPrivate::apply() QUrl location = !userStyleSheetLocation.isEmpty() ? userStyleSheetLocation : global->userStyleSheetLocation; settings->setUserStyleSheetLocation(WebCore::KURL(location)); + QString localStoragePath = !localStorageDatabasePath.isEmpty() ? localStorageDatabasePath : global->localStorageDatabasePath; + settings->setLocalStorageDatabasePath(localStoragePath); + value = attributes.value(QWebSettings::ZoomTextOnly, global->attributes.value(QWebSettings::ZoomTextOnly)); settings->setZoomsTextOnly(value); + + value = attributes.value(QWebSettings::PrintElementBackgrounds, + global->attributes.value(QWebSettings::PrintElementBackgrounds)); + settings->setShouldPrintBackgrounds(value); + + value = attributes.value(QWebSettings::OfflineStorageDatabaseEnabled, + global->attributes.value(QWebSettings::OfflineStorageDatabaseEnabled)); + settings->setDatabasesEnabled(value); + + value = attributes.value(QWebSettings::OfflineWebApplicationCacheEnabled, + global->attributes.value(QWebSettings::OfflineWebApplicationCacheEnabled)); + settings->setOfflineWebApplicationCacheEnabled(value); + + value = attributes.value(QWebSettings::LocalStorageDatabaseEnabled, + global->attributes.value(QWebSettings::LocalStorageDatabaseEnabled)); + settings->setLocalStorageEnabled(value); } else { QList<QWebSettingsPrivate *> settings = *::allSettings(); for (int i = 0; i < settings.count(); ++i) @@ -195,9 +219,26 @@ QWebSettings *QWebSettings::globalSettings() family, the location of a custom stylesheet, and generic attributes like java script, plugins, etc. The \l{QWebSettings::WebAttribute}{WebAttribute} enum further describes this. - + QWebSettings also configures global properties such as the web page memory - cache and the web page icon database. + cache and the web page icon database, local database storage and offline + applications storage. + + \section1 Web Application Support + + WebKit provides support for features specified in \l{HTML 5} that improve the + performance and capabilities of Web applications. These include client-side + (offline) storage and the use of a Web application cache. + + Client-side (offline) storage is an improvement over the use of cookies to + store persistent data in Web applications. Applications can configure and + enable the use of an offline storage database by calling the + setOfflineStoragePath() with an appropriate file path, and can limit the quota + for each application by calling setOfflineStorageDefaultQuota(). + + The performance of Web applications can be enhanced with the use of an + offline cache. This can be enabled by calling setOfflineWebApplicationCache() + with an appropriate file path. \sa QWebPage::settings(), QWebView::settings(), {Browser} */ @@ -266,6 +307,14 @@ QWebSettings *QWebSettings::globalSettings() included in the keyboard focus chain. \value ZoomTextOnly Specifies whether the zoom factor on a frame applies to only the text or all content. + \value PrintElementBackgrounds Specifies whether the background color and images + are also drawn when the page is printed. + \value OfflineStorageDatabaseEnabled Specifies whether support for the HTML 5 + offline storage feature is enabled or not. + \value OfflineWebApplicationCacheEnabled Specifies whether support for the HTML 5 + web application cache feature is enabled or not. + \value LocalStorageDatabaseEnabled Specifies whether support for the HTML 5 + local storage feature is enabled or not. */ /*! @@ -275,9 +324,8 @@ QWebSettings::QWebSettings() : d(new QWebSettingsPrivate) { // Initialize our global defaults - // changing any of those will likely break the LayoutTests - d->fontSizes.insert(QWebSettings::MinimumFontSize, 5); - d->fontSizes.insert(QWebSettings::MinimumLogicalFontSize, 5); + d->fontSizes.insert(QWebSettings::MinimumFontSize, 0); + d->fontSizes.insert(QWebSettings::MinimumLogicalFontSize, 0); d->fontSizes.insert(QWebSettings::DefaultFontSize, 14); d->fontSizes.insert(QWebSettings::DefaultFixedFontSize, 14); d->fontFamilies.insert(QWebSettings::StandardFont, QLatin1String("Arial")); @@ -291,6 +339,12 @@ QWebSettings::QWebSettings() d->attributes.insert(QWebSettings::JavascriptEnabled, true); d->attributes.insert(QWebSettings::LinksIncludedInFocusChain, true); d->attributes.insert(QWebSettings::ZoomTextOnly, false); + d->attributes.insert(QWebSettings::PrintElementBackgrounds, true); + d->attributes.insert(QWebSettings::OfflineStorageDatabaseEnabled, true); + d->attributes.insert(QWebSettings::OfflineWebApplicationCacheEnabled, true); + d->attributes.insert(QWebSettings::LocalStorageDatabaseEnabled, true); + d->offlineStorageDefaultQuota = 5 * 1024 * 1024; + } /*! @@ -600,3 +654,130 @@ void QWebSettings::resetAttribute(WebAttribute attr) } } +/*! + \since 4.5 + + Sets the path for HTML5 offline storage to \a path. + + \a path must point to an existing directory where the databases are stored. + + Setting an empty path disables the feature. + + \sa offlineStoragePath() +*/ +void QWebSettings::setOfflineStoragePath(const QString& path) +{ +#if ENABLE(DATABASE) + WebCore::DatabaseTracker::tracker().setDatabaseDirectoryPath(path); +#endif +} + +/*! + \since 4.5 + + Returns the path of the HTML5 offline storage or an empty string if the + feature is disabled. + + \sa setOfflineStoragePath() +*/ +QString QWebSettings::offlineStoragePath() +{ +#if ENABLE(DATABASE) + return WebCore::DatabaseTracker::tracker().databaseDirectoryPath(); +#else + return QString(); +#endif +} + +/*! + \since 4.5 + + Sets the value of the default quota for new offline storage databases + to \a maximumSize. +*/ +void QWebSettings::setOfflineStorageDefaultQuota(qint64 maximumSize) +{ + QWebSettings::globalSettings()->d->offlineStorageDefaultQuota = maximumSize; +} + +/*! + \since 4.5 + + Returns the value of the default quota for new offline storage databases. +*/ +qint64 QWebSettings::offlineStorageDefaultQuota() +{ + return QWebSettings::globalSettings()->d->offlineStorageDefaultQuota; +} + +/*! + \since 4.5 + + Sets the path for HTML5 offline web application cache storage to \a path. + + \a path must point to an existing directory where the cache is stored. + + Setting an empty path disables the feature. + + \sa offlineWebApplicationCachePath() +*/ +void QWebSettings::setOfflineWebApplicationCachePath(const QString& path) +{ +#if ENABLE(OFFLINE_WEB_APPLICATIONS) + WebCore::cacheStorage().setCacheDirectory(path); +#endif +} + +/*! + \since 4.5 + + Returns the path of the HTML5 offline web application cache storage + or an empty string if the feature is disabled. + + \sa setOfflineWebApplicationCachePath() +*/ +QString QWebSettings::offlineWebApplicationCachePath() +{ +#if ENABLE(OFFLINE_WEB_APPLICATIONS) + return WebCore::cacheStorage().cacheDirectory(); +#else + return QString(); +#endif +} + +/* + \since 4.5 + + Sets the path for HTML5 local storage databases to \a path. + + \a path must point to an existing directory where the cache is stored. + + Setting an empty path disables the feature. + + \sa localStorageDatabasePath() +*/ + +void QWEBKIT_EXPORT qt_websettings_setLocalStorageDatabasePath(QWebSettings* settings, const QString& path) +{ + QWebSettingsPrivate *d = settings->handle(); + d->localStorageDatabasePath = path; + d->apply(); +} + +/* + \since 4.5 + + Returns the path for HTML5 local storage databases + or an empty string if the feature is disabled. + + \sa setLocalStorageDatabasePath() +*/ +QString QWEBKIT_EXPORT qt_websettings_localStorageDatabasePath(QWebSettings* settings) +{ + return settings->handle()->localStorageDatabasePath; +} + +/*! + \fn QWebSettingsPrivate* QWebSettings::handle() const + \internal +*/ diff --git a/WebKit/qt/Api/qwebsettings.h b/WebKit/qt/Api/qwebsettings.h index 9a75dbf..4251fbb 100644 --- a/WebKit/qt/Api/qwebsettings.h +++ b/WebKit/qt/Api/qwebsettings.h @@ -59,7 +59,11 @@ public: JavascriptCanAccessClipboard, DeveloperExtrasEnabled, LinksIncludedInFocusChain, - ZoomTextOnly + ZoomTextOnly, + PrintElementBackgrounds, + OfflineStorageDatabaseEnabled, + OfflineWebApplicationCacheEnabled, + LocalStorageDatabaseEnabled }; enum WebGraphic { MissingImageGraphic, @@ -103,6 +107,16 @@ public: static int maximumPagesInCache(); static void setObjectCacheCapacities(int cacheMinDeadCapacity, int cacheMaxDead, int totalCapacity); + static void setOfflineStoragePath(const QString& path); + static QString offlineStoragePath(); + static void setOfflineStorageDefaultQuota(qint64 maximumSize); + static qint64 offlineStorageDefaultQuota(); + + static void setOfflineWebApplicationCachePath(const QString& path); + static QString offlineWebApplicationCachePath(); + + inline QWebSettingsPrivate* handle() const { return d; } + private: friend class QWebPagePrivate; friend class QWebSettingsPrivate; diff --git a/WebKit/qt/Api/qwebview.cpp b/WebKit/qt/Api/qwebview.cpp index ad0b12a..ea503a1 100644 --- a/WebKit/qt/Api/qwebview.cpp +++ b/WebKit/qt/Api/qwebview.cpp @@ -156,15 +156,10 @@ QWebView::QWebView(QWidget *parent) { d = new QWebViewPrivate(this); - QPalette pal = palette(); - pal.setBrush(QPalette::Background, Qt::white); - - setAttribute(Qt::WA_OpaquePaintEvent); #if !defined(Q_WS_QWS) setAttribute(Qt::WA_InputMethodEnabled); #endif - setPalette(pal); setAcceptDrops(true); setMouseTracking(true); @@ -245,6 +240,7 @@ void QWebView::setPage(QWebPage *page) connect(d->page, SIGNAL(microFocusChanged()), this, SLOT(updateMicroFocus())); } + setAttribute(Qt::WA_OpaquePaintEvent, d->page); update(); } @@ -290,8 +286,8 @@ void QWebView::load(const QNetworkRequest &request, /*! Sets the content of the web view to the specified \a html. - External objects referenced in the HTML document are located relative to - \a baseUrl. + External objects such as stylesheets or images referenced in the HTML + document are located relative to \a baseUrl. When using this method, WebKit assumes that external resources such as JavaScript programs or style sheets are encoded in UTF-8 unless otherwise @@ -515,11 +511,18 @@ qreal QWebView::zoomFactor() const By default, this property contains a value of 1.0. */ +/*! + Sets the value of the multiplier used to scale the text in a Web page to + the \a factor specified. +*/ void QWebView::setTextSizeMultiplier(qreal factor) { page()->mainFrame()->setTextSizeMultiplier(factor); } +/*! + Returns the value of the multiplier used to scale the text in a Web page. +*/ qreal QWebView::textSizeMultiplier() const { return page()->mainFrame()->textSizeMultiplier(); @@ -546,6 +549,8 @@ bool QWebView::event(QEvent *e) if (d->page) { #ifndef QT_NO_CONTEXTMENU if (e->type() == QEvent::ContextMenu) { + if (!isEnabled()) + return false; QContextMenuEvent *event = static_cast<QContextMenuEvent *>(e); if (d->page->swallowContextMenuEvent(event)) { e->accept(); |