summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-01-17 12:51:21 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-01-17 12:51:21 +0100
commit2c6e6b86ef0a6c63297f9d5daa41c294aaf31a9b (patch)
treea8bcb1c7cb5aaf8194eab09f8bc56b2659f13ea5 /src
parentaa527a2e553bea0514bc088bfc09105703fe87ba (diff)
parent819e00f71e37f5230b9b2c2ff756db4cc4cfda5e (diff)
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts: .qmake.conf src/webengine/api/qquickwebengineview_p_p.h src/webenginewidgets/api/qwebenginepage_p.h tests/auto/quick/qmltests/data/TestWebEngineView.qml Change-Id: Id2acc92e8d0364bdaaf5a63ea2d2cb9cd533ade3
Diffstat (limited to 'src')
m---------src/3rdparty0
-rw-r--r--src/core/api/core_api.pro2
-rw-r--r--src/core/api/qwebenginebrowsercontext.cpp73
-rw-r--r--src/core/api/qwebenginebrowsercontext_p.h83
-rw-r--r--src/core/api/qwebenginecookiestore.cpp5
-rw-r--r--src/core/api/qwebengineurlrequestjob.cpp8
-rw-r--r--src/core/browser_context_adapter.cpp14
-rw-r--r--src/core/browser_context_adapter.h2
-rw-r--r--src/core/config/common.pri15
-rw-r--r--src/core/content_browser_client_qt.cpp9
-rw-r--r--src/core/core_module.pro13
-rw-r--r--src/core/delegated_frame_node.cpp2
-rw-r--r--src/core/pdfium_document_wrapper_qt.cpp20
-rw-r--r--src/core/pdfium_document_wrapper_qt.h6
-rw-r--r--src/core/proxy_config_service_qt.cpp14
-rw-r--r--src/core/renderer/user_resource_controller.cpp25
-rw-r--r--src/core/url_request_custom_job.cpp6
-rw-r--r--src/core/web_contents_adapter.cpp12
-rw-r--r--src/core/web_contents_adapter_client.h2
-rw-r--r--src/core/web_contents_delegate_qt.cpp25
-rw-r--r--src/core/web_engine_context.cpp21
-rw-r--r--src/core/web_engine_context.h5
-rw-r--r--src/core/web_event_factory.cpp3
-rw-r--r--src/webengine/api/qquickwebengineprofile.cpp20
-rw-r--r--src/webengine/api/qquickwebengineprofile_p.h7
-rw-r--r--src/webengine/api/qquickwebengineview.cpp7
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h5
-rw-r--r--src/webengine/ui_delegates_manager.cpp5
-rw-r--r--src/webengine/webengine.pro2
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.cpp7
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp49
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h5
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.cpp24
-rw-r--r--src/webenginewidgets/api/qwebengineprofile_p.h16
-rw-r--r--src/webenginewidgets/api/qwebengineview.cpp15
-rw-r--r--src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc5
-rw-r--r--src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc5
37 files changed, 394 insertions, 143 deletions
diff --git a/src/3rdparty b/src/3rdparty
-Subproject 3af56a2143e4fa3a10f93917ecde4ef46c2c807
+Subproject 17e4aafb6fe894047b46abeb3c3b8290de4094c
diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro
index 270595378..93eebbc45 100644
--- a/src/core/api/core_api.pro
+++ b/src/core/api/core_api.pro
@@ -33,6 +33,7 @@ HEADERS = \
qwebenginecallback_p.h \
qtwebenginecoreglobal.h \
qtwebenginecoreglobal_p.h \
+ qwebenginebrowsercontext_p.h \
qwebenginecookiestore.h \
qwebenginecookiestore_p.h \
qwebenginehttprequest.h \
@@ -44,6 +45,7 @@ HEADERS = \
SOURCES = \
qtwebenginecoreglobal.cpp \
+ qwebenginebrowsercontext.cpp \
qwebenginecookiestore.cpp \
qwebenginehttprequest.cpp \
qwebengineurlrequestinfo.cpp \
diff --git a/src/core/api/qwebenginebrowsercontext.cpp b/src/core/api/qwebenginebrowsercontext.cpp
new file mode 100644
index 000000000..c3ab16460
--- /dev/null
+++ b/src/core/api/qwebenginebrowsercontext.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwebenginebrowsercontext_p.h"
+
+#include "browser_context_adapter.h"
+#include <qtwebenginecoreglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+QWebEngineBrowserContext::QWebEngineBrowserContext(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext,
+ QtWebEngineCore::BrowserContextAdapterClient *profile)
+ : QObject(QtWebEngineCore::BrowserContextAdapter::globalQObjectRoot())
+ , browserContextRef(browserContext)
+ , m_profile(profile)
+{
+ browserContextRef->addClient(m_profile);
+}
+
+QWebEngineBrowserContext::~QWebEngineBrowserContext()
+{
+ if (m_profile)
+ shutdown();
+}
+
+void QWebEngineBrowserContext::shutdown()
+{
+ Q_ASSERT(m_profile);
+ // In the case the user sets this profile as the parent of the interceptor
+ // it can be deleted before the browser-context still referencing it is.
+ browserContextRef->setRequestInterceptor(nullptr);
+ browserContextRef->removeClient(m_profile);
+ m_profile = 0;
+ deleteLater();
+}
+
+QT_END_NAMESPACE
diff --git a/src/core/api/qwebenginebrowsercontext_p.h b/src/core/api/qwebenginebrowsercontext_p.h
new file mode 100644
index 000000000..713ab730e
--- /dev/null
+++ b/src/core/api/qwebenginebrowsercontext_p.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWEBENGINEBROWSERCONTEXT_P_H
+#define QWEBENGINEBROWSERCONTEXT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+#include "qtwebenginecoreglobal_p.h"
+
+#include <QObject>
+#include <QSharedPointer>
+
+namespace QtWebEngineCore {
+class BrowserContextAdapter;
+class BrowserContextAdapterClient;
+}
+
+QT_BEGIN_NAMESPACE
+
+// This is a wrapper class for BrowserContextAdapter. BrowserContextAdapter must be destructed before WebEngineContext
+// is destructed. Therefore access it via the QWebEngineBrowserContext which parent is the WebEngineContext::globalQObject.
+// This guarantees the destruction together with the WebEngineContext.
+class QWEBENGINE_PRIVATE_EXPORT QWebEngineBrowserContext : public QObject {
+public:
+ QWebEngineBrowserContext(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext, QtWebEngineCore::BrowserContextAdapterClient *profile);
+ ~QWebEngineBrowserContext();
+
+ void shutdown();
+
+ QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContextRef;
+
+private:
+ QtWebEngineCore::BrowserContextAdapterClient *m_profile;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWEBENGINEBROWSERCONTEXT_P_H
diff --git a/src/core/api/qwebenginecookiestore.cpp b/src/core/api/qwebenginecookiestore.cpp
index 8adf46bea..031eb8d3d 100644
--- a/src/core/api/qwebenginecookiestore.cpp
+++ b/src/core/api/qwebenginecookiestore.cpp
@@ -230,7 +230,10 @@ QWebEngineCookieStore::~QWebEngineCookieStore()
/*!
Adds \a cookie to the cookie store.
- It is possible to provide an optional \a origin URL argument to limit the scope of the cookie.
+ \note If \a cookie specifies a QNetworkCookie::domain() that does not start with a dot,
+ a dot is automatically prepended. To limit the cookie to the exact server,
+ omit QNetworkCookie::domain() and set \a origin instead.
+
The provided URL should also include the scheme.
\note This operation is asynchronous.
diff --git a/src/core/api/qwebengineurlrequestjob.cpp b/src/core/api/qwebengineurlrequestjob.cpp
index a071adbd5..47aab48a0 100644
--- a/src/core/api/qwebengineurlrequestjob.cpp
+++ b/src/core/api/qwebengineurlrequestjob.cpp
@@ -115,12 +115,20 @@ QByteArray QWebEngineUrlRequestJob::requestMethod() const
/*!
Replies to the request with \a device and the MIME type \a contentType.
+
The user has to be aware that \a device will be used on another thread
until the job is deleted. In case simultaneous access from the main thread
is desired, the user is reponsible for making access to \a device thread-safe
for example by using QMutex. Note that the \a device object is not owned by
the web engine. Therefore, the signal QObject::destroyed() of
QWebEngineUrlRequestJob must be monitored.
+
+ The device should remain available at least as long as the job exists.
+ When calling this method with a newly constructed device, one solution is to
+ make the device delete itself when closed, like this:
+ \code
+ connect(device, &QIODevice::aboutToClose, device, &QObject::deleteLater);
+ \endcode
*/
void QWebEngineUrlRequestJob::reply(const QByteArray &contentType, QIODevice *device)
{
diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp
index 0f392f9f8..3f8397752 100644
--- a/src/core/browser_context_adapter.cpp
+++ b/src/core/browser_context_adapter.cpp
@@ -42,6 +42,7 @@
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/browsing_data_remover.h"
+#include "content/public/browser/download_manager.h"
#include "browser_context_qt.h"
#include "content_client_qt.h"
@@ -102,9 +103,16 @@ BrowserContextAdapter::BrowserContextAdapter(const QString &storageName)
BrowserContextAdapter::~BrowserContextAdapter()
{
+ Q_ASSERT(!m_downloadManagerDelegate);
+}
+
+void BrowserContextAdapter::shutdown()
+{
m_browserContext->ShutdownStoragePartitions();
- if (m_downloadManagerDelegate)
- content::BrowserThread::DeleteSoon(content::BrowserThread::UI, FROM_HERE, m_downloadManagerDelegate.take());
+ if (m_downloadManagerDelegate) {
+ m_browserContext->GetDownloadManager(m_browserContext.data())->Shutdown();
+ m_downloadManagerDelegate.reset();
+ }
BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices(m_browserContext.data());
}
@@ -178,6 +186,8 @@ void BrowserContextAdapter::addClient(BrowserContextAdapterClient *adapterClient
void BrowserContextAdapter::removeClient(BrowserContextAdapterClient *adapterClient)
{
m_clients.removeOne(adapterClient);
+ if (m_clients.isEmpty() && this != WebEngineContext::current()->m_defaultBrowserContext.data())
+ shutdown();
}
void BrowserContextAdapter::cancelDownload(quint32 downloadId)
diff --git a/src/core/browser_context_adapter.h b/src/core/browser_context_adapter.h
index 5960014b9..b647bc30c 100644
--- a/src/core/browser_context_adapter.h
+++ b/src/core/browser_context_adapter.h
@@ -73,6 +73,8 @@ public:
static QSharedPointer<BrowserContextAdapter> defaultContext();
static QObject* globalQObjectRoot();
+ void shutdown();
+
VisitedLinksManagerQt *visitedLinksManager();
DownloadManagerDelegateQt *downloadManagerDelegate();
diff --git a/src/core/config/common.pri b/src/core/config/common.pri
index d8a4fa181..886ebe83d 100644
--- a/src/core/config/common.pri
+++ b/src/core/config/common.pri
@@ -13,7 +13,8 @@ gn_args += \
treat_warnings_as_errors=false \
enable_swiftshader=false \
use_custom_libcxx=false \
- use_jumbo_build=true
+ use_jumbo_build=true \
+ jumbo_file_merge_limit=50
qtConfig(webengine-printing-and-pdf) {
gn_args += enable_basic_printing=true enable_print_preview=true
@@ -62,3 +63,15 @@ CONFIG(debug, debug|release) {
# Compiling with -Os makes a huge difference in binary size
optimize_size: gn_args += optimize_for_size=true
+
+# We don't want to apply sanitizer options to the build tools (GN, dict convert, etc).
+!host_build {
+ sanitizer: gn_args += sanitizer_keep_symbols=true
+ sanitize_address: gn_args += is_asan=true
+ sanitize_thread: gn_args += is_tsan=true
+ sanitize_memory: gn_args += is_msan=true
+ # rtti is required for a specific check of ubsan, -fsanitize=vptr, which uses the runtime
+ # type information to check that correct derived objects are assigned to base pointers. Without
+ # rtti, linking would fail at build time.
+ sanitize_undefined: gn_args += is_ubsan=true use_rtti=true
+}
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index 328dcd38d..d0019e4f3 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -105,6 +105,10 @@
#include "web_engine_context.h"
#include "web_engine_library_info.h"
+#if defined(Q_OS_WIN)
+#include "ui/display/win/screen_win.h"
+#endif
+
#if defined(Q_OS_LINUX)
#include "global_descriptors_qt.h"
#include "ui/base/resource/resource_bundle.h"
@@ -295,8 +299,11 @@ public:
{
base::ThreadRestrictions::SetIOAllowed(true);
// Like ChromeBrowserMainExtraPartsViews::PreCreateThreads does.
+#if defined(Q_OS_WIN)
+ display::Screen::SetScreenInstance(new display::win::ScreenWin);
+#else
display::Screen::SetScreenInstance(new DesktopScreenQt);
-
+#endif
return 0;
}
diff --git a/src/core/core_module.pro b/src/core/core_module.pro
index 2409ccb12..d21985e60 100644
--- a/src/core/core_module.pro
+++ b/src/core/core_module.pro
@@ -40,8 +40,17 @@ else: LIBS_PRIVATE += $$NINJA_ARCHIVES
LIBS_PRIVATE += $$NINJA_LIB_DIRS $$NINJA_LIBS
# GN's LFLAGS doesn't always work across all the Linux configurations we support.
# The Windows and macOS ones from GN does provide a few useful flags however
-linux: QMAKE_LFLAGS += -Wl,--gc-sections -Wl,-O1 -Wl,-z,now -Wl,-z,defs
-else: QMAKE_LFLAGS += $$NINJA_LFLAGS
+
+linux {
+ QMAKE_LFLAGS += -Wl,--gc-sections -Wl,-O1 -Wl,-z,now
+ # Embedded address sanitizer symbols are undefined and are picked up by the dynamic link loader
+ # at runtime. Thus we do not to pass the linker flag below, because the linker would complain
+ # about the undefined sanitizer symbols.
+ !sanitizer: QMAKE_LFLAGS += -Wl,-z,defs
+} else {
+ QMAKE_LFLAGS += $$NINJA_LFLAGS
+}
+
POST_TARGETDEPS += $$NINJA_TARGETDEPS
diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp
index 6f4a4e8db..de39300c9 100644
--- a/src/core/delegated_frame_node.cpp
+++ b/src/core/delegated_frame_node.cpp
@@ -739,6 +739,7 @@ void DelegatedFrameNode::preprocess()
if (!mailboxesToFetch.isEmpty())
fetchAndSyncMailboxes(mailboxesToFetch);
+#endif
// Then render any intermediate RenderPass in order.
typedef QPair<int, QSharedPointer<QSGLayer> > Pair;
@@ -748,7 +749,6 @@ void DelegatedFrameNode::preprocess()
// Proceed with the actual update.
pair.second->updateTexture();
}
-#endif
}
static YUVVideoMaterial::ColorSpace toQt(cc::YUVVideoDrawQuad::ColorSpace color_space)
diff --git a/src/core/pdfium_document_wrapper_qt.cpp b/src/core/pdfium_document_wrapper_qt.cpp
index df829a426..ca1e8cd07 100644
--- a/src/core/pdfium_document_wrapper_qt.cpp
+++ b/src/core/pdfium_document_wrapper_qt.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
@@ -129,7 +129,9 @@ private:
};
-PdfiumDocumentWrapperQt::PdfiumDocumentWrapperQt(const void *pdfData, size_t size, const QSize& imageSize, const char *password)
+PdfiumDocumentWrapperQt::PdfiumDocumentWrapperQt(const void *pdfData, size_t size,
+ const QSize& imageSize,
+ const char *password)
: m_imageSize(imageSize * 2.0)
{
Q_ASSERT(pdfData);
@@ -153,21 +155,13 @@ QImage PdfiumDocumentWrapperQt::pageAsQImage(size_t index)
return QImage();
}
- PdfiumPageWrapperQt *pageWrapper = nullptr;
- if (!m_cachedPages.contains(index)) {
- pageWrapper = new PdfiumPageWrapperQt(m_documentHandle, index,
- m_imageSize.width(), m_imageSize.height());
- m_cachedPages.insert(index, pageWrapper);
- } else {
- pageWrapper = m_cachedPages.value(index);
- }
-
- return pageWrapper->image();
+ PdfiumPageWrapperQt pageWrapper(m_documentHandle, index,
+ m_imageSize.width(), m_imageSize.height());
+ return pageWrapper.image();
}
PdfiumDocumentWrapperQt::~PdfiumDocumentWrapperQt()
{
- qDeleteAll(m_cachedPages);
FPDF_CloseDocument(m_documentHandle);
if (--m_libraryUsers == 0)
FPDF_DestroyLibrary();
diff --git a/src/core/pdfium_document_wrapper_qt.h b/src/core/pdfium_document_wrapper_qt.h
index 42ac94a28..28c490ae5 100644
--- a/src/core/pdfium_document_wrapper_qt.h
+++ b/src/core/pdfium_document_wrapper_qt.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
@@ -53,7 +53,8 @@ class PdfiumPageWrapperQt;
class QWEBENGINE_EXPORT PdfiumDocumentWrapperQt
{
public:
- PdfiumDocumentWrapperQt(const void *pdfData, size_t size, const QSize &imageSize, const char *password = nullptr);
+ PdfiumDocumentWrapperQt(const void *pdfData, size_t size, const QSize &imageSize,
+ const char *password = nullptr);
virtual ~PdfiumDocumentWrapperQt();
QImage pageAsQImage(size_t index);
int pageCount() const { return m_pageCount; }
@@ -63,7 +64,6 @@ private:
int m_pageCount;
void *m_documentHandle;
QSize m_imageSize;
- QHash<int, PdfiumPageWrapperQt*> m_cachedPages;
};
} // namespace QtWebEngineCore
diff --git a/src/core/proxy_config_service_qt.cpp b/src/core/proxy_config_service_qt.cpp
index cd8f4c0fe..7fca18eb6 100644
--- a/src/core/proxy_config_service_qt.cpp
+++ b/src/core/proxy_config_service_qt.cpp
@@ -52,22 +52,20 @@ using content::BrowserThread;
net::ProxyServer ProxyConfigServiceQt::fromQNetworkProxy(const QNetworkProxy &qtProxy)
{
- net::ProxyServer::Scheme proxyScheme = net::ProxyServer::SCHEME_INVALID;
+ net::HostPortPair hostPortPair(qtProxy.hostName().toStdString(), qtProxy.port());
switch (qtProxy.type()) {
case QNetworkProxy::Socks5Proxy:
- proxyScheme = net::ProxyServer::SCHEME_SOCKS5;
- break;
+ return net::ProxyServer(net::ProxyServer::SCHEME_SOCKS5, hostPortPair);
case QNetworkProxy::HttpProxy:
case QNetworkProxy::HttpCachingProxy:
case QNetworkProxy::FtpCachingProxy:
- proxyScheme = net::ProxyServer::SCHEME_HTTP;
- break;
+ return net::ProxyServer(net::ProxyServer::SCHEME_HTTP, hostPortPair);
case QNetworkProxy::NoProxy:
case QNetworkProxy::DefaultProxy:
- proxyScheme = net::ProxyServer::SCHEME_DIRECT;
- break;
+ return net::ProxyServer(net::ProxyServer::SCHEME_DIRECT, net::HostPortPair());
+ default:
+ return net::ProxyServer(net::ProxyServer::SCHEME_INVALID, net::HostPortPair());
}
- return net::ProxyServer(proxyScheme, net::HostPortPair(qtProxy.hostName().toStdString(), qtProxy.port()));
}
ProxyConfigServiceQt::ProxyConfigServiceQt(std::unique_ptr<ProxyConfigService> baseService)
diff --git a/src/core/renderer/user_resource_controller.cpp b/src/core/renderer/user_resource_controller.cpp
index b4375dfdb..f85879053 100644
--- a/src/core/renderer/user_resource_controller.cpp
+++ b/src/core/renderer/user_resource_controller.cpp
@@ -148,9 +148,14 @@ void UserResourceController::RenderFrameObserverHelper::runScripts(UserScriptDat
void UserResourceController::runScripts(UserScriptData::InjectionPoint p, blink::WebLocalFrame *frame)
{
content::RenderFrame *renderFrame = content::RenderFrame::FromWebFrame(frame);
- content::RenderView *renderView = renderFrame->GetRenderView();
+ if (!renderFrame)
+ return;
const bool isMainFrame = renderFrame->IsMainFrame();
+ content::RenderView *renderView = renderFrame->GetRenderView();
+ if (!renderView)
+ return;
+
QList<uint64_t> scriptsToRun = m_viewUserScriptMap.value(0).toList();
scriptsToRun.append(m_viewUserScriptMap.value(renderView).toList());
@@ -233,7 +238,8 @@ void UserResourceController::RenderFrameObserverHelper::OnDestruct()
void UserResourceController::RenderViewObserverHelper::OnDestruct()
{
// Remove all scripts associated with the render view.
- UserResourceController::instance()->renderViewDestroyed(render_view());
+ if (content::RenderView *view = render_view())
+ UserResourceController::instance()->renderViewDestroyed(view);
delete this;
}
@@ -251,20 +257,23 @@ bool UserResourceController::RenderFrameObserverHelper::OnMessageReceived(const
void UserResourceController::RenderFrameObserverHelper::onUserScriptAdded(const UserScriptData &script)
{
- content::RenderView *view = render_frame()->GetRenderView();
- UserResourceController::instance()->addScriptForView(script, view);
+ if (content::RenderFrame *frame = render_frame())
+ if (content::RenderView *view = frame->GetRenderView())
+ UserResourceController::instance()->addScriptForView(script, view);
}
void UserResourceController::RenderFrameObserverHelper::onUserScriptRemoved(const UserScriptData &script)
{
- content::RenderView *view = render_frame()->GetRenderView();
- UserResourceController::instance()->removeScriptForView(script, view);
+ if (content::RenderFrame *frame = render_frame())
+ if (content::RenderView *view = frame->GetRenderView())
+ UserResourceController::instance()->removeScriptForView(script, view);
}
void UserResourceController::RenderFrameObserverHelper::onScriptsCleared()
{
- content::RenderView *view = render_frame()->GetRenderView();
- UserResourceController::instance()->clearScriptsForView(view);
+ if (content::RenderFrame *frame = render_frame())
+ if (content::RenderView *view = frame->GetRenderView())
+ UserResourceController::instance()->clearScriptsForView(view);
}
UserResourceController *UserResourceController::instance()
diff --git a/src/core/url_request_custom_job.cpp b/src/core/url_request_custom_job.cpp
index b49135f79..070414b4b 100644
--- a/src/core/url_request_custom_job.cpp
+++ b/src/core/url_request_custom_job.cpp
@@ -65,12 +65,12 @@ URLRequestCustomJob::URLRequestCustomJob(URLRequest *request,
URLRequestCustomJob::~URLRequestCustomJob()
{
m_proxy->m_job = nullptr;
- content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
- base::Bind(&URLRequestCustomJobProxy::release,
- m_proxy));
if (m_device && m_device->isOpen())
m_device->close();
m_device = nullptr;
+ content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&URLRequestCustomJobProxy::release,
+ m_proxy));
}
void URLRequestCustomJob::Start()
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 0b6a44d8d..668e791c1 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -632,9 +632,11 @@ void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeT
CHECK_VALID_RENDER_WIDGET_HOST_VIEW(d->webContents->GetRenderViewHost());
QByteArray encodedData = data.toPercentEncoding();
- std::string urlString("data:");
- urlString.append(mimeType.toStdString());
- urlString.append(",");
+ std::string urlString;
+ if (!mimeType.isEmpty())
+ urlString = std::string("data:") + mimeType.toStdString() + std::string(",");
+ else
+ urlString = std::string("data:text/plain;charset=US-ASCII,");
urlString.append(encodedData.constData(), encodedData.length());
GURL dataUrlToLoad(urlString);
@@ -1359,7 +1361,11 @@ bool WebContentsAdapter::handleDropDataFileContents(const content::DropData &dro
const auto maybeFilename = dropData.GetSafeFilenameForImageFileContents();
const QString fileName = maybeFilename ? toQt(maybeFilename->AsUTF16Unsafe()) : QString();
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0))
const QString &filePath = d->dndTmpDir->filePath(fileName);
+#else
+ const QString &filePath = d->dndTmpDir->path() + QLatin1Char('/') + fileName;
+#endif
QFile file(filePath);
if (!file.open(QIODevice::WriteOnly)) {
qWarning("Cannot write temporary file %s.", qUtf8Printable(filePath));
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index 6416ab6af..d6de9dfe6 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -390,7 +390,7 @@ public:
virtual bool isBeingAdopted() = 0;
virtual void close() = 0;
virtual void windowCloseRejected() = 0;
- virtual bool contextMenuRequested(const WebEngineContextMenuData &) = 0;
+ virtual void contextMenuRequested(const WebEngineContextMenuData &) = 0;
virtual void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) = 0;
virtual void requestFullScreenMode(const QUrl &origin, bool fullscreen) = 0;
virtual bool isFullScreenMode() const = 0;
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index 2086bea4b..7b765d99b 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -80,6 +80,16 @@
namespace QtWebEngineCore {
+static gfx::Rect rootViewToScreenRect(content::WebContents *web_contents, const gfx::Rect &anchor_in_root_view)
+{
+ RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt *>(web_contents->GetRenderWidgetHostView());
+ if (!rwhv)
+ return gfx::Rect();
+ content::ScreenInfo screenInfo;
+ rwhv->GetScreenInfo(&screenInfo);
+ return gfx::ScaleToEnclosingRect(anchor_in_root_view, 1 / screenInfo.device_scale_factor);
+}
+
// Maps the LogSeverity defines in base/logging.h to the web engines message levels.
static WebContentsAdapterClient::JavaScriptConsoleMessageLevel mapToJavascriptConsoleMessageLevel(int32_t messageLevel) {
if (messageLevel < 1)
@@ -336,6 +346,9 @@ void WebContentsDelegateQt::DidUpdateFaviconURL(const std::vector<content::Favic
faviconCandidates.append(toFaviconInfo(candidate));
}
+ // Favicon URL can be changed from JavaScript too. Thus we need to reset
+ // the current candidate icon list to not handle previous icon as a candidate.
+ m_faviconManager->resetCandidates();
m_faviconManager->update(faviconCandidates);
}
@@ -552,8 +565,10 @@ void WebContentsDelegateQt::launchExternalURL(const QUrl &url, ui::PageTransitio
void WebContentsDelegateQt::ShowValidationMessage(content::WebContents *web_contents, const gfx::Rect &anchor_in_root_view, const base::string16 &main_text, const base::string16 &sub_text)
{
- Q_UNUSED(web_contents);
- m_viewClient->showValidationMessage(toQt(anchor_in_root_view), toQt(main_text), toQt(sub_text));
+ gfx::Rect anchor = rootViewToScreenRect(web_contents, anchor_in_root_view);
+ if (anchor.IsEmpty())
+ return;
+ m_viewClient->showValidationMessage(toQt(anchor), toQt(main_text), toQt(sub_text));
}
void WebContentsDelegateQt::HideValidationMessage(content::WebContents *web_contents)
@@ -564,8 +579,10 @@ void WebContentsDelegateQt::HideValidationMessage(content::WebContents *web_cont
void WebContentsDelegateQt::MoveValidationMessage(content::WebContents *web_contents, const gfx::Rect &anchor_in_root_view)
{
- Q_UNUSED(web_contents);
- m_viewClient->moveValidationMessage(toQt(anchor_in_root_view));
+ gfx::Rect anchor = rootViewToScreenRect(web_contents, anchor_in_root_view);
+ if (anchor.IsEmpty())
+ return;
+ m_viewClient->moveValidationMessage(toQt(anchor));
}
void WebContentsDelegateQt::BeforeUnloadFired(content::WebContents *tab, bool proceed, bool *proceed_to_fire_unload)
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index e7bbbb9c7..84f6ce738 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -123,7 +123,11 @@ void destroyContext()
// Before destroying MessageLoop via destroying BrowserMainRunner destructor
// WebEngineContext's pointer is used.
sContext->destroy();
- sContext = 0;
+#if !defined(NDEBUG)
+ if (!sContext->HasOneRef())
+ qWarning("WebEngineContext leaked on exit, likely due to leaked WebEngine View or Page");
+#endif
+ sContext = nullptr;
s_destroyed = true;
}
@@ -199,20 +203,27 @@ void WebEngineContext::destroy()
{
if (m_devtoolsServer)
m_devtoolsServer->stop();
- delete m_globalQObject;
- m_globalQObject = 0;
base::MessagePump::Delegate *delegate =
static_cast<base::MessageLoop *>(m_runLoop->delegate_);
// Flush the UI message loop before quitting.
while (delegate->DoWork()) { }
+
+ if (m_defaultBrowserContext)
+ m_defaultBrowserContext->shutdown();
+ // Delete the global object and thus custom profiles
+ delete m_globalQObject;
+ m_globalQObject = nullptr;
+ // Handle any events posted by browser-context shutdown.
+ while (delegate->DoWork()) { }
+
GLContextHelper::destroy();
- m_devtoolsServer.reset(0);
+ m_devtoolsServer.reset();
m_runLoop->AfterRun();
// Force to destroy RenderProcessHostImpl by destroying BrowserMainRunner.
// RenderProcessHostImpl should be destroyed before WebEngineContext since
// default BrowserContext might be used by the RenderprocessHostImpl's destructor.
- m_browserRunner.reset(0);
+ m_browserRunner.reset();
// Drop the false reference.
sContext->Release();
diff --git a/src/core/web_engine_context.h b/src/core/web_engine_context.h
index 92c45e260..1b4be48b1 100644
--- a/src/core/web_engine_context.h
+++ b/src/core/web_engine_context.h
@@ -80,7 +80,7 @@ class WebEngineContext : public base::RefCounted<WebEngineContext> {
public:
static scoped_refptr<WebEngineContext> current();
- QSharedPointer<QtWebEngineCore::BrowserContextAdapter> defaultBrowserContext();
+ QSharedPointer<BrowserContextAdapter> defaultBrowserContext();
QObject *globalQObject();
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
printing::PrintJobManager* getPrintJobManager();
@@ -90,6 +90,7 @@ public:
private:
friend class base::RefCounted<WebEngineContext>;
+ friend class BrowserContextAdapter;
WebEngineContext();
~WebEngineContext();
@@ -98,7 +99,7 @@ private:
std::unique_ptr<content::ContentMainRunner> m_contentRunner;
std::unique_ptr<content::BrowserMainRunner> m_browserRunner;
QObject* m_globalQObject;
- QSharedPointer<QtWebEngineCore::BrowserContextAdapter> m_defaultBrowserContext;
+ QSharedPointer<BrowserContextAdapter> m_defaultBrowserContext;
std::unique_ptr<DevToolsServerQt> m_devtoolsServer;
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
std::unique_ptr<printing::PrintJobManager> m_printJobManager;
diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp
index 4241a11c2..4fb89d4e6 100644
--- a/src/core/web_event_factory.cpp
+++ b/src/core/web_event_factory.cpp
@@ -1024,7 +1024,8 @@ static inline double currentTimeForEvent(const QEvent *event)
{
Q_ASSERT(event);
- if (const QInputEvent *inputEvent = static_cast<const QInputEvent *>(event)) {
+ if (event->type() != QEvent::Leave) {
+ const QInputEvent *inputEvent = static_cast<const QInputEvent *>(event);
if (inputEvent->timestamp())
return static_cast<double>(inputEvent->timestamp()) / 1000;
}
diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp
index f966f2dc6..728f0b4a4 100644
--- a/src/webengine/api/qquickwebengineprofile.cpp
+++ b/src/webengine/api/qquickwebengineprofile.cpp
@@ -142,9 +142,8 @@ ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::MimeHtmlSaveFormat, QtWebEngineC
QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(QSharedPointer<BrowserContextAdapter> browserContext)
: m_settings(new QQuickWebEngineSettings())
- , m_browserContextRef(browserContext)
+ , m_browserContext(new QWebEngineBrowserContext(browserContext, this))
{
- m_browserContextRef->addClient(this);
m_settings->d_ptr->initDefaults();
// Fullscreen API was implemented before the supported setting, so we must
// make it default true to avoid change in default API behavior.
@@ -153,21 +152,26 @@ QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(QSharedPointer<Brow
QQuickWebEngineProfilePrivate::~QQuickWebEngineProfilePrivate()
{
- m_browserContextRef->setRequestInterceptor(nullptr);
-
- m_browserContextRef->removeClient(this);
-
- Q_FOREACH (QQuickWebEngineDownloadItem* download, m_ongoingDownloads) {
+ Q_FOREACH (QQuickWebEngineDownloadItem *download, m_ongoingDownloads) {
if (download)
download->cancel();
}
m_ongoingDownloads.clear();
+
+ if (m_browserContext)
+ m_browserContext->shutdown();
+}
+
+QSharedPointer<QtWebEngineCore::BrowserContextAdapter> QQuickWebEngineProfilePrivate::browserContext() const
+{
+ return m_browserContext ? m_browserContext->browserContextRef : nullptr;
}
void QQuickWebEngineProfilePrivate::cancelDownload(quint32 downloadId)
{
- browserContext()->cancelDownload(downloadId);
+ if (m_browserContext)
+ m_browserContext->browserContextRef->cancelDownload(downloadId);
}
void QQuickWebEngineProfilePrivate::downloadDestroyed(quint32 downloadId)
diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h
index 5be82a4f5..61968bf77 100644
--- a/src/webengine/api/qquickwebengineprofile_p.h
+++ b/src/webengine/api/qquickwebengineprofile_p.h
@@ -52,8 +52,9 @@
//
#include "browser_context_adapter_client.h"
-#include "qquickwebengineprofile_p.h"
#include "browser_context_adapter.h"
+#include "qwebenginebrowsercontext_p.h"
+#include "qquickwebengineprofile_p.h"
#include <QExplicitlySharedDataPointer>
#include <QMap>
@@ -71,7 +72,7 @@ public:
QQuickWebEngineProfilePrivate(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext);
~QQuickWebEngineProfilePrivate();
- QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext() const { return m_browserContextRef; }
+ QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext() const;
QQuickWebEngineSettings *settings() const { return m_settings.data(); }
void cancelDownload(quint32 downloadId);
@@ -90,7 +91,7 @@ private:
friend class QQuickWebEngineViewPrivate;
QQuickWebEngineProfile *q_ptr;
QScopedPointer<QQuickWebEngineSettings> m_settings;
- QSharedPointer<QtWebEngineCore::BrowserContextAdapter> m_browserContextRef;
+ QPointer<QWebEngineBrowserContext> m_browserContext;
QMap<quint32, QPointer<QQuickWebEngineDownloadItem> > m_ongoingDownloads;
QList<QQuickWebEngineScript *> m_userScripts;
};
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 2721039ae..2c30627ad 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -183,7 +183,7 @@ RenderWidgetHostViewQtDelegate *QQuickWebEngineViewPrivate::CreateRenderWidgetHo
return quickDelegate;
}
-bool QQuickWebEngineViewPrivate::contextMenuRequested(const WebEngineContextMenuData &data)
+void QQuickWebEngineViewPrivate::contextMenuRequested(const WebEngineContextMenuData &data)
{
Q_Q(QQuickWebEngineView);
@@ -195,13 +195,13 @@ bool QQuickWebEngineViewPrivate::contextMenuRequested(const WebEngineContextMenu
Q_EMIT q->contextMenuRequested(request);
if (request->isAccepted())
- return true;
+ return;
// Assign the WebEngineView as the parent of the menu, so mouse events are properly propagated
// on OSX.
QObject *menu = ui()->addMenu(q, QString(), data.position());
if (!menu)
- return false;
+ return;
// Populate our menu
MenuItemHandler *item = 0;
@@ -329,7 +329,6 @@ bool QQuickWebEngineViewPrivate::contextMenuRequested(const WebEngineContextMenu
// Now fire the popup() method on the top level menu
ui()->showMenu(menu);
- return true;
}
void QQuickWebEngineViewPrivate::navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame)
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index a30614b2f..baa89718d 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -114,7 +114,7 @@ public:
void windowCloseRejected() override;
void requestFullScreenMode(const QUrl &origin, bool fullscreen) override;
bool isFullScreenMode() const override;
- bool contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &) override;
+ void contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &) override;
void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) override;
void javascriptDialog(QSharedPointer<QtWebEngineCore::JavaScriptDialogController>) override;
void runFileChooser(QSharedPointer<QtWebEngineCore::FilePickerController>) override;
@@ -138,8 +138,7 @@ public:
void showValidationMessage(const QRect &anchor, const QString &mainText, const QString &subText) override;
void hideValidationMessage() override;
void moveValidationMessage(const QRect &anchor) override;
- virtual void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus,
- int exitCode) override;
+ void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode) override;
void requestGeometryChange(const QRect &geometry, const QRect &frameGeometry) override;
void updateScrollPosition(const QPointF &position) override;
void updateContentsSize(const QSizeF &size) override;
diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp
index fb23f5db7..046affbf4 100644
--- a/src/webengine/ui_delegates_manager.cpp
+++ b/src/webengine/ui_delegates_manager.cpp
@@ -504,7 +504,12 @@ public:
if (pos.isNull() || !item->contains(pos))
return;
const QPoint oldPos = QCursor::pos();
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 7, 0))
const QPoint globalPos = item->mapToGlobal(QPointF(pos)).toPoint();
+#else
+ const QPoint posInWindow = item->mapToItem(item->window()->contentItem(), QPointF(pos)).toPoint();
+ const QPoint globalPos = item->window()->mapToGlobal(posInWindow);
+#endif
if (oldPos == globalPos)
return;
m_oldCursorPos = oldPos;
diff --git a/src/webengine/webengine.pro b/src/webengine/webengine.pro
index 58e1263a7..570f41866 100644
--- a/src/webengine/webengine.pro
+++ b/src/webengine/webengine.pro
@@ -59,7 +59,7 @@ HEADERS = \
ui_delegates_manager.h
qtConfig(webengine-testsupport) {
- QT += testlib
+ QT_PRIVATE += testlib
SOURCES += api/qquickwebenginetestsupport.cpp
HEADERS += api/qquickwebenginetestsupport_p.h
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp
index ac7a71959..8f097df6c 100644
--- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp
+++ b/src/webenginewidgets/api/qwebenginedownloaditem.cpp
@@ -195,9 +195,10 @@ void QWebEngineDownloadItem::cancel()
// We directly cancel the download request if the user cancels
// before it even started, so no need to notify the profile here.
- if (state == QWebEngineDownloadItem::DownloadInProgress)
- d->profile->browserContext()->cancelDownload(d->downloadId);
- else {
+ if (state == QWebEngineDownloadItem::DownloadInProgress) {
+ if (auto browserContext = d->profile->browserContext())
+ browserContext->cancelDownload(d->downloadId);
+ } else {
d->downloadState = QWebEngineDownloadItem::DownloadCancelled;
Q_EMIT stateChanged(d->downloadState);
}
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 3bb7f6c83..a8fa98bea 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
@@ -139,7 +139,8 @@ static bool printPdfDataOnPrinter(const QByteArray& data, QPrinter& printer)
QPainter painter;
if (!painter.begin(&printer)) {
- qWarning("Failure to print on printer %ls: Could not open printer for painting.", qUtf16Printable(printer.printerName()));
+ qWarning("Failure to print on printer %ls: Could not open printer for painting.",
+ qUtf16Printable(printer.printerName()));
return false;
}
@@ -1475,35 +1476,36 @@ void QWebEnginePagePrivate::wasHidden()
adapter->wasHidden();
}
-bool QWebEnginePagePrivate::contextMenuRequested(const WebEngineContextMenuData &data)
+void QWebEnginePagePrivate::contextMenuRequested(const WebEngineContextMenuData &data)
{
if (!view)
- return false;
+ return;
contextData.reset();
- QContextMenuEvent event(QContextMenuEvent::Mouse, data.position(), view->mapToGlobal(data.position()));
switch (view->contextMenuPolicy()) {
- case Qt::PreventContextMenu:
- return false;
case Qt::DefaultContextMenu:
+ {
contextData = data;
+ QContextMenuEvent event(QContextMenuEvent::Mouse, data.position(), view->mapToGlobal(data.position()));
view->contextMenuEvent(&event);
- break;
+ return;
+ }
case Qt::CustomContextMenu:
contextData = data;
Q_EMIT view->customContextMenuRequested(data.position());
- break;
+ return;
case Qt::ActionsContextMenu:
if (view->actions().count()) {
+ QContextMenuEvent event(QContextMenuEvent::Mouse, data.position(), view->mapToGlobal(data.position()));
QMenu::exec(view->actions(), event.globalPos(), 0, view);
- break;
}
- // fallthrough
+ return;
+ case Qt::PreventContextMenu:
case Qt::NoContextMenu:
- event.ignore();
- return false;
+ return;
}
- return true;
+
+ Q_UNREACHABLE();
}
void QWebEnginePagePrivate::navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame)
@@ -1630,12 +1632,21 @@ bool QWebEnginePagePrivate::isEnabled() const
void QWebEnginePagePrivate::setToolTip(const QString &toolTipText)
{
- if (view) {
- QString wrappedTip;
- if (!toolTipText.isEmpty())
- wrappedTip = QLatin1String("<p>") % toolTipText.toHtmlEscaped().left(MaxTooltipLength) % QLatin1String("</p>");
- view->setToolTip(wrappedTip);
+ if (!view)
+ return;
+
+ // Hide tooltip if shown.
+ if (toolTipText.isEmpty()) {
+ if (!view->toolTip().isEmpty())
+ view->setToolTip(QString());
+
+ return;
}
+
+ // Update tooltip if text was changed.
+ QString wrappedTip = QLatin1String("<p>") % toolTipText.toHtmlEscaped().left(MaxTooltipLength) % QLatin1String("</p>");
+ if (view->toolTip() != wrappedTip)
+ view->setToolTip(wrappedTip);
}
QMenu *QWebEnginePage::createStandardContextMenu()
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index 66f479717..270849aee 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -109,7 +109,7 @@ public:
bool isBeingAdopted() override;
void close() override;
void windowCloseRejected() override;
- bool contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &data) override;
+ void contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &data) override;
void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) override;
void requestFullScreenMode(const QUrl &origin, bool fullscreen) override;
bool isFullScreenMode() const override;
@@ -135,8 +135,7 @@ public:
void showValidationMessage(const QRect &anchor, const QString &mainText, const QString &subText) override;
void hideValidationMessage() override;
void moveValidationMessage(const QRect &anchor) override;
- virtual void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus,
- int exitCode) override;
+ void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode) override;
void requestGeometryChange(const QRect &geometry, const QRect &frameGeometry) override;
void updateScrollPosition(const QPointF &position) override;
void updateContentsSize(const QSizeF &size) override;
diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp
index 02fdfa113..737326c24 100644
--- a/src/webenginewidgets/api/qwebengineprofile.cpp
+++ b/src/webenginewidgets/api/qwebengineprofile.cpp
@@ -47,8 +47,9 @@
#include "qwebenginesettings.h"
#include "qwebenginescriptcollection_p.h"
+#include "qwebenginebrowsercontext_p.h"
+#include "qtwebenginecoreglobal.h"
#include "browser_context_adapter.h"
-#include <qtwebenginecoreglobal.h>
#include "visited_links_manager_qt.h"
#include "web_engine_settings.h"
@@ -145,23 +146,6 @@ using QtWebEngineCore::BrowserContextAdapter;
\sa QWebEngineDownloadItem, QWebEnginePage::download()
*/
-QWebEngineBrowserContext::QWebEngineBrowserContext(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext, QWebEngineProfilePrivate *profile)
- : QObject(BrowserContextAdapter::globalQObjectRoot())
- , browserContextRef(browserContext)
- , m_profile(profile)
-{
- browserContextRef->addClient(m_profile);
-}
-
-QWebEngineBrowserContext::~QWebEngineBrowserContext()
-{
- Q_ASSERT(m_profile);
- // In the case the user sets this profile as the parent of the interceptor
- // it can be deleted before the browser-context still referencing it is.
- browserContextRef->setRequestInterceptor(nullptr);
- browserContextRef->removeClient(m_profile);
-}
-
QWebEngineProfilePrivate::QWebEngineProfilePrivate(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext)
: m_settings(new QWebEngineSettings())
, m_scriptCollection(new QWebEngineScriptCollection(new QWebEngineScriptCollectionPrivate(browserContext->userResourceController())))
@@ -181,11 +165,13 @@ QWebEngineProfilePrivate::~QWebEngineProfilePrivate()
}
m_ongoingDownloads.clear();
+ if (m_browserContext)
+ m_browserContext->shutdown();
}
QSharedPointer<QtWebEngineCore::BrowserContextAdapter> QWebEngineProfilePrivate::browserContext() const
{
- return m_browserContext->browserContextRef;
+ return m_browserContext ? m_browserContext->browserContextRef : nullptr;
}
void QWebEngineProfilePrivate::downloadDestroyed(quint32 downloadId)
diff --git a/src/webenginewidgets/api/qwebengineprofile_p.h b/src/webenginewidgets/api/qwebengineprofile_p.h
index 8cbf241f3..72fa904e4 100644
--- a/src/webenginewidgets/api/qwebengineprofile_p.h
+++ b/src/webenginewidgets/api/qwebengineprofile_p.h
@@ -54,6 +54,7 @@
#include "browser_context_adapter_client.h"
#include "qwebengineprofile.h"
#include "qwebenginescriptcollection.h"
+
#include <QMap>
#include <QPointer>
#include <QScopedPointer>
@@ -65,23 +66,10 @@ class BrowserContextAdapter;
QT_BEGIN_NAMESPACE
+class QWebEngineBrowserContext;
class QWebEngineProfilePrivate;
class QWebEngineSettings;
-// This is a wrapper class for BrowserContextAdapter. BrowserContextAdapter must be destructed before WebEngineContext
-// is destructed. Therefore access it via the QWebEngineBrowserContext which parent is the WebEngineContext::globalQObject.
-// This guarantees the destruction together with the WebEngineContext.
-class QWebEngineBrowserContext : public QObject {
-public:
- QWebEngineBrowserContext(QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContext, QWebEngineProfilePrivate *profile);
- ~QWebEngineBrowserContext();
-
- QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContextRef;
-
-private:
- QWebEngineProfilePrivate *m_profile;
-};
-
class QWebEngineProfilePrivate : public QtWebEngineCore::BrowserContextAdapterClient {
public:
Q_DECLARE_PUBLIC(QWebEngineProfile)
diff --git a/src/webenginewidgets/api/qwebengineview.cpp b/src/webenginewidgets/api/qwebengineview.cpp
index 9b3f62217..7ea451fc5 100644
--- a/src/webenginewidgets/api/qwebengineview.cpp
+++ b/src/webenginewidgets/api/qwebengineview.cpp
@@ -50,8 +50,9 @@
#include <QAction>
#include <QMenu>
#include <QContextMenuEvent>
-#include <QStackedLayout>
#include <QPageLayout>
+#include <QStackedLayout>
+#include <QToolTip>
QT_BEGIN_NAMESPACE
@@ -327,6 +328,18 @@ bool QWebEngineView::event(QEvent *ev)
ev->accept();
return true;
}
+
+ // Override QWidget's default ToolTip handler since it doesn't hide tooltip on empty text.
+ if (ev->type() == QEvent::ToolTip) {
+ if (!toolTip().isEmpty())
+ QToolTip::showText(static_cast<QHelpEvent *>(ev)->globalPos(), toolTip(), this, QRect(), toolTipDuration());
+ else
+ QToolTip::hideText();
+
+ ev->accept();
+ return true;
+ }
+
return QWidget::event(ev);
}
diff --git a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
index eb91d576d..2c161e2df 100644
--- a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
@@ -694,9 +694,8 @@
/*!
\fn void QWebEnginePage::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
- Sets the content of this page to \a data. If the \a mimeType argument
- is empty, it is currently assumed that the content is HTML but in future versions we may introduce
- auto-detection.
+ Sets the content of the web page to \a data. If the \a mimeType argument
+ is empty, it is assumed that the content is \c{text/plain,charset=US-ASCII}.
External objects referenced in the content are located relative to \a baseUrl.
diff --git a/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc
index 27ee96c5e..18d139c00 100644
--- a/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc
@@ -152,9 +152,8 @@
/*!
\fn void QWebEngineView::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
- Sets the content of the web view to the specified content \a data. If the \a mimeType argument
- is empty, it is currently assumed that the content is HTML but in future versions we may
- introduce auto-detection.
+ Sets the content of the web view to \a data. If the \a mimeType argument
+ is empty, it is assumed that the content is \c{text/plain,charset=US-ASCII}.
External objects referenced in the content are located relative to \a baseUrl.