diff options
Diffstat (limited to 'WebKit/qt')
41 files changed, 2735 insertions, 137 deletions
diff --git a/WebKit/qt/Api/DerivedSources.pro b/WebKit/qt/Api/DerivedSources.pro index 22d4c8d..62546f6 100644 --- a/WebKit/qt/Api/DerivedSources.pro +++ b/WebKit/qt/Api/DerivedSources.pro @@ -12,7 +12,7 @@ DOUBLE_ESCAPED_QUOTE = "" ESCAPE = "" win32-msvc*|symbian { ESCAPE = "^" -} else:win32-g++:isEmpty(QMAKE_SH) { +} else:win32-g++*:isEmpty(QMAKE_SH) { # MinGW's make will run makefile commands using sh, even if make # was run from the Windows shell, if it finds sh in the path. ESCAPE = "^" diff --git a/WebKit/qt/Api/headers.pri b/WebKit/qt/Api/headers.pri index 29bb125..e9fe28d 100644 --- a/WebKit/qt/Api/headers.pri +++ b/WebKit/qt/Api/headers.pri @@ -12,4 +12,5 @@ WEBKIT_API_HEADERS = $$PWD/qwebframe.h \ $$PWD/qwebpluginfactory.h \ $$PWD/qwebhistory.h \ $$PWD/qwebinspector.h \ - $$PWD/qwebkitversion.h + $$PWD/qwebkitversion.h \ + $$PWD/qwebscriptworld.h diff --git a/WebKit/qt/Api/qgraphicswebview.cpp b/WebKit/qt/Api/qgraphicswebview.cpp index 178f5c2..8361970 100644 --- a/WebKit/qt/Api/qgraphicswebview.cpp +++ b/WebKit/qt/Api/qgraphicswebview.cpp @@ -122,7 +122,7 @@ void QGraphicsWebViewPrivate::_q_pageDestroyed() void QGraphicsWebViewPrivate::updateResizesToContentsForPage() { ASSERT(page); - + static_cast<PageClientQGraphicsWidget*>(page->d->client)->viewResizesToContents = resizesToContents; if (resizesToContents) { // resizes to contents mode requires preferred contents size to be set if (!page->preferredContentsSize().isValid()) @@ -821,10 +821,8 @@ void QGraphicsWebView::setResizesToContents(bool enabled) if (d->resizesToContents == enabled) return; d->resizesToContents = enabled; - if (d->page) { - static_cast<PageClientQGraphicsWidget*>(d->page->d->client)->viewResizesToContents = enabled; + if (d->page) d->updateResizesToContentsForPage(); - } } bool QGraphicsWebView::resizesToContents() const diff --git a/WebKit/qt/Api/qwebframe.cpp b/WebKit/qt/Api/qwebframe.cpp index 3eba058..c42cfa3 100644 --- a/WebKit/qt/Api/qwebframe.cpp +++ b/WebKit/qt/Api/qwebframe.cpp @@ -71,6 +71,8 @@ #include "qwebpage_p.h" #include "qwebsecurityorigin.h" #include "qwebsecurityorigin_p.h" +#include "qwebscriptworld.h" +#include "qwebscriptworld_p.h" #include "runtime_object.h" #include "runtime_root.h" #include "wtf/HashMap.h" @@ -1272,8 +1274,8 @@ void QWebFrame::print(QPrinter *printer) const if (!painter.begin(printer)) return; - const qreal zoomFactorX = printer->logicalDpiX() / qt_defaultDpi(); - const qreal zoomFactorY = printer->logicalDpiY() / qt_defaultDpi(); + const qreal zoomFactorX = (qreal)printer->logicalDpiX() / qt_defaultDpi(); + const qreal zoomFactorY = (qreal)printer->logicalDpiY() / qt_defaultDpi(); PrintContext printContext(d->frame); float pageHeight = 0; @@ -1376,6 +1378,22 @@ QVariant QWebFrame::evaluateJavaScript(const QString& scriptSource) return rc; } +QVariant QWebFrame::evaluateScriptInIsolatedWorld(QWebScriptWorld* scriptWorld, const QString& scriptSource) +{ + ScriptController *proxy = d->frame->script(); + QVariant rc; + + if (proxy) { + JSC::JSValue v = proxy->executeScriptInWorld(scriptWorld->world(), scriptSource, true).jsValue(); + if (!d->frame) // In case the script removed our frame from the page. + return QString(); + int distance = 0; + rc = JSC::Bindings::convertValueToQVariant(proxy->globalObject(mainThreadNormalWorld())->globalExec(), v, QMetaType::Void, &distance); + } + return rc; +} + + /*! \since 4.5 diff --git a/WebKit/qt/Api/qwebframe.h b/WebKit/qt/Api/qwebframe.h index ecd31de..5f3dbd4 100644 --- a/WebKit/qt/Api/qwebframe.h +++ b/WebKit/qt/Api/qwebframe.h @@ -49,6 +49,7 @@ class QWebHistoryItem; class QWebSecurityOrigin; class QWebElement; class QWebElementCollection; +class QWebScriptWorld; class DumpRenderTreeSupportQt; namespace WebCore { @@ -199,6 +200,7 @@ public: public Q_SLOTS: QVariant evaluateJavaScript(const QString& scriptSource); + QVariant evaluateScriptInIsolatedWorld(QWebScriptWorld* scriptWorld, const QString& scriptSource); #ifndef QT_NO_PRINTER void print(QPrinter *printer) const; #endif diff --git a/WebKit/qt/Api/qwebframe_p.h b/WebKit/qt/Api/qwebframe_p.h index fcc37e7..62bd59e 100644 --- a/WebKit/qt/Api/qwebframe_p.h +++ b/WebKit/qt/Api/qwebframe_p.h @@ -71,6 +71,7 @@ public: , allowsScrolling(true) , marginWidth(-1) , marginHeight(-1) + , initialLayoutComplete(false) {} void init(QWebFrame* qframe, QWebFrameData* frameData); void setPage(QWebPage*); @@ -98,6 +99,7 @@ public: bool allowsScrolling; int marginWidth; int marginHeight; + bool initialLayoutComplete; }; class QWebHitTestResultPrivate { diff --git a/WebKit/qt/Api/qwebhistory.cpp b/WebKit/qt/Api/qwebhistory.cpp index 0147f92..a6f3d0c 100644 --- a/WebKit/qt/Api/qwebhistory.cpp +++ b/WebKit/qt/Api/qwebhistory.cpp @@ -363,9 +363,8 @@ bool QWebHistory::canGoForward() const void QWebHistory::back() { if (canGoBack()) { - d->lst->goBack(); WebCore::Page* page = d->lst->page(); - page->goToItem(currentItem().d->item, WebCore::FrameLoadTypeIndexedBackForward); + page->goToItem(d->lst->backItem(), WebCore::FrameLoadTypeIndexedBackForward); } } @@ -378,9 +377,8 @@ void QWebHistory::back() void QWebHistory::forward() { if (canGoForward()) { - d->lst->goForward(); WebCore::Page* page = d->lst->page(); - page->goToItem(currentItem().d->item, WebCore::FrameLoadTypeIndexedBackForward); + page->goToItem(d->lst->forwardItem(), WebCore::FrameLoadTypeIndexedBackForward); } } @@ -391,9 +389,8 @@ void QWebHistory::forward() */ void QWebHistory::goToItem(const QWebHistoryItem &item) { - d->lst->goToItem(item.d->item); WebCore::Page* page = d->lst->page(); - page->goToItem(currentItem().d->item, WebCore::FrameLoadTypeIndexedBackForward); + page->goToItem(item.d->item, WebCore::FrameLoadTypeIndexedBackForward); } /*! diff --git a/WebKit/qt/Api/qwebkitplatformplugin.h b/WebKit/qt/Api/qwebkitplatformplugin.h index bac618c..32d22d4 100644 --- a/WebKit/qt/Api/qwebkitplatformplugin.h +++ b/WebKit/qt/Api/qwebkitplatformplugin.h @@ -31,7 +31,7 @@ class QWebSelectData { public: - inline ~QWebSelectData() {} + virtual ~QWebSelectData() {} enum ItemType { Option, Group, Separator }; @@ -48,7 +48,7 @@ class QWebSelectMethod : public QObject { Q_OBJECT public: - inline ~QWebSelectMethod() {} + virtual ~QWebSelectMethod() {} virtual void show(const QWebSelectData&) = 0; virtual void hide() = 0; @@ -61,6 +61,8 @@ Q_SIGNALS: class QWebNotificationData { public: + virtual ~QWebNotificationData() {} + virtual const QString title() const = 0; virtual const QString message() const = 0; virtual const QByteArray iconData() const = 0; diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp index d49ac14..eab909c 100644 --- a/WebKit/qt/Api/qwebpage.cpp +++ b/WebKit/qt/Api/qwebpage.cpp @@ -593,7 +593,7 @@ void QWebPagePrivate::timerEvent(QTimerEvent *ev) if (timerId == tripleClickTimer.timerId()) tripleClickTimer.stop(); else - q->QObject::timerEvent(ev); + q->timerEvent(ev); } void QWebPagePrivate::mouseMoveEvent(QGraphicsSceneMouseEvent* ev) @@ -1207,6 +1207,14 @@ void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev) } #ifndef QT_NO_PROPERTIES +typedef struct { + const char* name; + double deferredRepaintDelay; + double initialDeferredRepaintDelayDuringLoading; + double maxDeferredRepaintDelayDuringLoading; + double deferredRepaintDelayIncrementDuringLoading; +} QRepaintThrottlingPreset; + void QWebPagePrivate::dynamicPropertyChangeEvent(QDynamicPropertyChangeEvent* event) { if (event->propertyName() == "_q_viewMode") { @@ -1224,7 +1232,42 @@ void QWebPagePrivate::dynamicPropertyChangeEvent(QDynamicPropertyChangeEvent* ev } else if (event->propertyName() == "_q_HTMLTokenizerTimeDelay") { double timeDelay = q->property("_q_HTMLTokenizerTimeDelay").toDouble(); q->handle()->page->setCustomHTMLTokenizerTimeDelay(timeDelay); - } + } else if (event->propertyName() == "_q_RepaintThrottlingDeferredRepaintDelay") { + double p = q->property("_q_RepaintThrottlingDeferredRepaintDelay").toDouble(); + FrameView::setRepaintThrottlingDeferredRepaintDelay(p); + } else if (event->propertyName() == "_q_RepaintThrottlingnInitialDeferredRepaintDelayDuringLoading") { + double p = q->property("_q_RepaintThrottlingnInitialDeferredRepaintDelayDuringLoading").toDouble(); + FrameView::setRepaintThrottlingnInitialDeferredRepaintDelayDuringLoading(p); + } else if (event->propertyName() == "_q_RepaintThrottlingMaxDeferredRepaintDelayDuringLoading") { + double p = q->property("_q_RepaintThrottlingMaxDeferredRepaintDelayDuringLoading").toDouble(); + FrameView::setRepaintThrottlingMaxDeferredRepaintDelayDuringLoading(p); + } else if (event->propertyName() == "_q_RepaintThrottlingDeferredRepaintDelayIncrementDuringLoading") { + double p = q->property("_q_RepaintThrottlingDeferredRepaintDelayIncrementDuringLoading").toDouble(); + FrameView::setRepaintThrottlingDeferredRepaintDelayIncrementDuringLoading(p); + } else if (event->propertyName() == "_q_RepaintThrottlingPreset") { + static const QRepaintThrottlingPreset presets[] = { + { "NoThrottling", 0, 0, 0, 0 }, + { "Legacy", 0.025, 0, 2.5, 0.5 }, + { "Minimal", 0.01, 0, 1, 0.2 }, + { "Medium", 0.025, 1, 5, 0.5 }, + { "Heavy", 0.1, 2, 10, 1 } + }; + + QString p = q->property("_q_RepaintThrottlingPreset").toString(); + for(int i = 0; i < sizeof(presets) / sizeof(presets[0]); i++) { + if(p == presets[i].name) { + FrameView::setRepaintThrottlingDeferredRepaintDelay( + presets[i].deferredRepaintDelay); + FrameView::setRepaintThrottlingnInitialDeferredRepaintDelayDuringLoading( + presets[i].initialDeferredRepaintDelayDuringLoading); + FrameView::setRepaintThrottlingMaxDeferredRepaintDelayDuringLoading( + presets[i].maxDeferredRepaintDelayDuringLoading); + FrameView::setRepaintThrottlingDeferredRepaintDelayIncrementDuringLoading( + presets[i].deferredRepaintDelayIncrementDuringLoading); + break; + } + } + } #if ENABLE(TILED_BACKING_STORE) else if (event->propertyName() == "_q_TiledBackingStoreTileSize") { WebCore::Frame* frame = QWebFramePrivate::core(q->mainFrame()); @@ -1655,6 +1698,109 @@ InspectorController* QWebPagePrivate::inspectorController() \value WebModalDialog The window acts as modal dialog. */ + +/*! + \class QWebPage::ViewportHints + \since 4.7 + \brief The QWebPage::ViewportHints class describes hints that can be applied to a viewport. + + QWebPage::ViewportHints provides a description of a viewport, such as viewport geometry, + initial scale factor with limits, plus information about whether a user should be able + to scale the contents in the viewport or not, ie. by zooming. + + ViewportHints can be set by a web author using the viewport meta tag extension, documented + at \l{http://developer.apple.com/safari/library/documentation/appleapplications/reference/safariwebcontent/usingtheviewport/usingtheviewport.html}{Safari Reference Library: Using the Viewport Meta Tag}. + + All values might not be set, as such when dealing with the hints, the developer needs to + check whether the values are valid. Negative values denote an invalid qreal value. + + \inmodule QtWebKit +*/ + +/*! + Constructs an empty QWebPage::ViewportHints. +*/ +QWebPage::ViewportHints::ViewportHints() + : d(0) + , m_initialScaleFactor(-1.0) + , m_minimumScaleFactor(-1.0) + , m_maximumScaleFactor(-1.0) + , m_isUserScalable(true) + , m_isValid(false) +{ + +} + +/*! + Constructs a QWebPage::ViewportHints which is a copy from \a other . +*/ +QWebPage::ViewportHints::ViewportHints(const QWebPage::ViewportHints& other) + : d(other.d) + , m_initialScaleFactor(other.m_initialScaleFactor) + , m_minimumScaleFactor(other.m_minimumScaleFactor) + , m_maximumScaleFactor(other.m_maximumScaleFactor) + , m_isUserScalable(other.m_isUserScalable) + , m_isValid(other.m_isValid) + , m_size(other.m_size) +{ + +} + +/*! + Destroys the QWebPage::ViewportHints. +*/ +QWebPage::ViewportHints::~ViewportHints() +{ + +} + +/*! + Assigns the given QWebPage::ViewportHints to this viewport hints and returns a + reference to this. +*/ +QWebPage::ViewportHints& QWebPage::ViewportHints::operator=(const QWebPage::ViewportHints& other) +{ + if (this != &other) { + d = other.d; + m_initialScaleFactor = other.m_initialScaleFactor; + m_minimumScaleFactor = other.m_minimumScaleFactor; + m_maximumScaleFactor = other.m_maximumScaleFactor; + m_isUserScalable = other.m_isUserScalable; + m_isValid = other.m_isValid; + m_size = other.m_size; + } + + return *this; +} + +/*! \fn inline bool QWebPage::ViewportHints::isValid() const + Returns whether this is a valid ViewportHints or not. + + An invalid ViewportHints will have an empty QSize, negative values for scale factors and + true for the boolean isUserScalable. +*/ + +/*! \fn inline QSize QWebPage::ViewportHints::size() const + Returns the size of the viewport. +*/ + +/*! \fn inline qreal QWebPage::ViewportHints::initialScaleFactor() const + Returns the initial scale of the viewport as a multiplier. +*/ + +/*! \fn inline qreal QWebPage::ViewportHints::minimumScaleFactor() const + Returns the minimum scale value of the viewport as a multiplier. +*/ + +/*! \fn inline qreal QWebPage::ViewportHints::maximumScaleFactor() const + Returns the maximum scale value of the viewport as a multiplier. +*/ + +/*! \fn inline bool QWebPage::ViewportHints::isUserScalable() const + Determines whether or not the scale can be modified by the user. +*/ + + /*! \class QWebPage \since 4.4 @@ -1852,9 +1998,14 @@ QWidget *QWebPage::view() const */ void QWebPage::javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID) { - Q_UNUSED(message) - Q_UNUSED(lineNumber) Q_UNUSED(sourceID) + + // Catch plugin logDestroy message for LayoutTests/plugins/open-and-close-window-with-plugin.html + // At this point DRT's WebPage has already been destroyed + if (QWebPagePrivate::drtRun) { + if (message == "PLUGIN: NPP_Destroy") + fprintf (stdout, "CONSOLE MESSAGE: line %d: %s\n", lineNumber, message.toUtf8().constData()); + } } /*! @@ -2184,30 +2335,42 @@ QSize QWebPage::preferredContentsSize() const /*! \property QWebPage::preferredContentsSize \since 4.6 - \brief the preferred size of the contents + \brief a custom size used for laying out the page contents. + + By default all pages are laid out using the viewport of the page as the base. + + As pages mostly are designed for desktop usage, they often do not layout properly + on small devices as the contents require a certain view width. For this reason + it is common to use a different layout size and then scale the contents to fit + within the actual view. - If this property is set to a valid size, it is used to lay out the page. - If it is not set (the default), the viewport size is used instead. + If this property is set to a valid size, this size is used for all layout needs + instead of the size of the viewport. + + Setting an invalid size, makes the page fall back to using the viewport size for layout. \sa viewportSize */ -void QWebPage::setPreferredContentsSize(const QSize &size) const +void QWebPage::setPreferredContentsSize(const QSize& size) const { + // FIXME: Rename this method to setCustomLayoutSize + d->fixedLayoutSize = size; - QWebFrame *frame = mainFrame(); - if (frame->d->frame && frame->d->frame->view()) { - WebCore::FrameView* view = frame->d->frame->view(); + QWebFrame* frame = mainFrame(); + if (!frame->d->frame || !frame->d->frame->view()) + return; - if (size.isValid()) { - view->setUseFixedLayout(true); - view->setFixedLayoutSize(size); - view->layout(); - } else if (view->useFixedLayout()) { - view->setUseFixedLayout(false); - view->layout(); - } - } + WebCore::FrameView* view = frame->d->frame->view(); + + if (size.isValid()) { + view->setUseFixedLayout(true); + view->setFixedLayoutSize(size); + } else if (view->useFixedLayout()) + view->setUseFixedLayout(false); + + if (frame->d->initialLayoutComplete) + view->layout(); } /*! @@ -3538,6 +3701,29 @@ quint64 QWebPage::bytesReceived() const } /*! + \since 4.7 + \fn void QWebPage::viewportChangeRequested(const QWebPage::ViewportHints& hints) + + This signal is emitted before any layout of the contents, giving you the viewport \a arguments + the web page would like you to use when laying out its contents, including elements fixed to the + viewport. This viewport might be larger that your actual viewport, meaning that a initialScaleFactor + should be applied. When no scale is given, it is assumed that the contents should be scaled + such that the width of the scaled contents fits within the actual viewport. + + The minimum and maximum allowed scale represents the min and max values that the page + allows for scaling, and thus, affects the ability to zoom in on the page. + + Invalid values are supplied for the values not explicitly set by the web author; thus an + invalid viewport size, and negative values for scale factor and limits. The boolean + ViewportHints::isUserScalable is set to true. + + Page authors can provide the supplied values by using the viewport meta tag. More information + about this can be found at \l{http://developer.apple.com/safari/library/documentation/appleapplications/reference/safariwebcontent/usingtheviewport/usingtheviewport.html}{Safari Reference Library: Using the Viewport Meta Tag}. + + \sa QWebPage::ViewportHints, setPreferredContentsSize(), QGraphicsWebView::setScale() +*/ + +/*! \fn void QWebPage::loadStarted() This signal is emitted when a new load of the page is started. diff --git a/WebKit/qt/Api/qwebpage.h b/WebKit/qt/Api/qwebpage.h index 721f4a8..fcaa302 100644 --- a/WebKit/qt/Api/qwebpage.h +++ b/WebKit/qt/Api/qwebpage.h @@ -42,12 +42,13 @@ class QWebFrame; class QWebNetworkRequest; class QWebHistory; -class QWebPagePrivate; class QWebFrameData; +class QWebHistoryItem; +class QWebHitTestResult; class QWebNetworkInterface; +class QWebPagePrivate; class QWebPluginFactory; -class QWebHitTestResult; -class QWebHistoryItem; +class QtViewportHintsPrivate; namespace WebCore { class ChromeClientQt; @@ -194,6 +195,35 @@ public: WebModalDialog }; + class ViewportHints { + public: + ViewportHints(); + ViewportHints(const QWebPage::ViewportHints& other); + + ~ViewportHints(); + + QWebPage::ViewportHints& operator=(const QWebPage::ViewportHints& other); + + inline qreal initialScaleFactor() const { return m_initialScaleFactor; }; + inline qreal minimumScaleFactor() const { return m_minimumScaleFactor; }; + inline qreal maximumScaleFactor() const { return m_maximumScaleFactor; }; + inline bool isUserScalable() const { return m_isUserScalable; }; + inline bool isValid() const { return m_isValid; }; + inline QSize size() const { return m_size; }; + + private: + QSharedDataPointer<QtViewportHintsPrivate> d; + qreal m_initialScaleFactor; + qreal m_minimumScaleFactor; + qreal m_maximumScaleFactor; + bool m_isUserScalable; + bool m_isValid; + QSize m_size; + + friend class WebCore::ChromeClientQt; + }; + + explicit QWebPage(QObject *parent = 0); ~QWebPage(); @@ -339,6 +369,8 @@ Q_SIGNALS: void saveFrameStateRequested(QWebFrame* frame, QWebHistoryItem* item); void restoreFrameStateRequested(QWebFrame* frame); + void viewportChangeRequested(const QWebPage::ViewportHints& hints); + protected: virtual QWebPage *createWindow(WebWindowType type); virtual QObject *createPlugin(const QString &classid, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues); diff --git a/WebKit/qt/Api/qwebpage_p.h b/WebKit/qt/Api/qwebpage_p.h index 272f96b..54a1523 100644 --- a/WebKit/qt/Api/qwebpage_p.h +++ b/WebKit/qt/Api/qwebpage_p.h @@ -58,6 +58,15 @@ QT_END_NAMESPACE class QWebInspector; class QWebPageClient; +class QtViewportHintsPrivate : public QSharedData { +public: + QtViewportHintsPrivate(QWebPage::ViewportHints* qq) + : q(qq) + { } + + QWebPage::ViewportHints* q; +}; + class QWebPagePrivate { public: QWebPagePrivate(QWebPage*); diff --git a/WebKit/qt/Api/qwebscriptworld.cpp b/WebKit/qt/Api/qwebscriptworld.cpp new file mode 100644 index 0000000..5d912cc --- /dev/null +++ b/WebKit/qt/Api/qwebscriptworld.cpp @@ -0,0 +1,49 @@ +/* + Copyright (C) 2010 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 "qwebscriptworld.h" +#include "qwebscriptworld_p.h" + +#include "KURL.h" +#include "ScriptController.h" +#include <QStringList> + +using namespace WebCore; + +/*! + Constructs a security origin from \a other. +*/ +QWebScriptWorld::QWebScriptWorld() +{ + d = new QWebScriptWorldPrivate(ScriptController::createWorld()); +} + +DOMWrapperWorld* QWebScriptWorld::world() const +{ + return d->world.get(); +} + +/*! + Destroys the security origin. +*/ +QWebScriptWorld::~QWebScriptWorld() +{ +} + diff --git a/WebKit/qt/Api/qwebscriptworld.h b/WebKit/qt/Api/qwebscriptworld.h new file mode 100644 index 0000000..6e728ab --- /dev/null +++ b/WebKit/qt/Api/qwebscriptworld.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2010 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. +*/ + +#ifndef QWebScriptWorld_h_ +#define QWebScriptWorld_h_ + +#include <QtCore/qurl.h> +#include <QtCore/qshareddata.h> + +#include "qwebkitglobal.h" + +namespace WebCore { + class DOMWrapperWorld; +} + +class QWebScriptWorldPrivate; +class QWebFrame; + +class QWEBKIT_EXPORT QWebScriptWorld { +public: + QWebScriptWorld(); + ~QWebScriptWorld(); + + WebCore::DOMWrapperWorld* world() const; + +private: + QExplicitlySharedDataPointer<QWebScriptWorldPrivate> d; + + friend class QWebFrame; +}; + +#endif diff --git a/WebKit/qt/Api/qwebscriptworld_p.h b/WebKit/qt/Api/qwebscriptworld_p.h new file mode 100644 index 0000000..7115eb2 --- /dev/null +++ b/WebKit/qt/Api/qwebscriptworld_p.h @@ -0,0 +1,44 @@ +/* + Copyright (C) 2010 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. +*/ + +#ifndef _QWEBSCRIPTWORLD_P_H_ +#define _QWEBSCRIPTWORLD_P_H_ + +#include "RefPtr.h" + +namespace WebCore { + class DOMWrapperWorld; +} + +class QWebScriptWorldPrivate : public QSharedData { +public: + QWebScriptWorldPrivate(WTF::PassRefPtr<WebCore::DOMWrapperWorld> o) + { + Q_ASSERT(o); + world = o; + } + + ~QWebScriptWorldPrivate() + { + } + + WTF::RefPtr<WebCore::DOMWrapperWorld> world; +}; + +#endif diff --git a/WebKit/qt/Api/qwebsettings.cpp b/WebKit/qt/Api/qwebsettings.cpp index 4881bac..b2766a7 100644 --- a/WebKit/qt/Api/qwebsettings.cpp +++ b/WebKit/qt/Api/qwebsettings.cpp @@ -24,9 +24,9 @@ #include "qwebpage_p.h" #include "qwebplugindatabase_p.h" +#include "AbstractDatabase.h" #include "Cache.h" #include "CrossOriginPreflightResultCache.h" -#include "Database.h" #include "FontCache.h" #include "Page.h" #include "PageCache.h" @@ -217,7 +217,7 @@ void QWebSettingsPrivate::apply() #if ENABLE(DATABASE) value = attributes.value(QWebSettings::OfflineStorageDatabaseEnabled, global->attributes.value(QWebSettings::OfflineStorageDatabaseEnabled)); - WebCore::Database::setIsAvailable(value); + WebCore::AbstractDatabase::setIsAvailable(value); #endif value = attributes.value(QWebSettings::OfflineWebApplicationCacheEnabled, diff --git a/WebKit/qt/Api/qwebsettings.h b/WebKit/qt/Api/qwebsettings.h index c063bcd..38a2b3f 100644 --- a/WebKit/qt/Api/qwebsettings.h +++ b/WebKit/qt/Api/qwebsettings.h @@ -74,8 +74,8 @@ public: LocalContentCanAccessFileUrls, TiledBackingStoreEnabled, FrameFlatteningEnabled, - WebGLEnabled, - SiteSpecificQuirksEnabled + SiteSpecificQuirksEnabled, + WebGLEnabled }; enum WebGraphic { MissingImageGraphic, diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog index f83d64d..2e565ae 100644 --- a/WebKit/qt/ChangeLog +++ b/WebKit/qt/ChangeLog @@ -1,3 +1,632 @@ +2010-06-24 Simon Hausmann <simon.hausmann@nokia.com> + + Unreviewed Symbian build fix. + + The QML WebKit integration needs to be part of QtWebKit.sis + + * declarative/declarative.pro: Removed non-working deployment. + +2010-06-23 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Unreviewed, Symbian build fix. + + [Qt] Update the def file after r61478. + + * symbian/eabi/QtWebKitu.def: + +2010-06-23 David Boddie <dboddie@trolltech.com> + + Reviewed by Simon Hausmann. + + [Qt] Doc: Fixed documentation errors. + + * docs/qtwebkit-bridge.qdoc: + +2010-06-23 Alessandro Portale <alessandro.portale@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Provide the Webkit Qml plugin with a UID3 on Symbian + + ...otherwise we cannot Symbian sign it. + + * declarative/declarative.pro: + +2010-06-23 Simon Hausmann <simon.hausmann@nokia.com> + + Unreviewed Qt package build fix. + + When building without build-webkit, set OUTPUT_DIR if necessary, like + in the other .pro files. + + * declarative/declarative.pro: + +2010-06-22 Tasuku Suzuki <tasuku.suzuki@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Fix compilation with QT_NO_COMBOBOX. + + * WebCoreSupport/ChromeClientQt.cpp: + (WebCore::ChromeClientQt::createSelectPopup): + +2010-06-21 Robert Hogan <robert@webkit.org> + + [Qt] Build fix for Qt on Windows MSVC2008 + + Unreviewed, build fix. + + Fix by Jocelyn Turcotte. + + * Api/qwebframe.cpp: + +2010-06-21 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> + + Reviewed by nobody, build fix. + + [Qt] Fix MSVC build. + + The max macro was replacing the max function used in StringImpl.h + when compiling moc_NotificationPresenterClientQt.cpp. + + * WebCoreSupport/NotificationPresenterClientQt.cpp: + +2010-06-21 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Unreviewed, Symbian build fix. + + [Qt] Update the def file with recent new exports. + + * symbian/eabi/QtWebKitu.def: + +2010-06-21 Simon Hausmann <simon.hausmann@nokia.com> + + Unreviewed build fix. + + [Qt] Fix package builds + + Don't use rpath unless we're building inside the trunk. + + * declarative/declarative.pro: + +2010-06-20 Jedrzej Nowacki <jedrzej.nowacki@nokia.com> + + Reviewed by Simon Hausmann. + + The QWebHistory regression fix. + + After change r51629 and r61207 QWebHistory's function back(), + forward(), goToItem() got broken. + + Use page->goToItem() instead of direct actions on the BackForwardList. + + [Qt] REGRESSION(r61207): qwebhistory unit test hangs + https://bugs.webkit.org/show_bug.cgi?id=40672 + + * Api/qwebhistory.cpp: + (QWebHistory::back): + (QWebHistory::forward): + (QWebHistory::goToItem): + * tests/qwebhistory/tst_qwebhistory.cpp: + (tst_QWebHistory::init): + (tst_QWebHistory::back): + (tst_QWebHistory::forward): + +2010-06-19 Yael Aharon <yael.aharon@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Platform plugin's multi-select does not take OptGroup into account + https://bugs.webkit.org/show_bug.cgi?id=40718 + + Make sure that SelectData is valid throughout the lifetime of the dialog. + This is mostly important for the Orbt based plugin. + Added virtual desctructors where they were missing. + + * Api/qwebkitplatformplugin.h: + (QWebSelectData::~QWebSelectData): + (QWebSelectMethod::~QWebSelectMethod): + (QWebNotificationData::~QWebNotificationData): + * WebCoreSupport/QtPlatformPlugin.cpp: + (WebCore::SelectInputMethodWrapper::SelectInputMethodWrapper): + (WebCore::SelectInputMethodWrapper::~SelectInputMethodWrapper): + (WebCore::SelectInputMethodWrapper::show): + * WebCoreSupport/QtPlatformPlugin.h: + * examples/platformplugin/WebPlugin.cpp: + * examples/platformplugin/qwebkitplatformplugin.h: + (QWebSelectData::~QWebSelectData): + (QWebSelectMethod::~QWebSelectMethod): + (QWebNotificationData::~QWebNotificationData): + +2010-06-19 No'am Rosenthal <noam.rosenthal@nokia.com> + + Reviewed by Simon Hausmann. + + Bridge documentation: some snippets have the wrong indentation + https://bugs.webkit.org/show_bug.cgi?id=40717 + + Fixed code snippets + + * docs/webkitsnippets/qtwebkit_bridge_snippets.cpp: + (wrapInFunction): + +2010-06-02 Robert Hogan <robert@webkit.org> + + Reviewed by Adam Barth. + + [Qt] Support evaluateScriptInIsolatedWorld() + + https://bugs.webkit.org/show_bug.cgi?id=40079 + + * Api/headers.pri: + * Api/qwebframe.cpp: + (QWebFrame::evaluateScriptInIsolatedWorld): + * Api/qwebframe.h: + * Api/qwebscriptworld.cpp: Added. + (QWebScriptWorld::QWebScriptWorld): + (QWebScriptWorld::world): + (QWebScriptWorld::~QWebScriptWorld): + * Api/qwebscriptworld.h: Added. + * Api/qwebscriptworld_p.h: Added. + (QWebScriptWorldPrivate::QWebScriptWorldPrivate): + (QWebScriptWorldPrivate::~QWebScriptWorldPrivate): + * WebCoreSupport/DumpRenderTreeSupportQt.cpp: + * WebCoreSupport/DumpRenderTreeSupportQt.h: + +2010-06-19 Olivier Goffart <olivier.goffart@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Compilation in QWebPagePrivate::timerEvent with clang + https://bugs.webkit.org/show_bug.cgi?id=40714 + + QObject::timerEvent is protected and cannot be accessed by QWebPagePrivate + with clang + + QWebPagePrivate is a friend of QWebPage and then should have access to + all protected members of parents of QWebPage, including QObject. + But the clang team do not want to conform to this aspect of the specification + because "It is either a drafting error or a horrible mistake." + See http://llvm.org/bugs/show_bug.cgi?id=6840 + + This change is better because QWebPage does not reimplement the timerEvent + (QWebPagePrivate::timerEvent is called from QWebPage::event) + So customers that would reimplement their own timerEvent + for their own timer now get a chance to catch them. + + + * Api/qwebpage.cpp: + (QWebPagePrivate::timerEvent): + +2010-06-19 Mirko Damiani <mirko@develer.com> + + Reviewed by Simon Hausmann. + + [Qt] Avoid truncation of zoom factor in QWebFrame's print function. + https://bugs.webkit.org/show_bug.cgi?id=40662 + + The zoom factor is a qreal number but its value is truncated to an + integer. So a cast to qreal is needed to avoid this issue. + + * Api/qwebframe.cpp: + (QWebFrame::print): + +2010-06-18 Robert Hogan <robert@webkit.org> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] pass plugins/open-and-close-window-with-plugin.html on Qt + + Capture logDestroy messages from the test plugin. DRT's WebPage + is already destroyed by the time they are emitted. + + https://bugs.webkit.org/show_bug.cgi?id=33333 + + Unskip: + plugins/open-and-close-window-with-plugin.html + plugins/geturlnotify-during-document-teardown.html + + * Api/qwebpage.cpp: + (QWebPage::javaScriptConsoleMessage): + +2010-06-18 Alexis Menard <alexis.menard@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Fix documentation for the declarative module import. + + * declarative/qdeclarativewebview.cpp: + +2010-06-18 Alexis Menard <alexis.menard@nokia.com> + + Reviewed by Simon Hausmann. + + Fix documentation issue on the onAlert handler. + Fix compilation issue with QT_NO_ACTION. + + * declarative/qdeclarativewebview.cpp: + * declarative/qdeclarativewebview_p.h: + +2010-06-18 Simon Hausmann <simon.hausmann@nokia.com> + + Reviewed by Antti Koivisto. + + REGRESSION(r60958) [Qt] qwebpage::inputMethods auto-test fails + https://bugs.webkit.org/show_bug.cgi?id=40830 + + When activating a regular input method field, always set or unset the ImhHiddenText + input method hint. + + * WebCoreSupport/EditorClientQt.cpp: + (WebCore::EditorClientQt::setInputMethodState): + +2010-06-18 Alexis Menard <alexis.menard@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Change the target path to QtWebKit. + + * declarative/declarative.pro: + +2010-06-15 Dumitru Daniliuc <dumi@chromium.org> + + Reviewed by Adam Barth. + + Move isAvailable()/setIsAvailable() from Database/DatabaseSync to AbstractDatabase. + https://bugs.webkit.org/show_bug.cgi?id=39041 + + * Api/qwebsettings.cpp: + (QWebSettingsPrivate::apply): + +2010-06-17 Robert Hogan <robert@webkit.org> + + [Qt] Build fix + + Unreviewed. + + Remove includes in qdeclarativewebview*.* that rely on an installation + of QtWebKit. + + * declarative/qdeclarativewebview.cpp: + * declarative/qdeclarativewebview_p.h: + +2010-06-17 Robert Hogan <robert@webkit.org> + + Unreviewed, rolling out r61346. + http://trac.webkit.org/changeset/61346 + https://bugs.webkit.org/show_bug.cgi?id=33333 + + Broke inspector tests on Qt + + * Api/qwebpage.cpp: + (QWebPage::javaScriptConsoleMessage): + +2010-06-17 Robert Hogan <robert@webkit.org> + + Reviewed by Simon Hausmann. + + [Qt] pass plugins/open-and-close-window-with-plugin.html on Qt + + Capture logDestroy messages from the test plugin. DRT's WebPage + is already destroyed by the time they are emitted. + + https://bugs.webkit.org/show_bug.cgi?id=33333 + + Unskip: + plugins/open-and-close-window-with-plugin.html + plugins/geturlnotify-during-document-teardown.html + + * Api/qwebpage.cpp: + (QWebPage::javaScriptConsoleMessage): + +2010-06-17 Jesus Sanchez-Palencia <jesus@webkit.org>, Kenneth Rohde Christiansen <kenneth@webkit.org> + + Reviewed by Simon Hausmann. + + [Qt] QtWebKit does not support viewport meta tag + https://bugs.webkit.org/show_bug.cgi?id=39902 + + Add viewport meta tag support to QtWebKit API layer. + + This implements didReceiveViewportArguments in our ChromeClientQt + which is hooked up with QWebPage::viewportChangeRequested(). + This signal does not affect the current default behavior. + The documentation of the signal explains how to make use of this new feature. + + * Api/qwebframe_p.h: + (QWebFramePrivate::QWebFramePrivate): + Store information about whether the page has been laid out or not. + * Api/qwebpage.cpp: + (QWebPage::viewportChangeRequested): + * Api/qwebpage_p.h: + Added class QtViewportHintsPrivate. + * Api/qwebpage.h: + (QWebPage::setPreferredContentsSize): + Improved documentation and now only layout if the page had already + passed layout phase. + Added class QWebPage::ViewportHints. + * WebCoreSupport/ChromeClientQt.cpp: + (WebCore::ChromeClientQt::windowRect): + Modified to work as intended by the DOM, for both QWebView + and QGraphicsWebView. + (WebCore::ChromeClientQt::didReceiveViewportArguments): + Emits the signal QWebPage::viewportChangeRequested. + * WebCoreSupport/ChromeClientQt.h: + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::dispatchDidCommitLoad): + (WebCore::FrameLoaderClientQt::dispatchDidFirstLayout): + Update information about whether the page has been laid out or not. + If the page has been laid out we ignore any further viewport meta data. + * WebCoreSupport/PageClientQt.cpp: + (WebCore::PageClientQWidget::windowRect): + (WebCore::PageClientQGraphicsWidget::windowRect): + (WebCore::PageClientQGraphicsWidget::graphicsItemVisibleRect): + * WebCoreSupport/PageClientQt.h: + The PageClient is now responsible for providing the right window rect. + +2010-06-17 Alexis Menard <alexis.menard@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Upstream the WebKit QML integration plugin + https://bugs.webkit.org/show_bug.cgi?id=40050 + + Add to the Qt port the QML WebKit integration plugin. + QDeclarativeWebView is creating the item and expose + properties. The C++ API is not public, only the + properties are. + + * declarative/declarative.pro: Added. + * declarative/plugin.cpp: Added. + (WebKitQmlPlugin::registerTypes): + * declarative/qdeclarativewebview.cpp: Added. + (QDeclarativeWebViewPrivate::QDeclarativeWebViewPrivate): + (QDeclarativeWebViewPrivate::): + (QDeclarativeWebViewPrivate::windowObjectsAppend): + (GraphicsWebView::GraphicsWebView): + (GraphicsWebView::mousePressEvent): + (GraphicsWebView::mouseReleaseEvent): + (GraphicsWebView::mouseDoubleClickEvent): + (GraphicsWebView::timerEvent): + (GraphicsWebView::mouseMoveEvent): + (QDeclarativeWebView::QDeclarativeWebView): + (QDeclarativeWebView::~QDeclarativeWebView): + (QDeclarativeWebView::init): + (QDeclarativeWebView::componentComplete): + (QDeclarativeWebView::status): + (QDeclarativeWebView::progress): + (QDeclarativeWebView::doLoadStarted): + (QDeclarativeWebView::doLoadProgress): + (QDeclarativeWebView::pageUrlChanged): + (QDeclarativeWebView::doLoadFinished): + (QDeclarativeWebView::url): + (QDeclarativeWebView::setUrl): + (QDeclarativeWebView::preferredWidth): + (QDeclarativeWebView::setPreferredWidth): + (QDeclarativeWebView::preferredHeight): + (QDeclarativeWebView::setPreferredHeight): + (QDeclarativeWebView::evaluateJavaScript): + (QDeclarativeWebView::updateDeclarativeWebViewSize): + (QDeclarativeWebView::initialLayout): + (QDeclarativeWebView::updateContentsSize): + (QDeclarativeWebView::geometryChanged): + (QDeclarativeWebView::javaScriptWindowObjects): + (QDeclarativeWebView::qmlAttachedProperties): + (QDeclarativeWebViewPrivate::updateWindowObjects): + (QDeclarativeWebView::renderingEnabled): + (QDeclarativeWebView::setRenderingEnabled): + (QDeclarativeWebView::heuristicZoom): + (QDeclarativeWebView::pressGrabTime): + (QDeclarativeWebView::setPressGrabTime): + (QDeclarativeWebView::backAction): + (QDeclarativeWebView::forwardAction): + (QDeclarativeWebView::reloadAction): + (QDeclarativeWebView::stopAction): + (QDeclarativeWebView::title): + (QDeclarativeWebView::icon): + (QDeclarativeWebView::setStatusText): + (QDeclarativeWebView::windowObjectCleared): + (QDeclarativeWebView::statusText): + (QDeclarativeWebView::page): + (QDeclarativeWebView::settingsObject): + (QDeclarativeWebView::setPage): + (QDeclarativeWebView::load): + (QDeclarativeWebView::html): + (QDeclarativeWebView::setHtml): + (QDeclarativeWebView::setContent): + (QDeclarativeWebView::history): + (QDeclarativeWebView::settings): + (QDeclarativeWebView::createWindow): + (QDeclarativeWebView::newWindowComponent): + (QDeclarativeWebView::setNewWindowComponent): + (QDeclarativeWebView::newWindowParent): + (QDeclarativeWebView::setNewWindowParent): + (QDeclarativeWebView::contentsSize): + (QDeclarativeWebView::contentsScale): + (QDeclarativeWebView::setContentsScale): + (QDeclarativeWebView::elementAreaAt): + (QDeclarativeWebPage::QDeclarativeWebPage): + (QDeclarativeWebPage::~QDeclarativeWebPage): + (QDeclarativeWebPage::chooseFile): + (QDeclarativeWebPage::javaScriptAlert): + (QDeclarativeWebPage::javaScriptConfirm): + (QDeclarativeWebPage::javaScriptPrompt): + (QDeclarativeWebPage::viewItem): + (QDeclarativeWebPage::createWindow): + * declarative/qdeclarativewebview_p.h: Added. + (QDeclarativeWebView::): + (QDeclarativeWebView::isComponentCompletePublic): + (QDeclarativeWebViewAttached::QDeclarativeWebViewAttached): + (QDeclarativeWebViewAttached::windowObjectName): + (QDeclarativeWebViewAttached::setWindowObjectName): + (QDeclarativeWebSettings::QDeclarativeWebSettings): + (QDeclarativeWebSettings::standardFontFamily): + (QDeclarativeWebSettings::setStandardFontFamily): + (QDeclarativeWebSettings::fixedFontFamily): + (QDeclarativeWebSettings::setFixedFontFamily): + (QDeclarativeWebSettings::serifFontFamily): + (QDeclarativeWebSettings::setSerifFontFamily): + (QDeclarativeWebSettings::sansSerifFontFamily): + (QDeclarativeWebSettings::setSansSerifFontFamily): + (QDeclarativeWebSettings::cursiveFontFamily): + (QDeclarativeWebSettings::setCursiveFontFamily): + (QDeclarativeWebSettings::fantasyFontFamily): + (QDeclarativeWebSettings::setFantasyFontFamily): + (QDeclarativeWebSettings::minimumFontSize): + (QDeclarativeWebSettings::setMinimumFontSize): + (QDeclarativeWebSettings::minimumLogicalFontSize): + (QDeclarativeWebSettings::setMinimumLogicalFontSize): + (QDeclarativeWebSettings::defaultFontSize): + (QDeclarativeWebSettings::setDefaultFontSize): + (QDeclarativeWebSettings::defaultFixedFontSize): + (QDeclarativeWebSettings::setDefaultFixedFontSize): + (QDeclarativeWebSettings::autoLoadImages): + (QDeclarativeWebSettings::setAutoLoadImages): + (QDeclarativeWebSettings::javascriptEnabled): + (QDeclarativeWebSettings::setJavascriptEnabled): + (QDeclarativeWebSettings::javaEnabled): + (QDeclarativeWebSettings::setJavaEnabled): + (QDeclarativeWebSettings::pluginsEnabled): + (QDeclarativeWebSettings::setPluginsEnabled): + (QDeclarativeWebSettings::privateBrowsingEnabled): + (QDeclarativeWebSettings::setPrivateBrowsingEnabled): + (QDeclarativeWebSettings::javascriptCanOpenWindows): + (QDeclarativeWebSettings::setJavascriptCanOpenWindows): + (QDeclarativeWebSettings::javascriptCanAccessClipboard): + (QDeclarativeWebSettings::setJavascriptCanAccessClipboard): + (QDeclarativeWebSettings::developerExtrasEnabled): + (QDeclarativeWebSettings::setDeveloperExtrasEnabled): + (QDeclarativeWebSettings::linksIncludedInFocusChain): + (QDeclarativeWebSettings::setLinksIncludedInFocusChain): + (QDeclarativeWebSettings::zoomTextOnly): + (QDeclarativeWebSettings::setZoomTextOnly): + (QDeclarativeWebSettings::printElementBackgrounds): + (QDeclarativeWebSettings::setPrintElementBackgrounds): + (QDeclarativeWebSettings::offlineStorageDatabaseEnabled): + (QDeclarativeWebSettings::setOfflineStorageDatabaseEnabled): + (QDeclarativeWebSettings::offlineWebApplicationCacheEnabled): + (QDeclarativeWebSettings::setOfflineWebApplicationCacheEnabled): + (QDeclarativeWebSettings::localStorageDatabaseEnabled): + (QDeclarativeWebSettings::setLocalStorageDatabaseEnabled): + (QDeclarativeWebSettings::localContentCanAccessRemoteUrls): + (QDeclarativeWebSettings::setLocalContentCanAccessRemoteUrls): + * declarative/qmldir: Added. + * docs/qtwebkit.qdocconf: + +2010-06-17 Mark Brand <mabrand@mabrand.nl> + + Reviewed by Simon Hausmann. + + [Qt] use "win32-g++*" scope to match all MinGW makespecs + + The scope "win32-g++" comes from the name of the makespec. However, it + is frequently used to check for MinGW. This works fine as long as + win32-g++ is the only makespec for MinGW. Now we need the wildcard + to cover "win32-g++-cross" as well. + + * Api/DerivedSources.pro: + +2010-05-28 Viatcheslav Ostapenko <ostapenko.viatcheslav@nokia.com> + + Reviewed by Simon Hausmann, Antti Koivisto + + [Qt] Add internal Qt Api to configure repaint throttling parameters. + https://bugs.webkit.org/show_bug.cgi?id=38401 + + * Api/qwebpage.cpp: + (QWebPagePrivate::dynamicPropertyChangeEvent): + +2010-06-16 Alexis Menard <alexis.menard@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Fix tiled backing store painting when calling QGraphicsWebView::setPage() after setResizesToContents(true) + + When calling setPage() after setResizesToContents, the value of the property wasn't propagated + to the page client. Therefore the visible rect for the tiled backing store was incorrect. + + Simply move the variable assignment into updateResizesToContentsForPage(), which is always called. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebViewPrivate::updateResizesToContentsForPage): + (QGraphicsWebView::setResizesToContents): + +2010-06-16 Simon Hausmann <simon.hausmann@nokia.com> + + Rubber-stamped by Tor Arne Vestbø. + + Swap WebGL and SiteSpecificQuirks attributes in the QWebSettings + enum, to allow for binary compatibility with qtwebkit-2.0, where + WebGL is not in the settings but SiteSpecificQuirks will be. + + * Api/qwebsettings.h: + +2010-06-15 Darin Adler <darin@apple.com> + + Fix build. + + * WebCoreSupport/DumpRenderTreeSupportQt.cpp: + (DumpRenderTreeSupportQt::shouldClose): Call loader()->shouldClose(). + +2010-06-15 Yael Aharon <yael.aharon@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Rename NotificatioIconWrapper to NotificationWrapper + https://bugs.webkit.org/show_bug.cgi?id=40571 + + * WebCoreSupport/NotificationPresenterClientQt.cpp: + (WebCore::NotificationWrapper::NotificationWrapper): + (WebCore::NotificationWrapper::close): + (WebCore::NotificationWrapper::title): + (WebCore::NotificationWrapper::message): + (WebCore::NotificationWrapper::iconData): + (WebCore::NotificationWrapper::notificationClosed): + (WebCore::NotificationPresenterClientQt::displayNotification): + (WebCore::NotificationPresenterClientQt::cancel): + (WebCore::NotificationPresenterClientQt::notificationForWrapper): + * WebCoreSupport/NotificationPresenterClientQt.h: + (WebCore::NotificationWrapper::~NotificationWrapper): + +2010-06-15 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Unreviewed, Symbian build fix. + + [Qt] Update the def file with recent new exports. + + * symbian/eabi/QtWebKitu.def: + +2010-06-15 Yael Aharon <yael.aharon@nokia.com> + + Unreviewed. + + Fix typo in reviewer name in r61187 + +2010-06-15 Yael Aharon <yael.aharon@nokia.com> + + Reviewed by Simon Fraser. + + [Qt] Build fix for Qt minimal after r61121 + https://bugs.webkit.org/show_bug.cgi?id=40624 + + * WebCoreSupport/NotificationPresenterClientQt.cpp: + (WebCore::NotificationIconWrapper::NotificationIconWrapper): + (WebCore::NotificationIconWrapper::close): + (WebCore::NotificationIconWrapper::title): + (WebCore::NotificationIconWrapper::message): + (WebCore::NotificationIconWrapper::iconData): + (WebCore::NotificationIconWrapper::notificationClosed): + * WebCoreSupport/NotificationPresenterClientQt.h: + (WebCore::NotificationIconWrapper::~NotificationIconWrapper): + +2010-06-14 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Unreviewed, Symbian build fix. + + [Qt] Update the def file with recent new exports. + + * symbian/eabi/QtWebKitu.def: + 2010-06-13 Yael Aharon <yael.aharon@nokia.com> Reviewed by Kenneth Rohde Christiansen. diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp index 98ffd8a..faec705 100644 --- a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp @@ -37,36 +37,37 @@ #include "FrameLoaderClientQt.h" #include "FrameView.h" #include "Geolocation.h" +#if USE(ACCELERATED_COMPOSITING) +#include "GraphicsLayerQt.h" +#endif #include "HitTestResult.h" #include "Icon.h" #include "NotImplemented.h" #include "NotificationPresenterClientQt.h" -#include "ScrollbarTheme.h" -#include "WindowFeatures.h" +#include "PageClientQt.h" #if defined(Q_WS_MAEMO_5) #include "QtMaemoWebPopup.h" #else #include "QtFallbackWebPopup.h" #endif #include "QWebPageClient.h" +#include "ScrollbarTheme.h" #include "SecurityOrigin.h" +#include "ViewportArguments.h" +#include "WindowFeatures.h" +#include "qgraphicswebview.h" #include "qwebframe_p.h" #include "qwebpage.h" #include "qwebpage_p.h" #include "qwebsecurityorigin.h" #include "qwebsecurityorigin_p.h" #include "qwebview.h" - #include <qdebug.h> #include <qeventloop.h> #include <qtextdocument.h> #include <qtooltip.h> -#if USE(ACCELERATED_COMPOSITING) -#include "GraphicsLayerQt.h" -#endif - namespace WebCore { ChromeClientQt::ChromeClientQt(QWebPage* webPage) @@ -90,19 +91,18 @@ void ChromeClientQt::setWindowRect(const FloatRect& rect) qRound(rect.width()), qRound(rect.height()))); } - +/*! + windowRect represents the rect of the Window, including all interface elements + like toolbars/scrollbars etc. It is used by the viewport meta tag as well as + by the DOM Window object: outerHeight(), outerWidth(), screenX(), screenY(). +*/ FloatRect ChromeClientQt::windowRect() { - if (!m_webPage) - return FloatRect(); - - QWidget* view = m_webPage->view(); - if (!view) + if (!platformPageClient()) return FloatRect(); - return IntRect(view->window()->geometry()); + return platformPageClient()->windowRect(); } - FloatRect ChromeClientQt::pageRect() { if (!m_webPage) @@ -595,7 +595,7 @@ QtAbstractWebPopup* ChromeClientQt::createSelectPopup() #elif !defined(QT_NO_COMBOBOX) return new QtFallbackWebPopup; #else - return result; + return 0; #endif } @@ -626,4 +626,23 @@ bool ChromeClientQt::isMinimized() } #endif +void ChromeClientQt::didReceiveViewportArguments(Frame* frame, const ViewportArguments& arguments) const +{ + if (m_webPage->mainFrame()->d->initialLayoutComplete) + return; + + QSize viewportSize(arguments.width, arguments.height); + bool isUserScalable = arguments.userScalable == 1; + + QWebPage::ViewportHints hints; + hints.m_isValid = true; + hints.m_size = viewportSize; + hints.m_initialScaleFactor = arguments.initialScale; + hints.m_minimumScaleFactor = arguments.minimumScale; + hints.m_maximumScaleFactor = arguments.maximumScale; + hints.m_isUserScalable = isUserScalable; + + emit m_webPage->viewportChangeRequested(hints); } + +} // namespace WebCore diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.h b/WebKit/qt/WebCoreSupport/ChromeClientQt.h index 0396aef..4b55eb2 100644 --- a/WebKit/qt/WebCoreSupport/ChromeClientQt.h +++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.h @@ -48,6 +48,7 @@ namespace WebCore { class Page; struct FrameLoadRequest; class QtAbstractWebPopup; + struct ViewportArguments; class ChromeClientQt : public ChromeClient { @@ -177,6 +178,8 @@ namespace WebCore { QtAbstractWebPopup* createSelectPopup(); + virtual void didReceiveViewportArguments(Frame*, const ViewportArguments&) const; + QWebPage* m_webPage; WebCore::KURL lastHoverURL; WebCore::String lastHoverTitle; diff --git a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp index c92e43f..0ae55d7 100644 --- a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp +++ b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp @@ -331,13 +331,6 @@ void DumpRenderTreeSupportQt::resumeActiveDOMObjects(QWebFrame* frame) coreFrame->document()->resumeActiveDOMObjects(); } -void DumpRenderTreeSupportQt::evaluateScriptInIsolatedWorld(QWebFrame* frame, int worldId, const QString& script) -{ - Frame* coreFrame = QWebFramePrivate::core(frame); - if (coreFrame) - JSC::JSValue result = coreFrame->script()->executeScriptInWorld(mainThreadNormalWorld(), script, true).jsValue(); -} - void DumpRenderTreeSupportQt::whiteListAccessFromOrigin(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains) { SecurityOrigin::addOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains); @@ -621,7 +614,7 @@ QList<QWebHistoryItem> DumpRenderTreeSupportQt::getChildHistoryItems(const QWebH bool DumpRenderTreeSupportQt::shouldClose(QWebFrame* frame) { WebCore::Frame* coreFrame = QWebFramePrivate::core(frame); - return coreFrame->shouldClose(); + return coreFrame->loader()->shouldClose(); } // Provide a backward compatibility with previously exported private symbols as of QtWebKit 4.6 release diff --git a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h index e3408e3..0b94a03 100644 --- a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h +++ b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h @@ -70,7 +70,6 @@ public: static void setMediaType(QWebFrame* qframe, const QString& type); static void setDumpRenderTreeModeEnabled(bool b); - static void evaluateScriptInIsolatedWorld(QWebFrame* frame, int worldId, const QString& script); static void garbageCollectorCollect(); static void garbageCollectorCollectOnAlternateThread(bool waitUntilDone); static void setJavaScriptProfilingEnabled(QWebFrame*, bool enabled); diff --git a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp index 93e5745..e140968 100644 --- a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp @@ -611,6 +611,7 @@ void EditorClientQt::setInputMethodState(bool active) webPageClient->setInputMethodHint(Qt::ImhDigitsOnly, inputElement->isNumberField()); webPageClient->setInputMethodHint(Qt::ImhEmailCharactersOnly, inputElement->isEmailField()); webPageClient->setInputMethodHint(Qt::ImhUrlCharactersOnly, inputElement->isUrlField()); + webPageClient->setInputMethodHint(Qt::ImhHiddenText, inputElement->isPasswordField()); } } diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp index e86a84a..42b0c49 100644 --- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp @@ -380,6 +380,8 @@ void FrameLoaderClientQt::dispatchDidCommitLoad() if (m_frame->tree()->parent() || !m_webFrame) return; + m_webFrame->d->initialLayoutComplete = false; + emit m_webFrame->urlChanged(m_webFrame->url()); m_webFrame->page()->d->updateNavigationActions(); @@ -387,6 +389,12 @@ void FrameLoaderClientQt::dispatchDidCommitLoad() // will be called very soon with the correct title. // This properly resets the title when we navigate to a URI without a title. emit titleChanged(String()); + + bool isMainFrame = (m_frame == m_frame->page()->mainFrame()); + if (!isMainFrame) + return; + + emit m_webFrame->page()->viewportChangeRequested(QWebPage::ViewportHints()); } @@ -424,7 +432,7 @@ void FrameLoaderClientQt::dispatchDidFinishLoad() void FrameLoaderClientQt::dispatchDidFirstLayout() { - notImplemented(); + m_webFrame->d->initialLayoutComplete = true; } void FrameLoaderClientQt::dispatchDidFirstVisuallyNonEmptyLayout() diff --git a/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp b/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp index 8bde5c4..c90b3b5 100644 --- a/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp @@ -42,10 +42,10 @@ #include "qwebkitglobal.h" #include <QtGui> -#if ENABLE(NOTIFICATIONS) - namespace WebCore { +#if ENABLE(NOTIFICATIONS) + const double notificationTimeout = 10.0; bool NotificationPresenterClientQt::dumpNotification = false; @@ -61,51 +61,69 @@ NotificationPresenterClientQt* NotificationPresenterClientQt::notificationPresen return s_notificationPresenter; } -NotificationIconWrapper::NotificationIconWrapper() - : m_closeTimer(this, &NotificationIconWrapper::close) +#endif + +NotificationWrapper::NotificationWrapper() + : m_closeTimer(this, &NotificationWrapper::close) { +#if ENABLE(NOTIFICATIONS) + #ifndef QT_NO_SYSTEMTRAYICON m_notificationIcon = 0; #endif m_presenter = 0; +#endif } -NotificationIconWrapper::~NotificationIconWrapper() -{ -} - -void NotificationIconWrapper::close(Timer<NotificationIconWrapper>*) +void NotificationWrapper::close(Timer<NotificationWrapper>*) { +#if ENABLE(NOTIFICATIONS) NotificationPresenterClientQt::notificationPresenter()->cancel(this); +#endif } -const QString NotificationIconWrapper::title() const +const QString NotificationWrapper::title() const { +#if ENABLE(NOTIFICATIONS) Notification* notification = NotificationPresenterClientQt::notificationPresenter()->notificationForWrapper(this); if (notification) return notification->contents().title(); +#endif return QString(); } -const QString NotificationIconWrapper::message() const +const QString NotificationWrapper::message() const { +#if ENABLE(NOTIFICATIONS) Notification* notification = NotificationPresenterClientQt::notificationPresenter()->notificationForWrapper(this); if (notification) return notification->contents().body(); +#endif return QString(); } -const QByteArray NotificationIconWrapper::iconData() const +const QByteArray NotificationWrapper::iconData() const { - Notification* notification = NotificationPresenterClientQt::notificationPresenter()->notificationForWrapper(this); QByteArray iconData; +#if ENABLE(NOTIFICATIONS) + Notification* notification = NotificationPresenterClientQt::notificationPresenter()->notificationForWrapper(this); if (notification) { if (notification->iconData()) iconData = QByteArray::fromRawData(notification->iconData()->data(), notification->iconData()->size()); } +#endif return iconData; } +void NotificationWrapper::notificationClosed() +{ +#if ENABLE(NOTIFICATIONS) + NotificationPresenterClientQt::notificationPresenter()->cancel(this); +#endif +} + +#if ENABLE(NOTIFICATIONS) + NotificationPresenterClientQt::NotificationPresenterClientQt() : m_clientCount(0) { } @@ -127,11 +145,6 @@ void NotificationPresenterClientQt::removeClient() } } -void NotificationIconWrapper::notificationClosed() -{ - NotificationPresenterClientQt::notificationPresenter()->cancel(this); -} - bool NotificationPresenterClientQt::show(Notification* notification) { // FIXME: workers based notifications are not supported yet. @@ -152,7 +165,7 @@ bool NotificationPresenterClientQt::show(Notification* notification) void NotificationPresenterClientQt::displayNotification(Notification* notification, const QByteArray& bytes) { - NotificationIconWrapper* wrapper = new NotificationIconWrapper(); + NotificationWrapper* wrapper = new NotificationWrapper(); m_notifications.insert(notification, wrapper); QString title; QString message; @@ -213,14 +226,14 @@ void NotificationPresenterClientQt::cancel(Notification* notification) } } -void NotificationPresenterClientQt::cancel(NotificationIconWrapper* wrapper) +void NotificationPresenterClientQt::cancel(NotificationWrapper* wrapper) { Notification* notification = notificationForWrapper(wrapper); if (notification) cancel(notification); } -Notification* NotificationPresenterClientQt::notificationForWrapper(const NotificationIconWrapper* wrapper) const +Notification* NotificationPresenterClientQt::notificationForWrapper(const NotificationWrapper* wrapper) const { NotificationsQueue::ConstIterator end = m_notifications.end(); NotificationsQueue::ConstIterator iter = m_notifications.begin(); @@ -341,5 +354,7 @@ void NotificationPresenterClientQt::dumpShowText(Notification* notification) } } -} #endif // ENABLE(NOTIFICATIONS) +} + +#include "moc_NotificationPresenterClientQt.cpp" diff --git a/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h b/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h index 1630cd9..82c5f7c 100644 --- a/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h +++ b/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h @@ -47,14 +47,14 @@ namespace WebCore { class Document; class KURL; -class NotificationIconWrapper : public QObject, public QWebNotificationData { +class NotificationWrapper : public QObject, public QWebNotificationData { Q_OBJECT public: - NotificationIconWrapper(); - ~NotificationIconWrapper(); + NotificationWrapper(); + ~NotificationWrapper() {} void close(); - void close(Timer<NotificationIconWrapper>*); + void close(Timer<NotificationWrapper>*); const QString title() const; const QString message() const; const QByteArray iconData() const; @@ -68,12 +68,12 @@ public: #endif OwnPtr<QWebNotificationPresenter> m_presenter; - Timer<NotificationIconWrapper> m_closeTimer; + Timer<NotificationWrapper> m_closeTimer; }; #if ENABLE(NOTIFICATIONS) -typedef QHash <Notification*, NotificationIconWrapper*> NotificationsQueue; +typedef QHash <Notification*, NotificationWrapper*> NotificationsQueue; class NotificationPresenterClientQt : public NotificationPresenter { public: @@ -87,7 +87,7 @@ public: virtual void requestPermission(SecurityOrigin*, PassRefPtr<VoidCallback>); virtual NotificationPresenter::Permission checkPermission(const KURL&); - void cancel(NotificationIconWrapper*); + void cancel(NotificationWrapper*); void allowNotificationForOrigin(const QString& origin); @@ -99,7 +99,7 @@ public: void removeClient(); static NotificationPresenterClientQt* notificationPresenter(); - Notification* notificationForWrapper(const NotificationIconWrapper*) const; + Notification* notificationForWrapper(const NotificationWrapper*) const; private: void sendEvent(Notification*, const AtomicString& eventName); diff --git a/WebKit/qt/WebCoreSupport/PageClientQt.cpp b/WebKit/qt/WebCoreSupport/PageClientQt.cpp index 4ccf34a..f52c382 100644 --- a/WebKit/qt/WebCoreSupport/PageClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/PageClientQt.cpp @@ -103,6 +103,11 @@ QStyle* PageClientQWidget::style() const return view->style(); } +QRectF PageClientQWidget::windowRect() const +{ + return QRectF(view->window()->geometry()); +} + PageClientQGraphicsWidget::~PageClientQGraphicsWidget() { #if USE(ACCELERATED_COMPOSITING) @@ -292,14 +297,14 @@ QRect PageClientQGraphicsWidget::geometryRelativeToOwnerWidget() const #if ENABLE(TILED_BACKING_STORE) QRectF PageClientQGraphicsWidget::graphicsItemVisibleRect() const -{ +{ if (!view->scene()) return QRectF(); QList<QGraphicsView*> views = view->scene()->views(); if (views.isEmpty()) return QRectF(); - + QGraphicsView* graphicsView = views.at(0); int xOffset = graphicsView->horizontalScrollBar()->value(); int yOffset = graphicsView->verticalScrollBar()->value(); @@ -317,6 +322,13 @@ QStyle* PageClientQGraphicsWidget::style() const return view->style(); } +QRectF PageClientQGraphicsWidget::windowRect() const +{ + if (!view->scene()) + return QRectF(); - + // The sceneRect is a good approximation of the size of the application, independent of the view. + return view->scene()->sceneRect(); } + +} // namespace WebCore diff --git a/WebKit/qt/WebCoreSupport/PageClientQt.h b/WebKit/qt/WebCoreSupport/PageClientQt.h index 818c67a..4d42ca1 100644 --- a/WebKit/qt/WebCoreSupport/PageClientQt.h +++ b/WebKit/qt/WebCoreSupport/PageClientQt.h @@ -76,9 +76,11 @@ public: virtual QObject* pluginParent() const; virtual QStyle* style() const; - + virtual bool viewResizesToContentsEnabled() const { return false; } + virtual QRectF windowRect() const; + QWidget* view; }; @@ -182,6 +184,8 @@ public: virtual bool allowsAcceleratedCompositing() const { return true; } #endif + virtual QRectF windowRect() const; + QGraphicsWidget* view; QWebPage* page; bool viewResizesToContents; diff --git a/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp b/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp index 5e7e6d1..cccb07c 100644 --- a/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp +++ b/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp @@ -56,16 +56,24 @@ QWebSelectData::ItemType SelectData::itemType(int index) const SelectInputMethodWrapper::SelectInputMethodWrapper(QWebSelectMethod* plugin) : m_plugin(plugin) + , m_selectData(0) { m_plugin->setParent(this); connect(m_plugin, SIGNAL(didHide()), this, SLOT(didHide())); connect(m_plugin, SIGNAL(selectItem(int, bool, bool)), this, SLOT(selectItem(int, bool, bool))); } +SelectInputMethodWrapper::~SelectInputMethodWrapper() +{ + delete m_selectData; +} + void SelectInputMethodWrapper::show() { - SelectData data(this); - m_plugin->show(data); + if (m_selectData) + delete m_selectData; + m_selectData = new SelectData(this); + m_plugin->show(*m_selectData); } void SelectInputMethodWrapper::hide() diff --git a/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h b/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h index ff10d58..2de4859 100644 --- a/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h +++ b/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h @@ -28,6 +28,7 @@ class QWebSelectMethod; class QWebKitPlatformPlugin; class QWebNotificationPresenter; +class QWebSelectData; namespace WebCore { @@ -35,6 +36,7 @@ class SelectInputMethodWrapper : public QObject, public QtAbstractWebPopup { Q_OBJECT public: SelectInputMethodWrapper(QWebSelectMethod* plugin); + ~SelectInputMethodWrapper(); virtual void show(); virtual void hide(); @@ -45,6 +47,7 @@ private Q_SLOTS: private: QWebSelectMethod* m_plugin; + QWebSelectData* m_selectData; }; class QtPlatformPlugin { diff --git a/WebKit/qt/declarative/declarative.pro b/WebKit/qt/declarative/declarative.pro new file mode 100644 index 0000000..75268f3 --- /dev/null +++ b/WebKit/qt/declarative/declarative.pro @@ -0,0 +1,72 @@ +TARGET = qmlwebkitplugin +TARGETPATH = QtWebKit + +TEMPLATE = lib +CONFIG += qt plugin + +win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release + +isEmpty(OUTPUT_DIR): OUTPUT_DIR = ../../.. + +QMLDIRFILE = $${_PRO_FILE_PWD_}/qmldir +copy2build.input = QMLDIRFILE +CONFIG(QTDIR_build) { + copy2build.output = $$QT_BUILD_TREE/imports/$$TARGETPATH/qmldir +} else { + copy2build.output = $$OUTPUT_DIR/imports/$$TARGETPATH/qmldir +} +!contains(TEMPLATE_PREFIX, vc):copy2build.variable_out = PRE_TARGETDEPS +copy2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} +copy2build.name = COPY ${QMAKE_FILE_IN} +copy2build.CONFIG += no_link +QMAKE_EXTRA_COMPILERS += copy2build + +TARGET = $$qtLibraryTarget($$TARGET) +contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols + +wince*:LIBS += $$QMAKE_LIBS_GUI + +symbian: { + TARGET.EPOCALLOWDLLDATA=1 + TARGET.CAPABILITY = All -Tcb + load(armcc_warnings) +} + +include(../../../WebKit.pri) + +QT += declarative + +!CONFIG(standalone_package) { + linux-* { + # From Creator's src/rpath.pri: + # Do the rpath by hand since it's not possible to use ORIGIN in QMAKE_RPATHDIR + # this expands to $ORIGIN (after qmake and make), it does NOT read a qmake var. + QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR + MY_RPATH = $$join(QMAKE_RPATHDIR, ":") + + QMAKE_LFLAGS += -Wl,-z,origin \'-Wl,-rpath,$${MY_RPATH}\' + QMAKE_RPATHDIR = + } else { + QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR + } +} + +SOURCES += qdeclarativewebview.cpp plugin.cpp +HEADERS += qdeclarativewebview_p.h + +CONFIG(QTDIR_build) { + DESTDIR = $$QT_BUILD_TREE/imports/$$TARGETPATH +} else { + DESTDIR = $$OUTPUT_DIR/imports/$$TARGETPATH +} +target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH + + +qmldir.files += $$PWD/qmldir +qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH + +symbian:{ + TARGET.UID3 = 0x20021321 +} + +INSTALLS += target qmldir diff --git a/WebKit/qt/declarative/plugin.cpp b/WebKit/qt/declarative/plugin.cpp new file mode 100644 index 0000000..f1f165e --- /dev/null +++ b/WebKit/qt/declarative/plugin.cpp @@ -0,0 +1,43 @@ +/* + 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 "qdeclarativewebview_p.h" + +#include <QtDeclarative/qdeclarative.h> +#include <QtDeclarative/qdeclarativeextensionplugin.h> + +QT_BEGIN_NAMESPACE + +class WebKitQmlPlugin : public QDeclarativeExtensionPlugin { + Q_OBJECT +public: + virtual void registerTypes(const char* uri) + { + Q_ASSERT(QLatin1String(uri) == QLatin1String("QtWebKit")); + qmlRegisterType<QDeclarativeWebSettings>(); + qmlRegisterType<QDeclarativeWebView>(uri, 1, 0, "WebView"); + } +}; + +QT_END_NAMESPACE + +#include "plugin.moc" + +Q_EXPORT_PLUGIN2(qmlwebkitplugin, QT_PREPEND_NAMESPACE(WebKitQmlPlugin)); + diff --git a/WebKit/qt/declarative/qdeclarativewebview.cpp b/WebKit/qt/declarative/qdeclarativewebview.cpp new file mode 100644 index 0000000..a349bec --- /dev/null +++ b/WebKit/qt/declarative/qdeclarativewebview.cpp @@ -0,0 +1,1022 @@ +/* + 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 "qdeclarativewebview_p.h" + +#include <QtCore/QDebug> +#include <QtCore/QEvent> +#include <QtCore/QFile> +#include <QtDeclarative/QDeclarativeContext> +#include <QtDeclarative/QDeclarativeEngine> +#include <QtDeclarative/qdeclarative.h> +#include <QtGui/QApplication> +#include <QtGui/QGraphicsSceneMouseEvent> +#include <QtGui/QKeyEvent> +#include <QtGui/QMouseEvent> +#include <QtGui/QPen> +#include "qwebelement.h" +#include "qwebframe.h" +#include "qwebpage.h" +#include "qwebsettings.h" + +QT_BEGIN_NAMESPACE + +class QDeclarativeWebViewPrivate { +public: + QDeclarativeWebViewPrivate(QDeclarativeWebView* qq) + : q(qq) + , preferredwidth(0) + , preferredheight(0) + , progress(1.0) + , status(QDeclarativeWebView::Null) + , pending(PendingNone) + , newWindowComponent(0) + , newWindowParent(0) + , rendering(true) + { + } + + QDeclarativeWebView* q; + + QUrl url; // page url might be different if it has not loaded yet + GraphicsWebView* view; + + int preferredwidth, preferredheight; + qreal progress; + QDeclarativeWebView::Status status; + QString statusText; + enum { PendingNone, PendingUrl, PendingHtml, PendingContent } pending; + QUrl pendingUrl; + QString pendingString; + QByteArray pendingData; + mutable QDeclarativeWebSettings settings; + QDeclarativeComponent* newWindowComponent; + QDeclarativeItem* newWindowParent; + + static void windowObjectsAppend(QDeclarativeListProperty<QObject>* prop, QObject* o) + { + static_cast<QDeclarativeWebViewPrivate*>(prop->data)->windowObjects.append(o); + static_cast<QDeclarativeWebViewPrivate*>(prop->data)->updateWindowObjects(); + } + + void updateWindowObjects(); + QObjectList windowObjects; + + bool rendering; +}; + +GraphicsWebView::GraphicsWebView(QDeclarativeWebView* parent) + : QGraphicsWebView(parent) + , parent(parent) + , pressTime(400) +{ +} + +void GraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent* event) +{ + setFocus(); + pressPoint = event->pos(); + if (pressTime) { + pressTimer.start(pressTime, this); + parent->setKeepMouseGrab(false); + } else { + grabMouse(); + parent->setKeepMouseGrab(true); + } + QGraphicsWebView::mousePressEvent(event); +} + +void GraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) +{ + QGraphicsWebView::mouseReleaseEvent(event); + pressTimer.stop(); + parent->setKeepMouseGrab(false); + ungrabMouse(); +} + +void GraphicsWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) +{ + QMouseEvent* me = new QMouseEvent(QEvent::MouseButtonDblClick, (event->pos() / parent->contentsScale()).toPoint(), event->button(), event->buttons(), 0); + emit doubleClick(event->pos().x(), event->pos().y()); + delete me; +} + +void GraphicsWebView::timerEvent(QTimerEvent* event) +{ + if (event->timerId() == pressTimer.timerId()) { + pressTimer.stop(); + grabMouse(); + parent->setKeepMouseGrab(true); + } +} + +void GraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent* event) +{ + if (pressTimer.isActive()) { + if ((event->pos() - pressPoint).manhattanLength() > QApplication::startDragDistance()) + pressTimer.stop(); + } + if (parent->keepMouseGrab()) + QGraphicsWebView::mouseMoveEvent(event); +} + +/*! + \qmlclass WebView QDeclarativeWebView + \since 4.7 + \brief The WebView item allows you to add web content to a canvas. + \inherits Item + + A WebView renders web content based on a URL. + + This type is made available by importing the \c QtWebKit module: + + \bold{import QtWebKit 1.0} + + If the width and height of the item is not set, they will + dynamically adjust to a size appropriate for the content. + This width may be large for typical online web pages. + + If the width or height is explictly set, the rendered website + will be clipped, not scaled, to fit into the set dimensions. + + If the preferredWidth is set, the width will be this amount or larger, + usually laying out the web content to fit the preferredWidth. + + \qml + import QtWebKit 1.0 + + WebView { + url: "http://www.nokia.com" + preferredWidth: 490 + preferredHeight: 400 + scale: 0.5 + smooth: false + smoothCache: true + } + \endqml + + \image webview.png + + The item includes no scrolling, scaling, + toolbars, etc., those must be implemented around WebView. See the WebBrowser example + for a demonstration of this. + + When this item has keyboard focus, all keyboard input will be sent directly to the + web page within. +*/ + +/*! + \internal + \class QDeclarativeWebView + \brief The QDeclarativeWebView class allows you to add web content to a QDeclarativeView. + + A WebView renders web content base on a URL. + + \image webview.png + + The item includes no scrolling, scaling, + toolbars, etc., those must be implemented around WebView. See the WebBrowser example + for a demonstration of this. + + A QDeclarativeWebView object can be instantiated in Qml using the tag \l WebView. +*/ + +QDeclarativeWebView::QDeclarativeWebView(QDeclarativeItem *parent) : QDeclarativeItem(parent) +{ + init(); +} + +QDeclarativeWebView::~QDeclarativeWebView() +{ + delete d; +} + +void QDeclarativeWebView::init() +{ + d = new QDeclarativeWebViewPrivate(this); + + QWebSettings::enablePersistentStorage(); + + setAcceptedMouseButtons(Qt::LeftButton); + setFlag(QGraphicsItem::ItemHasNoContents, true); + setClip(true); + + d->view = new GraphicsWebView(this); + d->view->setResizesToContents(true); + QWebPage* wp = new QDeclarativeWebPage(this); + setPage(wp); + connect(d->view, SIGNAL(geometryChanged()), this, SLOT(updateDeclarativeWebViewSize())); + connect(d->view, SIGNAL(doubleClick(int, int)), this, SIGNAL(doubleClick(int, int))); + connect(d->view, SIGNAL(scaleChanged()), this, SIGNAL(contentsScaleChanged())); +} + +void QDeclarativeWebView::componentComplete() +{ + QDeclarativeItem::componentComplete(); + page()->setNetworkAccessManager(qmlEngine(this)->networkAccessManager()); + + switch (d->pending) { + case QDeclarativeWebViewPrivate::PendingUrl: + setUrl(d->pendingUrl); + break; + case QDeclarativeWebViewPrivate::PendingHtml: + setHtml(d->pendingString, d->pendingUrl); + break; + case QDeclarativeWebViewPrivate::PendingContent: + setContent(d->pendingData, d->pendingString, d->pendingUrl); + break; + default: + break; + } + d->pending = QDeclarativeWebViewPrivate::PendingNone; + d->updateWindowObjects(); +} + +QDeclarativeWebView::Status QDeclarativeWebView::status() const +{ + return d->status; +} + + +/*! + \qmlproperty real WebView::progress + This property holds the progress of loading the current URL, from 0 to 1. + + If you just want to know when progress gets to 1, use + WebView::onLoadFinished() or WebView::onLoadFailed() instead. +*/ +qreal QDeclarativeWebView::progress() const +{ + return d->progress; +} + +void QDeclarativeWebView::doLoadStarted() +{ + if (!d->url.isEmpty()) { + d->status = Loading; + emit statusChanged(d->status); + } + emit loadStarted(); +} + +void QDeclarativeWebView::doLoadProgress(int p) +{ + if (d->progress == p / 100.0) + return; + d->progress = p / 100.0; + emit progressChanged(); +} + +void QDeclarativeWebView::pageUrlChanged() +{ + updateContentsSize(); + + if ((d->url.isEmpty() && page()->mainFrame()->url() != QUrl(QLatin1String("about:blank"))) + || (d->url != page()->mainFrame()->url() && !page()->mainFrame()->url().isEmpty())) + { + d->url = page()->mainFrame()->url(); + if (d->url == QUrl(QLatin1String("about:blank"))) + d->url = QUrl(); + emit urlChanged(); + } +} + +void QDeclarativeWebView::doLoadFinished(bool ok) +{ + if (ok) { + d->status = d->url.isEmpty() ? Null : Ready; + emit loadFinished(); + } else { + d->status = Error; + emit loadFailed(); + } + emit statusChanged(d->status); +} + +/*! + \qmlproperty url WebView::url + This property holds the URL to the page displayed in this item. It can be set, + but also can change spontaneously (eg. because of network redirection). + + If the url is empty, the page is blank. + + The url is always absolute (QML will resolve relative URL strings in the context + of the containing QML document). +*/ +QUrl QDeclarativeWebView::url() const +{ + return d->url; +} + +void QDeclarativeWebView::setUrl(const QUrl& url) +{ + if (url == d->url) + return; + + if (isComponentComplete()) { + d->url = url; + updateContentsSize(); + QUrl seturl = url; + if (seturl.isEmpty()) + seturl = QUrl(QLatin1String("about:blank")); + + Q_ASSERT(!seturl.isRelative()); + + page()->mainFrame()->load(seturl); + + emit urlChanged(); + } else { + d->pending = d->PendingUrl; + d->pendingUrl = url; + } +} + +/*! + \qmlproperty int WebView::preferredWidth + This property holds the ideal width for displaying the current URL. +*/ +int QDeclarativeWebView::preferredWidth() const +{ + return d->preferredwidth; +} + +void QDeclarativeWebView::setPreferredWidth(int width) +{ + if (d->preferredwidth == width) + return; + d->preferredwidth = width; + updateContentsSize(); + emit preferredWidthChanged(); +} + +/*! + \qmlproperty int WebView::preferredHeight + This property holds the ideal height for displaying the current URL. + This only affects the area zoomed by heuristicZoom(). +*/ +int QDeclarativeWebView::preferredHeight() const +{ + return d->preferredheight; +} + +void QDeclarativeWebView::setPreferredHeight(int height) +{ + if (d->preferredheight == height) + return; + d->preferredheight = height; + updateContentsSize(); + emit preferredHeightChanged(); +} + +/*! + \qmlmethod bool WebView::evaluateJavaScript(string) + + Evaluates the \a scriptSource JavaScript inside the context of the + main web frame, and returns the result of the last executed statement. + + Note that this JavaScript does \e not have any access to QML objects + except as made available as windowObjects. +*/ +QVariant QDeclarativeWebView::evaluateJavaScript(const QString& scriptSource) +{ + return this->page()->mainFrame()->evaluateJavaScript(scriptSource); +} + +void QDeclarativeWebView::updateDeclarativeWebViewSize() +{ + QSizeF size = d->view->geometry().size() * contentsScale(); + setImplicitWidth(size.width()); + setImplicitHeight(size.height()); +} + +void QDeclarativeWebView::initialLayout() +{ + // nothing useful to do at this point +} + +void QDeclarativeWebView::updateContentsSize() +{ + if (page()) { + page()->setPreferredContentsSize(QSize( + d->preferredwidth>0 ? d->preferredwidth : width(), + d->preferredheight>0 ? d->preferredheight : height())); + } +} + +void QDeclarativeWebView::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) +{ + QWebPage* webPage = page(); + if (newGeometry.size() != oldGeometry.size() && webPage) { + QSize contentSize = webPage->preferredContentsSize(); + if (widthValid()) + contentSize.setWidth(width()); + if (heightValid()) + contentSize.setHeight(height()); + if (contentSize != webPage->preferredContentsSize()) + webPage->setPreferredContentsSize(contentSize); + } + QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); +} + +/*! + \qmlproperty list<object> WebView::javaScriptWindowObjects + + A list of QML objects to expose to the web page. + + Each object will be added as a property of the web frame's window object. The + property name is controlled by the value of \c WebView.windowObjectName + attached property. + + Exposing QML objects to a web page allows JavaScript executing in the web + page itself to communicate with QML, by reading and writing properties and + by calling methods of the exposed QML objects. + + This example shows how to call into a QML method using a window object. + + \qml + WebView { + javaScriptWindowObjects: QtObject { + WebView.windowObjectName: "qml" + + function qmlCall() { + console.log("This call is in QML!"); + } + } + + html: "<script>console.log(\"This is in WebKit!\"); window.qml.qmlCall();</script>" + } + \endqml + + The output of the example will be: + \code + This is in WebKit! + This call is in QML! + \endcode + + If Javascript is not enabled for the page, then this property does nothing. +*/ +QDeclarativeListProperty<QObject> QDeclarativeWebView::javaScriptWindowObjects() +{ + return QDeclarativeListProperty<QObject>(this, d, &QDeclarativeWebViewPrivate::windowObjectsAppend); +} + +QDeclarativeWebViewAttached* QDeclarativeWebView::qmlAttachedProperties(QObject* o) +{ + return new QDeclarativeWebViewAttached(o); +} + +void QDeclarativeWebViewPrivate::updateWindowObjects() +{ + if (!q->isComponentCompletePublic() || !q->page()) + return; + + for (int i = 0; i < windowObjects.count(); ++i) { + QObject* object = windowObjects.at(i); + QDeclarativeWebViewAttached* attached = static_cast<QDeclarativeWebViewAttached *>(qmlAttachedPropertiesObject<QDeclarativeWebView>(object)); + if (attached && !attached->windowObjectName().isEmpty()) + q->page()->mainFrame()->addToJavaScriptWindowObject(attached->windowObjectName(), object); + } +} + +bool QDeclarativeWebView::renderingEnabled() const +{ + return d->rendering; +} + +void QDeclarativeWebView::setRenderingEnabled(bool enabled) +{ + if (d->rendering == enabled) + return; + d->rendering = enabled; + emit renderingEnabledChanged(); + d->view->setTiledBackingStoreFrozen(!enabled); +} + +/*! + \qmlsignal WebView::onDoubleClick(clickx, clicky) + + The WebView does not pass double-click events to the web engine, but rather + emits this signals. +*/ + +/*! + \qmlmethod bool WebView::heuristicZoom(clickX,clickY,maxzoom) + + Finds a zoom that: + \list + \i shows a whole item + \i includes (\a clickX, \a clickY) + \i fits into the preferredWidth and preferredHeight + \i zooms by no more than \a maxZoom + \i is more than 10% above the current zoom + \endlist + + If such a zoom exists, emits zoomTo(zoom,centerX,centerY) and returns true; otherwise, + no signal is emitted and returns false. +*/ +bool QDeclarativeWebView::heuristicZoom(int clickX, int clickY, qreal maxZoom) +{ + if (contentsScale() >= maxZoom / scale()) + return false; + qreal ozf = contentsScale(); + QRect showArea = elementAreaAt(clickX, clickY, d->preferredwidth / maxZoom, d->preferredheight / maxZoom); + qreal z = qMin(qreal(d->preferredwidth) / showArea.width(), qreal(d->preferredheight) / showArea.height()); + if (z > maxZoom / scale()) + z = maxZoom / scale(); + if (z / ozf > 1.2) { + QRectF r(showArea.left() * z, showArea.top() * z, showArea.width() * z, showArea.height() * z); + emit zoomTo(z, r.x() + r.width() / 2, r.y() + r.height() / 2); + return true; + } + return false; +} + +/*! + \qmlproperty int WebView::pressGrabTime + + The number of milliseconds the user must press before the WebView + starts passing move events through to the web engine (rather than + letting other QML elements such as a Flickable take them). + + Defaults to 400ms. Set to 0 to always grab and pass move events to + the web engine. +*/ +int QDeclarativeWebView::pressGrabTime() const +{ + return d->view->pressTime; +} + +void QDeclarativeWebView::setPressGrabTime(int millis) +{ + if (d->view->pressTime == millis) + return; + d->view->pressTime = millis; + emit pressGrabTimeChanged(); +} + +#ifndef QT_NO_ACTION +/*! + \qmlproperty action WebView::back + This property holds the action for causing the previous URL in the history to be displayed. +*/ +QAction* QDeclarativeWebView::backAction() const +{ + return page()->action(QWebPage::Back); +} + +/*! + \qmlproperty action WebView::forward + This property holds the action for causing the next URL in the history to be displayed. +*/ +QAction* QDeclarativeWebView::forwardAction() const +{ + return page()->action(QWebPage::Forward); +} + +/*! + \qmlproperty action WebView::reload + This property holds the action for reloading with the current URL +*/ +QAction* QDeclarativeWebView::reloadAction() const +{ + return page()->action(QWebPage::Reload); +} + +/*! + \qmlproperty action WebView::stop + This property holds the action for stopping loading with the current URL +*/ +QAction* QDeclarativeWebView::stopAction() const +{ + return page()->action(QWebPage::Stop); +} +#endif // QT_NO_ACTION + +/*! + \qmlproperty real WebView::title + This property holds the title of the web page currently viewed + + By default, this property contains an empty string. +*/ +QString QDeclarativeWebView::title() const +{ + return page()->mainFrame()->title(); +} + +/*! + \qmlproperty pixmap WebView::icon + This property holds the icon associated with the web page currently viewed +*/ +QPixmap QDeclarativeWebView::icon() const +{ + return page()->mainFrame()->icon().pixmap(QSize(256, 256)); +} + +/*! + \qmlproperty string WebView::statusText + + This property is the current status suggested by the current web page. In a web browser, + such status is often shown in some kind of status bar. +*/ +void QDeclarativeWebView::setStatusText(const QString& text) +{ + d->statusText = text; + emit statusTextChanged(); +} + +void QDeclarativeWebView::windowObjectCleared() +{ + d->updateWindowObjects(); +} + +QString QDeclarativeWebView::statusText() const +{ + return d->statusText; +} + +QWebPage* QDeclarativeWebView::page() const +{ + return d->view->page(); +} + +// The QObject interface to settings(). +/*! + \qmlproperty string WebView::settings.standardFontFamily + \qmlproperty string WebView::settings.fixedFontFamily + \qmlproperty string WebView::settings.serifFontFamily + \qmlproperty string WebView::settings.sansSerifFontFamily + \qmlproperty string WebView::settings.cursiveFontFamily + \qmlproperty string WebView::settings.fantasyFontFamily + + \qmlproperty int WebView::settings.minimumFontSize + \qmlproperty int WebView::settings.minimumLogicalFontSize + \qmlproperty int WebView::settings.defaultFontSize + \qmlproperty int WebView::settings.defaultFixedFontSize + + \qmlproperty bool WebView::settings.autoLoadImages + \qmlproperty bool WebView::settings.javascriptEnabled + \qmlproperty bool WebView::settings.javaEnabled + \qmlproperty bool WebView::settings.pluginsEnabled + \qmlproperty bool WebView::settings.privateBrowsingEnabled + \qmlproperty bool WebView::settings.javascriptCanOpenWindows + \qmlproperty bool WebView::settings.javascriptCanAccessClipboard + \qmlproperty bool WebView::settings.developerExtrasEnabled + \qmlproperty bool WebView::settings.linksIncludedInFocusChain + \qmlproperty bool WebView::settings.zoomTextOnly + \qmlproperty bool WebView::settings.printElementBackgrounds + \qmlproperty bool WebView::settings.offlineStorageDatabaseEnabled + \qmlproperty bool WebView::settings.offlineWebApplicationCacheEnabled + \qmlproperty bool WebView::settings.localStorageDatabaseEnabled + \qmlproperty bool WebView::settings.localContentCanAccessRemoteUrls + + These properties give access to the settings controlling the web view. + + See QWebSettings for details of these properties. + + \qml + WebView { + settings.pluginsEnabled: true + settings.standardFontFamily: "Arial" + ... + } + \endqml +*/ +QDeclarativeWebSettings* QDeclarativeWebView::settingsObject() const +{ + d->settings.s = page()->settings(); + return &d->settings; +} + +void QDeclarativeWebView::setPage(QWebPage* page) +{ + if (d->view->page() == page) + return; + + d->view->setPage(page); + updateContentsSize(); + page->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); + page->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); + connect(page->mainFrame(), SIGNAL(urlChanged(QUrl)), this, SLOT(pageUrlChanged())); + connect(page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString))); + connect(page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(iconChanged())); + connect(page->mainFrame(), SIGNAL(iconChanged()), this, SIGNAL(iconChanged())); + connect(page->mainFrame(), SIGNAL(initialLayoutCompleted()), this, SLOT(initialLayout())); + connect(page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SIGNAL(contentsSizeChanged(QSize))); + + connect(page, SIGNAL(loadStarted()), this, SLOT(doLoadStarted())); + connect(page, SIGNAL(loadProgress(int)), this, SLOT(doLoadProgress(int))); + connect(page, SIGNAL(loadFinished(bool)), this, SLOT(doLoadFinished(bool))); + connect(page, SIGNAL(statusBarMessage(QString)), this, SLOT(setStatusText(QString))); + + connect(page->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(windowObjectCleared())); + + page->settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, true); + +} + +/*! + \qmlsignal WebView::onLoadStarted() + + This handler is called when the web engine begins loading + a page. Later, WebView::onLoadFinished() or WebView::onLoadFailed() + will be emitted. +*/ + +/*! + \qmlsignal WebView::onLoadFinished() + + This handler is called when the web engine \e successfully + finishes loading a page, including any component content + (WebView::onLoadFailed() will be emitted otherwise). + + \sa progress +*/ + +/*! + \qmlsignal WebView::onLoadFailed() + + This handler is called when the web engine fails loading + a page or any component content + (WebView::onLoadFinished() will be emitted on success). +*/ + +void QDeclarativeWebView::load(const QNetworkRequest& request, QNetworkAccessManager::Operation operation, const QByteArray& body) +{ + page()->mainFrame()->load(request, operation, body); +} + +QString QDeclarativeWebView::html() const +{ + return page()->mainFrame()->toHtml(); +} + +/*! + \qmlproperty string WebView::html + This property holds HTML text set directly + + The html property can be set as a string. + + \qml + WebView { + html: "<p>This is <b>HTML</b>." + } + \endqml +*/ +void QDeclarativeWebView::setHtml(const QString& html, const QUrl& baseUrl) +{ + updateContentsSize(); + if (isComponentComplete()) + page()->mainFrame()->setHtml(html, baseUrl); + else { + d->pending = d->PendingHtml; + d->pendingUrl = baseUrl; + d->pendingString = html; + } + emit htmlChanged(); +} + +void QDeclarativeWebView::setContent(const QByteArray& data, const QString& mimeType, const QUrl& baseUrl) +{ + updateContentsSize(); + + if (isComponentComplete()) + page()->mainFrame()->setContent(data, mimeType, qmlContext(this)->resolvedUrl(baseUrl)); + else { + d->pending = d->PendingContent; + d->pendingUrl = baseUrl; + d->pendingString = mimeType; + d->pendingData = data; + } +} + +QWebHistory* QDeclarativeWebView::history() const +{ + return page()->history(); +} + +QWebSettings* QDeclarativeWebView::settings() const +{ + return page()->settings(); +} + +QDeclarativeWebView* QDeclarativeWebView::createWindow(QWebPage::WebWindowType type) +{ + switch (type) { + case QWebPage::WebBrowserWindow: { + if (!d->newWindowComponent && d->newWindowParent) + qWarning("WebView::newWindowComponent not set - WebView::newWindowParent ignored"); + else if (d->newWindowComponent && !d->newWindowParent) + qWarning("WebView::newWindowParent not set - WebView::newWindowComponent ignored"); + else if (d->newWindowComponent && d->newWindowParent) { + QDeclarativeWebView* webview = 0; + QDeclarativeContext* windowContext = new QDeclarativeContext(qmlContext(this)); + + QObject* newObject = d->newWindowComponent->create(windowContext); + if (newObject) { + windowContext->setParent(newObject); + QDeclarativeItem* item = qobject_cast<QDeclarativeItem *>(newObject); + if (!item) + delete newObject; + else { + webview = item->findChild<QDeclarativeWebView*>(); + if (!webview) + delete item; + else { + newObject->setParent(d->newWindowParent); + static_cast<QGraphicsObject*>(item)->setParentItem(d->newWindowParent); + } + } + } else + delete windowContext; + + return webview; + } + } + break; + case QWebPage::WebModalDialog: { + // Not supported + } + } + return 0; +} + +/*! + \qmlproperty component WebView::newWindowComponent + + This property holds the component to use for new windows. + The component must have a WebView somewhere in its structure. + + When the web engine requests a new window, it will be an instance of + this component. + + The parent of the new window is set by newWindowParent. It must be set. +*/ +QDeclarativeComponent* QDeclarativeWebView::newWindowComponent() const +{ + return d->newWindowComponent; +} + +void QDeclarativeWebView::setNewWindowComponent(QDeclarativeComponent* newWindow) +{ + if (newWindow == d->newWindowComponent) + return; + d->newWindowComponent = newWindow; + emit newWindowComponentChanged(); +} + + +/*! + \qmlproperty item WebView::newWindowParent + + The parent item for new windows. + + \sa newWindowComponent +*/ +QDeclarativeItem* QDeclarativeWebView::newWindowParent() const +{ + return d->newWindowParent; +} + +void QDeclarativeWebView::setNewWindowParent(QDeclarativeItem* parent) +{ + if (parent == d->newWindowParent) + return; + if (d->newWindowParent && parent) { + QList<QGraphicsItem *> children = d->newWindowParent->childItems(); + for (int i = 0; i < children.count(); ++i) + children.at(i)->setParentItem(parent); + } + d->newWindowParent = parent; + emit newWindowParentChanged(); +} + +QSize QDeclarativeWebView::contentsSize() const +{ + return page()->mainFrame()->contentsSize() * contentsScale(); +} + +qreal QDeclarativeWebView::contentsScale() const +{ + return d->view->scale(); +} + +void QDeclarativeWebView::setContentsScale(qreal scale) +{ + if (scale == d->view->scale()) + return; + d->view->setScale(scale); + updateDeclarativeWebViewSize(); + emit contentsScaleChanged(); +} + +/*! + Returns the area of the largest element at position (\a x,\a y) that is no larger + than \a maxWidth by \a maxHeight pixels. + + May return an area larger in the case when no smaller element is at the position. +*/ +QRect QDeclarativeWebView::elementAreaAt(int x, int y, int maxWidth, int maxHeight) const +{ + QWebHitTestResult hit = page()->mainFrame()->hitTestContent(QPoint(x, y)); + QRect hitRect = hit.boundingRect(); + QWebElement element = hit.enclosingBlockElement(); + if (maxWidth <= 0) + maxWidth = INT_MAX; + if (maxHeight <= 0) + maxHeight = INT_MAX; + while (!element.parent().isNull() && element.geometry().width() <= maxWidth && element.geometry().height() <= maxHeight) { + hitRect = element.geometry(); + element = element.parent(); + } + return hitRect; +} + +/*! + \internal + \class QDeclarativeWebPage + \brief The QDeclarativeWebPage class is a QWebPage that can create QML plugins. + + \sa QDeclarativeWebView +*/ +QDeclarativeWebPage::QDeclarativeWebPage(QDeclarativeWebView* parent) : + QWebPage(parent) +{ +} + +QDeclarativeWebPage::~QDeclarativeWebPage() +{ +} + +QString QDeclarativeWebPage::chooseFile(QWebFrame* originatingFrame, const QString& oldFile) +{ + // Not supported (it's modal) + Q_UNUSED(originatingFrame) + Q_UNUSED(oldFile) + return oldFile; +} + +/*! + \qmlsignal WebView::onAlert(message) + + The handler is called when the web engine sends a JavaScript alert. The \a message is the text + to be displayed in the alert to the user. +*/ + + +void QDeclarativeWebPage::javaScriptAlert(QWebFrame* originatingFrame, const QString& msg) +{ + Q_UNUSED(originatingFrame) + emit viewItem()->alert(msg); +} + +bool QDeclarativeWebPage::javaScriptConfirm(QWebFrame* originatingFrame, const QString& msg) +{ + // Not supported (it's modal) + Q_UNUSED(originatingFrame) + Q_UNUSED(msg) + return false; +} + +bool QDeclarativeWebPage::javaScriptPrompt(QWebFrame* originatingFrame, const QString& msg, const QString& defaultValue, QString* result) +{ + // Not supported (it's modal) + Q_UNUSED(originatingFrame) + Q_UNUSED(msg) + Q_UNUSED(defaultValue) + Q_UNUSED(result) + return false; +} + + +QDeclarativeWebView* QDeclarativeWebPage::viewItem() +{ + return static_cast<QDeclarativeWebView*>(parent()); +} + +QWebPage* QDeclarativeWebPage::createWindow(WebWindowType type) +{ + QDeclarativeWebView* newView = viewItem()->createWindow(type); + if (newView) + return newView->page(); + return 0; +} + +QT_END_NAMESPACE + diff --git a/WebKit/qt/declarative/qdeclarativewebview_p.h b/WebKit/qt/declarative/qdeclarativewebview_p.h new file mode 100644 index 0000000..b2055bf --- /dev/null +++ b/WebKit/qt/declarative/qdeclarativewebview_p.h @@ -0,0 +1,371 @@ +/* + 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 qdeclarativewebview_p_h +#define qdeclarativewebview_p_h + +#include <QtCore/QBasicTimer> +#include <QtCore/QUrl> +#include <QtDeclarative/QDeclarativeItem> +#include <QtGui/QAction> +#include <QtNetwork/QNetworkAccessManager> +#include "qgraphicswebview.h" +#include "qwebpage.h" + + +QT_BEGIN_HEADER + +class QWebHistory; +class QWebSettings; + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) +class QDeclarativeWebSettings; +class QDeclarativeWebViewPrivate; +class QNetworkRequest; +class QDeclarativeWebView; +class QDeclarativeWebViewPrivate; + +class QDeclarativeWebPage : public QWebPage { + Q_OBJECT +public: + explicit QDeclarativeWebPage(QDeclarativeWebView *parent); + ~QDeclarativeWebPage(); +protected: + QWebPage *createWindow(WebWindowType type); + QString chooseFile(QWebFrame *originatingFrame, const QString& oldFile); + void javaScriptAlert(QWebFrame *originatingFrame, const QString& msg); + bool javaScriptConfirm(QWebFrame *originatingFrame, const QString& msg); + bool javaScriptPrompt(QWebFrame *originatingFrame, const QString& msg, const QString& defaultValue, QString* result); + +private: + QDeclarativeWebView *viewItem(); +}; + +class GraphicsWebView : public QGraphicsWebView { + Q_OBJECT +public: + GraphicsWebView(QDeclarativeWebView* parent = 0); +protected: + void mousePressEvent(QGraphicsSceneMouseEvent* event); + void mouseReleaseEvent(QGraphicsSceneMouseEvent* event); + void mouseMoveEvent(QGraphicsSceneMouseEvent* event); + void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); + void timerEvent(QTimerEvent* event); +Q_SIGNALS: + void doubleClick(int clickX, int clickY); +private: + QDeclarativeWebView *parent; + QPointF pressPoint; + QBasicTimer pressTimer; + int pressTime; // milliseconds before the touch event becomes a "tap and hold" + friend class QDeclarativeWebView; +}; + +class QDeclarativeWebViewAttached; + +// TODO: browser plugins + +class QDeclarativeWebView : public QDeclarativeItem { + Q_OBJECT + + Q_ENUMS(Status SelectionMode) + + Q_PROPERTY(QString title READ title NOTIFY titleChanged) + Q_PROPERTY(QPixmap icon READ icon NOTIFY iconChanged) + Q_PROPERTY(QString statusText READ statusText NOTIFY statusTextChanged) + + Q_PROPERTY(QString html READ html WRITE setHtml NOTIFY htmlChanged) + + Q_PROPERTY(int pressGrabTime READ pressGrabTime WRITE setPressGrabTime NOTIFY pressGrabTimeChanged) + + Q_PROPERTY(int preferredWidth READ preferredWidth WRITE setPreferredWidth NOTIFY preferredWidthChanged) + Q_PROPERTY(int preferredHeight READ preferredHeight WRITE setPreferredHeight NOTIFY preferredHeightChanged) + Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) + Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) + Q_PROPERTY(Status status READ status NOTIFY statusChanged) + +#ifndef QT_NO_ACTION + Q_PROPERTY(QAction* reload READ reloadAction CONSTANT) + Q_PROPERTY(QAction* back READ backAction CONSTANT) + Q_PROPERTY(QAction* forward READ forwardAction CONSTANT) + Q_PROPERTY(QAction* stop READ stopAction CONSTANT) +#endif + + Q_PROPERTY(QDeclarativeWebSettings* settings READ settingsObject CONSTANT) + + Q_PROPERTY(QDeclarativeListProperty<QObject> javaScriptWindowObjects READ javaScriptWindowObjects CONSTANT) + + Q_PROPERTY(QDeclarativeComponent* newWindowComponent READ newWindowComponent WRITE setNewWindowComponent NOTIFY newWindowComponentChanged) + Q_PROPERTY(QDeclarativeItem* newWindowParent READ newWindowParent WRITE setNewWindowParent NOTIFY newWindowParentChanged) + + Q_PROPERTY(bool renderingEnabled READ renderingEnabled WRITE setRenderingEnabled NOTIFY renderingEnabledChanged) + + Q_PROPERTY(QSize contentsSize READ contentsSize NOTIFY contentsSizeChanged) + Q_PROPERTY(qreal contentsScale READ contentsScale WRITE setContentsScale NOTIFY contentsScaleChanged) + +public: + QDeclarativeWebView(QDeclarativeItem *parent = 0); + ~QDeclarativeWebView(); + + QUrl url() const; + void setUrl(const QUrl &); + + QString title() const; + + QPixmap icon() const; + + Q_INVOKABLE bool heuristicZoom(int clickX, int clickY, qreal maxzoom); + QRect elementAreaAt(int x, int y, int minwidth, int minheight) const; + + int pressGrabTime() const; + void setPressGrabTime(int); + + int preferredWidth() const; + void setPreferredWidth(int); + int preferredHeight() const; + void setPreferredHeight(int); + + enum Status { Null, Ready, Loading, Error }; + Status status() const; + qreal progress() const; + QString statusText() const; + +#ifndef QT_NO_ACTION + QAction *reloadAction() const; + QAction *backAction() const; + QAction *forwardAction() const; + QAction *stopAction() const; +#endif + + QWebPage *page() const; + void setPage(QWebPage *page); + + void load(const QNetworkRequest &request, + QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, + const QByteArray &body = QByteArray()); + + QString html() const; + + 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; + QDeclarativeWebSettings *settingsObject() const; + + bool renderingEnabled() const; + void setRenderingEnabled(bool); + + QDeclarativeListProperty<QObject> javaScriptWindowObjects(); + + static QDeclarativeWebViewAttached* qmlAttachedProperties(QObject*); + + QDeclarativeComponent *newWindowComponent() const; + void setNewWindowComponent(QDeclarativeComponent *newWindow); + QDeclarativeItem* newWindowParent() const; + void setNewWindowParent(QDeclarativeItem* newWindow); + + bool isComponentCompletePublic() const { return isComponentComplete(); } + + QSize contentsSize() const; + + void setContentsScale(qreal scale); + qreal contentsScale() const; + +Q_SIGNALS: + void preferredWidthChanged(); + void preferredHeightChanged(); + void urlChanged(); + void progressChanged(); + void statusChanged(Status); + void titleChanged(const QString&); + void iconChanged(); + void statusTextChanged(); + void htmlChanged(); + void pressGrabTimeChanged(); + void newWindowComponentChanged(); + void newWindowParentChanged(); + void renderingEnabledChanged(); + void contentsSizeChanged(const QSize&); + void contentsScaleChanged(); + + void loadStarted(); + void loadFinished(); + void loadFailed(); + + void doubleClick(int clickX, int clickY); + + void zoomTo(qreal zoom, int centerX, int centerY); + + void alert(const QString& message); + +public Q_SLOTS: + QVariant evaluateJavaScript(const QString&); + +private Q_SLOTS: + void doLoadStarted(); + void doLoadProgress(int p); + void doLoadFinished(bool ok); + void setStatusText(const QString&); + void windowObjectCleared(); + void pageUrlChanged(); + void initialLayout(); + + void updateDeclarativeWebViewSize(); + + virtual void geometryChanged(const QRectF &newGeometry, + const QRectF &oldGeometry); + QDeclarativeWebView* createWindow(QWebPage::WebWindowType type); + +private: + void updateContentsSize(); + void init(); + virtual void componentComplete(); + Q_DISABLE_COPY(QDeclarativeWebView) + QDeclarativeWebViewPrivate* d; + QMouseEvent* sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent*); + QMouseEvent* sceneHoverMoveEventToMouseEvent(QGraphicsSceneHoverEvent*); + friend class QDeclarativeWebPage; +}; + +class QDeclarativeWebViewAttached : public QObject { + Q_OBJECT + Q_PROPERTY(QString windowObjectName READ windowObjectName WRITE setWindowObjectName) +public: + QDeclarativeWebViewAttached(QObject* parent) + : QObject(parent) + { + } + + QString windowObjectName() const + { + return m_windowObjectName; + } + + void setWindowObjectName(const QString &n) + { + m_windowObjectName = n; + } + +private: + QString m_windowObjectName; +}; + +class QDeclarativeWebSettings : public QObject { + Q_OBJECT + + Q_PROPERTY(QString standardFontFamily READ standardFontFamily WRITE setStandardFontFamily) + Q_PROPERTY(QString fixedFontFamily READ fixedFontFamily WRITE setFixedFontFamily) + Q_PROPERTY(QString serifFontFamily READ serifFontFamily WRITE setSerifFontFamily) + Q_PROPERTY(QString sansSerifFontFamily READ sansSerifFontFamily WRITE setSansSerifFontFamily) + Q_PROPERTY(QString cursiveFontFamily READ cursiveFontFamily WRITE setCursiveFontFamily) + Q_PROPERTY(QString fantasyFontFamily READ fantasyFontFamily WRITE setFantasyFontFamily) + + Q_PROPERTY(int minimumFontSize READ minimumFontSize WRITE setMinimumFontSize) + Q_PROPERTY(int minimumLogicalFontSize READ minimumLogicalFontSize WRITE setMinimumLogicalFontSize) + Q_PROPERTY(int defaultFontSize READ defaultFontSize WRITE setDefaultFontSize) + Q_PROPERTY(int defaultFixedFontSize READ defaultFixedFontSize WRITE setDefaultFixedFontSize) + + Q_PROPERTY(bool autoLoadImages READ autoLoadImages WRITE setAutoLoadImages) + Q_PROPERTY(bool javascriptEnabled READ javascriptEnabled WRITE setJavascriptEnabled) + Q_PROPERTY(bool javaEnabled READ javaEnabled WRITE setJavaEnabled) + Q_PROPERTY(bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled) + Q_PROPERTY(bool privateBrowsingEnabled READ privateBrowsingEnabled WRITE setPrivateBrowsingEnabled) + Q_PROPERTY(bool javascriptCanOpenWindows READ javascriptCanOpenWindows WRITE setJavascriptCanOpenWindows) + Q_PROPERTY(bool javascriptCanAccessClipboard READ javascriptCanAccessClipboard WRITE setJavascriptCanAccessClipboard) + Q_PROPERTY(bool developerExtrasEnabled READ developerExtrasEnabled WRITE setDeveloperExtrasEnabled) + Q_PROPERTY(bool linksIncludedInFocusChain READ linksIncludedInFocusChain WRITE setLinksIncludedInFocusChain) + Q_PROPERTY(bool zoomTextOnly READ zoomTextOnly WRITE setZoomTextOnly) + Q_PROPERTY(bool printElementBackgrounds READ printElementBackgrounds WRITE setPrintElementBackgrounds) + Q_PROPERTY(bool offlineStorageDatabaseEnabled READ offlineStorageDatabaseEnabled WRITE setOfflineStorageDatabaseEnabled) + Q_PROPERTY(bool offlineWebApplicationCacheEnabled READ offlineWebApplicationCacheEnabled WRITE setOfflineWebApplicationCacheEnabled) + Q_PROPERTY(bool localStorageDatabaseEnabled READ localStorageDatabaseEnabled WRITE setLocalStorageDatabaseEnabled) + Q_PROPERTY(bool localContentCanAccessRemoteUrls READ localContentCanAccessRemoteUrls WRITE setLocalContentCanAccessRemoteUrls) + +public: + QDeclarativeWebSettings() {} + + QString standardFontFamily() const { return s->fontFamily(QWebSettings::StandardFont); } + void setStandardFontFamily(const QString& f) { s->setFontFamily(QWebSettings::StandardFont, f); } + QString fixedFontFamily() const { return s->fontFamily(QWebSettings::FixedFont); } + void setFixedFontFamily(const QString& f) { s->setFontFamily(QWebSettings::FixedFont, f); } + QString serifFontFamily() const { return s->fontFamily(QWebSettings::SerifFont); } + void setSerifFontFamily(const QString& f) { s->setFontFamily(QWebSettings::SerifFont, f); } + QString sansSerifFontFamily() const { return s->fontFamily(QWebSettings::SansSerifFont); } + void setSansSerifFontFamily(const QString& f) { s->setFontFamily(QWebSettings::SansSerifFont, f); } + QString cursiveFontFamily() const { return s->fontFamily(QWebSettings::CursiveFont); } + void setCursiveFontFamily(const QString& f) { s->setFontFamily(QWebSettings::CursiveFont, f); } + QString fantasyFontFamily() const { return s->fontFamily(QWebSettings::FantasyFont); } + void setFantasyFontFamily(const QString& f) { s->setFontFamily(QWebSettings::FantasyFont, f); } + + int minimumFontSize() const { return s->fontSize(QWebSettings::MinimumFontSize); } + void setMinimumFontSize(int size) { s->setFontSize(QWebSettings::MinimumFontSize, size); } + int minimumLogicalFontSize() const { return s->fontSize(QWebSettings::MinimumLogicalFontSize); } + void setMinimumLogicalFontSize(int size) { s->setFontSize(QWebSettings::MinimumLogicalFontSize, size); } + int defaultFontSize() const { return s->fontSize(QWebSettings::DefaultFontSize); } + void setDefaultFontSize(int size) { s->setFontSize(QWebSettings::DefaultFontSize, size); } + int defaultFixedFontSize() const { return s->fontSize(QWebSettings::DefaultFixedFontSize); } + void setDefaultFixedFontSize(int size) { s->setFontSize(QWebSettings::DefaultFixedFontSize, size); } + + bool autoLoadImages() const { return s->testAttribute(QWebSettings::AutoLoadImages); } + void setAutoLoadImages(bool on) { s->setAttribute(QWebSettings::AutoLoadImages, on); } + bool javascriptEnabled() const { return s->testAttribute(QWebSettings::JavascriptEnabled); } + void setJavascriptEnabled(bool on) { s->setAttribute(QWebSettings::JavascriptEnabled, on); } + bool javaEnabled() const { return s->testAttribute(QWebSettings::JavaEnabled); } + void setJavaEnabled(bool on) { s->setAttribute(QWebSettings::JavaEnabled, on); } + bool pluginsEnabled() const { return s->testAttribute(QWebSettings::PluginsEnabled); } + void setPluginsEnabled(bool on) { s->setAttribute(QWebSettings::PluginsEnabled, on); } + bool privateBrowsingEnabled() const { return s->testAttribute(QWebSettings::PrivateBrowsingEnabled); } + void setPrivateBrowsingEnabled(bool on) { s->setAttribute(QWebSettings::PrivateBrowsingEnabled, on); } + bool javascriptCanOpenWindows() const { return s->testAttribute(QWebSettings::JavascriptCanOpenWindows); } + void setJavascriptCanOpenWindows(bool on) { s->setAttribute(QWebSettings::JavascriptCanOpenWindows, on); } + bool javascriptCanAccessClipboard() const { return s->testAttribute(QWebSettings::JavascriptCanAccessClipboard); } + void setJavascriptCanAccessClipboard(bool on) { s->setAttribute(QWebSettings::JavascriptCanAccessClipboard, on); } + bool developerExtrasEnabled() const { return s->testAttribute(QWebSettings::DeveloperExtrasEnabled); } + void setDeveloperExtrasEnabled(bool on) { s->setAttribute(QWebSettings::DeveloperExtrasEnabled, on); } + bool linksIncludedInFocusChain() const { return s->testAttribute(QWebSettings::LinksIncludedInFocusChain); } + void setLinksIncludedInFocusChain(bool on) { s->setAttribute(QWebSettings::LinksIncludedInFocusChain, on); } + bool zoomTextOnly() const { return s->testAttribute(QWebSettings::ZoomTextOnly); } + void setZoomTextOnly(bool on) { s->setAttribute(QWebSettings::ZoomTextOnly, on); } + bool printElementBackgrounds() const { return s->testAttribute(QWebSettings::PrintElementBackgrounds); } + void setPrintElementBackgrounds(bool on) { s->setAttribute(QWebSettings::PrintElementBackgrounds, on); } + bool offlineStorageDatabaseEnabled() const { return s->testAttribute(QWebSettings::OfflineStorageDatabaseEnabled); } + void setOfflineStorageDatabaseEnabled(bool on) { s->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, on); } + bool offlineWebApplicationCacheEnabled() const { return s->testAttribute(QWebSettings::OfflineWebApplicationCacheEnabled); } + void setOfflineWebApplicationCacheEnabled(bool on) { s->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, on); } + bool localStorageDatabaseEnabled() const { return s->testAttribute(QWebSettings::LocalStorageDatabaseEnabled); } + void setLocalStorageDatabaseEnabled(bool on) { s->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, on); } + bool localContentCanAccessRemoteUrls() const { return s->testAttribute(QWebSettings::LocalContentCanAccessRemoteUrls); } + void setLocalContentCanAccessRemoteUrls(bool on) { s->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, on); } + + QWebSettings *s; +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarativeWebView) +QML_DECLARE_TYPE(QDeclarativeWebSettings) +QML_DECLARE_TYPEINFO(QDeclarativeWebView, QML_HAS_ATTACHED_PROPERTIES) + +QT_END_HEADER + +#endif diff --git a/WebKit/qt/declarative/qmldir b/WebKit/qt/declarative/qmldir new file mode 100644 index 0000000..dcfdd06 --- /dev/null +++ b/WebKit/qt/declarative/qmldir @@ -0,0 +1 @@ +plugin qmlwebkitplugin diff --git a/WebKit/qt/docs/qtwebkit-bridge.qdoc b/WebKit/qt/docs/qtwebkit-bridge.qdoc index fa93293..c2a38fd 100644 --- a/WebKit/qt/docs/qtwebkit-bridge.qdoc +++ b/WebKit/qt/docs/qtwebkit-bridge.qdoc @@ -8,7 +8,7 @@ The QtWebKit bridge is a mechanism that extends WebKit's JavaScript environment to access native objects that are represented as \l{QObject}s. It takes advantage of the \l{QObject} introspection, - a part of the \l{Qt Object Model}, which makes it easy to integrate with the dynamic JavaScript environment, + a part of the \l{Object Model}, which makes it easy to integrate with the dynamic JavaScript environment, for example \l{QObject} properties map directly to JavaScript properties. For example, both JavaScript and QObjects have properties: a construct that represent a getter/setter @@ -24,7 +24,7 @@ applications. For example, an application that contains a media-player, playlist manager, and music store. The playlist manager is usually best authored as a classic desktop application, with the native-looking robust \l{QWidget}s helping with producing that application. - The media-player control, which usually looks custom, can be written using \l{The Graphics View framework} + The media-player control, which usually looks custom, can be written using the \l{Graphics View framework} or with in a declarative way with \l{QtDeclarative}. The music store, which shows dynamic content from the internet and gets modified rapidly, is best authored in HTML and maintained on the server. diff --git a/WebKit/qt/docs/qtwebkit.qdocconf b/WebKit/qt/docs/qtwebkit.qdocconf index 292c124..5f877c2 100644 --- a/WebKit/qt/docs/qtwebkit.qdocconf +++ b/WebKit/qt/docs/qtwebkit.qdocconf @@ -3,8 +3,8 @@ project = qtwebkit description = "Qt WebKit API Documentation" -headerdirs = $SRCDIR/WebKit/qt/Api -sourcedirs = $SRCDIR/WebKit/qt/Api $SRCDIR/WebKit/qt/docs $SRCDIR/JavaScriptCore/qt/api +headerdirs = $SRCDIR/WebKit/qt/Api $SRCDIR/WebKit/qt/declarative +sourcedirs = $SRCDIR/WebKit/qt/Api $SRCDIR/WebKit/qt/docs $SRCDIR/JavaScriptCore/qt/api $SRCDIR/WebKit/qt/declarative outputdir = $OUTPUT_DIR/doc/html outputformats = HTML sources.fileextensions = "*.cpp *.doc *.qdoc *.h" diff --git a/WebKit/qt/docs/webkitsnippets/qtwebkit_bridge_snippets.cpp b/WebKit/qt/docs/webkitsnippets/qtwebkit_bridge_snippets.cpp index 62eeeca..6a517c2 100644 --- a/WebKit/qt/docs/webkitsnippets/qtwebkit_bridge_snippets.cpp +++ b/WebKit/qt/docs/webkitsnippets/qtwebkit_bridge_snippets.cpp @@ -12,10 +12,10 @@ void wrapInFunction() //! [1] { width: ..., - height: ..., - toDataURL: function() { ... }, - assignToHTMLImageElement: function(element) { ... } - } + height: ..., + toDataURL: function() { ... }, + assignToHTMLImageElement: function(element) { ... } + } //! [1] #endif //! [2] @@ -24,7 +24,7 @@ void wrapInFunction() Q_PROPERTY(QPixmap myPixmap READ getPixmap) public: - QPixmap getPixmap() const; + QPixmap getPixmap() const; }; /* ... */ @@ -36,21 +36,22 @@ void wrapInFunction() #if 0 //! [3] <html> - <head> + <head> <script> - function loadImage() { - myObject.myPixmap.assignToHTMLImageElement(document.getElementById("imageElement")); - } - </script> - </head> - <body onload="loadImage()"> - <img id="imageElement" width="300" height="200" /> - </body> - </html> - //! [3] + function loadImage() + { + myObject.myPixmap.assignToHTMLImageElement(document.getElementById("imageElement")); + } + </script> + </head> + <body onload="loadImage()"> + <img id="imageElement" width="300" height="200" /> + </body> + </html> +//! [3] #endif - //! [4] - class MyObject : QObject { +//! [4] +class MyObject : QObject { Q_OBJECT public slots: @@ -161,11 +162,7 @@ void wrapInFunction() myQObject.enabled = !myQObject.enabled; //! [24] //! [25] - myQObject.enabled = true; - - ... - - myQObject.enabled = !myQObject.enabled; + myDialog.okButton //! [25] //! [26] myDialog.okButton diff --git a/WebKit/qt/examples/platformplugin/WebPlugin.cpp b/WebKit/qt/examples/platformplugin/WebPlugin.cpp index 1f3877c..c3efb80 100644 --- a/WebKit/qt/examples/platformplugin/WebPlugin.cpp +++ b/WebKit/qt/examples/platformplugin/WebPlugin.cpp @@ -221,4 +221,4 @@ bool WebPlugin::supportsExtension(Extension extension) const return false; } -Q_EXPORT_PLUGIN2(qwebselectim, WebPlugin) +Q_EXPORT_PLUGIN2(platformplugin, WebPlugin) diff --git a/WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h b/WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h index bac618c..32d22d4 100644 --- a/WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h +++ b/WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h @@ -31,7 +31,7 @@ class QWebSelectData { public: - inline ~QWebSelectData() {} + virtual ~QWebSelectData() {} enum ItemType { Option, Group, Separator }; @@ -48,7 +48,7 @@ class QWebSelectMethod : public QObject { Q_OBJECT public: - inline ~QWebSelectMethod() {} + virtual ~QWebSelectMethod() {} virtual void show(const QWebSelectData&) = 0; virtual void hide() = 0; @@ -61,6 +61,8 @@ Q_SIGNALS: class QWebNotificationData { public: + virtual ~QWebNotificationData() {} + virtual const QString title() const = 0; virtual const QString message() const = 0; virtual const QByteArray iconData() const = 0; diff --git a/WebKit/qt/symbian/eabi/QtWebKitu.def b/WebKit/qt/symbian/eabi/QtWebKitu.def index 93fd33c..3fefb4d 100644 --- a/WebKit/qt/symbian/eabi/QtWebKitu.def +++ b/WebKit/qt/symbian/eabi/QtWebKitu.def @@ -760,7 +760,7 @@ EXPORTS _ZN23DumpRenderTreeSupportQt27setTimelineProfilingEnabledEP8QWebPageb @759 NONAME _ZN23DumpRenderTreeSupportQt28setDumpRenderTreeModeEnabledEb @760 NONAME _ZN23DumpRenderTreeSupportQt29dumpResourceLoadCallbacksPathERK7QString @761 NONAME - _ZN23DumpRenderTreeSupportQt29evaluateScriptInIsolatedWorldEP9QWebFrameiRK7QString @762 NONAME + _ZN23DumpRenderTreeSupportQt29evaluateScriptInIsolatedWorldEP9QWebFrameiRK7QString @762 NONAME ABSENT _ZN23DumpRenderTreeSupportQt29setJavaScriptProfilingEnabledEP9QWebFrameb @763 NONAME _ZN23DumpRenderTreeSupportQt29setWillSendRequestReturnsNullEb @764 NONAME _ZN23DumpRenderTreeSupportQt30setWillSendRequestClearHeadersERK11QStringList @765 NONAME @@ -776,3 +776,9 @@ EXPORTS _ZN23DumpRenderTreeSupportQt26setCheckPermissionFunctionEPFvP7QObjectRK4QUrlR22NotificationPermissionE @ 775 NONAME _ZN23DumpRenderTreeSupportQt28setRequestPermissionFunctionEPFvP7QObjectRK7QStringE @ 776 NONAME _ZN23DumpRenderTreeSupportQt31removeWhiteListAccessFromOriginERK7QStringS2_S2_b @ 777 NONAME + _ZN23DumpRenderTreeSupportQt11shouldCloseEP9QWebFrame @ 778 NONAME + _ZN23DumpRenderTreeSupportQt12isTargetItemERK15QWebHistoryItem @ 779 NONAME + _ZN23DumpRenderTreeSupportQt17historyItemTargetERK15QWebHistoryItem @ 780 NONAME + _ZN23DumpRenderTreeSupportQt20getChildHistoryItemsERK15QWebHistoryItem @ 781 NONAME + _ZN23DumpRenderTreeSupportQt23setMockGeolocationErrorEiRK7QString @ 782 NONAME + _ZN23DumpRenderTreeSupportQt26setMockGeolocationPositionEddd @ 783 NONAME diff --git a/WebKit/qt/tests/qwebhistory/tst_qwebhistory.cpp b/WebKit/qt/tests/qwebhistory/tst_qwebhistory.cpp index 49a606b..783214c 100644 --- a/WebKit/qt/tests/qwebhistory/tst_qwebhistory.cpp +++ b/WebKit/qt/tests/qwebhistory/tst_qwebhistory.cpp @@ -84,7 +84,7 @@ void tst_QWebHistory::init() { page = new QWebPage(this); frame = page->mainFrame(); - connect(page, SIGNAL(loadFinished(bool)), &waitForLoadFinished, SLOT(quit())); + connect(page, SIGNAL(loadFinished(bool)), &waitForLoadFinished, SLOT(quit()), Qt::QueuedConnection); for (int i = 1;i < 6;i++) { loadPage(i); @@ -126,6 +126,7 @@ void tst_QWebHistory::back() } //try one more time (too many). crash test hist->back(); + QCOMPARE(page->mainFrame()->toPlainText(), QString("page1")); } /** @@ -146,6 +147,7 @@ void tst_QWebHistory::forward() } //try one more time (too many). crash test hist->forward(); + QCOMPARE(page->mainFrame()->toPlainText(), QString("page") + QString::number(histsize)); } /** |