Diff
Modified: trunk/Source/WebKit2/ChangeLog (145514 => 145515)
--- trunk/Source/WebKit2/ChangeLog 2013-03-12 11:13:02 UTC (rev 145514)
+++ trunk/Source/WebKit2/ChangeLog 2013-03-12 11:13:31 UTC (rev 145515)
@@ -1,5 +1,37 @@
2013-02-14 Jocelyn Turcotte <jocelyn.turco...@digia.com>
+ [Qt][WK2] Allow QtWebContext to call directly to QQuickWebView with a WKPageRef
+ https://bugs.webkit.org/show_bug.cgi?id=109829
+
+ Reviewed by Allan Sandfeld Jensen.
+ Signed off for WebKit2 by Benjamin Poulain.
+
+ Instead of going through WebPageProxy and PageClient to forward
+ injected bundle messages received by the context, maintain a static map
+ of WKPageRef to QQuickWebViewPrivate.
+
+ * UIProcess/API/qt/qquickwebview.cpp:
+ (QQuickWebViewPrivate::get):
+ (QQuickWebViewPrivate::~QQuickWebViewPrivate):
+ (QQuickWebViewPrivate::initialize):
+ (QQuickWebViewPrivate::didReceiveMessageFromNavigatorQtObject):
+ * UIProcess/API/qt/qquickwebview_p_p.h:
+ (QQuickWebViewPrivate):
+ * UIProcess/API/qt/raw/qrawwebview.cpp:
+ * UIProcess/API/qt/raw/qrawwebview_p_p.h:
+ * UIProcess/PageClient.h:
+ (PageClient):
+ * UIProcess/WebPageProxy.h:
+ (WebPageProxy):
+ * UIProcess/qt/QtPageClient.cpp:
+ * UIProcess/qt/QtPageClient.h:
+ (QtPageClient):
+ * UIProcess/qt/QtWebContext.cpp:
+ (WebKit::didReceiveMessageFromInjectedBundle):
+ * UIProcess/qt/WebPageProxyQt.cpp:
+
+2013-02-14 Jocelyn Turcotte <jocelyn.turco...@digia.com>
+
[Qt][WK2] Keep the WebContext alive during the whole application's lifetime
https://bugs.webkit.org/show_bug.cgi?id=109827
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp (145514 => 145515)
--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp 2013-03-12 11:13:02 UTC (rev 145514)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp 2013-03-12 11:13:31 UTC (rev 145515)
@@ -44,6 +44,7 @@
#endif
#include "WebPageGroup.h"
#include "WebPreferences.h"
+#include "qglobal.h"
#include "qquicknetworkreply_p.h"
#include "qquicknetworkrequest_p.h"
#include "qquickwebpage_p_p.h"
@@ -60,6 +61,7 @@
#include <_javascript_Core/JSBase.h>
#include <_javascript_Core/JSRetainPtr.h>
#include <QDateTime>
+#include <QMap>
#include <QtCore/QFile>
#include <QtQml/QJSValue>
#include <QtQuick/QQuickView>
@@ -86,6 +88,9 @@
static const qreal kAxisLockVelocityThreshold = 300;
static const qreal kAxisLockVelocityDirectionThreshold = 50;
+typedef QMap<WKPageRef, QQuickWebViewPrivate*> PageToViewMap;
+Q_GLOBAL_STATIC(PageToViewMap, pageToView)
+
static inline QQuickWebViewPrivate* toQQuickWebViewPrivate(const void* clientInfo)
{
ASSERT(clientInfo);
@@ -198,6 +203,11 @@
return new QQuickWebViewLegacyPrivate(publicObject);
}
+QQuickWebViewPrivate* QQuickWebViewPrivate::get(WKPageRef page)
+{
+ return pageToView()->value(page);
+}
+
QQuickWebViewPrivate::FlickableAxisLocker::FlickableAxisLocker()
: m_allowedDirection(QQuickFlickable::AutoFlickDirection)
, m_time(0), m_sampleCount(0)
@@ -301,6 +311,7 @@
QQuickWebViewPrivate::~QQuickWebViewPrivate()
{
webPageProxy->close();
+ pageToView()->remove(webPage.get());
}
// Note: we delay this initialization to make sure that QQuickWebView has its d-ptr in-place.
@@ -313,6 +324,8 @@
context = contextRef ? QtWebContext::create(toImpl(contextRef)) : QtWebContext::defaultContext();
webPageProxy = context->createWebPage(&pageClient, toImpl(pageGroup.get()));
webPage = toAPI(webPageProxy.get());
+ pageToView()->insert(webPage.get(), this);
+
webPageProxy->setUseFixedLayout(s_flickableViewportEnabled);
#if ENABLE(FULLSCREEN_API)
webPageProxy->fullScreenManager()->setWebView(q_ptr);
@@ -913,10 +926,10 @@
\sa postMessage
*/
-void QQuickWebViewPrivate::didReceiveMessageFromNavigatorQtObject(const String& message)
+void QQuickWebViewPrivate::didReceiveMessageFromNavigatorQtObject(WKStringRef message)
{
QVariantMap variantMap;
- variantMap.insert(QLatin1String("data"), QString(message));
+ variantMap.insert(QLatin1String("data"), WKStringCopyQString(message));
variantMap.insert(QLatin1String("origin"), q_ptr->url());
emit q_ptr->experimental()->messageReceived(variantMap);
}
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h (145514 => 145515)
--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h 2013-03-12 11:13:02 UTC (rev 145514)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h 2013-03-12 11:13:31 UTC (rev 145515)
@@ -65,6 +65,7 @@
public:
static QQuickWebViewPrivate* get(QQuickWebView* q) { return q->d_ptr.data(); }
+ static QQuickWebViewPrivate* get(WKPageRef);
virtual ~QQuickWebViewPrivate();
@@ -124,13 +125,14 @@
// PageClient.
WebCore::IntSize viewSize() const;
- void didReceiveMessageFromNavigatorQtObject(const String& message);
virtual void pageDidRequestScroll(const QPoint& pos) { }
void processDidCrash();
void didRelaunchProcess();
PassOwnPtr<WebKit::DrawingAreaProxy> createDrawingAreaProxy();
void handleDownloadRequest(WebKit::DownloadProxy*);
+ void didReceiveMessageFromNavigatorQtObject(WKStringRef message);
+
protected:
class FlickableAxisLocker {
QQuickFlickable::FlickableDirection m_allowedDirection;
Modified: trunk/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp (145514 => 145515)
--- trunk/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp 2013-03-12 11:13:02 UTC (rev 145514)
+++ trunk/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp 2013-03-12 11:13:31 UTC (rev 145515)
@@ -37,11 +37,6 @@
#include <WebCore/CoordinatedGraphicsScene.h>
#include <WebKit2/qrawwebview_p.h>
-void QRawWebViewPrivate::didReceiveMessageFromNavigatorQtObject(const String& message)
-{
- notImplemented();
-}
-
void QRawWebViewPrivate::didChangeViewportProperties(const WebCore::ViewportAttributes& attr)
{
notImplemented();
Modified: trunk/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p_p.h (145514 => 145515)
--- trunk/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p_p.h 2013-03-12 11:13:02 UTC (rev 145514)
+++ trunk/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p_p.h 2013-03-12 11:13:31 UTC (rev 145515)
@@ -46,7 +46,6 @@
virtual void countStringMatchesInCustomRepresentation(const String&, WebKit::FindOptions, unsigned maxMatchCount) { }
virtual void clearAllEditCommands() { }
- virtual void didReceiveMessageFromNavigatorQtObject(const String& message);
virtual void didChangeViewportProperties(const WebCore::ViewportAttributes& attr);
virtual void handleDownloadRequest(WebKit::DownloadProxy* download);
Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (145514 => 145515)
--- trunk/Source/WebKit2/UIProcess/PageClient.h 2013-03-12 11:13:02 UTC (rev 145514)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h 2013-03-12 11:13:31 UTC (rev 145515)
@@ -121,7 +121,6 @@
#endif
#if PLATFORM(QT)
virtual void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&) = 0;
- virtual void didReceiveMessageFromNavigatorQtObject(const String&) = 0;
virtual void handleAuthenticationRequiredRequest(const String& hostname, const String& realm, const String& prefilledUsername, String& username, String& password) = 0;
virtual void handleCertificateVerificationRequest(const String& hostname, bool& ignoreErrors) = 0;
virtual void handleProxyAuthenticationRequiredRequest(const String& hostname, uint16_t port, const String& prefilledUsername, String& username, String& password) = 0;
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (145514 => 145515)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2013-03-12 11:13:02 UTC (rev 145514)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2013-03-12 11:13:31 UTC (rev 145515)
@@ -655,7 +655,6 @@
#if PLATFORM(QT)
void findZoomableAreaForPoint(const WebCore::IntPoint&, const WebCore::IntSize&);
- void didReceiveMessageFromNavigatorQtObject(const String&);
#endif
#if PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(GTK)
Modified: trunk/Source/WebKit2/UIProcess/qt/QtPageClient.cpp (145514 => 145515)
--- trunk/Source/WebKit2/UIProcess/qt/QtPageClient.cpp 2013-03-12 11:13:02 UTC (rev 145514)
+++ trunk/Source/WebKit2/UIProcess/qt/QtPageClient.cpp 2013-03-12 11:13:31 UTC (rev 145515)
@@ -245,11 +245,6 @@
m_eventHandler->didFindZoomableArea(target, area);
}
-void QtPageClient::didReceiveMessageFromNavigatorQtObject(const String& message)
-{
- QQuickWebViewPrivate::get(m_webView)->didReceiveMessageFromNavigatorQtObject(message);
-}
-
void QtPageClient::updateTextInputState()
{
ASSERT(m_eventHandler);
Modified: trunk/Source/WebKit2/UIProcess/qt/QtPageClient.h (145514 => 145515)
--- trunk/Source/WebKit2/UIProcess/qt/QtPageClient.h 2013-03-12 11:13:02 UTC (rev 145514)
+++ trunk/Source/WebKit2/UIProcess/qt/QtPageClient.h 2013-03-12 11:13:31 UTC (rev 145515)
@@ -47,7 +47,6 @@
virtual WebCore::IntSize viewSize();
virtual bool isViewFocused();
virtual bool isViewVisible();
- virtual void didReceiveMessageFromNavigatorQtObject(const String&);
virtual void pageDidRequestScroll(const WebCore::IntPoint&);
virtual void didChangeContentsSize(const WebCore::IntSize&);
virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&);
Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebContext.cpp (145514 => 145515)
--- trunk/Source/WebKit2/UIProcess/qt/QtWebContext.cpp 2013-03-12 11:13:02 UTC (rev 145514)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebContext.cpp 2013-03-12 11:13:31 UTC (rev 145515)
@@ -26,7 +26,7 @@
#include "WKAPICast.h"
#include "WebContext.h"
#include "WebInspectorServer.h"
-#include "WebPageProxy.h"
+#include "qquickwebview_p_p.h"
#include <WKArray.h>
#include <WKPage.h>
#include <WKString.h>
@@ -99,7 +99,7 @@
WKPageRef page = static_cast<WKPageRef>(WKArrayGetItemAtIndex(body, 0));
WKStringRef str = static_cast<WKStringRef>(WKArrayGetItemAtIndex(body, 1));
- toImpl(page)->didReceiveMessageFromNavigatorQtObject(toImpl(str)->string());
+ QQuickWebViewPrivate::get(page)->didReceiveMessageFromNavigatorQtObject(str);
}
static void initializeContextInjectedBundleClient(WebContext* context)
Modified: trunk/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp (145514 => 145515)
--- trunk/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp 2013-03-12 11:13:02 UTC (rev 145514)
+++ trunk/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp 2013-03-12 11:13:31 UTC (rev 145515)
@@ -99,11 +99,6 @@
m_process->send(Messages::WebPage::FindZoomableAreaForPoint(point, area), m_pageID);
}
-void WebPageProxy::didReceiveMessageFromNavigatorQtObject(const String& contents)
-{
- m_pageClient->didReceiveMessageFromNavigatorQtObject(contents);
-}
-
void WebPageProxy::authenticationRequiredRequest(const String& hostname, const String& realm, const String& prefilledUsername, String& username, String& password)
{
m_pageClient->handleAuthenticationRequiredRequest(hostname, realm, prefilledUsername, username, password);