summaryrefslogtreecommitdiff
path: root/Source/WebKit/qt/Api
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/qt/Api')
-rw-r--r--Source/WebKit/qt/Api/qgraphicswebview.cpp6
-rw-r--r--Source/WebKit/qt/Api/qwebelement.cpp6
-rw-r--r--Source/WebKit/qt/Api/qwebframe.cpp227
-rw-r--r--Source/WebKit/qt/Api/qwebframe.h7
-rw-r--r--Source/WebKit/qt/Api/qwebframe_p.h62
-rw-r--r--Source/WebKit/qt/Api/qwebhistory.cpp7
-rw-r--r--Source/WebKit/qt/Api/qwebhistory_p.h4
-rw-r--r--Source/WebKit/qt/Api/qwebinspector.cpp4
-rw-r--r--Source/WebKit/qt/Api/qwebinspector_p.h2
-rw-r--r--Source/WebKit/qt/Api/qwebkitglobal.h14
-rw-r--r--Source/WebKit/qt/Api/qwebpage.cpp718
-rw-r--r--Source/WebKit/qt/Api/qwebpage.h6
-rw-r--r--Source/WebKit/qt/Api/qwebpage_p.h126
-rw-r--r--Source/WebKit/qt/Api/qwebsettings.cpp34
-rw-r--r--Source/WebKit/qt/Api/qwebsettings.h1
-rw-r--r--Source/WebKit/qt/Api/qwebview.cpp4
16 files changed, 788 insertions, 440 deletions
diff --git a/Source/WebKit/qt/Api/qgraphicswebview.cpp b/Source/WebKit/qt/Api/qgraphicswebview.cpp
index ef42c9518..84b4e801b 100644
--- a/Source/WebKit/qt/Api/qgraphicswebview.cpp
+++ b/Source/WebKit/qt/Api/qgraphicswebview.cpp
@@ -88,7 +88,7 @@ public:
PageClientQGraphicsWidget* pageClient() const
{
- return static_cast<WebCore::PageClientQGraphicsWidget*> (page->d->client.get());
+ return static_cast<WebCore::PageClientQGraphicsWidget*> (page->d->client.data());
}
};
@@ -468,7 +468,7 @@ void QGraphicsWebViewPrivate::detachCurrentPage()
return;
page->d->view = 0;
- page->d->client = nullptr;
+ page->d->client.reset();
// if the page was created by us, we own it and need to
// destroy it as well.
@@ -501,7 +501,7 @@ void QGraphicsWebView::setPage(QWebPage* page)
if (!d->page)
return;
- d->page->d->client = adoptPtr(new PageClientQGraphicsWidget(this, page));
+ d->page->d->client.reset(new PageClientQGraphicsWidget(this, page));
if (d->overlay())
d->overlay()->prepareGraphicsItemGeometryChange();
diff --git a/Source/WebKit/qt/Api/qwebelement.cpp b/Source/WebKit/qt/Api/qwebelement.cpp
index 108b9b06f..82f579d95 100644
--- a/Source/WebKit/qt/Api/qwebelement.cpp
+++ b/Source/WebKit/qt/Api/qwebelement.cpp
@@ -39,6 +39,7 @@
#include "JSHTMLElement.h"
#include "JSObject.h"
#include "PropertyNameArray.h"
+#include <QWebFrameAdapter.h>
#include <parser/SourceCode.h>
#include "qt_runtime.h"
#include "NodeList.h"
@@ -47,8 +48,6 @@
#include "StaticNodeList.h"
#include "StyleResolver.h"
#include "markup.h"
-#include "qwebframe.h"
-#include "qwebframe_p.h"
#include "runtime_root.h"
#include <JSDocument.h>
#include <wtf/Vector.h>
@@ -706,7 +705,8 @@ QWebFrame *QWebElement::webFrame() const
Frame* frame = document->frame();
if (!frame)
return 0;
- return QWebFramePrivate::kit(frame);
+ QWebFrameAdapter* frameAdapter = QWebFrameAdapter::kit(frame);
+ return frameAdapter->apiHandle();
}
static bool setupScriptContext(WebCore::Element* element, JSC::JSValue& thisValue, ScriptState*& state, ScriptController*& scriptController)
diff --git a/Source/WebKit/qt/Api/qwebframe.cpp b/Source/WebKit/qt/Api/qwebframe.cpp
index 1310348ed..89474dd2e 100644
--- a/Source/WebKit/qt/Api/qwebframe.cpp
+++ b/Source/WebKit/qt/Api/qwebframe.cpp
@@ -106,54 +106,6 @@ QT_BEGIN_NAMESPACE
extern Q_GUI_EXPORT int qt_defaultDpi();
QT_END_NAMESPACE
-static inline ResourceRequestCachePolicy cacheLoadControlToCachePolicy(uint cacheLoadControl)
-{
- switch (cacheLoadControl) {
- case QNetworkRequest::AlwaysNetwork:
- return WebCore::ReloadIgnoringCacheData;
- case QNetworkRequest::PreferCache:
- return WebCore::ReturnCacheDataElseLoad;
- case QNetworkRequest::AlwaysCache:
- return WebCore::ReturnCacheDataDontLoad;
- default:
- break;
- }
- return WebCore::UseProtocolCachePolicy;
-}
-
-QWebFrameData::QWebFrameData(WebCore::Page* parentPage, WebCore::Frame* parentFrame,
- WebCore::HTMLFrameOwnerElement* ownerFrameElement,
- const WTF::String& frameName)
- : name(frameName)
- , ownerElement(ownerFrameElement)
- , page(parentPage)
- , allowsScrolling(true)
- , marginWidth(0)
- , marginHeight(0)
-{
- frameLoaderClient = new FrameLoaderClientQt();
- frame = Frame::create(page, ownerElement, frameLoaderClient);
-
- // FIXME: All of the below should probably be moved over into WebCore
- frame->tree()->setName(name);
- if (parentFrame)
- parentFrame->tree()->appendChild(frame);
-}
-
-void QWebFramePrivate::init(QWebFrame *qframe, QWebFrameData *frameData)
-{
- q = qframe;
-
- allowsScrolling = frameData->allowsScrolling;
- marginWidth = frameData->marginWidth;
- marginHeight = frameData->marginHeight;
- frame = frameData->frame.get();
- frameLoaderClient = frameData->frameLoaderClient;
- frameLoaderClient->setFrame(qframe, frame);
-
- frame->init();
-}
-
void QWebFramePrivate::setPage(QWebPage* newPage)
{
if (page == newPage)
@@ -166,6 +118,7 @@ void QWebFramePrivate::setPage(QWebPage* newPage)
q->setParent(newPage);
page = newPage;
+ pageAdapter = newPage->handle();
emit q->pageChanged();
}
@@ -375,6 +328,11 @@ void QWebFramePrivate::emitUrlChanged()
emit q->urlChanged(url);
}
+void QWebFramePrivate::didStartProvisionalLoad()
+{
+ emit q->provisionalLoad();
+}
+
void QWebFramePrivate::_q_orientationChanged()
{
#if ENABLE(ORIENTATION_EVENTS)
@@ -409,6 +367,65 @@ void QWebFramePrivate::didClearWindowObject()
emit q->javaScriptWindowObjectCleared();
}
+bool QWebFramePrivate::handleProgressFinished(QPoint *localPos)
+{
+ QWidget *view = q->page()->view();
+ if (!view || !localPos)
+ return false;
+ *localPos = view->mapFromGlobal(QCursor::pos());
+ return view->hasFocus() && view->rect().contains(*localPos);
+}
+
+void QWebFramePrivate::emitInitialLayoutCompleted()
+{
+ emit q->initialLayoutCompleted();
+}
+
+void QWebFramePrivate::emitIconChanged()
+{
+ emit q->iconChanged();
+}
+
+void QWebFramePrivate::emitLoadStarted(bool originatingLoad)
+{
+ if (page && originatingLoad)
+ emit page->loadStarted();
+ emit q->loadStarted();
+}
+
+void QWebFramePrivate::emitLoadFinished(bool originatingLoad, bool ok)
+{
+ if (page && originatingLoad)
+ emit page->loadFinished(ok);
+ emit q->loadFinished(ok);
+}
+
+QWebFrameAdapter* QWebFramePrivate::createChildFrame(QWebFrameData* frameData)
+{
+ QWebFrame* newFrame = new QWebFrame(/*parent frame*/q, frameData);
+ return newFrame->d;
+}
+
+QWebFrame *QWebFramePrivate::apiHandle()
+{
+ return q;
+}
+
+QObject *QWebFramePrivate::handle()
+{
+ return q;
+}
+
+void QWebFramePrivate::contentsSizeDidChange(const QSize &size)
+{
+ emit q->contentsSizeChanged(size);
+}
+
+int QWebFramePrivate::scrollBarPolicy(Qt::Orientation orientation) const
+{
+ return (int) q->scrollBarPolicy(orientation);
+}
+
/*!
\class QWebFrame
\since 4.4
@@ -472,29 +489,27 @@ void QWebFramePrivate::didClearWindowObject()
\value AllLayers Includes all the above layers
*/
-QWebFrame::QWebFrame(QWebPage *parent, QWebFrameData *frameData)
- : QObject(parent)
+QWebFrame::QWebFrame(QWebPage *parentPage)
+ : QObject(parentPage)
, d(new QWebFramePrivate)
{
- d->page = parent;
- d->init(this, frameData);
+ d->page = parentPage;
+ d->q = this;
+ d->init(/*page adapter*/ parentPage->handle());
- if (!frameData->url.isEmpty()) {
- WebCore::ResourceRequest request(frameData->url, frameData->referrer);
- d->frame->loader()->load(request, frameData->name, false);
- }
#if ENABLE(ORIENTATION_EVENTS)
connect(&d->m_orientation, SIGNAL(readingChanged()), this, SLOT(_q_orientationChanged()));
d->m_orientation.start();
#endif
}
-QWebFrame::QWebFrame(QWebFrame *parent, QWebFrameData *frameData)
+QWebFrame::QWebFrame(QWebFrame* parent, QWebFrameData* frameData)
: QObject(parent)
, d(new QWebFramePrivate)
{
d->page = parent->d->page;
- d->init(this, frameData);
+ d->q = this;
+ d->init(parent->d->pageAdapter, frameData);
#if ENABLE(ORIENTATION_EVENTS)
connect(&d->m_orientation, SIGNAL(readingChanged()), this, SLOT(_q_orientationChanged()));
d->m_orientation.start();
@@ -503,9 +518,6 @@ QWebFrame::QWebFrame(QWebFrame *parent, QWebFrameData *frameData)
QWebFrame::~QWebFrame()
{
- if (d->frame && d->frame->loader() && d->frame->loader()->client())
- static_cast<FrameLoaderClientQt*>(d->frame->loader()->client())->m_webFrame = 0;
-
delete d;
}
@@ -674,22 +686,6 @@ static inline bool isCoreFrameClear(WebCore::Frame* frame)
return frame->document()->url().isEmpty();
}
-static inline QUrl ensureAbsoluteUrl(const QUrl &url)
-{
- if (!url.isValid() || !url.isRelative())
- return url;
-
- // This contains the URL with absolute path but without
- // the query and the fragment part.
- QUrl baseUrl = QUrl::fromLocalFile(QFileInfo(url.toLocalFile()).absoluteFilePath());
-
- // The path is removed so the query and the fragment parts are there.
- QString pathRemoved = url.toString(QUrl::RemovePath);
- QUrl toResolve(pathRemoved);
-
- return baseUrl.resolved(toResolve);
-}
-
/*!
\property QWebFrame::url
\brief the url of the frame currently viewed
@@ -704,7 +700,7 @@ static inline QUrl ensureAbsoluteUrl(const QUrl &url)
void QWebFrame::setUrl(const QUrl &url)
{
clearCoreFrame(d->frame);
- const QUrl absolute = ensureAbsoluteUrl(url);
+ const QUrl absolute = QWebFrameAdapter::ensureAbsoluteUrl(url);
d->url = absolute;
load(absolute);
}
@@ -798,58 +794,7 @@ void QWebFrame::load(const QNetworkRequest &req,
QNetworkAccessManager::Operation operation,
const QByteArray &body)
{
- if (d->parentFrame())
- d->page->d->insideOpenCall = true;
-
- QUrl url = ensureAbsoluteUrl(req.url());
-
- WebCore::ResourceRequest request(url);
-
- switch (operation) {
- case QNetworkAccessManager::HeadOperation:
- request.setHTTPMethod("HEAD");
- break;
- case QNetworkAccessManager::GetOperation:
- request.setHTTPMethod("GET");
- break;
- case QNetworkAccessManager::PutOperation:
- request.setHTTPMethod("PUT");
- break;
- case QNetworkAccessManager::PostOperation:
- request.setHTTPMethod("POST");
- break;
- case QNetworkAccessManager::DeleteOperation:
- request.setHTTPMethod("DELETE");
- break;
- case QNetworkAccessManager::CustomOperation:
- request.setHTTPMethod(req.attribute(QNetworkRequest::CustomVerbAttribute).toByteArray().constData());
- break;
- case QNetworkAccessManager::UnknownOperation:
- // eh?
- break;
- }
-
- QVariant cacheLoad = req.attribute(QNetworkRequest::CacheLoadControlAttribute);
- if (cacheLoad.isValid()) {
- bool ok;
- uint cacheLoadValue = cacheLoad.toUInt(&ok);
- if (ok)
- request.setCachePolicy(cacheLoadControlToCachePolicy(cacheLoadValue));
- }
-
- QList<QByteArray> httpHeaders = req.rawHeaderList();
- for (int i = 0; i < httpHeaders.size(); ++i) {
- const QByteArray &headerName = httpHeaders.at(i);
- request.addHTTPHeaderField(QString::fromLatin1(headerName), QString::fromLatin1(req.rawHeader(headerName)));
- }
-
- if (!body.isEmpty())
- request.setHTTPBody(WebCore::FormData::create(body.constData(), body.size()));
-
- d->frame->loader()->load(request, false);
-
- if (d->parentFrame())
- d->page->d->insideOpenCall = false;
+ d->load(req, operation, body);
}
/*!
@@ -1088,10 +1033,7 @@ void QWebFrame::scroll(int dx, int dy)
QPoint QWebFrame::scrollPosition() const
{
- if (!d->frame->view())
- return QPoint(0, 0);
-
- IntSize ofs = d->frame->view()->scrollOffset();
+ IntSize ofs = d->scrollPosition();
return QPoint(ofs.width(), ofs.height());
}
@@ -1248,9 +1190,7 @@ QPoint QWebFrame::pos() const
*/
QRect QWebFrame::geometry() const
{
- if (!d->frame->view())
- return QRect();
- return d->frame->view()->frameRect();
+ return d->frameRect();
}
/*!
@@ -1479,6 +1419,11 @@ QWebFrame* QWebFramePrivate::kit(const WebCore::Frame* coreFrame)
return qobject_cast<QWebFrame*>(coreFrame->loader()->networkingContext()->originatingObject());
}
+QWebFrame *QWebFramePrivate::kit(const QWebFrameAdapter* frameAdapter)
+{
+ return static_cast<const QWebFramePrivate*>(frameAdapter)->q;
+}
+
/*!
\fn void QWebFrame::javaScriptWindowObjectCleared()
@@ -1859,4 +1804,12 @@ QWebFrame *QWebHitTestResult::frame() const
return d->frame.data();
}
+/*!
+ * \internal
+ */
+QWebFrameAdapter *QWebFrame::handle() const
+{
+ return d;
+}
+
#include "moc_qwebframe.cpp"
diff --git a/Source/WebKit/qt/Api/qwebframe.h b/Source/WebKit/qt/Api/qwebframe.h
index ca96661e3..fe00d81f5 100644
--- a/Source/WebKit/qt/Api/qwebframe.h
+++ b/Source/WebKit/qt/Api/qwebframe.h
@@ -41,8 +41,10 @@ class QPrinter;
QT_END_NAMESPACE
class QWebNetworkRequest;
+class QWebFrameAdapter;
class QWebFramePrivate;
class QWebPage;
+class QWebPageAdapter;
class QWebHitTestResult;
class QWebHistoryItem;
class QWebSecurityOrigin;
@@ -115,8 +117,8 @@ class QWEBKIT_EXPORT QWebFrame : public QObject {
Q_PROPERTY(QPoint scrollPosition READ scrollPosition WRITE setScrollPosition)
Q_PROPERTY(bool focus READ hasFocus)
private:
- QWebFrame(QWebPage *parent, QWebFrameData *frameData);
- QWebFrame(QWebFrame *parent, QWebFrameData *frameData);
+ QWebFrame(QWebPage *parentPage);
+ QWebFrame(QWebFrame* parent, QWebFrameData*);
~QWebFrame();
public:
@@ -200,6 +202,7 @@ public:
virtual bool event(QEvent *);
QWebSecurityOrigin securityOrigin() const;
+ QWebFrameAdapter* handle() const;
public Q_SLOTS:
QVariant evaluateJavaScript(const QString& scriptSource);
diff --git a/Source/WebKit/qt/Api/qwebframe_p.h b/Source/WebKit/qt/Api/qwebframe_p.h
index d6779f2bc..dbdcbc85a 100644
--- a/Source/WebKit/qt/Api/qwebframe_p.h
+++ b/Source/WebKit/qt/Api/qwebframe_p.h
@@ -21,24 +21,25 @@
#ifndef QWEBFRAME_P_H
#define QWEBFRAME_P_H
+#include "QWebFrameAdapter.h"
+
#include "qwebframe.h"
#include "qwebpage_p.h"
#include "EventHandler.h"
+#include "Frame.h"
#include "GraphicsContext.h"
#include "KURL.h"
#if ENABLE(ORIENTATION_EVENTS)
#include "qorientationsensor.h"
#endif // ENABLE(ORIENTATION_EVENTS).
#include "qwebelement.h"
-#include "wtf/RefPtr.h"
-#include "Frame.h"
-#include "ViewportArguments.h"
-#include <wtf/text/WTFString.h>
-
#if USE(ACCELERATED_COMPOSITING)
#include "texmap/TextureMapper.h"
#endif
+#include "ViewportArguments.h"
+#include <wtf/RefPtr.h>
+#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -50,42 +51,17 @@ namespace WebCore {
}
class QWebPage;
-class QWebFrameData {
-public:
- QWebFrameData(WebCore::Page*, WebCore::Frame* parentFrame = 0,
- WebCore::HTMLFrameOwnerElement* = 0,
- const WTF::String& frameName = WTF::String());
-
- WebCore::KURL url;
- WTF::String name;
- WebCore::HTMLFrameOwnerElement* ownerElement;
- WebCore::Page* page;
- RefPtr<WebCore::Frame> frame;
- WebCore::FrameLoaderClientQt* frameLoaderClient;
-
- WTF::String referrer;
- bool allowsScrolling;
- int marginWidth;
- int marginHeight;
-};
-
-class QWebFramePrivate {
+class QWebFramePrivate : public QWebFrameAdapter {
public:
QWebFramePrivate()
: q(0)
, horizontalScrollBarPolicy(Qt::ScrollBarAsNeeded)
, verticalScrollBarPolicy(Qt::ScrollBarAsNeeded)
- , frameLoaderClient(0)
- , frame(0)
, page(0)
- , allowsScrolling(true)
- , marginWidth(-1)
- , marginHeight(-1)
#if USE(ACCELERATED_COMPOSITING)
, rootTextureMapperLayer(0)
#endif
{}
- void init(QWebFrame* qframe, QWebFrameData* frameData);
void setPage(QWebPage*);
inline QWebFrame *parentFrame() { return qobject_cast<QWebFrame*>(q->parent()); }
@@ -95,6 +71,7 @@ public:
static WebCore::Frame* core(const QWebFrame*);
static QWebFrame* kit(const WebCore::Frame*);
+ static QWebFrame* kit(const QWebFrameAdapter*);
void renderRelativeCoords(WebCore::GraphicsContext*, QFlags<QWebFrame::RenderLayer>, const QRegion& clip);
#if USE(TILED_BACKING_STORE)
@@ -105,22 +82,29 @@ public:
void renderCompositedLayers(WebCore::GraphicsContext*, const WebCore::IntRect& clip);
#endif
void renderFrameExtras(WebCore::GraphicsContext*, QFlags<QWebFrame::RenderLayer>, const QRegion& clip);
- void emitUrlChanged();
void _q_orientationChanged();
- void didClearWindowObject();
+
+ // Adapter implementation
+ virtual QWebFrame* apiHandle() OVERRIDE;
+ virtual QObject* handle() OVERRIDE;
+ virtual void contentsSizeDidChange(const QSize &) OVERRIDE;
+ virtual int scrollBarPolicy(Qt::Orientation) const OVERRIDE;
+ virtual void emitUrlChanged() OVERRIDE;
+ virtual void didStartProvisionalLoad() OVERRIDE;
+ virtual void didClearWindowObject() OVERRIDE;
+ virtual bool handleProgressFinished(QPoint*) OVERRIDE;
+ virtual void emitInitialLayoutCompleted() OVERRIDE;
+ virtual void emitIconChanged() OVERRIDE;
+ virtual void emitLoadStarted(bool originatingLoad) OVERRIDE;
+ virtual void emitLoadFinished(bool originatingLoad, bool ok) OVERRIDE;
+ virtual QWebFrameAdapter* createChildFrame(QWebFrameData*) OVERRIDE;
QWebFrame *q;
Qt::ScrollBarPolicy horizontalScrollBarPolicy;
Qt::ScrollBarPolicy verticalScrollBarPolicy;
- WebCore::FrameLoaderClientQt *frameLoaderClient;
- WebCore::Frame *frame;
QWebPage *page;
- WebCore::KURL url;
- bool allowsScrolling;
- int marginWidth;
- int marginHeight;
#if USE(ACCELERATED_COMPOSITING)
WebCore::TextureMapperLayer* rootTextureMapperLayer;
OwnPtr<WebCore::TextureMapper> textureMapper;
diff --git a/Source/WebKit/qt/Api/qwebhistory.cpp b/Source/WebKit/qt/Api/qwebhistory.cpp
index f7849666e..a945b592b 100644
--- a/Source/WebKit/qt/Api/qwebhistory.cpp
+++ b/Source/WebKit/qt/Api/qwebhistory.cpp
@@ -20,15 +20,16 @@
#include "config.h"
#include "qwebhistory.h"
#include "qwebhistory_p.h"
-#include "qwebframe_p.h"
#include "BackForwardListImpl.h"
+#include "Frame.h"
#include "IconDatabaseBase.h"
#include "Image.h"
#include "IntSize.h"
#include "KURL.h"
#include "Page.h"
#include "PageGroup.h"
+#include <QWebPageAdapter.h>
#include <wtf/text/WTFString.h>
#include <QSharedData>
@@ -552,9 +553,9 @@ QDataStream& operator>>(QDataStream& source, QWebHistory& history)
return source;
}
-QWebPagePrivate* QWebHistoryPrivate::page()
+QWebPageAdapter* QWebHistoryPrivate::page()
{
- return QWebFramePrivate::kit(static_cast<WebCore::BackForwardListImpl*>(lst)->page()->mainFrame())->page()->handle();
+ return QWebPageAdapter::kit(static_cast<WebCore::BackForwardListImpl*>(lst)->page());
}
WebCore::HistoryItem* QWebHistoryItemPrivate::core(const QWebHistoryItem* q)
diff --git a/Source/WebKit/qt/Api/qwebhistory_p.h b/Source/WebKit/qt/Api/qwebhistory_p.h
index aaee38632..17634ebc0 100644
--- a/Source/WebKit/qt/Api/qwebhistory_p.h
+++ b/Source/WebKit/qt/Api/qwebhistory_p.h
@@ -26,7 +26,7 @@
#include <QtCore/qglobal.h>
#include <QtCore/qshareddata.h>
-class QWebPagePrivate;
+class QWebPageAdapter;
class QWEBKIT_EXPORT QWebHistoryItemPrivate : public QSharedData {
public:
@@ -63,7 +63,7 @@ public:
lst->deref();
}
- QWebPagePrivate* page();
+ QWebPageAdapter* page();
WebCore::BackForwardListImpl* lst;
};
diff --git a/Source/WebKit/qt/Api/qwebinspector.cpp b/Source/WebKit/qt/Api/qwebinspector.cpp
index 2fbbab249..55089e1a1 100644
--- a/Source/WebKit/qt/Api/qwebinspector.cpp
+++ b/Source/WebKit/qt/Api/qwebinspector.cpp
@@ -184,12 +184,12 @@ void QWebInspector::closeEvent(QCloseEvent* event)
}
/*! \internal */
-void QWebInspectorPrivate::setFrontend(QWidget* newFrontend)
+void QWebInspectorPrivate::setFrontend(QObject* newFrontend)
{
if (frontend)
frontend->setParent(0);
- frontend = newFrontend;
+ frontend = qobject_cast<QWidget*>(newFrontend);
if (frontend) {
frontend->setParent(q);
diff --git a/Source/WebKit/qt/Api/qwebinspector_p.h b/Source/WebKit/qt/Api/qwebinspector_p.h
index 4d327cc5a..908de84ed 100644
--- a/Source/WebKit/qt/Api/qwebinspector_p.h
+++ b/Source/WebKit/qt/Api/qwebinspector_p.h
@@ -35,7 +35,7 @@ public:
, frontend(0)
{}
- void setFrontend(QWidget* newFrontend);
+ void setFrontend(QObject* newFrontend);
void adjustFrontendSize(const QSize& size);
QWebInspector* q;
diff --git a/Source/WebKit/qt/Api/qwebkitglobal.h b/Source/WebKit/qt/Api/qwebkitglobal.h
index 7ee56de86..947ba0654 100644
--- a/Source/WebKit/qt/Api/qwebkitglobal.h
+++ b/Source/WebKit/qt/Api/qwebkitglobal.h
@@ -28,22 +28,14 @@
// Use: #if (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 0, 0)). Similar to Qt.
#define QTWEBKIT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
-#if defined(QT_MAKEDLL) /* create a Qt DLL library */
+#ifndef QT_STATIC
# if defined(BUILDING_WEBKIT)
# define QWEBKIT_EXPORT Q_DECL_EXPORT
# else
# define QWEBKIT_EXPORT Q_DECL_IMPORT
# endif
-#elif defined(QT_DLL) /* use a Qt DLL library */
-# define QWEBKIT_EXPORT Q_DECL_IMPORT
-#endif
-
-#if !defined(QWEBKIT_EXPORT)
-# if defined(QT_SHARED)
-# define QWEBKIT_EXPORT Q_DECL_EXPORT
-# else
-# define QWEBKIT_EXPORT
-# endif
+#else
+# define QWEBKIT_EXPORT
#endif
#endif // QWEBKITGLOBAL_H
diff --git a/Source/WebKit/qt/Api/qwebpage.cpp b/Source/WebKit/qt/Api/qwebpage.cpp
index 02383ac67..65624d190 100644
--- a/Source/WebKit/qt/Api/qwebpage.cpp
+++ b/Source/WebKit/qt/Api/qwebpage.cpp
@@ -22,18 +22,6 @@
#include "config.h"
#include "qwebpage.h"
-#include "qwebview.h"
-#include "qwebframe.h"
-#include "qwebpage_p.h"
-#include "qwebframe_p.h"
-#include "qwebhistory.h"
-#include "qwebhistory_p.h"
-#include "qwebinspector.h"
-#include "qwebinspector_p.h"
-#include "qwebsettings.h"
-#include "qwebkitplatformplugin.h"
-#include "qwebkitversion.h"
-
#include "CSSComputedStyleDeclaration.h"
#include "CSSParser.h"
#include "ApplicationCacheStorage.h"
@@ -45,6 +33,9 @@
#include "ContextMenu.h"
#include "ContextMenuClientQt.h"
#include "ContextMenuController.h"
+#if USE(QT_MULTIMEDIA)
+#include "DefaultFullScreenVideoHandler.h"
+#endif
#if ENABLE(DEVICE_ORIENTATION)
#include "DeviceMotionClientQt.h"
#include "DeviceOrientationClientMock.h"
@@ -62,7 +53,6 @@
#include "Frame.h"
#include "FrameLoadRequest.h"
#include "FrameLoader.h"
-#include "FrameLoader.h"
#include "FrameLoaderClientQt.h"
#include "FrameTree.h"
#include "FrameView.h"
@@ -79,7 +69,9 @@
#include "HitTestResult.h"
#include "Image.h"
#include "InitWebCoreQt.h"
+#include "InitWebKitQt.h"
#include "InspectorClientQt.h"
+#include "InspectorClientWebPage.h"
#include "InspectorController.h"
#include "InspectorServerQt.h"
#include "KURL.h"
@@ -88,20 +80,22 @@
#include "NavigationAction.h"
#include "NetworkingContext.h"
#include "NodeList.h"
-#include "NotificationPresenterClientQt.h"
#include "NotImplemented.h"
+#include "NotificationPresenterClientQt.h"
#include "Page.h"
#include "PageClientQt.h"
#include "PageGroup.h"
#include "Pasteboard.h"
-#include "PlatformGestureEvent.h"
#include "PlatformKeyboardEvent.h"
#include "PlatformTouchEvent.h"
#include "PlatformWheelEvent.h"
#include "PluginDatabase.h"
-#include "PluginDatabase.h"
#include "PluginPackage.h"
#include "ProgressTracker.h"
+#include "QGraphicsWidgetPluginImpl.h"
+#include "QWebUndoCommand.h"
+#include "QWidgetPluginImpl.h"
+#include "QtFallbackWebPopup.h"
#include "QtPlatformPlugin.h"
#include "RenderTextControl.h"
#include "RenderThemeQt.h"
@@ -114,16 +108,30 @@
#include "SystemInfo.h"
#endif // Q_OS_WIN32
#include "TextIterator.h"
+#include "UndoStepQt.h"
#include "UserAgentQt.h"
#include "WebEventConversion.h"
#include "WebKitVersion.h"
#include "WindowFeatures.h"
#include "WorkerThread.h"
+#include "qwebframe.h"
+#include "qwebframe_p.h"
+#include "qwebhistory.h"
+#include "qwebhistory_p.h"
+#include "qwebinspector.h"
+#include "qwebinspector_p.h"
+#include "qwebkitplatformplugin.h"
+#include "qwebkitversion.h"
+#include "qwebpage_p.h"
+#include "qwebsettings.h"
+#include "qwebview.h"
+
#include <QAction>
#include <QApplication>
#include <QBasicTimer>
#include <QBitArray>
+#include <QClipboard>
#include <QColorDialog>
#include <QDebug>
#include <QDesktopWidget>
@@ -137,24 +145,25 @@
#include <QLabel>
#include <QMenu>
#include <QMessageBox>
+#include <QNetworkAccessManager>
#include <QNetworkProxy>
-#include <QUndoStack>
-#include <QUrl>
+#include <QNetworkRequest>
#include <QPainter>
-#include <QClipboard>
#include <QSslSocket>
#include <QStyle>
#include <QSysInfo>
+#if USE(QT_MOBILITY_SYSTEMINFO)
+#include <qsysteminfo.h>
+#endif
+#include <QSystemTrayIcon>
#include <QTextCharFormat>
+#include <QToolTip>
#include <QTouchEvent>
-#include <QNetworkAccessManager>
-#include <QNetworkRequest>
+#include <QUndoStack>
+#include <QUrl>
#if defined(Q_WS_X11)
#include <QX11Info>
#endif
-#if USE(QT_MOBILITY_SYSTEMINFO)
-#include <qsysteminfo.h>
-#endif
using namespace WebCore;
@@ -163,8 +172,6 @@ QT_BEGIN_NAMESPACE
extern Q_GUI_EXPORT int qt_defaultDpi();
QT_END_NAMESPACE
-bool QWebPagePrivate::drtRun = false;
-
// Lookup table mapping QWebPage::WebActions to the associated Editor commands
static const char* editorCommandWebActions[] =
{
@@ -300,40 +307,33 @@ static inline Qt::DropAction dragOpToDropAction(unsigned actions)
QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
: q(qq)
- , page(0)
#ifndef QT_NO_UNDOSTACK
, undoStack(0)
#endif
- , insideOpenCall(false)
, m_totalBytes(0)
, m_bytesReceived()
, clickCausedFocus(false)
- , networkManager(0)
- , forwardUnsupportedContent(false)
- , smartInsertDeleteEnabled(true)
- , selectTrailingWhitespaceEnabled(false)
, linkPolicy(QWebPage::DontDelegateLinks)
- , viewportSize(QSize(0, 0))
- , settings(0)
+ , m_viewportSize(QSize(0, 0))
, useFixedLayout(false)
- , pluginFactory(0)
, inspectorFrontend(0)
, inspector(0)
, inspectorIsInternalOnly(false)
, m_lastDropAction(Qt::IgnoreAction)
{
#if ENABLE(GEOLOCATION) || ENABLE(DEVICE_ORIENTATION)
- bool useMock = QWebPagePrivate::drtRun;
+ bool useMock = QWebPageAdapter::drtRun;
#endif
+ WebKit::initializeWebKitWidgets();
WebCore::initializeWebCoreQt();
Page::PageClients pageClients;
- pageClients.chromeClient = new ChromeClientQt(q);
+ pageClients.chromeClient = new ChromeClientQt(this);
pageClients.contextMenuClient = new ContextMenuClientQt();
- pageClients.editorClient = new EditorClientQt(q);
- pageClients.dragClient = new DragClientQt(q);
- pageClients.inspectorClient = new InspectorClientQt(q);
+ pageClients.editorClient = new EditorClientQt(this);
+ pageClients.dragClient = new DragClientQt(pageClients.chromeClient);
+ pageClients.inspectorClient = new InspectorClientQt(this);
page = new Page(pageClients);
#if ENABLE(GEOLOCATION)
if (useMock) {
@@ -342,7 +342,7 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
WebCore::provideGeolocationTo(page, mock);
mock->setController(WebCore::GeolocationController::from(page));
} else
- WebCore::provideGeolocationTo(page, new GeolocationClientQt(q));
+ WebCore::provideGeolocationTo(page, new GeolocationClientQt(this));
#endif
#if ENABLE(DEVICE_ORIENTATION)
if (useMock)
@@ -351,9 +351,6 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
WebCore::provideDeviceOrientationTo(page, new DeviceOrientationClientQt);
WebCore::provideDeviceMotionTo(page, new DeviceMotionClientQt);
#endif
-#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
- WebCore::provideNotification(page, NotificationPresenterClientQt::notificationPresenter());
-#endif
// By default each page is put into their own unique page group, which affects popup windows
// and visited links. Page groups (per process only) is a feature making it possible to use
@@ -364,7 +361,7 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
page->addLayoutMilestones(DidFirstVisuallyNonEmptyLayout);
- settings = new QWebSettings(page->settings());
+ QWebPageAdapter::init(page);
history.d = new QWebHistoryPrivate(static_cast<WebCore::BackForwardListImpl*>(page->backForwardList()));
memset(actions, 0, sizeof(actions));
@@ -372,8 +369,13 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
PageGroup::setShouldTrackVisitedLinks(true);
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
- NotificationPresenterClientQt::notificationPresenter()->addClient();
-#endif
+ NotificationPresenterClientQt* presenter = NotificationPresenterClientQt::notificationPresenter();
+ presenter->addClient();
+#ifndef QT_NO_SYSTEMTRAYICON
+ if (!presenter->hasSystemTrayIcon())
+ presenter->setSystemTrayIcon(new QSystemTrayIcon);
+#endif // QT_NO_SYSTEMTRAYICON
+#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
}
QWebPagePrivate::~QWebPagePrivate()
@@ -384,8 +386,6 @@ QWebPagePrivate::~QWebPagePrivate()
#ifndef QT_NO_UNDOSTACK
delete undoStack;
#endif
- delete settings;
- delete page;
if (inspector) {
// If the inspector is ours, delete it, otherwise just detach from it.
@@ -394,41 +394,225 @@ QWebPagePrivate::~QWebPagePrivate()
else
inspector->setPage(0);
}
+ // Explicitly destruct the WebCore page at this point when the
+ // QWebPagePrivate / QWebPageAdapater vtables are still intact,
+ // in order for various destruction callbacks out of WebCore to
+ // work.
+ deletePage();
+}
-#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
- NotificationPresenterClientQt::notificationPresenter()->removeClient();
+WebCore::Page* QWebPagePrivate::core(const QWebPage* page)
+{
+ return page->d->page;
+}
+
+void QWebPagePrivate::show()
+{
+ if (!view)
+ return;
+ view->window()->show();
+}
+
+void QWebPagePrivate::setFocus()
+{
+ if (!view)
+ return;
+ view->setFocus();
+}
+
+void QWebPagePrivate::unfocus()
+{
+ if (!view)
+ return;
+ view->clearFocus();
+}
+
+void QWebPagePrivate::setWindowRect(const QRect &rect)
+{
+ emit q->geometryChangeRequested(rect);
+}
+
+QSize QWebPagePrivate::viewportSize() const
+{
+ return q->viewportSize();
+}
+
+QWebPageAdapter *QWebPagePrivate::createWindow(bool dialog)
+{
+ QWebPage *newPage = q->createWindow(dialog ? QWebPage::WebModalDialog : QWebPage::WebBrowserWindow);
+ if (!newPage)
+ return 0;
+ // Make sure the main frame exists, as WebCore expects it when returning from this ChromeClient::createWindow()
+ newPage->d->createMainFrame();
+ return newPage->d;
+}
+
+void QWebPagePrivate::javaScriptConsoleMessage(const QString &message, int lineNumber, const QString &sourceID)
+{
+ q->javaScriptConsoleMessage(message, lineNumber, sourceID);
+}
+
+void QWebPagePrivate::javaScriptAlert(QWebFrameAdapter* frame, const QString& msg)
+{
+ q->javaScriptAlert(QWebFramePrivate::kit(frame), msg);
+}
+
+bool QWebPagePrivate::javaScriptConfirm(QWebFrameAdapter* frame, const QString& msg)
+{
+ return q->javaScriptConfirm(QWebFramePrivate::kit(frame), msg);
+}
+
+bool QWebPagePrivate::javaScriptPrompt(QWebFrameAdapter *frame, const QString &msg, const QString &defaultValue, QString *result)
+{
+ return q->javaScriptPrompt(QWebFramePrivate::kit(frame), msg, defaultValue, result);
+}
+
+bool QWebPagePrivate::shouldInterruptJavaScript()
+{
+ return q->shouldInterruptJavaScript();
+}
+
+void QWebPagePrivate::printRequested(QWebFrameAdapter *frame)
+{
+ emit q->printRequested(QWebFramePrivate::kit(frame));
+}
+
+void QWebPagePrivate::databaseQuotaExceeded(QWebFrameAdapter* frame, const QString& databaseName)
+{
+ emit q->databaseQuotaExceeded(QWebFramePrivate::kit(frame), databaseName);
+}
+
+void QWebPagePrivate::applicationCacheQuotaExceeded(QWebSecurityOrigin *origin, quint64 defaultOriginQuota, quint64 c)
+{
+ emit q->applicationCacheQuotaExceeded(origin, defaultOriginQuota, c);
+}
+
+void QWebPagePrivate::setToolTip(const QString &tip)
+{
+#ifndef QT_NO_TOOLTIP
+ if (!view)
+ return;
+
+ if (tip.isEmpty()) {
+ view->setToolTip(QString());
+ QToolTip::hideText();
+ } else {
+ QString dtip = QLatin1String("<p>") + QString(tip).toHtmlEscaped() + QLatin1String("</p>");
+ view->setToolTip(dtip);
+ }
+#else
+ Q_UNUSED(tip);
#endif
}
-WebCore::ViewportArguments QWebPagePrivate::viewportArguments()
+#if USE(QT_MULTIMEDIA)
+QWebFullScreenVideoHandler *QWebPagePrivate::createFullScreenVideoHandler()
{
- return page ? page->viewportArguments() : WebCore::ViewportArguments();
+ return new WebKit::DefaultFullScreenVideoHandler;
}
+#endif
-WebCore::Page* QWebPagePrivate::core(const QWebPage* page)
+QWebFrameAdapter *QWebPagePrivate::mainFrameAdapter()
{
- return page->d->page;
+ return q->mainFrame()->d;
}
-QWebPagePrivate* QWebPagePrivate::priv(QWebPage* page)
+QStringList QWebPagePrivate::chooseFiles(QWebFrameAdapter *frame, bool allowMultiple, const QStringList &suggestedFileNames)
{
- return page->d;
+ if (allowMultiple && q->supportsExtension(QWebPage::ChooseMultipleFilesExtension)) {
+ QWebPage::ChooseMultipleFilesExtensionOption option;
+ option.parentFrame = QWebFramePrivate::kit(frame);
+ option.suggestedFileNames = suggestedFileNames;
+
+ QWebPage::ChooseMultipleFilesExtensionReturn output;
+ q->extension(QWebPage::ChooseMultipleFilesExtension, &option, &output);
+
+ return output.fileNames;
+ }
+ // Single file
+ QStringList result;
+ QString suggestedFile;
+ if (!suggestedFileNames.isEmpty())
+ suggestedFile = suggestedFileNames.first();
+ QString file = q->chooseFile(QWebFramePrivate::kit(frame), suggestedFile);
+ if (!file.isEmpty())
+ result << file;
+ return result;
}
-bool QWebPagePrivate::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
+bool QWebPagePrivate::acceptNavigationRequest(QWebFrameAdapter *frameAdapter, const QNetworkRequest &request, int type)
{
+ QWebFrame *frame = frameAdapter ? QWebFramePrivate::kit(frameAdapter): 0;
if (insideOpenCall
&& frame == mainFrame.data())
return true;
- return q->acceptNavigationRequest(frame, request, type);
+ return q->acceptNavigationRequest(frame, request, QWebPage::NavigationType(type));
+}
+
+void QWebPagePrivate::emitRestoreFrameStateRequested(QWebFrameAdapter *frame)
+{
+ emit q->restoreFrameStateRequested(QWebFramePrivate::kit(frame));
+}
+
+void QWebPagePrivate::emitSaveFrameStateRequested(QWebFrameAdapter *frame, QWebHistoryItem *item)
+{
+ emit q->saveFrameStateRequested(QWebFramePrivate::kit(frame), item);
+}
+
+void QWebPagePrivate::emitDownloadRequested(const QNetworkRequest &request)
+{
+ emit q->downloadRequested(request);
+}
+
+void QWebPagePrivate::emitFrameCreated(QWebFrameAdapter *frame)
+{
+ emit q->frameCreated(QWebFramePrivate::kit(frame));
+}
+
+bool QWebPagePrivate::errorPageExtension(QWebPageAdapter::ErrorPageOption *opt, QWebPageAdapter::ErrorPageReturn *out)
+{
+ QWebPage::ErrorPageExtensionOption option;
+ if (opt->domain == QLatin1String("QtNetwork"))
+ option.domain = QWebPage::QtNetwork;
+ else if (opt->domain == QLatin1String("HTTP"))
+ option.domain = QWebPage::Http;
+ else if (opt->domain == QLatin1String("WebKit"))
+ option.domain = QWebPage::WebKit;
+ else
+ return false;
+ option.url = opt->url;
+ option.frame = QWebFramePrivate::kit(opt->frame);
+ option.error = opt->error;
+ option.errorString = opt->errorString;
+ QWebPage::ErrorPageExtensionReturn output;
+ if (!q->extension(QWebPage::ErrorPageExtension, &option, &output))
+ return false;
+ out->baseUrl = output.baseUrl;
+ out->content = output.content;
+ out->contentType = output.contentType;
+ out->encoding = output.encoding;
+ return true;
+}
+
+QtPluginWidgetAdapter *QWebPagePrivate::createPlugin(const QString &classid, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues)
+{
+ QObject *widget = q->createPlugin(classid, url, paramNames, paramValues);
+ return adapterForWidget(widget);
+}
+
+QtPluginWidgetAdapter *QWebPagePrivate::adapterForWidget(QObject *object) const
+{
+ if (QWidget *widget = qobject_cast<QWidget*>(object))
+ return new QWidgetPluginImpl(widget);
+ if (QGraphicsWidget *widget = qobject_cast<QGraphicsWidget*>(object))
+ return new QGraphicsWidgetPluginImpl(widget);
+ return 0;
}
void QWebPagePrivate::createMainFrame()
{
if (!mainFrame) {
- QWebFrameData frameData(page);
- mainFrame = new QWebFrame(q, &frameData);
-
+ mainFrame = new QWebFrame(q);
emit q->frameCreated(mainFrame.data());
}
}
@@ -475,49 +659,49 @@ QMenu *QWebPagePrivate::createContextMenu(const WebCore::ContextMenu *webcoreMen
if (!client || !webcoreMenu)
return 0;
- QMenu* menu = new QMenu(client->ownerWidget());
+ QMenu* menu = new QMenu(q->view());
for (int i = 0; i < items->count(); ++i) {
const ContextMenuItem &item = items->at(i);
switch (item.type()) {
- case WebCore::CheckableActionType: /* fall through */
- case WebCore::ActionType: {
- QWebPage::WebAction action = webActionForContextMenuAction(item.action());
- QAction *a = q->action(action);
- if (a) {
- ContextMenuItem it(item);
- page->contextMenuController()->checkOrEnableIfNeeded(it);
- PlatformMenuItemDescription desc = it.releasePlatformDescription();
- a->setEnabled(desc.enabled);
- a->setChecked(desc.checked);
- a->setCheckable(item.type() == WebCore::CheckableActionType);
-
- menu->addAction(a);
- visitedWebActions->setBit(action);
- }
- break;
+ case WebCore::CheckableActionType: /* fall through */
+ case WebCore::ActionType: {
+ QWebPage::WebAction action = webActionForContextMenuAction(item.action());
+ QAction *a = q->action(action);
+ if (a) {
+ ContextMenuItem it(item);
+ page->contextMenuController()->checkOrEnableIfNeeded(it);
+ PlatformMenuItemDescription desc = it.releasePlatformDescription();
+ a->setEnabled(desc.enabled);
+ a->setChecked(desc.checked);
+ a->setCheckable(item.type() == WebCore::CheckableActionType);
+
+ menu->addAction(a);
+ visitedWebActions->setBit(action);
}
- case WebCore::SeparatorType:
- menu->addSeparator();
- break;
- case WebCore::SubmenuType: {
- QMenu *subMenu = createContextMenu(webcoreMenu, item.platformSubMenu(), visitedWebActions);
-
- bool anyEnabledAction = false;
+ break;
+ }
+ case WebCore::SeparatorType:
+ menu->addSeparator();
+ break;
+ case WebCore::SubmenuType: {
+ QMenu *subMenu = createContextMenu(webcoreMenu, item.platformSubMenu(), visitedWebActions);
- QList<QAction *> actions = subMenu->actions();
- for (int i = 0; i < actions.count(); ++i) {
- if (actions.at(i)->isVisible())
- anyEnabledAction |= actions.at(i)->isEnabled();
- }
+ bool anyEnabledAction = false;
- // don't show sub-menus with just disabled actions
- if (anyEnabledAction) {
- subMenu->setTitle(item.title());
- menu->addAction(subMenu->menuAction());
- } else
- delete subMenu;
- break;
+ QList<QAction *> actions = subMenu->actions();
+ for (int i = 0; i < actions.count(); ++i) {
+ if (actions.at(i)->isVisible())
+ anyEnabledAction |= actions.at(i)->isEnabled();
}
+
+ // don't show sub-menus with just disabled actions
+ if (anyEnabledAction) {
+ subMenu->setTitle(item.title());
+ menu->addAction(subMenu->menuAction());
+ } else
+ delete subMenu;
+ break;
+ }
}
}
return menu;
@@ -619,6 +803,65 @@ void QWebPagePrivate::updateNavigationActions()
updateAction(QWebPage::ReloadAndBypassCache);
}
+QObject *QWebPagePrivate::inspectorHandle()
+{
+ return getOrCreateInspector();
+}
+
+void QWebPagePrivate::setInspectorFrontend(QObject* frontend)
+{
+ inspectorFrontend = qobject_cast<QWidget*>(frontend);
+ if (inspector)
+ inspector->d->setFrontend(frontend);
+}
+
+void QWebPagePrivate::setInspectorWindowTitle(const QString& title)
+{
+ if (inspector)
+ inspector->setWindowTitle(title);
+}
+
+void QWebPagePrivate::createWebInspector(QObject** inspectorView, QWebPageAdapter** inspectorPage)
+{
+ QWebPage* page = new WebKit::InspectorClientWebPage;
+ *inspectorView = page->view();
+ *inspectorPage = page->d;
+}
+
+#ifndef QT_NO_MENU
+static QStringList iterateContextMenu(QMenu* menu)
+{
+ if (!menu)
+ return QStringList();
+
+ QStringList items;
+ QList<QAction *> actions = menu->actions();
+ for (int i = 0; i < actions.count(); ++i) {
+ if (actions.at(i)->isSeparator())
+ items << QLatin1String("<separator>");
+ else
+ items << actions.at(i)->text();
+ if (actions.at(i)->menu())
+ items << iterateContextMenu(actions.at(i)->menu());
+ }
+ return items;
+}
+#endif
+
+QStringList QWebPagePrivate::menuActionsAsText()
+{
+#ifndef QT_NO_MENU
+ return iterateContextMenu(currentContextMenu.data());
+#else
+ return QStringList();
+#endif
+}
+
+void QWebPagePrivate::emitViewportChangeRequested()
+{
+ emit q->viewportChangeRequested();
+}
+
void QWebPagePrivate::updateEditorActions()
{
updateAction(QWebPage::Cut);
@@ -682,8 +925,7 @@ void QWebPagePrivate::timerEvent(QTimerEvent *ev)
q->timerEvent(ev);
}
-template<class T>
-void QWebPagePrivate::mouseMoveEvent(T* ev)
+void QWebPagePrivate::mouseMoveEvent(QMouseEvent* ev)
{
WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data());
if (!frame->view())
@@ -693,8 +935,7 @@ void QWebPagePrivate::mouseMoveEvent(T* ev)
ev->setAccepted(accepted);
}
-template<class T>
-void QWebPagePrivate::mousePressEvent(T* ev)
+void QWebPagePrivate::mousePressEvent(QMouseEvent* ev)
{
WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data());
if (!frame->view())
@@ -729,8 +970,7 @@ void QWebPagePrivate::mousePressEvent(T* ev)
clickCausedFocus = true;
}
-template<class T>
-void QWebPagePrivate::mouseDoubleClickEvent(T *ev)
+void QWebPagePrivate::mouseDoubleClickEvent(QMouseEvent *ev)
{
WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data());
if (!frame->view())
@@ -747,8 +987,7 @@ void QWebPagePrivate::mouseDoubleClickEvent(T *ev)
tripleClick = QPointF(ev->pos()).toPoint();
}
-template<class T>
-void QWebPagePrivate::mouseTripleClickEvent(T *ev)
+void QWebPagePrivate::mouseTripleClickEvent(QMouseEvent *ev)
{
WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data());
if (!frame->view())
@@ -762,8 +1001,7 @@ void QWebPagePrivate::mouseTripleClickEvent(T *ev)
ev->setAccepted(accepted);
}
-template<class T>
-void QWebPagePrivate::mouseReleaseEvent(T *ev)
+void QWebPagePrivate::mouseReleaseEvent(QMouseEvent *ev)
{
WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data());
if (!frame->view())
@@ -790,7 +1028,7 @@ void QWebPagePrivate::handleSoftwareInputPanel(Qt::MouseButton button, const QPo
&& frame->document()->focusedNode()
&& button == Qt::LeftButton && qApp->autoSipEnabled()) {
QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
- client->ownerWidget()->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
+ client->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
if (!clickCausedFocus || behavior == QStyle::RSIP_OnMouseClick) {
HitTestResult result = frame->eventHandler()->hitTestResultAtPoint(frame->view()->windowToContents(pos), false);
if (result.isContentEditable()) {
@@ -833,14 +1071,13 @@ QMenu *QWebPage::createStandardContextMenu()
}
#ifndef QT_NO_WHEELEVENT
-template<class T>
-void QWebPagePrivate::wheelEvent(T *ev)
+void QWebPagePrivate::wheelEvent(QWheelEvent *ev)
{
WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data());
if (!frame->view())
return;
- PlatformWheelEvent pev = convertWheelEvent(ev);
+ PlatformWheelEvent pev = convertWheelEvent(ev, QApplication::wheelScrollLines());
bool accepted = frame->eventHandler()->handleWheelEvent(pev);
ev->setAccepted(accepted);
}
@@ -1340,33 +1577,39 @@ bool QWebPagePrivate::touchEvent(QTouchEvent* event)
bool QWebPagePrivate::gestureEvent(QGestureEvent* event)
{
-#if ENABLE(GESTURE_EVENTS)
- WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data());
- if (!frame->view())
+ QWebFrameAdapter* frame = mainFrame.data()->d;
+ if (!frame->hasView())
return false;
-
// QGestureEvents can contain updates for multiple gestures.
bool handled = false;
+#if ENABLE(GESTURE_EVENTS)
+ // QGestureEvent lives in Widgets, we'll need a dummy struct to mule the info it contains to the "other side"
+ QGestureEventFacade gestureFacade;
+
QGesture* gesture = event->gesture(Qt::TapGesture);
// Beware that gestures send by DumpRenderTree will have state Qt::NoGesture,
// due to not originating from a GestureRecognizer.
if (gesture && (gesture->state() == Qt::GestureStarted || gesture->state() == Qt::NoGesture)) {
- frame->eventHandler()->handleGestureEvent(convertGesture(event, gesture));
- event->setAccepted(true);
+ gestureFacade.type = Qt::TapGesture;
+ QPointF globalPos = static_cast<const QTapGesture*>(gesture)->position();
+ gestureFacade.globalPos = globalPos.toPoint();
+ gestureFacade.pos = event->widget()->mapFromGlobal(globalPos.toPoint());
+ frame->handleGestureEvent(&gestureFacade);
handled = true;
}
gesture = event->gesture(Qt::TapAndHoldGesture);
if (gesture && (gesture->state() == Qt::GestureStarted || gesture->state() == Qt::NoGesture)) {
- frame->eventHandler()->sendContextMenuEventForGesture(convertGesture(event, gesture));
- event->setAccepted(true);
+ gestureFacade.type = Qt::TapAndHoldGesture;
+ QPointF globalPos = static_cast<const QTapAndHoldGesture*>(gesture)->position();
+ gestureFacade.globalPos = globalPos.toPoint();
+ gestureFacade.pos = event->widget()->mapFromGlobal(globalPos.toPoint());
+ frame->handleGestureEvent(&gestureFacade);
handled = true;
}
+#endif // ENABLE(GESTURE_EVENTS)
+ event->setAccepted(handled);
return handled;
-#else
- event->ignore();
- return false;
-#endif
}
/*!
@@ -2037,12 +2280,12 @@ void QWebPage::setView(QWidget* view)
if (d->client) {
if (d->client->isQWidgetClient())
- static_cast<PageClientQWidget*>(d->client.get())->view = view;
+ static_cast<PageClientQWidget*>(d->client.data())->view = view;
return;
}
if (view)
- d->client = adoptPtr(new PageClientQWidget(view, this));
+ d->client.reset(new PageClientQWidget(view, this));
}
/*!
@@ -2068,7 +2311,7 @@ void QWebPage::javaScriptConsoleMessage(const QString& message, int lineNumber,
// 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 (QWebPageAdapter::drtRun) {
if (message == QLatin1String("PLUGIN: NPP_Destroy")) {
fprintf(stdout, "CONSOLE MESSAGE: ");
if (lineNumber)
@@ -2088,8 +2331,7 @@ void QWebPage::javaScriptAlert(QWebFrame *frame, const QString& msg)
{
Q_UNUSED(frame)
#ifndef QT_NO_MESSAGEBOX
- QWidget* parent = (d->client) ? d->client->ownerWidget() : 0;
- QMessageBox box(parent);
+ QMessageBox box(view());
box.setWindowTitle(tr("JavaScript Alert - %1").arg(mainFrame()->url().host()));
box.setTextFormat(Qt::PlainText);
box.setText(msg);
@@ -2110,8 +2352,7 @@ bool QWebPage::javaScriptConfirm(QWebFrame *frame, const QString& msg)
#ifdef QT_NO_MESSAGEBOX
return true;
#else
- QWidget* parent = (d->client) ? d->client->ownerWidget() : 0;
- QMessageBox box(parent);
+ QMessageBox box(view());
box.setWindowTitle(tr("JavaScript Confirm - %1").arg(mainFrame()->url().host()));
box.setTextFormat(Qt::PlainText);
box.setText(msg);
@@ -2136,8 +2377,7 @@ bool QWebPage::javaScriptPrompt(QWebFrame *frame, const QString& msg, const QStr
bool ok = false;
#ifndef QT_NO_INPUTDIALOG
- QWidget* parent = (d->client) ? d->client->ownerWidget() : 0;
- QInputDialog dlg(parent);
+ QInputDialog dlg(view());
dlg.setWindowTitle(tr("JavaScript Prompt - %1").arg(mainFrame()->url().host()));
// Hack to force the dialog's QLabel into plain text mode
@@ -2171,18 +2411,13 @@ bool QWebPage::javaScriptPrompt(QWebFrame *frame, const QString& msg, const QStr
If the user wanted to stop the JavaScript the implementation should return true; otherwise false.
The default implementation executes the query using QMessageBox::information with QMessageBox::Yes and QMessageBox::No buttons.
-
- \warning Because of binary compatibility constraints, this function is not virtual. If you want to
- provide your own implementation in a QWebPage subclass, reimplement the shouldInterruptJavaScript()
- slot in your subclass instead. QtWebKit will dynamically detect the slot and call it.
*/
bool QWebPage::shouldInterruptJavaScript()
{
#ifdef QT_NO_MESSAGEBOX
return false;
#else
- QWidget* parent = (d->client) ? d->client->ownerWidget() : 0;
- return QMessageBox::Yes == QMessageBox::information(parent, tr("JavaScript Problem - %1").arg(mainFrame()->url().host()), tr("The script on this page appears to have a problem. Do you want to stop the script?"), QMessageBox::Yes, QMessageBox::No);
+ return QMessageBox::Yes == QMessageBox::information(view(), tr("JavaScript Problem - %1").arg(mainFrame()->url().host()), tr("The script on this page appears to have a problem. Do you want to stop the script?"), QMessageBox::Yes, QMessageBox::No);
#endif
}
@@ -2197,7 +2432,8 @@ void QWebPage::setFeaturePermission(QWebFrame* frame, Feature feature, Permissio
break;
case Geolocation:
#if ENABLE(GEOLOCATION)
- GeolocationPermissionClientQt::geolocationPermissionClient()->setPermission(frame, policy);
+ if (policy != PermissionUnknown)
+ GeolocationPermissionClientQt::geolocationPermissionClient()->setPermission(frame->d, (policy == PermissionGrantedByUser));
#endif
break;
@@ -2461,20 +2697,146 @@ QColor QWebPagePrivate::colorSelectionRequested(const QColor &selectedColor)
{
QColor ret = selectedColor;
#ifndef QT_NO_COLORDIALOG
- QWidget* parent = (client) ? client->ownerWidget() : 0;
- ret = QColorDialog::getColor(selectedColor, parent);
+ ret = QColorDialog::getColor(selectedColor, q->view());
if (!ret.isValid())
ret = selectedColor;
#endif
return ret;
}
+QWebSelectMethod *QWebPagePrivate::createSelectPopup()
+{
+ return new QtFallbackWebPopup(this);
+}
+
+QRect QWebPagePrivate::viewRectRelativeToWindow()
+{
+
+ QWidget* ownerWidget= client.isNull() ? 0 : qobject_cast<QWidget*>(client->ownerWidget());
+ if (!ownerWidget)
+ return QRect();
+ QWidget* topLevelWidget = ownerWidget->window();
+
+ QPoint topLeftCorner = ownerWidget->mapFrom(topLevelWidget, QPoint(0, 0));
+ return QRect(topLeftCorner, ownerWidget->size());
+}
+
+void QWebPagePrivate::geolocationPermissionRequested(QWebFrameAdapter* frame)
+{
+ emit q->featurePermissionRequested(QWebFramePrivate::kit(frame), QWebPage::Geolocation);
+}
+
+void QWebPagePrivate::geolocationPermissionRequestCancelled(QWebFrameAdapter* frame)
+{
+ emit q->featurePermissionRequestCanceled(QWebFramePrivate::kit(frame), QWebPage::Geolocation);
+}
+
+void QWebPagePrivate::notificationsPermissionRequested(QWebFrameAdapter* frame)
+{
+ emit q->featurePermissionRequested(QWebFramePrivate::kit(frame), QWebPage::Notifications);
+}
+
+void QWebPagePrivate::notificationsPermissionRequestCancelled(QWebFrameAdapter* frame)
+{
+ emit q->featurePermissionRequestCanceled(QWebFramePrivate::kit(frame), QWebPage::Notifications);
+}
+
+void QWebPagePrivate::respondToChangedContents()
+{
+ updateEditorActions();
+
+ emit q->contentsChanged();
+}
+
+void QWebPagePrivate::respondToChangedSelection()
+{
+ updateEditorActions();
+ emit q->selectionChanged();
+}
+
+void QWebPagePrivate::microFocusChanged()
+{
+ emit q->microFocusChanged();
+}
+
+void QWebPagePrivate::triggerCopyAction()
+{
+ q->triggerAction(QWebPage::Copy);
+}
+
+void QWebPagePrivate::triggerActionForKeyEvent(QKeyEvent* event)
+{
+ QWebPage::WebAction action = editorActionForKeyEvent(event);
+ q->triggerAction(action);
+}
+
+void QWebPagePrivate::clearUndoStack()
+{
+#ifndef QT_NO_UNDOSTACK
+ if (undoStack)
+ undoStack->clear();
+#endif
+}
+
+bool QWebPagePrivate::canUndo() const
+{
+#ifndef QT_NO_UNDOSTACK
+ if (!undoStack)
+ return false;
+ return undoStack->canUndo();
+#else
+ return false;
+#endif
+}
+
+bool QWebPagePrivate::canRedo() const
+{
+#ifndef QT_NO_UNDOSTACK
+ if (!undoStack)
+ return false;
+ return undoStack->canRedo();
+#else
+ return false;
+#endif
+}
+
+void QWebPagePrivate::undo()
+{
+#ifndef QT_NO_UNDOSTACK
+ if (undoStack)
+ undoStack->undo();
+#endif
+}
+
+void QWebPagePrivate::redo()
+{
+#ifndef QT_NO_UNDOSTACK
+ if (undoStack)
+ undoStack->redo();
+#endif
+}
+
+void QWebPagePrivate::createUndoStep(QSharedPointer<UndoStepQt> step)
+{
+#ifndef QT_NO_UNDOSTACK
+ // Call undoStack() getter first to ensure stack is created
+ // if it doesn't exist yet.
+ q->undoStack()->push(new QWebUndoCommand(step));
+#endif
+}
+
+const char *QWebPagePrivate::editorCommandForKeyEvent(QKeyEvent* event)
+{
+ QWebPage::WebAction action = editorActionForKeyEvent(event);
+ return editorCommandForWebActions(action);
+}
+
QSize QWebPage::viewportSize() const
{
if (d->mainFrame && d->mainFrame.data()->d->frame->view())
return d->mainFrame.data()->d->frame->view()->frameRect().size();
- return d->viewportSize;
+ return d->m_viewportSize;
}
/*!
@@ -2491,7 +2853,7 @@ QSize QWebPage::viewportSize() const
*/
void QWebPage::setViewportSize(const QSize &size) const
{
- d->viewportSize = size;
+ d->m_viewportSize = size;
QWebFrame *frame = mainFrame();
if (frame->d->frame && frame->d->frame->view()) {
@@ -2577,7 +2939,7 @@ QWebPage::ViewportAttributes QWebPage::viewportAttributesForSize(const QSize& av
// Both environment variables need to be set - or they will be ignored.
if (deviceWidth < 0 && deviceHeight < 0) {
- QSize size = queryDeviceSizeForScreenContainingWidget((d->client) ? d->client->ownerWidget() : 0);
+ QSize size = queryDeviceSizeForScreenContainingWidget(view());
deviceWidth = size.width();
deviceHeight = size.height();
}
@@ -3093,18 +3455,34 @@ bool QWebPage::event(QEvent *ev)
d->mouseReleaseEvent(static_cast<QMouseEvent*>(ev));
break;
#if !defined(QT_NO_GRAPHICSVIEW)
- case QEvent::GraphicsSceneMouseMove:
- d->mouseMoveEvent(static_cast<QGraphicsSceneMouseEvent*>(ev));
+ case QEvent::GraphicsSceneMouseMove: {
+ QGraphicsSceneMouseEvent *gsEv = static_cast<QGraphicsSceneMouseEvent*>(ev);
+ QMouseEvent dummyEvent(QEvent::MouseMove, gsEv->pos(), gsEv->screenPos(), gsEv->button(), gsEv->buttons(), gsEv->modifiers());
+ d->mouseMoveEvent(&dummyEvent);
+ ev->setAccepted(dummyEvent.isAccepted());
break;
- case QEvent::GraphicsSceneMousePress:
- d->mousePressEvent(static_cast<QGraphicsSceneMouseEvent*>(ev));
+ }
+ case QEvent::GraphicsSceneMouseRelease: {
+ QGraphicsSceneMouseEvent *gsEv = static_cast<QGraphicsSceneMouseEvent*>(ev);
+ QMouseEvent dummyEvent(QEvent::MouseButtonRelease, gsEv->pos(), gsEv->screenPos(), gsEv->button(), gsEv->buttons(), gsEv->modifiers());
+ d->mouseReleaseEvent(&dummyEvent);
+ ev->setAccepted(dummyEvent.isAccepted());
break;
- case QEvent::GraphicsSceneMouseDoubleClick:
- d->mouseDoubleClickEvent(static_cast<QGraphicsSceneMouseEvent*>(ev));
+ }
+ case QEvent::GraphicsSceneMousePress: {
+ QGraphicsSceneMouseEvent *gsEv = static_cast<QGraphicsSceneMouseEvent*>(ev);
+ QMouseEvent dummyEvent(QEvent::MouseButtonPress, gsEv->pos(), gsEv->screenPos(), gsEv->button(), gsEv->buttons(), gsEv->modifiers());
+ d->mousePressEvent(&dummyEvent);
+ ev->setAccepted(dummyEvent.isAccepted());
break;
- case QEvent::GraphicsSceneMouseRelease:
- d->mouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent*>(ev));
+ }
+ case QEvent::GraphicsSceneMouseDoubleClick: {
+ QGraphicsSceneMouseEvent *gsEv = static_cast<QGraphicsSceneMouseEvent*>(ev);
+ QMouseEvent dummyEvent(QEvent::MouseButtonDblClick, gsEv->pos(), gsEv->screenPos(), gsEv->button(), gsEv->buttons(), gsEv->modifiers());
+ d->mouseDoubleClickEvent(&dummyEvent);
+ ev->setAccepted(dummyEvent.isAccepted());
break;
+ }
#endif
#ifndef QT_NO_CONTEXTMENU
case QEvent::ContextMenu:
@@ -3121,9 +3499,13 @@ bool QWebPage::event(QEvent *ev)
d->wheelEvent(static_cast<QWheelEvent*>(ev));
break;
#if !defined(QT_NO_GRAPHICSVIEW)
- case QEvent::GraphicsSceneWheel:
- d->wheelEvent(static_cast<QGraphicsSceneWheelEvent*>(ev));
+ case QEvent::GraphicsSceneWheel: {
+ QGraphicsSceneWheelEvent *gsEv = static_cast<QGraphicsSceneWheelEvent*>(ev);
+ QWheelEvent dummyEvent(gsEv->pos(), gsEv->screenPos(), gsEv->delta(), gsEv->buttons(), gsEv->modifiers(), gsEv->orientation());
+ d->wheelEvent(&dummyEvent);
+ ev->setAccepted(dummyEvent.isAccepted());
break;
+ }
#endif
#endif
case QEvent::KeyPress:
@@ -3639,8 +4021,7 @@ bool QWebPage::extension(Extension extension, const ExtensionOption *option, Ext
if (extension == ChooseMultipleFilesExtension) {
// FIXME: do not ignore suggestedFiles
QStringList suggestedFiles = static_cast<const ChooseMultipleFilesExtensionOption*>(option)->suggestedFileNames;
- QWidget* parent = (d->client) ? d->client->ownerWidget() : 0;
- QStringList names = QFileDialog::getOpenFileNames(parent, QString::null);
+ QStringList names = QFileDialog::getOpenFileNames(view(), QString::null);
static_cast<ChooseMultipleFilesExtensionReturn*>(output)->fileNames = names;
return true;
}
@@ -3665,6 +4046,14 @@ bool QWebPage::supportsExtension(Extension extension) const
}
/*!
+ * \internal
+ */
+QWebPageAdapter *QWebPage::handle() const
+{
+ return d;
+}
+
+/*!
Finds the specified string, \a subString, in the page, using the given \a options.
If the HighlightAllOccurrences flag is passed, the function will highlight all occurrences
@@ -3732,8 +4121,7 @@ QString QWebPage::chooseFile(QWebFrame *parentFrame, const QString& suggestedFil
{
Q_UNUSED(parentFrame)
#ifndef QT_NO_FILEDIALOG
- QWidget* parent = (d->client) ? d->client->ownerWidget() : 0;
- return QFileDialog::getOpenFileName(parent, QString::null, suggestedFile);
+ return QFileDialog::getOpenFileName(view(), QString::null, suggestedFile);
#else
return QString::null;
#endif
@@ -3750,11 +4138,7 @@ QString QWebPage::chooseFile(QWebFrame *parentFrame, const QString& suggestedFil
*/
void QWebPage::setNetworkAccessManager(QNetworkAccessManager *manager)
{
- if (manager == d->networkManager)
- return;
- if (d->networkManager && d->networkManager->parent() == this)
- delete d->networkManager;
- d->networkManager = manager;
+ d->setNetworkAccessManager(manager);
}
/*!
@@ -3765,11 +4149,7 @@ void QWebPage::setNetworkAccessManager(QNetworkAccessManager *manager)
*/
QNetworkAccessManager *QWebPage::networkAccessManager() const
{
- if (!d->networkManager) {
- QWebPage *that = const_cast<QWebPage *>(this);
- that->d->networkManager = new QNetworkAccessManager(that);
- }
- return d->networkManager;
+ return d->networkAccessManager();
}
/*!
diff --git a/Source/WebKit/qt/Api/qwebpage.h b/Source/WebKit/qt/Api/qwebpage.h
index b2caa131d..bb5421fcc 100644
--- a/Source/WebKit/qt/Api/qwebpage.h
+++ b/Source/WebKit/qt/Api/qwebpage.h
@@ -46,6 +46,7 @@ class QWebFrameData;
class QWebHistoryItem;
class QWebHitTestResult;
class QWebNetworkInterface;
+class QWebPageAdapter;
class QWebPagePrivate;
class QWebPluginFactory;
class QWebSecurityOrigin;
@@ -365,10 +366,9 @@ public:
virtual bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0);
virtual bool supportsExtension(Extension extension) const;
- inline QWebPagePrivate* handle() const { return d; }
+ QWebPageAdapter* handle() const;
-public Q_SLOTS:
- bool shouldInterruptJavaScript();
+ virtual bool shouldInterruptJavaScript();
Q_SIGNALS:
void loadStarted();
diff --git a/Source/WebKit/qt/Api/qwebpage_p.h b/Source/WebKit/qt/Api/qwebpage_p.h
index 794322991..2434dd653 100644
--- a/Source/WebKit/qt/Api/qwebpage_p.h
+++ b/Source/WebKit/qt/Api/qwebpage_p.h
@@ -21,29 +21,22 @@
#ifndef QWEBPAGE_P_H
#define QWEBPAGE_P_H
-#include <QPointer>
+#include "QWebPageAdapter.h"
+
+#include "qwebframe.h"
+#include "qwebhistory.h"
+#include "qwebpage.h"
+#include <QPointer>
#include <qbasictimer.h>
-#include <qnetworkproxy.h>
#include <qevent.h>
#include <qgesture.h>
#include <qgraphicssceneevent.h>
+#include <qgraphicswidget.h>
+#include <qnetworkproxy.h>
-#include "qwebpage.h"
-#include "qwebhistory.h"
-#include "qwebframe.h"
-
-#include "IntPoint.h"
-#include "KURL.h"
-
-#include <wtf/OwnPtr.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/WTFString.h>
-
-#include "ViewportArguments.h"
namespace WebCore {
- class ChromeClientQt;
class ContextMenuClientQt;
class ContextMenuItem;
class ContextMenu;
@@ -54,7 +47,6 @@ namespace WebCore {
class IntRect;
class Node;
class NodeList;
- class Page;
class Frame;
}
@@ -64,8 +56,10 @@ class QMenu;
class QBitArray;
QT_END_NAMESPACE
+class QtPluginWidgetAdapter;
class QWebInspector;
-class QWebPageClient;
+class QWebFrameAdapter;
+class UndoStepQt;
class QtViewportAttributesPrivate : public QSharedData {
public:
@@ -76,13 +70,74 @@ public:
QWebPage::ViewportAttributes* q;
};
-class QWebPagePrivate {
+class QWebPagePrivate : public QWebPageAdapter {
public:
QWebPagePrivate(QWebPage*);
~QWebPagePrivate();
static WebCore::Page* core(const QWebPage*);
- static QWebPagePrivate* priv(QWebPage*);
+
+ // Adapter implementation
+ virtual void show() OVERRIDE;
+ virtual void setFocus() OVERRIDE;
+ virtual void unfocus() OVERRIDE;
+ virtual void setWindowRect(const QRect &) OVERRIDE;
+ virtual QSize viewportSize() const OVERRIDE;
+ virtual QWebPageAdapter* createWindow(bool /*dialog*/) OVERRIDE;
+ virtual QObject* handle() OVERRIDE { return q; }
+ virtual void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID) OVERRIDE;
+ virtual void javaScriptAlert(QWebFrameAdapter*, const QString& msg) OVERRIDE;
+ virtual bool javaScriptConfirm(QWebFrameAdapter*, const QString& msg) OVERRIDE;
+ virtual bool javaScriptPrompt(QWebFrameAdapter*, const QString& msg, const QString& defaultValue, QString* result) OVERRIDE;
+ virtual bool shouldInterruptJavaScript() OVERRIDE;
+ virtual void printRequested(QWebFrameAdapter*) OVERRIDE;
+ virtual void databaseQuotaExceeded(QWebFrameAdapter*, const QString& databaseName) OVERRIDE;
+ virtual void applicationCacheQuotaExceeded(QWebSecurityOrigin*, quint64 defaultOriginQuota, quint64 totalSpaceNeeded) OVERRIDE;
+ virtual void setToolTip(const QString&) OVERRIDE;
+#if USE(QT_MULTIMEDIA)
+ virtual QWebFullScreenVideoHandler* createFullScreenVideoHandler() OVERRIDE;
+#endif
+ virtual QWebFrameAdapter* mainFrameAdapter() OVERRIDE;
+ virtual QStringList chooseFiles(QWebFrameAdapter*, bool allowMultiple, const QStringList& suggestedFileNames) OVERRIDE;
+ virtual QColor colorSelectionRequested(const QColor& selectedColor) OVERRIDE;
+ virtual QWebSelectMethod* createSelectPopup() OVERRIDE;
+ virtual QRect viewRectRelativeToWindow() OVERRIDE;
+ virtual void geolocationPermissionRequested(QWebFrameAdapter*) OVERRIDE;
+ virtual void geolocationPermissionRequestCancelled(QWebFrameAdapter*) OVERRIDE;
+ virtual void notificationsPermissionRequested(QWebFrameAdapter*) OVERRIDE;
+ virtual void notificationsPermissionRequestCancelled(QWebFrameAdapter*) OVERRIDE;
+
+ virtual void respondToChangedContents() OVERRIDE;
+ virtual void respondToChangedSelection() OVERRIDE;
+ virtual void microFocusChanged() OVERRIDE;
+ virtual void triggerCopyAction() OVERRIDE;
+ virtual void triggerActionForKeyEvent(QKeyEvent*) OVERRIDE;
+ virtual void clearUndoStack() OVERRIDE;
+ virtual bool canUndo() const OVERRIDE;
+ virtual bool canRedo() const OVERRIDE;
+ virtual void undo() OVERRIDE;
+ virtual void redo() OVERRIDE;
+ virtual void createUndoStep(QSharedPointer<UndoStepQt>) OVERRIDE;
+ virtual const char* editorCommandForKeyEvent(QKeyEvent*) OVERRIDE;
+
+ void updateNavigationActions() OVERRIDE;
+
+ virtual QObject* inspectorHandle() OVERRIDE;
+ virtual void setInspectorFrontend(QObject*) OVERRIDE;
+ virtual void setInspectorWindowTitle(const QString&) OVERRIDE;
+ virtual void createWebInspector(QObject** inspectorView, QWebPageAdapter** inspectorPage) OVERRIDE;
+ virtual QStringList menuActionsAsText() OVERRIDE;
+ virtual void emitViewportChangeRequested() OVERRIDE;
+ virtual bool acceptNavigationRequest(QWebFrameAdapter*, const QNetworkRequest&, int type) OVERRIDE;
+ virtual void emitRestoreFrameStateRequested(QWebFrameAdapter*) OVERRIDE;
+ virtual void emitSaveFrameStateRequested(QWebFrameAdapter*, QWebHistoryItem*) OVERRIDE;
+ virtual void emitDownloadRequested(const QNetworkRequest&) OVERRIDE;
+ virtual void emitFrameCreated(QWebFrameAdapter*) OVERRIDE;
+ virtual QString userAgentForUrl(const QUrl &url) const OVERRIDE { return q->userAgentForUrl(url); }
+ virtual bool supportsErrorPageExtension() const OVERRIDE { return q->supportsExtension(QWebPage::ErrorPageExtension); }
+ virtual bool errorPageExtension(ErrorPageOption *, ErrorPageReturn *) OVERRIDE;
+ virtual QtPluginWidgetAdapter* createPlugin(const QString &, const QUrl &, const QStringList &, const QStringList &) OVERRIDE;
+ virtual QtPluginWidgetAdapter* adapterForWidget(QObject *) const OVERRIDE;
void createMainFrame();
#ifndef QT_NO_CONTEXTMENU
@@ -92,23 +147,20 @@ public:
void _q_webActionTriggered(bool checked);
void _q_cleanupLeakMessages();
void updateAction(QWebPage::WebAction action);
- void updateNavigationActions();
void updateEditorActions();
- QColor colorSelectionRequested(const QColor& selectedColor);
-
void timerEvent(QTimerEvent*);
- template<class T> void mouseMoveEvent(T*);
- template<class T> void mousePressEvent(T*);
- template<class T> void mouseDoubleClickEvent(T*);
- template<class T> void mouseTripleClickEvent(T*);
- template<class T> void mouseReleaseEvent(T*);
+ void mouseMoveEvent(QMouseEvent*);
+ void mousePressEvent(QMouseEvent*);
+ void mouseDoubleClickEvent(QMouseEvent*);
+ void mouseTripleClickEvent(QMouseEvent*);
+ void mouseReleaseEvent(QMouseEvent*);
#ifndef QT_NO_CONTEXTMENU
void contextMenuEvent(const QPoint& globalPos);
#endif
#ifndef QT_NO_WHEELEVENT
- template<class T> void wheelEvent(T*);
+ void wheelEvent(QWheelEvent*);
#endif
void keyPressEvent(QKeyEvent*);
void keyReleaseEvent(QKeyEvent*);
@@ -159,16 +211,12 @@ public:
WebCore::InspectorController* inspectorController();
quint16 inspectorServerPort();
- WebCore::ViewportArguments viewportArguments();
-
#ifndef QT_NO_SHORTCUT
static QWebPage::WebAction editorActionForKeyEvent(QKeyEvent* event);
#endif
static const char* editorCommandForWebActions(QWebPage::WebAction action);
QWebPage *q;
- WebCore::Page *page;
- OwnPtr<QWebPageClient> client;
QPointer<QWebFrame> mainFrame;
#ifndef QT_NO_UNDOSTACK
@@ -177,7 +225,6 @@ public:
QPointer<QWidget> view;
- bool insideOpenCall;
quint64 m_totalBytes;
quint64 m_bytesReceived;
@@ -186,15 +233,9 @@ public:
bool clickCausedFocus;
- bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type);
- QNetworkAccessManager *networkManager;
-
- bool forwardUnsupportedContent;
- bool smartInsertDeleteEnabled;
- bool selectTrailingWhitespaceEnabled;
QWebPage::LinkDelegationPolicy linkPolicy;
- QSize viewportSize;
+ QSize m_viewportSize;
QSize fixedLayoutSize;
QWebHistory history;
@@ -202,20 +243,15 @@ public:
#ifndef QT_NO_CONTEXTMENU
QPointer<QMenu> currentContextMenu;
#endif
- QWebSettings *settings;
QPalette palette;
bool useFixedLayout;
QAction *actions[QWebPage::WebActionCount];
- QWebPluginFactory *pluginFactory;
-
QWidget* inspectorFrontend;
QWebInspector* inspector;
bool inspectorIsInternalOnly; // True if created through the Inspect context menu action
Qt::DropAction m_lastDropAction;
-
- static bool drtRun;
};
#endif
diff --git a/Source/WebKit/qt/Api/qwebsettings.cpp b/Source/WebKit/qt/Api/qwebsettings.cpp
index 768c80256..74d8524d8 100644
--- a/Source/WebKit/qt/Api/qwebsettings.cpp
+++ b/Source/WebKit/qt/Api/qwebsettings.cpp
@@ -20,41 +20,39 @@
#include "config.h"
#include "qwebsettings.h"
-#include "qwebpage.h"
-#include "qwebpage_p.h"
#include "qwebplugindatabase_p.h"
#include "AbstractDatabase.h"
-#include "MemoryCache.h"
+#include "ApplicationCacheStorage.h"
#include "CrossOriginPreflightResultCache.h"
+#include "DatabaseTracker.h"
+#include "FileSystem.h"
#include "FontCache.h"
+#include "IconDatabase.h"
+#include "Image.h"
#if ENABLE(ICONDATABASE)
#include "IconDatabaseClientQt.h"
#endif
#include "InitWebCoreQt.h"
+#include "IntSize.h"
+#include "KURL.h"
+#include "MemoryCache.h"
+#include "NetworkStateNotifier.h"
#include "Page.h"
#include "PageCache.h"
-#include "Settings.h"
-#include "KURL.h"
-#include "IconDatabase.h"
#include "PluginDatabase.h"
-#include "Image.h"
-#include "IntSize.h"
-#include "ApplicationCacheStorage.h"
-#include "DatabaseTracker.h"
-#include "FileSystem.h"
-#include <wtf/text/WTFString.h>
-
-#include <QApplication>
-#include <QStandardPaths>
+#include "Settings.h"
#include <QDir>
+#include <QFileInfo>
+#include <QFont>
+#include <QGuiApplication>
#include <QHash>
#include <QSharedData>
+#include <QStandardPaths>
#include <QUrl>
-#include <QFileInfo>
-#include <QStyle>
+#include <wtf/text/WTFString.h>
+
-#include "NetworkStateNotifier.h"
void QWEBKIT_EXPORT qt_networkAccessAllowed(bool isAllowed)
{
diff --git a/Source/WebKit/qt/Api/qwebsettings.h b/Source/WebKit/qt/Api/qwebsettings.h
index 5e7d3e1b4..49721b7cb 100644
--- a/Source/WebKit/qt/Api/qwebsettings.h
+++ b/Source/WebKit/qt/Api/qwebsettings.h
@@ -163,6 +163,7 @@ public:
inline QWebSettingsPrivate* handle() const { return d; }
private:
+ friend class QWebPageAdapter;
friend class QWebPagePrivate;
friend class QWebSettingsPrivate;
diff --git a/Source/WebKit/qt/Api/qwebview.cpp b/Source/WebKit/qt/Api/qwebview.cpp
index 9f2af5787..2eda6a18e 100644
--- a/Source/WebKit/qt/Api/qwebview.cpp
+++ b/Source/WebKit/qt/Api/qwebview.cpp
@@ -227,9 +227,9 @@ void QWebViewPrivate::detachCurrentPage()
// to destroy it.
if (page->d->client && page->d->client->isQWidgetClient())
- page->d->client.clear();
+ page->d->client.reset();
- page->d->client.release();
+ page->d->client.take();
// if the page was created by us, we own it and need to
// destroy it as well.