Source

Target

Showing with 126 additions and 21 deletions
......@@ -142,7 +142,11 @@ WebEngineContext::WebEngineContext()
#if defined(OS_WIN)
parsedCommandLine->AppendSwitch(switches::kDisableD3D11);
// ANGLE doesn't support multi-threading, doing texture upload from the GPU thread
// hasn't been causing problems yet but doing rendering there is conflicting with
// Qt's rendering of the scene graph.
parsedCommandLine->AppendSwitch(switches::kDisableExperimentalWebGL);
parsedCommandLine->AppendSwitch(switches::kDisableAccelerated2dCanvas);
#endif
#if defined(QTWEBENGINE_MOBILE_SWITCHES)
......
......@@ -92,6 +92,39 @@ QString location(QLibraryInfo::LibraryLocation path)
return QLibraryInfo::location(path);
}
#if defined(OS_MACOSX)
static inline CFBundleRef frameworkBundle()
{
return CFBundleGetBundleWithIdentifier(CFSTR("org.qt-project.Qt.QtWebEngineCore"));
}
static QString getPath(CFBundleRef frameworkBundle)
{
QString path;
if (frameworkBundle) {
CFURLRef bundleUrl = CFBundleCopyBundleURL(frameworkBundle);
CFStringRef bundlePath = CFURLCopyFileSystemPath(bundleUrl, kCFURLPOSIXPathStyle);
path = QString::fromCFString(bundlePath);
CFRelease(bundlePath);
CFRelease(bundleUrl);
}
return path;
}
static QString getResourcesPath(CFBundleRef frameworkBundle)
{
QString path;
if (frameworkBundle) {
CFURLRef resourcesRelativeUrl = CFBundleCopyResourcesDirectoryURL(frameworkBundle);
CFStringRef resourcesRelativePath = CFURLCopyFileSystemPath(resourcesRelativeUrl, kCFURLPOSIXPathStyle);
path = getPath(frameworkBundle) % QLatin1Char('/') % QString::fromCFString(resourcesRelativePath);
CFRelease(resourcesRelativePath);
CFRelease(resourcesRelativeUrl);
}
return path;
}
#endif
QString subProcessPath()
{
static bool initialized = false;
......@@ -100,14 +133,19 @@ QString subProcessPath()
#else
static QString processBinary (QLatin1String(QTWEBENGINEPROCESS_NAME));
#endif
#if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD)
static QString processPath (getPath(frameworkBundle())
% QStringLiteral("/Helpers/" QTWEBENGINEPROCESS_NAME ".app/Contents/MacOS/" QTWEBENGINEPROCESS_NAME));
#else
static QString processPath (location(QLibraryInfo::LibraryExecutablesPath)
% QDir::separator() % processBinary);
#endif
if (!initialized) {
// Allow overriding at runtime for the time being.
const QByteArray fromEnv = qgetenv("QTWEBENGINEPROCESS_PATH");
if (!fromEnv.isEmpty())
processPath = QString::fromLatin1(fromEnv);
if (processPath.isEmpty() || !QFileInfo(processPath).exists()) {
if (!QFileInfo(processPath).exists()) {
qWarning("QtWebEngineProcess not found at location %s. Trying fallback path...", qPrintable(processPath));
processPath = QCoreApplication::applicationDirPath() % QDir::separator() % processBinary;
}
......@@ -121,12 +159,20 @@ QString subProcessPath()
QString pluginsPath()
{
#if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD)
return getPath(frameworkBundle()) % QLatin1String("/Libraries");
#else
return location(QLibraryInfo::PluginsPath) % QDir::separator() % QLatin1String("qtwebengine");
#endif
}
QString localesPath()
{
#if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD)
return getResourcesPath(frameworkBundle()) % QLatin1String("/qtwebengine_locales");
#else
return location(QLibraryInfo::TranslationsPath) % QLatin1String("/qtwebengine_locales");
#endif
}
QString fallbackDir() {
......@@ -155,7 +201,11 @@ base::FilePath WebEngineLibraryInfo::getPath(int key)
QString directory;
switch (key) {
case QT_RESOURCES_PAK:
#if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD)
return toFilePath(getResourcesPath(frameworkBundle()) % QLatin1String("/qtwebengine_resources.pak"));
#else
return toFilePath(location(QLibraryInfo::DataPath) % QLatin1String("/qtwebengine_resources.pak"));
#endif
case base::FILE_EXE:
case content::CHILD_PROCESS_EXE:
return toFilePath(subProcessPath());
......@@ -171,7 +221,11 @@ base::FilePath WebEngineLibraryInfo::getPath(int key)
directory = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
break;
case base::DIR_QT_LIBRARY_DATA:
#if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD)
return toFilePath(getResourcesPath(frameworkBundle()));
#else
return toFilePath(location(QLibraryInfo::DataPath));
#endif
#if defined(OS_ANDROID)
case base::DIR_SOURCE_ROOT:
case base::DIR_ANDROID_EXTERNAL_STORAGE:
......
TARGET = $$QTWEBENGINEPROCESS_NAME
TEMPLATE = app
QT_PRIVATE += webenginecore
load(qt_build_paths)
contains(QT_CONFIG, qt_framework) {
# Deploy the QtWebEngineProcess app bundle into the QtWebEngineCore framework.
DESTDIR = $$MODULE_BASE_OUTDIR/lib/QtWebEngineCore.framework/Versions/5/Helpers
CONFIG -= app_bundle
# FIXME: We can remove those steps in Qt 5.5 once @rpath works
# "QT += webenginecore" would pull all dependencies that we'd also need to update
# with install_name_tool on OSX, but we only need access to the private
# QtWebEngine::processMain. qtAddModule will take care of finding where
# the library is without pulling additional librarie.
QT = core
qtAddModule(webenginecore, LIBS)
CONFIG -= link_prl
QMAKE_POST_LINK = \
"xcrun install_name_tool -change " \
"`xcrun otool -X -L $(TARGET) | grep QtWebEngineCore | cut -d ' ' -f 1` " \
"@executable_path/../../../../QtWebEngineCore " \
"$(TARGET); " \
"xcrun install_name_tool -change " \
"`xcrun otool -X -L $(TARGET) | grep QtCore | cut -d ' ' -f 1` " \
"@executable_path/../../../../../../../QtCore.framework/QtCore " \
"$(TARGET) "
} else {
CONFIG -= app_bundle
DESTDIR = $$MODULE_BASE_OUTDIR/libexec
load(qt_build_paths)
DESTDIR = $$MODULE_BASE_OUTDIR/libexec
QT_PRIVATE += webenginecore
}
INCLUDEPATH += ../core
SOURCES = main.cpp
target.path = $$[QT_INSTALL_LIBEXECS]
contains(QT_CONFIG, qt_framework) {
target.path = $$[QT_INSTALL_LIBS]/QtWebEngineCore.framework/Versions/5/Helpers
} else {
target.path = $$[QT_INSTALL_LIBEXECS]
}
INSTALLS += target
......@@ -78,6 +78,7 @@ QQuickWebEngineSettings *QQuickWebEngineSettings::globalSettings()
QQuickWebEngineSettings::~QQuickWebEngineSettings()
{
allSettings->removeAll(this->d_func());
}
bool QQuickWebEngineSettings::autoLoadImages() const
......
......@@ -117,6 +117,12 @@
\li \l {Qt WebEngine Widgets C++ Classes}
\endlist
\section1 Examples
\list
\li \l {Qt WebEngine Widgets Examples}
\endlist
\section1 License Information
This is a snapshot of the integration of Chromium into Qt.
......
......@@ -42,38 +42,49 @@
import QtQuick 2.0
import QtTest 1.0
import QtWebEngine 1.0
import QtWebEngine.experimental 1.0
TestWebEngineView {
id: webEngineView
width: 400
height: 300
property variant testUrl
SignalSpy {
id: spyIconChanged
target: webEngineView
signalName: "iconChanged"
}
property variant unavailableUrl
TestCase {
id: test
name: "WebEngineViewLoadFail"
function initTestCase() {
WebEngine.settings.errorPageEnabled = false
}
function test_fail() {
testUrl = Qt.resolvedUrl("file_that_does_not_exist.html")
webEngineView.url = testUrl
unavailableUrl = Qt.resolvedUrl("file_that_does_not_exist.html")
webEngineView.url = unavailableUrl
verify(webEngineView.waitForLoadFailed())
spyIconChanged.clear()
}
// If this testcase finishes too early, we can not handle the received replacement content.
// So we should wait to ignore this error page.
spyIconChanged.wait()
function test_fail_url() {
var url = Qt.resolvedUrl("test1.html")
webEngineView.url = url
compare(webEngineView.url, url)
verify(webEngineView.waitForLoadSucceeded())
compare(webEngineView.url, url)
unavailableUrl = Qt.resolvedUrl("file_that_does_not_exist.html")
webEngineView.url = unavailableUrl
compare(webEngineView.url, unavailableUrl)
verify(webEngineView.waitForLoadFailed())
// When error page is disabled in case of LoadFail the entry of the unavailable page is not stored.
// We expect the url of the previously loaded page here.
compare(webEngineView.url, url)
}
}
onLoadingChanged: {
if (loadRequest.status == WebEngineView.LoadFailedStatus) {
test.compare(loadRequest.url, testUrl)
test.compare(loadRequest.url, unavailableUrl)
test.compare(loadRequest.errorDomain, WebEngineView.InternalErrorDomain)
}
}
......
......@@ -42,6 +42,7 @@
import QtQuick 2.0
import QtTest 1.0
import QtWebEngine 1.0
import QtWebEngine.experimental 1.0
TestWebEngineView {
id: webEngineView
......@@ -106,6 +107,8 @@ TestWebEngineView {
}
function test_urlProperty() {
WebEngine.settings.errorPageEnabled = false
var url = Qt.resolvedUrl("test1.html")
webEngineView.url = url
......@@ -117,7 +120,7 @@ TestWebEngineView {
webEngineView.url = bogusSite
compare(webEngineView.url, bogusSite)
verify(webEngineView.waitForLoadFailed())
compare(webEngineView.url, bogusSite)
compare(webEngineView.url, url)
webEngineView.url = "about:blank" // Reset from previous test
verify(webEngineView.waitForLoadSucceeded())
......