summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/API
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/UIProcess/API')
-rw-r--r--Source/WebKit2/UIProcess/API/APIURLSchemeHandlerTask.cpp44
-rw-r--r--Source/WebKit2/UIProcess/API/APIURLSchemeHandlerTask.h48
-rw-r--r--Source/WebKit2/UIProcess/API/APIWebsiteDataStore.cpp2
-rw-r--r--Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp9
-rw-r--r--Source/WebKit2/UIProcess/API/qt/APIWebsiteDataStoreQt.cpp90
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp6
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h6
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp184
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h13
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h11
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebchannelwebkittransport.cpp21
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebchannelwebkittransport_p.h6
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebkittest.cpp24
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebloadrequest.cpp2
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp16
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/CMakeLists.txt93
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml4
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_evaluateJavaScript.qml38
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_webchannel.qml2
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/notification.html4
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp4
21 files changed, 483 insertions, 144 deletions
diff --git a/Source/WebKit2/UIProcess/API/APIURLSchemeHandlerTask.cpp b/Source/WebKit2/UIProcess/API/APIURLSchemeHandlerTask.cpp
new file mode 100644
index 000000000..8c4201c91
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/APIURLSchemeHandlerTask.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "APIURLSchemeHandlerTask.h"
+
+#include "WebURLSchemeHandler.h"
+#include "WebURLSchemeHandlerTask.h"
+
+namespace API {
+
+Ref<URLSchemeHandlerTask> URLSchemeHandlerTask::create(WebKit::WebURLSchemeHandlerTask& webURLSchemeHandlerTask)
+{
+ return adoptRef(*new URLSchemeHandlerTask(webURLSchemeHandlerTask));
+}
+
+URLSchemeHandlerTask::URLSchemeHandlerTask(WebKit::WebURLSchemeHandlerTask& webURLSchemeHandlerTask)
+ : m_webURLSchemeHandlerTask(webURLSchemeHandlerTask)
+{
+}
+
+}
diff --git a/Source/WebKit2/UIProcess/API/APIURLSchemeHandlerTask.h b/Source/WebKit2/UIProcess/API/APIURLSchemeHandlerTask.h
new file mode 100644
index 000000000..7e31508fd
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/APIURLSchemeHandlerTask.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "APIObject.h"
+
+namespace WebKit {
+class WebURLSchemeHandlerTask;
+}
+
+namespace API {
+
+class URLSchemeHandlerTask final : public ObjectImpl<Object::Type::URLSchemeHandlerTask> {
+public:
+ static Ref<URLSchemeHandlerTask> create(WebKit::WebURLSchemeHandlerTask&);
+
+ WebKit::WebURLSchemeHandlerTask& task() { return m_webURLSchemeHandlerTask.get(); }
+
+private:
+ URLSchemeHandlerTask(WebKit::WebURLSchemeHandlerTask&);
+
+ Ref<WebKit::WebURLSchemeHandlerTask> m_webURLSchemeHandlerTask;
+};
+
+}
diff --git a/Source/WebKit2/UIProcess/API/APIWebsiteDataStore.cpp b/Source/WebKit2/UIProcess/API/APIWebsiteDataStore.cpp
index 1d0873890..7f6f4a0b2 100644
--- a/Source/WebKit2/UIProcess/API/APIWebsiteDataStore.cpp
+++ b/Source/WebKit2/UIProcess/API/APIWebsiteDataStore.cpp
@@ -66,7 +66,7 @@ bool WebsiteDataStore::isPersistent()
return m_websiteDataStore->isPersistent();
}
-#if !PLATFORM(COCOA) && !PLATFORM(EFL) && !PLATFORM(GTK)
+#if !PLATFORM(COCOA) && !PLATFORM(EFL) && !PLATFORM(GTK) && !PLATFORM(QT)
WebKit::WebsiteDataStore::Configuration WebsiteDataStore::defaultDataStoreConfiguration()
{
// FIXME: Fill everything in.
diff --git a/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp b/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp
index 4ae448e62..6fad021f6 100644
--- a/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp
+++ b/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp
@@ -39,8 +39,13 @@ QString WKStringCopyQString(WKStringRef stringRef)
{
if (!stringRef)
return QString();
- const WTF::String& string = toImpl(stringRef)->string();
- return QString(reinterpret_cast<const QChar*>(string.characters()), string.length());
+
+ auto stringView = toImpl(stringRef)->stringView();
+
+ if (stringView.is8Bit())
+ return QString::fromLatin1(reinterpret_cast<const char*>(stringView.characters8()), stringView.length());
+
+ return QString(reinterpret_cast<const QChar*>(stringView.characters16()), stringView.length());
}
namespace WebKit {
diff --git a/Source/WebKit2/UIProcess/API/qt/APIWebsiteDataStoreQt.cpp b/Source/WebKit2/UIProcess/API/qt/APIWebsiteDataStoreQt.cpp
new file mode 100644
index 000000000..ab2b11a1b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/APIWebsiteDataStoreQt.cpp
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "APIWebsiteDataStore.h"
+
+#include "QtWebContext.h"
+
+#include <WebCore/ApplicationCacheStorage.h>
+#include <WebCore/FileSystem.h>
+
+namespace API {
+
+String WebsiteDataStore::defaultApplicationCacheDirectory()
+{
+ return WebKit::QtWebContext::preparedStoragePath(WebKit::QtWebContext::ApplicationCacheStorage);
+}
+
+String WebsiteDataStore::defaultNetworkCacheDirectory()
+{
+ return WebKit::QtWebContext::preparedStoragePath(WebKit::QtWebContext::DiskCacheStorage);
+}
+
+String WebsiteDataStore::defaultIndexedDBDatabaseDirectory()
+{
+ return WebKit::QtWebContext::preparedStoragePath(WebKit::QtWebContext::DatabaseStorage);
+}
+
+String WebsiteDataStore::defaultLocalStorageDirectory()
+{
+ return WebKit::QtWebContext::preparedStoragePath(WebKit::QtWebContext::LocalStorage);
+}
+
+String WebsiteDataStore::defaultMediaKeysStorageDirectory()
+{
+ return String(); // QTFIXME: Add MediaKeys path
+}
+
+String WebsiteDataStore::defaultWebSQLDatabaseDirectory()
+{
+ return WebKit::QtWebContext::preparedStoragePath(WebKit::QtWebContext::DatabaseStorage);
+}
+
+String WebsiteDataStore::cacheDirectoryFileSystemRepresentation(const String& directoryName)
+{
+ return String();
+}
+
+String WebsiteDataStore::websiteDataDirectoryFileSystemRepresentation(const String& directoryName)
+{
+ return String();
+}
+
+WebKit::WebsiteDataStore::Configuration WebsiteDataStore::defaultDataStoreConfiguration()
+{
+ WebKit::WebsiteDataStore::Configuration configuration;
+
+ configuration.applicationCacheDirectory = defaultApplicationCacheDirectory();
+ configuration.networkCacheDirectory = defaultNetworkCacheDirectory();
+
+ configuration.webSQLDatabaseDirectory = defaultWebSQLDatabaseDirectory();
+ configuration.localStorageDirectory = defaultLocalStorageDirectory();
+ configuration.mediaKeysStorageDirectory = defaultMediaKeysStorageDirectory();
+
+ return configuration;
+}
+
+} // namespace API
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp
index a991bcfdd..f6717a405 100644
--- a/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp
@@ -59,10 +59,10 @@ QQuickWebPagePrivate::QQuickWebPagePrivate(QQuickWebPage* q, QQuickWebView* view
{
}
-void QQuickWebPagePrivate::paint(QPainter* painter)
+void QQuickWebPagePrivate::paint(QPainter* painter, const WebCore::Color& backgroundColor, bool drawsBackground)
{
if (CoordinatedGraphicsScene* scene = QQuickWebViewPrivate::get(viewportItem)->coordinatedGraphicsScene())
- scene->paintToGraphicsContext(painter);
+ scene->paintToGraphicsContext(painter, backgroundColor, drawsBackground);
}
@@ -88,7 +88,7 @@ QSGNode* QQuickWebPage::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*)
}
if (!node)
- node = new QtWebPageSGNode;
+ node = new QtWebPageSGNode(*webViewPrivate->webPageProxy);
node->setCoordinatedGraphicsScene(scene);
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h
index 9a04b3f03..e8120a19e 100644
--- a/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h
@@ -24,6 +24,10 @@
#include "qquickwebpage_p.h"
#include <QTransform>
+namespace WebCore {
+class Color;
+}
+
class QQuickWebViewPrivate;
class QQuickWebPagePrivate {
@@ -33,7 +37,7 @@ public:
void updateSize();
- void paint(QPainter*);
+ void paint(QPainter*, const WebCore::Color& backgroundColor, bool drawsBackground);
void resetPaintNode();
QQuickWebPage* const q;
QQuickWebView* const viewportItem;
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
index 9b634184a..cf8ac19d9 100644
--- a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
@@ -23,11 +23,13 @@
#include "config.h"
#include "qquickwebview_p.h"
+#include "APIPageConfiguration.h"
+#include "CoordinatedDrawingAreaProxy.h"
#include "CoordinatedGraphicsScene.h"
#include "CoordinatedLayerTreeHostProxy.h"
#include "DownloadProxy.h"
-#include "DrawingAreaProxyImpl.h"
#include "PageViewportControllerClientQt.h"
+#include "QrcSchemeHandler.h"
#include "QtDialogRunner.h"
#include "QtDownloadManager.h"
#include "QtWebContext.h"
@@ -68,8 +70,10 @@
#include <QtCore/QFile>
#include <QtQml/QJSValue>
#include <QtQuick/QQuickView>
+#include <WKData.h>
#include <WKNumber.h>
#include <WKOpenPanelResultListener.h>
+#include <WKPageConfigurationRef.h>
#include <WKPageGroup.h>
#include <WKPreferencesRef.h>
#include <WKSerializedScriptValue.h>
@@ -84,7 +88,7 @@
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
-#ifdef HAVE_WEBCHANNEL
+#if ENABLE(QT_WEBCHANNEL)
#include "qwebchannelwebkittransport_p.h"
#include <QtWebChannel/QQmlWebChannel>
#endif
@@ -92,7 +96,8 @@
using namespace WebCore;
using namespace WebKit;
-static bool s_flickableViewportEnabled = true;
+// QTFIXME: flickable viewport has painting artifacts so we cannot enable it by default
+static bool s_flickableViewportEnabled = false; //true;
static const int kAxisLockSampleCount = 5;
static const qreal kAxisLockVelocityThreshold = 300;
static const qreal kAxisLockVelocityDirectionThreshold = 50;
@@ -131,6 +136,11 @@ static QJSValue buildQJSValue(QJSEngine* engine, JSGlobalContextRef context, JSV
return var;
switch (JSValueGetType(context, value)) {
+ case kJSTypeUndefined:
+ break;
+ case kJSTypeNull:
+ var = QJSValue(QJSValue::NullValue);
+ break;
case kJSTypeBoolean:
var = QJSValue(JSValueToBoolean(context, value));
break;
@@ -324,39 +334,47 @@ QQuickWebViewPrivate::~QQuickWebViewPrivate()
}
// Note: we delay this initialization to make sure that QQuickWebView has its d-ptr in-place.
-void QQuickWebViewPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
-{
- pageGroup = pageGroupRef;
- if (!pageGroup)
- pageGroup = adoptWK(WKPageGroupCreateWithIdentifier(0));
+void QQuickWebViewPrivate::initialize(WKPageConfigurationRef configurationRef)
+{
+ WKRetainPtr<WKPageConfigurationRef> pageConfiguration;
+ WKContextRef contextRef = nullptr;
+
+ if (configurationRef) {
+ pageConfiguration = adoptWK(configurationRef);
+ contextRef = WKPageConfigurationGetContext(configurationRef);
+ context = QtWebContext::create(contextRef);
+ } else {
+ pageConfiguration = adoptWK(WKPageConfigurationCreate());
+ WKRetainPtr<WKPageGroupRef> pageGroup = adoptWK(WKPageGroupCreateWithIdentifier(0));
+ WKPageConfigurationSetPageGroup(pageConfiguration.get(), pageGroup.get());
+ context = QtWebContext::defaultContext();
+ }
- context = contextRef ? QtWebContext::create(contextRef) : QtWebContext::defaultContext();
- webPageProxy = toImpl(context->context())->createWebPage(pageClient, toImpl(pageGroup.get()));
+ webPageProxy = toImpl(context->context())->createWebPage(pageClient, toImpl(pageConfiguration.get())->copy());
webPage = toAPI(webPageProxy.get());
pageToView()->insert(webPage.get(), this);
- webPageProxy->setUseFixedLayout(s_flickableViewportEnabled);
-#if ENABLE(FULLSCREEN_API)
- webPageProxy->fullScreenManager()->setWebView(q_ptr);
-#endif
-
pageEventHandler.reset(new QtWebPageEventHandler(webPage.get(), pageView.data(), q_ptr));
+ pageClient.initialize(q_ptr, pageEventHandler.data(), &undoController);
+ webPageProxy->initializeWebPage();
+
+ webPageProxy->setUseFixedLayout(s_flickableViewportEnabled);
{
- WKPageFindClient findClient;
- memset(&findClient, 0, sizeof(WKPageFindClient));
- findClient.version = kWKPageFindClientCurrentVersion;
- findClient.clientInfo = this;
+ WKPageFindClientV0 findClient;
+ memset(&findClient, 0, sizeof(WKPageFindClientV0));
+ findClient.base.version = 0;
+ findClient.base.clientInfo = this;
findClient.didFindString = didFindString;
findClient.didFailToFindString = didFailToFindString;
- WKPageSetPageFindClient(webPage.get(), &findClient);
+ WKPageSetPageFindClient(webPage.get(), &findClient.base);
}
{
- WKPageLoaderClient loadClient;
- memset(&loadClient, 0, sizeof(WKPageLoaderClient));
- loadClient.version = kWKPageLoaderClientCurrentVersion;
- loadClient.clientInfo = this;
+ WKPageLoaderClientV0 loadClient;
+ memset(&loadClient, 0, sizeof(WKPageLoaderClientV0));
+ loadClient.base.version = 0;
+ loadClient.base.clientInfo = this;
loadClient.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame;
loadClient.didReceiveServerRedirectForProvisionalLoadForFrame = didReceiveServerRedirectForProvisionalLoadForFrame;
loadClient.didFailProvisionalLoadWithErrorForFrame = didFailLoad;
@@ -371,7 +389,7 @@ void QQuickWebViewPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pa
loadClient.didChangeBackForwardList = didChangeBackForwardList;
loadClient.processDidBecomeUnresponsive = processDidBecomeUnresponsive;
loadClient.processDidBecomeResponsive = processDidBecomeResponsive;
- WKPageSetPageLoaderClient(webPage.get(), &loadClient);
+ WKPageSetPageLoaderClient(webPage.get(), &loadClient.base);
}
pagePolicyClient.reset(new QtWebPagePolicyClient(webPage.get(), q_ptr));
@@ -382,18 +400,17 @@ void QQuickWebViewPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pa
QObject::connect(iconDatabase, SIGNAL(iconChangedForPageURL(QString)), q_ptr, SLOT(_q_onIconChangedForPageURL(QString)));
// Any page setting should preferrable be set before creating the page.
- WKPreferencesRef preferencesRef = WKPageGroupGetPreferences(pageGroup.get());
- WKPreferencesSetAcceleratedCompositingEnabled(preferencesRef, true);
+ auto& preferences = webPageProxy->pageGroup().preferences();
+ preferences.setAcceleratedCompositingEnabled(true);
bool showDebugVisuals = qgetenv("WEBKIT_SHOW_COMPOSITING_DEBUG_VISUALS") == "1";
- WKPreferencesSetCompositingBordersVisible(preferencesRef, showDebugVisuals);
- WKPreferencesSetCompositingRepaintCountersVisible(preferencesRef, showDebugVisuals);
- WKPreferencesSetFrameFlatteningEnabled(preferencesRef, true);
- WKPreferencesSetWebGLEnabled(preferencesRef, true);
- webPageProxy->pageGroup().preferences().setForceCompositingMode(true);
+ preferences.setCompositingBordersVisible(showDebugVisuals);
+ preferences.setCompositingRepaintCountersVisible(showDebugVisuals);
+ preferences.setFrameFlatteningEnabled(true);
+ preferences.setMediaSourceEnabled(false);
+ preferences.setWebGLEnabled(true);
+ preferences.setForceCompositingMode(true);
- pageClient.initialize(q_ptr, pageEventHandler.data(), &undoController);
- webPageProxy->initializeWebPage();
- webPageProxy->registerApplicationScheme(ASCIILiteral("qrc"));
+ webPageProxy->setURLSchemeHandlerForScheme(QrcSchemeHandler::create(), ASCIILiteral("qrc"));
q_ptr->setAcceptedMouseButtons(Qt::MouseButtonMask);
q_ptr->setAcceptHoverEvents(true);
@@ -574,7 +591,7 @@ void QQuickWebViewPrivate::setNeedsDisplay()
// the web process when running tests even if the render loop is not active.
QImage dummyImage(1, 1, QImage::Format_ARGB32);
QPainter painter(&dummyImage);
- q->page()->d->paint(&painter);
+ q->page()->d->paint(&painter, webPageProxy->pageExtendedBackgroundColor(), webPageProxy->drawsBackground());
return;
}
q->page()->update();
@@ -600,7 +617,7 @@ void QQuickWebViewPrivate::processDidCrash()
// Check if loading was ongoing, when process crashed.
if (m_loadProgress > 0 && m_loadProgress < 100) {
- QWebLoadRequest loadRequest(url, QQuickWebView::LoadFailedStatus, QLatin1String("The web process crashed."), QQuickWebView::InternalErrorDomain, 0);
+ QWebLoadRequest loadRequest(url, QQuickWebView::LoadFailedStatus, QStringLiteral("The web process crashed."), QQuickWebView::InternalErrorDomain, 0);
loadProgressDidChange(100);
emit q->loadingChanged(&loadRequest);
@@ -643,7 +660,7 @@ void QQuickWebViewPrivate::processDidBecomeResponsive(WKPageRef, const void* cli
std::unique_ptr<DrawingAreaProxy> QQuickWebViewPrivate::createDrawingAreaProxy()
{
- return std::make_unique<WebKit::DrawingAreaProxyImpl>(*webPageProxy.get());
+ return std::make_unique<WebKit::CoordinatedDrawingAreaProxy>(*webPageProxy.get());
}
void QQuickWebViewPrivate::handleDownloadRequest(DownloadProxy* download)
@@ -874,11 +891,11 @@ void QQuickWebViewPrivate::setNavigatorQtObjectEnabled(bool enabled)
WKPagePostMessageToInjectedBundle(webPage.get(), messageName, wkEnabled.get());
}
-static WKRetainPtr<WKStringRef> readUserFile(const QUrl& url, const char* userFileType)
+static WTF::Optional<String> readUserFile(const QUrl& url, const char* userFileType)
{
if (!url.isValid()) {
qWarning("QQuickWebView: Couldn't open '%s' as %s because URL is invalid.", qPrintable(url.toString()), userFileType);
- return 0;
+ return WTF::Nullopt;
}
QString path;
@@ -888,33 +905,36 @@ static WKRetainPtr<WKStringRef> readUserFile(const QUrl& url, const char* userFi
path = QStringLiteral(":") + url.path();
else {
qWarning("QQuickWebView: Couldn't open '%s' as %s because only file:/// and qrc:/// URLs are supported.", qPrintable(url.toString()), userFileType);
- return 0;
+ return WTF::Nullopt;
}
QFile file(path);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qWarning("QQuickWebView: Couldn't open '%s' as %s due to error '%s'.", qPrintable(url.toString()), userFileType, qPrintable(file.errorString()));
- return 0;
+ return WTF::Nullopt;
}
QByteArray contents = file.readAll();
- if (contents.isEmpty())
+ if (contents.isEmpty()) {
qWarning("QQuickWebView: Ignoring '%s' as %s because file is empty.", qPrintable(url.toString()), userFileType);
+ return WTF::Nullopt;
+ }
- return adoptWK(WKStringCreateWithUTF8CString(contents.constData()));
+ return String::fromUTF8(contents);
}
void QQuickWebViewPrivate::updateUserScripts()
{
// This feature works per-WebView because we keep an unique page group for
// each Page/WebView pair we create.
- WKPageGroupRemoveAllUserScripts(pageGroup.get());
+ webPageProxy->pageGroup().removeAllUserScripts();
- foreach (const QUrl& url, userScripts) {
- WKRetainPtr<WKStringRef> contents = readUserFile(url, "user script");
- if (!contents || WKStringIsEmpty(contents.get()))
+ for (const QUrl& url : userScripts) {
+ auto contents = readUserFile(url, "user script");
+ if (!contents)
continue;
- WKPageGroupAddUserScript(pageGroup.get(), contents.get(), /*baseURL*/ 0, /*whitelistedURLPatterns*/ 0, /*blacklistedURLPatterns*/ 0, kWKInjectInTopFrameOnly, kWKInjectAtDocumentEnd);
+ webPageProxy->pageGroup().addUserScript(contents.value(), /*baseURL*/ String(),
+ /*whitelistedURLPatterns*/ 0, /*blacklistedURLPatterns*/ 0, WebCore::InjectInTopFrameOnly, WebCore::InjectAtDocumentEnd);
}
}
@@ -922,24 +942,25 @@ void QQuickWebViewPrivate::updateUserStyleSheets()
{
// This feature works per-WebView because we keep an unique page group for
// each Page/WebView pair we create.
- WKPageGroupRemoveAllUserStyleSheets(pageGroup.get());
+ webPageProxy->pageGroup().removeAllUserStyleSheets();
- foreach (const QUrl& url, userStyleSheets) {
- WKRetainPtr<WKStringRef> contents = readUserFile(url, "user style sheet");
- if (!contents || WKStringIsEmpty(contents.get()))
+ for (const QUrl& url : userStyleSheets) {
+ auto contents = readUserFile(url, "user style sheet");
+ if (!contents)
continue;
- WKPageGroupAddUserStyleSheet(pageGroup.get(), contents.get(), /*baseURL*/ 0, /*whitelistedURLPatterns*/ 0, /*blacklistedURLPatterns*/ 0, kWKInjectInTopFrameOnly);
+ webPageProxy->pageGroup().addUserStyleSheet(contents.value(), /*baseURL*/ String(),
+ /*whitelistedURLPatterns*/ 0, /*blacklistedURLPatterns*/ 0, WebCore::InjectInTopFrameOnly, WebCore::UserStyleUserLevel);
}
}
void QQuickWebViewPrivate::updateSchemeDelegates()
{
- webPageProxy->registerApplicationScheme(ASCIILiteral("qrc"));
+ webPageProxy->setURLSchemeHandlerForScheme(QrcSchemeHandler::create(), ASCIILiteral("qrc"));
QQmlListProperty<QQuickUrlSchemeDelegate> schemes = experimental->schemeDelegates();
for (int i = 0, numSchemes = experimental->schemeDelegates_Count(&schemes); i < numSchemes; ++i) {
QQuickUrlSchemeDelegate* scheme = experimental->schemeDelegates_At(&schemes, i);
- webPageProxy->registerApplicationScheme(scheme->scheme());
+ //webPageProxy->registerApplicationScheme(scheme->scheme());
}
}
@@ -978,20 +999,25 @@ void QQuickWebViewPrivate::didReceiveMessageFromNavigatorQtObject(WKStringRef me
emit q_ptr->experimental()->messageReceived(variantMap);
}
-#ifdef HAVE_WEBCHANNEL
-void QQuickWebViewPrivate::didReceiveMessageFromNavigatorQtWebChannelTransportObject(WKStringRef message)
+#if ENABLE(QT_WEBCHANNEL)
+void QQuickWebViewPrivate::didReceiveMessageFromNavigatorQtWebChannelTransportObject(WKDataRef data)
{
- // TODO: can I convert a WKStringRef to a UTF8 QByteArray directly?
- q_ptr->experimental()->m_webChannelTransport->receiveMessage(WKStringCopyQString(message).toUtf8());
+ const char* bytes = reinterpret_cast<const char*>(WKDataGetBytes(data));
+ int size = WKDataGetSize(data);
+ q_ptr->experimental()->m_webChannelTransport->receiveMessage(bytes, size);
}
#endif
CoordinatedGraphicsScene* QQuickWebViewPrivate::coordinatedGraphicsScene()
{
- if (webPageProxy && webPageProxy->drawingArea() && webPageProxy->drawingArea()->coordinatedLayerTreeHostProxy())
- return webPageProxy->drawingArea()->coordinatedLayerTreeHostProxy()->coordinatedGraphicsScene();
+ // QTFIXME: redundant null check?
+// if (!webPageProxy)
+// return nullptr;
- return 0;
+ if (CoordinatedDrawingAreaProxy* drawingArea = static_cast<CoordinatedDrawingAreaProxy*>(webPageProxy->drawingArea()))
+ return drawingArea->coordinatedLayerTreeHostProxy().coordinatedGraphicsScene();
+
+ return nullptr;
}
float QQuickWebViewPrivate::deviceScaleFactor()
@@ -1009,9 +1035,9 @@ QQuickWebViewLegacyPrivate::QQuickWebViewLegacyPrivate(QQuickWebView* viewport)
{
}
-void QQuickWebViewLegacyPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
+void QQuickWebViewLegacyPrivate::initialize(WKPageConfigurationRef configurationRef)
{
- QQuickWebViewPrivate::initialize(contextRef, pageGroupRef);
+ QQuickWebViewPrivate::initialize(configurationRef);
// Trigger setting of correct visibility flags after everything was allocated and initialized.
_q_onVisibleChanged();
@@ -1026,7 +1052,7 @@ void QQuickWebViewLegacyPrivate::updateViewportSize()
pageView->setContentsSize(viewportSize);
- if (DrawingAreaProxy *drawingArea = webPageProxy->drawingArea()) {
+ if (CoordinatedDrawingAreaProxy* drawingArea = static_cast<CoordinatedDrawingAreaProxy*>(webPageProxy->drawingArea())) {
// The fixed layout is handled by the FrameView and the drawing area doesn't behave differently
// whether its fixed or not. We still need to tell the drawing area which part of it
// has to be rendered on tiles, and in desktop mode it's all of it.
@@ -1052,9 +1078,9 @@ QQuickWebViewFlickablePrivate::QQuickWebViewFlickablePrivate(QQuickWebView* view
{
}
-void QQuickWebViewFlickablePrivate::initialize(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
+void QQuickWebViewFlickablePrivate::initialize(WKPageConfigurationRef configurationRef)
{
- QQuickWebViewPrivate::initialize(contextRef, pageGroupRef);
+ QQuickWebViewPrivate::initialize(configurationRef);
}
void QQuickWebViewFlickablePrivate::onComponentComplete()
@@ -1064,6 +1090,7 @@ void QQuickWebViewFlickablePrivate::onComponentComplete()
Q_Q(QQuickWebView);
m_pageViewportControllerClient.reset(new PageViewportControllerClientQt(q, pageView.data()));
m_pageViewportController.reset(new PageViewportController(webPageProxy.get(), *m_pageViewportControllerClient.data()));
+ m_pageViewportControllerClient->setController(m_pageViewportController.data());
pageEventHandler->setViewportController(m_pageViewportControllerClient.data());
// Trigger setting of correct visibility flags after everything was allocated and initialized.
@@ -1101,12 +1128,12 @@ QQuickWebViewExperimental::QQuickWebViewExperimental(QQuickWebView *webView, QQu
, d_ptr(webViewPrivate)
, schemeParent(new QObject(this))
, m_test(new QWebKitTest(webViewPrivate, this))
-#ifdef HAVE_WEBCHANNEL
+#if ENABLE(QT_WEBCHANNEL)
, m_webChannel(new QQmlWebChannel(this))
, m_webChannelTransport(new QWebChannelWebKitTransport(this))
#endif
{
-#ifdef HAVE_WEBCHANNEL
+#if ENABLE(QT_WEBCHANNEL)
m_webChannel->connectTo(m_webChannelTransport);
#endif
}
@@ -1197,7 +1224,7 @@ bool QQuickWebViewExperimental::flickableViewportEnabled()
return s_flickableViewportEnabled;
}
-#ifdef HAVE_WEBCHANNEL
+#if ENABLE(QT_WEBCHANNEL)
QQmlWebChannel* QQuickWebViewExperimental::webChannel() const
{
return m_webChannel;
@@ -1239,12 +1266,13 @@ void QQuickWebViewExperimental::postMessage(const QString& message)
WKPagePostMessageToInjectedBundle(d->webPage.get(), messageName, contents.get());
}
-#ifdef HAVE_WEBCHANNEL
+#if ENABLE(QT_WEBCHANNEL)
void QQuickWebViewExperimental::postQtWebChannelTransportMessage(const QByteArray& message)
{
Q_D(QQuickWebView);
static WKStringRef messageName = WKStringCreateWithUTF8CString("MessageToNavigatorQtWebChannelTransportObject");
- WKRetainPtr<WKStringRef> contents = adoptWK(WKStringCreateWithUTF8CString(message.constData()));
+ // TODO: API::Data::createWithoutCopying may help to avoid copy
+ WKRetainPtr<WKDataRef> contents = adoptWK(WKDataCreate(reinterpret_cast<const unsigned char*>(message.data()), message.size()));
WKPagePostMessageToInjectedBundle(d->webPage.get(), messageName, contents.get());
}
#endif
@@ -1585,7 +1613,7 @@ void QQuickWebViewExperimental::schemeDelegates_Append(QQmlListProperty<QQuickUr
return;
scheme->reply()->setWebViewExperimental(webViewExperimental);
QQuickWebViewPrivate* d = webViewExperimental->d_func();
- d->webPageProxy->registerApplicationScheme(scheme->scheme());
+ //d->webPageProxy->registerApplicationScheme(scheme->scheme());
}
int QQuickWebViewExperimental::schemeDelegates_Count(QQmlListProperty<QQuickUrlSchemeDelegate>* property)
@@ -1640,7 +1668,7 @@ void QQuickWebViewExperimental::invokeApplicationSchemeHandler(PassRefPtr<QtRefC
void QQuickWebViewExperimental::sendApplicationSchemeReply(QQuickNetworkReply* reply)
{
- d_ptr->webPageProxy->sendApplicationSchemeReply(reply);
+ //d_ptr->webPageProxy->sendApplicationSchemeReply(reply);
}
void QQuickWebViewExperimental::goForwardTo(int index)
@@ -1749,12 +1777,12 @@ QQuickWebView::QQuickWebView(QQuickItem* parent)
d->initialize();
}
-QQuickWebView::QQuickWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef, QQuickItem* parent)
- : QQuickFlickable(parent)
+QQuickWebView::QQuickWebView(WKPageConfigurationRef configurationRef)
+ : QQuickFlickable()
, d_ptr(createPrivateObject(this))
{
Q_D(QQuickWebView);
- d->initialize(contextRef, pageGroupRef);
+ d->initialize(configurationRef);
}
QQuickWebView::~QQuickWebView()
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h
index c06f8f219..541544463 100644
--- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h
@@ -65,8 +65,7 @@ namespace WTF {
template<class T> class PassRefPtr;
}
-typedef const struct OpaqueWKContext* WKContextRef;
-typedef const struct OpaqueWKPageGroup* WKPageGroupRef;
+typedef const struct OpaqueWKPageConfiguration* WKPageConfigurationRef;
typedef const struct OpaqueWKPage* WKPageRef;
QT_BEGIN_NAMESPACE
@@ -210,7 +209,7 @@ private:
QPointF contentPos() const;
void setContentPos(const QPointF&);
- QQuickWebView(WKContextRef, WKPageGroupRef, QQuickItem* parent = 0);
+ QQuickWebView(WKPageConfigurationRef);
WKPageRef pageRef() const;
void emitUrlChangeIfNeeded();
@@ -283,7 +282,7 @@ class QWEBKIT_EXPORT QQuickWebViewExperimental : public QObject {
Q_PROPERTY(QList<QUrl> userScripts READ userScripts WRITE setUserScripts NOTIFY userScriptsChanged)
Q_PROPERTY(QList<QUrl> userStyleSheets READ userStyleSheets WRITE setUserStyleSheets NOTIFY userStyleSheetsChanged)
Q_PROPERTY(QUrl remoteInspectorUrl READ remoteInspectorUrl NOTIFY remoteInspectorUrlChanged FINAL)
-#ifdef HAVE_WEBCHANNEL
+#ifdef QT_WEBCHANNEL_LIB
Q_PROPERTY(QQmlWebChannel* webChannel READ webChannel WRITE setWebChannel NOTIFY webChannelChanged)
#endif
Q_ENUMS(NavigationRequestActionExperimental)
@@ -365,7 +364,7 @@ public:
static void setFlickableViewportEnabled(bool enable);
static bool flickableViewportEnabled();
-#ifdef HAVE_WEBCHANNEL
+#ifdef QT_WEBCHANNEL_LIB
QQmlWebChannel* webChannel() const;
void setWebChannel(QQmlWebChannel* channel);
void postQtWebChannelTransportMessage(const QByteArray& message);
@@ -409,9 +408,7 @@ Q_SIGNALS:
void processDidBecomeUnresponsive();
void processDidBecomeResponsive();
-#ifdef HAVE_WEBCHANNEL
void webChannelChanged(QQmlWebChannel* channel);
-#endif
private:
QQuickWebViewExperimental(QQuickWebView* webView, QQuickWebViewPrivate* webViewPrivate);
@@ -420,7 +417,7 @@ private:
QObject* schemeParent;
QWebKitTest* m_test;
-#ifdef HAVE_WEBCHANNEL
+#ifdef QT_WEBCHANNEL_LIB
QQmlWebChannel* m_webChannel;
QWebChannelWebKitTransport* m_webChannelTransport;
#endif
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
index d041a8eb1..fe40823ea 100644
--- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
@@ -71,7 +71,7 @@ public:
virtual ~QQuickWebViewPrivate();
- virtual void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0);
+ virtual void initialize(WKPageConfigurationRef configurationRef = 0);
virtual void onComponentComplete() { }
@@ -135,8 +135,8 @@ public:
void handleDownloadRequest(WebKit::DownloadProxy*);
void didReceiveMessageFromNavigatorQtObject(WKStringRef message);
-#ifdef HAVE_WEBCHANNEL
- void didReceiveMessageFromNavigatorQtWebChannelTransportObject(WKStringRef message);
+#if ENABLE(QT_WEBCHANNEL)
+ void didReceiveMessageFromNavigatorQtWebChannelTransportObject(WKDataRef);
#endif
WebKit::CoordinatedGraphicsScene* coordinatedGraphicsScene();
@@ -181,7 +181,6 @@ protected:
QQuickWebViewPrivate(QQuickWebView* viewport);
RefPtr<WebKit::WebPageProxy> webPageProxy;
WKRetainPtr<WKPageRef> webPage;
- WKRetainPtr<WKPageGroupRef> pageGroup;
WebKit::QtPageClient pageClient;
WebKit::DefaultUndoController undoController;
@@ -227,7 +226,7 @@ class QQuickWebViewLegacyPrivate : public QQuickWebViewPrivate {
Q_DECLARE_PUBLIC(QQuickWebView)
public:
QQuickWebViewLegacyPrivate(QQuickWebView* viewport);
- void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0) Q_DECL_OVERRIDE;
+ void initialize(WKPageConfigurationRef configurationRef = 0) Q_DECL_OVERRIDE;
void updateViewportSize() Q_DECL_OVERRIDE;
@@ -239,7 +238,7 @@ class QQuickWebViewFlickablePrivate : public QQuickWebViewPrivate {
Q_DECLARE_PUBLIC(QQuickWebView)
public:
QQuickWebViewFlickablePrivate(QQuickWebView* viewport);
- void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0) Q_DECL_OVERRIDE;
+ void initialize(WKPageConfigurationRef configurationRef = 0) Q_DECL_OVERRIDE;
void onComponentComplete() Q_DECL_OVERRIDE;
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebchannelwebkittransport.cpp b/Source/WebKit2/UIProcess/API/qt/qwebchannelwebkittransport.cpp
index b74c45b3c..c6f96f094 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwebchannelwebkittransport.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qwebchannelwebkittransport.cpp
@@ -42,7 +42,7 @@
#include "config.h"
#include "qwebchannelwebkittransport_p.h"
-#ifdef HAVE_WEBCHANNEL
+#if ENABLE(QT_WEBCHANNEL)
#include "qquickwebview_p.h"
@@ -57,23 +57,16 @@ QWebChannelWebKitTransport::QWebChannelWebKitTransport(QQuickWebViewExperimental
void QWebChannelWebKitTransport::sendMessage(const QJsonObject& message)
{
- const QByteArray data = QJsonDocument(message).toJson(QJsonDocument::Compact);
+ QByteArray data = QJsonDocument(message).toBinaryData();
m_experimental->postQtWebChannelTransportMessage(data);
}
-void QWebChannelWebKitTransport::receiveMessage(const QByteArray& message)
+void QWebChannelWebKitTransport::receiveMessage(const char* message, int size)
{
- QJsonParseError error;
- const QJsonDocument doc = QJsonDocument::fromJson(message, &error);
- if (error.error != QJsonParseError::NoError) {
- qWarning() << "Failed to parse the client WebKit QWebChannel message as JSON: " << message
- << "Error message is:" << error.errorString();
- return;
- } else if (!doc.isObject()) {
- qWarning() << "Received WebKit QWebChannel message is not a JSON object: " << message;
- return;
- }
+ QJsonDocument doc = QJsonDocument::fromRawData(message, size, QJsonDocument::BypassValidation);
emit messageReceived(doc.object(), this);
}
-#endif // HAVE_WEBCHANNEL
+#include "moc_qwebchannelwebkittransport_p.cpp"
+
+#endif // ENABLE(QT_WEBCHANNEL)
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebchannelwebkittransport_p.h b/Source/WebKit2/UIProcess/API/qt/qwebchannelwebkittransport_p.h
index 9e17d6fa4..8d8cf643d 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwebchannelwebkittransport_p.h
+++ b/Source/WebKit2/UIProcess/API/qt/qwebchannelwebkittransport_p.h
@@ -41,8 +41,6 @@
#pragma once
-#ifdef HAVE_WEBCHANNEL
-
#include <QtWebChannel/QWebChannelAbstractTransport>
class QQuickWebViewExperimental;
@@ -54,10 +52,8 @@ public:
void sendMessage(const QJsonObject& message) override;
- void receiveMessage(const QByteArray& message);
+ void receiveMessage(const char* message, int size);
private:
QQuickWebViewExperimental* m_experimental;
};
-
-#endif // HAVE_WEBCHANNEL
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebkittest.cpp b/Source/WebKit2/UIProcess/API/qt/qwebkittest.cpp
index 20cfa388d..2909124da 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwebkittest.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qwebkittest.cpp
@@ -140,8 +140,8 @@ QSize QWebKitTest::contentsSize() const
static inline QJsonObject toJsonObject(const QSizeF& sizeF)
{
QJsonObject result;
- result.insert(QLatin1String("width"), sizeF.width());
- result.insert(QLatin1String("height"), sizeF.height());
+ result.insert(QStringLiteral("width"), sizeF.width());
+ result.insert(QStringLiteral("height"), sizeF.height());
return result;
}
@@ -149,16 +149,16 @@ QJsonObject QWebKitTest::viewport() const
{
QJsonObject viewportData;
if (const PageViewportController* const viewportHandler = m_webViewPrivate->viewportController()) {
- viewportData.insert(QLatin1String("layoutSize"), toJsonObject(viewportHandler->contentsLayoutSize()));
- viewportData.insert(QLatin1String("isScalable"), viewportHandler->allowsUserScaling());
- viewportData.insert(QLatin1String("minimumScale"), viewportHandler->minimumScale());
- viewportData.insert(QLatin1String("maximumScale"), viewportHandler->maximumScale());
+ viewportData.insert(QStringLiteral("layoutSize"), toJsonObject(viewportHandler->contentsLayoutSize()));
+ viewportData.insert(QStringLiteral("isScalable"), viewportHandler->allowsUserScaling());
+ viewportData.insert(QStringLiteral("minimumScale"), viewportHandler->minimumScale());
+ viewportData.insert(QStringLiteral("maximumScale"), viewportHandler->maximumScale());
} else {
- viewportData.insert(QLatin1String("initialScale"), 1.0);
- viewportData.insert(QLatin1String("layoutSize"), toJsonObject(QSizeF()));
- viewportData.insert(QLatin1String("isScalable"), false);
- viewportData.insert(QLatin1String("minimumScale"), 1.0);
- viewportData.insert(QLatin1String("maximumScale"), 1.0);
+ viewportData.insert(QStringLiteral("initialScale"), 1.0);
+ viewportData.insert(QStringLiteral("layoutSize"), toJsonObject(QSizeF()));
+ viewportData.insert(QStringLiteral("isScalable"), false);
+ viewportData.insert(QStringLiteral("minimumScale"), 1.0);
+ viewportData.insert(QStringLiteral("maximumScale"), 1.0);
}
return viewportData;
}
@@ -176,3 +176,5 @@ QVariant QWebKitTest::contentsScale() const
return viewport->currentScale();
return 1.0;
}
+
+#include "moc_qwebkittest_p.cpp"
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebloadrequest.cpp b/Source/WebKit2/UIProcess/API/qt/qwebloadrequest.cpp
index 6271ebfa6..453abc03e 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwebloadrequest.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qwebloadrequest.cpp
@@ -108,3 +108,5 @@ int QWebLoadRequest::errorCode() const
{
return d->errorCode;
}
+
+#include "moc_qwebloadrequest_p.cpp"
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp b/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp
index b486e9391..cead3f7c2 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp
@@ -20,8 +20,10 @@
#include "config.h"
#include "qwebpreferences_p.h"
+#include "WebPageGroup.h"
#include "qquickwebview_p_p.h"
#include "qwebpreferences_p_p.h"
+#include <WKPageConfigurationRef.h>
#include <WKPageGroup.h>
#include <WKPreferencesRef.h>
#include <WKRetainPtr.h>
@@ -37,7 +39,7 @@ QWebPreferences* QWebPreferencesPrivate::createPreferences(QQuickWebViewPrivate*
bool QWebPreferencesPrivate::testAttribute(QWebPreferencesPrivate::WebAttribute attr) const
{
- WKPreferencesRef preferencesRef = WKPageGroupGetPreferences(webViewPrivate->pageGroup.get());
+ WKPreferencesRef preferencesRef = toAPI(&webViewPrivate->webPageProxy->pageGroup().preferences());
switch (attr) {
case AutoLoadImages:
return WKPreferencesGetLoadsImagesAutomatically(preferencesRef);
@@ -95,7 +97,7 @@ bool QWebPreferencesPrivate::testAttribute(QWebPreferencesPrivate::WebAttribute
void QWebPreferencesPrivate::setAttribute(QWebPreferencesPrivate::WebAttribute attr, bool enable)
{
- WKPreferencesRef preferencesRef = WKPageGroupGetPreferences(webViewPrivate->pageGroup.get());
+ WKPreferencesRef preferencesRef = toAPI(&webViewPrivate->webPageProxy->pageGroup().preferences());
switch (attr) {
case AutoLoadImages:
WKPreferencesSetLoadsImagesAutomatically(preferencesRef, enable);
@@ -196,7 +198,7 @@ void QWebPreferencesPrivate::initializeDefaultFontSettings()
void QWebPreferencesPrivate::setFontFamily(QWebPreferencesPrivate::FontFamily which, const QString& family)
{
- WKPreferencesRef preferencesRef = WKPageGroupGetPreferences(webViewPrivate->pageGroup.get());
+ WKPreferencesRef preferencesRef = toAPI(&webViewPrivate->webPageProxy->pageGroup().preferences());
WKRetainPtr<WKStringRef> familyRef = adoptWK(WKStringCreateWithQString(family));
switch (which) {
case StandardFont:
@@ -224,7 +226,7 @@ void QWebPreferencesPrivate::setFontFamily(QWebPreferencesPrivate::FontFamily wh
QString QWebPreferencesPrivate::fontFamily(QWebPreferencesPrivate::FontFamily which) const
{
- WKPreferencesRef preferencesRef = WKPageGroupGetPreferences(webViewPrivate->pageGroup.get());
+ WKPreferencesRef preferencesRef = toAPI(&webViewPrivate->webPageProxy->pageGroup().preferences());
switch (which) {
case StandardFont:
return adoptToQString(WKPreferencesCopyStandardFontFamily(preferencesRef));
@@ -244,8 +246,8 @@ QString QWebPreferencesPrivate::fontFamily(QWebPreferencesPrivate::FontFamily wh
}
void QWebPreferencesPrivate::setFontSize(QWebPreferencesPrivate::FontSizeType type, unsigned size)
-{
- WKPreferencesRef preferencesRef = WKPageGroupGetPreferences(webViewPrivate->pageGroup.get());
+{
+ WKPreferencesRef preferencesRef = toAPI(&webViewPrivate->webPageProxy->pageGroup().preferences());
switch (type) {
case MinimumFontSize:
WKPreferencesSetMinimumFontSize(preferencesRef, static_cast<uint32_t>(size));
@@ -263,7 +265,7 @@ void QWebPreferencesPrivate::setFontSize(QWebPreferencesPrivate::FontSizeType ty
unsigned QWebPreferencesPrivate::fontSize(QWebPreferencesPrivate::FontSizeType type) const
{
- WKPreferencesRef preferencesRef = WKPageGroupGetPreferences(webViewPrivate->pageGroup.get());
+ WKPreferencesRef preferencesRef = toAPI(&webViewPrivate->webPageProxy->pageGroup().preferences());
switch (type) {
case MinimumFontSize:
return static_cast<unsigned>(WKPreferencesGetMinimumFontSize(preferencesRef));
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/CMakeLists.txt b/Source/WebKit2/UIProcess/API/qt/tests/CMakeLists.txt
new file mode 100644
index 000000000..b26366492
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/CMakeLists.txt
@@ -0,0 +1,93 @@
+include_directories(
+ "${CMAKE_SOURCE_DIR}/Source"
+ "${FORWARDING_HEADERS_DIR}/QtWebKit"
+ "${WEBKIT_DIR}/qt/Api"
+)
+
+include_directories(SYSTEM
+ ${Qt5Quick_INCLUDE_DIRS}
+ ${Qt5Quick_PRIVATE_INCLUDE_DIRS}
+ ${Qt5QuickTest_INCLUDE_DIRS}
+)
+
+set(tst_qmltests_DEFINITIONS
+ IMPORT_DIR="${CMAKE_BINARY_DIR}/imports"
+ QWP_PATH="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
+ TESTS_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
+)
+
+set(tst_qmltests_DesktopBehavior_DEFINITIONS
+ ${tst_qmltests_DEFINITIONS}
+
+ QUICK_TEST_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/qmltests/DesktopBehavior"
+ DISABLE_FLICKABLE_VIEWPORT=1
+)
+
+set(tst_qmltests_WebView_DEFINITIONS
+ ${tst_qmltests_DEFINITIONS}
+
+ QUICK_TEST_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/qmltests/WebView"
+)
+
+set(qmltests_QML_SOURCES
+ qmltests/DesktopBehavior/tst_linkHovered.qml
+ qmltests/DesktopBehavior/tst_loadHtml.qml
+ qmltests/DesktopBehavior/tst_navigationRequested.qml
+
+ qmltests/WebView/tst_applicationScheme.qml
+ qmltests/WebView/tst_colorChooser.qml
+ qmltests/WebView/tst_doubleTapToZoom.qml
+ qmltests/WebView/tst_download.qml
+ qmltests/WebView/tst_evaluateJavaScript.qml
+ qmltests/WebView/tst_favIconLoad.qml
+ qmltests/WebView/tst_findText.qml
+ qmltests/WebView/tst_fitToView.qml
+ qmltests/WebView/tst_geopermission.qml
+ qmltests/WebView/tst_itemSelector.qml
+ qmltests/WebView/tst_javaScriptDialogs.qml
+ qmltests/WebView/tst_loadFail.qml
+ qmltests/WebView/tst_loadHtml.qml
+ qmltests/WebView/tst_loadProgress.qml
+ qmltests/WebView/tst_loadProgressSignal.qml
+ qmltests/WebView/tst_loadUrl.qml
+ qmltests/WebView/tst_messaging.qml
+ qmltests/WebView/tst_multiFileUpload.qml
+ qmltests/WebView/tst_navigationHistory.qml
+ qmltests/WebView/tst_notification.qml
+ qmltests/WebView/tst_origin.qml
+ qmltests/WebView/tst_preferences.qml
+ qmltests/WebView/tst_properties.qml
+ qmltests/WebView/tst_resize.qml
+ qmltests/WebView/tst_singleFileUpload.qml
+ qmltests/WebView/tst_titleChanged.qml
+ qmltests/WebView/tst_userScripts.qml
+ qmltests/WebView/tst_webchannel.qml
+ qmltests/WebView/tst_wheelEventHandling.qml
+
+ qmltests/common/TestWebView.qml
+)
+
+set(qmltests_SOURCES
+ bytearraytestdata.cpp
+ util.cpp
+
+ qmltests/tst_qmltests.cpp
+ ${qmltests_QML_SOURCES}
+)
+
+qt5_add_resources(qmltests_SOURCES qmltests/resources.qrc)
+
+set(qmltests_LIBRARIES
+ WebKit
+ ${Qt5Quick_LIBRARIES}
+ ${Qt5QuickTest_LIBRARIES}
+ ${Qt5Test_LIBRARIES}
+)
+
+add_executable(tst_qmltests_WebView ${qmltests_SOURCES})
+target_compile_definitions(tst_qmltests_WebView PRIVATE ${tst_qmltests_WebView_DEFINITIONS})
+target_link_libraries(tst_qmltests_WebView ${qmltests_LIBRARIES})
+
+add_executable(tst_qmltests_DesktopBehavior ${qmltests_SOURCES})
+target_compile_definitions(tst_qmltests_DesktopBehavior PRIVATE ${tst_qmltests_DesktopBehavior_DEFINITIONS})
+target_link_libraries(tst_qmltests_DesktopBehavior ${qmltests_LIBRARIES})
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml
index e561e1a32..d25dcb9a8 100644
--- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml
@@ -70,6 +70,7 @@ TestWebView {
name: "WebViewApplicationSchemes"
function test_applicationScheme() {
+ skip("QTFIXME: application schemes are not supported yet")
var testUrl = "applicationScheme://something"
webView.url = testUrl
verify(webView.waitForLoadSucceeded())
@@ -77,6 +78,7 @@ TestWebView {
}
function test_multipleSchemes() {
+ skip("QTFIXME: application schemes are not supported yet")
// Test if we receive the right reply when defining multiple schemes.
var testUrl = "scheme2://some-url-string"
webView.url = testUrl
@@ -90,6 +92,7 @@ TestWebView {
}
function test_multipleUrlsForScheme() {
+ skip("QTFIXME: application schemes are not supported yet")
var testUrl = "scheme3://url1"
webView.url = testUrl
verify(webView.waitForLoadSucceeded())
@@ -103,6 +106,7 @@ TestWebView {
}
function test_charsets() {
+ skip("QTFIXME: application schemes are not supported yet")
var testUrl = "schemeCharset://latin1"
webView.url = testUrl
verify(webView.waitForLoadSucceeded())
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_evaluateJavaScript.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_evaluateJavaScript.qml
index 720b4cd04..b4576af36 100644
--- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_evaluateJavaScript.qml
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_evaluateJavaScript.qml
@@ -78,7 +78,43 @@ Item {
resultSpy.wait()
compare(JSON.stringify(webView.lastResult),
- '{"child":{"level":2},"level":"1"}')
+ '{"level":"1","child":{"level":2}}')
+ }
+
+ function test_undefinedValue() {
+ resultSpy.clear()
+ webView.url = "about:blank"
+ verify(webView.waitForLoadSucceeded())
+
+ webView.experimental.evaluateJavaScript(
+ "(function() { })()",
+
+ function(result) {
+ webView.lastResult = result
+ })
+
+ resultSpy.wait()
+ verify(typeof webView.lastResult === "undefined")
+ compare(webView.lastResult, undefined)
+ }
+
+ function test_nullValue() {
+ resultSpy.clear()
+
+ webView.url = "about:blank"
+ verify(webView.waitForLoadSucceeded())
+
+ webView.experimental.evaluateJavaScript(
+ "(function() { return { value: null } })()",
+
+ function(result) {
+ webView.lastResult = result
+ })
+
+ resultSpy.wait()
+ verify(typeof webView.lastResult === "object")
+ verify(typeof webView.lastResult.value === "object")
+ compare(webView.lastResult.value, null)
}
function test_booleanValue() {
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_webchannel.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_webchannel.qml
index e16b7866e..dfdcf7add 100644
--- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_webchannel.qml
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_webchannel.qml
@@ -72,7 +72,7 @@ Item {
TestWebView {
id: webView
- experimental.windowObjects: [testObject]
+ experimental.webChannel.registeredObjects: [testObject]
experimental.preferences.developerExtrasEnabled: true
}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/notification.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/notification.html
index b53533eb0..e9186a4fd 100644
--- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/notification.html
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/notification.html
@@ -3,9 +3,9 @@
<title>Desktop Notification Permission test</title>
<script>
requestPermission = function(cb) {
- window.webkitNotifications.requestPermission(function() {
+ window.Notification.requestPermission(function() {
if (cb)
- cb(window.webkitNotifications.checkPermission() == 0);
+ cb(window.Notification.permission);
});
}
requestPermission()
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp
index ab57556bd..e681daa0d 100644
--- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp
@@ -21,7 +21,6 @@
#include "../util.h"
#include "private/qquickwebview_p.h"
-#include <QGuiApplication>
#include <QVarLengthArray>
#include <QtQuickTest/quicktest.h>
@@ -40,9 +39,6 @@ int main(int argc, char** argv)
suppressDebugOutput();
addQtWebProcessToPath();
- // Instantiate QApplication to prevent quick_test_main to instantiate a QGuiApplication.
- // This can be removed as soon as we do not use QtWidgets any more.
- QGuiApplication app(argc, argv);
qmlRegisterType<ByteArrayTestData>("Test", 1, 0, "ByteArrayTestData");
#ifdef DISABLE_FLICKABLE_VIEWPORT