summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
m---------src/3rdparty0
-rw-r--r--src/buildtools/configure.json8
-rw-r--r--src/buildtools/gn.pro4
-rw-r--r--src/core/api/core_api.pro18
-rw-r--r--src/core/api/qtbug-60565.cpp138
-rw-r--r--src/core/api/qtbug-61521.cpp120
-rw-r--r--src/core/api/qtwebenginecoreglobal.cpp157
-rw-r--r--src/core/api/qwebenginecertificateerror.cpp (renamed from src/webenginewidgets/api/qwebenginecertificateerror.cpp)117
-rw-r--r--src/core/api/qwebenginecertificateerror.h (renamed from src/webenginewidgets/api/qwebenginecertificateerror.h)50
-rw-r--r--src/core/api/qwebengineclientcertificatestore.cpp4
-rw-r--r--src/core/api/qwebengineclientcertificatestore.h11
-rw-r--r--src/core/api/qwebenginecontextmenurequest.cpp296
-rw-r--r--src/core/api/qwebenginecontextmenurequest.h (renamed from src/webengine/api/qquickwebenginecontextmenurequest_p.h)74
-rw-r--r--src/core/api/qwebenginecontextmenurequest_p.h (renamed from src/core/certificate_error_controller_p.h)56
-rw-r--r--src/core/api/qwebenginecookiestore_p.h4
-rw-r--r--src/core/api/qwebenginedownloadrequest.cpp (renamed from src/webenginewidgets/api/qwebenginedownloaditem.cpp)406
-rw-r--r--src/core/api/qwebenginedownloadrequest.h (renamed from src/webengine/api/qquickwebenginedownloaditem_p.h)141
-rw-r--r--src/core/api/qwebenginedownloadrequest_p.h (renamed from src/webenginewidgets/api/qwebenginedownloaditem_p.h)49
-rw-r--r--src/core/api/qwebenginehttprequest.cpp10
-rw-r--r--src/core/api/qwebenginehttprequest.h6
-rw-r--r--src/core/browser_accessibility_manager_qt.h4
-rw-r--r--src/core/certificate_error_controller.cpp194
-rw-r--r--src/core/certificate_error_controller.h88
-rw-r--r--src/core/client_cert_select_controller.cpp12
-rw-r--r--src/core/client_cert_select_controller.h14
-rw-r--r--src/core/compositor/chromium_gpu_helper.cpp87
-rw-r--r--src/core/compositor/chromium_gpu_helper.h73
-rw-r--r--src/core/compositor/compositor.cpp216
-rw-r--r--src/core/compositor/compositor.h204
-rw-r--r--src/core/compositor/compositor_resource.h123
-rw-r--r--src/core/compositor/compositor_resource_tracker.cpp266
-rw-r--r--src/core/compositor/compositor_resource_tracker.h127
-rw-r--r--src/core/compositor/delegated_frame_node.cpp1101
-rw-r--r--src/core/compositor/delegated_frame_node.h133
-rw-r--r--src/core/compositor/display_consumer.h62
-rw-r--r--src/core/compositor/display_frame_sink.cpp140
-rw-r--r--src/core/compositor/display_frame_sink.h77
-rw-r--r--src/core/compositor/display_gl_output_surface.cpp55
-rw-r--r--src/core/compositor/display_gl_output_surface.h18
-rw-r--r--src/core/compositor/display_gl_output_surface_qsg.cpp121
-rw-r--r--src/core/compositor/display_producer.h69
-rw-r--r--src/core/compositor/display_software_output_surface.cpp103
-rw-r--r--src/core/compositor/stream_video_node.cpp169
-rw-r--r--src/core/compositor/yuv_video_node.cpp352
-rw-r--r--src/core/compositor/yuv_video_node.h117
-rw-r--r--src/core/config/common.pri7
-rw-r--r--src/core/content_browser_client_qt.cpp149
-rw-r--r--src/core/content_browser_client_qt.h4
-rw-r--r--src/core/core_chromium.pri25
-rw-r--r--src/core/delegated_frame_host_client_qt.cpp1
-rw-r--r--src/core/download_manager_delegate_qt.cpp16
-rw-r--r--src/core/download_manager_delegate_qt.h3
-rw-r--r--src/core/gn_run.pro6
-rw-r--r--src/core/locked_ptr.h301
-rw-r--r--src/core/macos_context_type_helper.h1
-rw-r--r--src/core/macos_context_type_helper.mm5
-rw-r--r--src/core/net/client_cert_store_data.h4
-rw-r--r--src/core/net/cookie_monster_delegate_qt.h6
-rw-r--r--src/core/ozone/gl_share_context_qt.cpp110
-rw-r--r--src/core/ozone/gl_share_context_qt.h (renamed from src/core/compositor/stream_video_node.h)75
-rw-r--r--src/core/ozone/surface_factory_qt.cpp28
-rw-r--r--src/core/ozone/surface_factory_qt.h2
-rw-r--r--src/core/pref_service_adapter.h6
-rw-r--r--src/core/profile_adapter.h3
-rw-r--r--src/core/profile_adapter_client.h9
-rw-r--r--src/core/profile_qt.h4
-rw-r--r--src/core/render_view_context_menu_qt.cpp45
-rw-r--r--src/core/render_view_context_menu_qt.h6
-rw-r--r--src/core/render_widget_host_view_qt.cpp1202
-rw-r--r--src/core/render_widget_host_view_qt.h185
-rw-r--r--src/core/render_widget_host_view_qt_delegate.h37
-rw-r--r--src/core/render_widget_host_view_qt_delegate_client.cpp976
-rw-r--r--src/core/render_widget_host_view_qt_delegate_client.h164
-rw-r--r--src/core/renderer/content_renderer_client_qt.cpp2
-rw-r--r--src/core/renderer/user_resource_controller.cpp4
-rw-r--r--src/core/renderer/web_channel_ipc_transport.cpp29
-rw-r--r--src/core/renderer/web_channel_ipc_transport.h2
-rw-r--r--src/core/renderer_host/web_channel_ipc_transport_host.cpp11
-rw-r--r--src/core/renderer_host/web_channel_ipc_transport_host.h3
-rw-r--r--src/core/type_conversion.cpp36
-rw-r--r--src/core/type_conversion.h7
-rw-r--r--src/core/visited_links_manager_qt.h4
-rw-r--r--src/core/web_contents_adapter.cpp18
-rw-r--r--src/core/web_contents_adapter.h1
-rw-r--r--src/core/web_contents_adapter_client.h286
-rw-r--r--src/core/web_contents_delegate_qt.cpp22
-rw-r--r--src/core/web_contents_delegate_qt.h12
-rw-r--r--src/core/web_contents_view_qt.cpp162
-rw-r--r--src/core/web_contents_view_qt.h14
-rw-r--r--src/core/web_engine_context.cpp304
-rw-r--r--src/core/web_engine_context.h4
-rw-r--r--src/core/web_engine_settings.cpp7
-rw-r--r--src/core/web_event_factory.cpp32
-rw-r--r--src/pdf/api/qpdflinkmodel_p_p.h2
-rw-r--r--src/pdf/api/qpdfpagerenderer.h2
-rw-r--r--src/pdf/api/qpdfsearchmodel.h2
-rw-r--r--src/pdf/api/qpdfsearchmodel_p.h4
-rw-r--r--src/pdf/api/qpdfsearchresult.h8
-rw-r--r--src/pdf/api/qpdfsearchresult_p.h4
-rw-r--r--src/pdf/api/qpdfselection.h6
-rw-r--r--src/pdf/api/qpdfselection_p.h6
-rw-r--r--src/pdf/qpdfbookmarkmodel.cpp4
-rw-r--r--src/pdf/qpdfdocument.cpp22
-rw-r--r--src/pdf/qpdflinkmodel.cpp7
-rw-r--r--src/pdf/qpdfpagerenderer.cpp5
-rw-r--r--src/pdf/qpdfsearchmodel.cpp15
-rw-r--r--src/pdf/qpdfsearchresult.cpp4
-rw-r--r--src/pdf/qpdfselection.cpp4
-rw-r--r--src/pdf/quick/qquickpdflinkmodel_p.h2
-rw-r--r--src/pdf/quick/qquickpdfnavigationstack_p.h2
-rw-r--r--src/pdf/quick/qquickpdfsearchmodel.cpp10
-rw-r--r--src/pdf/quick/qquickpdfsearchmodel_p.h10
-rw-r--r--src/pdf/quick/qquickpdfselection.cpp2
-rw-r--r--src/pdf/quick/qquickpdfselection_p.h10
-rw-r--r--src/pdf/quick/qquicktableviewextra.cpp1
-rw-r--r--src/pdf/quick/qquicktableviewextra_p.h3
-rw-r--r--src/pdfwidgets/qpdfview.cpp21
-rw-r--r--src/pdfwidgets/qpdfview.h3
-rw-r--r--src/pdfwidgets/qpdfview_p.h8
-rw-r--r--src/process/process.pro4
-rw-r--r--src/src.pro1
-rw-r--r--src/tools/qwebengine_convert_dict/main.cpp4
-rw-r--r--src/webengine/api/qquickwebenginecertificateerror_p.h115
-rw-r--r--src/webengine/api/qquickwebengineclientcertificateselection.cpp7
-rw-r--r--src/webengine/api/qquickwebengineclientcertificateselection_p.h14
-rw-r--r--src/webengine/api/qquickwebenginecontextmenurequest.cpp383
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem.cpp789
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem_p_p.h99
-rw-r--r--src/webengine/api/qquickwebengineprofile.cpp40
-rw-r--r--src/webengine/api/qquickwebengineprofile.h8
-rw-r--r--src/webengine/api/qquickwebengineprofile_p.h4
-rw-r--r--src/webengine/api/qquickwebenginesingleton_p.h5
-rw-r--r--src/webengine/api/qquickwebenginetouchhandleprovider.cpp2
-rw-r--r--src/webengine/api/qquickwebengineview.cpp238
-rw-r--r--src/webengine/api/qquickwebengineview_p.h20
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h26
-rw-r--r--src/webengine/api/qtwebengineglobal.cpp12
-rw-r--r--src/webengine/doc/src/context_menu_request.qdoc218
-rw-r--r--src/webengine/doc/src/fullscreen_request.qdoc82
-rw-r--r--src/webengine/doc/src/quota_request.qdoc74
-rw-r--r--src/webengine/doc/src/register_protocol_handler_request.qdoc66
-rw-r--r--src/webengine/doc/src/webengine_certificate_error.qdoc (renamed from src/webengine/api/qquickwebenginecertificateerror.cpp)140
-rw-r--r--src/webengine/doc/src/webengine_download_request.qdoc302
-rw-r--r--src/webengine/doc/src/webengineview_lgpl.qdoc142
-rw-r--r--src/webengine/module.pro9
-rw-r--r--src/webengine/plugin/plugin.cpp35
-rw-r--r--src/webengine/plugin/plugins.qmltypes5
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quick.cpp121
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quick.h18
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp26
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quickwindow.h6
-rw-r--r--src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp2
-rw-r--r--src/webenginewidgets/api/qwebengineclientcertificateselection.cpp11
-rw-r--r--src/webenginewidgets/api/qwebengineclientcertificateselection.h19
-rw-r--r--src/webenginewidgets/api/qwebenginecontextmenudata.cpp306
-rw-r--r--src/webenginewidgets/api/qwebenginecontextmenudata.h133
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.h174
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp417
-rw-r--r--src/webenginewidgets/api/qwebenginepage.h18
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h30
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.cpp40
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.h4
-rw-r--r--src/webenginewidgets/api/qwebengineprofile_p.h2
-rw-r--r--src/webenginewidgets/api/qwebengineview.cpp244
-rw-r--r--src/webenginewidgets/api/qwebengineview.h6
-rw-r--r--src/webenginewidgets/api/qwebengineview_p.h21
-rw-r--r--src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc9
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp171
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h6
-rw-r--r--src/webenginewidgets/webenginewidgets.pro7
170 files changed, 4815 insertions, 9921 deletions
diff --git a/src/3rdparty b/src/3rdparty
-Subproject 4e0b66a6f2d6901b4c738c8bcfb9d89d74def60
+Subproject 5596a886555297ecd3a7038764382cd6dadf670
diff --git a/src/buildtools/configure.json b/src/buildtools/configure.json
index 1ca6214a0..2da87a11c 100644
--- a/src/buildtools/configure.json
+++ b/src/buildtools/configure.json
@@ -292,7 +292,8 @@
},
"webengine-ninja": {
"label": "system ninja",
- "type": "detectNinja"
+ "type": "detectNinja",
+ "log": "path"
},
"webengine-python2": {
"label": "python2",
@@ -446,7 +447,10 @@
"webengine-system-ninja": {
"label": "Use System Ninja",
"condition": "tests.webengine-ninja",
- "output": [ "privateFeature" ]
+ "output": [
+ "privateFeature",
+ { "type": "varAssign", "name": "QMAKE_NINJA", "value": "tests.webengine-ninja.path" }
+ ]
},
"webengine-system-fontconfig": {
"label": "fontconfig",
diff --git a/src/buildtools/gn.pro b/src/buildtools/gn.pro
index 033202e6e..9e8cfe157 100644
--- a/src/buildtools/gn.pro
+++ b/src/buildtools/gn.pro
@@ -11,8 +11,6 @@ build_pass|!debug_and_release {
buildgn.target = build_gn
out = $$gnPath()
out_path = $$dirname(out)
- !qtConfig(webengine-system-ninja): ninja_path = $$ninjaPath()
- else: ninja_path="ninja"
# check if it is not already build
!exists($$out) {
src_3rd_party_dir = $$absolute_path("$${getChromiumSrcDir()}/../", "$$QTWEBENGINE_ROOT")
@@ -32,7 +30,7 @@ build_pass|!debug_and_release {
!system("$$pythonPathForSystem() $$gn_configure") {
error("GN generation error!")
}
- !system("cd $$system_quote($$system_path($$out_path)) && $$ninja_path $$basename(out)" ) {
+ !system("cd $$system_quote($$system_path($$out_path)) && $$system_quote($$system_path($$ninjaPath())) $$basename(out)" ) {
error("GN build error!")
}
}
diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro
index d53fb6942..885b81f70 100644
--- a/src/core/api/core_api.pro
+++ b/src/core/api/core_api.pro
@@ -36,6 +36,7 @@ HEADERS = \
qwebengineclientcertificatestore.h \
qtwebenginecoreglobal.h \
qtwebenginecoreglobal_p.h \
+ qwebenginecertificateerror.h \
qwebenginecookiestore.h \
qwebenginecookiestore_p.h \
qwebenginefindtextresult.h \
@@ -49,10 +50,15 @@ HEADERS = \
qwebengineurlrequestinfo_p.h \
qwebengineurlrequestjob.h \
qwebengineurlscheme.h \
- qwebengineurlschemehandler.h
+ qwebengineurlschemehandler.h \
+ qwebenginecontextmenurequest.h \
+ qwebenginecontextmenurequest_p.h \
+ qwebenginedownloadrequest.h \
+ qwebenginedownloadrequest_p.h
SOURCES = \
qtwebenginecoreglobal.cpp \
+ qwebenginecertificateerror.cpp \
qwebengineclientcertificatestore.cpp \
qwebenginecookiestore.cpp \
qwebenginefindtextresult.cpp \
@@ -64,13 +70,9 @@ SOURCES = \
qwebengineurlrequestinfo.cpp \
qwebengineurlrequestjob.cpp \
qwebengineurlscheme.cpp \
- qwebengineurlschemehandler.cpp
-
-### Qt6 Remove this workaround
-unix:!isEmpty(QMAKE_LFLAGS_VERSION_SCRIPT):!static {
- SOURCES += qtbug-60565.cpp \
- qtbug-61521.cpp
-}
+ qwebengineurlschemehandler.cpp \
+ qwebenginecontextmenurequest.cpp \
+ qwebenginedownloadrequest.cpp
# Chromium headers included are not remotely clean
CONFIG -= warning_clean
diff --git a/src/core/api/qtbug-60565.cpp b/src/core/api/qtbug-60565.cpp
deleted file mode 100644
index f48a2a701..000000000
--- a/src/core/api/qtbug-60565.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
-**
-** 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.
-**
-** $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 <new>
-#include <unistd.h>
-
-#if defined(__LP64__)
-# define SIZE_T_MANGLING "m"
-#else
-# define SIZE_T_MANGLING "j"
-#endif
-
-#define SHIM_ALIAS_SYMBOL(fn) __attribute__((weak, alias(#fn)))
-#define SHIM_HIDDEN __attribute__ ((visibility ("hidden")))
-
-extern "C" {
-
-__asm__(".symver __ShimCppNew, _Znw" SIZE_T_MANGLING "@Qt_5");
-void* __ShimCppNew(size_t size)
- SHIM_ALIAS_SYMBOL(ShimCppNew);
-
-__asm__(".symver __ShimCppDelete, _ZdlPv@Qt_5");
-void __ShimCppDelete(void* address)
- SHIM_ALIAS_SYMBOL(ShimCppDelete);
-
-__asm__(".symver __ShimCppNewArray, _Zna" SIZE_T_MANGLING "@Qt_5");
-void* __ShimCppNewArray(size_t size)
- SHIM_ALIAS_SYMBOL(ShimCppNewArray);
-
-__asm__(".symver __ShimCppDeleteArray, _ZdaPv@Qt_5");
-void __ShimCppDeleteArray(void* address)
- SHIM_ALIAS_SYMBOL(ShimCppDeleteArray);
-
-__asm__(".symver __ShimCppNewNoThrow, _Znw" SIZE_T_MANGLING "RKSt9nothrow_t@Qt_5");
-void *__ShimCppNewNoThrow(size_t size, const std::nothrow_t&) noexcept
- SHIM_ALIAS_SYMBOL(ShimCppNewNoThrow);
-
-__asm__(".symver __ShimCppNewArrayNoThrow, _Zna" SIZE_T_MANGLING "RKSt9nothrow_t@Qt_5");
-void *__ShimCppNewArrayNoThrow(size_t size, const std::nothrow_t&) noexcept
- SHIM_ALIAS_SYMBOL(ShimCppNewArrayNoThrow);
-
-__asm__(".symver __ShimCppDeleteNoThrow, _ZdlPvRKSt9nothrow_t@Qt_5");
-void __ShimCppDeleteNoThrow(void* address, const std::nothrow_t&) noexcept
- SHIM_ALIAS_SYMBOL(ShimCppDeleteNoThrow);
-
-__asm__(".symver __ShimCppDeleteArrayNoThrow, _ZdaPvRKSt9nothrow_t@Qt_5");
-void __ShimCppDeleteArrayNoThrow(void* address, const std::nothrow_t&) noexcept
- SHIM_ALIAS_SYMBOL(ShimCppDeleteArrayNoThrow);
-
-static void* __shimCppNew(size_t size);
-static void* __shimCppNewArray(size_t size);
-static void __shimCppDelete(void *address);
-static void __shimCppDeleteArray(void *address);
-
-SHIM_HIDDEN void* ShimCppNew(size_t size) {
- return __shimCppNew(size);
-}
-
-SHIM_HIDDEN void* ShimCppNewNoThrow(size_t size, const std::nothrow_t&) noexcept {
- return __shimCppNew(size);
-}
-
-SHIM_HIDDEN void* ShimCppNewArray(size_t size) {
- return __shimCppNewArray(size);
-}
-
-SHIM_HIDDEN void* ShimCppNewArrayNoThrow(size_t size, const std::nothrow_t&) noexcept {
- return __shimCppNewArray(size);
-}
-
-SHIM_HIDDEN void ShimCppDelete(void* address) {
- __shimCppDelete(address);
-}
-
-SHIM_HIDDEN void ShimCppDeleteNoThrow(void* address, const std::nothrow_t&) noexcept {
- __shimCppDelete(address);
-}
-
-SHIM_HIDDEN void ShimCppDeleteArray(void* address) {
- __shimCppDeleteArray(address);
-}
-
-SHIM_HIDDEN void ShimCppDeleteArrayNoThrow(void* address, const std::nothrow_t&) noexcept {
- __shimCppDeleteArray(address);
-}
-} // extern "C"
-
-static void* __shimCppNew(size_t size) {
- return operator new(size);
-}
-
-static void* __shimCppNewArray(size_t size) {
- return operator new[](size);
-}
-
-static void __shimCppDelete(void* address) {
- operator delete(address);
-}
-
-static void __shimCppDeleteArray(void* address) {
- operator delete[](address);
-}
diff --git a/src/core/api/qtbug-61521.cpp b/src/core/api/qtbug-61521.cpp
deleted file mode 100644
index 002a1af22..000000000
--- a/src/core/api/qtbug-61521.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/****************************************************************************
-**
-** 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.
-**
-** $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 <stdlib.h>
-#include <malloc.h>
-
-#define SHIM_ALIAS_SYMBOL(fn) __attribute__((weak, alias(#fn)))
-#define SHIM_SYMBOL_VERSION(fn) __asm__(".symver __" #fn "," #fn "@Qt_5")
-#define SHIM_HIDDEN __attribute__ ((visibility ("hidden")))
-
-extern "C" {
-
-SHIM_SYMBOL_VERSION(malloc);
-void* __malloc(size_t size)
- SHIM_ALIAS_SYMBOL(ShimMalloc);
-
-SHIM_SYMBOL_VERSION(free);
-void __free(void* ptr)
- SHIM_ALIAS_SYMBOL(ShimFree);
-
-SHIM_SYMBOL_VERSION(realloc);
-void* __realloc(void* ptr, size_t size)
- SHIM_ALIAS_SYMBOL(ShimRealloc);
-
-SHIM_SYMBOL_VERSION(calloc);
-void* __calloc(size_t n, size_t size)
- SHIM_ALIAS_SYMBOL(ShimCalloc);
-
-SHIM_SYMBOL_VERSION(cfree);
-void __cfree(void* ptr)
- SHIM_ALIAS_SYMBOL(ShimCFree);
-
-SHIM_SYMBOL_VERSION(memalign);
-void* __memalign(size_t align, size_t s)
- SHIM_ALIAS_SYMBOL(ShimMemalign);
-
-SHIM_SYMBOL_VERSION(valloc);
-void* __valloc(size_t size)
- SHIM_ALIAS_SYMBOL(ShimValloc);
-
-SHIM_SYMBOL_VERSION(pvalloc);
-void* __pvalloc(size_t size)
- SHIM_ALIAS_SYMBOL(ShimPvalloc);
-
-SHIM_SYMBOL_VERSION(posix_memalign);
-int __posix_memalign(void** r, size_t a, size_t s)
- SHIM_ALIAS_SYMBOL(ShimPosixMemalign);
-
-SHIM_HIDDEN void* ShimMalloc(size_t size) {
- return malloc(size);
-}
-
-SHIM_HIDDEN void ShimFree(void* ptr) {
- free(ptr);
-}
-
-SHIM_HIDDEN void* ShimRealloc(void* ptr, size_t size) {
- return realloc(ptr,size);
-}
-
-SHIM_HIDDEN void* ShimCalloc(size_t n, size_t size) {
- return calloc(n,size);
-}
-
-SHIM_HIDDEN void ShimCFree(void* ptr) {
- free(ptr);
-}
-
-SHIM_HIDDEN void* ShimMemalign(size_t align, size_t s) {
- return memalign(align,s);
-}
-
-SHIM_HIDDEN void* ShimValloc(size_t size) {
- return valloc(size);
-}
-
-SHIM_HIDDEN void* ShimPvalloc(size_t size) {
- return pvalloc(size);
-}
-
-SHIM_HIDDEN int ShimPosixMemalign(void** r, size_t a, size_t s) {
- return posix_memalign(r,a,s);
-}
-} // extern "C"
diff --git a/src/core/api/qtwebenginecoreglobal.cpp b/src/core/api/qtwebenginecoreglobal.cpp
index 3c9387a10..0e0c4b63b 100644
--- a/src/core/api/qtwebenginecoreglobal.cpp
+++ b/src/core/api/qtwebenginecoreglobal.cpp
@@ -105,83 +105,104 @@ Q_WEBENGINECORE_PRIVATE_EXPORT void initialize()
qputenv("QT_MAC_PRO_WEBENGINE_WORKAROUND", "1");
#endif
// No need to override the shared context if QApplication already set one (e.g with Qt::AA_ShareOpenGLContexts).
- if (qt_gl_global_share_context())
- return;
+ if (!qt_gl_global_share_context()) {
- QCoreApplication *app = QCoreApplication::instance();
- if (!app) {
- qFatal("QtWebEngine::initialize() but no core application instance.");
- return;
- }
-
- // Bail out silently if the user did not construct a QGuiApplication.
- if (!qobject_cast<QGuiApplication *>(app))
- return;
-
- if (app->thread() != QThread::currentThread()) {
- qFatal("QtWebEngine::initialize() must be called from the Qt gui thread.");
- return;
- }
+ QCoreApplication *app = QCoreApplication::instance();
+ if (!app) {
+ qFatal("QtWebEngine::initialize() but no core application instance.");
+ return;
+ }
- if (shareContext)
- return;
+ // Bail out silently if the user did not construct a QGuiApplication.
+ if (!qobject_cast<QGuiApplication *>(app))
+ return;
- shareContext = new QOpenGLContext;
- QSurfaceFormat format = QSurfaceFormat::defaultFormat();
-// format.setOption(QSurfaceFormat::ResetNotification);
+ if (app->thread() != QThread::currentThread()) {
+ qFatal("QtWebEngine::initialize() must be called from the Qt gui thread.");
+ return;
+ }
-#ifdef Q_OS_MACOS
- if (format == QSurfaceFormat()) {
- QOpenGLContext testContext;
-
- // Chromium turns off OpenGL for CoreProfiles with versions < 4.1
- // The newest Mac that only supports 3.3 was released in Mid 2011,
- // so it should be safe to request 4.1, but we still double check it
- // works in order not to set an invalid default surface format.
- format.setVersion(4, 1);
- format.setProfile(QSurfaceFormat::CoreProfile);
-
- testContext.setFormat(format);
- if (testContext.create()) {
- QOffscreenSurface surface;
- surface.setFormat(format);
- surface.create();
-
- if (testContext.makeCurrent(&surface)) {
- // The Cocoa QPA integration allows sharing between OpenGL 3.2 and 4.1 contexts,
- // which means even though we requested a 4.1 context, if we only get a 3.2 context,
- // it will still work an Chromium will not black list it.
- if (testContext.format().version() >= qMakePair(3, 2) &&
- testContext.format().profile() == QSurfaceFormat::CoreProfile &&
- !isCurrentContextSoftware()) {
- QSurfaceFormat::setDefaultFormat(format);
- } else {
- qWarning("The available OpenGL surface format was either not version 3.2 or higher or not a Core Profile.\n"
- "Chromium on macOS will fall back to software rendering in this case.\n"
- "Hardware acceleration and features such as WebGL will not be available.");
- format = QSurfaceFormat::defaultFormat();
- }
- testContext.doneCurrent();
+ if (shareContext)
+ return;
+
+ shareContext = new QOpenGLContext;
+ QSurfaceFormat format = QSurfaceFormat::defaultFormat();
+
+#if defined(Q_OS_MACOS)
+ if (format == QSurfaceFormat()) {
+ QOpenGLContext testContext;
+
+ // Chromium turns off OpenGL for CoreProfiles with versions < 4.1
+ // The newest Mac that only supports 3.3 was released in Mid 2011,
+ // so it should be safe to request 4.1, but we still double check it
+ // works in order not to set an invalid default surface format.
+ format.setVersion(4, 1);
+ format.setProfile(QSurfaceFormat::CoreProfile);
+
+ testContext.setFormat(format);
+ if (testContext.create()) {
+ QOffscreenSurface surface;
+ surface.setFormat(format);
+ surface.create();
+
+ if (testContext.makeCurrent(&surface)) {
+ // The Cocoa QPA integration allows sharing between OpenGL 3.2 and 4.1 contexts,
+ // which means even though we requested a 4.1 context, if we only get a 3.2
+ // context, it will still work an Chromium will not black list it.
+ if (testContext.format().version() >= qMakePair(3, 2)
+ && testContext.format().profile() == QSurfaceFormat::CoreProfile
+ && !isCurrentContextSoftware()) {
+ QSurfaceFormat::setDefaultFormat(format);
+ } else {
+ qWarning("The available OpenGL surface format was either not version 3.2 "
+ "or higher or not a Core Profile.\n"
+ "Chromium on macOS will fall back to software rendering in this "
+ "case.\n"
+ "Hardware acceleration and features such as WebGL will not be "
+ "available.");
+ format = QSurfaceFormat::defaultFormat();
+ }
+ testContext.doneCurrent();
+ }
+ surface.destroy();
+ }
+ } else {
+ // The user explicitly requested a specific surface format that does not fit Chromium's
+ // requirements. Warn them about this.
+ if (format.version() < qMakePair(3, 2)
+ || format.profile() != QSurfaceFormat::CoreProfile) {
+ qWarning("An OpenGL surfcace format was requested that is either not version 3.2 "
+ "or higher or a not Core Profile.\n"
+ "Chromium on macOS will fall back to software rendering in this case.\n"
+ "Hardware acceleration and features such as WebGL will not be available.");
}
- surface.destroy();
- }
- } else {
- // The user explicitly requested a specific surface format that does not fit Chromium's requirements. Warn them about this.
- if (format.version() < qMakePair(3,2) || format.profile() != QSurfaceFormat::CoreProfile) {
- qWarning("An OpenGL surfcace format was requested that is either not version 3.2 or higher or a not Core Profile.\n"
- "Chromium on macOS will fall back to software rendering in this case.\n"
- "Hardware acceleration and features such as WebGL will not be available.");
}
- }
#endif
- shareContext->setFormat(format);
- shareContext->create();
- qAddPostRoutine(deleteShareContext);
- qt_gl_set_global_share_context(shareContext);
+ shareContext->setFormat(format);
+ shareContext->create();
+ qAddPostRoutine(deleteShareContext);
+ qt_gl_set_global_share_context(shareContext);
+
+ // Classes like QOpenGLWidget check for the attribute
+ app->setAttribute(Qt::AA_ShareOpenGLContexts);
+ }
+
+#if defined(Q_OS_MACOS)
+ // Check that the default QSurfaceFormat OpenGL profile is compatible with the global OpenGL
+ // shared context profile, otherwise this could lead to a nasty crash.
+ QSurfaceFormat sharedFormat = qt_gl_global_share_context()->format();
+ QSurfaceFormat defaultFormat = QSurfaceFormat::defaultFormat();
+
+ if (defaultFormat.profile() != sharedFormat.profile()
+ && defaultFormat.profile() == QSurfaceFormat::CoreProfile
+ && defaultFormat.version() >= qMakePair(3, 2)) {
+ qFatal("QWebEngine: Default QSurfaceFormat OpenGL profile is not compatible with the "
+ "global shared context OpenGL profile. Please make sure you set a compatible "
+ "QSurfaceFormat before the QtGui application instance is created.");
+ }
+#endif
- // Classes like QOpenGLWidget check for the attribute
- app->setAttribute(Qt::AA_ShareOpenGLContexts);
#endif // QT_CONFIG(opengl)
}
} // namespace QtWebEngineCore
diff --git a/src/webenginewidgets/api/qwebenginecertificateerror.cpp b/src/core/api/qwebenginecertificateerror.cpp
index d86019af8..33f63f2da 100644
--- a/src/webenginewidgets/api/qwebenginecertificateerror.cpp
+++ b/src/core/api/qwebenginecertificateerror.cpp
@@ -47,67 +47,18 @@ QT_BEGIN_NAMESPACE
\class QWebEngineCertificateError
\brief The QWebEngineCertificateError class provides information about a certificate error.
\since 5.4
- \inmodule QtWebEngineWidgets
+ \inmodule QtWebEngineCore
Provides information about a certificate error. This class is used as a parameter of
QWebEnginePage::certificateError().
*/
-class QWebEngineCertificateErrorPrivate : public QSharedData {
-public:
- QWebEngineCertificateErrorPrivate(int error, QUrl url, bool overridable, QString errorDescription);
-
- ~QWebEngineCertificateErrorPrivate() {
- if (deferred && !answered)
- rejectCertificate();
- }
-
- void resolveError(bool accept) {
- if (answered)
- return;
- answered = true;
- if (overridable) {
- if (auto ctl = controller.lock())
- ctl->accept(accept);
- }
- }
-
- void ignoreCertificateError() { resolveError(true); }
- void rejectCertificate() { resolveError(false); }
-
- QWebEngineCertificateError::Error error;
- QUrl url;
- bool overridable;
- QString errorDescription;
- QList<QSslCertificate> certificateChain;
-
- bool answered = false, deferred = false;
- QWeakPointer<CertificateErrorController> controller;
-
- Q_DISABLE_COPY(QWebEngineCertificateErrorPrivate)
-};
-
-QWebEngineCertificateErrorPrivate::QWebEngineCertificateErrorPrivate(int error, QUrl url, bool overridable, QString errorDescription)
- : error(QWebEngineCertificateError::Error(error))
- , url(url)
- , overridable(overridable)
- , errorDescription(errorDescription)
-{ }
-
-/*! \internal
-*/
-QWebEngineCertificateError::QWebEngineCertificateError(int error, QUrl url, bool overridable, QString errorDescription)
- : d(new QWebEngineCertificateErrorPrivate(error, url, overridable, errorDescription))
-{ }
-
/*! \internal
*/
-QWebEngineCertificateError::QWebEngineCertificateError(const QSharedPointer<CertificateErrorController> &controller)
- : d(new QWebEngineCertificateErrorPrivate(controller->error(), controller->url(),
- controller->overridable(), controller->errorString()))
+QWebEngineCertificateError::QWebEngineCertificateError(
+ const QSharedPointer<QtWebEngineCore::CertificateErrorController> &controller)
+ : d(controller)
{
- d->controller = controller;
- d->certificateChain = controller->certificateChain();
}
QWebEngineCertificateError::QWebEngineCertificateError(const QWebEngineCertificateError &) = default;
@@ -116,13 +67,10 @@ QWebEngineCertificateError& QWebEngineCertificateError::operator=(const QWebEngi
/*! \internal
*/
-QWebEngineCertificateError::~QWebEngineCertificateError()
-{
-
-}
+QWebEngineCertificateError::~QWebEngineCertificateError() = default;
/*!
- \enum QWebEngineCertificateError::Error
+ \enum QWebEngineCertificateError::Type
This enum describes the type of certificate error encountered.
@@ -155,31 +103,31 @@ QWebEngineCertificateError::~QWebEngineCertificateError()
/*!
Returns whether this error can be overridden and accepted.
- \sa error(), errorDescription()
+ \sa error(), description()
*/
bool QWebEngineCertificateError::isOverridable() const
{
- return d->overridable;
+ return d->overridable();
}
/*!
Returns the URL that triggered the error.
- \sa error(), errorDescription()
+ \sa error(), description()
*/
QUrl QWebEngineCertificateError::url() const
{
- return d->url;
+ return d->url();
}
/*!
Returns the type of the error.
- \sa errorDescription(), isOverridable()
+ \sa description(), isOverridable()
*/
-QWebEngineCertificateError::Error QWebEngineCertificateError::error() const
+QWebEngineCertificateError::Type QWebEngineCertificateError::type() const
{
- return d->error;
+ return d->error();
}
/*!
@@ -187,9 +135,9 @@ QWebEngineCertificateError::Error QWebEngineCertificateError::error() const
\sa error(), url(), isOverridable()
*/
-QString QWebEngineCertificateError::errorDescription() const
+QString QWebEngineCertificateError::description() const
{
- return d->errorDescription;
+ return d->errorString();
}
/*!
@@ -197,9 +145,9 @@ QString QWebEngineCertificateError::errorDescription() const
Marks the certificate error for delayed handling.
- This function should be called when there is a need to postpone the decision whether to ignore a
- certificate error, for example, while waiting for user input. When called, the function pauses the
- URL request until ignoreCertificateError() or rejectCertificate() is called.
+ This function should be called when there is a need to postpone the decision whether to accept a
+ certificate, for example, while waiting for user input. When called, the function pauses the
+ URL request until acceptCertificate() or rejectCertificate() is called.
\note It is only possible to defer overridable certificate errors.
@@ -207,26 +155,15 @@ QString QWebEngineCertificateError::errorDescription() const
*/
void QWebEngineCertificateError::defer()
{
- if (isOverridable())
- d->deferred = true;
+ d->defer();
}
/*!
\since 5.14
- Returns whether the decision for error handling was delayed and the URL load was halted.
+ Accepts the certificate and continues the loading of the requested URL.
*/
-bool QWebEngineCertificateError::deferred() const
-{
- return d->deferred;
-}
-
-/*!
- \since 5.14
-
- Ignores the certificate error and continues the loading of the requested URL.
-*/
-void QWebEngineCertificateError::ignoreCertificateError()
+void QWebEngineCertificateError::acceptCertificate()
{
d->ignoreCertificateError();
}
@@ -244,23 +181,13 @@ void QWebEngineCertificateError::rejectCertificate()
/*!
\since 5.14
- Returns \c true if the error was explicitly rejected or ignored.
-*/
-bool QWebEngineCertificateError::answered() const
-{
- return d->answered;
-}
-
-/*!
- \since 5.14
-
Returns the peer's chain of digital certificates.
Chain starts with the peer's immediate certificate and ending with the CA's certificate.
*/
QList<QSslCertificate> QWebEngineCertificateError::certificateChain() const
{
- return d->certificateChain;
+ return d->certificateChain();
}
QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginecertificateerror.h b/src/core/api/qwebenginecertificateerror.h
index a32f7ab8e..3cf2d9990 100644
--- a/src/webenginewidgets/api/qwebenginecertificateerror.h
+++ b/src/core/api/qwebenginecertificateerror.h
@@ -40,24 +40,33 @@
#ifndef QWEBENGINECERTIFICATEERROR_H
#define QWEBENGINECERTIFICATEERROR_H
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
+#include <QtWebEngineCore/qtwebenginecoreglobal.h>
#include <QtCore/qsharedpointer.h>
#include <QtCore/qurl.h>
#include <QtNetwork/QSslCertificate>
+namespace QtWebEngineCore {
+class WebContentsDelegateQt;
+class CertificateErrorController;
+}
+
QT_BEGIN_NAMESPACE
-class CertificateErrorController;
-class QWebEngineCertificateErrorPrivate;
+class Q_WEBENGINECORE_EXPORT QWebEngineCertificateError {
+ Q_GADGET
+ Q_PROPERTY(QUrl url READ url CONSTANT FINAL)
+ Q_PROPERTY(Type type READ type CONSTANT FINAL)
+ Q_PROPERTY(QString description READ description CONSTANT FINAL)
+ Q_PROPERTY(bool overridable READ isOverridable CONSTANT FINAL)
-class QWEBENGINEWIDGETS_EXPORT QWebEngineCertificateError {
public:
- QWebEngineCertificateError(int error, QUrl url, bool overridable, QString errorDescription);
+ QWebEngineCertificateError(const QWebEngineCertificateError &other);
+ QWebEngineCertificateError& operator=(const QWebEngineCertificateError &other);
~QWebEngineCertificateError();
- // Keep this identical to CertificateErrorController::CertificateError, or add mapping layer.
- enum Error {
+ // Keep this identical to NET_ERROR in net_error_list.h, or add mapping layer.
+ enum Type {
SslPinnedKeyNotInCertificateChain = -150,
CertificateCommonNameInvalid = -200,
CertificateDateInvalid = -201,
@@ -73,32 +82,31 @@ public:
CertificateNameConstraintViolation = -212,
CertificateValidityTooLong = -213,
CertificateTransparencyRequired = -214,
+ CertificateSymantecLegacy = -215,
CertificateKnownInterceptionBlocked = -217,
};
+ Q_ENUM(Type)
- Error error() const;
+ Type type() const;
QUrl url() const;
bool isOverridable() const;
- QString errorDescription() const;
+ QString description() const;
- QWebEngineCertificateError(const QWebEngineCertificateError &other);
- QWebEngineCertificateError& operator=(const QWebEngineCertificateError &other);
-
- void defer();
- bool deferred() const;
-
- void rejectCertificate();
- void ignoreCertificateError();
- bool answered() const;
+ Q_INVOKABLE void defer();
+ Q_INVOKABLE void rejectCertificate();
+ Q_INVOKABLE void acceptCertificate();
QList<QSslCertificate> certificateChain() const;
private:
- friend class QWebEnginePagePrivate;
- QWebEngineCertificateError(const QSharedPointer<CertificateErrorController> &controller);
- QExplicitlySharedDataPointer<QWebEngineCertificateErrorPrivate> d;
+ friend class QtWebEngineCore::WebContentsDelegateQt;
+ QWebEngineCertificateError(
+ const QSharedPointer<QtWebEngineCore::CertificateErrorController> &controller);
+ QSharedPointer<QtWebEngineCore::CertificateErrorController> d;
};
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QWebEngineCertificateError)
+
#endif // QWEBENGINECERTIFICATEERROR_H
diff --git a/src/core/api/qwebengineclientcertificatestore.cpp b/src/core/api/qwebengineclientcertificatestore.cpp
index 84f273328..462a63b26 100644
--- a/src/core/api/qwebengineclientcertificatestore.cpp
+++ b/src/core/api/qwebengineclientcertificatestore.cpp
@@ -88,9 +88,9 @@ void QWebEngineClientCertificateStore::add(const QSslCertificate &certificate, c
Returns an empty list if the store does not contain any certificates.
*/
-QVector<QSslCertificate> QWebEngineClientCertificateStore::certificates() const
+QList<QSslCertificate> QWebEngineClientCertificateStore::certificates() const
{
- QVector<QSslCertificate> certificateList;
+ QList<QSslCertificate> certificateList;
for (auto data : qAsConst(m_storeData->extraCerts))
certificateList.append(data->certificate);
return certificateList;
diff --git a/src/core/api/qwebengineclientcertificatestore.h b/src/core/api/qwebengineclientcertificatestore.h
index a4c83bb2e..a9282f0fb 100644
--- a/src/core/api/qwebengineclientcertificatestore.h
+++ b/src/core/api/qwebengineclientcertificatestore.h
@@ -41,8 +41,10 @@
#define QWEBENGINECLIENTCERTIFICATESTORE_H
#include <QtWebEngineCore/qtwebenginecoreglobal.h>
+#include <QtNetwork/qtnetwork-config.h>
-#include <QtCore/qvector.h>
+#if QT_CONFIG(ssl)
+#include <QtCore/qlist.h>
#include <QtNetwork/qsslcertificate.h>
#include <QtNetwork/qsslkey.h>
@@ -53,13 +55,11 @@ class ProfileAdapter;
QT_BEGIN_NAMESPACE
-#if QT_CONFIG(ssl)
-
class Q_WEBENGINECORE_EXPORT QWebEngineClientCertificateStore {
public:
void add(const QSslCertificate &certificate, const QSslKey &privateKey);
- QVector<QSslCertificate> certificates() const;
+ QList<QSslCertificate> certificates() const;
void remove(const QSslCertificate &certificate);
void clear();
@@ -72,8 +72,7 @@ private:
QtWebEngineCore::ClientCertificateStoreData *m_storeData;
};
-#endif // QT_CONFIG(ssl)
-
QT_END_NAMESPACE
+#endif // QT_CONFIG(ssl)
#endif // QWebEngineClientCertificateStore_H
diff --git a/src/core/api/qwebenginecontextmenurequest.cpp b/src/core/api/qwebenginecontextmenurequest.cpp
new file mode 100644
index 000000000..62a328b72
--- /dev/null
+++ b/src/core/api/qwebenginecontextmenurequest.cpp
@@ -0,0 +1,296 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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 "qwebenginecontextmenurequest.h"
+#include "qwebenginecontextmenurequest_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QWebEngineContextMenuRequest
+ \since 6.0
+ \brief The QWebEngineContextMenuRequest class provides request for populating or extending a context menu with actions.
+
+ \inmodule QtWebEngineCore
+
+ QWebEngineContextMenuRequest is returned by QWebEngineView::lastContextMenuRequest() after a context menu event,
+ and contains information about where the context menu event took place. This is also in the context
+ in which any context specific QWebEnginePage::WebAction will be performed.
+*/
+
+/*!
+ \enum QWebEngineContextMenuRequest::MediaType
+ \readonly
+ \since 6.0
+
+ This enum describes the media type of the context menu request if any.
+
+ \value MediaTypeNone The context is not a media type.
+ \value MediaTypeImage The context is an image element.
+ \value MediaTypeVideo The context is a video element.
+ \value MediaTypeAudio The context is an audio element.
+ \value MediaTypeCanvas The context is a canvas element.
+ \value MediaTypeFile The context is a file.
+ \value MediaTypePlugin The context is a plugin element.
+*/
+
+/*!
+ \enum QWebEngineContextMenuRequest::EditFlag
+ \readonly
+ \since 6.0
+
+ The available edit operations in the current context menu request.
+
+ \value CanUndo Undo is available.
+ \value CanRedo Redo is available.
+ \value CanCut Cut is available.
+ \value CanCopy Copy is available.
+ \value CanPaste Paste is available.
+ \value CanDelete Delete is available.
+ \value CanSelectAll Select All is available.
+ \value CanTranslate Translate is available.
+ \value CanEditRichly Context is richly editable.
+*/
+
+/*!
+ \enum QWebEngineContextMenuRequest::MediaFlag
+ \readonly
+ \since 6.0
+
+ The current media element's status and its available operations.
+ \c MediaNone if the selected web page content is not a media element.
+
+ \value MediaInError An error occurred.
+ \value MediaPaused Media is paused.
+ \value MediaMuted Media is muted.
+ \value MediaLoop Media can be looped.
+ \value MediaCanSave Media can be saved.
+ \value MediaHasAudio Media has audio.
+ \value MediaCanToggleControls Media can show controls.
+ \value MediaControls Media controls are shown.
+ \value MediaCanPrint Media is printable.
+ \value MediaCanRotate Media is rotatable.
+*/
+
+/*!
+ \internal
+*/
+QWebEngineContextMenuRequest::QWebEngineContextMenuRequest(
+ QWebEngineContextMenuRequestPrivate *request)
+ : d(request)
+{
+}
+
+/*!
+ Destroys the context menu request.
+*/
+QWebEngineContextMenuRequest::~QWebEngineContextMenuRequest() = default;
+
+/*!
+ Returns the position of the context menu request, usually the mouse
+ position where the context menu event was triggered.
+*/
+QPoint QWebEngineContextMenuRequest::position() const
+{
+ return d->m_position;
+}
+
+/*!
+ Returns the selected text of the context menu request.
+*/
+QString QWebEngineContextMenuRequest::selectedText() const
+{
+ return d->m_selectedText;
+}
+
+/*!
+ Returns the text of a link if the context menu request was requested for a link.
+*/
+QString QWebEngineContextMenuRequest::linkText() const
+{
+ return d->m_linkText;
+}
+
+/*!
+ Returns the URL of a link if the menu context request is a link.
+ It is not guaranteed to be a valid URL.
+*/
+QUrl QWebEngineContextMenuRequest::linkUrl() const
+{
+ return d->m_unfilteredLinkUrl;
+}
+
+/*!
+ If the context menu request is a media element, returns the URL of that media.
+*/
+QUrl QWebEngineContextMenuRequest::mediaUrl() const
+{
+ return d->m_mediaUrl;
+}
+
+/*!
+ Returns the type of the media element or \c MediaTypeNone
+ if the context menu requestis not a media element.
+*/
+QWebEngineContextMenuRequest::MediaType QWebEngineContextMenuRequest::mediaType() const
+{
+ return static_cast<QWebEngineContextMenuRequest::MediaType>(d->m_mediaType);
+}
+
+/*!
+ Returns \c true if the context menu request is editable by the user;
+ otherwise returns \c false.
+*/
+bool QWebEngineContextMenuRequest::isContentEditable() const
+{
+ return d->m_isEditable;
+}
+
+/*!
+ If the menu context request is a word considered misspelled by the spell-checker,
+ returns the misspelled word.
+
+ For possible replacements of the word, see spellCheckerSuggestions().
+*/
+QString QWebEngineContextMenuRequest::misspelledWord() const
+{
+ return d->m_misspelledWord;
+}
+
+
+/*!
+ If the menu context request is a word considered misspelled by the spell-checker,
+ returns a list of suggested replacements for misspelledWord().
+*/
+QStringList QWebEngineContextMenuRequest::spellCheckerSuggestions() const
+{
+ return d->m_spellCheckerSuggestions;
+}
+
+/*!
+ TODO: needs api in page
+*/
+bool QWebEngineContextMenuRequest::isAccepted() const
+{
+ return d->m_accepted;
+}
+
+/*!
+ TODO: needs api in page
+*/
+void QWebEngineContextMenuRequest::setAccepted(bool accepted)
+{
+ d->m_accepted = accepted;
+}
+
+/*!
+ Returns the current media element's status and its available operations.
+ \c MediaNone if the selected web page content is not a media element.
+*/
+QWebEngineContextMenuRequest::MediaFlags QWebEngineContextMenuRequest::mediaFlags() const
+{
+ return static_cast<QWebEngineContextMenuRequest::MediaFlags>(d->m_mediaFlags);
+}
+
+/*!
+ Returns the available edit operations in the current context
+ or \c CanDoNone if no actions are available.
+*/
+QWebEngineContextMenuRequest::EditFlags QWebEngineContextMenuRequest::editFlags() const
+{
+ return static_cast<QWebEngineContextMenuRequest::EditFlags>(d->m_editFlags);
+}
+
+/*!
+ \internal
+*/
+QUrl QWebEngineContextMenuRequest::filteredLinkUrl() const
+{
+ return d->m_filteredLinkUrl;
+}
+
+/*!
+ \internal
+*/
+QString QWebEngineContextMenuRequest::altText() const
+{
+ return d->m_altText;
+}
+
+/*!
+ \internal
+*/
+QString QWebEngineContextMenuRequest::titleText() const
+{
+ return d->m_titleText;
+}
+
+/*!
+ \internal
+*/
+QUrl QWebEngineContextMenuRequest::referrerUrl() const
+{
+ return !d->m_frameUrl.isEmpty() ? d->m_frameUrl : d->m_pageUrl;
+}
+
+/*!
+ \internal
+*/
+QtWebEngineCore::ReferrerPolicy QWebEngineContextMenuRequest::referrerPolicy() const
+{
+ return d->m_referrerPolicy;
+}
+
+/*!
+ \internal
+*/
+QString QWebEngineContextMenuRequest::suggestedFileName() const
+{
+ return d->m_suggestedFileName;
+}
+
+/*!
+ \internal
+*/
+bool QWebEngineContextMenuRequest::hasImageContent() const
+{
+ return d->m_hasImageContent;
+}
+
+QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebenginecontextmenurequest_p.h b/src/core/api/qwebenginecontextmenurequest.h
index bc50eccb8..bc8095dc9 100644
--- a/src/webengine/api/qquickwebenginecontextmenurequest_p.h
+++ b/src/core/api/qwebenginecontextmenurequest.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
@@ -37,31 +37,39 @@
**
****************************************************************************/
-#ifndef QQUICKWEBENGINECONTEXTMENUREQUEST_H
-#define QQUICKWEBENGINECONTEXTMENUREQUEST_H
+#ifndef QWEBENGINECONTEXTMENUREQUEST_H
+#define QWEBENGINECONTEXTMENUREQUEST_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 <QtWebEngine/private/qtwebengineglobal_p.h>
-#include <QtCore/QScopedPointer>
+#include <QtWebEngineCore/qtwebenginecoreglobal.h>
#include <QtCore/QObject>
#include <QtCore/QUrl>
+#include <QtCore/QPoint>
+#include <QScopedPointer>
namespace QtWebEngineCore {
- class WebEngineContextMenuData;
+class RenderViewContextMenuQt;
+class WebContentsViewQt;
+
+// Must match blink::WebReferrerPolicy
+enum class ReferrerPolicy {
+ Always,
+ Default,
+ NoReferrerWhenDowngrade,
+ Never,
+ Origin,
+ OriginWhenCrossOrigin,
+ NoReferrerWhenDowngradeOriginWhenCrossOrigin,
+ SameOrigin,
+ StrictOrigin,
+ Last = StrictOrigin,
+};
}
QT_BEGIN_NAMESPACE
-class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineContextMenuRequest: public QObject {
+class QWebEngineContextMenuRequestPrivate;
+class Q_WEBENGINECORE_EXPORT QWebEngineContextMenuRequest : public QObject
+{
Q_OBJECT
public:
enum MediaType {
@@ -106,8 +114,7 @@ public:
Q_DECLARE_FLAGS(EditFlags, EditFlag)
Q_FLAG(EditFlags)
- Q_PROPERTY(int x READ x CONSTANT FINAL)
- Q_PROPERTY(int y READ y CONSTANT FINAL)
+ Q_PROPERTY(QPoint position READ position CONSTANT FINAL)
Q_PROPERTY(QString selectedText READ selectedText CONSTANT FINAL)
Q_PROPERTY(QString linkText READ linkText CONSTANT FINAL)
Q_PROPERTY(QUrl linkUrl READ linkUrl CONSTANT FINAL)
@@ -120,9 +127,8 @@ public:
Q_PROPERTY(MediaFlags mediaFlags READ mediaFlags CONSTANT FINAL REVISION 1)
Q_PROPERTY(EditFlags editFlags READ editFlags CONSTANT FINAL REVISION 1)
- ~QQuickWebEngineContextMenuRequest();
- int x() const;
- int y() const;
+ virtual ~QWebEngineContextMenuRequest();
+ QPoint position() const;
QString selectedText() const;
QString linkText() const;
QUrl linkUrl() const;
@@ -137,14 +143,26 @@ public:
EditFlags editFlags() const;
private:
- QQuickWebEngineContextMenuRequest(const QtWebEngineCore::WebEngineContextMenuData &data, QObject *parent = nullptr);
- QScopedPointer<QtWebEngineCore::WebEngineContextMenuData> m_data;
- bool m_accepted;
- friend class QQuickWebEngineView;
+ QUrl filteredLinkUrl() const;
+ QString altText() const;
+ QString titleText() const;
+ QUrl referrerUrl() const;
+ QtWebEngineCore::ReferrerPolicy referrerPolicy() const;
+ bool hasImageContent() const;
+ QString suggestedFileName() const;
+
+private:
+ QWebEngineContextMenuRequest(QWebEngineContextMenuRequestPrivate *d);
+ QScopedPointer<QWebEngineContextMenuRequestPrivate> d;
+ friend class QtWebEngineCore::WebContentsViewQt;
+ friend class QtWebEngineCore::RenderViewContextMenuQt;
friend class QQuickWebEngineViewPrivate;
- Q_DISABLE_COPY(QQuickWebEngineContextMenuRequest)
+ friend class QQuickWebEngineView;
+ friend class ContextMenuRequestJSWrapper;
+ friend class QWebEngineViewPrivate;
+ friend class QWebEnginePage;
};
QT_END_NAMESPACE
-#endif // QQUICKWEBENGINECONTEXTMENUREQUEST_H
+#endif // QWEBENGINECONTEXTMENUREQUEST_H
diff --git a/src/core/certificate_error_controller_p.h b/src/core/api/qwebenginecontextmenurequest_p.h
index b0b0bc658..c7b98a871 100644
--- a/src/core/certificate_error_controller_p.h
+++ b/src/core/api/qwebenginecontextmenurequest_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef CERTIFICATE_ERROR_CONTROLLER_P_H
-#define CERTIFICATE_ERROR_CONTROLLER_P_H
+#ifndef QWEBENGINECONTEXTMENUREQUEST_P_H
+#define QWEBENGINECONTEXTMENUREQUEST_P_H
//
// W A R N I N G
@@ -51,29 +51,43 @@
// We mean it.
//
-#include "content/public/browser/content_browser_client.h"
-
-#include "certificate_error_controller.h"
+#include "qtwebenginecoreglobal_p.h"
+#include "qwebenginecontextmenurequest.h"
+#include <QPoint>
+#include <QUrl>
QT_BEGIN_NAMESPACE
-class CertificateErrorControllerPrivate {
+class QWebEngineContextMenuRequestPrivate
+{
public:
- CertificateErrorControllerPrivate(int cert_error, const net::SSLInfo& ssl_info, const GURL& request_url, bool main_frame, bool fatal_error, bool strict_enforcement, base::OnceCallback<void(content::CertificateRequestResultType)> callback);
-
- void accept(bool accepted);
-
- CertificateErrorController::CertificateError certError;
- const QUrl requestUrl;
- QDateTime validStart;
- QDateTime validExpiry;
- CertificateErrorController::ResourceType resourceType;
- bool fatalError;
- bool strictEnforcement;
- base::OnceCallback<void(content::CertificateRequestResultType)> callback;
- QList<QSslCertificate> certificateChain;
+ bool m_accepted = false;
+ bool m_hasImageContent = false;
+ bool m_isEditable = false;
+ bool m_isSpellCheckerEnabled = false;
+ uint m_mediaType = 0;
+ uint m_mediaFlags = 0;
+ uint m_editFlags = 0;
+ QPoint m_position;
+ QUrl m_filteredLinkUrl;
+ QUrl m_unfilteredLinkUrl;
+ QUrl m_mediaUrl;
+ QString m_altText;
+ QString m_linkText;
+ QString m_titleText;
+ QString m_selectedText;
+ QString m_suggestedFileName;
+ QString m_misspelledWord;
+ QStringList m_spellCheckerSuggestions;
+ QUrl m_pageUrl;
+ QUrl m_frameUrl;
+ QtWebEngineCore::ReferrerPolicy m_referrerPolicy = QtWebEngineCore::ReferrerPolicy::Default;
+ // Some likely candidates for future additions as we add support for the related actions:
+ // bool isImageBlocked;
+ // <enum tbd> mediaType;
+ // ...
};
QT_END_NAMESPACE
-#endif // CERTIFICATE_ERROR_CONTROLLER_P_H
+#endif
diff --git a/src/core/api/qwebenginecookiestore_p.h b/src/core/api/qwebenginecookiestore_p.h
index a79e2b095..e6fa245c2 100644
--- a/src/core/api/qwebenginecookiestore_p.h
+++ b/src/core/api/qwebenginecookiestore_p.h
@@ -56,7 +56,7 @@
#include "qwebenginecallback_p.h"
#include "qwebenginecookiestore.h"
-#include <QVector>
+#include <QList>
#include <QNetworkCookie>
#include <QUrl>
@@ -79,7 +79,7 @@ class Q_WEBENGINECORE_PRIVATE_EXPORT QWebEngineCookieStorePrivate {
public:
QtWebEngineCore::CallbackDirectory callbackDirectory;
std::function<bool(const QWebEngineCookieStore::FilterRequest &)> filterCallback;
- QVector<CookieData> m_pendingUserCookies;
+ QList<CookieData> m_pendingUserCookies;
quint64 m_nextCallbackId;
bool m_deleteSessionCookiesPending;
bool m_deleteAllCookiesPending;
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/core/api/qwebenginedownloadrequest.cpp
index 7366dbf59..bf4994a64 100644
--- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp
+++ b/src/core/api/qwebenginedownloadrequest.cpp
@@ -37,11 +37,10 @@
**
****************************************************************************/
-#include "qwebenginedownloaditem.h"
-#include "qwebenginedownloaditem_p.h"
+#include "qwebenginedownloadrequest.h"
+#include "qwebenginedownloadrequest_p.h"
#include "profile_adapter.h"
-#include "qwebengineprofile_p.h"
#include <QDir>
#include "QFileInfo"
@@ -50,65 +49,63 @@ QT_BEGIN_NAMESPACE
using QtWebEngineCore::ProfileAdapterClient;
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NoReason, QWebEngineDownloadItem::NoReason)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileFailed, QWebEngineDownloadItem::FileFailed)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileAccessDenied, QWebEngineDownloadItem::FileAccessDenied)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileNoSpace, QWebEngineDownloadItem::FileNoSpace)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileNameTooLong, QWebEngineDownloadItem::FileNameTooLong)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileTooLarge, QWebEngineDownloadItem::FileTooLarge)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileVirusInfected, QWebEngineDownloadItem::FileVirusInfected)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileTransientError, QWebEngineDownloadItem::FileTransientError)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileBlocked, QWebEngineDownloadItem::FileBlocked)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileSecurityCheckFailed, QWebEngineDownloadItem::FileSecurityCheckFailed)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileTooShort, QWebEngineDownloadItem::FileTooShort)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileHashMismatch, QWebEngineDownloadItem::FileHashMismatch)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkFailed, QWebEngineDownloadItem::NetworkFailed)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkTimeout, QWebEngineDownloadItem::NetworkTimeout)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkDisconnected, QWebEngineDownloadItem::NetworkDisconnected)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkServerDown, QWebEngineDownloadItem::NetworkServerDown)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkInvalidRequest, QWebEngineDownloadItem::NetworkInvalidRequest)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerFailed, QWebEngineDownloadItem::ServerFailed)
-//ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerNoRange, QWebEngineDownloadItem::ServerNoRange)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerBadContent, QWebEngineDownloadItem::ServerBadContent)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerUnauthorized, QWebEngineDownloadItem::ServerUnauthorized)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerCertProblem, QWebEngineDownloadItem::ServerCertProblem)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerForbidden, QWebEngineDownloadItem::ServerForbidden)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerUnreachable, QWebEngineDownloadItem::ServerUnreachable)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::UserCanceled, QWebEngineDownloadItem::UserCanceled)
-//ASSERT_ENUMS_MATCH(ProfileAdapterClient::UserShutdown, QWebEngineDownloadItem::UserShutdown)
-//ASSERT_ENUMS_MATCH(ProfileAdapterClient::Crash, QWebEngineDownloadItem::Crash)
-
-static inline QWebEngineDownloadItem::DownloadState toDownloadState(int state)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::NoReason, QWebEngineDownloadRequest::NoReason)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileFailed, QWebEngineDownloadRequest::FileFailed)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileAccessDenied, QWebEngineDownloadRequest::FileAccessDenied)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileNoSpace, QWebEngineDownloadRequest::FileNoSpace)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileNameTooLong, QWebEngineDownloadRequest::FileNameTooLong)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileTooLarge, QWebEngineDownloadRequest::FileTooLarge)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileVirusInfected, QWebEngineDownloadRequest::FileVirusInfected)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileTransientError, QWebEngineDownloadRequest::FileTransientError)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileBlocked, QWebEngineDownloadRequest::FileBlocked)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileSecurityCheckFailed, QWebEngineDownloadRequest::FileSecurityCheckFailed)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileTooShort, QWebEngineDownloadRequest::FileTooShort)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileHashMismatch, QWebEngineDownloadRequest::FileHashMismatch)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkFailed, QWebEngineDownloadRequest::NetworkFailed)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkTimeout, QWebEngineDownloadRequest::NetworkTimeout)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkDisconnected, QWebEngineDownloadRequest::NetworkDisconnected)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkServerDown, QWebEngineDownloadRequest::NetworkServerDown)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkInvalidRequest, QWebEngineDownloadRequest::NetworkInvalidRequest)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerFailed, QWebEngineDownloadRequest::ServerFailed)
+//ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerNoRange, QWebEngineDownloadRequest::ServerNoRange)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerBadContent, QWebEngineDownloadRequest::ServerBadContent)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerUnauthorized, QWebEngineDownloadRequest::ServerUnauthorized)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerCertProblem, QWebEngineDownloadRequest::ServerCertProblem)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerForbidden, QWebEngineDownloadRequest::ServerForbidden)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerUnreachable, QWebEngineDownloadRequest::ServerUnreachable)
+ASSERT_ENUMS_MATCH(ProfileAdapterClient::UserCanceled, QWebEngineDownloadRequest::UserCanceled)
+//ASSERT_ENUMS_MATCH(ProfileAdapterClient::UserShutdown, QWebEngineDownloadRequest::UserShutdown)
+//ASSERT_ENUMS_MATCH(ProfileAdapterClient::Crash, QWebEngineDownloadRequest::Crash)
+
+static inline QWebEngineDownloadRequest::DownloadState toDownloadState(int state)
{
switch (state) {
case ProfileAdapterClient::DownloadInProgress:
- return QWebEngineDownloadItem::DownloadInProgress;
+ return QWebEngineDownloadRequest::DownloadInProgress;
case ProfileAdapterClient::DownloadCompleted:
- return QWebEngineDownloadItem::DownloadCompleted;
+ return QWebEngineDownloadRequest::DownloadCompleted;
case ProfileAdapterClient::DownloadCancelled:
- return QWebEngineDownloadItem::DownloadCancelled;
+ return QWebEngineDownloadRequest::DownloadCancelled;
case ProfileAdapterClient::DownloadInterrupted:
- return QWebEngineDownloadItem::DownloadInterrupted;
+ return QWebEngineDownloadRequest::DownloadInterrupted;
default:
Q_UNREACHABLE();
- return QWebEngineDownloadItem::DownloadCancelled;
+ return QWebEngineDownloadRequest::DownloadCancelled;
}
}
-static inline QWebEngineDownloadItem::DownloadInterruptReason toDownloadInterruptReason(int reason)
+static inline QWebEngineDownloadRequest::DownloadInterruptReason toDownloadInterruptReason(int reason)
{
- return static_cast<QWebEngineDownloadItem::DownloadInterruptReason>(reason);
+ return static_cast<QWebEngineDownloadRequest::DownloadInterruptReason>(reason);
}
/*!
- \class QWebEngineDownloadItem
- \brief The QWebEngineDownloadItem class provides information about a download.
+ \class QWebEngineDownloadRequest
+ \brief The QWebEngineDownloadRequest class provides information about a download.
- \since 5.5
+ \inmodule QtWebEngineCore
- \inmodule QtWebEngineWidgets
-
- QWebEngineDownloadItem models a download throughout its life cycle, starting
+ QWebEngineDownloadRequest models a download throughout its life cycle, starting
with a pending download request and finishing with a completed download. It
can be used, for example, to get information about new downloads, to monitor
progress, and to pause, resume, and cancel downloads.
@@ -117,7 +114,7 @@ static inline QWebEngineDownloadItem::DownloadInterruptReason toDownloadInterrup
QWebEngineProfile's responsibility to notify the application of new download
requests, which it does by emitting the
\l{QWebEngineProfile::downloadRequested}{downloadRequested} signal together
- with a newly created QWebEngineDownloadItem. The application can then
+ with a newly created QWebEngineDownloadRequest. The application can then
examine this item and decide whether to accept it or not. A signal handler
must explicitly call accept() on the item for \QWE to actually start
downloading and writing data to disk. If no signal handler calls accept(),
@@ -160,45 +157,53 @@ static inline QWebEngineDownloadItem::DownloadInterruptReason toDownloadInterrup
QWebEnginePage::download, QWebEnginePage::save
*/
-QWebEngineDownloadItemPrivate::QWebEngineDownloadItemPrivate(QWebEngineProfilePrivate *p, const QUrl &url)
- : profile(p)
+QWebEngineDownloadRequestPrivate::QWebEngineDownloadRequestPrivate(QtWebEngineCore::ProfileAdapter *adapter, const QUrl &url)
+ : m_profileAdapter(adapter)
, downloadFinished(false)
, downloadId(-1)
- , downloadState(QWebEngineDownloadItem::DownloadCancelled)
- , savePageFormat(QWebEngineDownloadItem::MimeHtmlSaveFormat)
- , type(QWebEngineDownloadItem::Attachment)
- , interruptReason(QWebEngineDownloadItem::NoReason)
+ , downloadState(QWebEngineDownloadRequest::DownloadCancelled)
+ , savePageFormat(QWebEngineDownloadRequest::MimeHtmlSaveFormat)
+ , interruptReason(QWebEngineDownloadRequest::NoReason)
, downloadUrl(url)
, downloadPaused(false)
, isCustomFileName(false)
, totalBytes(-1)
, receivedBytes(0)
- , page(0)
+ , isSavePageDownload(false)
+ , page(nullptr)
{
}
-QWebEngineDownloadItemPrivate::~QWebEngineDownloadItemPrivate()
+QWebEngineDownloadRequestPrivate::~QWebEngineDownloadRequestPrivate()
{
}
-void QWebEngineDownloadItemPrivate::update(const ProfileAdapterClient::DownloadItemInfo &info)
+void QWebEngineDownloadRequestPrivate::update(const ProfileAdapterClient::DownloadItemInfo &info)
{
- Q_Q(QWebEngineDownloadItem);
+ Q_Q(QWebEngineDownloadRequest);
- Q_ASSERT(downloadState != QWebEngineDownloadItem::DownloadRequested);
+ Q_ASSERT(downloadState != QWebEngineDownloadRequest::DownloadRequested);
- if (toDownloadInterruptReason(info.downloadInterruptReason) != interruptReason)
+ if (toDownloadInterruptReason(info.downloadInterruptReason) != interruptReason) {
interruptReason = toDownloadInterruptReason(info.downloadInterruptReason);
-
+ Q_EMIT q->interruptReasonChanged();
+ }
if (toDownloadState(info.state) != downloadState) {
downloadState = toDownloadState(info.state);
Q_EMIT q->stateChanged(downloadState);
}
if (info.receivedBytes != receivedBytes || info.totalBytes != totalBytes) {
- receivedBytes = info.receivedBytes;
- totalBytes = info.totalBytes;
- Q_EMIT q->downloadProgress(receivedBytes, totalBytes);
+
+ if (info.receivedBytes != receivedBytes) {
+ receivedBytes = info.receivedBytes;
+ Q_EMIT q->receivedBytesChanged();
+ }
+ if (info.totalBytes != totalBytes) {
+ totalBytes = info.totalBytes;
+ Q_EMIT q->totalBytesChanged();
+ }
+ Q_EMIT q->downloadProgress(receivedBytes, totalBytes);
}
if (info.done)
@@ -206,17 +211,17 @@ void QWebEngineDownloadItemPrivate::update(const ProfileAdapterClient::DownloadI
if (downloadPaused != info.paused) {
downloadPaused = info.paused;
- Q_EMIT q->isPausedChanged(downloadPaused);
+ Q_EMIT q->isPausedChanged();
}
}
-void QWebEngineDownloadItemPrivate::setFinished()
+void QWebEngineDownloadRequestPrivate::setFinished()
{
if (downloadFinished)
return;
downloadFinished = true;
- Q_EMIT q_ptr->finished();
+ Q_EMIT q_ptr->isFinishedChanged();
}
/*!
@@ -229,14 +234,14 @@ void QWebEngineDownloadItemPrivate::setFinished()
\sa finished(), stateChanged()
*/
-void QWebEngineDownloadItem::accept()
+void QWebEngineDownloadRequest::accept()
{
- Q_D(QWebEngineDownloadItem);
+ Q_D(QWebEngineDownloadRequest);
- if (d->downloadState != QWebEngineDownloadItem::DownloadRequested)
+ if (d->downloadState != QWebEngineDownloadRequest::DownloadRequested)
return;
- d->downloadState = QWebEngineDownloadItem::DownloadInProgress;
+ d->downloadState = QWebEngineDownloadRequest::DownloadInProgress;
Q_EMIT stateChanged(d->downloadState);
}
@@ -254,30 +259,29 @@ void QWebEngineDownloadItem::accept()
\sa finished(), stateChanged()
*/
-void QWebEngineDownloadItem::cancel()
+void QWebEngineDownloadRequest::cancel()
{
- Q_D(QWebEngineDownloadItem);
+ Q_D(QWebEngineDownloadRequest);
- QWebEngineDownloadItem::DownloadState state = d->downloadState;
+ QWebEngineDownloadRequest::DownloadState state = d->downloadState;
- if (state == QWebEngineDownloadItem::DownloadCompleted
- || state == QWebEngineDownloadItem::DownloadCancelled)
+ if (state == QWebEngineDownloadRequest::DownloadCompleted
+ || state == QWebEngineDownloadRequest::DownloadCancelled)
return;
// 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) {
- if (auto profileAdapter = d->profile->profileAdapter())
- profileAdapter->cancelDownload(d->downloadId);
+ if (state == QWebEngineDownloadRequest::DownloadInProgress) {
+ if (d->m_profileAdapter)
+ d->m_profileAdapter->cancelDownload(d->downloadId);
} else {
- d->downloadState = QWebEngineDownloadItem::DownloadCancelled;
+ d->downloadState = QWebEngineDownloadRequest::DownloadCancelled;
Q_EMIT stateChanged(d->downloadState);
d->setFinished();
}
}
/*!
- \since 5.10
Pauses the download.
Has no effect if the state is not \l DownloadInProgress. Does not change the
@@ -286,20 +290,20 @@ void QWebEngineDownloadItem::cancel()
\sa resume(), isPaused()
*/
-void QWebEngineDownloadItem::pause()
+void QWebEngineDownloadRequest::pause()
{
- Q_D(QWebEngineDownloadItem);
+ Q_D(QWebEngineDownloadRequest);
- QWebEngineDownloadItem::DownloadState state = d->downloadState;
+ QWebEngineDownloadRequest::DownloadState state = d->downloadState;
- if (state != QWebEngineDownloadItem::DownloadInProgress)
+ if (state != QWebEngineDownloadRequest::DownloadInProgress)
return;
- d->profile->profileAdapter()->pauseDownload(d->downloadId);
+ if (d->m_profileAdapter)
+ d->m_profileAdapter->pauseDownload(d->downloadId);
}
/*!
- \since 5.10
Resumes the current download if it was paused or interrupted.
Has no effect if the state is not \l DownloadInProgress or \l
@@ -307,29 +311,30 @@ void QWebEngineDownloadItem::pause()
\sa pause(), isPaused(), state()
*/
-void QWebEngineDownloadItem::resume()
+void QWebEngineDownloadRequest::resume()
{
- Q_D(QWebEngineDownloadItem);
+ Q_D(QWebEngineDownloadRequest);
- QWebEngineDownloadItem::DownloadState state = d->downloadState;
+ QWebEngineDownloadRequest::DownloadState state = d->downloadState;
- if (d->downloadFinished || (state != QWebEngineDownloadItem::DownloadInProgress && state != QWebEngineDownloadItem::DownloadInterrupted))
+ if (d->downloadFinished || (state != QWebEngineDownloadRequest::DownloadInProgress && state != QWebEngineDownloadRequest::DownloadInterrupted))
return;
- d->profile->profileAdapter()->resumeDownload(d->downloadId);
+ if (d->m_profileAdapter)
+ d->m_profileAdapter->resumeDownload(d->downloadId);
}
/*!
Returns the download item's ID.
*/
-quint32 QWebEngineDownloadItem::id() const
+quint32 QWebEngineDownloadRequest::id() const
{
- Q_D(const QWebEngineDownloadItem);
+ Q_D(const QWebEngineDownloadRequest);
return d->downloadId;
}
/*!
- \fn void QWebEngineDownloadItem::finished()
+ \fn void QWebEngineDownloadRequest::finished()
This signal is emitted when the download finishes.
@@ -337,8 +342,7 @@ quint32 QWebEngineDownloadItem::id() const
*/
/*!
- \fn void QWebEngineDownloadItem::isPausedChanged(bool isPaused)
- \since 5.10
+ \fn void QWebEngineDownloadRequest::isPausedChanged(bool isPaused)
This signal is emitted whenever \a isPaused changes.
@@ -346,7 +350,7 @@ quint32 QWebEngineDownloadItem::id() const
*/
/*!
- \fn void QWebEngineDownloadItem::stateChanged(DownloadState state)
+ \fn void QWebEngineDownloadRequest::stateChanged(DownloadState state)
This signal is emitted whenever the download's \a state changes.
@@ -354,7 +358,7 @@ quint32 QWebEngineDownloadItem::id() const
*/
/*!
- \fn void QWebEngineDownloadItem::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
+ \fn void QWebEngineDownloadRequest::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
This signal is emitted to indicate the progress of the download request.
@@ -367,7 +371,7 @@ quint32 QWebEngineDownloadItem::id() const
*/
/*!
- \enum QWebEngineDownloadItem::DownloadState
+ \enum QWebEngineDownloadRequest::DownloadState
This enum describes the state of the download:
@@ -380,8 +384,7 @@ quint32 QWebEngineDownloadItem::id() const
*/
/*!
- \enum QWebEngineDownloadItem::SavePageFormat
- \since 5.7
+ \enum QWebEngineDownloadRequest::SavePageFormat
This enum describes the format that is used to save a web page.
@@ -394,28 +397,7 @@ quint32 QWebEngineDownloadItem::id() const
*/
/*!
- \enum QWebEngineDownloadItem::DownloadType
- \since 5.8
- \obsolete
-
- Describes the requested download's type.
-
- \value Attachment The web server's response includes a
- \c Content-Disposition header with the \c attachment directive. If \c Content-Disposition
- is present in the reply, the web server is indicating that the client should prompt the
- user to save the content regardless of the content type.
- See \l {RFC 2616 section 19.5.1} for details.
- \value DownloadAttribute The user clicked a link with the \c download
- attribute.
- \value UserRequested The user initiated the download, for example by
- selecting a web action.
- \value SavePage Saving of the current page was requested (for example by
- the \l{QWebEnginePage::WebAction}{QWebEnginePage::SavePage} web action).
-*/
-
-/*!
- \enum QWebEngineDownloadItem::DownloadInterruptReason
- \since 5.9
+ \enum QWebEngineDownloadRequest::DownloadInterruptReason
Describes the reason why a download was interrupted:
@@ -458,9 +440,9 @@ quint32 QWebEngineDownloadItem::id() const
\sa DownloadState
*/
-QWebEngineDownloadItem::DownloadState QWebEngineDownloadItem::state() const
+QWebEngineDownloadRequest::DownloadState QWebEngineDownloadRequest::state() const
{
- Q_D(const QWebEngineDownloadItem);
+ Q_D(const QWebEngineDownloadRequest);
return d->downloadState;
}
@@ -470,9 +452,9 @@ QWebEngineDownloadItem::DownloadState QWebEngineDownloadItem::state() const
\c -1 means the size is unknown.
*/
-qint64 QWebEngineDownloadItem::totalBytes() const
+qint64 QWebEngineDownloadRequest::totalBytes() const
{
- Q_D(const QWebEngineDownloadItem);
+ Q_D(const QWebEngineDownloadRequest);
return d->totalBytes;
}
@@ -482,9 +464,9 @@ qint64 QWebEngineDownloadItem::totalBytes() const
\c -1 means the size is unknown.
*/
-qint64 QWebEngineDownloadItem::receivedBytes() const
+qint64 QWebEngineDownloadRequest::receivedBytes() const
{
- Q_D(const QWebEngineDownloadItem);
+ Q_D(const QWebEngineDownloadRequest);
return d->receivedBytes;
}
@@ -492,96 +474,33 @@ qint64 QWebEngineDownloadItem::receivedBytes() const
Returns the download's origin URL.
*/
-QUrl QWebEngineDownloadItem::url() const
+QUrl QWebEngineDownloadRequest::url() const
{
- Q_D(const QWebEngineDownloadItem);
+ Q_D(const QWebEngineDownloadRequest);
return d->downloadUrl;
}
/*!
- \since 5.6
-
Returns the MIME type of the download.
*/
-QString QWebEngineDownloadItem::mimeType() const
+QString QWebEngineDownloadRequest::mimeType() const
{
- Q_D(const QWebEngineDownloadItem);
+ Q_D(const QWebEngineDownloadRequest);
return d->mimeType;
}
/*!
- \obsolete
-
- Use \l suggestedFileName(), \l downloadDirectory(), and
- \l downloadFileName() instead.
-
- Returns the full target path where data is being downloaded to.
-
- The path includes the file name. The default suggested path is the standard download location
- and file name is deduced not to overwrite already existing files.
-*/
-
-QString QWebEngineDownloadItem::path() const
-{
- Q_D(const QWebEngineDownloadItem);
- return QDir::cleanPath(QDir(d->downloadDirectory).filePath(d->downloadFileName));
-}
-
-/*!
- \obsolete
-
- Use \l setDownloadDirectory() and \l setDownloadFileName() instead.
-
- Sets the full target path to download the file to.
-
- The \a path should also include the file name. The download path can only be set in response
- to the QWebEngineProfile::downloadRequested() signal before the download is accepted.
- Past that point, this function has no effect on the download item's state.
-*/
-void QWebEngineDownloadItem::setPath(QString path)
-{
- Q_D(QWebEngineDownloadItem);
- if (d->downloadState != QWebEngineDownloadItem::DownloadRequested) {
- qWarning("Setting the download path is not allowed after the download has been accepted.");
- return;
- }
- if (QDir(d->downloadDirectory).filePath(d->downloadFileName) != path) {
- if (QFileInfo(path).fileName().isEmpty()) {
- qWarning("The download path does not include file name.");
- return;
- }
-
- if (QFileInfo(path).isDir()) {
- qWarning("The download path matches with an already existing directory path.");
- return;
- }
-
- if (QFileInfo(path).fileName() == path) {
- d->downloadDirectory = QStringLiteral("");
- d->downloadFileName = path;
- } else {
- d->downloadDirectory = QFileInfo(path).path();
- d->downloadFileName = QFileInfo(path).fileName();
- }
- }
-}
-
-/*!
- \since 5.14
-
Returns the download directory path.
*/
-QString QWebEngineDownloadItem::downloadDirectory() const
+QString QWebEngineDownloadRequest::downloadDirectory() const
{
- Q_D(const QWebEngineDownloadItem);
+ Q_D(const QWebEngineDownloadRequest);
return d->downloadDirectory;
}
/*!
- \since 5.14
-
Sets \a directory as the directory path to download the file to.
The download directory path can only be set in response to the QWebEngineProfile::downloadRequested()
@@ -589,10 +508,10 @@ QString QWebEngineDownloadItem::downloadDirectory() const
download item's state.
*/
-void QWebEngineDownloadItem::setDownloadDirectory(const QString &directory)
+void QWebEngineDownloadRequest::setDownloadDirectory(const QString &directory)
{
- Q_D(QWebEngineDownloadItem);
- if (d->downloadState != QWebEngineDownloadItem::DownloadRequested) {
+ Q_D(QWebEngineDownloadRequest);
+ if (d->downloadState != QWebEngineDownloadRequest::DownloadRequested) {
qWarning("Setting the download directory is not allowed after the download has been accepted.");
return;
}
@@ -600,27 +519,23 @@ void QWebEngineDownloadItem::setDownloadDirectory(const QString &directory)
if (!directory.isEmpty() && d->downloadDirectory != directory)
d->downloadDirectory = directory;
- if (!d->isCustomFileName)
- d->downloadFileName = QFileInfo(d->profile->profileAdapter()->determineDownloadPath(d->downloadDirectory,
+ if (!d->isCustomFileName && d->m_profileAdapter)
+ d->downloadFileName = QFileInfo(d->m_profileAdapter->determineDownloadPath(d->downloadDirectory,
d->suggestedFileName,
d->startTime)).fileName();
}
/*!
- \since 5.14
-
Returns the file name to download the file to.
*/
-QString QWebEngineDownloadItem::downloadFileName() const
+QString QWebEngineDownloadRequest::downloadFileName() const
{
- Q_D(const QWebEngineDownloadItem);
+ Q_D(const QWebEngineDownloadRequest);
return d->downloadFileName;
}
/*!
- \since 5.14
-
Sets \a fileName as the file name to download the file to.
The download file name can only be set in response to the QWebEngineProfile::downloadRequested()
@@ -628,10 +543,10 @@ QString QWebEngineDownloadItem::downloadFileName() const
download item's state.
*/
-void QWebEngineDownloadItem::setDownloadFileName(const QString &fileName)
+void QWebEngineDownloadRequest::setDownloadFileName(const QString &fileName)
{
- Q_D(QWebEngineDownloadItem);
- if (d->downloadState != QWebEngineDownloadItem::DownloadRequested) {
+ Q_D(QWebEngineDownloadRequest);
+ if (d->downloadState != QWebEngineDownloadRequest::DownloadRequested) {
qWarning("Setting the download file name is not allowed after the download has been accepted.");
return;
}
@@ -643,14 +558,12 @@ void QWebEngineDownloadItem::setDownloadFileName(const QString &fileName)
}
/*!
- \since 5.14
-
Returns the suggested file name.
*/
-QString QWebEngineDownloadItem::suggestedFileName() const
+QString QWebEngineDownloadRequest::suggestedFileName() const
{
- Q_D(const QWebEngineDownloadItem);
+ Q_D(const QWebEngineDownloadRequest);
return d->suggestedFileName;
}
@@ -660,9 +573,9 @@ QString QWebEngineDownloadItem::suggestedFileName() const
\sa finished(), state(),
*/
-bool QWebEngineDownloadItem::isFinished() const
+bool QWebEngineDownloadRequest::isFinished() const
{
- Q_D(const QWebEngineDownloadItem);
+ Q_D(const QWebEngineDownloadRequest);
return d->downloadFinished;
}
@@ -672,101 +585,82 @@ bool QWebEngineDownloadItem::isFinished() const
\sa pause(), resume()
*/
-bool QWebEngineDownloadItem::isPaused() const
+bool QWebEngineDownloadRequest::isPaused() const
{
- Q_D(const QWebEngineDownloadItem);
+ Q_D(const QWebEngineDownloadRequest);
return d->downloadPaused;
}
/*!
Returns the format the web page will be saved in if this is a download request for a web page.
- \since 5.7
-
\sa setSavePageFormat(), isSavePageDownload()
*/
-QWebEngineDownloadItem::SavePageFormat QWebEngineDownloadItem::savePageFormat() const
+QWebEngineDownloadRequest::SavePageFormat QWebEngineDownloadRequest::savePageFormat() const
{
- Q_D(const QWebEngineDownloadItem);
+ Q_D(const QWebEngineDownloadRequest);
return d->savePageFormat;
}
/*!
Sets the \a format the web page will be saved in if this is a download request for a web page.
- \since 5.7
\sa savePageFormat(), isSavePageDownload()
*/
-void QWebEngineDownloadItem::setSavePageFormat(QWebEngineDownloadItem::SavePageFormat format)
-{
- Q_D(QWebEngineDownloadItem);
- d->savePageFormat = format;
-}
-
-/*!
- Returns the requested download's type.
- \since 5.8
- \obsolete
-
- \note This property works unreliably, except for \c SavePage
- downloads. Use \l isSavePageDownload() instead.
- */
-
-QWebEngineDownloadItem::DownloadType QWebEngineDownloadItem::type() const
+void QWebEngineDownloadRequest::setSavePageFormat(QWebEngineDownloadRequest::SavePageFormat format)
{
- Q_D(const QWebEngineDownloadItem);
- return d->type;
+ Q_D(QWebEngineDownloadRequest);
+ if (d->savePageFormat != format) {
+ d->savePageFormat = format;
+ Q_EMIT savePageFormatChanged();
+ }
}
/*!
Returns \c true if this is a download request for saving a web page.
- \since 5.11
\sa savePageFormat(), setSavePageFormat()
*/
-bool QWebEngineDownloadItem::isSavePageDownload() const
+bool QWebEngineDownloadRequest::isSavePageDownload() const
{
- Q_D(const QWebEngineDownloadItem);
- return d->type == QWebEngineDownloadItem::SavePage;
+ Q_D(const QWebEngineDownloadRequest);
+ return d->isSavePageDownload;
}
/*!
Returns the reason why the download was interrupted.
- \since 5.9
\sa interruptReasonString()
*/
-QWebEngineDownloadItem::DownloadInterruptReason QWebEngineDownloadItem::interruptReason() const
+QWebEngineDownloadRequest::DownloadInterruptReason QWebEngineDownloadRequest::interruptReason() const
{
- Q_D(const QWebEngineDownloadItem);
+ Q_D(const QWebEngineDownloadRequest);
return d->interruptReason;
}
/*!
Returns a human-readable description of the reason for interrupting the download.
- \since 5.9
\sa interruptReason()
*/
-QString QWebEngineDownloadItem::interruptReasonString() const
+QString QWebEngineDownloadRequest::interruptReasonString() const
{
return ProfileAdapterClient::downloadInterruptReasonToString(
static_cast<ProfileAdapterClient::DownloadInterruptReason>(interruptReason()));
}
/*!
- \since 5.12
Returns the page the download was requested on. If the download was not triggered by content in a page,
\c nullptr is returned.
*/
-QWebEnginePage *QWebEngineDownloadItem::page() const
+QObject *QWebEngineDownloadRequest::page() const
{
- Q_D(const QWebEngineDownloadItem);
+ Q_D(const QWebEngineDownloadRequest);
return d->page;
}
-QWebEngineDownloadItem::QWebEngineDownloadItem(QWebEngineDownloadItemPrivate *p, QObject *parent)
+QWebEngineDownloadRequest::QWebEngineDownloadRequest(QWebEngineDownloadRequestPrivate *p, QObject *parent)
: QObject(parent)
, d_ptr(p)
{
@@ -775,7 +669,7 @@ QWebEngineDownloadItem::QWebEngineDownloadItem(QWebEngineDownloadItemPrivate *p,
/*! \internal
*/
-QWebEngineDownloadItem::~QWebEngineDownloadItem()
+QWebEngineDownloadRequest::~QWebEngineDownloadRequest()
{
// MEMO Items are owned by profile by default and will be destroyed on profile's destruction
// It's not safe to access profile in that case, so we rely on profile to clean up items
diff --git a/src/webengine/api/qquickwebenginedownloaditem_p.h b/src/core/api/qwebenginedownloadrequest.h
index e1b1b9040..38d43cf1f 100644
--- a/src/webengine/api/qquickwebenginedownloaditem_p.h
+++ b/src/core/api/qwebenginedownloadrequest.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
@@ -37,36 +37,43 @@
**
****************************************************************************/
-#ifndef QQUICKWEBENGINEDOWNLOADITEM_P_H
-#define QQUICKWEBENGINEDOWNLOADITEM_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 <QtWebEngine/private/qtwebengineglobal_p.h>
-#include <QObject>
-#include <QScopedPointer>
-#include <QString>
-#include <QUrl>
+#ifndef QWEBENGINEDOWNLOADREQUEST_H
+#define QWEBENGINEDOWNLOADREQUEST_H
+
+#include <QtWebEngineCore/qtwebenginecoreglobal.h>
+
+#include <QtCore/qobject.h>
+#include <QtCore/QUrl>
QT_BEGIN_NAMESPACE
-class QQuickWebEngineDownloadItemPrivate;
-class QQuickWebEngineProfilePrivate;
-class QQuickWebEngineView;
+//TODO: class QWebEnginePage;
+class QWebEngineDownloadRequestPrivate;
+class QWebEngineProfilePrivate;
-class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineDownloadItem: public QObject {
+class Q_WEBENGINECORE_EXPORT QWebEngineDownloadRequest : public QObject
+{
Q_OBJECT
public:
- ~QQuickWebEngineDownloadItem();
+ Q_PROPERTY(quint32 id READ id CONSTANT FINAL)
+ Q_PROPERTY(DownloadState state READ state NOTIFY stateChanged FINAL)
+ Q_PROPERTY(SavePageFormat savePageFormat READ savePageFormat WRITE setSavePageFormat NOTIFY savePageFormatChanged FINAL)
+ Q_PROPERTY(qint64 totalBytes READ totalBytes NOTIFY totalBytesChanged FINAL)
+ Q_PROPERTY(qint64 receivedBytes READ receivedBytes NOTIFY receivedBytesChanged FINAL)
+ Q_PROPERTY(QString mimeType READ mimeType FINAL)
+ Q_PROPERTY(DownloadInterruptReason interruptReason READ interruptReason NOTIFY interruptReasonChanged FINAL)
+ Q_PROPERTY(QString interruptReasonString READ interruptReasonString NOTIFY interruptReasonChanged FINAL)
+ Q_PROPERTY(bool isFinished READ isFinished NOTIFY isFinishedChanged FINAL)
+ Q_PROPERTY(bool isPaused READ isPaused NOTIFY isPausedChanged FINAL)
+ Q_PROPERTY(bool isSavePageDownload READ isSavePageDownload CONSTANT FINAL)
+ //TODO: Q_PROPERTY(QQuickWebEngineView *view READ view CONSTANT REVISION 7 FINAL)
+ Q_PROPERTY(QUrl url READ url CONSTANT FINAL)
+ Q_PROPERTY(QString suggestedFileName READ suggestedFileName CONSTANT FINAL)
+ Q_PROPERTY(QString downloadDirectory READ downloadDirectory WRITE setDownloadDirectory NOTIFY downloadDirectoryChanged FINAL)
+ Q_PROPERTY(QString downloadFileName READ downloadFileName WRITE setDownloadFileName NOTIFY downloadFileNameChanged FINAL)
+
+ ~QWebEngineDownloadRequest();
+
enum DownloadState {
DownloadRequested,
DownloadInProgress,
@@ -115,85 +122,57 @@ public:
};
Q_ENUM(DownloadInterruptReason)
- enum DownloadType {
- Attachment = 0,
- DownloadAttribute,
- UserRequested,
- SavePage
- };
- Q_ENUM(DownloadType)
-
- Q_PROPERTY(quint32 id READ id CONSTANT FINAL)
- Q_PROPERTY(DownloadState state READ state NOTIFY stateChanged FINAL)
- Q_PROPERTY(SavePageFormat savePageFormat READ savePageFormat WRITE setSavePageFormat NOTIFY savePageFormatChanged REVISION 2 FINAL)
- Q_PROPERTY(qint64 totalBytes READ totalBytes NOTIFY totalBytesChanged FINAL)
- Q_PROPERTY(qint64 receivedBytes READ receivedBytes NOTIFY receivedBytesChanged FINAL)
- Q_PROPERTY(QString mimeType READ mimeType NOTIFY mimeTypeChanged REVISION 1 FINAL)
- Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged FINAL)
- Q_PROPERTY(DownloadType type READ type NOTIFY typeChanged REVISION 3 FINAL)
- Q_PROPERTY(DownloadInterruptReason interruptReason READ interruptReason NOTIFY interruptReasonChanged REVISION 4 FINAL)
- Q_PROPERTY(QString interruptReasonString READ interruptReasonString NOTIFY interruptReasonChanged REVISION 4 FINAL)
- Q_PROPERTY(bool isFinished READ isFinished NOTIFY isFinishedChanged REVISION 5 FINAL)
- Q_PROPERTY(bool isPaused READ isPaused NOTIFY isPausedChanged REVISION 5 FINAL)
- Q_PROPERTY(bool isSavePageDownload READ isSavePageDownload CONSTANT REVISION 6 FINAL)
- Q_PROPERTY(QQuickWebEngineView *view READ view CONSTANT REVISION 7 FINAL)
- Q_PROPERTY(QUrl url READ url CONSTANT REVISION 10 FINAL)
- Q_PROPERTY(QString suggestedFileName READ suggestedFileName CONSTANT REVISION 10 FINAL)
- Q_PROPERTY(QString downloadDirectory READ downloadDirectory WRITE setDownloadDirectory NOTIFY downloadDirectoryChanged REVISION 10 FINAL)
- Q_PROPERTY(QString downloadFileName READ downloadFileName WRITE setDownloadFileName NOTIFY downloadFileNameChanged REVISION 10 FINAL)
-
- Q_INVOKABLE void accept();
- Q_INVOKABLE void cancel();
- Q_INVOKABLE void pause();
- Q_INVOKABLE void resume();
-
quint32 id() const;
DownloadState state() const;
qint64 totalBytes() const;
qint64 receivedBytes() const;
+ QUrl url() const;
QString mimeType() const;
- QString path() const;
- void setPath(QString path);
+ bool isFinished() const;
+ bool isPaused() const;
SavePageFormat savePageFormat() const;
void setSavePageFormat(SavePageFormat format);
- DownloadType Q_DECL_DEPRECATED type() const;
DownloadInterruptReason interruptReason() const;
QString interruptReasonString() const;
- bool isFinished() const;
- bool isPaused() const;
bool isSavePageDownload() const;
- QQuickWebEngineView *view() const;
- QUrl url() const;
QString suggestedFileName() const;
QString downloadDirectory() const;
void setDownloadDirectory(const QString &directory);
QString downloadFileName() const;
void setDownloadFileName(const QString &fileName);
- bool isCustomFileName;
+
+ //TODO:
+ QObject *page() const;
+
+public Q_SLOTS:
+ void accept();
+ void cancel();
+ void pause();
+ void resume();
Q_SIGNALS:
- void stateChanged();
- Q_REVISION(2) void savePageFormatChanged();
+ void stateChanged(QWebEngineDownloadRequest::DownloadState state);
+ //TODO: fix it for qml
+ void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
+ void savePageFormatChanged();
void receivedBytesChanged();
void totalBytesChanged();
- Q_REVISION(1) void mimeTypeChanged();
- void pathChanged();
- Q_REVISION(3) void typeChanged();
- Q_REVISION(4) void interruptReasonChanged();
- Q_REVISION(5) void isFinishedChanged();
- Q_REVISION(5) void isPausedChanged();
- Q_REVISION(10) void downloadDirectoryChanged();
- Q_REVISION(10) void downloadFileNameChanged();
+ void interruptReasonChanged();
+ void isFinishedChanged();
+ void isPausedChanged();
+ void downloadDirectoryChanged();
+ void downloadFileNameChanged();
private:
- QQuickWebEngineDownloadItem(QQuickWebEngineDownloadItemPrivate*, QObject *parent = 0);
- Q_DISABLE_COPY(QQuickWebEngineDownloadItem)
- Q_DECLARE_PRIVATE(QQuickWebEngineDownloadItem)
- friend class QQuickWebEngineProfilePrivate;
+ Q_DISABLE_COPY(QWebEngineDownloadRequest)
+ Q_DECLARE_PRIVATE(QWebEngineDownloadRequest)
- QScopedPointer<QQuickWebEngineDownloadItemPrivate> d_ptr;
+ friend class QWebEngineProfilePrivate;
+ friend class QQuickWebEngineProfilePrivate;
+ QWebEngineDownloadRequest(QWebEngineDownloadRequestPrivate*, QObject *parent = Q_NULLPTR);
+ QScopedPointer<QWebEngineDownloadRequestPrivate> d_ptr;
};
QT_END_NAMESPACE
-#endif // QQUICKWEBENGINEDOWNLOADITEM_P_H
+#endif // QWEBENGINEDOWNLOADREQUEST_H
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem_p.h b/src/core/api/qwebenginedownloadrequest_p.h
index 04c6fadcc..bc172bd7b 100644
--- a/src/webenginewidgets/api/qwebenginedownloaditem_p.h
+++ b/src/core/api/qwebenginedownloadrequest_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef QWEBENGINEDOWNLOADITEM_P_H
-#define QWEBENGINEDOWNLOADITEM_P_H
+#ifndef QWEBENGINEDOWNLOADREQUEST_P_H
+#define QWEBENGINEDOWNLOADREQUEST_P_H
//
// W A R N I N G
@@ -51,30 +51,32 @@
// We mean it.
//
-#include "qtwebenginewidgetsglobal.h"
-
-#include "qwebenginedownloaditem.h"
-#include "qwebengineprofile_p.h"
+#include "qtwebenginecoreglobal.h"
+#include "qwebenginedownloadrequest.h"
+#include "profile_adapter_client.h"
#include <QString>
+#include <QPointer>
+
+namespace QtWebEngineCore {
+class ProfileAdapter;
+}
QT_BEGIN_NAMESPACE
-class QWebEngineDownloadItemPrivate {
- QWebEngineDownloadItem *q_ptr;
- QWebEngineProfilePrivate* profile;
- friend class QWebEngineProfilePrivate;
+class Q_WEBENGINECORE_PRIVATE_EXPORT QWebEngineDownloadRequestPrivate {
public:
- Q_DECLARE_PUBLIC(QWebEngineDownloadItem)
- QWebEngineDownloadItemPrivate(QWebEngineProfilePrivate *p, const QUrl &url);
- ~QWebEngineDownloadItemPrivate();
+ QWebEngineDownloadRequestPrivate(QtWebEngineCore::ProfileAdapter *adapter, const QUrl &url);
+ ~QWebEngineDownloadRequestPrivate();
+
+ void update(const QtWebEngineCore::ProfileAdapterClient::DownloadItemInfo &info);
+ void setFinished();
bool downloadFinished;
quint32 downloadId;
qint64 startTime;
- QWebEngineDownloadItem::DownloadState downloadState;
- QWebEngineDownloadItem::SavePageFormat savePageFormat;
- QWebEngineDownloadItem::DownloadType type;
- QWebEngineDownloadItem::DownloadInterruptReason interruptReason;
+ QWebEngineDownloadRequest::DownloadState downloadState;
+ QWebEngineDownloadRequest::SavePageFormat savePageFormat;
+ QWebEngineDownloadRequest::DownloadInterruptReason interruptReason;
QString downloadPath;
const QUrl downloadUrl;
QString mimeType;
@@ -83,17 +85,16 @@ public:
QString downloadDirectory;
QString downloadFileName;
bool isCustomFileName;
-
qint64 totalBytes;
qint64 receivedBytes;
- QWebEnginePage *page;
-
- void update(const QtWebEngineCore::ProfileAdapterClient::DownloadItemInfo &info);
-
- void setFinished();
+ bool isSavePageDownload;
+ QWebEngineDownloadRequest *q_ptr;
+ QPointer<QtWebEngineCore::ProfileAdapter> m_profileAdapter;
+ QObject *page;
+ Q_DECLARE_PUBLIC(QWebEngineDownloadRequest)
};
QT_END_NAMESPACE
-#endif // QWEBENGINEDOWNLOADITEM_P_H
+#endif // QWEBENGINEDOWNLOADREQUEST_P_H
diff --git a/src/core/api/qwebenginehttprequest.cpp b/src/core/api/qwebenginehttprequest.cpp
index 3395cc99f..f5733cde4 100644
--- a/src/core/api/qwebenginehttprequest.cpp
+++ b/src/core/api/qwebenginehttprequest.cpp
@@ -72,7 +72,7 @@ public:
QUrl url;
QWebEngineHttpRequest::Method method;
typedef QPair<QByteArray, QByteArray> HeaderPair;
- typedef QVector<HeaderPair> Headers;
+ typedef QList<HeaderPair> Headers;
Headers headers;
QByteArray postData;
@@ -96,7 +96,7 @@ public:
Headers::ConstIterator findHeader(const QByteArray &key) const;
Headers allHeaders() const;
- QVector<QByteArray> headersKeys() const;
+ QList<QByteArray> headersKeys() const;
void setHeader(const QByteArray &key, const QByteArray &value);
void unsetHeader(const QByteArray &key);
void setAllHeaders(const Headers &list);
@@ -293,7 +293,7 @@ QByteArray QWebEngineHttpRequest::header(const QByteArray &headerName) const
\sa setHeader(), header(), hasHeader(), unsetHeader()
*/
-QVector<QByteArray> QWebEngineHttpRequest::headers() const
+QList<QByteArray> QWebEngineHttpRequest::headers() const
{
return d->headersKeys();
}
@@ -339,9 +339,9 @@ QWebEngineHttpRequestPrivate::Headers QWebEngineHttpRequestPrivate::allHeaders()
return headers;
}
-QVector<QByteArray> QWebEngineHttpRequestPrivate::headersKeys() const
+QList<QByteArray> QWebEngineHttpRequestPrivate::headersKeys() const
{
- QVector<QByteArray> result;
+ QList<QByteArray> result;
result.reserve(headers.size());
Headers::ConstIterator it = headers.constBegin(), end = headers.constEnd();
for (; it != end; ++it)
diff --git a/src/core/api/qwebenginehttprequest.h b/src/core/api/qwebenginehttprequest.h
index 1c4d7837b..ce77c04dd 100644
--- a/src/core/api/qwebenginehttprequest.h
+++ b/src/core/api/qwebenginehttprequest.h
@@ -41,9 +41,9 @@
#define QWEBENGINEHTTPREQUEST_H
#include <QtWebEngineCore/qtwebenginecoreglobal.h>
-#include <QtCore/qshareddata.h>
-#include <QtCore/qvector.h>
+#include <QtCore/qlist.h>
#include <QtCore/qmap.h>
+#include <QtCore/qshareddata.h>
#include <QtCore/qstring.h>
#include <QtCore/qurl.h>
@@ -87,7 +87,7 @@ public:
void setPostData(const QByteArray &postData);
bool hasHeader(const QByteArray &headerName) const;
- QVector<QByteArray> headers() const;
+ QList<QByteArray> headers() const;
QByteArray header(const QByteArray &headerName) const;
void setHeader(const QByteArray &headerName, const QByteArray &value);
void unsetHeader(const QByteArray &headerName);
diff --git a/src/core/browser_accessibility_manager_qt.h b/src/core/browser_accessibility_manager_qt.h
index 6d6086811..511f6bf9a 100644
--- a/src/core/browser_accessibility_manager_qt.h
+++ b/src/core/browser_accessibility_manager_qt.h
@@ -47,9 +47,7 @@
#if QT_CONFIG(accessibility)
-QT_BEGIN_NAMESPACE
-class QAccessibleInterface;
-QT_END_NAMESPACE
+QT_FORWARD_DECLARE_CLASS(QAccessibleInterface)
namespace content {
diff --git a/src/core/certificate_error_controller.cpp b/src/core/certificate_error_controller.cpp
index 353228c2d..a5a665e70 100644
--- a/src/core/certificate_error_controller.cpp
+++ b/src/core/certificate_error_controller.cpp
@@ -38,7 +38,6 @@
****************************************************************************/
#include "certificate_error_controller.h"
-#include "certificate_error_controller_p.h"
#include <net/base/net_errors.h>
#include <net/cert/x509_certificate.h>
@@ -48,94 +47,131 @@
#include "components/strings/grit/components_strings.h"
#include "type_conversion.h"
-QT_BEGIN_NAMESPACE
-
-using namespace QtWebEngineCore;
-
-ASSERT_ENUMS_MATCH(CertificateErrorController::SslPinnedKeyNotInCertificateChain, net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN)
-ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateCommonNameInvalid, net::ERR_CERT_BEGIN)
-ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateCommonNameInvalid, net::ERR_CERT_COMMON_NAME_INVALID)
-ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateDateInvalid, net::ERR_CERT_DATE_INVALID)
-ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateAuthorityInvalid, net::ERR_CERT_AUTHORITY_INVALID)
-ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateContainsErrors, net::ERR_CERT_CONTAINS_ERRORS)
-ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateUnableToCheckRevocation, net::ERR_CERT_UNABLE_TO_CHECK_REVOCATION)
-ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateRevoked, net::ERR_CERT_REVOKED)
-ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateInvalid, net::ERR_CERT_INVALID)
-ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateWeakSignatureAlgorithm, net::ERR_CERT_WEAK_SIGNATURE_ALGORITHM)
-ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateNonUniqueName, net::ERR_CERT_NON_UNIQUE_NAME)
-ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateWeakKey, net::ERR_CERT_WEAK_KEY)
-ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateNameConstraintViolation, net::ERR_CERT_NAME_CONSTRAINT_VIOLATION)
-ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateValidityTooLong, net::ERR_CERT_VALIDITY_TOO_LONG)
-ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateTransparencyRequired, net::ERR_CERTIFICATE_TRANSPARENCY_REQUIRED)
-ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateSymantecLegacy, net::ERR_CERT_SYMANTEC_LEGACY)
-ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateKnownInterceptionBlocked, net::ERR_CERT_KNOWN_INTERCEPTION_BLOCKED)
-ASSERT_ENUMS_MATCH(CertificateErrorController::CertificateErrorEnd, net::ERR_CERT_END)
-
-void CertificateErrorControllerPrivate::accept(bool accepted)
+namespace QtWebEngineCore {
+
+ASSERT_ENUMS_MATCH(QWebEngineCertificateError::SslPinnedKeyNotInCertificateChain,
+ net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN)
+ASSERT_ENUMS_MATCH(QWebEngineCertificateError::CertificateCommonNameInvalid, net::ERR_CERT_BEGIN)
+ASSERT_ENUMS_MATCH(QWebEngineCertificateError::CertificateCommonNameInvalid,
+ net::ERR_CERT_COMMON_NAME_INVALID)
+ASSERT_ENUMS_MATCH(QWebEngineCertificateError::CertificateDateInvalid, net::ERR_CERT_DATE_INVALID)
+ASSERT_ENUMS_MATCH(QWebEngineCertificateError::CertificateAuthorityInvalid,
+ net::ERR_CERT_AUTHORITY_INVALID)
+ASSERT_ENUMS_MATCH(QWebEngineCertificateError::CertificateContainsErrors,
+ net::ERR_CERT_CONTAINS_ERRORS)
+ASSERT_ENUMS_MATCH(QWebEngineCertificateError::CertificateUnableToCheckRevocation,
+ net::ERR_CERT_UNABLE_TO_CHECK_REVOCATION)
+ASSERT_ENUMS_MATCH(QWebEngineCertificateError::CertificateRevoked, net::ERR_CERT_REVOKED)
+ASSERT_ENUMS_MATCH(QWebEngineCertificateError::CertificateInvalid, net::ERR_CERT_INVALID)
+ASSERT_ENUMS_MATCH(QWebEngineCertificateError::CertificateWeakSignatureAlgorithm,
+ net::ERR_CERT_WEAK_SIGNATURE_ALGORITHM)
+ASSERT_ENUMS_MATCH(QWebEngineCertificateError::CertificateNonUniqueName,
+ net::ERR_CERT_NON_UNIQUE_NAME)
+ASSERT_ENUMS_MATCH(QWebEngineCertificateError::CertificateWeakKey, net::ERR_CERT_WEAK_KEY)
+ASSERT_ENUMS_MATCH(QWebEngineCertificateError::CertificateNameConstraintViolation,
+ net::ERR_CERT_NAME_CONSTRAINT_VIOLATION)
+ASSERT_ENUMS_MATCH(QWebEngineCertificateError::CertificateValidityTooLong,
+ net::ERR_CERT_VALIDITY_TOO_LONG)
+ASSERT_ENUMS_MATCH(QWebEngineCertificateError::CertificateTransparencyRequired,
+ net::ERR_CERTIFICATE_TRANSPARENCY_REQUIRED)
+ASSERT_ENUMS_MATCH(QWebEngineCertificateError::CertificateSymantecLegacy,
+ net::ERR_CERT_SYMANTEC_LEGACY)
+ASSERT_ENUMS_MATCH(QWebEngineCertificateError::CertificateKnownInterceptionBlocked,
+ net::ERR_CERT_KNOWN_INTERCEPTION_BLOCKED)
+// ASSERT_ENUMS_MATCH(QWebEngineCertificateError::CertificateErrorEnd, net::ERR_CERT_END)
+
+// Copied from chrome/browser/ssl/ssl_error_handler.cc:
+static int IsCertErrorFatal(int cert_error)
{
- std::move(callback).Run(accepted ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE : content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
+ switch (cert_error) {
+ case net::ERR_CERT_COMMON_NAME_INVALID:
+ case net::ERR_CERT_DATE_INVALID:
+ case net::ERR_CERT_AUTHORITY_INVALID:
+ case net::ERR_CERT_WEAK_SIGNATURE_ALGORITHM:
+ case net::ERR_CERT_WEAK_KEY:
+ case net::ERR_CERT_NAME_CONSTRAINT_VIOLATION:
+ case net::ERR_CERT_VALIDITY_TOO_LONG:
+ case net::ERR_CERTIFICATE_TRANSPARENCY_REQUIRED:
+ case net::ERR_CERT_SYMANTEC_LEGACY:
+ return false;
+ case net::ERR_CERT_CONTAINS_ERRORS:
+ case net::ERR_CERT_REVOKED:
+ case net::ERR_CERT_INVALID:
+ case net::ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY:
+ case net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN:
+ return true;
+ default:
+ NOTREACHED();
+ }
+ return true;
}
-CertificateErrorControllerPrivate::CertificateErrorControllerPrivate(int cert_error,
- const net::SSLInfo& ssl_info,
- const GURL &request_url,
- bool main_frame,
- bool fatal_error,
- bool strict_enforcement,
- base::OnceCallback<void(content::CertificateRequestResultType)> cb
- )
- : certError(CertificateErrorController::CertificateError(cert_error))
- , requestUrl(toQt(request_url))
- , resourceType(main_frame ? CertificateErrorController::ResourceTypeMainFrame : CertificateErrorController::ResourceTypeOther)
- , fatalError(fatal_error)
- , strictEnforcement(strict_enforcement)
- , callback(std::move(cb))
+CertificateErrorController::CertificateErrorController(
+ int cert_error, const net::SSLInfo &ssl_info, const GURL &request_url,
+ bool strict_enforcement, base::OnceCallback<void(content::CertificateRequestResultType)> cb)
+ : m_certError(QWebEngineCertificateError::Type(cert_error))
+ , m_requestUrl(toQt(request_url))
+ , m_overridable(!IsCertErrorFatal(cert_error) && !strict_enforcement)
{
+ if (m_overridable)
+ m_callback = std::move(cb);
if (auto cert = ssl_info.cert.get()) {
- validStart = toQt(cert->valid_start());
- validExpiry = toQt(cert->valid_expiry());
- certificateChain = toCertificateChain(cert);
+ m_validExpiry = toQt(cert->valid_expiry());
+ m_certificateChain = toCertificateChain(cert);
}
}
-CertificateErrorController::CertificateErrorController(CertificateErrorControllerPrivate *p) : d(p)
-{
-}
-
CertificateErrorController::~CertificateErrorController()
{
- delete d;
- d = 0;
+ if (!answered())
+ rejectCertificate();
}
-CertificateErrorController::CertificateError CertificateErrorController::error() const
+QWebEngineCertificateError::Type CertificateErrorController::error() const
{
- return d->certError;
+ return m_certError;
}
QUrl CertificateErrorController::url() const
{
- return d->requestUrl;
+ return m_requestUrl;
}
bool CertificateErrorController::overridable() const
{
- return !d->fatalError && !d->strictEnforcement;
+ return m_overridable;
+}
+
+bool CertificateErrorController::deferred() const
+{
+ return m_deferred;
+}
+
+void CertificateErrorController::defer()
+{
+ m_deferred = true;
}
-bool CertificateErrorController::strictEnforcement() const
+bool CertificateErrorController::answered() const
{
- return d->strictEnforcement;
+ return m_answered;
}
void CertificateErrorController::accept(bool accepted)
{
- d->accept(accepted);
+ if (answered())
+ return;
+
+ m_answered = true;
+ if (m_callback)
+ std::move(m_callback)
+ .Run(accepted ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE
+ : content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
}
-CertificateErrorController::ResourceType CertificateErrorController::resourceType() const
+void CertificateErrorController::deactivate()
{
- return d->resourceType;
+ m_callback.Reset();
}
static QString getQStringForMessageId(int message_id) {
@@ -148,41 +184,41 @@ QString CertificateErrorController::errorString() const
// Try to use chromiums translation of the error strings, though not all are
// consistently described and we need to use versions that does not contain HTML
// formatted text.
- switch (d->certError) {
- case SslPinnedKeyNotInCertificateChain:
+ switch (m_certError) {
+ case QWebEngineCertificateError::SslPinnedKeyNotInCertificateChain:
return getQStringForMessageId(IDS_CERT_ERROR_SUMMARY_PINNING_FAILURE_DETAILS);
- case CertificateCommonNameInvalid:
+ case QWebEngineCertificateError::CertificateCommonNameInvalid:
return getQStringForMessageId(IDS_CERT_ERROR_COMMON_NAME_INVALID_DESCRIPTION);
- case CertificateDateInvalid:
- if (QDateTime::currentDateTime() > d->validExpiry)
+ case QWebEngineCertificateError::CertificateDateInvalid:
+ if (QDateTime::currentDateTime() > m_validExpiry)
return getQStringForMessageId(IDS_CERT_ERROR_EXPIRED_DESCRIPTION);
else
return getQStringForMessageId(IDS_CERT_ERROR_NOT_YET_VALID_DESCRIPTION);
- case CertificateAuthorityInvalid:
- case CertificateKnownInterceptionBlocked:
- case CertificateSymantecLegacy:
+ case QWebEngineCertificateError::CertificateAuthorityInvalid:
+ case QWebEngineCertificateError::CertificateKnownInterceptionBlocked:
+ case QWebEngineCertificateError::CertificateSymantecLegacy:
return getQStringForMessageId(IDS_CERT_ERROR_AUTHORITY_INVALID_DESCRIPTION);
- case CertificateContainsErrors:
+ case QWebEngineCertificateError::CertificateContainsErrors:
return getQStringForMessageId(IDS_CERT_ERROR_CONTAINS_ERRORS_DESCRIPTION);
- case CertificateNoRevocationMechanism:
+ case QWebEngineCertificateError::CertificateNoRevocationMechanism:
return getQStringForMessageId(IDS_CERT_ERROR_NO_REVOCATION_MECHANISM_DETAILS);
- case CertificateRevoked:
+ case QWebEngineCertificateError::CertificateRevoked:
return getQStringForMessageId(IDS_CERT_ERROR_REVOKED_CERT_DESCRIPTION);
- case CertificateInvalid:
+ case QWebEngineCertificateError::CertificateInvalid:
return getQStringForMessageId(IDS_CERT_ERROR_INVALID_CERT_DESCRIPTION);
- case CertificateWeakSignatureAlgorithm:
+ case QWebEngineCertificateError::CertificateWeakSignatureAlgorithm:
return getQStringForMessageId(IDS_CERT_ERROR_WEAK_SIGNATURE_ALGORITHM_DESCRIPTION);
- case CertificateNonUniqueName:
+ case QWebEngineCertificateError::CertificateNonUniqueName:
return getQStringForMessageId(IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
- case CertificateWeakKey:
+ case QWebEngineCertificateError::CertificateWeakKey:
return getQStringForMessageId(IDS_CERT_ERROR_WEAK_KEY_DESCRIPTION);
- case CertificateNameConstraintViolation:
+ case QWebEngineCertificateError::CertificateNameConstraintViolation:
return getQStringForMessageId(IDS_CERT_ERROR_NAME_CONSTRAINT_VIOLATION_DESCRIPTION);
- case CertificateValidityTooLong:
+ case QWebEngineCertificateError::CertificateValidityTooLong:
return getQStringForMessageId(IDS_CERT_ERROR_VALIDITY_TOO_LONG_DESCRIPTION);
- case CertificateTransparencyRequired:
+ case QWebEngineCertificateError::CertificateTransparencyRequired:
return getQStringForMessageId(IDS_CERT_ERROR_CERTIFICATE_TRANSPARENCY_REQUIRED_DESCRIPTION);
- case CertificateUnableToCheckRevocation: // Deprecated in Chromium.
+ case QWebEngineCertificateError::CertificateUnableToCheckRevocation: // Deprecated in Chromium.
default:
break;
}
@@ -192,7 +228,7 @@ QString CertificateErrorController::errorString() const
QList<QSslCertificate> CertificateErrorController::certificateChain() const
{
- return d->certificateChain;
+ return m_certificateChain;
}
-QT_END_NAMESPACE
+}
diff --git a/src/core/certificate_error_controller.h b/src/core/certificate_error_controller.h
index dc1c3cf54..ec3e26806 100644
--- a/src/core/certificate_error_controller.h
+++ b/src/core/certificate_error_controller.h
@@ -52,83 +52,59 @@
#define CERTIFICATE_ERROR_CONTROLLER_H
#include "qtwebenginecoreglobal_p.h"
-
+#include "base/callback.h"
+#include "content/public/browser/certificate_request_result_type.h"
+#include "qwebenginecertificateerror.h"
#include <QtCore/QDateTime>
+#include <QtCore/QScopedPointer>
#include <QtCore/QUrl>
#include <QtNetwork/QSslCertificate>
-QT_BEGIN_NAMESPACE
+namespace net {
+class SSLInfo;
+}
+class GURL;
-class CertificateErrorControllerPrivate;
+namespace QtWebEngineCore {
class Q_WEBENGINECORE_PRIVATE_EXPORT CertificateErrorController {
public:
- CertificateErrorController(CertificateErrorControllerPrivate *p);
+ CertificateErrorController(
+ int cert_error, const net::SSLInfo &ssl_info, const GURL &request_url,
+ bool strict_enforcement,
+ base::OnceCallback<void(content::CertificateRequestResultType)> callback);
~CertificateErrorController();
- // We can't use QSslError::SslErrors, because the error categories doesn't map.
- // Keep up to date with net/base/net_errors.h and net::IsCertificateError():
- enum CertificateError {
- SslPinnedKeyNotInCertificateChain = -150,
- CertificateCommonNameInvalid = -200,
- CertificateDateInvalid = -201,
- CertificateAuthorityInvalid = -202,
- CertificateContainsErrors = -203,
- CertificateNoRevocationMechanism = -204,
- CertificateUnableToCheckRevocation = -205,
- CertificateRevoked = -206,
- CertificateInvalid = -207,
- CertificateWeakSignatureAlgorithm = -208,
- CertificateNonUniqueName = -210,
- CertificateWeakKey = -211,
- CertificateNameConstraintViolation = -212,
- CertificateValidityTooLong = -213,
- CertificateTransparencyRequired = -214,
- CertificateSymantecLegacy = -215,
- CertificateKnownInterceptionBlocked = -217,
- CertificateErrorEnd = -218 // not an error, just an enum boundary
- };
-
- CertificateError error() const;
+ QWebEngineCertificateError::Type error() const;
QUrl url() const;
bool overridable() const;
- bool strictEnforcement() const;
QString errorString() const;
- QDateTime validStart() const;
QDateTime validExpiry() const;
QList<QSslCertificate> certificateChain() const;
+ bool deferred() const;
+ void defer();
+
+ bool answered() const;
void accept(bool);
- // Note: The resource type should probably not be exported, since once accepted the certificate exception
- // counts for all resource types.
- // Keep up to date with webkit/common/resource_type.h
- enum ResourceType {
- ResourceTypeMainFrame = 0, // top level page
- ResourceTypeSubFrame, // frame or iframe
- ResourceTypeStylesheet, // a CSS stylesheet
- ResourceTypeScript, // an external script
- ResourceTypeImage, // an image (jpg/gif/png/etc)
- ResourceTypeFont, // a font
- ResourceTypeOther, // an "other" subresource.
- ResourceTypeObject, // an object (or embed) tag for a plugin,
- // or a resource that a plugin requested.
- ResourceTypeMedia, // a media resource.
- ResourceTypeWorker, // the main resource of a dedicated worker.
- ResourceTypeSharedWorker, // the main resource of a shared worker.
- ResourceTypePrefetch, // an explicitly requested prefetch
- ResourceTypeFavicon, // a favicon
- ResourceTypeXHR, // a XMLHttpRequest
- ResourceTypePing, // a ping request for <a ping>
- ResourceTypeServiceWorker, // the main resource of a service worker.
- };
+ void ignoreCertificateError() { accept(true); }
+ void rejectCertificate() { accept(false); }
- ResourceType resourceType() const;
+ void deactivate();
+
+ QWebEngineCertificateError::Type m_certError;
+ const QUrl m_requestUrl;
+ QDateTime m_validExpiry;
+ bool m_overridable;
+ base::OnceCallback<void(content::CertificateRequestResultType)> m_callback;
+ QList<QSslCertificate> m_certificateChain;
+
+ bool m_answered = false, m_deferred = false;
private:
- CertificateErrorControllerPrivate* d;
+ Q_DISABLE_COPY(CertificateErrorController)
};
-QT_END_NAMESPACE
-
+}
#endif // CERTIFICATE_ERROR_CONTROLLER_H
diff --git a/src/core/client_cert_select_controller.cpp b/src/core/client_cert_select_controller.cpp
index 0baaf2bc5..2f2d24716 100644
--- a/src/core/client_cert_select_controller.cpp
+++ b/src/core/client_cert_select_controller.cpp
@@ -50,9 +50,7 @@
#include <QDebug>
-QT_BEGIN_NAMESPACE
-
-using namespace QtWebEngineCore;
+namespace QtWebEngineCore {
ClientCertSelectController::ClientCertSelectController(net::SSLCertRequestInfo *certRequestInfo,
std::vector<std::unique_ptr<net::ClientCertIdentity>> clientCerts,
@@ -73,8 +71,6 @@ ClientCertSelectController::~ClientCertSelectController()
m_delegate->ContinueWithCertificate(nullptr, nullptr);
}
-#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
-
void ClientCertSelectController::selectNone()
{
if (m_selected) {
@@ -132,7 +128,7 @@ void ClientCertSelectController::select(const QSslCertificate &certificate)
<< " Selected certificate needs to be one of the offered";
}
-QVector<QSslCertificate> ClientCertSelectController::certificates() const
+QList<QSslCertificate> ClientCertSelectController::certificates() const
{
if (!m_certificates.isEmpty())
return m_certificates;
@@ -144,6 +140,4 @@ QVector<QSslCertificate> ClientCertSelectController::certificates() const
return m_certificates;
}
-#endif // !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
-
-QT_END_NAMESPACE
+}
diff --git a/src/core/client_cert_select_controller.h b/src/core/client_cert_select_controller.h
index f121c1155..3a733f56f 100644
--- a/src/core/client_cert_select_controller.h
+++ b/src/core/client_cert_select_controller.h
@@ -55,10 +55,8 @@
#include <QtNetwork/qtnetwork-config.h>
#include <QtCore/QUrl>
-#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
-#include <QtCore/QVector>
+#include <QtCore/QList>
#include <QtNetwork/QSslCertificate>
-#endif
#include <memory>
namespace content {
@@ -70,7 +68,7 @@ class ClientCertIdentity;
class SSLCertRequestInfo;
}
-QT_BEGIN_NAMESPACE
+namespace QtWebEngineCore {
class Q_WEBENGINECORE_PRIVATE_EXPORT ClientCertSelectController {
public:
@@ -80,22 +78,20 @@ public:
~ClientCertSelectController();
QUrl hostAndPort() const { return m_hostAndPort; }
-#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
void selectNone();
void select(const QSslCertificate &certificate);
void select(int index);
- QVector<QSslCertificate> certificates() const;
-#endif
+ QList<QSslCertificate> certificates() const;
private:
QUrl m_hostAndPort;
std::vector<std::unique_ptr<net::ClientCertIdentity>> m_clientCerts;
std::unique_ptr<content::ClientCertificateDelegate> m_delegate;
- mutable QVector<QSslCertificate> m_certificates;
+ mutable QList<QSslCertificate> m_certificates;
bool m_selected;
};
-QT_END_NAMESPACE
+}
#endif // CLIENT_CERT_SELECT_CONTROLLER_H
diff --git a/src/core/compositor/chromium_gpu_helper.cpp b/src/core/compositor/chromium_gpu_helper.cpp
deleted file mode 100644
index 1ddbf75e5..000000000
--- a/src/core/compositor/chromium_gpu_helper.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
-
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE.Chromium file.
-
-#include "chromium_gpu_helper.h"
-
-// Some headers include the namespace ws, and can not coexist with
-// Qt headers that include QTextStream, which includes most QSG headers
-// via QMatrix4x4.
-#include "content/browser/renderer_host/render_widget_host_impl.h"
-
-// Including gpu/command_buffer headers before content/gpu headers makes sure that
-// guards are defined to prevent duplicate definition errors with forward declared
-// GL typedefs cascading through content header includes.
-#include "gpu/command_buffer/service/mailbox_manager.h"
-#include "gpu/command_buffer/service/texture_base.h"
-
-#include "content/gpu/gpu_child_thread.h"
-#include "gpu/ipc/service/gpu_channel_manager.h"
-
-#include <QtGlobal> // We need this for Q_UNUSED
-
-scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner()
-{
- return content::GpuChildThread::instance()->main_thread_runner();
-}
-
-gpu::MailboxManager *mailbox_manager()
-{
- gpu::GpuChannelManager *gpuChannelManager = content::GpuChildThread::instance()->gpu_channel_manager();
- return gpuChannelManager->mailbox_manager();
-}
-
-gpu::TextureBase* ConsumeTexture(gpu::MailboxManager *mailboxManager, unsigned target, const gpu::Mailbox& mailbox)
-{
- Q_UNUSED(target);
- return mailboxManager->ConsumeTexture(mailbox);
-}
-
-unsigned int service_id(gpu::TextureBase *tex)
-{
- return tex->service_id();
-}
-
-void ProgressFlingIfNeeded(content::RenderWidgetHost *host, const base::TimeTicks &current_time)
-{
- content::RenderWidgetHostImpl::From(host)->ProgressFlingIfNeeded(current_time);
-}
diff --git a/src/core/compositor/chromium_gpu_helper.h b/src/core/compositor/chromium_gpu_helper.h
deleted file mode 100644
index e692b9b85..000000000
--- a/src/core/compositor/chromium_gpu_helper.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 CHROMIUM_GPU_HELPER_H
-#define CHROMIUM_GPU_HELPER_H
-
-#include "base/memory/scoped_refptr.h"
-
-namespace base {
-class SingleThreadTaskRunner;
-class TimeTicks;
-}
-
-namespace content {
-class RenderWidgetHost;
-}
-
-namespace gpu {
-struct Mailbox;
-class MailboxManager;
-class TextureBase;
-}
-
-// These functions wrap code that needs to include headers that are
-// incompatible with Qt GL headers.
-// From the outside, types from incompatible headers referenced in these
-// functions should only be forward-declared and considered as opaque types.
-
-scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner();
-gpu::MailboxManager *mailbox_manager();
-
-gpu::TextureBase* ConsumeTexture(gpu::MailboxManager *mailboxManager, unsigned target, const gpu::Mailbox& mailbox);
-unsigned int service_id(gpu::TextureBase *tex);
-
-void ProgressFlingIfNeeded(content::RenderWidgetHost *host, const base::TimeTicks &current_time);
-
-#endif // CHROMIUM_GPU_HELPER_H
diff --git a/src/core/compositor/compositor.cpp b/src/core/compositor/compositor.cpp
index 82a9f7ee4..655126f20 100644
--- a/src/core/compositor/compositor.cpp
+++ b/src/core/compositor/compositor.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2018 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
@@ -39,149 +39,159 @@
#include "compositor.h"
-#include "compositor_resource_tracker.h"
-#include "delegated_frame_node.h"
+#include "base/memory/ref_counted.h"
+#include "components/viz/common/surfaces/frame_sink_id.h"
-#include "base/task/post_task.h"
-#include "components/viz/common/resources/returned_resource.h"
-#include "content/public/browser/browser_task_traits.h"
-#include "content/public/browser/browser_thread.h"
-#include "services/viz/privileged/mojom/compositing/frame_sink_manager.mojom.h"
+#include <QHash>
+#include <QImage>
+#include <QMutex>
namespace QtWebEngineCore {
-Compositor::Compositor(content::RenderWidgetHost *host)
- : m_resourceTracker(new CompositorResourceTracker)
- , m_host(host)
-{
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+// Compositor::Id
- m_taskRunner = base::CreateSingleThreadTaskRunner({content::BrowserThread::UI, base::TaskPriority::USER_VISIBLE});
- m_beginFrameSource =
- std::make_unique<viz::DelayBasedBeginFrameSource>(
- std::make_unique<viz::DelayBasedTimeSource>(m_taskRunner.get()),
- viz::BeginFrameSource::kNotRestartableId);
-}
+Compositor::Id::Id(viz::FrameSinkId fid) : client_id(fid.client_id()), sink_id(fid.sink_id()) { }
-Compositor::~Compositor()
+static size_t qHash(Compositor::Id id, size_t seed = 0)
{
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ QtPrivate::QHashCombine hasher;
+ seed = hasher(seed, id.client_id);
+ seed = hasher(seed, id.sink_id);
+ return seed;
}
-void Compositor::setFrameSinkClient(viz::mojom::CompositorFrameSinkClient *frameSinkClient)
+static bool operator==(Compositor::Id id1, Compositor::Id id2)
{
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ return id1.client_id == id2.client_id && id1.sink_id == id2.sink_id;
+}
- if (m_frameSinkClient == frameSinkClient)
- return;
+// Compositor::Binding and Compositor::Bindings
- // Accumulated resources belong to the old RendererCompositorFrameSink and
- // should not be returned.
- //
- // TODO(juvaldma): Can there be a pending frame from the old client?
- m_resourceTracker->returnResources();
- m_frameSinkClient = frameSinkClient;
-}
+struct Compositor::Binding
+{
+ const Id id;
+ Compositor *compositor = nullptr;
+ Observer *observer = nullptr;
+
+ Binding(Id id) : id(id) { }
+ ~Binding();
+};
-void Compositor::setNeedsBeginFrames(bool needsBeginFrames)
+class Compositor::BindingMap
{
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+public:
+ void lock() { m_mutex.lock(); }
- if (m_needsBeginFrames == needsBeginFrames)
- return;
+ void unlock() { m_mutex.unlock(); }
- if (needsBeginFrames)
- m_beginFrameSource->AddObserver(this);
- else
- m_beginFrameSource->RemoveObserver(this);
+ Binding *findOrCreate(Id id)
+ {
+ auto it = m_map.find(id);
+ if (it == m_map.end())
+ it = m_map.insert(id, new Binding(id));
+ return *it;
+ }
- m_needsBeginFrames = needsBeginFrames;
-}
+ void remove(Id id) { m_map.remove(id); }
+
+private:
+ QMutex m_mutex;
+ QHash<Id, Binding *> m_map;
+} static g_bindings;
-void Compositor::submitFrame(viz::CompositorFrame frame, base::OnceClosure callback)
+Compositor::Binding::~Binding()
{
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- DCHECK(!m_submitCallback);
-
- m_pendingFrame = std::move(frame);
- m_submitCallback = std::move(callback);
- m_resourceTracker->submitResources(
- m_pendingFrame,
- base::BindOnce(&Compositor::runSubmitCallback, base::Unretained(this)));
+ g_bindings.remove(id);
}
-QSGNode *Compositor::updatePaintNode(QSGNode *oldNode, RenderWidgetHostViewQtDelegate *viewDelegate)
+// Compositor::Observer
+
+void Compositor::Observer::bind(Id id)
{
- // DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- //
- // This might be called from a Qt Quick render thread, but the UI thread
- // will still be blocked for the duration of this call.
-
- DelegatedFrameNode *frameNode = static_cast<DelegatedFrameNode *>(oldNode);
- if (!frameNode)
- frameNode = new DelegatedFrameNode;
-
- if (!m_updatePaintNodeShouldCommit) {
- frameNode->commit(m_committedFrame, viz::CompositorFrame(), m_resourceTracker.get(), viewDelegate);
- return frameNode;
- }
- m_updatePaintNodeShouldCommit = false;
+ DCHECK(!m_binding);
+ g_bindings.lock();
+ m_binding = g_bindings.findOrCreate(id);
+ DCHECK(!m_binding->observer);
+ m_binding->observer = this;
+ g_bindings.unlock();
+}
- m_presentations.emplace(m_committedFrame.metadata.frame_token, viz::FrameTimingDetails{base::TimeTicks::Now()});
+void Compositor::Observer::unbind()
+{
+ DCHECK(m_binding);
+ g_bindings.lock();
+ m_binding->observer = nullptr;
+ if (m_binding->compositor == nullptr)
+ delete m_binding;
+ m_binding = nullptr;
+ g_bindings.unlock();
+}
- m_resourceTracker->commitResources();
- frameNode->commit(m_pendingFrame, m_committedFrame, m_resourceTracker.get(), viewDelegate);
- m_committedFrame = std::move(m_pendingFrame);
- m_pendingFrame = viz::CompositorFrame();
+Compositor::Handle<Compositor> Compositor::Observer::compositor()
+{
+ if (!m_binding)
+ return nullptr;
+ g_bindings.lock();
+ if (m_binding->compositor)
+ return m_binding->compositor; // delay unlock
+ g_bindings.unlock();
+ return nullptr;
+}
- m_taskRunner->PostTask(FROM_HERE,
- base::BindOnce(&Compositor::notifyFrameCommitted, m_weakPtrFactory.GetWeakPtr()));
+// Compositor
- return frameNode;
+void Compositor::bind(Id id)
+{
+ DCHECK(!m_binding);
+ g_bindings.lock();
+ m_binding = g_bindings.findOrCreate(id);
+ DCHECK(!m_binding->compositor);
+ m_binding->compositor = this;
+ g_bindings.unlock();
}
-void Compositor::runSubmitCallback()
+void Compositor::unbind()
{
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
-
- m_updatePaintNodeShouldCommit = true;
- std::move(m_submitCallback).Run();
+ DCHECK(m_binding);
+ g_bindings.lock();
+ m_binding->compositor = nullptr;
+ if (m_binding->observer == nullptr)
+ delete m_binding;
+ m_binding = nullptr;
+ g_bindings.unlock();
}
-void Compositor::notifyFrameCommitted()
+Compositor::Handle<Compositor::Observer> Compositor::observer()
{
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
-
- m_beginFrameSource->DidFinishFrame(this);
- if (m_frameSinkClient)
- m_frameSinkClient->DidReceiveCompositorFrameAck(m_resourceTracker->returnResources());
+ if (!m_binding)
+ return nullptr;
+ g_bindings.lock();
+ if (m_binding->observer)
+ return m_binding->observer; // delay unlock
+ g_bindings.unlock();
+ return nullptr;
}
-void Compositor::sendPresentationFeedback(uint frame_token)
+QImage Compositor::image()
{
- viz::FrameTimingDetails dummyDetails = {base::TimeTicks::Now()};
- m_presentations.emplace(frame_token, dummyDetails);
+ Q_UNREACHABLE();
+ return {};
}
-bool Compositor::OnBeginFrameDerivedImpl(const viz::BeginFrameArgs &args)
+void Compositor::waitForTexture()
{
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
-
- ProgressFlingIfNeeded(m_host, args.frame_time);
- m_beginFrameSource->OnUpdateVSyncParameters(args.frame_time, args.interval);
- if (m_frameSinkClient) {
- m_frameSinkClient->OnBeginFrame(args, m_presentations);
- m_presentations.clear();
- }
-
- return true;
+ Q_UNREACHABLE();
}
-void Compositor::OnBeginFrameSourcePausedChanged(bool)
+int Compositor::textureId()
{
- // Ignored for now. If the begin frame source is paused, the renderer
- // doesn't need to be informed about it and will just not receive more
- // begin frames.
+ Q_UNREACHABLE();
+ return 0;
}
+// static
+void Compositor::unlockBindings()
+{
+ g_bindings.unlock();
+}
} // namespace QtWebEngineCore
diff --git a/src/core/compositor/compositor.h b/src/core/compositor/compositor.h
index 36e62c17a..316178891 100644
--- a/src/core/compositor/compositor.h
+++ b/src/core/compositor/compositor.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2018 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
@@ -40,90 +40,154 @@
#ifndef COMPOSITOR_H
#define COMPOSITOR_H
-#include "base/memory/weak_ptr.h"
-#include "components/viz/common/frame_timing_details.h"
-#include "components/viz/common/frame_sinks/begin_frame_source.h"
-#include "components/viz/common/quads/compositor_frame.h"
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qshareddata.h>
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qshareddata.h>
+#include "qtwebenginecoreglobal_p.h"
QT_BEGIN_NAMESPACE
-class QSGNode;
+class QImage;
+class QSize;
QT_END_NAMESPACE
-namespace content {
-class RenderWidgetHost;
-}
namespace viz {
-struct ReturnedResource;
-namespace mojom {
-class CompositorFrameSinkClient;
-} // namespace mojom
+class FrameSinkId;
} // namespace viz
namespace QtWebEngineCore {
-class CompositorResourceTracker;
-class RenderWidgetHostViewQtDelegate;
-
-// Receives viz::CompositorFrames from child compositors and provides QSGNodes
-// to the Qt Quick renderer.
-//
-// The life cycle of a frame:
-//
-// Step 1. A new CompositorFrame is received from child compositors and handed
-// off to submitFrame(). The new frame will start off in a pending state.
+// Produces composited frames for display.
//
-// Step 2. Once the new frame is ready to be rendered, Compositor will notify
-// the client by running the callback given to submitFrame().
-//
-// Step 3. Once the client is ready to render, updatePaintNode() should be
-// called to receive the scene graph for the new frame. This call will commit
-// the pending frame. Until the next frame is ready, all subsequent calls to
-// updatePaintNode() will keep using this same committed frame.
-//
-// Step 4. The Compositor will return unneeded resources back to the child
-// compositors. Go to step 1.
-class Compositor final : private viz::BeginFrameObserverBase
+// Used by quick/widgets libraries for accessing the frame and
+// controlling frame swapping. Must be cast to a subclass to access
+// the frame as QImage or OpenGL texture, etc.
+class Q_WEBENGINECORE_PRIVATE_EXPORT Compositor
{
+ struct Binding;
+
public:
- explicit Compositor(content::RenderWidgetHost *host);
- ~Compositor() override;
+ // Identifies the implementation type.
+ enum class Type {
+ Software,
+ OpenGL,
+ };
+
+ // Identifies a compositor.
+ //
+ // The purpose of assigning ids to compositors is to allow the
+ // corresponding observer to be registered before the compositor
+ // itself is created, which is necessary since the creation
+ // happens on a different thread in the depths of viz.
+ //
+ // (Maps to viz::FrameSinkId internally).
+ struct Id
+ {
+ quint32 client_id;
+ quint32 sink_id;
+
+ Id(viz::FrameSinkId);
+ };
+
+ // Pointer to Compositor or Observer that holds a lock to prevent
+ // either from being unbound and destroyed.
+ template<typename T>
+ class Handle
+ {
+ public:
+ Handle(std::nullptr_t) : m_data(nullptr) { }
+ Handle(T *data) : m_data(data) { }
+ Handle(Handle &&that) : m_data(that.m_data) { that.m_data = nullptr; }
+ ~Handle()
+ {
+ if (m_data)
+ Compositor::unlockBindings();
+ }
+ T *operator->() const { return m_data; }
+ T &operator*() const { return *m_data; }
+ explicit operator bool() const { return m_data; }
+
+ private:
+ T *m_data;
+ };
+
+ // Observes the compositor corresponding to the given id.
+ //
+ // Only one observer can exist per compositor.
+ class Q_WEBENGINECORE_PRIVATE_EXPORT Observer
+ {
+ public:
+ // Binding to compositor
+ void bind(Id id);
+ void unbind();
+
+ // Compositor if bound
+ Handle<Compositor> compositor();
+
+ // There's a new frame ready, time to swapFrame().
+ virtual void readyToSwap() = 0;
+
+ protected:
+ Observer() = default;
+ ~Observer() = default;
+
+ private:
+ Binding *m_binding = nullptr;
+ };
+
+ // Type determines which methods can be called.
+ Type type() const { return m_type; }
+
+ // Binding to observer.
+ void bind(Id id);
+ void unbind();
+
+ // Observer if bound.
+ Handle<Observer> observer();
+
+ // Update to next frame if possible.
+ virtual void swapFrame() = 0;
+
+ // Ratio of pixels to DIPs.
+ //
+ // Don't use the devicePixelRatio of QImage, it's always 1.
+ virtual float devicePixelRatio() = 0;
+
+ // Size of frame in pixels.
+ virtual QSize size() = 0;
+
+ // Whether frame needs an alpha channel.
+ //
+ // In software mode, the image format can be either
+ // QImage::Format_ARGB32_Premultiplied or
+ // QImage::Format_RGBA8888_Premultiplied
+ //
+ // In OpenGL mode, the texture format is either GL_RGBA or GL_RGB.
+ virtual bool hasAlphaChannel() = 0;
+
+ // (Software) QImage of the frame.
+ //
+ // This is a big image so we should try not to make copies of it.
+ // In particular, the client should drop its QImage reference
+ // before calling swapFrame(), otherwise each swap will cause a
+ // detach.
+ virtual QImage image();
+
+ // (OpenGL) Wait on texture fence in Qt's current OpenGL context.
+ virtual void waitForTexture();
+
+ // (OpenGL) Texture of the frame.
+ virtual int textureId();
+
+protected:
+ Compositor(Type type) : m_type(type) { }
+ ~Compositor() = default;
- void setFrameSinkClient(viz::mojom::CompositorFrameSinkClient *frameSinkClient);
- void setNeedsBeginFrames(bool needsBeginFrames);
+private:
+ template<typename T>
+ friend class Handle;
- void submitFrame(viz::CompositorFrame frame, base::OnceClosure callback);
- QSGNode *updatePaintNode(QSGNode *oldNode, RenderWidgetHostViewQtDelegate *viewDelegate);
+ class BindingMap;
+ static void unlockBindings();
-private:
- void runSubmitCallback();
- void notifyFrameCommitted();
- void sendPresentationFeedback(uint frame_token);
-
- // viz::BeginFrameObserverBase
- bool OnBeginFrameDerivedImpl(const viz::BeginFrameArgs &args) override;
- void OnBeginFrameSourcePausedChanged(bool paused) override;
-
- viz::CompositorFrame m_committedFrame;
- viz::CompositorFrame m_pendingFrame;
- base::OnceClosure m_submitCallback;
- std::unique_ptr<CompositorResourceTracker> m_resourceTracker;
- content::RenderWidgetHost *m_host;
- std::unique_ptr<viz::SyntheticBeginFrameSource> m_beginFrameSource;
- base::flat_map<uint32_t, viz::FrameTimingDetails> m_presentations;
- viz::mojom::CompositorFrameSinkClient *m_frameSinkClient = nullptr;
- bool m_updatePaintNodeShouldCommit = false;
- bool m_needsBeginFrames = false;
-
- scoped_refptr<base::SingleThreadTaskRunner> m_taskRunner;
- base::WeakPtrFactory<Compositor> m_weakPtrFactory{this};
-
- DISALLOW_COPY_AND_ASSIGN(Compositor);
+ const Type m_type;
+ Binding *m_binding = nullptr;
};
} // namespace QtWebEngineCore
diff --git a/src/core/compositor/compositor_resource.h b/src/core/compositor/compositor_resource.h
deleted file mode 100644
index f7df2ab59..000000000
--- a/src/core/compositor/compositor_resource.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
-**
-** 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 COMPOSITOR_RESOURCE_H
-#define COMPOSITOR_RESOURCE_H
-
-#include <base/memory/ref_counted.h>
-#include <components/viz/common/resources/transferable_resource.h>
-
-#include <QtCore/qglobal.h>
-#include <QtGui/qtgui-config.h>
-
-#if QT_CONFIG(opengl)
-# include "compositor_resource_fence.h"
-#endif
-
-namespace viz {
-class SharedBitmap;
-} // namespace viz
-
-namespace QtWebEngineCore {
-
-using CompositorResourceId = quint32;
-
-// A resource (OpenGL texture or software shared bitmap).
-//
-// - Created by the CompositorResourceTracker from a newly submitted
-// CompositorFrame's resource_list.
-//
-// - Until the frame is committed, its resources are in a 'pending' state and
-// are inaccessible from outside the CompositorResourceTracker.
-//
-// - Once the frame is committed, its resources can be found via
-// CompositorResourceTracker::findResource.
-//
-// - A committed resource's fields may not be updated and are safe to use from
-// other threads without synchronization (unless noted otherwise).
-class CompositorResource : public viz::TransferableResource
-{
-public:
- CompositorResource(const viz::TransferableResource &tr) : viz::TransferableResource(tr) {}
-
- // Counts the number of times this resource has been encountered in
- // CompositorFrames' resource lists.
- //
- // Corresponds to viz::ReturnedResource::count.
- //
- // Updated by CompositorResourceTracker on UI thread.
- int import_count = 1;
-
- // Identifies the last frame that needed this resource. Used by
- // CompositorResourceTracker to return unused resources back to child
- // compositors.
- //
- // Updated by CompositorResourceTracker on UI thread.
- quint32 last_used_for_frame = 0;
-
- // Bitmap (if is_software).
- std::unique_ptr<viz::SharedBitmap> bitmap;
-
-#if QT_CONFIG(opengl)
- // OpenGL texture id (if !is_software).
- quint32 texture_id = 0;
-
- // Should be waited on before using the texture (non-null if !is_software).
- scoped_refptr<CompositorResourceFence> texture_fence;
-#endif // QT_CONFIG(opengl)
-};
-
-inline bool operator<(const CompositorResource &r1, const CompositorResource &r2)
-{
- return r1.id < r2.id;
-}
-
-inline bool operator<(const CompositorResource &r, CompositorResourceId id)
-{
- return r.id < id;
-}
-
-inline bool operator<(CompositorResourceId id, const CompositorResource &r)
-{
- return id < r.id;
-}
-
-} // namespace QtWebEngineCore
-
-#endif // !COMPOSITOR_RESOURCE_H
diff --git a/src/core/compositor/compositor_resource_tracker.cpp b/src/core/compositor/compositor_resource_tracker.cpp
deleted file mode 100644
index 1e7108571..000000000
--- a/src/core/compositor/compositor_resource_tracker.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-/****************************************************************************
-**
-** 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 "compositor_resource_tracker.h"
-
-#include "chromium_gpu_helper.h"
-#include "render_widget_host_view_qt_delegate.h"
-#include "web_engine_context.h"
-
-#include "base/message_loop/message_loop.h"
-#include "base/task/post_task.h"
-#include "components/viz/common/quads/compositor_frame.h"
-#include "components/viz/common/resources/returned_resource.h"
-#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
-#include "content/browser/browser_main_loop.h"
-#include "content/public/browser/browser_task_traits.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/gpu/content_gpu_client.h"
-#include "gpu/command_buffer/service/mailbox_manager.h"
-#include "gpu/command_buffer/service/sync_point_manager.h"
-
-namespace QtWebEngineCore {
-
-CompositorResourceTracker::CompositorResourceTracker()
-{}
-
-CompositorResourceTracker::~CompositorResourceTracker()
-{}
-
-void CompositorResourceTracker::submitResources(const viz::CompositorFrame &frame, base::OnceClosure callback)
-{
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- DCHECK(!m_submitCallback);
- DCHECK(m_pendingResources.empty());
- DCHECK(m_pendingImports.empty());
- DCHECK(m_pendingResourceUpdates == 0);
-
- m_submitCallback = std::move(callback);
-
- m_pendingResources.reserve(frame.resource_list.size());
- m_pendingImports.reserve(frame.resource_list.size());
-
- for (const viz::TransferableResource &transferableResource : frame.resource_list) {
- auto it = m_committedResources.find(transferableResource.id);
- if (it != m_committedResources.end())
- m_pendingImports.push_back(&*it);
- else
- m_pendingResources.emplace_back(transferableResource);
- }
-
- if (m_pendingResources.empty()) {
- scheduleRunSubmitCallback();
- return;
- }
-
- m_pendingResourceUpdates = m_pendingResources.size();
-
- std::vector<CompositorResource *> batch;
- batch.reserve(m_pendingResources.size());
-
- for (CompositorResource &resource : m_pendingResources) {
- if (resource.is_software)
- updateBitmap(&resource);
- else if (!scheduleUpdateMailbox(&resource))
- batch.push_back(&resource);
- }
-
- if (!batch.empty())
- scheduleUpdateMailboxes(std::move(batch));
-}
-
-void CompositorResourceTracker::commitResources()
-{
- // DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- //
- // This might be called from a Qt Quick render thread, but the UI thread
- // will still be blocked for the duration of this call.
-
- DCHECK(m_pendingResourceUpdates == 0);
-
- for (CompositorResource *resource : m_pendingImports)
- resource->import_count++;
- m_pendingImports.clear();
-
- m_committedResources.insert(std::make_move_iterator(m_pendingResources.begin()),
- std::make_move_iterator(m_pendingResources.end()));
- m_pendingResources.clear();
-
- ++m_committedFrameId;
-}
-
-std::vector<viz::ReturnedResource> CompositorResourceTracker::returnResources()
-{
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
-
- std::vector<viz::ReturnedResource> returnedResources;
- base::EraseIf(m_committedResources, [&](const CompositorResource &resource) {
- if (resource.last_used_for_frame != m_committedFrameId) {
- viz::ReturnedResource returnedResource;
- returnedResource.id = resource.id;
- returnedResource.count = resource.import_count;
- returnedResources.push_back(std::move(returnedResource));
- return true;
- }
- return false;
- });
- return returnedResources;
-}
-
-const CompositorResource *CompositorResourceTracker::findResource(CompositorResourceId id) const
-{
- auto it = m_committedResources.find(id);
- DCHECK(it != m_committedResources.end());
-
- const_cast<CompositorResource &>(*it).last_used_for_frame = m_committedFrameId;
-
- return &*it;
-}
-
-void CompositorResourceTracker::updateBitmap(CompositorResource *resource)
-{
- content::BrowserMainLoop *browserMainLoop = content::BrowserMainLoop::GetInstance();
- viz::ServerSharedBitmapManager *bitmapManager = browserMainLoop->GetServerSharedBitmapManager();
-
- resource->bitmap = bitmapManager->GetSharedBitmapFromId(
- resource->size,
- viz::BGRA_8888,
- resource->mailbox_holder.mailbox);
-
- if (--m_pendingResourceUpdates == 0)
- scheduleRunSubmitCallback();
-}
-
-quint32 CompositorResourceTracker::consumeMailbox(const gpu::MailboxHolder &mailboxHolder)
-{
-#if QT_CONFIG(opengl)
- gpu::MailboxManager *mailboxManager = mailbox_manager();
- DCHECK(mailboxManager);
- if (mailboxHolder.sync_token.HasData())
- mailboxManager->PullTextureUpdates(mailboxHolder.sync_token);
- gpu::TextureBase *tex = mailboxManager->ConsumeTexture(mailboxHolder.mailbox);
- return tex ? service_id(tex) : 0;
-#else
- NOTREACHED();
-#endif // QT_CONFIG(OPENGL)
-}
-
-bool CompositorResourceTracker::scheduleUpdateMailbox(CompositorResource *resource)
-{
-#if QT_CONFIG(opengl)
- gpu::SyncPointManager *syncPointManager = WebEngineContext::syncPointManager();
- DCHECK(syncPointManager);
- return syncPointManager->WaitOutOfOrder(
- resource->mailbox_holder.sync_token,
- base::BindOnce(&CompositorResourceTracker::updateMailbox,
- m_weakPtrFactory.GetWeakPtr(),
- resource));
-#else
- NOTREACHED();
-#endif // QT_CONFIG(OPENGL)
-}
-
-void CompositorResourceTracker::updateMailbox(CompositorResource *resource)
-{
-#if QT_CONFIG(opengl)
- resource->texture_id = consumeMailbox(resource->mailbox_holder);
- resource->texture_fence = CompositorResourceFence::create();
-
- if (--m_pendingResourceUpdates == 0)
- scheduleRunSubmitCallback();
-#else
- NOTREACHED();
-#endif // QT_CONFIG(OPENGL)
-}
-
-void CompositorResourceTracker::scheduleUpdateMailboxes(std::vector<CompositorResource *> resources)
-{
-#if QT_CONFIG(opengl)
- scoped_refptr<base::SingleThreadTaskRunner> gpuTaskRunner = gpu_task_runner();
- DCHECK(gpuTaskRunner);
- thread_local bool currentThreadIsGpu = gpuTaskRunner->BelongsToCurrentThread();
- if (currentThreadIsGpu)
- return updateMailboxes(std::move(resources));
- gpuTaskRunner->PostTask(
- FROM_HERE,
- base::BindOnce(&CompositorResourceTracker::updateMailboxes,
- m_weakPtrFactory.GetWeakPtr(),
- std::move(resources)));
-#else
- NOTREACHED();
-#endif // QT_CONFIG(OPENGL)
-}
-
-void CompositorResourceTracker::updateMailboxes(std::vector<CompositorResource *> resources)
-{
-#if QT_CONFIG(opengl)
- for (CompositorResource *resource : resources)
- resource->texture_id = consumeMailbox(resource->mailbox_holder);
-
- scoped_refptr<CompositorResourceFence> fence = CompositorResourceFence::create();
-
- for (CompositorResource *resource : resources)
- resource->texture_fence = fence;
-
- if ((m_pendingResourceUpdates -= resources.size()) == 0)
- scheduleRunSubmitCallback();
-#else
- NOTREACHED();
-#endif // QT_CONFIG(OPENGL)
-}
-
-void CompositorResourceTracker::scheduleRunSubmitCallback()
-{
- thread_local bool currentThreadIsUi = content::BrowserThread::CurrentlyOn(content::BrowserThread::UI);
- if (currentThreadIsUi)
- return runSubmitCallback();
- base::PostTask(
- FROM_HERE, { content::BrowserThread::UI, base::TaskPriority::USER_VISIBLE },
- base::BindOnce(&CompositorResourceTracker::runSubmitCallback,
- m_weakPtrFactory.GetWeakPtr()));
-}
-
-void CompositorResourceTracker::runSubmitCallback()
-{
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
-
- std::move(m_submitCallback).Run();
-}
-
-} // namespace QtWebEngineCore
diff --git a/src/core/compositor/compositor_resource_tracker.h b/src/core/compositor/compositor_resource_tracker.h
deleted file mode 100644
index 080891e5f..000000000
--- a/src/core/compositor/compositor_resource_tracker.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** 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 COMPOSITOR_RESOURCE_TRACKER_H
-#define COMPOSITOR_RESOURCE_TRACKER_H
-
-#include "base/bind.h"
-#include "base/callback.h"
-#include "base/containers/flat_set.h"
-
-#include "compositor_resource.h"
-#include "locked_ptr.h"
-
-#include <atomic>
-#include <vector>
-
-namespace viz {
-class CompositorFrame;
-struct ReturnedResource;
-} // namespace viz
-
-namespace gpu {
-struct MailboxHolder;
-} // namespace gpu
-
-namespace QtWebEngineCore {
-
-// Ensures resources are not used before they are ready.
-//
-// The life cycle of a frame's resources:
-//
-// Step 1. A new CompositorFrame is received and given to submitResources().
-// The frame's resources will extracted and initialized to a pending state.
-//
-// Step 2. Once the new resources are ready to be committed,
-// CompositorResourceTracker will notify the client by running the callback
-// given to submitResources().
-//
-// Step 3. Once the client is ready to render, commitResources() should be
-// called. This will commit all the pending resources, making them available
-// via findResource().
-//
-// Step 4. Once all the resources have been used (via findResource()),
-// returnResources() may be called to return a list of all the resources which
-// were *not* used since the last commitResources(). Go to step 1.
-class CompositorResourceTracker final
-{
-public:
- CompositorResourceTracker();
- ~CompositorResourceTracker();
-
- void submitResources(const viz::CompositorFrame &frame, base::OnceClosure callback);
- void commitResources();
- std::vector<viz::ReturnedResource> returnResources();
-
- // The returned pointer is invalidated by the next call to commitFrame() or
- // returnResources(). It should therefore not be stored in data structures
- // but used immediately.
- //
- // Do not ask for resources which do not exist.
- const CompositorResource *findResource(CompositorResourceId id) const;
-
-private:
- void updateBitmap(CompositorResource *resource);
-
- quint32 consumeMailbox(const gpu::MailboxHolder &mailboxHolder);
-
- bool scheduleUpdateMailbox(CompositorResource *resource);
- void updateMailbox(CompositorResource *resource);
-
- void scheduleUpdateMailboxes(std::vector<CompositorResource *> resources);
- void updateMailboxes(std::vector<CompositorResource *> resources);
-
- void scheduleRunSubmitCallback();
- void runSubmitCallback();
-
- base::flat_set<CompositorResource> m_committedResources;
- std::vector<CompositorResource> m_pendingResources;
- std::vector<CompositorResource *> m_pendingImports;
- base::OnceClosure m_submitCallback;
- std::atomic<size_t> m_pendingResourceUpdates{0};
- quint32 m_committedFrameId = 0;
-
- base::LockedPtrFactory<CompositorResourceTracker> m_weakPtrFactory{this};
-
- DISALLOW_COPY_AND_ASSIGN(CompositorResourceTracker);
-};
-
-} // namespace QtWebEngineCore
-
-#endif // !COMPOSITOR_RESOURCE_TRACKER_H
diff --git a/src/core/compositor/delegated_frame_node.cpp b/src/core/compositor/delegated_frame_node.cpp
deleted file mode 100644
index f182a2c9e..000000000
--- a/src/core/compositor/delegated_frame_node.cpp
+++ /dev/null
@@ -1,1101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
-
-// On Mac we need to reset this define in order to prevent definition
-// of "check" macros etc. The "check" macro collides with a member function name in QtQuick.
-// See AssertMacros.h in the Mac SDK.
-#include <QtGlobal> // We need this for the Q_OS_MAC define.
-#if defined(Q_OS_MAC)
-#undef __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES
-#define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
-#endif
-
-#include "delegated_frame_node.h"
-
-#include "chromium_gpu_helper.h"
-#include "stream_video_node.h"
-#include "type_conversion.h"
-#include "yuv_video_node.h"
-#include "compositor_resource_tracker.h"
-
-#include "base/bind.h"
-#include "cc/base/math_util.h"
-#include "components/viz/common/quads/compositor_frame.h"
-#include "components/viz/common/quads/debug_border_draw_quad.h"
-#include "components/viz/common/quads/draw_quad.h"
-#include "components/viz/common/quads/render_pass_draw_quad.h"
-#include "components/viz/common/quads/solid_color_draw_quad.h"
-#include "components/viz/common/quads/stream_video_draw_quad.h"
-#include "components/viz/common/quads/texture_draw_quad.h"
-#include "components/viz/common/quads/tile_draw_quad.h"
-#include "components/viz/common/quads/yuv_video_draw_quad.h"
-#include "components/viz/service/display/bsp_tree.h"
-#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
-
-#if QT_CONFIG(opengl)
-# include <QOpenGLContext>
-# include <QOpenGLFunctions>
-# include <QSGFlatColorMaterial>
-#endif
-#include <QSGTexture>
-#include <private/qsgadaptationlayer_p.h>
-
-#include <QSGImageNode>
-#include <QSGRectangleNode>
-
-#ifndef GL_TEXTURE_RECTANGLE
-#define GL_TEXTURE_RECTANGLE 0x84F5
-#endif
-
-#ifndef GL_NEAREST
-#define GL_NEAREST 0x2600
-#endif
-
-#ifndef GL_LINEAR
-#define GL_LINEAR 0x2601
-#endif
-
-#ifndef GL_RGBA
-#define GL_RGBA 0x1908
-#endif
-
-#ifndef GL_RGB
-#define GL_RGB 0x1907
-#endif
-
-#ifndef GL_LINE_LOOP
-#define GL_LINE_LOOP 0x0002
-#endif
-
-#if QT_CONFIG(opengl)
-QT_BEGIN_NAMESPACE
-Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();
-QT_END_NAMESPACE
-#endif
-
-namespace QtWebEngineCore {
-#if QT_CONFIG(opengl)
-class MailboxTexture : public QSGTexture, protected QOpenGLFunctions {
-public:
- MailboxTexture(const CompositorResource *resource, bool hasAlphaChannel, int target = -1);
- ~MailboxTexture();
- // QSGTexture:
- int textureId() const override { return m_textureId; }
- QSize textureSize() const override { return m_textureSize; }
- bool hasAlphaChannel() const override { return m_hasAlpha; }
- bool hasMipmaps() const override { return false; }
- void bind() override;
-
-private:
- int m_textureId;
- scoped_refptr<CompositorResourceFence> m_fence;
- QSize m_textureSize;
- bool m_hasAlpha;
- GLenum m_target;
-#if defined(USE_OZONE)
- bool m_ownsTexture;
-#endif
- friend class DelegatedFrameNode;
-};
-#endif // QT_CONFIG(opengl)
-
-class RectClipNode : public QSGClipNode
-{
-public:
- RectClipNode(const QRectF &);
-private:
- QSGGeometry m_geometry;
-};
-
-class DelegatedNodeTreeHandler
-{
-public:
- DelegatedNodeTreeHandler(QVector<QSGNode*> *sceneGraphNodes)
- : m_sceneGraphNodes(sceneGraphNodes)
- {
- }
-
- virtual ~DelegatedNodeTreeHandler(){}
-
- virtual void setupRenderPassNode(QSGTexture *, const QRect &, const QRectF &, QSGNode *) = 0;
- virtual void setupTextureContentNode(QSGTexture *, const QRect &, const QRectF &,
- QSGImageNode::TextureCoordinatesTransformMode,
- QSGNode *) = 0;
- virtual void setupSolidColorNode(const QRect &, const QColor &, QSGNode *) = 0;
-
-#if QT_CONFIG(opengl)
- virtual void setupDebugBorderNode(QSGGeometry *, QSGFlatColorMaterial *, QSGNode *) = 0;
- virtual void setupYUVVideoNode(QSGTexture *, QSGTexture *, QSGTexture *, QSGTexture *,
- const QRectF &, const QRectF &, const QSizeF &, const QSizeF &,
- gfx::ColorSpace, float, float, const QRectF &,
- QSGNode *) = 0;
-#ifdef GL_OES_EGL_image_external
- virtual void setupStreamVideoNode(MailboxTexture *, const QRectF &,
- const QMatrix4x4 &, QSGNode *) = 0;
-#endif // GL_OES_EGL_image_external
-#endif // QT_CONFIG(opengl)
-protected:
- QVector<QSGNode*> *m_sceneGraphNodes;
-};
-
-class DelegatedNodeTreeUpdater : public DelegatedNodeTreeHandler
-{
-public:
- DelegatedNodeTreeUpdater(QVector<QSGNode*> *sceneGraphNodes)
- : DelegatedNodeTreeHandler(sceneGraphNodes)
- , m_nodeIterator(sceneGraphNodes->begin())
- {
- }
-
- void setupRenderPassNode(QSGTexture *layer, const QRect &rect, const QRectF &sourceRect, QSGNode *) override
- {
- Q_ASSERT(layer);
- Q_ASSERT(m_nodeIterator != m_sceneGraphNodes->end());
- QSGImageNode *imageNode = static_cast<QSGImageNode*>(*m_nodeIterator++);
- imageNode->setRect(rect);
- imageNode->setSourceRect(sourceRect);
- imageNode->setTexture(layer);
- }
-
- void setupTextureContentNode(QSGTexture *texture, const QRect &rect, const QRectF &sourceRect,
- QSGImageNode::TextureCoordinatesTransformMode texCoordTransForm,
- QSGNode *) override
- {
- Q_ASSERT(m_nodeIterator != m_sceneGraphNodes->end());
- QSGImageNode *textureNode = static_cast<QSGImageNode*>(*m_nodeIterator++);
- if (textureNode->texture() != texture) {
- // Chromium sometimes uses textures that doesn't completely fit
- // in which case the geometry needs to be recalculated even if
- // rect and src-rect matches.
- if (textureNode->texture()->textureSize() != texture->textureSize())
- textureNode->markDirty(QSGImageNode::DirtyGeometry);
- textureNode->setTexture(texture);
- }
- if (textureNode->textureCoordinatesTransform() != texCoordTransForm)
- textureNode->setTextureCoordinatesTransform(texCoordTransForm);
- if (textureNode->rect() != rect)
- textureNode->setRect(rect);
- if (textureNode->sourceRect() != sourceRect)
- textureNode->setSourceRect(sourceRect);
- if (textureNode->filtering() != texture->filtering())
- textureNode->setFiltering(texture->filtering());
- }
- void setupSolidColorNode(const QRect &rect, const QColor &color, QSGNode *) override
- {
- Q_ASSERT(m_nodeIterator != m_sceneGraphNodes->end());
- QSGRectangleNode *rectangleNode = static_cast<QSGRectangleNode*>(*m_nodeIterator++);
-
- if (rectangleNode->rect() != rect)
- rectangleNode->setRect(rect);
- if (rectangleNode->color() != color)
- rectangleNode->setColor(color);
- }
-#if QT_CONFIG(opengl)
- void setupDebugBorderNode(QSGGeometry *geometry, QSGFlatColorMaterial *material,
- QSGNode *) override
- {
- Q_ASSERT(m_nodeIterator != m_sceneGraphNodes->end());
- QSGGeometryNode *geometryNode = static_cast<QSGGeometryNode*>(*m_nodeIterator++);
-
- geometryNode->setGeometry(geometry);
- geometryNode->setMaterial(material);
- }
-
- void setupYUVVideoNode(QSGTexture *, QSGTexture *, QSGTexture *, QSGTexture *,
- const QRectF &, const QRectF &, const QSizeF &, const QSizeF &,
- gfx::ColorSpace, float, float, const QRectF &,
- QSGNode *) override
- {
- Q_UNREACHABLE();
- }
-#ifdef GL_OES_EGL_image_external
- void setupStreamVideoNode(MailboxTexture *, const QRectF &,
- const QMatrix4x4 &, QSGNode *) override
- {
- Q_UNREACHABLE();
- }
-#endif // GL_OES_EGL_image_external
-#endif // QT_CONFIG(opengl)
-
-private:
- QVector<QSGNode*>::iterator m_nodeIterator;
-};
-
-class DelegatedNodeTreeCreator : public DelegatedNodeTreeHandler
-{
-public:
- DelegatedNodeTreeCreator(QVector<QSGNode*> *sceneGraphNodes,
- RenderWidgetHostViewQtDelegate *apiDelegate)
- : DelegatedNodeTreeHandler(sceneGraphNodes)
- , m_apiDelegate(apiDelegate)
- {
- }
-
- void setupRenderPassNode(QSGTexture *layer, const QRect &rect, const QRectF &sourceRect,
- QSGNode *layerChain) override
- {
- Q_ASSERT(layer);
- QSGImageNode *imageNode = m_apiDelegate->createImageNode();
- imageNode->setRect(rect);
- imageNode->setSourceRect(sourceRect);
- imageNode->setTexture(layer);
-
- layerChain->appendChildNode(imageNode);
- m_sceneGraphNodes->append(imageNode);
- }
-
- void setupTextureContentNode(QSGTexture *texture, const QRect &rect, const QRectF &sourceRect,
- QSGImageNode::TextureCoordinatesTransformMode texCoordTransForm,
- QSGNode *layerChain) override
- {
- QSGImageNode *textureNode = m_apiDelegate->createImageNode();
- textureNode->setTextureCoordinatesTransform(texCoordTransForm);
- textureNode->setRect(rect);
- textureNode->setSourceRect(sourceRect);
- textureNode->setTexture(texture);
- textureNode->setFiltering(texture->filtering());
-
- layerChain->appendChildNode(textureNode);
- m_sceneGraphNodes->append(textureNode);
- }
-
- void setupSolidColorNode(const QRect &rect, const QColor &color,
- QSGNode *layerChain) override
- {
- QSGRectangleNode *rectangleNode = m_apiDelegate->createRectangleNode();
- rectangleNode->setRect(rect);
- rectangleNode->setColor(color);
-
- layerChain->appendChildNode(rectangleNode);
- m_sceneGraphNodes->append(rectangleNode);
- }
-
-#if QT_CONFIG(opengl)
- void setupDebugBorderNode(QSGGeometry *geometry, QSGFlatColorMaterial *material,
- QSGNode *layerChain) override
- {
- QSGGeometryNode *geometryNode = new QSGGeometryNode;
- geometryNode->setFlags(QSGNode::OwnsGeometry | QSGNode::OwnsMaterial);
-
- geometryNode->setGeometry(geometry);
- geometryNode->setMaterial(material);
-
- layerChain->appendChildNode(geometryNode);
- m_sceneGraphNodes->append(geometryNode);
- }
-
- void setupYUVVideoNode(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture,
- QSGTexture *aTexture, const QRectF &yaTexCoordRect,
- const QRectF &uvTexCoordRect, const QSizeF &yaTexSize,
- const QSizeF &uvTexSize, gfx::ColorSpace colorspace,
- float rMul, float rOff, const QRectF &rect,
- QSGNode *layerChain) override
- {
- YUVVideoNode *videoNode = new YUVVideoNode(
- yTexture,
- uTexture,
- vTexture,
- aTexture,
- yaTexCoordRect,
- uvTexCoordRect,
- yaTexSize,
- uvTexSize,
- colorspace,
- rMul,
- rOff);
- videoNode->setRect(rect);
-
- layerChain->appendChildNode(videoNode);
- m_sceneGraphNodes->append(videoNode);
- }
-#ifdef GL_OES_EGL_image_external
- void setupStreamVideoNode(MailboxTexture *texture, const QRectF &rect,
- const QMatrix4x4 &textureMatrix, QSGNode *layerChain) override
- {
- StreamVideoNode *svideoNode = new StreamVideoNode(texture, false, ExternalTarget);
- svideoNode->setRect(rect);
- svideoNode->setTextureMatrix(textureMatrix);
- layerChain->appendChildNode(svideoNode);
- m_sceneGraphNodes->append(svideoNode);
- }
-#endif // GL_OES_EGL_image_external
-#endif // QT_CONFIG(opengl)
-
-private:
- RenderWidgetHostViewQtDelegate *m_apiDelegate;
-};
-
-
-static inline QSharedPointer<QSGLayer> findRenderPassLayer(const int &id, const QVector<QPair<int, QSharedPointer<QSGLayer> > > &list)
-{
- typedef QPair<int, QSharedPointer<QSGLayer> > Pair;
- for (const Pair &pair : list)
- if (pair.first == id)
- return pair.second;
- return QSharedPointer<QSGLayer>();
-}
-
-static QSGNode *buildRenderPassChain(QSGNode *chainParent)
-{
- // Chromium already ordered the quads from back to front for us, however the
- // Qt scene graph layers individual geometries in their own z-range and uses
- // the depth buffer to visually stack nodes according to their item tree order.
-
- // This gets rid of the z component of all quads, once any x and y perspective
- // transformation has been applied to vertices not on the z=0 plane. Qt will
- // use an orthographic projection to render them.
- QSGTransformNode *zCompressNode = new QSGTransformNode;
- QMatrix4x4 zCompressMatrix;
- zCompressMatrix.scale(1, 1, 0);
- zCompressNode->setMatrix(zCompressMatrix);
- chainParent->appendChildNode(zCompressNode);
- return zCompressNode;
-}
-
-static QSGNode *buildLayerChain(QSGNode *chainParent, const viz::SharedQuadState *layerState)
-{
- QSGNode *layerChain = chainParent;
- if (layerState->is_clipped) {
- RectClipNode *clipNode = new RectClipNode(toQt(layerState->clip_rect));
- layerChain->appendChildNode(clipNode);
- layerChain = clipNode;
- }
- if (!layerState->quad_to_target_transform.IsIdentity()) {
- QSGTransformNode *transformNode = new QSGTransformNode;
- QMatrix4x4 qMatrix;
- convertToQt(layerState->quad_to_target_transform.matrix(), qMatrix);
- transformNode->setMatrix(qMatrix);
- layerChain->appendChildNode(transformNode);
- layerChain = transformNode;
- }
- if (layerState->opacity < 1.0) {
- QSGOpacityNode *opacityNode = new QSGOpacityNode;
- opacityNode->setOpacity(layerState->opacity);
- layerChain->appendChildNode(opacityNode);
- layerChain = opacityNode;
- }
- return layerChain;
-}
-
-#if QT_CONFIG(opengl)
-MailboxTexture::MailboxTexture(const CompositorResource *resource, bool hasAlphaChannel, int target)
- : m_textureId(resource->texture_id)
- , m_fence(resource->texture_fence)
- , m_textureSize(toQt(resource->size))
- , m_hasAlpha(hasAlphaChannel)
- , m_target(target >= 0 ? target : GL_TEXTURE_2D)
-#if defined(USE_OZONE)
- , m_ownsTexture(false)
-#endif
-{
- initializeOpenGLFunctions();
-
- // Assume that resources without a size will be used with a full source rect.
- // Setting a size of 1x1 will let any texture node compute a normalized source
- // rect of (0, 0) to (1, 1) while an empty texture size would set (0, 0) on all corners.
- if (m_textureSize.isEmpty())
- m_textureSize = QSize(1, 1);
-}
-
-MailboxTexture::~MailboxTexture()
-{
-#if defined(USE_OZONE)
- // This is rare case, where context is not shared
- // we created extra texture in current context, so
- // delete it now
- if (m_ownsTexture) {
- QOpenGLContext *currentContext = QOpenGLContext::currentContext() ;
- QOpenGLFunctions *funcs = currentContext->functions();
- GLuint id(m_textureId);
- funcs->glDeleteTextures(1, &id);
- }
-#endif
-}
-
-void MailboxTexture::bind()
-{
- if (m_fence)
- m_fence->wait();
- glBindTexture(m_target, m_textureId);
-}
-#endif // QT_CONFIG(opengl)
-
-RectClipNode::RectClipNode(const QRectF &rect)
- : m_geometry(QSGGeometry::defaultAttributes_Point2D(), 4)
-{
- QSGGeometry::updateRectGeometry(&m_geometry, rect);
- setGeometry(&m_geometry);
- setClipRect(rect);
- setIsRectangular(true);
-}
-
-DelegatedFrameNode::DelegatedFrameNode()
-#if defined(USE_OZONE) && QT_CONFIG(opengl)
- : m_contextShared(true)
-#endif
-{
- setFlag(UsePreprocess);
-#if defined(USE_OZONE) && QT_CONFIG(opengl)
- QOpenGLContext *currentContext = QOpenGLContext::currentContext() ;
- QOpenGLContext *sharedContext = qt_gl_global_share_context();
- if (currentContext && sharedContext && !QOpenGLContext::areSharing(currentContext, sharedContext)) {
- static bool allowNotSharedContextWarningShown = true;
- if (allowNotSharedContextWarningShown) {
- allowNotSharedContextWarningShown = false;
- qWarning("Context is not shared, textures will be copied between contexts.");
- }
- m_offsurface.reset(new QOffscreenSurface);
- m_offsurface->create();
- m_contextShared = false;
- }
-#endif
-}
-
-DelegatedFrameNode::~DelegatedFrameNode()
-{
-}
-
-void DelegatedFrameNode::preprocess()
-{
- // Then render any intermediate RenderPass in order.
- typedef QPair<int, QSharedPointer<QSGLayer> > Pair;
- for (const Pair &pair : qAsConst(m_sgObjects.renderPassLayers)) {
- // The layer is non-live, request a one-time update here.
- pair.second->scheduleUpdate();
- // Proceed with the actual update.
- pair.second->updateTexture();
- }
-}
-
-static bool areSharedQuadStatesEqual(const viz::SharedQuadState *layerState,
- const viz::SharedQuadState *prevLayerState)
-{
- if (layerState->sorting_context_id != 0 || prevLayerState->sorting_context_id != 0)
- return false;
- if (layerState->is_clipped != prevLayerState->is_clipped
- || layerState->clip_rect != prevLayerState->clip_rect)
- return false;
- if (layerState->quad_to_target_transform != prevLayerState->quad_to_target_transform)
- return false;
- return qFuzzyCompare(layerState->opacity, prevLayerState->opacity);
-}
-
-// Compares if the frame data that we got from the Chromium Compositor is
-// *structurally* equivalent to the one of the previous frame.
-// If it is, we will just reuse and update the old nodes where necessary.
-static bool areRenderPassStructuresEqual(const viz::CompositorFrame *frameData,
- const viz::CompositorFrame *previousFrameData)
-{
- if (!previousFrameData)
- return false;
-
- if (previousFrameData->render_pass_list.size() != frameData->render_pass_list.size())
- return false;
-
- for (unsigned i = 0; i < frameData->render_pass_list.size(); ++i) {
- viz::RenderPass *newPass = frameData->render_pass_list.at(i).get();
- viz::RenderPass *prevPass = previousFrameData->render_pass_list.at(i).get();
-
- if (newPass->id != prevPass->id)
- return false;
-
- if (newPass->quad_list.size() != prevPass->quad_list.size())
- return false;
-
- viz::QuadList::ConstBackToFrontIterator it = newPass->quad_list.BackToFrontBegin();
- viz::QuadList::ConstBackToFrontIterator end = newPass->quad_list.BackToFrontEnd();
- viz::QuadList::ConstBackToFrontIterator prevIt = prevPass->quad_list.BackToFrontBegin();
- viz::QuadList::ConstBackToFrontIterator prevEnd = prevPass->quad_list.BackToFrontEnd();
- for (; it != end && prevIt != prevEnd; ++it, ++prevIt) {
- const viz::DrawQuad *quad = *it;
- const viz::DrawQuad *prevQuad = *prevIt;
- if (quad->material != prevQuad->material)
- return false;
-#if QT_CONFIG(opengl)
- if (quad->material == viz::DrawQuad::Material::kYuvVideoContent)
- return false;
-#ifdef GL_OES_EGL_image_external
- if (quad->material == viz::DrawQuad::Material::kStreamVideoContent)
- return false;
-#endif // GL_OES_EGL_image_external
-#endif // QT_CONFIG(opengl)
- if (!areSharedQuadStatesEqual(quad->shared_quad_state, prevQuad->shared_quad_state))
- return false;
- if (quad->shared_quad_state->is_clipped && quad->visible_rect != prevQuad->visible_rect) {
- gfx::Rect targetRect1 =
- cc::MathUtil::MapEnclosingClippedRect(quad->shared_quad_state->quad_to_target_transform, quad->visible_rect);
- gfx::Rect targetRect2 =
- cc::MathUtil::MapEnclosingClippedRect(quad->shared_quad_state->quad_to_target_transform, prevQuad->visible_rect);
- targetRect1.Intersect(quad->shared_quad_state->clip_rect);
- targetRect2.Intersect(quad->shared_quad_state->clip_rect);
- if (targetRect1.IsEmpty() != targetRect2.IsEmpty())
- return false;
- }
- }
- }
- return true;
-}
-
-void DelegatedFrameNode::commit(const viz::CompositorFrame &pendingFrame,
- const viz::CompositorFrame &committedFrame,
- const CompositorResourceTracker *resourceTracker,
- RenderWidgetHostViewQtDelegate *apiDelegate)
-{
- const viz::CompositorFrame* frameData = &pendingFrame;
- if (frameData->render_pass_list.empty())
- return;
-
- // DelegatedFrameNode is a transform node only for the purpose of
- // countering the scale of devicePixel-scaled tiles when rendering them
- // to the final surface.
- QMatrix4x4 matrix;
- const float devicePixelRatio = frameData->metadata.device_scale_factor;
- matrix.scale(1 / devicePixelRatio, 1 / devicePixelRatio);
- if (QSGTransformNode::matrix() != matrix)
- setMatrix(matrix);
-
- QScopedPointer<DelegatedNodeTreeHandler> nodeHandler;
-
- const QSizeF viewportSizeInPt = apiDelegate->viewGeometry().size();
- const QSizeF viewportSizeF = viewportSizeInPt * devicePixelRatio;
- const QSize viewportSize(std::ceil(viewportSizeF.width()), std::ceil(viewportSizeF.height()));
-
- // We first compare if the render passes from the previous frame data are structurally
- // equivalent to the render passes in the current frame data. If they are, we are going
- // to reuse the old nodes. Otherwise, we will delete the old nodes and build a new tree.
- //
- // Additionally, because we clip (i.e. don't build scene graph nodes for) quads outside
- // of the visible area, we also have to rebuild the tree whenever the window is resized.
- const bool buildNewTree =
- !areRenderPassStructuresEqual(frameData, &committedFrame) ||
- m_sceneGraphNodes.empty() ||
- viewportSize != m_previousViewportSize;
-
- if (buildNewTree) {
- // Keep the old objects in scope to hold a ref on layers, resources and textures
- // that we can re-use. Destroy the remaining objects before returning.
- qSwap(m_sgObjects, m_previousSGObjects);
- // Discard the scene graph nodes from the previous frame.
- while (QSGNode *oldChain = firstChild())
- delete oldChain;
- m_sceneGraphNodes.clear();
- nodeHandler.reset(new DelegatedNodeTreeCreator(&m_sceneGraphNodes, apiDelegate));
- } else {
- qSwap(m_sgObjects.bitmapTextures, m_previousSGObjects.bitmapTextures);
- qSwap(m_sgObjects.mailboxTextures, m_previousSGObjects.mailboxTextures);
- nodeHandler.reset(new DelegatedNodeTreeUpdater(&m_sceneGraphNodes));
- }
- // The RenderPasses list is actually a tree where a parent RenderPass is connected
- // to its dependencies through a RenderPassId reference in one or more RenderPassQuads.
- // The list is already ordered with intermediate RenderPasses placed before their
- // parent, with the last one in the list being the root RenderPass, the one
- // that we displayed to the user.
- // All RenderPasses except the last one are rendered to an FBO.
- viz::RenderPass *rootRenderPass = frameData->render_pass_list.back().get();
-
- gfx::Rect viewportRect(toGfx(viewportSize));
- for (unsigned i = 0; i < frameData->render_pass_list.size(); ++i) {
- viz::RenderPass *pass = frameData->render_pass_list.at(i).get();
-
- QSGNode *renderPassParent = 0;
- gfx::Rect scissorRect;
- if (pass != rootRenderPass) {
- QSharedPointer<QSGLayer> rpLayer;
- if (buildNewTree) {
- rpLayer = findRenderPassLayer(pass->id, m_previousSGObjects.renderPassLayers);
- if (!rpLayer) {
- rpLayer = QSharedPointer<QSGLayer>(apiDelegate->createLayer());
- // Avoid any premature texture update since we need to wait
- // for the GPU thread to produce the dependent resources first.
- rpLayer->setLive(false);
- }
- QSharedPointer<QSGRootNode> rootNode(new QSGRootNode);
- rpLayer->setItem(rootNode.data());
- m_sgObjects.renderPassLayers.append(QPair<int,
- QSharedPointer<QSGLayer> >(pass->id, rpLayer));
- m_sgObjects.renderPassRootNodes.append(rootNode);
- renderPassParent = rootNode.data();
- } else
- rpLayer = findRenderPassLayer(pass->id, m_sgObjects.renderPassLayers);
-
- rpLayer->setRect(toQt(pass->output_rect));
- rpLayer->setSize(toQt(pass->output_rect.size()));
- rpLayer->setFormat(pass->has_transparent_background ? GL_RGBA : GL_RGB);
- rpLayer->setHasMipmaps(pass->generate_mipmap);
- rpLayer->setMirrorVertical(false);
- scissorRect = pass->output_rect;
- } else {
- renderPassParent = this;
- scissorRect = viewportRect;
- scissorRect += rootRenderPass->output_rect.OffsetFromOrigin();
- }
-
- if (scissorRect.IsEmpty()) {
- holdResources(pass, resourceTracker);
- continue;
- }
-
- QSGNode *renderPassChain = nullptr;
- if (buildNewTree)
- renderPassChain = buildRenderPassChain(renderPassParent);
-
- base::circular_deque<std::unique_ptr<viz::DrawPolygon>> polygonQueue;
- int nextPolygonId = 0;
- int currentSortingContextId = 0;
- const viz::SharedQuadState *currentLayerState = nullptr;
- QSGNode *currentLayerChain = nullptr;
- const auto quadListBegin = pass->quad_list.BackToFrontBegin();
- const auto quadListEnd = pass->quad_list.BackToFrontEnd();
- for (auto it = quadListBegin; it != quadListEnd; ++it) {
- const viz::DrawQuad *quad = *it;
- const viz::SharedQuadState *quadState = quad->shared_quad_state;
-
- gfx::Rect targetRect =
- cc::MathUtil::MapEnclosingClippedRect(quadState->quad_to_target_transform,
- quad->visible_rect);
- if (quadState->is_clipped)
- targetRect.Intersect(quadState->clip_rect);
- targetRect.Intersect(scissorRect);
- if (targetRect.IsEmpty()) {
- holdResources(quad, resourceTracker);
- continue;
- }
-
- if (quadState->sorting_context_id != currentSortingContextId) {
- flushPolygons(&polygonQueue, renderPassChain,
- nodeHandler.data(), resourceTracker, apiDelegate);
- currentSortingContextId = quadState->sorting_context_id;
- }
-
- if (currentSortingContextId != 0) {
- std::unique_ptr<viz::DrawPolygon> polygon(
- new viz::DrawPolygon(
- quad,
- gfx::RectF(quad->visible_rect),
- quadState->quad_to_target_transform,
- nextPolygonId++));
- if (polygon->points().size() > 2u)
- polygonQueue.push_back(std::move(polygon));
- continue;
- }
-
- if (renderPassChain && currentLayerState != quadState) {
- currentLayerState = quadState;
- currentLayerChain = buildLayerChain(renderPassChain, quadState);
- }
-
- handleQuad(quad, currentLayerChain,
- nodeHandler.data(), resourceTracker, apiDelegate);
- }
- flushPolygons(&polygonQueue, renderPassChain,
- nodeHandler.data(), resourceTracker, apiDelegate);
- }
-
- copyMailboxTextures();
-
- m_previousViewportSize = viewportSize;
- m_previousSGObjects = SGObjects();
-}
-
-void DelegatedFrameNode::flushPolygons(
- base::circular_deque<std::unique_ptr<viz::DrawPolygon>> *polygonQueue,
- QSGNode *renderPassChain,
- DelegatedNodeTreeHandler *nodeHandler,
- const CompositorResourceTracker *resourceTracker,
- RenderWidgetHostViewQtDelegate *apiDelegate)
-{
- if (polygonQueue->empty())
- return;
-
- const auto actionHandler = [&](viz::DrawPolygon *polygon) {
- const viz::DrawQuad *quad = polygon->original_ref();
- const viz::SharedQuadState *quadState = quad->shared_quad_state;
-
- QSGNode *currentLayerChain = nullptr;
- if (renderPassChain)
- currentLayerChain = buildLayerChain(renderPassChain, quad->shared_quad_state);
-
- gfx::Transform inverseTransform;
- bool invertible = quadState->quad_to_target_transform.GetInverse(&inverseTransform);
- DCHECK(invertible);
- polygon->TransformToLayerSpace(inverseTransform);
-
- handlePolygon(polygon, currentLayerChain,
- nodeHandler, resourceTracker, apiDelegate);
- };
-
- viz::BspTree(polygonQueue).TraverseWithActionHandler(&actionHandler);
-}
-
-void DelegatedFrameNode::handlePolygon(
- const viz::DrawPolygon *polygon,
- QSGNode *currentLayerChain,
- DelegatedNodeTreeHandler *nodeHandler,
- const CompositorResourceTracker *resourceTracker,
- RenderWidgetHostViewQtDelegate *apiDelegate)
-{
- const viz::DrawQuad *quad = polygon->original_ref();
-
- if (!polygon->is_split()) {
- handleQuad(quad, currentLayerChain,
- nodeHandler, resourceTracker, apiDelegate);
- } else {
- std::vector<gfx::QuadF> clipRegionList;
- polygon->ToQuads2D(&clipRegionList);
- for (const auto & clipRegion : clipRegionList)
- handleClippedQuad(quad, clipRegion, currentLayerChain,
- nodeHandler, resourceTracker, apiDelegate);
- }
-}
-
-void DelegatedFrameNode::handleClippedQuad(
- const viz::DrawQuad *quad,
- const gfx::QuadF &clipRegion,
- QSGNode *currentLayerChain,
- DelegatedNodeTreeHandler *nodeHandler,
- const CompositorResourceTracker *resourceTracker,
- RenderWidgetHostViewQtDelegate *apiDelegate)
-{
- if (currentLayerChain) {
- auto clipGeometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 4);
- auto clipGeometryVertices = clipGeometry->vertexDataAsPoint2D();
- clipGeometryVertices[0].set(clipRegion.p1().x(), clipRegion.p1().y());
- clipGeometryVertices[1].set(clipRegion.p2().x(), clipRegion.p2().y());
- clipGeometryVertices[2].set(clipRegion.p4().x(), clipRegion.p4().y());
- clipGeometryVertices[3].set(clipRegion.p3().x(), clipRegion.p3().y());
- auto clipNode = new QSGClipNode;
- clipNode->setGeometry(clipGeometry);
- clipNode->setIsRectangular(false);
- clipNode->setFlag(QSGNode::OwnsGeometry);
- currentLayerChain->appendChildNode(clipNode);
- currentLayerChain = clipNode;
- }
- handleQuad(quad, currentLayerChain,
- nodeHandler, resourceTracker, apiDelegate);
-}
-
-void DelegatedFrameNode::handleQuad(
- const viz::DrawQuad *quad,
- QSGNode *currentLayerChain,
- DelegatedNodeTreeHandler *nodeHandler,
- const CompositorResourceTracker *resourceTracker,
- RenderWidgetHostViewQtDelegate *apiDelegate)
-{
- switch (quad->material) {
- case viz::DrawQuad::Material::kRenderPass: {
- const viz::RenderPassDrawQuad *renderPassQuad = viz::RenderPassDrawQuad::MaterialCast(quad);
- if (!renderPassQuad->mask_texture_size.IsEmpty()) {
- const CompositorResource *resource = findAndHoldResource(renderPassQuad->mask_resource_id(), resourceTracker);
- Q_UNUSED(resource); // FIXME: QTBUG-67652
- }
- QSGLayer *layer =
- findRenderPassLayer(renderPassQuad->render_pass_id, m_sgObjects.renderPassLayers).data();
-
- if (layer)
- nodeHandler->setupRenderPassNode(layer, toQt(quad->rect), toQt(renderPassQuad->tex_coord_rect), currentLayerChain);
-
- break;
- }
- case viz::DrawQuad::Material::kTextureContent: {
- const viz::TextureDrawQuad *tquad = viz::TextureDrawQuad::MaterialCast(quad);
- const CompositorResource *resource = findAndHoldResource(tquad->resource_id(), resourceTracker);
- QSGTexture *texture =
- initAndHoldTexture(resource, quad->ShouldDrawWithBlending(true), apiDelegate);
- QSizeF textureSize;
- if (texture)
- textureSize = texture->textureSize();
- gfx::RectF uv_rect =
- gfx::ScaleRect(gfx::BoundingRect(tquad->uv_top_left, tquad->uv_bottom_right),
- textureSize.width(), textureSize.height());
-
- nodeHandler->setupTextureContentNode(
- texture, toQt(quad->rect), toQt(uv_rect),
- tquad->y_flipped ? QSGImageNode::MirrorVertically : QSGImageNode::NoTransform,
- currentLayerChain);
- break;
- }
- case viz::DrawQuad::Material::kSolidColor: {
- const viz::SolidColorDrawQuad *scquad = viz::SolidColorDrawQuad::MaterialCast(quad);
- // Qt only supports MSAA and this flag shouldn't be needed.
- // If we ever want to use QSGRectangleNode::setAntialiasing for this we should
- // try to see if we can do something similar for tile quads first.
- Q_UNUSED(scquad->force_anti_aliasing_off);
- nodeHandler->setupSolidColorNode(toQt(quad->rect), toQt(scquad->color), currentLayerChain);
- break;
-#if QT_CONFIG(opengl)
- }
- case viz::DrawQuad::Material::kDebugBorder: {
- const viz::DebugBorderDrawQuad *dbquad = viz::DebugBorderDrawQuad::MaterialCast(quad);
-
- QSGGeometry *geometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 4);
- geometry->setDrawingMode(GL_LINE_LOOP);
- geometry->setLineWidth(dbquad->width);
- // QSGGeometry::updateRectGeometry would actually set the
- // corners in the following order:
- // top-left, bottom-left, top-right, bottom-right, leading to a nice criss cross,
- // instead of having a closed loop.
- const gfx::Rect &r(dbquad->rect);
- geometry->vertexDataAsPoint2D()[0].set(r.x(), r.y());
- geometry->vertexDataAsPoint2D()[1].set(r.x() + r.width(), r.y());
- geometry->vertexDataAsPoint2D()[2].set(r.x() + r.width(), r.y() + r.height());
- geometry->vertexDataAsPoint2D()[3].set(r.x(), r.y() + r.height());
-
- QSGFlatColorMaterial *material = new QSGFlatColorMaterial;
- material->setColor(toQt(dbquad->color));
-
- nodeHandler->setupDebugBorderNode(geometry, material, currentLayerChain);
- break;
-#endif
- }
- case viz::DrawQuad::Material::kTiledContent: {
- const viz::TileDrawQuad *tquad = viz::TileDrawQuad::MaterialCast(quad);
- const CompositorResource *resource = findAndHoldResource(tquad->resource_id(), resourceTracker);
- nodeHandler->setupTextureContentNode(
- initAndHoldTexture(resource, quad->ShouldDrawWithBlending(true), apiDelegate),
- toQt(quad->rect), toQt(tquad->tex_coord_rect),
- QSGImageNode::NoTransform, currentLayerChain);
- break;
-#if QT_CONFIG(opengl)
- }
- case viz::DrawQuad::Material::kYuvVideoContent: {
- const viz::YUVVideoDrawQuad *vquad = viz::YUVVideoDrawQuad::MaterialCast(quad);
- const CompositorResource *yResource =
- findAndHoldResource(vquad->y_plane_resource_id(), resourceTracker);
- const CompositorResource *uResource =
- findAndHoldResource(vquad->u_plane_resource_id(), resourceTracker);
- const CompositorResource *vResource =
- findAndHoldResource(vquad->v_plane_resource_id(), resourceTracker);
- const CompositorResource *aResource = nullptr;
- // This currently requires --enable-vp8-alpha-playback and
- // needs a video with alpha data to be triggered.
- if (vquad->a_plane_resource_id())
- aResource = findAndHoldResource(vquad->a_plane_resource_id(), resourceTracker);
-
- nodeHandler->setupYUVVideoNode(
- initAndHoldTexture(yResource, quad->ShouldDrawWithBlending(true)),
- initAndHoldTexture(uResource, quad->ShouldDrawWithBlending(true)),
- initAndHoldTexture(vResource, quad->ShouldDrawWithBlending(true)),
- aResource ? initAndHoldTexture(aResource, quad->ShouldDrawWithBlending(true)) : 0,
- toQt(vquad->ya_tex_coord_rect), toQt(vquad->uv_tex_coord_rect),
- toQt(vquad->ya_tex_size), toQt(vquad->uv_tex_size), vquad->video_color_space,
- vquad->resource_multiplier, vquad->resource_offset, toQt(quad->rect),
- currentLayerChain);
- break;
-#ifdef GL_OES_EGL_image_external
- }
- case viz::DrawQuad::Material::kStreamVideoContent: {
- const viz::StreamVideoDrawQuad *squad = viz::StreamVideoDrawQuad::MaterialCast(quad);
- const CompositorResource *resource = findAndHoldResource(squad->resource_id(), resourceTracker);
- MailboxTexture *texture = static_cast<MailboxTexture *>(
- initAndHoldTexture(resource, quad->ShouldDrawWithBlending(true), apiDelegate, GL_TEXTURE_EXTERNAL_OES));
-
- QMatrix4x4 qMatrix;
-// convertToQt(squad->matrix.matrix(), qMatrix);
- nodeHandler->setupStreamVideoNode(texture, toQt(squad->rect), qMatrix, currentLayerChain);
- break;
-#endif // GL_OES_EGL_image_external
-#endif // QT_CONFIG(opengl)
- }
- case viz::DrawQuad::Material::kSurfaceContent:
- Q_UNREACHABLE();
- default:
- qWarning("Unimplemented quad material: %d", (int)quad->material);
- }
-}
-
-const CompositorResource *DelegatedFrameNode::findAndHoldResource(unsigned resourceId, const CompositorResourceTracker *resourceTracker)
-{
- return resourceTracker->findResource(resourceId);
-}
-
-void DelegatedFrameNode::holdResources(const viz::DrawQuad *quad, const CompositorResourceTracker *resourceTracker)
-{
- for (auto resource : quad->resources)
- findAndHoldResource(resource, resourceTracker);
-}
-
-void DelegatedFrameNode::holdResources(const viz::RenderPass *pass, const CompositorResourceTracker *resourceTracker)
-{
- for (const auto &quad : pass->quad_list)
- holdResources(quad, resourceTracker);
-}
-
-template<class Container, class Key>
-inline auto &findTexture(Container &map, Container &previousMap, const Key &key)
-{
- auto &value = map[key];
- if (value)
- return value;
- value = previousMap[key];
- return value;
-}
-
-QSGTexture *DelegatedFrameNode::initAndHoldTexture(const CompositorResource *resource, bool hasAlphaChannel, RenderWidgetHostViewQtDelegate *apiDelegate, int target)
-{
- QSGTexture::Filtering filtering;
-
- if (resource->filter == GL_NEAREST)
- filtering = QSGTexture::Nearest;
- else if (resource->filter == GL_LINEAR)
- filtering = QSGTexture::Linear;
- else {
- // Depends on qtdeclarative fix, see QTBUG-71322
-#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 1)
- filtering = QSGTexture::Linear;
-#else
- filtering = QSGTexture::Nearest;
-#endif
- }
-
- if (resource->is_software) {
- QSharedPointer<QSGTexture> &texture =
- findTexture(m_sgObjects.bitmapTextures, m_previousSGObjects.bitmapTextures, resource->id);
- if (texture)
- return texture.data();
- texture = createBitmapTexture(resource, hasAlphaChannel, apiDelegate);
- texture->setFiltering(filtering);
- return texture.data();
- } else {
-#if QT_CONFIG(opengl)
- QSharedPointer<MailboxTexture> &texture =
- findTexture(m_sgObjects.mailboxTextures, m_previousSGObjects.mailboxTextures, resource->id);
- if (texture)
- return texture.data();
- texture = createMailboxTexture(resource, hasAlphaChannel, target);
- texture->setFiltering(filtering);
- return texture.data();
-#else
- Q_UNREACHABLE();
- return nullptr;
-#endif
- }
-}
-
-QSharedPointer<QSGTexture> DelegatedFrameNode::createBitmapTexture(const CompositorResource *resource, bool hasAlphaChannel, RenderWidgetHostViewQtDelegate *apiDelegate)
-{
- Q_ASSERT(apiDelegate);
- viz::SharedBitmap *sharedBitmap = resource->bitmap.get();
- gfx::Size size = resource->size;
-
- // QSG interprets QImage::hasAlphaChannel meaning that a node should enable blending
- // to draw it but Chromium keeps this information in the quads.
- // The input format is currently always Format_ARGB32_Premultiplied, so assume that all
- // alpha bytes are 0xff if quads aren't requesting blending and avoid the conversion
- // from Format_ARGB32_Premultiplied to Format_RGB32 just to get hasAlphaChannel to
- // return false.
- QImage::Format format = hasAlphaChannel ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
- QImage image = sharedBitmap
- ? QImage(sharedBitmap->pixels(), size.width(), size.height(), format)
- : QImage(size.width(), size.height(), format);
- return QSharedPointer<QSGTexture>(apiDelegate->createTextureFromImage(image.copy()));
-}
-
-QSharedPointer<MailboxTexture> DelegatedFrameNode::createMailboxTexture(const CompositorResource *resource, bool hasAlphaChannel, int target)
-{
-#if QT_CONFIG(opengl)
- return QSharedPointer<MailboxTexture>::create(resource, hasAlphaChannel, target);
-#else
- Q_UNREACHABLE();
-#endif
-}
-
-void DelegatedFrameNode::copyMailboxTextures()
-{
-#if QT_CONFIG(opengl) && defined(USE_OZONE)
- // Workaround when context is not shared QTBUG-48969
- // Make slow copy between two contexts.
- if (!m_contextShared) {
- QOpenGLContext *currentContext = QOpenGLContext::currentContext() ;
- QOpenGLContext *sharedContext = qt_gl_global_share_context();
-
- QSurface *surface = currentContext->surface();
- Q_ASSERT(m_offsurface);
- sharedContext->makeCurrent(m_offsurface.data());
- QOpenGLFunctions *funcs = sharedContext->functions();
-
- GLuint fbo = 0;
- funcs->glGenFramebuffers(1, &fbo);
-
- for (const QSharedPointer<MailboxTexture> &mailboxTexture : qAsConst(m_sgObjects.mailboxTextures)) {
- if (mailboxTexture->m_ownsTexture)
- continue;
-
- // Read texture into QImage from shared context.
- // Switch to shared context.
- sharedContext->makeCurrent(m_offsurface.data());
- funcs = sharedContext->functions();
- QImage img(mailboxTexture->textureSize(), QImage::Format_RGBA8888_Premultiplied);
- funcs->glBindFramebuffer(GL_FRAMEBUFFER, fbo);
- mailboxTexture->m_fence->wait();
- funcs->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mailboxTexture->m_textureId, 0);
- GLenum status = funcs->glCheckFramebufferStatus(GL_FRAMEBUFFER);
- if (status != GL_FRAMEBUFFER_COMPLETE) {
- qWarning("fbo error, skipping slow copy...");
- continue;
- }
- funcs->glReadPixels(0, 0, mailboxTexture->textureSize().width(), mailboxTexture->textureSize().height(),
- GL_RGBA, GL_UNSIGNED_BYTE, img.bits());
-
- // Restore current context.
- // Create texture from QImage in current context.
- currentContext->makeCurrent(surface);
- GLuint texture = 0;
- funcs = currentContext->functions();
- funcs->glGenTextures(1, &texture);
- funcs->glBindTexture(GL_TEXTURE_2D, texture);
- funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, mailboxTexture->textureSize().width(), mailboxTexture->textureSize().height(), 0,
- GL_RGBA, GL_UNSIGNED_BYTE, img.bits());
- mailboxTexture->m_textureId = texture;
- mailboxTexture->m_ownsTexture = true;
- }
- // Cleanup allocated resources
- sharedContext->makeCurrent(m_offsurface.data());
- funcs = sharedContext->functions();
- funcs->glBindFramebuffer(GL_FRAMEBUFFER, 0);
- funcs->glDeleteFramebuffers(1, &fbo);
- currentContext->makeCurrent(surface);
- }
-#endif
-}
-
-} // namespace QtWebEngineCore
diff --git a/src/core/compositor/delegated_frame_node.h b/src/core/compositor/delegated_frame_node.h
deleted file mode 100644
index 34e4ba029..000000000
--- a/src/core/compositor/delegated_frame_node.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 DELEGATED_FRAME_NODE_H
-#define DELEGATED_FRAME_NODE_H
-
-#include "base/containers/circular_deque.h"
-#include "components/viz/common/quads/compositor_frame.h"
-#include "components/viz/common/quads/render_pass.h"
-
-#include <QtCore/QSharedPointer>
-#include <QtGui/QOffscreenSurface>
-#include <QtQuick/QSGTransformNode>
-
-#include "chromium_gpu_helper.h"
-#include "render_widget_host_view_qt_delegate.h"
-
-QT_BEGIN_NAMESPACE
-class QSGLayer;
-QT_END_NAMESPACE
-
-namespace gfx {
-class QuadF;
-}
-
-namespace viz {
-class DelegatedFrameData;
-class DrawQuad;
-class DrawPolygon;
-}
-
-namespace QtWebEngineCore {
-
-class CompositorResource;
-class CompositorResourceTracker;
-class DelegatedNodeTreeHandler;
-class MailboxTexture;
-
-class DelegatedFrameNode : public QSGTransformNode {
-public:
- DelegatedFrameNode();
- ~DelegatedFrameNode();
- void preprocess() override;
- void commit(const viz::CompositorFrame &pendingFrame, const viz::CompositorFrame &committedFrame, const CompositorResourceTracker *resourceTracker, RenderWidgetHostViewQtDelegate *apiDelegate);
-
-private:
- void flushPolygons(base::circular_deque<std::unique_ptr<viz::DrawPolygon> > *polygonQueue,
- QSGNode *renderPassChain,
- DelegatedNodeTreeHandler *nodeHandler,
- const CompositorResourceTracker *resourceTracker,
- RenderWidgetHostViewQtDelegate *apiDelegate);
- void handlePolygon(
- const viz::DrawPolygon *polygon,
- QSGNode *currentLayerChain,
- DelegatedNodeTreeHandler *nodeHandler,
- const CompositorResourceTracker *resourceTracker,
- RenderWidgetHostViewQtDelegate *apiDelegate);
- void handleClippedQuad(
- const viz::DrawQuad *quad,
- const gfx::QuadF &clipRegion,
- QSGNode *currentLayerChain,
- DelegatedNodeTreeHandler *nodeHandler,
- const CompositorResourceTracker *resourceTracker,
- RenderWidgetHostViewQtDelegate *apiDelegate);
- void handleQuad(
- const viz::DrawQuad *quad,
- QSGNode *currentLayerChain,
- DelegatedNodeTreeHandler *nodeHandler,
- const CompositorResourceTracker *resourceTracker,
- RenderWidgetHostViewQtDelegate *apiDelegate);
-
- const CompositorResource *findAndHoldResource(unsigned resourceId, const CompositorResourceTracker *resourceTracker);
- void holdResources(const viz::DrawQuad *quad, const CompositorResourceTracker *resourceTracker);
- void holdResources(const viz::RenderPass *pass, const CompositorResourceTracker *resourceTracker);
- QSGTexture *initAndHoldTexture(const CompositorResource *resource, bool hasAlphaChannel, RenderWidgetHostViewQtDelegate *apiDelegate = 0, int target = -1);
- QSharedPointer<QSGTexture> createBitmapTexture(const CompositorResource *resource, bool hasAlphaChannel, RenderWidgetHostViewQtDelegate *apiDelegate);
- QSharedPointer<MailboxTexture> createMailboxTexture(const CompositorResource *resource, bool hasAlphaChannel, int target);
-
- void copyMailboxTextures();
-
- struct SGObjects {
- QVector<QPair<int, QSharedPointer<QSGLayer> > > renderPassLayers;
- QVector<QSharedPointer<QSGRootNode> > renderPassRootNodes;
- QHash<unsigned, QSharedPointer<QSGTexture> > bitmapTextures;
- QHash<unsigned, QSharedPointer<MailboxTexture> > mailboxTextures;
- } m_sgObjects, m_previousSGObjects;
- QVector<QSGNode*> m_sceneGraphNodes;
-#if defined(USE_OZONE)
- bool m_contextShared;
- QScopedPointer<QOffscreenSurface> m_offsurface;
-#endif
- QSize m_previousViewportSize;
-};
-
-} // namespace QtWebEngineCore
-
-#endif // DELEGATED_FRAME_NODE_H
diff --git a/src/core/compositor/display_consumer.h b/src/core/compositor/display_consumer.h
deleted file mode 100644
index d220088ad..000000000
--- a/src/core/compositor/display_consumer.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 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 DISPLAY_CONSUMER_H
-#define DISPLAY_CONSUMER_H
-
-#include "qtwebenginecoreglobal_p.h"
-
-namespace QtWebEngineCore {
-
-// Receives composited frames for display.
-class DisplayConsumer
-{
-public:
- // Schedule a call to updatePaintNode soon.
- //
- // Called on the consumer thread.
- virtual void scheduleUpdate() = 0;
-
-protected:
- ~DisplayConsumer() {}
-};
-
-} // namespace QtWebEngineCore
-
-#endif // !DISPLAY_CONSUMER_H
diff --git a/src/core/compositor/display_frame_sink.cpp b/src/core/compositor/display_frame_sink.cpp
deleted file mode 100644
index 945600299..000000000
--- a/src/core/compositor/display_frame_sink.cpp
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 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 "display_frame_sink.h"
-
-#include <QMap>
-
-namespace QtWebEngineCore {
-
-namespace {
-
-class DisplayFrameSinkMap
-{
-public:
- static DisplayFrameSinkMap *instance()
- {
- static DisplayFrameSinkMap map;
- return &map;
- }
-
- scoped_refptr<DisplayFrameSink> findOrCreate(viz::FrameSinkId frameSinkId)
- {
- QMutexLocker locker(&m_mutex);
- auto it = m_map.find(frameSinkId);
- if (it == m_map.end())
- it = m_map.insert(frameSinkId, new DisplayFrameSink(frameSinkId));
- return *it;
- }
-
- void remove(viz::FrameSinkId frameSinkId)
- {
- QMutexLocker locker(&m_mutex);
- m_map.remove(frameSinkId);
- }
-
-private:
- mutable QMutex m_mutex;
- QMap<viz::FrameSinkId, DisplayFrameSink *> m_map;
-};
-
-} // namespace
-
-// static
-scoped_refptr<DisplayFrameSink> DisplayFrameSink::findOrCreate(viz::FrameSinkId frameSinkId)
-{
- return DisplayFrameSinkMap::instance()->findOrCreate(frameSinkId);
-}
-
-DisplayFrameSink::DisplayFrameSink(viz::FrameSinkId frameSinkId)
- : m_frameSinkId(frameSinkId)
-{
- DCHECK(m_frameSinkId.is_valid());
-}
-
-DisplayFrameSink::~DisplayFrameSink()
-{
- DisplayFrameSinkMap::instance()->remove(m_frameSinkId);
-}
-
-void DisplayFrameSink::connect(DisplayConsumer *consumer)
-{
- QMutexLocker locker(&m_mutex);
- DCHECK(m_consumer == nullptr);
- m_consumer = consumer;
-}
-
-void DisplayFrameSink::connect(DisplayProducer *producer)
-{
- QMutexLocker locker(&m_mutex);
- DCHECK(m_producer == nullptr);
- m_producer = producer;
-}
-
-void DisplayFrameSink::disconnect(DisplayConsumer *consumer)
-{
- QMutexLocker locker(&m_mutex);
- DCHECK(m_consumer == consumer);
- m_consumer = nullptr;
-}
-
-void DisplayFrameSink::disconnect(DisplayProducer *producer)
-{
- QMutexLocker locker(&m_mutex);
- DCHECK(m_producer == producer);
- m_producer = nullptr;
-}
-
-void DisplayFrameSink::scheduleUpdate()
-{
- QMutexLocker locker(&m_mutex);
- if (m_consumer)
- m_consumer->scheduleUpdate();
-}
-
-QSGNode *DisplayFrameSink::updatePaintNode(QSGNode *oldNode, RenderWidgetHostViewQtDelegate *delegate)
-{
- QMutexLocker locker(&m_mutex);
- QSGNode *newNode = oldNode;
- if (m_producer)
- newNode = m_producer->updatePaintNode(oldNode, delegate);
- return newNode;
-}
-
-} // namespace QtWebEngineCore
diff --git a/src/core/compositor/display_frame_sink.h b/src/core/compositor/display_frame_sink.h
deleted file mode 100644
index f620dc4f2..000000000
--- a/src/core/compositor/display_frame_sink.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 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 DISPLAY_FRAME_SINK_H
-#define DISPLAY_FRAME_SINK_H
-
-#include "display_consumer.h"
-#include "display_producer.h"
-
-#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_refptr.h"
-#include "components/viz/common/surfaces/frame_sink_id.h"
-
-#include <QMutex>
-
-namespace QtWebEngineCore {
-
-// Connects a DisplayConsumer with a DisplayProducer.
-class DisplayFrameSink final : public base::RefCountedThreadSafe<DisplayFrameSink>
-{
-public:
- static scoped_refptr<DisplayFrameSink> findOrCreate(viz::FrameSinkId frameSinkId);
- DisplayFrameSink(viz::FrameSinkId frameSinkId);
- ~DisplayFrameSink();
- void connect(DisplayConsumer *consumer);
- void connect(DisplayProducer *producer);
- void disconnect(DisplayConsumer *consumer);
- void disconnect(DisplayProducer *producer);
- void scheduleUpdate();
- QSGNode *updatePaintNode(QSGNode *oldNode, RenderWidgetHostViewQtDelegate *delegate);
-
-private:
- const viz::FrameSinkId m_frameSinkId;
- mutable QMutex m_mutex;
- DisplayProducer *m_producer = nullptr;
- DisplayConsumer *m_consumer = nullptr;
-};
-
-} // namespace QtWebEngineCore
-
-#endif // !DISPLAY_FRAME_SINK_H
diff --git a/src/core/compositor/display_gl_output_surface.cpp b/src/core/compositor/display_gl_output_surface.cpp
index ef12cc71b..05653149e 100644
--- a/src/core/compositor/display_gl_output_surface.cpp
+++ b/src/core/compositor/display_gl_output_surface.cpp
@@ -39,7 +39,7 @@
#include "display_gl_output_surface.h"
-#include "chromium_gpu_helper.h"
+#include "type_conversion.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/viz/service/display/display.h"
@@ -53,8 +53,10 @@
namespace QtWebEngineCore {
-DisplayGLOutputSurface::DisplayGLOutputSurface(scoped_refptr<viz::VizProcessContextProvider> contextProvider)
+DisplayGLOutputSurface::DisplayGLOutputSurface(
+ scoped_refptr<viz::VizProcessContextProvider> contextProvider)
: OutputSurface(contextProvider)
+ , Compositor(Compositor::Type::OpenGL)
, m_commandBuffer(contextProvider->command_buffer())
, m_gl(contextProvider->ContextGL())
, m_vizContextProvider(contextProvider)
@@ -65,18 +67,16 @@ DisplayGLOutputSurface::DisplayGLOutputSurface(scoped_refptr<viz::VizProcessCont
DisplayGLOutputSurface::~DisplayGLOutputSurface()
{
+ unbind();
m_vizContextProvider->SetUpdateVSyncParametersCallback(viz::UpdateVSyncParametersCallback());
m_gl->DeleteFramebuffers(1, &m_fboId);
- if (m_sink)
- m_sink->disconnect(this);
}
// Called from viz::Display::Initialize.
void DisplayGLOutputSurface::BindToClient(viz::OutputSurfaceClient *client)
{
m_display = static_cast<viz::Display *>(client);
- m_sink = DisplayFrameSink::findOrCreate(m_display->frame_sink_id());
- m_sink->connect(this);
+ bind(m_display->frame_sink_id());
}
// Triggered by ui::Compositor::SetVisible(true).
@@ -213,7 +213,8 @@ void DisplayGLOutputSurface::swapBuffersOnGpuThread(unsigned int id, std::unique
m_middleBuffer->fence = CompositorResourceFence::create(std::move(fence));
}
- m_sink->scheduleUpdate();
+ if (auto obs = observer())
+ obs->readyToSwap();
}
void DisplayGLOutputSurface::swapBuffersOnVizThread()
@@ -297,4 +298,44 @@ gfx::OverlayTransform DisplayGLOutputSurface::GetDisplayTransform()
return gfx::OVERLAY_TRANSFORM_NONE;
}
+void DisplayGLOutputSurface::swapFrame()
+{
+ QMutexLocker locker(&m_mutex);
+ if (m_middleBuffer && m_middleBuffer->serviceId) {
+ std::swap(m_middleBuffer, m_frontBuffer);
+ m_taskRunner->PostTask(FROM_HERE,
+ base::BindOnce(&DisplayGLOutputSurface::swapBuffersOnVizThread,
+ base::Unretained(this)));
+ m_taskRunner.reset();
+ }
+}
+
+void DisplayGLOutputSurface::waitForTexture()
+{
+ if (m_frontBuffer && m_frontBuffer->fence) {
+ m_frontBuffer->fence->wait();
+ m_frontBuffer->fence.reset();
+ }
+}
+
+int DisplayGLOutputSurface::textureId()
+{
+ return m_frontBuffer ? m_frontBuffer->serviceId : 0;
+}
+
+QSize DisplayGLOutputSurface::size()
+{
+ return m_frontBuffer ? toQt(m_frontBuffer->shape.sizeInPixels) : QSize();
+}
+
+bool DisplayGLOutputSurface::hasAlphaChannel()
+{
+ return m_frontBuffer ? m_frontBuffer->shape.hasAlpha : false;
+}
+
+float DisplayGLOutputSurface::devicePixelRatio()
+{
+ return m_frontBuffer ? m_frontBuffer->shape.devicePixelRatio : 1;
+}
+
} // namespace QtWebEngineCore
diff --git a/src/core/compositor/display_gl_output_surface.h b/src/core/compositor/display_gl_output_surface.h
index 67d987263..6b1b2e043 100644
--- a/src/core/compositor/display_gl_output_surface.h
+++ b/src/core/compositor/display_gl_output_surface.h
@@ -41,7 +41,7 @@
#define DISPLAY_GL_OUTPUT_SURFACE_H
#include "compositor_resource_fence.h"
-#include "display_frame_sink.h"
+#include "compositor.h"
#include "components/viz/common/display/update_vsync_parameters_callback.h"
#include "components/viz/service/display/output_surface.h"
@@ -49,6 +49,8 @@
#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/command_buffer/common/sync_token.h"
+#include <QMutex>
+
namespace viz {
class Display;
class SyntheticBeginFrameSource;
@@ -56,9 +58,7 @@ class SyntheticBeginFrameSource;
namespace QtWebEngineCore {
-// NOTE: Some methods are defined in display_gl_output_surface_qsg.cpp due
-// to conflicts between Qt & Chromium OpenGL APIs.
-class DisplayGLOutputSurface final : public viz::OutputSurface, public DisplayProducer
+class DisplayGLOutputSurface final : public viz::OutputSurface, public Compositor
{
public:
DisplayGLOutputSurface(scoped_refptr<viz::VizProcessContextProvider> contextProvider);
@@ -87,8 +87,13 @@ public:
void SetDisplayTransformHint(gfx::OverlayTransform transform) override;
gfx::OverlayTransform GetDisplayTransform() override;
- // Overridden from DisplayProducer.
- QSGNode *updatePaintNode(QSGNode *oldNode, RenderWidgetHostViewQtDelegate *delegate) override;
+ // Overridden from Compositor.
+ void swapFrame() override;
+ void waitForTexture() override;
+ int textureId() override;
+ QSize size() override;
+ bool hasAlphaChannel() override;
+ float devicePixelRatio() override;
private:
struct Shape
@@ -135,7 +140,6 @@ private:
mutable QMutex m_mutex;
uint32_t m_fboId = 0;
viz::Display *m_display = nullptr;
- scoped_refptr<DisplayFrameSink> m_sink;
Shape m_currentShape;
std::unique_ptr<Buffer> m_backBuffer;
std::unique_ptr<Buffer> m_middleBuffer;
diff --git a/src/core/compositor/display_gl_output_surface_qsg.cpp b/src/core/compositor/display_gl_output_surface_qsg.cpp
deleted file mode 100644
index d4b9154d1..000000000
--- a/src/core/compositor/display_gl_output_surface_qsg.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 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 "display_gl_output_surface.h"
-
-#include "compositor_resource_fence.h"
-#include "render_widget_host_view_qt_delegate.h"
-#include "type_conversion.h"
-
-#include <QOpenGLFunctions>
-#include <QSGImageNode>
-#include <QSGTexture>
-
-namespace QtWebEngineCore {
-
-class DisplayGLOutputSurface::Texture final : public QSGTexture
-{
-public:
- Texture(uint32_t id, QSize sizeInPixels, bool hasAlphaChannel, scoped_refptr<CompositorResourceFence> fence)
- : m_id(id)
- , m_sizeInPixels(sizeInPixels)
- , m_hasAlphaChannel(hasAlphaChannel)
- , m_fence(std::move(fence))
- {
- }
-
- // QSGTexture:
- int textureId() const override { return m_id; }
- QSize textureSize() const override { return m_sizeInPixels; }
- bool hasAlphaChannel() const override { return m_hasAlphaChannel; }
- bool hasMipmaps() const override { return false; }
- void bind() override
- {
- if (m_fence) {
- m_fence->wait();
- m_fence.reset();
- }
-
- QOpenGLContext *context = QOpenGLContext::currentContext();
- QOpenGLFunctions *funcs = context->functions();
- funcs->glBindTexture(GL_TEXTURE_2D, m_id);
- }
-
-private:
- uint32_t m_id;
- QSize m_sizeInPixels;
- bool m_hasAlphaChannel;
- scoped_refptr<CompositorResourceFence> m_fence;
-};
-
-QSGNode *DisplayGLOutputSurface::updatePaintNode(QSGNode *oldNode, RenderWidgetHostViewQtDelegate *delegate)
-{
- {
- QMutexLocker locker(&m_mutex);
- if (m_taskRunner) {
- std::swap(m_middleBuffer, m_frontBuffer);
- m_taskRunner->PostTask(
- FROM_HERE,
- base::BindOnce(&DisplayGLOutputSurface::swapBuffersOnVizThread, base::Unretained(this)));
- m_taskRunner.reset();
- }
- }
-
- if (!m_frontBuffer)
- return oldNode;
-
- auto node = static_cast<QSGImageNode *>(oldNode);
- if (!node)
- node = delegate->createImageNode();
-
- QSize sizeInPixels = toQt(m_frontBuffer->shape.sizeInPixels);
- QSizeF sizeInDips = QSizeF(sizeInPixels) / m_frontBuffer->shape.devicePixelRatio;
- QRectF rectInDips(QPointF(0, 0), sizeInDips);
- node->setRect(rectInDips);
- node->setOwnsTexture(true);
- node->setTexture(new Texture(m_frontBuffer->serviceId,
- sizeInPixels,
- m_frontBuffer->shape.hasAlpha,
- m_frontBuffer->fence));
- node->setTextureCoordinatesTransform(QSGImageNode::MirrorVertically);
-
- return node;
-}
-
-} // namespace QtWebEngineCore
diff --git a/src/core/compositor/display_producer.h b/src/core/compositor/display_producer.h
deleted file mode 100644
index 5de09d2d2..000000000
--- a/src/core/compositor/display_producer.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 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 DISPLAY_PRODUCER_H
-#define DISPLAY_PRODUCER_H
-
-#include "qtwebenginecoreglobal_p.h"
-
-QT_BEGIN_NAMESPACE
-class QSGNode;
-QT_END_NAMESPACE
-
-namespace QtWebEngineCore {
-class RenderWidgetHostViewQtDelegate;
-
-// Produces composited frames for display.
-class DisplayProducer
-{
-public:
- // Generate scene graph nodes for the current frame.
- //
- // If this is a scheduled update (that is, scheduleUpdate was called
- // earlier), then updatePaintNode will generate nodes for a new frame.
- // Otherwise, it will just regenerate nodes for the old frame.
- virtual QSGNode *updatePaintNode(QSGNode *oldNode, RenderWidgetHostViewQtDelegate *delegate) = 0;
-
-protected:
- ~DisplayProducer() {}
-};
-
-} // namespace QtWebEngineCore
-
-#endif // !DISPLAY_PRODUCER_H
diff --git a/src/core/compositor/display_software_output_surface.cpp b/src/core/compositor/display_software_output_surface.cpp
index ba99799f0..218bff94a 100644
--- a/src/core/compositor/display_software_output_surface.cpp
+++ b/src/core/compositor/display_software_output_surface.cpp
@@ -39,7 +39,7 @@
#include "display_software_output_surface.h"
-#include "display_frame_sink.h"
+#include "compositor.h"
#include "render_widget_host_view_qt_delegate.h"
#include "type_conversion.h"
@@ -49,28 +49,29 @@
#include <QMutex>
#include <QPainter>
-#include <QSGImageNode>
namespace QtWebEngineCore {
-class DisplaySoftwareOutputSurface::Device final : public viz::SoftwareOutputDevice, public DisplayProducer
+class DisplaySoftwareOutputSurface::Device final : public viz::SoftwareOutputDevice,
+ public Compositor
{
public:
+ Device();
~Device();
- // Called from DisplaySoftwareOutputSurface.
- void bind(viz::FrameSinkId frameSinkId);
-
// Overridden from viz::SoftwareOutputDevice.
void Resize(const gfx::Size &sizeInPixels, float devicePixelRatio) override;
void OnSwapBuffers(SwapBuffersCallback swap_ack_callback) override;
- // Overridden from DisplayProducer.
- QSGNode *updatePaintNode(QSGNode *oldNode, RenderWidgetHostViewQtDelegate *delegate) override;
+ // Overridden from Compositor.
+ void swapFrame() override;
+ QImage image() override;
+ float devicePixelRatio() override;
+ QSize size() override;
+ bool hasAlphaChannel() override;
private:
mutable QMutex m_mutex;
- scoped_refptr<DisplayFrameSink> m_sink;
float m_devicePixelRatio = 1.0;
scoped_refptr<base::SingleThreadTaskRunner> m_taskRunner;
SwapBuffersCallback m_swapCompletionCallback;
@@ -78,16 +79,13 @@ private:
float m_imageDevicePixelRatio = 1.0;
};
-DisplaySoftwareOutputSurface::Device::~Device()
-{
- if (m_sink)
- m_sink->disconnect(this);
-}
+DisplaySoftwareOutputSurface::Device::Device()
+ : Compositor(Type::Software)
+{}
-void DisplaySoftwareOutputSurface::Device::bind(viz::FrameSinkId frameSinkId)
+DisplaySoftwareOutputSurface::Device::~Device()
{
- m_sink = DisplayFrameSink::findOrCreate(frameSinkId);
- m_sink->connect(this);
+ unbind();
}
void DisplaySoftwareOutputSurface::Device::Resize(const gfx::Size &sizeInPixels, float devicePixelRatio)
@@ -104,7 +102,8 @@ void DisplaySoftwareOutputSurface::Device::OnSwapBuffers(SwapBuffersCallback swa
QMutexLocker locker(&m_mutex);
m_taskRunner = base::ThreadTaskRunnerHandle::Get();
m_swapCompletionCallback = std::move(swap_ack_callback);
- m_sink->scheduleUpdate();
+ if (auto obs = observer())
+ obs->readyToSwap();
}
inline QImage::Format imageFormat(SkColorType colorType)
@@ -120,41 +119,51 @@ inline QImage::Format imageFormat(SkColorType colorType)
}
}
-QSGNode *DisplaySoftwareOutputSurface::Device::updatePaintNode(
- QSGNode *oldNode, RenderWidgetHostViewQtDelegate *delegate)
+void DisplaySoftwareOutputSurface::Device::swapFrame()
{
QMutexLocker locker(&m_mutex);
- // Delete old node to make sure refcount of m_image is at most 1.
- delete oldNode;
- QSGImageNode *node = delegate->createImageNode();
-
- if (m_swapCompletionCallback) {
- SkPixmap skPixmap;
- surface_->peekPixels(&skPixmap);
- QImage image(reinterpret_cast<const uchar *>(skPixmap.addr()),
- viewport_pixel_size_.width(), viewport_pixel_size_.height(),
- skPixmap.rowBytes(), imageFormat(skPixmap.colorType()));
- if (m_image.size() == image.size()) {
- QRect damageRect = toQt(damage_rect_);
- QPainter painter(&m_image);
- painter.setCompositionMode(QPainter::CompositionMode_Source);
- painter.drawImage(damageRect, image, damageRect);
- } else {
- m_image = image;
- m_image.detach();
- }
- m_imageDevicePixelRatio = m_devicePixelRatio;
- m_taskRunner->PostTask(FROM_HERE, base::BindOnce(std::move(m_swapCompletionCallback), toGfx(m_image.size())));
- m_taskRunner.reset();
+ if (!m_swapCompletionCallback)
+ return;
+
+ SkPixmap skPixmap;
+ surface_->peekPixels(&skPixmap);
+ QImage image(reinterpret_cast<const uchar *>(skPixmap.addr()), viewport_pixel_size_.width(),
+ viewport_pixel_size_.height(), skPixmap.rowBytes(),
+ imageFormat(skPixmap.colorType()));
+ if (m_image.size() == image.size()) {
+ QRect damageRect = toQt(damage_rect_);
+ QPainter painter(&m_image);
+ painter.setCompositionMode(QPainter::CompositionMode_Source);
+ painter.drawImage(damageRect, image, damageRect);
+ } else {
+ m_image = image;
+ m_image.detach();
}
+ m_imageDevicePixelRatio = m_devicePixelRatio;
+ m_taskRunner->PostTask(
+ FROM_HERE, base::BindOnce(std::move(m_swapCompletionCallback), toGfx(m_image.size())));
+ m_taskRunner.reset();
+}
- QSizeF sizeInDips = QSizeF(m_image.size()) / m_imageDevicePixelRatio;
- node->setRect(QRectF(QPointF(0, 0), sizeInDips));
- node->setOwnsTexture(true);
- node->setTexture(delegate->createTextureFromImage(m_image));
+QImage DisplaySoftwareOutputSurface::Device::image()
+{
+ return m_image;
+}
+
+float DisplaySoftwareOutputSurface::Device::devicePixelRatio()
+{
+ return m_imageDevicePixelRatio;
+}
- return node;
+QSize DisplaySoftwareOutputSurface::Device::size()
+{
+ return m_image.size();
+}
+
+bool DisplaySoftwareOutputSurface::Device::hasAlphaChannel()
+{
+ return m_image.format() == QImage::Format_ARGB32_Premultiplied;
}
DisplaySoftwareOutputSurface::DisplaySoftwareOutputSurface()
diff --git a/src/core/compositor/stream_video_node.cpp b/src/core/compositor/stream_video_node.cpp
deleted file mode 100644
index fb9501f24..000000000
--- a/src/core/compositor/stream_video_node.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 "stream_video_node.h"
-
-#include <QtQuick/qsgtexture.h>
-
-namespace QtWebEngineCore {
-
-class StreamVideoMaterialShader : public QSGMaterialShader
-{
-public:
- StreamVideoMaterialShader(TextureTarget target) : m_target(target) { }
- virtual void updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
-
- char const *const *attributeNames() const override {
- static const char *names[] = {
- "a_position",
- "a_texCoord",
- 0
- };
- return names;
- }
-
-protected:
- const char *vertexShader() const override {
- // Keep in sync with cc::VertexShaderVideoTransform
- static const char *shader =
- "attribute highp vec4 a_position;\n"
- "attribute mediump vec2 a_texCoord;\n"
- "uniform highp mat4 matrix;\n"
- "uniform highp mat4 texMatrix;\n"
- "varying mediump vec2 v_texCoord;\n"
- "void main() {\n"
- " gl_Position = matrix * a_position;\n"
- " v_texCoord = vec4(texMatrix * vec4(a_texCoord.x, 1.0 - a_texCoord.y, 0.0, 1.0)).xy;\n"
- "}";
- return shader;
- }
-
- const char *fragmentShader() const override {
- // Keep in sync with cc::FragmentShaderRGBATexAlpha
- static const char *shaderExternal =
- "#extension GL_OES_EGL_image_external : require\n"
- "varying mediump vec2 v_texCoord;\n"
- "uniform samplerExternalOES s_texture;\n"
- "uniform lowp float alpha;\n"
- "void main() {\n"
- " lowp vec4 texColor = texture2D(s_texture, v_texCoord);\n"
- " gl_FragColor = texColor * alpha;\n"
- "}";
- static const char *shader2DRect =
- "#extension GL_ARB_texture_rectangle : require\n"
- "varying mediump vec2 v_texCoord;\n"
- "uniform sampler2DRect s_texture;\n"
- "uniform lowp float alpha;\n"
- "void main() {\n"
- " lowp vec4 texColor = texture2DRect(s_texture, v_texCoord);\n"
- " gl_FragColor = texColor * alpha;\n"
- "}";
- if (m_target == ExternalTarget)
- return shaderExternal;
- else
- return shader2DRect;
- }
-
- virtual void initialize() override {
- m_id_matrix = program()->uniformLocation("matrix");
- m_id_sTexture = program()->uniformLocation("s_texture");
- m_id_texMatrix = program()->uniformLocation("texMatrix");
- m_id_opacity = program()->uniformLocation("alpha");
- }
-
- int m_id_matrix;
- int m_id_texMatrix;
- int m_id_sTexture;
- int m_id_opacity;
- TextureTarget m_target;
-};
-
-void StreamVideoMaterialShader::updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
-{
- Q_UNUSED(oldMaterial);
-
- StreamVideoMaterial *mat = static_cast<StreamVideoMaterial *>(newMaterial);
- program()->setUniformValue(m_id_sTexture, 0);
-
- mat->m_texture->bind();
-
- if (state.isOpacityDirty())
- program()->setUniformValue(m_id_opacity, state.opacity());
-
- if (state.isMatrixDirty())
- program()->setUniformValue(m_id_matrix, state.combinedMatrix());
-
- program()->setUniformValue(m_id_texMatrix, mat->m_texMatrix);
-}
-
-StreamVideoMaterial::StreamVideoMaterial(QSGTexture *texture, TextureTarget target)
- : m_texture(texture)
- , m_target(target)
-{
-}
-
-QSGMaterialShader *StreamVideoMaterial::createShader() const
-{
- return new StreamVideoMaterialShader(m_target);
-}
-
-StreamVideoNode::StreamVideoNode(QSGTexture *texture, bool flip, TextureTarget target)
- : m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4)
- , m_flip(flip)
-{
- setGeometry(&m_geometry);
- setFlag(QSGNode::OwnsMaterial);
- m_material = new StreamVideoMaterial(texture, target);
- setMaterial(m_material);
-}
-
-void StreamVideoNode::setRect(const QRectF &rect)
-{
- if (m_flip)
- QSGGeometry::updateTexturedRectGeometry(geometry(), rect, QRectF(0, 1, 1, -1));
- else
- QSGGeometry::updateTexturedRectGeometry(geometry(), rect, QRectF(0, 0, 1, 1));
-}
-
-void StreamVideoNode::setTextureMatrix(const QMatrix4x4 &matrix)
-{
- m_material->m_texMatrix = matrix;
-}
-
-} // namespace
diff --git a/src/core/compositor/yuv_video_node.cpp b/src/core/compositor/yuv_video_node.cpp
deleted file mode 100644
index 4a436d952..000000000
--- a/src/core/compositor/yuv_video_node.cpp
+++ /dev/null
@@ -1,352 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
-
-// Based on cc/output/gl_renderer.cc and cc/output/shader.cc:
-// Copyright 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE.Chromium file.
-
-#include "yuv_video_node.h"
-
-#include <QtGui/qopenglcontext.h>
-#include <QtGui/qopenglfunctions.h>
-#include <QtQuick/qsgtexture.h>
-
-#include "ui/gfx/color_space.h"
-#include "ui/gfx/color_transform.h"
-
-namespace QtWebEngineCore {
-
-class YUVVideoMaterialShader : public QSGMaterialShader
-{
-public:
- YUVVideoMaterialShader(const gfx::ColorSpace &colorSpace)
- {
- static const char *shaderHead =
- "varying mediump vec2 v_yaTexCoord;\n"
- "varying mediump vec2 v_uvTexCoord;\n"
- "uniform sampler2D y_texture;\n"
- "uniform sampler2D u_texture;\n"
- "uniform sampler2D v_texture;\n"
- "uniform mediump float alpha;\n"
- "uniform mediump vec4 ya_clamp_rect;\n"
- "uniform mediump vec4 uv_clamp_rect;\n";
- static const char *shader =
- "void main() {\n"
- " mediump vec2 ya_clamped =\n"
- " max(ya_clamp_rect.xy, min(ya_clamp_rect.zw, v_yaTexCoord));\n"
- " mediump float y_raw = texture2D(y_texture, ya_clamped).x;\n"
- " mediump vec2 uv_clamped =\n"
- " max(uv_clamp_rect.xy, min(uv_clamp_rect.zw, v_uvTexCoord));\n"
- " mediump float u_unsigned = texture2D(u_texture, uv_clamped).x;\n"
- " mediump float v_unsigned = texture2D(v_texture, uv_clamped).x;\n"
- " mediump vec3 yuv = vec3(y_raw, u_unsigned, v_unsigned);\n"
- " mediump vec3 rgb = DoColorConversion(yuv);\n"
- " gl_FragColor = vec4(rgb, 1.0) * alpha;\n"
- "}";
- // Invalid or unspecified color spaces should be treated as REC709.
- gfx::ColorSpace src = colorSpace.IsValid() ? colorSpace : gfx::ColorSpace::CreateREC709();
- gfx::ColorSpace dst = gfx::ColorSpace::CreateSRGB();
- std::unique_ptr<gfx::ColorTransform> transform =
- gfx::ColorTransform::NewColorTransform(src, dst, gfx::ColorTransform::Intent::INTENT_PERCEPTUAL);
-
- QByteArray header(shaderHead);
- if (QOpenGLContext::currentContext()->isOpenGLES())
- header = QByteArray("precision mediump float;\n") + header;
-
- m_csShader = QByteArray::fromStdString(transform->GetShaderSource());
- m_fragmentShader = header + m_csShader + QByteArray(shader);
- }
- void updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
-
- char const *const *attributeNames() const override {
- static const char *names[] = {
- "a_position",
- "a_texCoord",
- 0
- };
- return names;
- }
-
-protected:
- const char *vertexShader() const override {
- // Keep in sync with logic in VertexShader in components/viz/service/display/shader.cc
- const char *shader =
- "attribute highp vec4 a_position;\n"
- "attribute mediump vec2 a_texCoord;\n"
- "uniform highp mat4 matrix;\n"
- "varying mediump vec2 v_yaTexCoord;\n"
- "varying mediump vec2 v_uvTexCoord;\n"
- "uniform mediump vec2 yaTexScale;\n"
- "uniform mediump vec2 yaTexOffset;\n"
- "uniform mediump vec2 uvTexScale;\n"
- "uniform mediump vec2 uvTexOffset;\n"
- "void main() {\n"
- " gl_Position = matrix * a_position;\n"
- " v_yaTexCoord = a_texCoord * yaTexScale + yaTexOffset;\n"
- " v_uvTexCoord = a_texCoord * uvTexScale + uvTexOffset;\n"
- "}";
- return shader;
- }
-
- const char *fragmentShader() const override {
- return m_fragmentShader.constData();
- }
-
- void initialize() override {
- m_id_matrix = program()->uniformLocation("matrix");
- m_id_yaTexScale = program()->uniformLocation("yaTexScale");
- m_id_uvTexScale = program()->uniformLocation("uvTexScale");
- m_id_yaTexOffset = program()->uniformLocation("yaTexOffset");
- m_id_uvTexOffset = program()->uniformLocation("uvTexOffset");
- m_id_yaClampRect = program()->uniformLocation("ya_clamp_rect");
- m_id_uvClampRect = program()->uniformLocation("uv_clamp_rect");
- m_id_yTexture = program()->uniformLocation("y_texture");
- m_id_uTexture = program()->uniformLocation("u_texture");
- m_id_vTexture = program()->uniformLocation("v_texture");
- m_id_yuvMatrix = program()->uniformLocation("yuv_matrix");
- m_id_yuvAdjust = program()->uniformLocation("yuv_adj");
- m_id_opacity = program()->uniformLocation("alpha");
- }
-
- int m_id_matrix;
- int m_id_yaTexScale;
- int m_id_uvTexScale;
- int m_id_yaTexOffset;
- int m_id_uvTexOffset;
- int m_id_yaClampRect;
- int m_id_uvClampRect;
- int m_id_yTexture;
- int m_id_uTexture;
- int m_id_vTexture;
- int m_id_yuvMatrix;
- int m_id_yuvAdjust;
- int m_id_opacity;
- QByteArray m_csShader;
- QByteArray m_fragmentShader;
-};
-
-class YUVAVideoMaterialShader : public YUVVideoMaterialShader
-{
-public:
- YUVAVideoMaterialShader(const gfx::ColorSpace &colorSpace) : YUVVideoMaterialShader(colorSpace)
- {
- static const char *shaderHead =
- "varying mediump vec2 v_yaTexCoord;\n"
- "varying mediump vec2 v_uvTexCoord;\n"
- "uniform sampler2D y_texture;\n"
- "uniform sampler2D u_texture;\n"
- "uniform sampler2D v_texture;\n"
- "uniform sampler2D a_texture;\n"
- "uniform mediump float alpha;\n"
- "uniform mediump vec4 ya_clamp_rect;\n"
- "uniform mediump vec4 uv_clamp_rect;\n";
- static const char *shader =
- "void main() {\n"
- " mediump vec2 ya_clamped =\n"
- " max(ya_clamp_rect.xy, min(ya_clamp_rect.zw, v_yaTexCoord));\n"
- " mediump float y_raw = texture2D(y_texture, ya_clamped).x;\n"
- " mediump vec2 uv_clamped =\n"
- " max(uv_clamp_rect.xy, min(uv_clamp_rect.zw, v_uvTexCoord));\n"
- " mediump float u_unsigned = texture2D(u_texture, uv_clamped).x;\n"
- " mediump float v_unsigned = texture2D(v_texture, uv_clamped).x;\n"
- " mediump float a_raw = texture2D(a_texture, ya_clamped).x;\n"
- " mediump vec3 yuv = vec3(y_raw, u_unsigned, v_unsigned);\n"
- " mediump vec3 rgb = DoColorConversion(yuv);\n"
- " gl_FragColor = vec4(rgb, 1.0) * (alpha * a_raw);\n"
- "}";
- QByteArray header(shaderHead);
- if (QOpenGLContext::currentContext()->isOpenGLES())
- header = QByteArray("precision mediump float;\n") + header;
- m_fragmentShader = header + m_csShader + QByteArray(shader);
- }
- void updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
-
-protected:
- void initialize() override {
- // YUVVideoMaterialShader has a subset of the uniforms.
- YUVVideoMaterialShader::initialize();
- m_id_aTexture = program()->uniformLocation("a_texture");
- }
-
- int m_id_aTexture;
-};
-
-void YUVVideoMaterialShader::updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
-{
- Q_UNUSED(oldMaterial);
-
- // Keep logic in sync with logic in GLRenderer::DrawYUVVideoQuad:
-
- YUVVideoMaterial *mat = static_cast<YUVVideoMaterial *>(newMaterial);
- program()->setUniformValue(m_id_yTexture, 0);
- program()->setUniformValue(m_id_uTexture, 1);
- program()->setUniformValue(m_id_vTexture, 2);
-
- QOpenGLFunctions glFuncs(QOpenGLContext::currentContext());
-
- glFuncs.glActiveTexture(GL_TEXTURE1);
- mat->m_uTexture->bind();
- glFuncs.glActiveTexture(GL_TEXTURE2);
- mat->m_vTexture->bind();
- glFuncs.glActiveTexture(GL_TEXTURE0); // Finish with 0 as default texture unit
- mat->m_yTexture->bind();
-
- const QSizeF yaSizeScale(1.0f / mat->m_yaTexSize.width(), 1.0f / mat->m_yaTexSize.height());
- const QSizeF uvSizeScale(1.0f / mat->m_uvTexSize.width(), 1.0f / mat->m_uvTexSize.height());
-
- const QPointF yaTexOffset(mat->m_yaTexCoordRect.left() * yaSizeScale.width(), mat->m_yaTexCoordRect.top() * yaSizeScale.height());
- const QPointF uvTexOffset(mat->m_uvTexCoordRect.left() * uvSizeScale.width(), mat->m_uvTexCoordRect.top() * uvSizeScale.height());
- const QSizeF yaTexScale(mat->m_yaTexCoordRect.width() * yaSizeScale.width(), mat->m_yaTexCoordRect.height() * yaSizeScale.height());
- const QSizeF uvTexScale(mat->m_uvTexCoordRect.width() * uvSizeScale.width(), mat->m_uvTexCoordRect.height() * uvSizeScale.height());
- program()->setUniformValue(m_id_yaTexOffset, yaTexOffset);
- program()->setUniformValue(m_id_uvTexOffset, uvTexOffset);
- program()->setUniformValue(m_id_yaTexScale, yaTexScale);
- program()->setUniformValue(m_id_uvTexScale, uvTexScale);
- QRectF yaClampRect(yaTexOffset, yaTexScale);
- QRectF uvClampRect(uvTexOffset, uvTexScale);
- yaClampRect = yaClampRect.marginsRemoved(QMarginsF(yaSizeScale.width() * 0.5f, yaSizeScale.height() * 0.5f,
- yaSizeScale.width() * 0.5f, yaSizeScale.height() * 0.5f));
- uvClampRect = uvClampRect.marginsRemoved(QMarginsF(uvSizeScale.width() * 0.5f, uvSizeScale.height() * 0.5f,
- uvSizeScale.width() * 0.5f, uvSizeScale.height() * 0.5f));
-
- const QVector4D yaClampV(yaClampRect.left(), yaClampRect.top(), yaClampRect.right(), yaClampRect.bottom());
- const QVector4D uvClampV(uvClampRect.left(), uvClampRect.top(), uvClampRect.right(), uvClampRect.bottom());
- program()->setUniformValue(m_id_yaClampRect, yaClampV);
- program()->setUniformValue(m_id_uvClampRect, uvClampV);
-
- if (state.isOpacityDirty())
- program()->setUniformValue(m_id_opacity, state.opacity());
-
- if (state.isMatrixDirty())
- program()->setUniformValue(m_id_matrix, state.combinedMatrix());
-}
-
-void YUVAVideoMaterialShader::updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
-{
- YUVVideoMaterialShader::updateState(state, newMaterial, oldMaterial);
-
- YUVAVideoMaterial *mat = static_cast<YUVAVideoMaterial *>(newMaterial);
- program()->setUniformValue(m_id_aTexture, 3);
-
- QOpenGLFunctions glFuncs(QOpenGLContext::currentContext());
-
- glFuncs.glActiveTexture(GL_TEXTURE3);
- mat->m_aTexture->bind();
-
- // Reset the default texture unit.
- glFuncs.glActiveTexture(GL_TEXTURE0);
-}
-
-
-YUVVideoMaterial::YUVVideoMaterial(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture,
- const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize,
- const gfx::ColorSpace &colorspace,
- float rMul, float rOff)
- : m_yTexture(yTexture)
- , m_uTexture(uTexture)
- , m_vTexture(vTexture)
- , m_yaTexCoordRect(yaTexCoordRect)
- , m_uvTexCoordRect(uvTexCoordRect)
- , m_yaTexSize(yaTexSize)
- , m_uvTexSize(uvTexSize)
- , m_colorSpace(colorspace)
- , m_resourceMultiplier(rMul)
- , m_resourceOffset(rOff)
-{
-}
-
-QSGMaterialShader *YUVVideoMaterial::createShader() const
-{
- return new YUVVideoMaterialShader(m_colorSpace);
-}
-
-int YUVVideoMaterial::compare(const QSGMaterial *other) const
-{
- const YUVVideoMaterial *m = static_cast<const YUVVideoMaterial *>(other);
- if (int diff = m_yTexture->textureId() - m->m_yTexture->textureId())
- return diff;
- if (int diff = m_uTexture->textureId() - m->m_uTexture->textureId())
- return diff;
- return m_vTexture->textureId() - m->m_vTexture->textureId();
-}
-
-YUVAVideoMaterial::YUVAVideoMaterial(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, QSGTexture *aTexture,
- const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize,
- const gfx::ColorSpace &colorspace,
- float rMul, float rOff)
- : YUVVideoMaterial(yTexture, uTexture, vTexture, yaTexCoordRect, uvTexCoordRect, yaTexSize, uvTexSize, colorspace, rMul, rOff)
- , m_aTexture(aTexture)
-{
- setFlag(Blending, aTexture);
-}
-
-QSGMaterialShader *YUVAVideoMaterial::createShader() const
-{
- return new YUVAVideoMaterialShader(m_colorSpace);
-}
-
-int YUVAVideoMaterial::compare(const QSGMaterial *other) const
-{
- if (int diff = YUVVideoMaterial::compare(other))
- return diff;
- const YUVAVideoMaterial *m = static_cast<const YUVAVideoMaterial *>(other);
- return (m_aTexture ? m_aTexture->textureId() : 0) - (m->m_aTexture ? m->m_aTexture->textureId() : 0);
-}
-
-YUVVideoNode::YUVVideoNode(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, QSGTexture *aTexture,
- const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize,
- const gfx::ColorSpace &colorspace, float rMul, float rOff)
- : m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4)
-{
- setGeometry(&m_geometry);
- setFlag(QSGNode::OwnsMaterial);
- if (aTexture)
- m_material = new YUVAVideoMaterial(yTexture, uTexture, vTexture, aTexture, yaTexCoordRect, uvTexCoordRect, yaTexSize, uvTexSize, colorspace, rMul, rOff);
- else
- m_material = new YUVVideoMaterial(yTexture, uTexture, vTexture, yaTexCoordRect, uvTexCoordRect, yaTexSize, uvTexSize, colorspace, rMul, rOff);
- setMaterial(m_material);
-}
-
-void YUVVideoNode::setRect(const QRectF &rect)
-{
- QSGGeometry::updateTexturedRectGeometry(geometry(), rect, QRectF(0, 0, 1, 1));
-}
-
-} // namespace
diff --git a/src/core/compositor/yuv_video_node.h b/src/core/compositor/yuv_video_node.h
deleted file mode 100644
index dca8fa5e2..000000000
--- a/src/core/compositor/yuv_video_node.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 YUV_VIDEO_NODE_H
-#define YUV_VIDEO_NODE_H
-
-#include <QtQuick/qsgmaterial.h>
-#include <QtQuick/qsgnode.h>
-
-#include "ui/gfx/color_space.h"
-
-QT_FORWARD_DECLARE_CLASS(QSGTexture)
-
-namespace QtWebEngineCore {
-
-// These classes duplicate, QtQuick style, the logic of GLRenderer::DrawYUVVideoQuad.
-// Their behavior should stay as close as possible to GLRenderer.
-
-class YUVVideoMaterial : public QSGMaterial
-{
-public:
- YUVVideoMaterial(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture,
- const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize,
- const gfx::ColorSpace &colorspace, float rMul, float rOff);
-
- QSGMaterialType *type() const override
- {
- static QSGMaterialType theType;
- return &theType;
- }
-
- QSGMaterialShader *createShader() const override;
- int compare(const QSGMaterial *other) const override;
-
- QSGTexture *m_yTexture;
- QSGTexture *m_uTexture;
- QSGTexture *m_vTexture;
- QRectF m_yaTexCoordRect;
- QRectF m_uvTexCoordRect;
- QSizeF m_yaTexSize;
- QSizeF m_uvTexSize;
- gfx::ColorSpace m_colorSpace;
- float m_resourceMultiplier;
- float m_resourceOffset;
-};
-
-class YUVAVideoMaterial : public YUVVideoMaterial
-{
-public:
- YUVAVideoMaterial(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, QSGTexture *aTexture,
- const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize,
- const gfx::ColorSpace &colorspace, float rMul, float rOff);
-
- QSGMaterialType *type() const override
- {
- static QSGMaterialType theType;
- return &theType;
- }
-
- QSGMaterialShader *createShader() const override;
- int compare(const QSGMaterial *other) const override;
-
- QSGTexture *m_aTexture;
-};
-
-class YUVVideoNode : public QSGGeometryNode
-{
-public:
- YUVVideoNode(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, QSGTexture *aTexture,
- const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize,
- const gfx::ColorSpace &colorspace, float rMul, float rOff);
- void setRect(const QRectF &rect);
-
-private:
- QSGGeometry m_geometry;
- YUVVideoMaterial *m_material;
-};
-
-} // namespace
-
-#endif // YUV_VIDEO_NODE_H
diff --git a/src/core/config/common.pri b/src/core/config/common.pri
index 9432fac7d..8ffd59e99 100644
--- a/src/core/config/common.pri
+++ b/src/core/config/common.pri
@@ -27,9 +27,10 @@ qtConfig(webengine-webrtc) {
qtConfig(webengine-proprietary-codecs) {
gn_args += proprietary_codecs=true ffmpeg_branding=\"Chrome\"
- qtConfig(webengine-webrtc) {
- gn_args += rtc_use_h264=true
- }
+# Fix after updating 3rdparty in dev to include the right fix
+# qtConfig(webengine-webrtc) {
+# gn_args += rtc_use_h264=true
+# }
} else {
gn_args += proprietary_codecs=false
}
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index 05957c26f..1abf2387e 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -103,10 +103,6 @@
#include "third_party/blink/public/mojom/insecure_input/insecure_input_service.mojom.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_switches.h"
-#include "ui/gl/gl_context.h"
-#include "ui/gl/gl_implementation.h"
-#include "ui/gl/gl_share_group.h"
-#include "ui/gl/gpu_timing.h"
#include "url/url_util_qt.h"
#include "qtwebengine/common/renderer_configuration.mojom.h"
@@ -116,7 +112,6 @@
#include "browser_main_parts_qt.h"
#include "browser_message_filter_qt.h"
#include "certificate_error_controller.h"
-#include "certificate_error_controller_p.h"
#include "client_cert_select_controller.h"
#include "devtools_manager_delegate_qt.h"
#include "login_delegate_qt.h"
@@ -145,7 +140,7 @@
#include "api/qwebenginecookiestore.h"
#include "api/qwebenginecookiestore_p.h"
#include "api/qwebengineurlscheme.h"
-
+#include "ozone/gl_share_context_qt.h"
#if defined(Q_OS_LINUX)
#include "global_descriptors_qt.h"
#include "ui/base/resource/resource_bundle.h"
@@ -186,15 +181,6 @@
#include <QGuiApplication>
#include <QLocale>
#include <QStandardPaths>
-#if QT_CONFIG(opengl)
-# include <QOpenGLContext>
-# include <QOpenGLExtraFunctions>
-#endif
-#include <qpa/qplatformnativeinterface.h>
-
-QT_BEGIN_NAMESPACE
-Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();
-QT_END_NAMESPACE
// Implement IsHandledProtocol as declared in //url/url_util_qt.h.
namespace url {
@@ -235,93 +221,6 @@ bool IsHandledProtocol(base::StringPiece scheme)
namespace QtWebEngineCore {
-class QtShareGLContext : public gl::GLContext {
-public:
- QtShareGLContext(QOpenGLContext *qtContext)
- : gl::GLContext(0)
- , m_handle(0)
- {
- QString platform = qApp->platformName().toLower();
- QPlatformNativeInterface *pni = QGuiApplication::platformNativeInterface();
- if (platform == QLatin1String("xcb") || platform == QLatin1String("offscreen")) {
- if (gl::GetGLImplementation() == gl::kGLImplementationEGLGLES2)
- m_handle = pni->nativeResourceForContext(QByteArrayLiteral("eglcontext"), qtContext);
- else
- m_handle = pni->nativeResourceForContext(QByteArrayLiteral("glxcontext"), qtContext);
- } else if (platform == QLatin1String("cocoa"))
- m_handle = pni->nativeResourceForContext(QByteArrayLiteral("cglcontextobj"), qtContext);
- else if (platform == QLatin1String("qnx"))
- m_handle = pni->nativeResourceForContext(QByteArrayLiteral("eglcontext"), qtContext);
- else if (platform == QLatin1String("eglfs") || platform == QLatin1String("wayland")
- || platform == QLatin1String("wayland-egl"))
- m_handle = pni->nativeResourceForContext(QByteArrayLiteral("eglcontext"), qtContext);
- else if (platform == QLatin1String("windows")) {
- if (gl::GetGLImplementation() == gl::kGLImplementationEGLGLES2)
- m_handle = pni->nativeResourceForContext(QByteArrayLiteral("eglContext"), qtContext);
- else
- m_handle = pni->nativeResourceForContext(QByteArrayLiteral("renderingcontext"), qtContext);
- } else {
- qFatal("%s platform not yet supported", platform.toLatin1().constData());
- // Add missing platforms once they work.
- Q_UNREACHABLE();
- }
- }
-
- void* GetHandle() override { return m_handle; }
- unsigned int CheckStickyGraphicsResetStatus() override
- {
-#if QT_CONFIG(opengl)
- if (QOpenGLContext *context = qt_gl_global_share_context()) {
- if (context->format().testOption(QSurfaceFormat::ResetNotification))
- return context->extraFunctions()->glGetGraphicsResetStatus();
- }
-#endif
- return 0 /*GL_NO_ERROR*/;
- }
-
- // We don't care about the rest, this context shouldn't be used except for its handle.
- bool Initialize(gl::GLSurface *, const gl::GLContextAttribs &) override { Q_UNREACHABLE(); return false; }
- bool MakeCurrent(gl::GLSurface *) override { Q_UNREACHABLE(); return false; }
- void ReleaseCurrent(gl::GLSurface *) override { Q_UNREACHABLE(); }
- bool IsCurrent(gl::GLSurface *) override { Q_UNREACHABLE(); return false; }
- scoped_refptr<gl::GPUTimingClient> CreateGPUTimingClient() override
- {
- return nullptr;
- }
- const gfx::ExtensionSet& GetExtensions() override
- {
- static const gfx::ExtensionSet s_emptySet;
- return s_emptySet;
- }
- void ResetExtensions() override
- {
- }
-
-private:
- void *m_handle;
-};
-
-class ShareGroupQtQuick : public gl::GLShareGroup {
-public:
- gl::GLContext* GetContext() override { return m_shareContextQtQuick.get(); }
- void AboutToAddFirstContext() override;
-
-private:
- scoped_refptr<QtShareGLContext> m_shareContextQtQuick;
-};
-
-void ShareGroupQtQuick::AboutToAddFirstContext()
-{
-#if QT_CONFIG(opengl)
- // This currently has to be setup by ::main in all applications using QQuickWebEngineView with delegated rendering.
- QOpenGLContext *shareContext = qt_gl_global_share_context();
- if (!shareContext) {
- qFatal("QWebEngine: OpenGL resource sharing is not set up in QtQuick. Please make sure to call QtWebEngine::initialize() in your main() function before QCoreApplication is created.");
- }
- m_shareContextQtQuick = new QtShareGLContext(shareContext);
-#endif
-}
-
ContentBrowserClientQt::ContentBrowserClientQt()
{
}
@@ -366,9 +265,9 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost
gl::GLShareGroup *ContentBrowserClientQt::GetInProcessGpuShareGroup()
{
- if (!m_shareGroupQtQuick.get())
- m_shareGroupQtQuick = new ShareGroupQtQuick;
- return m_shareGroupQtQuick.get();
+ if (!m_shareGroupQt.get())
+ m_shareGroupQt = new ShareGroupQt;
+ return m_shareGroupQt.get();
}
content::MediaObserver *ContentBrowserClientQt::GetMediaObserver()
@@ -402,52 +301,18 @@ void ContentBrowserClientQt::GetQuotaSettings(content::BrowserContext* context,
storage::GetDefaultDeviceInfoHelper(), std::move(callback));
}
-// Copied from chrome/browser/ssl/ssl_error_handler.cc:
-static int IsCertErrorFatal(int cert_error)
-{
- switch (cert_error) {
- case net::ERR_CERT_COMMON_NAME_INVALID:
- case net::ERR_CERT_DATE_INVALID:
- case net::ERR_CERT_AUTHORITY_INVALID:
- case net::ERR_CERT_WEAK_SIGNATURE_ALGORITHM:
- case net::ERR_CERT_WEAK_KEY:
- case net::ERR_CERT_NAME_CONSTRAINT_VIOLATION:
- case net::ERR_CERT_VALIDITY_TOO_LONG:
- case net::ERR_CERTIFICATE_TRANSPARENCY_REQUIRED:
- case net::ERR_CERT_SYMANTEC_LEGACY:
- return false;
- case net::ERR_CERT_CONTAINS_ERRORS:
- case net::ERR_CERT_REVOKED:
- case net::ERR_CERT_INVALID:
- case net::ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY:
- case net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN:
- return true;
- default:
- NOTREACHED();
- }
- return true;
-}
-
void ContentBrowserClientQt::AllowCertificateError(content::WebContents *webContents,
int cert_error,
const net::SSLInfo &ssl_info,
const GURL &request_url,
- bool is_main_frame_request,
+ bool /* is_main_frame_request */,
bool strict_enforcement,
base::OnceCallback<void(content::CertificateRequestResultType)> callback)
{
WebContentsDelegateQt* contentsDelegate = static_cast<WebContentsDelegateQt*>(webContents->GetDelegate());
- QSharedPointer<CertificateErrorController> errorController(
- new CertificateErrorController(
- new CertificateErrorControllerPrivate(
- cert_error,
- ssl_info,
- request_url,
- is_main_frame_request,
- IsCertErrorFatal(cert_error),
- strict_enforcement,
- std::move(callback))));
+ QSharedPointer<CertificateErrorController> errorController(new CertificateErrorController(
+ cert_error, ssl_info, request_url, strict_enforcement, std::move(callback)));
contentsDelegate->allowCertificateError(errorController);
}
diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h
index 341564574..f536f2427 100644
--- a/src/core/content_browser_client_qt.h
+++ b/src/core/content_browser_client_qt.h
@@ -76,7 +76,7 @@ namespace QtWebEngineCore {
class BrowserMainPartsQt;
class ProfileQt;
-class ShareGroupQtQuick;
+class ShareGroupQt;
class ContentBrowserClientQt : public content::ContentBrowserClient
{
@@ -261,7 +261,7 @@ public:
private:
void InitFrameInterfaces();
- scoped_refptr<ShareGroupQtQuick> m_shareGroupQtQuick;
+ scoped_refptr<ShareGroupQt> m_shareGroupQt;
std::unique_ptr<service_manager::BinderRegistry> m_frameInterfaces;
std::unique_ptr<service_manager::BinderRegistryWithArgs<content::RenderFrameHost*>> m_frameInterfacesParameterized;
};
diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri
index 4e4f529ab..09ca86cfc 100644
--- a/src/core/core_chromium.pri
+++ b/src/core/core_chromium.pri
@@ -53,12 +53,8 @@ SOURCES = \
common/qt_ipc_logging.cpp \
common/qt_messages.cpp \
common/user_script_data.cpp \
- compositor/chromium_gpu_helper.cpp \
compositor/compositor.cpp \
- compositor/compositor_resource_tracker.cpp \
compositor/content_gpu_client_qt.cpp \
- compositor/delegated_frame_node.cpp \
- compositor/display_frame_sink.cpp \
compositor/display_overrides.cpp \
compositor/display_software_output_surface.cpp \
content_client_qt.cpp \
@@ -93,6 +89,7 @@ SOURCES = \
net/url_request_custom_job_proxy.cpp \
net/webui_controller_factory_qt.cpp \
ozone/gl_context_qt.cpp \
+ ozone/gl_share_context_qt.cpp \
ozone/gl_ozone_egl_qt.cpp \
ozone/gl_surface_qt.cpp \
ozone/gl_surface_egl_qt.cpp \
@@ -112,6 +109,7 @@ SOURCES = \
register_protocol_handler_request_controller_impl.cpp \
render_view_context_menu_qt.cpp \
render_widget_host_view_qt.cpp \
+ render_widget_host_view_qt_delegate_client.cpp \
renderer/content_renderer_client_qt.cpp \
renderer/content_settings_observer_qt.cpp \
renderer/render_frame_observer_qt.cpp \
@@ -150,7 +148,6 @@ HEADERS = \
browsing_data_remover_delegate_qt.h \
browser_main_parts_qt.h \
browser_message_filter_qt.h \
- certificate_error_controller_p.h \
certificate_error_controller.h \
client_cert_select_controller.h \
clipboard_change_observer.h \
@@ -160,13 +157,8 @@ HEADERS = \
color_chooser_controller.h \
common/qt_messages.h \
common/user_script_data.h \
- compositor/chromium_gpu_helper.h \
compositor/compositor.h \
- compositor/compositor_resource.h \
- compositor/compositor_resource_tracker.h \
compositor/content_gpu_client_qt.h \
- compositor/delegated_frame_node.h \
- compositor/display_frame_sink.h \
compositor/display_software_output_surface.h \
content_client_qt.h \
content_browser_client_qt.h \
@@ -184,7 +176,6 @@ HEADERS = \
javascript_dialog_controller_p.h \
javascript_dialog_controller.h \
javascript_dialog_manager_qt.h \
- locked_ptr.h \
login_delegate_qt.h \
media_capture_devices_dispatcher.h \
net/client_cert_override.h \
@@ -200,6 +191,7 @@ HEADERS = \
net/url_request_custom_job_proxy.h \
net/webui_controller_factory_qt.h \
ozone/gl_context_qt.h \
+ ozone/gl_share_context_qt.h \
ozone/gl_ozone_egl_qt.h \
ozone/gl_surface_qt.h \
ozone/gl_surface_egl_qt.h \
@@ -224,6 +216,7 @@ HEADERS = \
render_view_context_menu_qt.h \
render_widget_host_view_qt.h \
render_widget_host_view_qt_delegate.h \
+ render_widget_host_view_qt_delegate_client.h \
renderer/content_renderer_client_qt.h \
renderer/content_settings_observer_qt.h \
renderer/render_frame_observer_qt.h \
@@ -301,15 +294,11 @@ qtConfig(webengine-printing-and-pdf) {
contains(QT_CONFIG, opengl) {
SOURCES += \
compositor/compositor_resource_fence.cpp \
- compositor/display_gl_output_surface.cpp \
- compositor/display_gl_output_surface_qsg.cpp \
- compositor/stream_video_node.cpp \
- compositor/yuv_video_node.cpp
+ compositor/display_gl_output_surface.cpp
HEADERS += \
compositor/compositor_resource_fence.h \
- compositor/display_gl_output_surface.h \
- compositor/stream_video_node.h \
- compositor/yuv_video_node.h
+ compositor/display_gl_output_surface.h
+
macos {
HEADERS+=macos_context_type_helper.h
SOURCES+=macos_context_type_helper.mm
diff --git a/src/core/delegated_frame_host_client_qt.cpp b/src/core/delegated_frame_host_client_qt.cpp
index 817ea2fa5..d3f5a4ade 100644
--- a/src/core/delegated_frame_host_client_qt.cpp
+++ b/src/core/delegated_frame_host_client_qt.cpp
@@ -61,7 +61,6 @@ SkColor DelegatedFrameHostClientQt::DelegatedFrameHostGetGutterColor() const
void DelegatedFrameHostClientQt::OnBeginFrame(base::TimeTicks frame_time)
{
p->host()->ProgressFlingIfNeeded(frame_time);
- p->UpdateNeedsBeginFramesInternal();
}
void DelegatedFrameHostClientQt::OnFrameTokenChanged(uint32_t frame_token)
diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp
index ebf498fdf..9b87d489a 100644
--- a/src/core/download_manager_delegate_qt.cpp
+++ b/src/core/download_manager_delegate_qt.cpp
@@ -68,7 +68,6 @@ DownloadManagerDelegateQt::DownloadManagerDelegateQt(ProfileAdapter *profileAdap
: m_profileAdapter(profileAdapter)
, m_currentId(0)
, m_weakPtrFactory(this)
- , m_nextDownloadIsUserRequested(false)
{
Q_ASSERT(m_profileAdapter);
}
@@ -138,17 +137,6 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(download::DownloadItem*
QString suggestedFilename = toQt(item->GetSuggestedFilename());
QString mimeTypeString = toQt(item->GetMimeType());
- int downloadType = 0;
- if (m_nextDownloadIsUserRequested) {
- downloadType = ProfileAdapterClient::UserRequested;
- m_nextDownloadIsUserRequested = false;
- } else {
- bool isAttachment = net::HttpContentDisposition(item->GetContentDisposition(), std::string()).is_attachment();
- if (isAttachment)
- downloadType = ProfileAdapterClient::Attachment;
- else
- downloadType = ProfileAdapterClient::DownloadAttribute;
- }
if (suggestedFilename.isEmpty())
suggestedFilename = toQt(net::HttpContentDisposition(item->GetContentDisposition(), net::kCharsetLatin1).filename());
@@ -191,7 +179,7 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(download::DownloadItem*
false /* accepted */,
false /* paused */,
false /* done */,
- downloadType,
+ false /* isSavePageDownload */,
item->GetLastReason(),
adapterClient,
suggestedFilename,
@@ -292,7 +280,7 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content
acceptedByDefault,
false, /* paused */
false, /* done */
- ProfileAdapterClient::SavePage,
+ true, /* isSavePageDownload */
ProfileAdapterClient::NoReason,
adapterClient,
QFileInfo(suggestedFilePath).fileName(),
diff --git a/src/core/download_manager_delegate_qt.h b/src/core/download_manager_delegate_qt.h
index 0cdbd6ee3..f254d23c9 100644
--- a/src/core/download_manager_delegate_qt.h
+++ b/src/core/download_manager_delegate_qt.h
@@ -89,8 +89,6 @@ public:
void resumeDownload(quint32 downloadId);
void removeDownload(quint32 downloadId);
- void markNextDownloadAsUserRequested() { m_nextDownloadIsUserRequested = true; }
-
// Inherited from content::DownloadItem::Observer
void OnDownloadUpdated(download::DownloadItem *download) override;
void OnDownloadDestroyed(download::DownloadItem *download) override;
@@ -103,7 +101,6 @@ private:
uint32_t m_currentId;
base::WeakPtrFactory<DownloadManagerDelegateQt> m_weakPtrFactory;
- bool m_nextDownloadIsUserRequested;
friend class DownloadManagerDelegateInstance;
friend class ProfileAdapter;
diff --git a/src/core/gn_run.pro b/src/core/gn_run.pro
index 3d6fda80e..4688ea59d 100644
--- a/src/core/gn_run.pro
+++ b/src/core/gn_run.pro
@@ -7,11 +7,7 @@ TEMPLATE = aux
qtConfig(debug_and_release): CONFIG += debug_and_release
qtConfig(build_all): CONFIG += build_all
-qtConfig(webengine-system-ninja) {
- QT_TOOL.ninja.binary = ninja
-} else {
- QT_TOOL.ninja.binary = $$shell_quote($$shell_path($$ninjaPath()))
-}
+QT_TOOL.ninja.binary = $$shell_quote($$shell_path($$ninjaPath()))
win32 {
# Add the gnuwin32/bin subdir of qt5.git to PATH. Needed for calling bison and friends.
diff --git a/src/core/locked_ptr.h b/src/core/locked_ptr.h
deleted file mode 100644
index 46d89819b..000000000
--- a/src/core/locked_ptr.h
+++ /dev/null
@@ -1,301 +0,0 @@
-/****************************************************************************
-**
-** 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 LOCKED_PTR_H
-#define LOCKED_PTR_H
-
-#include <base/bind_internal.h>
-
-#include <QtCore/qreadwritelock.h>
-
-namespace base {
-
-struct LockedPtrCore
-{
- LockedPtrCore(uintptr_t data) : data(data) {}
-
- std::atomic<size_t> refCount{1};
- // Atomic so that WeakLockedPtr::get can still read it.
- std::atomic<uintptr_t> data;
- QReadWriteLock lock{QReadWriteLock::Recursive};
-};
-
-enum class LockedPtrMode { Weak, Shared, Exclusive };
-
-template<class T, LockedPtrMode mode> class LockedPtr;
-
-// A WeakLockedPtr<T> is something like shared_ptr<T*>. The T* value can only be
-// accessed by atomic read.
-template<class T> using WeakLockedPtr = LockedPtr<T, LockedPtrMode::Weak>;
-
-// A SharedLockedPtr<T> is like WeakLockedPtr<T>, but the T* value is prevented
-// from changing for the lifetime of the SharedLockedPtr by holding a
-// shared-exclusive mutex in shared mode.
-template<class T> using SharedLockedPtr = LockedPtr<T, LockedPtrMode::Shared>;
-
-// An ExclusiveLockedPtr<T> is like SharedLockedPtr<T>, but the mutex is held in
-// exclusive mode. Only in this mode can the T* value be changed.
-template<class T> using ExclusiveLockedPtr = LockedPtr<T, LockedPtrMode::Exclusive>;
-
-template<class T, LockedPtrMode mode>
-class LockedPtr
-{
- template<class T1>
- static constexpr bool canConstructFrom =
- std::is_same<T, T1>::value ||
- std::is_same<T, const T1>::value;
-
-public:
- constexpr LockedPtr() {}
- constexpr LockedPtr(std::nullptr_t) {}
-
- LockedPtr(const LockedPtr &that)
- {
- m_core = that.m_core;
- lock();
- }
-
- LockedPtr &operator=(const LockedPtr &that)
- {
- unlock();
- m_core = that.m_core;
- lock();
- }
-
- LockedPtr(LockedPtr &&that)
- {
- m_core = that.m_core;
- that.m_core = nullptr;
- }
-
- LockedPtr &operator=(LockedPtr &&that)
- {
- unlock();
- m_core = that.m_core;
- that.m_core = nullptr;
- }
-
- template<class T1, LockedPtrMode mode1,
- class Enable = std::enable_if_t<canConstructFrom<T1>>>
- LockedPtr(const LockedPtr<T1, mode1> &that)
- {
- m_core = that.m_core;
- lock();
- }
-
- template<class T1, LockedPtrMode mode1,
- class Enable = std::enable_if_t<canConstructFrom<T1>>>
- LockedPtr &operator=(const LockedPtr<T1, mode1> &that)
- {
- unlock();
- m_core = that.m_core;
- lock();
- }
-
- template<class T1,
- class Enable = std::enable_if_t<canConstructFrom<T1>>>
- LockedPtr(LockedPtr<T1, mode> &&that)
- {
- m_core = that.m_core;
- that.m_core = nullptr;
- }
-
- template<class T1,
- class Enable = std::enable_if_t<canConstructFrom<T1>>>
- LockedPtr &operator=(LockedPtr<T1, mode> &&that)
- {
- unlock();
- m_core = that.m_core;
- that.m_core = nullptr;
- }
-
- ~LockedPtr()
- {
- unlock();
- }
-
- T *get() const
- {
- if (m_core) {
- if (mode == LockedPtrMode::Weak)
- return reinterpret_cast<T *>(m_core->data.load(std::memory_order_acquire));
- else
- return reinterpret_cast<T *>(m_core->data.load(std::memory_order_relaxed));
- }
- return nullptr;
- }
-
- void set(T *value)
- {
- static_assert(mode == LockedPtrMode::Exclusive, "");
- DCHECK(m_core);
- m_core->data.store(reinterpret_cast<uintptr_t>(value), std::memory_order_release);
- }
-
- T &operator*() const { return *get(); }
- T *operator->() const { return get(); }
- explicit operator bool() const { return get(); }
-
- bool MaybeValid() const { return m_core; }
-
- static LockedPtr create(T *value)
- {
- return new LockedPtrCore(reinterpret_cast<uintptr_t>(value));
- }
-
-private:
- template<class T1, LockedPtrMode mode1> friend class LockedPtr;
-
- LockedPtr(LockedPtrCore *core)
- : m_core(core)
- {}
-
- void lock()
- {
- if (m_core) {
- ++m_core->refCount;
-
- if (mode == LockedPtrMode::Shared)
- m_core->lock.lockForRead();
- else if (mode == LockedPtrMode::Exclusive)
- m_core->lock.lockForWrite();
- }
- }
-
- void unlock()
- {
- if (m_core) {
- if (mode != LockedPtrMode::Weak)
- m_core->lock.unlock();
-
- if (--m_core->refCount == 0)
- delete m_core;
- }
- }
-
- LockedPtrCore *m_core = nullptr;
-};
-
-// This makes Bind check the pointer before calling the functor.
-template<class T>
-struct IsWeakReceiver<WeakLockedPtr<T>> : std::true_type {};
-
-// By converting the WeakLockedPtr into a SharedLockedPtr we prevent the
-// pointed-to object from being destroyed during the base::Callback::Run call.
-//
-// Unwrap() is called before checking the pointer, so there's no race condition.
-template<class T>
-struct BindUnwrapTraits<WeakLockedPtr<T>>
-{
- static SharedLockedPtr<T> Unwrap(const WeakLockedPtr<T> &o)
- {
- return o;
- }
-};
-
-// Like base::WeakPtrFactory, but InvalidateWeakPtrs *waits* until all currently
-// executing base::Callbacks are finished. Queued up base::Callbacks are still
-// canceled, exactly like with WeakPtrFactory.
-//
-// Consider, for example, the function
-//
-// void fun()
-// {
-// MyClass *myClass = new MyClass;
-// myClass->scheduleDoStuff();
-// delete myClass; // ???
-// }
-//
-// where
-//
-// class MyClass
-// {
-// public:
-// void scheduleDoStuff()
-// {
-// content::BrowserThread::PostTask(
-// content::BrowserThread::IO, FROM_HERE,
-// base::BindOnce(&MyClass::doStuff, m_weakPtrFactory.GetWeakPtr()));
-// }
-// void doStuff();
-// private:
-// //base::WeakPtrFactory m_weakPtrFactory{this};
-// base::LockedPtrFactory m_weakPtrFactory{this};
-// };
-//
-// What happens if the 'delete myClass' line is executed concurrently with
-// MyClass::doStuff?
-//
-// With WeakPtrs we get a segfault or perhaps memory corruption.
-//
-// With LockedPtrs we get no crash and no corruption: LockedPtrFactory's
-// destructor will wait until doStuff is done before continuing.
-template<class T>
-class LockedPtrFactory
-{
-public:
- explicit LockedPtrFactory(T *value)
- : m_ptr(WeakLockedPtr<T>::create(value))
- {}
-
- ~LockedPtrFactory()
- {
- InvalidateWeakPtrs();
- }
-
- WeakLockedPtr<T> GetWeakPtr() { return m_ptr; }
- WeakLockedPtr<const T> GetWeakPtr() const { return m_ptr; }
- SharedLockedPtr<T> GetSharedPtr() { return m_ptr; }
- SharedLockedPtr<const T> GetSharedPtr() const { return m_ptr; }
- ExclusiveLockedPtr<T> GetExclusivePtr() { return m_ptr; }
- ExclusiveLockedPtr<const T> GetExclusivePtr() const { return m_ptr; }
-
- void InvalidateWeakPtrs()
- {
- if (ExclusiveLockedPtr<T> ptr = m_ptr)
- ptr.set(nullptr);
- }
-
-private:
- WeakLockedPtr<T> m_ptr;
-};
-
-} // namespace base
-
-#endif // !LOCKED_PTR_H
diff --git a/src/core/macos_context_type_helper.h b/src/core/macos_context_type_helper.h
index d234a2bff..a7b989bc3 100644
--- a/src/core/macos_context_type_helper.h
+++ b/src/core/macos_context_type_helper.h
@@ -39,4 +39,5 @@
#ifndef MACOS_CONTEXT_TYPE_HELPER_H_
#define MACOS_CONTEXT_TYPE_HELPER_H_
bool isCurrentContextSoftware();
+void* cglContext(NSOpenGLContext*);
#endif // MACOS_CONTEXT_TYPE_HELPER_H_
diff --git a/src/core/macos_context_type_helper.mm b/src/core/macos_context_type_helper.mm
index c814d2849..4c9302482 100644
--- a/src/core/macos_context_type_helper.mm
+++ b/src/core/macos_context_type_helper.mm
@@ -47,3 +47,8 @@ bool isCurrentContextSoftware()
[NSOpenGLContext.currentContext getValues:&rendererID forParameter:NSOpenGLContextParameterCurrentRendererID];
return (rendererID & kCGLRendererIDMatchingMask) == kCGLRendererGenericFloatID;
}
+
+void* cglContext(NSOpenGLContext *nsOpenGLContext)
+{
+ return [nsOpenGLContext CGLContextObj];
+}
diff --git a/src/core/net/client_cert_store_data.h b/src/core/net/client_cert_store_data.h
index e47a909e4..4976ac936 100644
--- a/src/core/net/client_cert_store_data.h
+++ b/src/core/net/client_cert_store_data.h
@@ -46,7 +46,7 @@
#if QT_CONFIG(ssl)
#include "base/memory/ref_counted.h"
-#include <QtCore/qvector.h>
+#include <QtCore/qlist.h>
#include <QtNetwork/qsslcertificate.h>
#include <QtNetwork/qsslkey.h>
@@ -71,7 +71,7 @@ struct ClientCertificateStoreData
void remove(const QSslCertificate &certificate);
void clear();
- QVector<Entry *> extraCerts;
+ QList<Entry *> extraCerts;
};
} // namespace QtWebEngineCore
diff --git a/src/core/net/cookie_monster_delegate_qt.h b/src/core/net/cookie_monster_delegate_qt.h
index 748e92da9..a8432e125 100644
--- a/src/core/net/cookie_monster_delegate_qt.h
+++ b/src/core/net/cookie_monster_delegate_qt.h
@@ -53,11 +53,6 @@
#include "qtwebenginecoreglobal_p.h"
-QT_WARNING_PUSH
-// For some reason adding -Wno-unused-parameter to QMAKE_CXXFLAGS has no
-// effect with clang, so use a pragma for these dirty chromium headers
-QT_WARNING_DISABLE_CLANG("-Wunused-parameter")
-
// We need to work around Chromium using 'signals' as a variable name in headers:
#ifdef signals
#define StAsH_signals signals
@@ -73,7 +68,6 @@ QT_WARNING_DISABLE_CLANG("-Wunused-parameter")
#define signals StAsH_signals
#undef StAsH_signals
#endif
-QT_WARNING_POP
#include <QNetworkCookie>
#include <QPointer>
diff --git a/src/core/ozone/gl_share_context_qt.cpp b/src/core/ozone/gl_share_context_qt.cpp
new file mode 100644
index 000000000..669652057
--- /dev/null
+++ b/src/core/ozone/gl_share_context_qt.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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 "gl_share_context_qt.h"
+#include <QtGui/qtgui-config.h>
+#include <qpa/qplatformnativeinterface.h>
+#include <QtGui/qopenglcontext_platform.h>
+#if defined(Q_OS_MACOS)
+#include "macos_context_type_helper.h"
+#endif
+#if QT_CONFIG(opengl)
+#include <QOpenGLContext>
+#include <QOpenGLExtraFunctions>
+#endif
+
+namespace QtWebEngineCore {
+
+QtShareGLContext::QtShareGLContext(QOpenGLContext *qtContext)
+ : gl::GLContext(nullptr), m_handle(nullptr)
+{
+#if QT_CONFIG(opengl)
+ QOpenGLContext *context = QOpenGLContext::globalShareContext();
+#if defined(Q_OS_MACOS)
+ auto *ctx = context->platformInterface<QPlatformInterface::QCocoaGLContext>();
+ if (ctx)
+ m_handle = cglContext(ctx->nativeContext());
+#endif
+#if defined(Q_OS_WIN)
+ auto *ctx = context->platformInterface<QPlatformInterface::QWGLContext>();
+#endif
+#if defined(Q_OS_LINUX)
+ auto *ctx = context->platformInterface<QPlatformInterface::QGLXContext>();
+#endif
+ if (ctx && !m_handle)
+ m_handle = (void *)ctx->nativeContext();
+#if QT_CONFIG(egl)
+ if (!m_handle) {
+ auto *ctx = context->platformInterface<QPlatformInterface::QEGLContext>();
+ if (ctx)
+ m_handle = (void *)ctx->nativeContext();
+ }
+#endif
+ if (!m_handle)
+ qFatal("Could not get handle for shared contex");
+#endif // QT_CONFIG(opengl)
+}
+
+unsigned int QtShareGLContext::CheckStickyGraphicsResetStatus()
+{
+#if QT_CONFIG(opengl)
+ if (QOpenGLContext *context = QOpenGLContext::globalShareContext()) {
+ if (context->format().testOption(QSurfaceFormat::ResetNotification))
+ return context->extraFunctions()->glGetGraphicsResetStatus();
+ }
+#endif
+ return 0 /*GL_NO_ERROR*/;
+}
+
+void ShareGroupQt::AboutToAddFirstContext()
+{
+#if QT_CONFIG(opengl)
+ // This currently has to be setup by ::main in all applications using QQuickWebEngineView with
+ // delegated rendering.
+ QOpenGLContext *shareContext = QOpenGLContext::globalShareContext();
+ if (!shareContext) {
+ qFatal("QWebEngine: OpenGL resource sharing is not set up in QtQuick. Please make sure to "
+ "call QtWebEngine::initialize() in your main() function before QCoreApplication is "
+ "created.");
+ }
+ m_shareContextQt = new QtShareGLContext(shareContext);
+#endif
+}
+
+} // namespace
diff --git a/src/core/compositor/stream_video_node.h b/src/core/ozone/gl_share_context_qt.h
index 9d937791f..26e884e10 100644
--- a/src/core/compositor/stream_video_node.h
+++ b/src/core/ozone/gl_share_context_qt.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
@@ -37,52 +37,63 @@
**
****************************************************************************/
-#ifndef STREAM_VIDEO_NODE_H
-#define STREAM_VIDEO_NODE_H
+#ifndef GL_SHARE_CONTEXT_QT
+#define GL_SHARE_CONTEXT_QT
-#include <QtQuick/qsgmaterial.h>
-#include <QtQuick/qsgnode.h>
+#include "ui/gl/gpu_timing.h"
+#include "ui/gl/gl_context.h"
+#include "ui/gl/gl_share_group.h"
+#include "qtwebenginecoreglobal.h"
-QT_FORWARD_DECLARE_CLASS(QSGTexture)
+QT_FORWARD_DECLARE_CLASS(QOpenGLContext)
namespace QtWebEngineCore {
-// These classes duplicate, QtQuick style, the logic of GLRenderer::DrawStreamVideoQuad.
-// Their behavior should stay as close as possible to GLRenderer.
-
-enum TextureTarget { ExternalTarget, RectangleTarget };
-
-class StreamVideoMaterial : public QSGMaterial
+class QtShareGLContext : public gl::GLContext
{
-public:
- StreamVideoMaterial(QSGTexture *texture, TextureTarget target);
- QSGMaterialType *type() const override
+public:
+ QtShareGLContext(QOpenGLContext *qtContext);
+ void *GetHandle() override { return m_handle; }
+ unsigned int CheckStickyGraphicsResetStatus() override;
+ // We don't care about the rest, this context shouldn't be used except for its handle.
+ bool Initialize(gl::GLSurface *, const gl::GLContextAttribs &) override
{
- static QSGMaterialType theType;
- return &theType;
+ Q_UNREACHABLE();
+ return false;
}
+ bool MakeCurrent(gl::GLSurface *) override
+ {
+ Q_UNREACHABLE();
+ return false;
+ }
+ void ReleaseCurrent(gl::GLSurface *) override { Q_UNREACHABLE(); }
+ bool IsCurrent(gl::GLSurface *) override
+ {
+ Q_UNREACHABLE();
+ return false;
+ }
+ scoped_refptr<gl::GPUTimingClient> CreateGPUTimingClient() override { return nullptr; }
+ const gfx::ExtensionSet &GetExtensions() override
+ {
+ static const gfx::ExtensionSet s_emptySet;
+ return s_emptySet;
+ }
+ void ResetExtensions() override {}
- QSGMaterialShader *createShader() const override;
-
- QSGTexture *m_texture;
- QMatrix4x4 m_texMatrix;
- TextureTarget m_target;
+private:
+ void *m_handle;
};
-class StreamVideoNode : public QSGGeometryNode
+class ShareGroupQt : public gl::GLShareGroup
{
+
public:
- StreamVideoNode(QSGTexture *texture, bool flip, TextureTarget target);
- void setRect(const QRectF &rect);
- void setTextureMatrix(const QMatrix4x4 &matrix);
+ gl::GLContext *GetContext() override { return m_shareContextQt.get(); }
+ void AboutToAddFirstContext() override;
private:
- QSGGeometry m_geometry;
- bool m_flip;
- StreamVideoMaterial *m_material;
+ scoped_refptr<QtShareGLContext> m_shareContextQt;
};
-
} // namespace
-
-#endif // STREAM_VIDEO_NODE_H
+#endif
diff --git a/src/core/ozone/surface_factory_qt.cpp b/src/core/ozone/surface_factory_qt.cpp
index 5420b4809..037641672 100644
--- a/src/core/ozone/surface_factory_qt.cpp
+++ b/src/core/ozone/surface_factory_qt.cpp
@@ -45,35 +45,43 @@
#endif
#include "ui/gl/gl_surface.h"
-#include <QGuiApplication>
#if defined(USE_OZONE)
#include "ozone/gl_ozone_egl_qt.h"
#include "ozone/surface_factory_qt.h"
#include "ui/gl/gl_surface.h"
+
+#include <QtGui/qtgui-config.h>
+#include <QOpenGLContext>
+
namespace QtWebEngineCore {
SurfaceFactoryQt::SurfaceFactoryQt()
{
- Q_ASSERT(qApp);
+ QOpenGLContext *context = QOpenGLContext::globalShareContext();
#if defined(USE_GLX)
- if (GLContextHelper::getGlXConfig()) {
- m_impl = gl::kGLImplementationDesktopGL;
+ auto *glx = context->platformInterface<QPlatformInterface::QGLXContext>();
+ if (glx) {
+ m_impl = { gl::kGLImplementationDesktopGL };
m_ozone.reset(new ui::GLOzoneGLXQt());
- } else
+ return;
+ }
#endif
- if (GLContextHelper::getEGLConfig()) {
- m_impl = gl::kGLImplementationEGLGLES2;
+#if QT_CONFIG(egl)
+ auto *egl = context->platformInterface<QPlatformInterface::QEGLContext>();
+ if (egl) {
+ m_impl = { gl::kGLImplementationDesktopGL, gl::kGLImplementationEGLGLES2 };
m_ozone.reset(new ui::GLOzoneEGLQt());
- } else {
- qFatal("No suitable graphics backend found\n");
+ return;
}
+#endif
+ qFatal("No suitable graphics backend found\n");
}
std::vector<gl::GLImplementation> SurfaceFactoryQt::GetAllowedGLImplementations()
{
- return { m_impl };
+ return m_impl;
}
ui::GLOzone* SurfaceFactoryQt::GetGLOzone(gl::GLImplementation implementation)
diff --git a/src/core/ozone/surface_factory_qt.h b/src/core/ozone/surface_factory_qt.h
index dee41d948..232f11e0f 100644
--- a/src/core/ozone/surface_factory_qt.h
+++ b/src/core/ozone/surface_factory_qt.h
@@ -53,7 +53,7 @@ public:
std::vector<gl::GLImplementation> GetAllowedGLImplementations() override;
ui::GLOzone* GetGLOzone(gl::GLImplementation implementation) override;
private:
- gl::GLImplementation m_impl;
+ std::vector<gl::GLImplementation> m_impl;
std::unique_ptr<ui::GLOzone> m_ozone;
};
diff --git a/src/core/pref_service_adapter.h b/src/core/pref_service_adapter.h
index 1c7c44a96..5c4c6e92a 100644
--- a/src/core/pref_service_adapter.h
+++ b/src/core/pref_service_adapter.h
@@ -44,11 +44,7 @@
#include "components/prefs/pref_service.h"
#include "qtwebenginecoreglobal_p.h"
-QT_BEGIN_NAMESPACE
-class QStringList;
-QT_END_NAMESPACE
-
-class ProfileAdapter;
+QT_FORWARD_DECLARE_CLASS(QStringList)
namespace QtWebEngineCore {
diff --git a/src/core/profile_adapter.h b/src/core/profile_adapter.h
index efd56e50e..f59768004 100644
--- a/src/core/profile_adapter.h
+++ b/src/core/profile_adapter.h
@@ -58,7 +58,6 @@
#include <QPointer>
#include <QScopedPointer>
#include <QString>
-#include <QVector>
#include "api/qwebengineclientcertificatestore.h"
#include "api/qwebenginecookiestore.h"
@@ -247,7 +246,7 @@ private:
QHash<QByteArray, QSharedPointer<UserNotificationController>> m_persistentNotifications;
QList<ProfileAdapterClient*> m_clients;
- QVector<WebContentsAdapterClient *> m_webContentsAdapterClients;
+ QList<WebContentsAdapterClient *> m_webContentsAdapterClients;
int m_httpCacheMaxSize;
QrcUrlSchemeHandler m_qrcHandler;
diff --git a/src/core/profile_adapter_client.h b/src/core/profile_adapter_client.h
index 394f92270..07c00044b 100644
--- a/src/core/profile_adapter_client.h
+++ b/src/core/profile_adapter_client.h
@@ -85,13 +85,6 @@ public:
MimeHtmlSaveFormat
};
- enum DownloadType {
- Attachment = 0,
- DownloadAttribute,
- UserRequested,
- SavePage
- };
-
// Keep in sync with content::DownloadInterruptReason
enum DownloadInterruptReason {
NoReason = 0,
@@ -136,7 +129,7 @@ public:
bool accepted;
bool paused;
bool done;
- int downloadType;
+ bool isSavePageDownload;
int downloadInterruptReason;
WebContentsAdapterClient *page;
QString suggestedFileName;
diff --git a/src/core/profile_qt.h b/src/core/profile_qt.h
index 59f5a8c21..df84136bc 100644
--- a/src/core/profile_qt.h
+++ b/src/core/profile_qt.h
@@ -48,9 +48,7 @@
#include "profile_io_data_qt.h"
#include <QtGlobal>
-QT_BEGIN_NAMESPACE
-class QStringList;
-QT_END_NAMESPACE
+QT_FORWARD_DECLARE_CLASS(QStringList)
class InMemoryPrefStore;
class PrefService;
diff --git a/src/core/render_view_context_menu_qt.cpp b/src/core/render_view_context_menu_qt.cpp
index 8fdae498c..47c8a6e32 100644
--- a/src/core/render_view_context_menu_qt.cpp
+++ b/src/core/render_view_context_menu_qt.cpp
@@ -39,6 +39,7 @@
#include <QtCore/QCoreApplication>
#include "render_view_context_menu_qt.h"
+#include "qwebenginecontextmenurequest.h"
namespace QtWebEngineCore {
@@ -74,8 +75,8 @@ namespace QtWebEngineCore {
return QCoreApplication::translate("RenderViewContextMenuQt", qUtf8Printable(names[menuItem]));
}
- RenderViewContextMenuQt::RenderViewContextMenuQt(const WebEngineContextMenuData &data)
- : m_contextData(data)
+ RenderViewContextMenuQt::RenderViewContextMenuQt(QWebEngineContextMenuRequest *request)
+ : m_contextData(request)
{
}
@@ -86,15 +87,17 @@ namespace QtWebEngineCore {
appendSeparatorItem();
}
- if (m_contextData.isEditable() && !m_contextData.spellCheckerSuggestions().isEmpty()) {
+ if (m_contextData->isContentEditable()
+ && !m_contextData->spellCheckerSuggestions().isEmpty()) {
appendSpellingSuggestionItems();
appendSeparatorItem();
}
- if (m_contextData.linkText().isEmpty() && !m_contextData.linkUrl().isValid() && !m_contextData.mediaUrl().isValid()) {
- if (m_contextData.isEditable())
+ if (m_contextData->linkText().isEmpty() && !m_contextData->filteredLinkUrl().isValid()
+ && !m_contextData->mediaUrl().isValid()) {
+ if (m_contextData->isContentEditable())
appendEditableItems();
- else if (!m_contextData.selectedText().isEmpty())
+ else if (!m_contextData->selectedText().isEmpty())
appendCopyItem();
else
appendPageItems();
@@ -102,27 +105,29 @@ namespace QtWebEngineCore {
appendPageItems();
}
- if (m_contextData.linkUrl().isValid() || !m_contextData.unfilteredLinkUrl().isEmpty() || !m_contextData.linkUrl().isEmpty())
+ if (m_contextData->filteredLinkUrl().isValid()
+ || !m_contextData->linkUrl().isEmpty()
+ || !m_contextData->filteredLinkUrl().isEmpty())
appendLinkItems();
- if (m_contextData.mediaUrl().isValid()) {
- switch (m_contextData.mediaType()) {
- case WebEngineContextMenuData::MediaTypeImage:
+ if (m_contextData->mediaUrl().isValid()) {
+ switch (m_contextData->mediaType()) {
+ case QWebEngineContextMenuRequest::MediaTypeImage:
appendSeparatorItem();
appendImageItems();
break;
- case WebEngineContextMenuData::MediaTypeCanvas:
+ case QWebEngineContextMenuRequest::MediaTypeCanvas:
Q_UNREACHABLE(); // mediaUrl is invalid for canvases
break;
- case WebEngineContextMenuData::MediaTypeAudio:
- case WebEngineContextMenuData::MediaTypeVideo:
+ case QWebEngineContextMenuRequest::MediaTypeAudio:
+ case QWebEngineContextMenuRequest::MediaTypeVideo:
appendSeparatorItem();
appendMediaItems();
break;
default:
break;
}
- } else if (m_contextData.mediaType() == WebEngineContextMenuData::MediaTypeCanvas) {
+ } else if (m_contextData->mediaType() == QWebEngineContextMenuRequest::MediaTypeCanvas) {
appendSeparatorItem();
appendCanvasItems();
}
@@ -160,7 +165,7 @@ namespace QtWebEngineCore {
addMenuItem(RenderViewContextMenuQt::Cut);
addMenuItem(RenderViewContextMenuQt::Copy);
addMenuItem(RenderViewContextMenuQt::Paste);
- if (m_contextData.misspelledWord().isEmpty()) {
+ if (m_contextData->misspelledWord().isEmpty()) {
addMenuItem(RenderViewContextMenuQt::PasteAndMatchStyle);
addMenuItem(RenderViewContextMenuQt::SelectAll);
}
@@ -190,7 +195,7 @@ namespace QtWebEngineCore {
void RenderViewContextMenuQt::appendMediaItems()
{
addMenuItem(RenderViewContextMenuQt::ToggleMediaLoop);
- if (m_contextData.mediaFlags() & QtWebEngineCore::WebEngineContextMenuData::MediaCanToggleControls)
+ if (m_contextData->mediaFlags() & QWebEngineContextMenuRequest::MediaCanToggleControls)
addMenuItem(RenderViewContextMenuQt::ToggleMediaControls);
addMenuItem(RenderViewContextMenuQt::DownloadMediaToDisk);
addMenuItem(RenderViewContextMenuQt::CopyMediaUrlToClipboard);
@@ -217,10 +222,8 @@ namespace QtWebEngineCore {
bool RenderViewContextMenuQt::canViewSource()
{
- return m_contextData.linkText().isEmpty()
- && !m_contextData.linkUrl().isValid()
- && !m_contextData.mediaUrl().isValid()
- && !m_contextData.isEditable()
- && m_contextData.selectedText().isEmpty();
+ return m_contextData->linkText().isEmpty() && !m_contextData->filteredLinkUrl().isValid()
+ && !m_contextData->mediaUrl().isValid() && !m_contextData->isContentEditable()
+ && m_contextData->selectedText().isEmpty();
}
}
diff --git a/src/core/render_view_context_menu_qt.h b/src/core/render_view_context_menu_qt.h
index e1ee301fc..f818ce200 100644
--- a/src/core/render_view_context_menu_qt.h
+++ b/src/core/render_view_context_menu_qt.h
@@ -53,6 +53,8 @@
#include "web_contents_adapter_client.h"
+QT_FORWARD_DECLARE_CLASS(QWebEngineContextMenuRequest)
+
namespace QtWebEngineCore {
class Q_WEBENGINECORE_PRIVATE_EXPORT RenderViewContextMenuQt
@@ -99,7 +101,7 @@ public:
static const QString getMenuItemName(RenderViewContextMenuQt::ContextMenuItem menuItem);
- RenderViewContextMenuQt(const WebEngineContextMenuData &data);
+ RenderViewContextMenuQt(QWebEngineContextMenuRequest *data);
void initMenu();
protected:
@@ -109,7 +111,7 @@ protected:
virtual void addMenuItem(ContextMenuItem menuItem) = 0;
virtual bool isMenuItemEnabled(ContextMenuItem menuItem) = 0;
- const WebEngineContextMenuData &m_contextData;
+ QWebEngineContextMenuRequest *m_contextData;
private:
void appendCanvasItems();
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index ef56e451d..9be6fac9a 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -42,12 +42,10 @@
#include "browser_accessibility_manager_qt.h"
#include "common/qt_messages.h"
-#include "compositor/compositor.h"
#include "qtwebenginecoreglobal_p.h"
#include "render_widget_host_view_qt_delegate.h"
-#include "touch_handle_drawable_client.h"
+#include "render_widget_host_view_qt_delegate_client.h"
#include "touch_selection_controller_client_qt.h"
-#include "touch_selection_menu_controller.h"
#include "type_conversion.h"
#include "web_contents_adapter.h"
#include "web_contents_adapter_client.h"
@@ -58,7 +56,6 @@
#include "components/viz/common/frame_sinks/begin_frame_source.h"
#include "components/viz/common/surfaces/frame_sink_id_allocator.h"
#include "components/viz/host/host_frame_sink_manager.h"
-#include "content/browser/compositor/surface_utils.h"
#include "content/browser/frame_host/frame_tree.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/browser/renderer_host/input/synthetic_gesture_target.h"
@@ -74,9 +71,7 @@
#include "ui/events/event.h"
#include "ui/events/gesture_detection/gesture_configuration.h"
#include "ui/events/gesture_detection/gesture_provider_config_helper.h"
-#include "ui/events/gesture_detection/motion_event.h"
#include "ui/gfx/image/image_skia.h"
-#include "ui/touch_selection/touch_selection_controller.h"
#if defined(USE_OZONE)
#include "ui/base/clipboard/scoped_clipboard_writer.h"
@@ -88,23 +83,10 @@
#include "ui/base/resource/resource_bundle.h"
#endif
-#include <private/qguiapplication_p.h>
-#include <qpa/qplatforminputcontext.h>
-#include <qpa/qplatformintegration.h>
-#include <QEvent>
-#include <QFocusEvent>
#include <QGuiApplication>
-#include <QInputMethodEvent>
-#include <QTextFormat>
-#include <QKeyEvent>
-#include <QMouseEvent>
#include <QPixmap>
#include <QScreen>
-#include <QStyleHints>
-#include <QVariant>
-#include <QWheelEvent>
#include <QWindow>
-#include <QtGui/private/qinputcontrol_p.h>
namespace QtWebEngineCore {
@@ -127,50 +109,6 @@ static inline ui::LatencyInfo CreateLatencyInfo(const blink::WebInputEvent& even
return latency_info;
}
-static inline Qt::InputMethodHints toQtInputMethodHints(ui::TextInputType inputType)
-{
- switch (inputType) {
- case ui::TEXT_INPUT_TYPE_TEXT:
- return Qt::ImhPreferLowercase;
- case ui::TEXT_INPUT_TYPE_SEARCH:
- return Qt::ImhPreferLowercase | Qt::ImhNoAutoUppercase;
- case ui::TEXT_INPUT_TYPE_PASSWORD:
- return Qt::ImhSensitiveData | Qt::ImhNoPredictiveText | Qt::ImhNoAutoUppercase | Qt::ImhHiddenText;
- case ui::TEXT_INPUT_TYPE_EMAIL:
- return Qt::ImhEmailCharactersOnly;
- case ui::TEXT_INPUT_TYPE_NUMBER:
- return Qt::ImhFormattedNumbersOnly;
- case ui::TEXT_INPUT_TYPE_TELEPHONE:
- return Qt::ImhDialableCharactersOnly;
- case ui::TEXT_INPUT_TYPE_URL:
- return Qt::ImhUrlCharactersOnly | Qt::ImhNoPredictiveText | Qt::ImhNoAutoUppercase;
- case ui::TEXT_INPUT_TYPE_DATE_TIME:
- case ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL:
- case ui::TEXT_INPUT_TYPE_DATE_TIME_FIELD:
- return Qt::ImhDate | Qt::ImhTime;
- case ui::TEXT_INPUT_TYPE_DATE:
- case ui::TEXT_INPUT_TYPE_MONTH:
- case ui::TEXT_INPUT_TYPE_WEEK:
- return Qt::ImhDate;
- case ui::TEXT_INPUT_TYPE_TIME:
- return Qt::ImhTime;
- case ui::TEXT_INPUT_TYPE_TEXT_AREA:
- case ui::TEXT_INPUT_TYPE_CONTENT_EDITABLE:
- return Qt::ImhMultiLine | Qt::ImhPreferLowercase;
- default:
- return Qt::ImhNone;
- }
-}
-
-static inline int firstAvailableId(const QMap<int, int> &map)
-{
- ui::BitSet32 usedIds;
- QMap<int, int>::const_iterator end = map.end();
- for (QMap<int, int>::const_iterator it = map.begin(); it != end; ++it)
- usedIds.mark_bit(it.value());
- return usedIds.first_unmarked_bit();
-}
-
static inline ui::GestureProvider::Config QtGestureProviderConfig() {
ui::GestureProvider::Config config = ui::GetGestureProviderConfig(ui::GestureProviderConfigType::CURRENT_PLATFORM);
// Causes an assert in CreateWebGestureEventFromGestureEventData and we don't need them in Qt.
@@ -180,154 +118,35 @@ static inline ui::GestureProvider::Config QtGestureProviderConfig() {
return config;
}
-static inline bool compareTouchPoints(const QTouchEvent::TouchPoint &lhs, const QTouchEvent::TouchPoint &rhs)
-{
- // TouchPointPressed < TouchPointMoved < TouchPointReleased
- return lhs.state() < rhs.state();
-}
-
-static inline bool isCommonTextEditShortcut(const QKeyEvent *ke)
-{
- return QInputControl::isCommonTextEditShortcut(ke);
-}
-
-static uint32_t s_eventId = 0;
-class MotionEventQt : public ui::MotionEvent {
-public:
- MotionEventQt(const QList<QTouchEvent::TouchPoint> &touchPoints, const base::TimeTicks &eventTime, Action action, const Qt::KeyboardModifiers modifiers, int index = -1)
- : touchPoints(touchPoints)
- , eventTime(eventTime)
- , action(action)
- , eventId(++s_eventId)
- , flags(flagsFromModifiers(modifiers))
- , index(index)
- {
- // ACTION_DOWN and ACTION_UP must be accesssed through pointer_index 0
- Q_ASSERT((action != Action::DOWN && action != Action::UP) || index == 0);
- }
-
- uint32_t GetUniqueEventId() const override { return eventId; }
- Action GetAction() const override { return action; }
- int GetActionIndex() const override { return index; }
- size_t GetPointerCount() const override { return touchPoints.size(); }
- int GetPointerId(size_t pointer_index) const override { return touchPoints.at(pointer_index).id(); }
- float GetX(size_t pointer_index) const override { return touchPoints.at(pointer_index).pos().x(); }
- float GetY(size_t pointer_index) const override { return touchPoints.at(pointer_index).pos().y(); }
- float GetRawX(size_t pointer_index) const override { return touchPoints.at(pointer_index).screenPos().x(); }
- float GetRawY(size_t pointer_index) const override { return touchPoints.at(pointer_index).screenPos().y(); }
- float GetTouchMajor(size_t pointer_index) const override
- {
- QSizeF diams = touchPoints.at(pointer_index).ellipseDiameters();
- return std::max(diams.height(), diams.width());
- }
- float GetTouchMinor(size_t pointer_index) const override
- {
- QSizeF diams = touchPoints.at(pointer_index).ellipseDiameters();
- return std::min(diams.height(), diams.width());
- }
- float GetOrientation(size_t pointer_index) const override
- {
- return 0;
- }
- int GetFlags() const override { return flags; }
- float GetPressure(size_t pointer_index) const override { return touchPoints.at(pointer_index).pressure(); }
- float GetTiltX(size_t pointer_index) const override { return 0; }
- float GetTiltY(size_t pointer_index) const override { return 0; }
- float GetTwist(size_t) const override { return 0; }
- float GetTangentialPressure(size_t) const override { return 0; }
- base::TimeTicks GetEventTime() const override { return eventTime; }
-
- size_t GetHistorySize() const override { return 0; }
- base::TimeTicks GetHistoricalEventTime(size_t historical_index) const override { return base::TimeTicks(); }
- float GetHistoricalTouchMajor(size_t pointer_index, size_t historical_index) const override { return 0; }
- float GetHistoricalX(size_t pointer_index, size_t historical_index) const override { return 0; }
- float GetHistoricalY(size_t pointer_index, size_t historical_index) const override { return 0; }
- ToolType GetToolType(size_t pointer_index) const override {
- return (touchPoints.at(pointer_index).flags() & QTouchEvent::TouchPoint::InfoFlag::Pen) ? ui::MotionEvent::ToolType::STYLUS
- : ui::MotionEvent::ToolType::FINGER;
- }
- int GetButtonState() const override { return 0; }
-
-private:
- QList<QTouchEvent::TouchPoint> touchPoints;
- base::TimeTicks eventTime;
- Action action;
- const uint32_t eventId;
- int flags;
- int index;
-};
-
-static content::ScreenInfo screenInfoFromQScreen(QScreen *screen)
-{
- content::ScreenInfo r;
- if (screen) {
- r.device_scale_factor = screen->devicePixelRatio();
- r.depth_per_component = 8;
- r.depth = screen->depth();
- r.is_monochrome = (r.depth == 1);
- r.rect = toGfx(screen->geometry());
- r.available_rect = toGfx(screen->availableGeometry());
- } else {
- r.device_scale_factor = qGuiApp->devicePixelRatio();
- }
- return r;
-}
-
RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget)
: content::RenderWidgetHostViewBase::RenderWidgetHostViewBase(widget)
, m_taskRunner(base::ThreadTaskRunnerHandle::Get())
, m_gestureProvider(QtGestureProviderConfig(), this)
- , m_sendMotionActionDown(false)
- , m_touchMotionStarted(false)
- , m_enableViz(features::IsVizDisplayCompositorEnabled())
- , m_visible(false)
- , m_needsBeginFrames(false)
- , m_loadVisuallyCommittedState(NotCommitted)
- , m_adapterClient(0)
- , m_imeInProgress(false)
- , m_receivedEmptyImeEvent(false)
- , m_isMouseLocked(false)
- , m_imState(0)
- , m_anchorPositionWithinSelection(-1)
- , m_cursorPositionWithinSelection(-1)
- , m_cursorPosition(0)
- , m_emptyPreviousSelection(true)
- , m_wheelAckPending(false)
- , m_mouseWheelPhaseHandler(this)
, m_frameSinkId(host()->GetFrameSinkId())
+ , m_delegateClient(new RenderWidgetHostViewQtDelegateClient(this))
{
if (GetTextInputManager())
GetTextInputManager()->AddObserver(this);
- const QPlatformInputContext *context = QGuiApplicationPrivate::platformIntegration()->inputContext();
- m_imeHasHiddenTextCapability = context && context->hasCapability(QPlatformInputContext::HiddenTextCapability);
-
- if (m_enableViz) {
- m_rootLayer.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
- m_rootLayer->SetColor(SK_ColorTRANSPARENT);
-
- m_delegatedFrameHost.reset(new content::DelegatedFrameHost(
- host()->GetFrameSinkId(),
- &m_delegatedFrameHostClient,
- true /* should_register_frame_sink_id */));
-
- content::ImageTransportFactory *imageTransportFactory = content::ImageTransportFactory::GetInstance();
- ui::ContextFactory *contextFactory = imageTransportFactory->GetContextFactory();
- ui::ContextFactoryPrivate *contextFactoryPrivate = imageTransportFactory->GetContextFactoryPrivate();
- m_uiCompositor.reset(new ui::Compositor(
- contextFactoryPrivate->AllocateFrameSinkId(),
- contextFactory,
- contextFactoryPrivate,
- m_taskRunner,
- false /* enable_pixel_canvas */));
- m_uiCompositor->SetAcceleratedWidget(gfx::kNullAcceleratedWidget); // null means offscreen
- m_uiCompositor->SetRootLayer(m_rootLayer.get());
-
- m_displayFrameSink = DisplayFrameSink::findOrCreate(m_uiCompositor->frame_sink_id());
- m_displayFrameSink->connect(this);
- } else {
- m_compositor.reset(new Compositor(widget));
- }
+ m_rootLayer.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
+ m_rootLayer->SetColor(SK_ColorTRANSPARENT);
+
+ m_delegatedFrameHost.reset(new content::DelegatedFrameHost(
+ host()->GetFrameSinkId(),
+ &m_delegatedFrameHostClient,
+ true /* should_register_frame_sink_id */));
+
+ content::ImageTransportFactory *imageTransportFactory = content::ImageTransportFactory::GetInstance();
+ ui::ContextFactory *contextFactory = imageTransportFactory->GetContextFactory();
+ ui::ContextFactoryPrivate *contextFactoryPrivate = imageTransportFactory->GetContextFactoryPrivate();
+ m_uiCompositor.reset(new ui::Compositor(
+ contextFactoryPrivate->AllocateFrameSinkId(),
+ contextFactory,
+ contextFactoryPrivate,
+ m_taskRunner,
+ false /* enable_pixel_canvas */));
+ m_uiCompositor->SetAcceleratedWidget(gfx::kNullAcceleratedWidget); // null means offscreen
+ m_uiCompositor->SetRootLayer(m_rootLayer.get());
if (host()->delegate() && host()->delegate()->GetInputEventRouter())
host()->delegate()->GetInputEventRouter()->AddFrameSinkIdOwner(GetFrameSinkId(), this);
@@ -341,7 +160,6 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget
host()->render_frame_metadata_provider()->ReportAllFrameSubmissionsForTesting(true);
- // May call SetNeedsBeginFrames
host()->SetView(this);
}
@@ -351,9 +169,6 @@ RenderWidgetHostViewQt::~RenderWidgetHostViewQt()
QObject::disconnect(m_adapterClientDestroyedConnection);
- if (m_enableViz)
- m_displayFrameSink->disconnect(this);
-
if (text_input_manager_)
text_input_manager_->RemoveObserver(this);
@@ -368,7 +183,7 @@ void RenderWidgetHostViewQt::setDelegate(RenderWidgetHostViewQtDelegate* delegat
m_deferredShow = false;
Show();
}
- visualPropertiesChanged();
+ delegateClient()->visualPropertiesChanged();
}
void RenderWidgetHostViewQt::setAdapterClient(WebContentsAdapterClient *adapterClient)
@@ -402,7 +217,7 @@ void RenderWidgetHostViewQt::SetSize(const gfx::Size &sizeInDips)
void RenderWidgetHostViewQt::SetBounds(const gfx::Rect &windowRectInDips)
{
- DCHECK(IsPopup());
+ DCHECK(isPopup());
m_delegate->move(toQt(windowRectInDips.origin()));
m_delegate->resize(windowRectInDips.width(), windowRectInDips.height());
}
@@ -439,7 +254,7 @@ content::BrowserAccessibilityManager* RenderWidgetHostViewQt::CreateBrowserAcces
// Set focus to the associated View component.
void RenderWidgetHostViewQt::Focus()
{
- if (!IsPopup())
+ if (!isPopup())
m_delegate->setKeyboardFocus();
host()->Focus();
}
@@ -456,25 +271,14 @@ bool RenderWidgetHostViewQt::IsMouseLocked()
bool RenderWidgetHostViewQt::IsSurfaceAvailableForCopy()
{
- if (m_enableViz)
- return m_delegatedFrameHost->CanCopyFromCompositingSurface();
- return true;
+ return m_delegatedFrameHost->CanCopyFromCompositingSurface();
}
void RenderWidgetHostViewQt::CopyFromSurface(const gfx::Rect &src_rect,
const gfx::Size &output_size,
base::OnceCallback<void(const SkBitmap &)> callback)
{
- if (m_enableViz) {
- m_delegatedFrameHost->CopyFromCompositingSurface(src_rect, output_size, std::move(callback));
- return;
- }
-
- QImage image;
- if (m_delegate->copySurface(toQt(src_rect), toQt(output_size), image))
- std::move(callback).Run(toSkBitmap(image));
- else
- std::move(callback).Run(SkBitmap());
+ m_delegatedFrameHost->CopyFromCompositingSurface(src_rect, output_size, std::move(callback));
}
void RenderWidgetHostViewQt::Show()
@@ -500,7 +304,7 @@ bool RenderWidgetHostViewQt::IsShowing()
// Retrieve the bounds of the View, in screen coordinates.
gfx::Rect RenderWidgetHostViewQt::GetViewBounds()
{
- return m_viewRectInDips;
+ return toGfx(delegateClient()->viewRectInDips());
}
void RenderWidgetHostViewQt::UpdateBackgroundColor()
@@ -510,12 +314,10 @@ void RenderWidgetHostViewQt::UpdateBackgroundColor()
m_delegate->setClearColor(toQt(color));
- if (m_enableViz) {
- bool opaque = SkColorGetA(color) == SK_AlphaOPAQUE;
- m_rootLayer->SetFillsBoundsOpaquely(opaque);
- m_rootLayer->SetColor(color);
- m_uiCompositor->SetBackgroundColor(color);
- }
+ bool opaque = SkColorGetA(color) == SK_AlphaOPAQUE;
+ m_rootLayer->SetFillsBoundsOpaquely(opaque);
+ m_rootLayer->SetColor(color);
+ m_uiCompositor->SetBackgroundColor(color);
content::RenderViewHost *rvh = content::RenderViewHost::From(host());
host()->Send(new RenderViewObserverQt_SetBackgroundColor(rvh->GetRoutingID(), color));
@@ -524,7 +326,7 @@ void RenderWidgetHostViewQt::UpdateBackgroundColor()
// Return value indicates whether the mouse is locked successfully or not.
bool RenderWidgetHostViewQt::LockMouse(bool)
{
- m_previousMousePosition = QCursor::pos();
+ delegateClient()->resetPreviousMousePosition();
m_delegate->lockMouse();
m_isMouseLocked = true;
qApp->setOverrideCursor(Qt::BlankCursor);
@@ -741,22 +543,14 @@ void RenderWidgetHostViewQt::DisplayTooltipText(const base::string16 &tooltip_te
void RenderWidgetHostViewQt::DidCreateNewRendererCompositorFrameSink(viz::mojom::CompositorFrameSinkClient *frameSinkClient)
{
- DCHECK(!m_enableViz);
- m_compositor->setFrameSinkClient(frameSinkClient);
+ // Not used with viz
+ NOTREACHED();
}
void RenderWidgetHostViewQt::SubmitCompositorFrame(const viz::LocalSurfaceId &local_surface_id, viz::CompositorFrame frame, base::Optional<viz::HitTestRegionList> hit_test_region_list)
{
- DCHECK(!m_enableViz);
-
- // Force to process swap messages
- uint32_t frame_token = frame.metadata.frame_token;
- if (frame_token)
- OnFrameTokenChangedForView(frame_token);
-
- m_compositor->submitFrame(
- std::move(frame),
- base::BindOnce(&RenderWidgetHostViewQt::callUpdate, base::Unretained(this)));
+ // Not used with viz
+ NOTREACHED();
}
void RenderWidgetHostViewQt::GetScreenInfo(content::ScreenInfo *results)
@@ -766,7 +560,7 @@ void RenderWidgetHostViewQt::GetScreenInfo(content::ScreenInfo *results)
gfx::Rect RenderWidgetHostViewQt::GetBoundsInRootWindow()
{
- return m_windowRectInDips;
+ return toGfx(delegateClient()->windowRectInDips());
}
void RenderWidgetHostViewQt::OnUpdateTextInputStateCalled(content::TextInputManager *text_input_manager, RenderWidgetHostViewBase *updated_view, bool did_update_state)
@@ -788,16 +582,18 @@ void RenderWidgetHostViewQt::OnUpdateTextInputStateCalled(content::TextInputMana
#else
m_delegate->setInputMethodHints(toQtInputMethodHints(getTextInputType()) | Qt::ImhNoPredictiveText);
#endif
- m_surroundingText = toQt(state->value);
+ QString surroundingText = toQt(state->value);
// Remove IME composition text from the surrounding text
if (state->composition_start != -1 && state->composition_end != -1)
- m_surroundingText.remove(state->composition_start, state->composition_end - state->composition_start);
+ surroundingText.remove(state->composition_start,
+ state->composition_end - state->composition_start);
+ delegateClient()->setSurroundingText(surroundingText);
// In case of text selection, the update is expected in RenderWidgetHostViewQt::selectionChanged().
if (GetSelectedText().empty()) {
// At this point it is unknown whether the text input state has been updated due to a text selection.
// Keep the cursor position updated for cursor movements too.
- m_cursorPosition = state->selection_start;
+ delegateClient()->setCursorPosition(state->selection_start);
m_delegate->inputMethodStateChanged(type != ui::TEXT_INPUT_TYPE_NONE, type == ui::TEXT_INPUT_TYPE_PASSWORD);
}
@@ -807,14 +603,14 @@ void RenderWidgetHostViewQt::OnUpdateTextInputStateCalled(content::TextInputMana
}
// Ignore selection change triggered by ime composition unless it clears an actual text selection
- if (state->composition_start != -1 && m_emptyPreviousSelection) {
+ if (state->composition_start != -1 && delegateClient()->isPreviousSelectionEmpty()) {
m_imState = 0;
return;
}
m_imState |= ImStateFlags::TextInputStateUpdated;
if (m_imState == ImStateFlags::AllFlags)
- selectionChanged();
+ delegateClient()->selectionChanged();
}
void RenderWidgetHostViewQt::OnSelectionBoundsChanged(content::TextInputManager *text_input_manager, RenderWidgetHostViewBase *updated_view)
@@ -825,7 +621,7 @@ void RenderWidgetHostViewQt::OnSelectionBoundsChanged(content::TextInputManager
m_imState |= ImStateFlags::TextSelectionBoundsUpdated;
if (m_imState == ImStateFlags::AllFlags
|| (m_imState == ImStateFlags::TextSelectionFlags && getTextInputType() == ui::TEXT_INPUT_TYPE_NONE)) {
- selectionChanged();
+ delegateClient()->selectionChanged();
}
}
@@ -849,82 +645,10 @@ void RenderWidgetHostViewQt::OnTextSelectionChanged(content::TextInputManager *t
m_imState |= ImStateFlags::TextSelectionUpdated;
if (m_imState == ImStateFlags::AllFlags
|| (m_imState == ImStateFlags::TextSelectionFlags && getTextInputType() == ui::TEXT_INPUT_TYPE_NONE)) {
- selectionChanged();
+ delegateClient()->selectionChanged();
}
}
-void RenderWidgetHostViewQt::selectionChanged()
-{
- // Reset input manager state
- m_imState = 0;
- ui::TextInputType type = getTextInputType();
-
- // Handle text selection out of an input field
- if (type == ui::TEXT_INPUT_TYPE_NONE) {
- if (GetSelectedText().empty() && m_emptyPreviousSelection)
- return;
-
- // Reset position values to emit selectionChanged signal when clearing text selection
- // by clicking into an input field. These values are intended to be used by inputMethodQuery
- // so they are not expected to be valid when selection is out of an input field.
- m_anchorPositionWithinSelection = -1;
- m_cursorPositionWithinSelection = -1;
-
- m_emptyPreviousSelection = GetSelectedText().empty();
- m_adapterClient->selectionChanged();
- return;
- }
-
- if (GetSelectedText().empty()) {
- // RenderWidgetHostViewQt::OnUpdateTextInputStateCalled() does not update the cursor position
- // if the selection is cleared because TextInputState changes before the TextSelection change.
- Q_ASSERT(text_input_manager_->GetTextInputState());
- m_cursorPosition = text_input_manager_->GetTextInputState()->selection_start;
- m_delegate->inputMethodStateChanged(true /*editorVisible*/, type == ui::TEXT_INPUT_TYPE_PASSWORD);
-
- m_anchorPositionWithinSelection = m_cursorPosition;
- m_cursorPositionWithinSelection = m_cursorPosition;
-
- if (!m_emptyPreviousSelection) {
- m_emptyPreviousSelection = true;
- m_adapterClient->selectionChanged();
- }
-
- return;
- }
-
- const content::TextInputManager::TextSelection *selection = text_input_manager_->GetTextSelection();
- if (!selection)
- return;
-
- if (!selection->range().IsValid())
- return;
-
- int newAnchorPositionWithinSelection = 0;
- int newCursorPositionWithinSelection = 0;
-
- if (text_input_manager_->GetSelectionRegion()->anchor.type() == gfx::SelectionBound::RIGHT) {
- newAnchorPositionWithinSelection = selection->range().GetMax() - selection->offset();
- newCursorPositionWithinSelection = selection->range().GetMin() - selection->offset();
- } else {
- newAnchorPositionWithinSelection = selection->range().GetMin() - selection->offset();
- newCursorPositionWithinSelection = selection->range().GetMax() - selection->offset();
- }
-
- if (m_anchorPositionWithinSelection == newAnchorPositionWithinSelection && m_cursorPositionWithinSelection == newCursorPositionWithinSelection)
- return;
-
- m_anchorPositionWithinSelection = newAnchorPositionWithinSelection;
- m_cursorPositionWithinSelection = newCursorPositionWithinSelection;
-
- if (!selection->selected_text().empty())
- m_cursorPosition = newCursorPositionWithinSelection;
-
- m_emptyPreviousSelection = selection->selected_text().empty();
- m_delegate->inputMethodStateChanged(true /*editorVisible*/, type == ui::TEXT_INPUT_TYPE_PASSWORD);
- m_adapterClient->selectionChanged();
-}
-
void RenderWidgetHostViewQt::OnGestureEvent(const ui::GestureEventData& gesture)
{
if ((gesture.type() == ui::ET_GESTURE_PINCH_BEGIN
@@ -978,270 +702,38 @@ void RenderWidgetHostViewQt::OnDidUpdateVisualPropertiesComplete(const cc::Rende
void RenderWidgetHostViewQt::OnDidFirstVisuallyNonEmptyPaint()
{
- if (m_loadVisuallyCommittedState == NotCommitted) {
- m_loadVisuallyCommittedState = DidFirstVisuallyNonEmptyPaint;
- } else if (m_loadVisuallyCommittedState == DidFirstCompositorFrameSwap) {
- m_adapterClient->loadVisuallyCommitted();
- m_loadVisuallyCommittedState = NotCommitted;
- }
+ m_adapterClient->didFirstVisuallyNonEmptyPaint();
}
-void RenderWidgetHostViewQt::scheduleUpdate()
+Compositor::Id RenderWidgetHostViewQt::compositorId()
{
- DCHECK(m_enableViz);
- m_taskRunner->PostTask(
- FROM_HERE,
- base::BindOnce(&RenderWidgetHostViewQt::callUpdate, m_weakPtrFactory.GetWeakPtr()));
-}
-
-void RenderWidgetHostViewQt::callUpdate()
-{
- m_delegate->update();
-
- if (m_loadVisuallyCommittedState == NotCommitted) {
- m_loadVisuallyCommittedState = DidFirstCompositorFrameSwap;
- } else if (m_loadVisuallyCommittedState == DidFirstVisuallyNonEmptyPaint) {
- m_adapterClient->loadVisuallyCommitted();
- m_loadVisuallyCommittedState = NotCommitted;
- }
-}
-
-QSGNode *RenderWidgetHostViewQt::updatePaintNode(QSGNode *oldNode)
-{
- if (m_enableViz)
- return m_displayFrameSink->updatePaintNode(oldNode, m_delegate.get());
- return m_compositor->updatePaintNode(oldNode, m_delegate.get());
+ return m_uiCompositor->frame_sink_id();
}
void RenderWidgetHostViewQt::notifyShown()
{
- if (m_enableViz) {
- // Handle possible frame eviction:
- if (!m_dfhLocalSurfaceIdAllocator.HasValidLocalSurfaceIdAllocation())
- m_dfhLocalSurfaceIdAllocator.GenerateId();
- if (m_visible)
- return;
- m_visible = true;
- }
+ // Handle possible frame eviction:
+ if (!m_dfhLocalSurfaceIdAllocator.HasValidLocalSurfaceIdAllocation())
+ m_dfhLocalSurfaceIdAllocator.GenerateId();
+ if (m_visible)
+ return;
+ m_visible = true;
host()->WasShown(base::nullopt);
- if (m_enableViz) {
- m_delegatedFrameHost->AttachToCompositor(m_uiCompositor.get());
- m_delegatedFrameHost->WasShown(GetLocalSurfaceIdAllocation().local_surface_id(),
- m_viewRectInDips.size(),
- base::nullopt);
- }
+ m_delegatedFrameHost->AttachToCompositor(m_uiCompositor.get());
+ m_delegatedFrameHost->WasShown(GetLocalSurfaceIdAllocation().local_surface_id(),
+ toGfx(delegateClient()->viewRectInDips().size()), base::nullopt);
}
void RenderWidgetHostViewQt::notifyHidden()
{
- if (m_enableViz) {
- if (!m_visible)
- return;
- m_visible = false;
- host()->WasHidden();
- m_delegatedFrameHost->WasHidden(content::DelegatedFrameHost::HiddenCause::kOther);
- m_delegatedFrameHost->DetachFromCompositor();
- } else {
- host()->WasHidden();
- }
-}
-
-void RenderWidgetHostViewQt::visualPropertiesChanged()
-{
- if (!m_delegate)
+ if (!m_visible)
return;
-
- gfx::Rect oldViewRect = m_viewRectInDips;
- m_viewRectInDips = toGfx(m_delegate->viewGeometry().toAlignedRect());
-
- gfx::Rect oldWindowRect = m_windowRectInDips;
- m_windowRectInDips = toGfx(m_delegate->windowGeometry());
-
- QWindow *window = m_delegate->window();
- content::ScreenInfo oldScreenInfo = m_screenInfo;
- m_screenInfo = screenInfoFromQScreen(window ? window->screen() : nullptr);
-
- if (m_viewRectInDips != oldViewRect || m_windowRectInDips != oldWindowRect)
- host()->SendScreenRects();
-
- if (m_viewRectInDips.size() != oldViewRect.size() || m_screenInfo != oldScreenInfo)
- synchronizeVisualProperties(base::nullopt);
-}
-
-bool RenderWidgetHostViewQt::forwardEvent(QEvent *event)
-{
- Q_ASSERT(host()->GetView());
-
- switch (event->type()) {
- case QEvent::ShortcutOverride: {
- QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
-
- auto acceptKeyOutOfInputField = [](QKeyEvent *keyEvent) -> bool {
-#ifdef Q_OS_MACOS
- // Check if a shortcut is registered for this key sequence.
- QKeySequence sequence = QKeySequence (
- (keyEvent->modifiers() | keyEvent->key()) &
- ~(Qt::KeypadModifier | Qt::GroupSwitchModifier));
- if (QGuiApplicationPrivate::instance()->shortcutMap.hasShortcutForKeySequence(sequence))
- return false;
-
- // The following shortcuts are handled out of input field too but
- // disabled on macOS to let the blinking menu handling to the
- // embedder application (see kKeyboardCodeKeyDownEntries in
- // third_party/WebKit/Source/core/editing/EditingBehavior.cpp).
- // Let them pass on macOS to generate the corresponding edit command.
- return keyEvent->matches(QKeySequence::Copy)
- || keyEvent->matches(QKeySequence::Paste)
- || keyEvent->matches(QKeySequence::Cut)
- || keyEvent->matches(QKeySequence::SelectAll);
-#else
- return false;
-#endif
- };
-
- if (!inputMethodQuery(Qt::ImEnabled).toBool() && !(inputMethodQuery(Qt::ImHints).toInt() & Qt::ImhHiddenText) && !acceptKeyOutOfInputField(keyEvent))
- return false;
-
- Q_ASSERT(m_editCommand.empty());
- if (WebEventFactory::getEditCommand(keyEvent, &m_editCommand)
- || isCommonTextEditShortcut(keyEvent)) {
- event->accept();
- return true;
- }
-
- return false;
- }
- case QEvent::MouseButtonPress:
- Focus();
- Q_FALLTHROUGH();
- case QEvent::MouseButtonRelease:
- case QEvent::MouseMove:
- // Skip second MouseMove event when a window is being adopted, so that Chromium
- // can properly handle further move events.
- // Also make sure the adapter client exists to prevent a null pointer dereference,
- // because it's possible for a QWebEnginePagePrivate (adapter) instance to be destroyed,
- // and then the OS (observed on Windows) might still send mouse move events to a still
- // existing popup RWHVQDW instance.
- if (m_adapterClient && m_adapterClient->isBeingAdopted())
- return false;
- handleMouseEvent(static_cast<QMouseEvent*>(event));
- break;
- case QEvent::KeyPress:
- case QEvent::KeyRelease:
- handleKeyEvent(static_cast<QKeyEvent*>(event));
- break;
- case QEvent::Wheel:
- handleWheelEvent(static_cast<QWheelEvent*>(event));
- break;
- case QEvent::TouchBegin:
- Focus();
- Q_FALLTHROUGH();
- case QEvent::TouchUpdate:
- case QEvent::TouchEnd:
- case QEvent::TouchCancel:
- handleTouchEvent(static_cast<QTouchEvent*>(event));
- break;
-#if QT_CONFIG(tabletevent)
- case QEvent::TabletPress:
- Focus();
- Q_FALLTHROUGH();
- case QEvent::TabletRelease:
- case QEvent::TabletMove:
- handleTabletEvent(static_cast<QTabletEvent*>(event));
- break;
-#endif
-#ifndef QT_NO_GESTURES
- case QEvent::NativeGesture:
- handleGestureEvent(static_cast<QNativeGestureEvent *>(event));
- break;
-#endif // QT_NO_GESTURES
- case QEvent::HoverMove:
- handleHoverEvent(static_cast<QHoverEvent*>(event));
- break;
- case QEvent::FocusIn:
- case QEvent::FocusOut:
- handleFocusEvent(static_cast<QFocusEvent*>(event));
- break;
- case QEvent::InputMethod:
- handleInputMethodEvent(static_cast<QInputMethodEvent*>(event));
- break;
- case QEvent::InputMethodQuery:
- handleInputMethodQueryEvent(static_cast<QInputMethodQueryEvent*>(event));
- break;
- case QEvent::Leave:
-#ifdef Q_OS_WIN
- if (m_mouseButtonPressed > 0)
- return false;
-#endif
- case QEvent::HoverLeave:
- host()->ForwardMouseEvent(WebEventFactory::toWebMouseEvent(event));
- break;
- default:
- return false;
- }
- return true;
-}
-
-QVariant RenderWidgetHostViewQt::inputMethodQuery(Qt::InputMethodQuery query)
-{
- switch (query) {
- case Qt::ImEnabled: {
- ui::TextInputType type = getTextInputType();
- bool editorVisible = type != ui::TEXT_INPUT_TYPE_NONE;
- // IME manager should disable composition on input fields with ImhHiddenText hint if supported
- if (m_imeHasHiddenTextCapability)
- return QVariant(editorVisible);
-
- bool passwordInput = type == ui::TEXT_INPUT_TYPE_PASSWORD;
- return QVariant(editorVisible && !passwordInput);
- }
- case Qt::ImFont:
- // TODO: Implement this
- return QVariant();
- case Qt::ImCursorRectangle: {
- if (text_input_manager_) {
- if (auto *region = text_input_manager_->GetSelectionRegion()) {
- if (region->focus.GetHeight() > 0) {
- gfx::Rect caretRect = gfx::RectBetweenSelectionBounds(region->anchor, region->focus);
- if (caretRect.width() == 0)
- caretRect.set_width(1); // IME API on Windows expects a width > 0
- return toQt(caretRect);
- }
- }
- }
- return QVariant();
- }
- case Qt::ImCursorPosition:
- return m_cursorPosition;
- case Qt::ImAnchorPosition:
- return GetSelectedText().empty() ? m_cursorPosition : m_anchorPositionWithinSelection;
- case Qt::ImSurroundingText:
- return m_surroundingText;
- case Qt::ImCurrentSelection:
- return toQt(GetSelectedText());
- case Qt::ImMaximumTextLength:
- // TODO: Implement this
- return QVariant(); // No limit.
- case Qt::ImHints:
-#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
- return int(toQtInputMethodHints(getTextInputType()) | Qt::ImhNoPredictiveText | Qt::ImhNoTextHandles | Qt::ImhNoEditMenu);
-#else
- return int(toQtInputMethodHints(getTextInputType()) | Qt::ImhNoPredictiveText);
-#endif
- default:
- return QVariant();
- }
-}
-
-void RenderWidgetHostViewQt::closePopup()
-{
- // We notify the popup to be closed by telling it that it lost focus. WebKit does the rest
- // (hiding the widget and automatic memory cleanup via
- // RenderWidget::CloseWidgetSoon() -> RenderWidgetHostImpl::ShutdownAndDestroyWidget(true).
- host()->SetActive(false);
- host()->LostFocus();
+ m_visible = false;
+ host()->WasHidden();
+ m_delegatedFrameHost->WasHidden(content::DelegatedFrameHost::HiddenCause::kOther);
+ m_delegatedFrameHost->DetachFromCompositor();
}
void RenderWidgetHostViewQt::ProcessAckedTouchEvent(const content::TouchEventWithLatencyInfo &touch, content::InputEventAckState ack_result) {
@@ -1262,277 +754,46 @@ void RenderWidgetHostViewQt::processMotionEvent(const ui::MotionEvent &motionEve
host()->ForwardTouchEventWithLatencyInfo(touchEvent, CreateLatencyInfo(touchEvent));
}
-QList<QTouchEvent::TouchPoint> RenderWidgetHostViewQt::mapTouchPointIds(const QList<QTouchEvent::TouchPoint> &inputPoints)
-{
- QList<QTouchEvent::TouchPoint> outputPoints = inputPoints;
- for (int i = 0; i < outputPoints.size(); ++i) {
- QTouchEvent::TouchPoint &point = outputPoints[i];
-
- int qtId = point.id();
- QMap<int, int>::const_iterator it = m_touchIdMapping.find(qtId);
- if (it == m_touchIdMapping.end())
- it = m_touchIdMapping.insert(qtId, firstAvailableId(m_touchIdMapping));
- point.setId(it.value());
-
- if (point.state() == Qt::TouchPointReleased)
- m_touchIdMapping.remove(qtId);
- }
-
- return outputPoints;
-}
-
-bool RenderWidgetHostViewQt::IsPopup() const
+bool RenderWidgetHostViewQt::isPopup() const
{
return widget_type_ == content::WidgetType::kPopup;
}
-void RenderWidgetHostViewQt::handleMouseEvent(QMouseEvent* event)
+bool RenderWidgetHostViewQt::updateScreenInfo()
{
- if (event->type() == QEvent::MouseButtonPress)
- m_mouseButtonPressed++;
- if (event->type() == QEvent::MouseButtonRelease)
- m_mouseButtonPressed--;
-
- // Don't forward mouse events synthesized by the system, which are caused by genuine touch
- // events. Chromium would then process for e.g. a mouse click handler twice, once due to the
- // system synthesized mouse event, and another time due to a touch-to-gesture-to-mouse
- // transformation done by Chromium.
- if (event->source() == Qt::MouseEventSynthesizedBySystem)
- return;
- handlePointerEvent<QMouseEvent>(event);
-}
-
-void RenderWidgetHostViewQt::handleKeyEvent(QKeyEvent *ev)
-{
- if (IsMouseLocked() && ev->key() == Qt::Key_Escape && ev->type() == QEvent::KeyRelease)
- UnlockMouse();
-
- if (m_receivedEmptyImeEvent) {
- // IME composition was not finished with a valid commit string.
- // We're getting the composition result in a key event.
- if (ev->key() != 0) {
- // The key event is not a result of an IME composition. Cancel IME.
- host()->ImeCancelComposition();
- m_receivedEmptyImeEvent = false;
- } else {
- if (ev->type() == QEvent::KeyRelease) {
- host()->ImeCommitText(toString16(ev->text()),
- std::vector<ui::ImeTextSpan>(),
- gfx::Range::InvalidRange(),
- 0);
- m_receivedEmptyImeEvent = false;
- m_imeInProgress = false;
- }
- return;
- }
- }
-
- // Ignore autorepeating KeyRelease events so that the generated web events
- // conform to the spec, which requires autorepeat to result in a sequence of
- // keypress events and only one final keyup event:
- // https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Auto-repeat_handling
- // https://w3c.github.io/uievents/#dom-keyboardevent-repeat
- if (ev->type() == QEvent::KeyRelease && ev->isAutoRepeat())
- return;
-
- content::NativeWebKeyboardEvent webEvent = WebEventFactory::toWebKeyboardEvent(ev);
- if (webEvent.GetType() == blink::WebInputEvent::kRawKeyDown && !m_editCommand.empty()) {
- ui::LatencyInfo latency;
- latency.set_source_event_type(ui::SourceEventType::KEY_PRESS);
- content::EditCommands commands;
- commands.emplace_back(m_editCommand, "");
- m_editCommand.clear();
- host()->ForwardKeyboardEventWithCommands(webEvent, latency, &commands, nullptr);
- return;
- }
-
- bool keyDownTextInsertion = webEvent.GetType() == blink::WebInputEvent::kRawKeyDown && webEvent.text[0];
- webEvent.skip_in_browser = keyDownTextInsertion;
- host()->ForwardKeyboardEvent(webEvent);
-
- if (keyDownTextInsertion) {
- // Blink won't consume the RawKeyDown, but rather the Char event in this case.
- // The RawKeyDown is skipped on the way back (see above).
- // The same os_event will be set on both NativeWebKeyboardEvents.
- webEvent.skip_in_browser = false;
- webEvent.SetType(blink::WebInputEvent::kChar);
- host()->ForwardKeyboardEvent(webEvent);
- }
-}
-
-void RenderWidgetHostViewQt::handleInputMethodEvent(QInputMethodEvent *ev)
-{
- // Reset input manager state
- m_imState = 0;
-
- if (!host())
- return;
-
- QString commitString = ev->commitString();
- QString preeditString = ev->preeditString();
-
- int cursorPositionInPreeditString = -1;
- gfx::Range selectionRange = gfx::Range::InvalidRange();
-
- const QList<QInputMethodEvent::Attribute> &attributes = ev->attributes();
- std::vector<ui::ImeTextSpan> underlines;
- bool hasSelection = false;
-
- for (const auto &attribute : attributes) {
- switch (attribute.type) {
- case QInputMethodEvent::TextFormat: {
- if (preeditString.isEmpty())
- break;
-
- int start = qMin(attribute.start, (attribute.start + attribute.length));
- int end = qMax(attribute.start, (attribute.start + attribute.length));
-
- // Blink does not support negative position values. Adjust start and end positions
- // to non-negative values.
- if (start < 0) {
- start = 0;
- end = qMax(0, start + end);
- }
-
- underlines.push_back(ui::ImeTextSpan(ui::ImeTextSpan::Type::kComposition, start, end, ui::ImeTextSpan::Thickness::kThin, SK_ColorTRANSPARENT));
-
- QTextCharFormat format = qvariant_cast<QTextFormat>(attribute.value).toCharFormat();
- if (format.underlineStyle() != QTextCharFormat::NoUnderline)
- underlines.back().underline_color = toSk(format.underlineColor());
-
- break;
- }
- case QInputMethodEvent::Cursor:
- // Always set the position of the cursor, even if it's marked invisible by Qt, otherwise
- // there is no way the user will know which part of the composition string will be
- // changed, when performing an IME-specific action (like selecting a different word
- // suggestion).
- cursorPositionInPreeditString = attribute.start;
- break;
- case QInputMethodEvent::Selection:
- hasSelection = true;
-
- // Cancel IME composition
- if (preeditString.isEmpty() && attribute.start + attribute.length == 0) {
- selectionRange.set_start(0);
- selectionRange.set_end(0);
- break;
- }
-
- selectionRange.set_start(qMin(attribute.start, (attribute.start + attribute.length)));
- selectionRange.set_end(qMax(attribute.start, (attribute.start + attribute.length)));
- break;
- default:
- break;
- }
- }
-
- if (!selectionRange.IsValid()) {
- // We did not receive a valid selection range, hence the range is going to mark the
- // cursor position.
- int newCursorPosition =
- (cursorPositionInPreeditString < 0) ? preeditString.length()
- : cursorPositionInPreeditString;
- selectionRange.set_start(newCursorPosition);
- selectionRange.set_end(newCursorPosition);
- }
-
- if (hasSelection) {
- content::mojom::FrameInputHandler *frameInputHandler = getFrameInputHandler();
- if (frameInputHandler)
- frameInputHandler->SetEditableSelectionOffsets(selectionRange.start(), selectionRange.end());
- }
-
- int replacementLength = ev->replacementLength();
- gfx::Range replacementRange = gfx::Range::InvalidRange();
-
- if (replacementLength > 0)
- {
- int replacementStart = ev->replacementStart() < 0 ? m_cursorPosition + ev->replacementStart() : ev->replacementStart();
- if (replacementStart >= 0 && replacementStart < m_surroundingText.length())
- replacementRange = gfx::Range(replacementStart, replacementStart + replacementLength);
- }
-
- // There are so-far two known cases, when an empty QInputMethodEvent is received.
- // First one happens when backspace is used to remove the last character in the pre-edit
- // string, thus signaling the end of the composition.
- // The second one happens (on Windows) when a Korean char gets composed, but instead of
- // the event having a commit string, both strings are empty, and the actual char is received
- // as a QKeyEvent after the QInputMethodEvent is processed.
- // In lieu of the second case, we can't simply cancel the composition on an empty event,
- // and then add the Korean char when QKeyEvent is received, because that leads to text
- // flickering in the textarea (or any other element).
- // Instead we postpone the processing of the empty QInputMethodEvent by posting it
- // to the same focused object, and cancelling the composition on the next event loop tick.
- if (commitString.isEmpty() && preeditString.isEmpty() && replacementLength == 0) {
- if (!m_receivedEmptyImeEvent && m_imeInProgress && !hasSelection) {
- m_receivedEmptyImeEvent = true;
- QInputMethodEvent *eventCopy = new QInputMethodEvent(*ev);
- QGuiApplication::postEvent(qApp->focusObject(), eventCopy);
- } else {
- m_receivedEmptyImeEvent = false;
- if (m_imeInProgress) {
- m_imeInProgress = false;
- host()->ImeCancelComposition();
- }
- }
-
- return;
- }
-
- m_receivedEmptyImeEvent = false;
+ content::ScreenInfo oldScreenInfo = m_screenInfo;
+ QScreen *screen = m_delegate->window() ? m_delegate->window()->screen() : nullptr;
- // Finish compostion: insert or erase text.
- if (!commitString.isEmpty() || replacementLength > 0) {
- host()->ImeCommitText(toString16(commitString),
- underlines,
- replacementRange,
- 0);
- m_imeInProgress = false;
+ if (screen) {
+ m_screenInfo.device_scale_factor = screen->devicePixelRatio();
+ m_screenInfo.depth_per_component = 8;
+ m_screenInfo.depth = screen->depth();
+ m_screenInfo.is_monochrome = (m_screenInfo.depth == 1);
+ m_screenInfo.rect = toGfx(screen->geometry());
+ m_screenInfo.available_rect = toGfx(screen->availableGeometry());
+ } else {
+ m_screenInfo.device_scale_factor = qGuiApp->devicePixelRatio();
}
- // Update or start new composition.
- // Be aware of that, we might get a commit string and a pre-edit string in a single event and
- // this means a new composition.
- if (!preeditString.isEmpty()) {
- host()->ImeSetComposition(toString16(preeditString),
- underlines,
- replacementRange,
- selectionRange.start(),
- selectionRange.end());
- m_imeInProgress = true;
- }
+ return (m_screenInfo != oldScreenInfo);
}
-void RenderWidgetHostViewQt::handleInputMethodQueryEvent(QInputMethodQueryEvent *ev)
-{
- Qt::InputMethodQueries queries = ev->queries();
- for (uint i = 0; i < 32; ++i) {
- Qt::InputMethodQuery query = (Qt::InputMethodQuery)(int)(queries & (1<<i));
- if (query) {
- QVariant v = inputMethodQuery(query);
- ev->setValue(query, v);
- }
- }
- ev->accept();
-}
-
-void RenderWidgetHostViewQt::handleWheelEvent(QWheelEvent *ev)
+void RenderWidgetHostViewQt::handleWheelEvent(QWheelEvent *event)
{
if (!m_wheelAckPending) {
Q_ASSERT(m_pendingWheelEvents.isEmpty());
- blink::WebMouseWheelEvent webEvent = WebEventFactory::toWebWheelEvent(ev);
+ blink::WebMouseWheelEvent webEvent = WebEventFactory::toWebWheelEvent(event);
m_wheelAckPending = (webEvent.phase != blink::WebMouseWheelEvent::kPhaseEnded);
- m_mouseWheelPhaseHandler.AddPhaseIfNeededAndScheduleEndEvent(webEvent, false);
+ GetMouseWheelPhaseHandler()->AddPhaseIfNeededAndScheduleEndEvent(webEvent, false);
host()->ForwardWheelEvent(webEvent);
return;
}
if (!m_pendingWheelEvents.isEmpty()) {
// Try to combine with this wheel event with the last pending one.
- if (WebEventFactory::coalesceWebWheelEvent(m_pendingWheelEvents.last(), ev))
+ if (WebEventFactory::coalesceWebWheelEvent(m_pendingWheelEvents.last(), event))
return;
}
- m_pendingWheelEvents.append(WebEventFactory::toWebWheelEvent(ev));
+ m_pendingWheelEvents.append(WebEventFactory::toWebWheelEvent(event));
}
void RenderWidgetHostViewQt::WheelEventAck(const blink::WebMouseWheelEvent &event, content::InputEventAckState /*ack_result*/)
@@ -1569,254 +830,10 @@ content::MouseWheelPhaseHandler *RenderWidgetHostViewQt::GetMouseWheelPhaseHandl
return &m_mouseWheelPhaseHandler;
}
-void RenderWidgetHostViewQt::clearPreviousTouchMotionState()
-{
- m_previousTouchPoints.clear();
- m_touchMotionStarted = false;
-}
-
-#ifndef QT_NO_GESTURES
-void RenderWidgetHostViewQt::handleGestureEvent(QNativeGestureEvent *ev)
-{
- const Qt::NativeGestureType type = ev->gestureType();
- // These are the only supported gestures by Chromium so far.
- if (type == Qt::ZoomNativeGesture || type == Qt::SmartZoomNativeGesture) {
- host()->ForwardGestureEvent(WebEventFactory::toWebGestureEvent(ev));
- }
-}
-#endif
-
-void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev)
-{
- // On macOS instead of handling touch events, we use the OS provided QNativeGestureEvents.
-#ifdef Q_OS_MACOS
- if (ev->spontaneous()) {
- return;
- } else {
- VLOG(1)
- << "Sending simulated touch events to Chromium does not work properly on macOS. "
- "Consider using QNativeGestureEvents or QMouseEvents.";
- }
-#endif
-
- // Chromium expects the touch event timestamps to be comparable to base::TimeTicks::Now().
- // Most importantly we also have to preserve the relative time distance between events.
- // Calculate a delta between event timestamps and Now() on the first received event, and
- // apply this delta to all successive events. This delta is most likely smaller than it
- // should by calculating it here but this will hopefully cause less than one frame of delay.
- base::TimeTicks eventTimestamp = base::TimeTicks() + base::TimeDelta::FromMilliseconds(ev->timestamp());
- if (m_eventsToNowDelta == base::TimeDelta())
- m_eventsToNowDelta = base::TimeTicks::Now() - eventTimestamp;
- eventTimestamp += m_eventsToNowDelta;
-
- QList<QTouchEvent::TouchPoint> touchPoints = mapTouchPointIds(ev->touchPoints());
- // Make sure that ACTION_POINTER_DOWN is delivered before ACTION_MOVE,
- // and ACTION_MOVE before ACTION_POINTER_UP.
- std::sort(touchPoints.begin(), touchPoints.end(), compareTouchPoints);
-
- // Check first if the touch event should be routed to the selectionController
- if (!touchPoints.isEmpty()) {
- ui::MotionEvent::Action action;
- switch (touchPoints[0].state()) {
- case Qt::TouchPointPressed:
- action = ui::MotionEvent::Action::DOWN;
- break;
- case Qt::TouchPointMoved:
- action = ui::MotionEvent::Action::MOVE;
- break;
- case Qt::TouchPointReleased:
- action = ui::MotionEvent::Action::UP;
- break;
- default:
- action = ui::MotionEvent::Action::NONE;
- break;
- }
-
- MotionEventQt motionEvent(touchPoints, eventTimestamp, action, ev->modifiers(), 0);
- if (m_touchSelectionController->WillHandleTouchEvent(motionEvent)) {
- m_previousTouchPoints = touchPoints;
- ev->accept();
- return;
- }
- } else {
- // An empty touchPoints always corresponds to a TouchCancel event.
- // We can't forward touch cancellations without a previously processed touch event,
- // as Chromium expects the previous touchPoints for Action::CANCEL.
- // If both are empty that means the TouchCancel was sent without an ongoing touch,
- // so there's nothing to cancel anyway.
- touchPoints = m_previousTouchPoints;
- if (touchPoints.isEmpty())
- return;
-
- MotionEventQt cancelEvent(touchPoints, eventTimestamp, ui::MotionEvent::Action::CANCEL, ev->modifiers());
- if (m_touchSelectionController->WillHandleTouchEvent(cancelEvent)) {
- m_previousTouchPoints.clear();
- ev->accept();
- return;
- }
- }
-
- switch (ev->type()) {
- case QEvent::TouchBegin:
- m_sendMotionActionDown = true;
- m_touchMotionStarted = true;
- m_touchSelectionControllerClient->onTouchDown();
- break;
- case QEvent::TouchUpdate:
- m_touchMotionStarted = true;
- break;
- case QEvent::TouchCancel:
- {
- // Only process TouchCancel events received following a TouchBegin or TouchUpdate event
- if (m_touchMotionStarted) {
- MotionEventQt cancelEvent(touchPoints, eventTimestamp, ui::MotionEvent::Action::CANCEL, ev->modifiers());
- processMotionEvent(cancelEvent);
- }
-
- clearPreviousTouchMotionState();
- return;
- }
- case QEvent::TouchEnd:
- clearPreviousTouchMotionState();
- m_touchSelectionControllerClient->onTouchUp();
- break;
- default:
- break;
- }
-
- if (m_imeInProgress && ev->type() == QEvent::TouchBegin) {
- m_imeInProgress = false;
- // Tell input method to commit the pre-edit string entered so far, and finish the
- // composition operation.
-#ifdef Q_OS_WIN
- // Yes the function name is counter-intuitive, but commit isn't actually implemented
- // by the Windows QPA, and reset does exactly what is necessary in this case.
- qApp->inputMethod()->reset();
-#else
- qApp->inputMethod()->commit();
-#endif
- }
-
- for (int i = 0; i < touchPoints.size(); ++i) {
- ui::MotionEvent::Action action;
- switch (touchPoints[i].state()) {
- case Qt::TouchPointPressed:
- if (m_sendMotionActionDown) {
- action = ui::MotionEvent::Action::DOWN;
- m_sendMotionActionDown = false;
- } else {
- action = ui::MotionEvent::Action::POINTER_DOWN;
- }
- break;
- case Qt::TouchPointMoved:
- action = ui::MotionEvent::Action::MOVE;
- break;
- case Qt::TouchPointReleased:
- action = touchPoints.size() > 1 ? ui::MotionEvent::Action::POINTER_UP :
- ui::MotionEvent::Action::UP;
- break;
- default:
- // Ignore Qt::TouchPointStationary
- continue;
- }
-
- MotionEventQt motionEvent(touchPoints, eventTimestamp, action, ev->modifiers(), i);
- processMotionEvent(motionEvent);
- }
-
- m_previousTouchPoints = touchPoints;
-}
-
-#if QT_CONFIG(tabletevent)
-void RenderWidgetHostViewQt::handleTabletEvent(QTabletEvent *event)
-{
- handlePointerEvent<QTabletEvent>(event);
-}
-#endif
-
-template<class T>
-void RenderWidgetHostViewQt::handlePointerEvent(T *event)
-{
- // Currently WebMouseEvent is a subclass of WebPointerProperties, so basically
- // tablet events are mouse events with extra properties.
- blink::WebMouseEvent webEvent = WebEventFactory::toWebMouseEvent(event);
- if ((webEvent.GetType() == blink::WebInputEvent::kMouseDown || webEvent.GetType() == blink::WebInputEvent::kMouseUp)
- && webEvent.button == blink::WebMouseEvent::Button::kNoButton) {
- // Blink can only handle the 5 main mouse-buttons and may assert when processing mouse-down for no button.
- LOG(INFO) << "Unhandled mouse button";
- return;
- }
-
- if (webEvent.GetType() == blink::WebInputEvent::kMouseDown) {
- if (event->button() != m_clickHelper.lastPressButton
- || (event->timestamp() - m_clickHelper.lastPressTimestamp > static_cast<ulong>(qGuiApp->styleHints()->mouseDoubleClickInterval()))
- || (event->pos() - m_clickHelper.lastPressPosition).manhattanLength() > qGuiApp->styleHints()->startDragDistance()
- || m_clickHelper.clickCounter >= 3)
- m_clickHelper.clickCounter = 0;
-
- m_clickHelper.lastPressTimestamp = event->timestamp();
- webEvent.click_count = ++m_clickHelper.clickCounter;
- m_clickHelper.lastPressButton = event->button();
- m_clickHelper.lastPressPosition = QPointF(event->pos()).toPoint();
- }
-
- if (webEvent.GetType() == blink::WebInputEvent::kMouseUp)
- webEvent.click_count = m_clickHelper.clickCounter;
-
- webEvent.movement_x = event->globalX() - m_previousMousePosition.x();
- webEvent.movement_y = event->globalY() - m_previousMousePosition.y();
-
- if (IsMouseLocked())
- QCursor::setPos(m_previousMousePosition);
- else
- m_previousMousePosition = event->globalPos();
-
- if (m_imeInProgress && webEvent.GetType() == blink::WebInputEvent::kMouseDown) {
- m_imeInProgress = false;
- // Tell input method to commit the pre-edit string entered so far, and finish the
- // composition operation.
-#ifdef Q_OS_WIN
- // Yes the function name is counter-intuitive, but commit isn't actually implemented
- // by the Windows QPA, and reset does exactly what is necessary in this case.
- qApp->inputMethod()->reset();
-#else
- qApp->inputMethod()->commit();
-#endif
- }
-
- host()->ForwardMouseEvent(webEvent);
-}
-
-void RenderWidgetHostViewQt::handleHoverEvent(QHoverEvent *ev)
-{
- host()->ForwardMouseEvent(WebEventFactory::toWebMouseEvent(ev));
-}
-
-void RenderWidgetHostViewQt::handleFocusEvent(QFocusEvent *ev)
-{
- if (ev->gotFocus()) {
- host()->GotFocus();
- host()->SetActive(true);
- content::RenderViewHostImpl *viewHost = content::RenderViewHostImpl::From(host());
- Q_ASSERT(viewHost);
- if (ev->reason() == Qt::TabFocusReason)
- viewHost->SetInitialFocus(false);
- else if (ev->reason() == Qt::BacktabFocusReason)
- viewHost->SetInitialFocus(true);
- ev->accept();
-
- m_adapterClient->webContentsAdapter()->handlePendingMouseLockPermission();
- } else if (ev->lostFocus()) {
- host()->SetActive(false);
- host()->LostFocus();
- ev->accept();
- }
-}
-
void RenderWidgetHostViewQt::SetNeedsBeginFrames(bool needs_begin_frames)
{
- m_needsBeginFrames = needs_begin_frames;
- UpdateNeedsBeginFramesInternal();
+ // Not used with viz
+ NOTREACHED();
}
content::RenderFrameHost *RenderWidgetHostViewQt::getFocusedFrameHost()
@@ -1851,22 +868,17 @@ ui::TextInputType RenderWidgetHostViewQt::getTextInputType() const
void RenderWidgetHostViewQt::SetWantsAnimateOnlyBeginFrames()
{
- if (m_enableViz)
- m_delegatedFrameHost->SetWantsAnimateOnlyBeginFrames();
+ m_delegatedFrameHost->SetWantsAnimateOnlyBeginFrames();
}
viz::SurfaceId RenderWidgetHostViewQt::GetCurrentSurfaceId() const
{
- if (m_enableViz)
- return m_delegatedFrameHost->GetCurrentSurfaceId();
- return viz::SurfaceId();
+ return m_delegatedFrameHost->GetCurrentSurfaceId();
}
const viz::FrameSinkId &RenderWidgetHostViewQt::GetFrameSinkId() const
{
- if (m_enableViz)
- return m_delegatedFrameHost->frame_sink_id();
- return m_frameSinkId;
+ return m_delegatedFrameHost->frame_sink_id();
}
const viz::LocalSurfaceIdAllocation &RenderWidgetHostViewQt::GetLocalSurfaceIdAllocation() const
@@ -1881,10 +893,8 @@ void RenderWidgetHostViewQt::TakeFallbackContentFrom(content::RenderWidgetHostVi
base::Optional<SkColor> color = viewQt->GetBackgroundColor();
if (color)
SetBackgroundColor(*color);
- if (m_enableViz) {
- m_delegatedFrameHost->TakeFallbackContentFrom(viewQt->m_delegatedFrameHost.get());
- host()->GetContentRenderingTimeoutFrom(viewQt->host());
- }
+ m_delegatedFrameHost->TakeFallbackContentFrom(viewQt->m_delegatedFrameHost.get());
+ host()->GetContentRenderingTimeoutFrom(viewQt->host());
}
void RenderWidgetHostViewQt::EnsureSurfaceSynchronizedForWebTest()
@@ -1929,20 +939,18 @@ void RenderWidgetHostViewQt::synchronizeVisualProperties(const base::Optional<vi
else
m_dfhLocalSurfaceIdAllocator.GenerateId();
- if (m_enableViz) {
- gfx::Size viewSizeInDips = GetRequestedRendererSize();
- gfx::Size viewSizeInPixels = GetCompositorViewportPixelSize();
- m_rootLayer->SetBounds(gfx::Rect(gfx::Point(), viewSizeInPixels));
- m_uiCompositorLocalSurfaceIdAllocator.GenerateId();
- m_uiCompositor->SetScaleAndSize(
- m_screenInfo.device_scale_factor,
- viewSizeInPixels,
- m_uiCompositorLocalSurfaceIdAllocator.GetCurrentLocalSurfaceIdAllocation());
- m_delegatedFrameHost->EmbedSurface(
- m_dfhLocalSurfaceIdAllocator.GetCurrentLocalSurfaceIdAllocation().local_surface_id(),
- viewSizeInDips,
- cc::DeadlinePolicy::UseDefaultDeadline());
- }
+ gfx::Size viewSizeInDips = GetRequestedRendererSize();
+ gfx::Size viewSizeInPixels = GetCompositorViewportPixelSize();
+ m_rootLayer->SetBounds(gfx::Rect(gfx::Point(), viewSizeInPixels));
+ m_uiCompositorLocalSurfaceIdAllocator.GenerateId();
+ m_uiCompositor->SetScaleAndSize(
+ m_screenInfo.device_scale_factor,
+ viewSizeInPixels,
+ m_uiCompositorLocalSurfaceIdAllocator.GetCurrentLocalSurfaceIdAllocation());
+ m_delegatedFrameHost->EmbedSurface(
+ m_dfhLocalSurfaceIdAllocator.GetCurrentLocalSurfaceIdAllocation().local_surface_id(),
+ viewSizeInDips,
+ cc::DeadlinePolicy::UseDefaultDeadline());
host()->SynchronizeVisualProperties();
}
@@ -1957,12 +965,4 @@ ui::Compositor *RenderWidgetHostViewQt::GetCompositor()
return m_uiCompositor.get();
}
-void RenderWidgetHostViewQt::UpdateNeedsBeginFramesInternal()
-{
- if (m_enableViz)
- m_delegatedFrameHost->SetNeedsBeginFrames(m_needsBeginFrames);
- else
- m_compositor->setNeedsBeginFrames(m_needsBeginFrames);
-}
-
} // namespace QtWebEngineCore
diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h
index e12dbefb1..c13facf00 100644
--- a/src/core/render_widget_host_view_qt.h
+++ b/src/core/render_widget_host_view_qt.h
@@ -40,7 +40,7 @@
#ifndef RENDER_WIDGET_HOST_VIEW_QT_H
#define RENDER_WIDGET_HOST_VIEW_QT_H
-#include "compositor/display_frame_sink.h"
+#include "compositor/compositor.h"
#include "delegated_frame_host_client_qt.h"
#include "render_widget_host_view_qt_delegate.h"
@@ -52,18 +52,9 @@
#include "content/browser/renderer_host/input/mouse_wheel_phase_handler.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "content/browser/renderer_host/text_input_manager.h"
-#include "content/public/browser/render_process_host_observer.h"
-#include "gpu/ipc/common/gpu_messages.h"
#include "ui/events/gesture_detection/filtered_gesture_provider.h"
-#include <QMap>
-#include <QPoint>
-#include <QtGlobal>
-#include <QtGui/QTouchEvent>
-
-QT_BEGIN_NAMESPACE
-class QAccessibleInterface;
-QT_END_NAMESPACE
+QT_FORWARD_DECLARE_CLASS(QAccessibleInterface)
namespace content {
class RenderFrameHost;
@@ -79,42 +70,17 @@ class TouchSelectionController;
namespace QtWebEngineCore {
-class Compositor;
-class TouchHandleDrawableClient;
+class RenderWidgetHostViewQtDelegateClient;
class TouchSelectionControllerClientQt;
-class TouchSelectionMenuController;
-
-struct MultipleMouseClickHelper
-{
- QPoint lastPressPosition;
- Qt::MouseButton lastPressButton;
- int clickCounter;
- ulong lastPressTimestamp;
-
- MultipleMouseClickHelper()
- : lastPressPosition(QPoint())
- , lastPressButton(Qt::NoButton)
- , clickCounter(0)
- , lastPressTimestamp(0)
- {
- }
-};
+class WebContentsAdapterClient;
class RenderWidgetHostViewQt
: public content::RenderWidgetHostViewBase
, public ui::GestureProviderClient
- , public RenderWidgetHostViewQtDelegateClient
, public base::SupportsWeakPtr<RenderWidgetHostViewQt>
, public content::TextInputManager::Observer
- , public DisplayConsumer
{
public:
- enum LoadVisuallyCommittedState {
- NotCommitted,
- DidFirstVisuallyNonEmptyPaint,
- DidFirstCompositorFrameSwap
- };
-
RenderWidgetHostViewQt(content::RenderWidgetHost* widget);
~RenderWidgetHostViewQt();
@@ -122,6 +88,7 @@ public:
void setDelegate(RenderWidgetHostViewQtDelegate *delegate);
WebContentsAdapterClient *adapterClient() { return m_adapterClient; }
void setAdapterClient(WebContentsAdapterClient *adapterClient);
+ RenderWidgetHostViewQtDelegateClient *delegateClient() const { return m_delegateClient.get(); }
void InitAsChild(gfx::NativeView) override;
void InitAsPopup(content::RenderWidgetHostView*, const gfx::Rect&) override;
@@ -176,151 +143,95 @@ public:
void DidStopFlinging() override;
std::unique_ptr<content::SyntheticGestureTarget> CreateSyntheticGestureTarget() override;
ui::Compositor *GetCompositor() override;
+#if defined(OS_MACOSX)
+ void SetActive(bool active) override { QT_NOT_YET_IMPLEMENTED }
+ void SpeakSelection() override { QT_NOT_YET_IMPLEMENTED }
+ void ShowDefinitionForSelection() override { QT_NOT_YET_IMPLEMENTED }
+#endif // defined(OS_MACOSX)
// Overridden from ui::GestureProviderClient.
void OnGestureEvent(const ui::GestureEventData& gesture) override;
- // Overridden from RenderWidgetHostViewQtDelegateClient.
- QSGNode *updatePaintNode(QSGNode *) override;
- void notifyShown() override;
- void notifyHidden() override;
- void visualPropertiesChanged() override;
- bool forwardEvent(QEvent *) override;
- QVariant inputMethodQuery(Qt::InputMethodQuery query) override;
- void closePopup() override;
-
// Overridden from content::TextInputManager::Observer
void OnUpdateTextInputStateCalled(content::TextInputManager *text_input_manager, RenderWidgetHostViewBase *updated_view, bool did_update_state) override;
void OnSelectionBoundsChanged(content::TextInputManager *text_input_manager, RenderWidgetHostViewBase *updated_view) override;
void OnTextSelectionChanged(content::TextInputManager *text_input_manager, RenderWidgetHostViewBase *updated_view) override;
- void handleMouseEvent(QMouseEvent*);
- void handleKeyEvent(QKeyEvent*);
- void handleWheelEvent(QWheelEvent*);
- void handleTouchEvent(QTouchEvent*);
-#if QT_CONFIG(tabletevent)
- void handleTabletEvent(QTabletEvent *ev);
-#endif
-#ifndef QT_NO_GESTURES
- void handleGestureEvent(QNativeGestureEvent *);
-#endif
- void handleHoverEvent(QHoverEvent*);
- void handleFocusEvent(QFocusEvent*);
- void handleInputMethodEvent(QInputMethodEvent*);
- void handleInputMethodQueryEvent(QInputMethodQueryEvent*);
-
- template<class T> void handlePointerEvent(T*);
-
-#if defined(OS_MACOSX)
- void SetActive(bool active) override { QT_NOT_YET_IMPLEMENTED }
- void SpeakSelection() override { QT_NOT_YET_IMPLEMENTED }
- void ShowDefinitionForSelection() override { QT_NOT_YET_IMPLEMENTED }
-#endif // defined(OS_MACOSX)
-
- void UpdateNeedsBeginFramesInternal();
-
// Overridden from content::BrowserAccessibilityDelegate
content::BrowserAccessibilityManager* CreateBrowserAccessibilityManager(content::BrowserAccessibilityDelegate* delegate, bool for_root_frame) override;
- // Called from WebContentsDelegateQt
- void OnDidFirstVisuallyNonEmptyPaint();
-
// Overridden from content::RenderFrameMetadataProvider::Observer
void OnRenderFrameMetadataChangedAfterActivation() override;
- // Overridden from DisplayConsumer
- void scheduleUpdate() override;
+ // Called from RenderWidgetHostViewQtDelegateClient.
+ Compositor::Id compositorId();
+ void notifyShown();
+ void notifyHidden();
+ bool updateScreenInfo();
+ void handleWheelEvent(QWheelEvent *);
+ void processMotionEvent(const ui::MotionEvent &motionEvent);
+ void resetInputManagerState() { m_imState = 0; }
+
+ // Called from WebContentsDelegateQt.
+ void OnDidFirstVisuallyNonEmptyPaint();
+ // Called from WebContentsAdapter.
gfx::SizeF lastContentsSize() const { return m_lastContentsSize; }
gfx::Vector2dF lastScrollOffset() const { return m_lastScrollOffset; }
+ ui::TextInputType getTextInputType() const;
+ content::mojom::FrameInputHandler *getFrameInputHandler();
+
ui::TouchSelectionController *getTouchSelectionController() const { return m_touchSelectionController.get(); }
TouchSelectionControllerClientQt *getTouchSelectionControllerClient() const { return m_touchSelectionControllerClient.get(); }
- content::mojom::FrameInputHandler *getFrameInputHandler();
- ui::TextInputType getTextInputType() const;
+
+ void synchronizeVisualProperties(
+ const base::Optional<viz::LocalSurfaceIdAllocation> &childSurfaceId);
private:
friend class DelegatedFrameHostClientQt;
- void processMotionEvent(const ui::MotionEvent &motionEvent);
- void clearPreviousTouchMotionState();
- QList<QTouchEvent::TouchPoint> mapTouchPointIds(const QList<QTouchEvent::TouchPoint> &inputPoints);
-
- bool IsPopup() const;
-
- void selectionChanged();
+ bool isPopup() const;
content::RenderFrameHost *getFocusedFrameHost();
- void synchronizeVisualProperties(const base::Optional<viz::LocalSurfaceIdAllocation> &childSurfaceId);
-
- void callUpdate();
-
- // Geometry of the view in screen DIPs.
- gfx::Rect m_viewRectInDips;
- // Geometry of the window, including frame, in screen DIPs.
- gfx::Rect m_windowRectInDips;
- content::ScreenInfo m_screenInfo;
-
scoped_refptr<base::SingleThreadTaskRunner> m_taskRunner;
-
ui::FilteredGestureProvider m_gestureProvider;
- base::TimeDelta m_eventsToNowDelta;
- bool m_sendMotionActionDown;
- bool m_touchMotionStarted;
- QMap<int, int> m_touchIdMapping;
- QList<QTouchEvent::TouchPoint> m_previousTouchPoints;
+ viz::FrameSinkId m_frameSinkId;
+ std::unique_ptr<RenderWidgetHostViewQtDelegateClient> m_delegateClient;
std::unique_ptr<RenderWidgetHostViewQtDelegate> m_delegate;
+ QMetaObject::Connection m_adapterClientDestroyedConnection;
+ WebContentsAdapterClient *m_adapterClient = nullptr;
- const bool m_enableViz;
- bool m_visible;
- bool m_needsBeginFrames;
+ bool m_isMouseLocked = false;
+ bool m_visible = false;
bool m_deferredShow = false;
- DelegatedFrameHostClientQt m_delegatedFrameHostClient{this};
+ gfx::Vector2dF m_lastScrollOffset;
+ gfx::SizeF m_lastContentsSize;
+ DelegatedFrameHostClientQt m_delegatedFrameHostClient { this };
+
+ // VIZ
+ content::ScreenInfo m_screenInfo;
std::unique_ptr<content::DelegatedFrameHost> m_delegatedFrameHost;
std::unique_ptr<ui::Layer> m_rootLayer;
std::unique_ptr<ui::Compositor> m_uiCompositor;
- scoped_refptr<DisplayFrameSink> m_displayFrameSink;
- std::unique_ptr<Compositor> m_compositor;
- LoadVisuallyCommittedState m_loadVisuallyCommittedState;
-
- QMetaObject::Connection m_adapterClientDestroyedConnection;
- WebContentsAdapterClient *m_adapterClient;
- MultipleMouseClickHelper m_clickHelper;
-
- bool m_imeInProgress;
- bool m_receivedEmptyImeEvent;
- QPoint m_previousMousePosition;
- bool m_isMouseLocked;
-
- gfx::Vector2dF m_lastScrollOffset;
- gfx::SizeF m_lastContentsSize;
viz::ParentLocalSurfaceIdAllocator m_dfhLocalSurfaceIdAllocator;
viz::ParentLocalSurfaceIdAllocator m_uiCompositorLocalSurfaceIdAllocator;
- uint m_imState;
- int m_anchorPositionWithinSelection;
- int m_cursorPositionWithinSelection;
- uint m_cursorPosition;
- bool m_emptyPreviousSelection;
- QString m_surroundingText;
-
- bool m_imeHasHiddenTextCapability;
+ // IME
+ uint m_imState = 0;
- bool m_wheelAckPending;
+ // Wheel
+ bool m_wheelAckPending = false;
QList<blink::WebMouseWheelEvent> m_pendingWheelEvents;
- content::MouseWheelPhaseHandler m_mouseWheelPhaseHandler;
- viz::FrameSinkId m_frameSinkId;
-
- std::string m_editCommand;
+ content::MouseWheelPhaseHandler m_mouseWheelPhaseHandler { this };
+ // TouchSelection
std::unique_ptr<TouchSelectionControllerClientQt> m_touchSelectionControllerClient;
std::unique_ptr<ui::TouchSelectionController> m_touchSelectionController;
gfx::SelectionBound m_selectionStart;
gfx::SelectionBound m_selectionEnd;
- base::WeakPtrFactory<RenderWidgetHostViewQt> m_weakPtrFactory{this};
-
- uint m_mouseButtonPressed = 0;
+ base::WeakPtrFactory<RenderWidgetHostViewQt> m_weakPtrFactory { this };
};
} // namespace QtWebEngineCore
diff --git a/src/core/render_widget_host_view_qt_delegate.h b/src/core/render_widget_host_view_qt_delegate.h
index 46f1802a6..dfbd3b26a 100644
--- a/src/core/render_widget_host_view_qt_delegate.h
+++ b/src/core/render_widget_host_view_qt_delegate.h
@@ -53,39 +53,18 @@
#include "qtwebenginecoreglobal_p.h"
-#include <QRect>
-#include <QtGui/qwindowdefs.h>
+#include <QtCore/QRect>
+#include <QtGui/QColor>
+#include <QtGui/QCursor>
+#include <QtGui/QImage>
QT_BEGIN_NAMESPACE
-class QEvent;
-class QInputMethodEvent;
-class QSGLayer;
-class QSGNode;
-class QSGRectangleNode;
-class QSGTexture;
-class QVariant;
class QWheelEvent;
-
-class QSGImageNode;
-
+class QWindow;
QT_END_NAMESPACE
namespace QtWebEngineCore {
-class WebContentsAdapterClient;
-
-class Q_WEBENGINECORE_PRIVATE_EXPORT RenderWidgetHostViewQtDelegateClient {
-public:
- virtual ~RenderWidgetHostViewQtDelegateClient() { }
- virtual QSGNode *updatePaintNode(QSGNode *) = 0;
- virtual void notifyShown() = 0;
- virtual void notifyHidden() = 0;
- virtual void visualPropertiesChanged() = 0;
- virtual bool forwardEvent(QEvent *) = 0;
- virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) = 0;
- virtual void closePopup() = 0;
-};
-
class Q_WEBENGINECORE_PRIVATE_EXPORT RenderWidgetHostViewQtDelegate {
public:
virtual ~RenderWidgetHostViewQtDelegate() { }
@@ -100,18 +79,12 @@ public:
virtual void hide() = 0;
virtual bool isVisible() const = 0;
virtual QWindow* window() const = 0;
- virtual QSGTexture *createTextureFromImage(const QImage &) = 0;
- virtual QSGLayer *createLayer() = 0;
- virtual QSGImageNode *createImageNode() = 0;
- virtual QSGRectangleNode *createRectangleNode() = 0;
- virtual void update() = 0;
virtual void updateCursor(const QCursor &) = 0;
virtual void resize(int width, int height) = 0;
virtual void move(const QPoint &) = 0;
virtual void inputMethodStateChanged(bool editorVisible, bool passwordInput) = 0;
virtual void setInputMethodHints(Qt::InputMethodHints hints) = 0;
virtual void setClearColor(const QColor &color) = 0;
- virtual bool copySurface(const QRect &, const QSize &, QImage &) = 0;
virtual void unhandledWheelEvent(QWheelEvent *) {}
};
diff --git a/src/core/render_widget_host_view_qt_delegate_client.cpp b/src/core/render_widget_host_view_qt_delegate_client.cpp
new file mode 100644
index 000000000..2c427cd46
--- /dev/null
+++ b/src/core/render_widget_host_view_qt_delegate_client.cpp
@@ -0,0 +1,976 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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 "render_widget_host_view_qt_delegate_client.h"
+
+#include "render_widget_host_view_qt.h"
+#include "touch_selection_controller_client_qt.h"
+#include "type_conversion.h"
+#include "web_contents_adapter.h"
+#include "web_contents_adapter_client.h"
+#include "web_event_factory.h"
+
+#include "content/browser/renderer_host/render_view_host_impl.h"
+#include "ui/touch_selection/touch_selection_controller.h"
+
+#include <QEvent>
+#include <QInputMethodEvent>
+#include <QSGNode>
+#include <QStyleHints>
+#include <QTextFormat>
+#include <QVariant>
+
+#include <private/qguiapplication_p.h>
+#include <qpa/qplatforminputcontext.h>
+#include <qpa/qplatformintegration.h>
+#include <QtGui/private/qinputcontrol_p.h>
+
+namespace QtWebEngineCore {
+
+static inline int firstAvailableId(const QMap<int, int> &map)
+{
+ ui::BitSet32 usedIds;
+ QMap<int, int>::const_iterator end = map.end();
+ for (QMap<int, int>::const_iterator it = map.begin(); it != end; ++it)
+ usedIds.mark_bit(it.value());
+ return usedIds.first_unmarked_bit();
+}
+
+static QList<QTouchEvent::TouchPoint>
+mapTouchPointIds(const QList<QTouchEvent::TouchPoint> &inputPoints)
+{
+ static QMap<int, int> touchIdMapping;
+ QList<QTouchEvent::TouchPoint> outputPoints = inputPoints;
+ for (int i = 0; i < outputPoints.size(); ++i) {
+ QTouchEvent::TouchPoint &point = outputPoints[i];
+
+ int qtId = point.id();
+ QMap<int, int>::const_iterator it = touchIdMapping.find(qtId);
+ if (it == touchIdMapping.end())
+ it = touchIdMapping.insert(qtId, firstAvailableId(touchIdMapping));
+ QMutableEventPoint &mut = QMutableEventPoint::from(point);
+ mut.setId(it.value());
+
+ if (point.state() == QEventPoint::State::Released)
+ touchIdMapping.remove(qtId);
+ }
+
+ return outputPoints;
+}
+
+static inline bool compareTouchPoints(const QTouchEvent::TouchPoint &lhs,
+ const QTouchEvent::TouchPoint &rhs)
+{
+ // TouchPointPressed < TouchPointMoved < TouchPointReleased
+ return lhs.state() < rhs.state();
+}
+
+static uint32_t s_eventId = 0;
+class MotionEventQt : public ui::MotionEvent
+{
+public:
+ MotionEventQt(const QList<QTouchEvent::TouchPoint> &touchPoints,
+ const base::TimeTicks &eventTime, Action action,
+ const Qt::KeyboardModifiers modifiers, int index = -1)
+ : touchPoints(touchPoints)
+ , eventTime(eventTime)
+ , action(action)
+ , eventId(++s_eventId)
+ , flags(flagsFromModifiers(modifiers))
+ , index(index)
+ {
+ // ACTION_DOWN and ACTION_UP must be accesssed through pointer_index 0
+ Q_ASSERT((action != Action::DOWN && action != Action::UP) || index == 0);
+ }
+
+ uint32_t GetUniqueEventId() const override { return eventId; }
+ Action GetAction() const override { return action; }
+ int GetActionIndex() const override { return index; }
+ size_t GetPointerCount() const override { return touchPoints.size(); }
+ int GetPointerId(size_t pointer_index) const override
+ {
+ return touchPoints.at(pointer_index).id();
+ }
+ float GetX(size_t pointer_index) const override
+ {
+ return touchPoints.at(pointer_index).position().x();
+ }
+ float GetY(size_t pointer_index) const override
+ {
+ return touchPoints.at(pointer_index).position().y();
+ }
+ float GetRawX(size_t pointer_index) const override
+ {
+ return touchPoints.at(pointer_index).globalPosition().x();
+ }
+ float GetRawY(size_t pointer_index) const override
+ {
+ return touchPoints.at(pointer_index).globalPosition().y();
+ }
+ float GetTouchMajor(size_t pointer_index) const override
+ {
+ QSizeF diams = touchPoints.at(pointer_index).ellipseDiameters();
+ return std::max(diams.height(), diams.width());
+ }
+ float GetTouchMinor(size_t pointer_index) const override
+ {
+ QSizeF diams = touchPoints.at(pointer_index).ellipseDiameters();
+ return std::min(diams.height(), diams.width());
+ }
+ float GetOrientation(size_t pointer_index) const override { return 0; }
+ int GetFlags() const override { return flags; }
+ float GetPressure(size_t pointer_index) const override
+ {
+ return touchPoints.at(pointer_index).pressure();
+ }
+ float GetTiltX(size_t pointer_index) const override { return 0; }
+ float GetTiltY(size_t pointer_index) const override { return 0; }
+ float GetTwist(size_t) const override { return 0; }
+ float GetTangentialPressure(size_t) const override { return 0; }
+ base::TimeTicks GetEventTime() const override { return eventTime; }
+
+ size_t GetHistorySize() const override { return 0; }
+ base::TimeTicks GetHistoricalEventTime(size_t historical_index) const override
+ {
+ return base::TimeTicks();
+ }
+ float GetHistoricalTouchMajor(size_t pointer_index, size_t historical_index) const override
+ {
+ return 0;
+ }
+ float GetHistoricalX(size_t pointer_index, size_t historical_index) const override { return 0; }
+ float GetHistoricalY(size_t pointer_index, size_t historical_index) const override { return 0; }
+ ToolType GetToolType(size_t pointer_index) const override
+ {
+ return ui::MotionEvent::ToolType::FINGER;
+ }
+
+ int GetButtonState() const override { return 0; }
+
+private:
+ QList<QTouchEvent::TouchPoint> touchPoints;
+ base::TimeTicks eventTime;
+ Action action;
+ const uint32_t eventId;
+ int flags;
+ int index;
+};
+
+RenderWidgetHostViewQtDelegateClient::RenderWidgetHostViewQtDelegateClient(
+ RenderWidgetHostViewQt *rwhv)
+ : m_rwhv(rwhv)
+{
+ Q_ASSERT(rwhv);
+
+ const QPlatformInputContext *context =
+ QGuiApplicationPrivate::platformIntegration()->inputContext();
+ m_imeHasHiddenTextCapability =
+ context && context->hasCapability(QPlatformInputContext::HiddenTextCapability);
+}
+
+Compositor::Id RenderWidgetHostViewQtDelegateClient::compositorId()
+{
+ return m_rwhv->compositorId();
+}
+
+void RenderWidgetHostViewQtDelegateClient::notifyShown()
+{
+ m_rwhv->notifyShown();
+}
+
+void RenderWidgetHostViewQtDelegateClient::notifyHidden()
+{
+ m_rwhv->notifyHidden();
+}
+
+void RenderWidgetHostViewQtDelegateClient::visualPropertiesChanged()
+{
+ RenderWidgetHostViewQtDelegate *delegate = m_rwhv->delegate();
+ if (!delegate)
+ return;
+
+ QRect oldViewRect = m_viewRectInDips;
+ m_viewRectInDips = delegate->viewGeometry().toAlignedRect();
+
+ QRect oldWindowRect = m_windowRectInDips;
+ m_windowRectInDips = delegate->windowGeometry();
+
+ bool screenInfoChanged = m_rwhv->updateScreenInfo();
+
+ if (m_viewRectInDips != oldViewRect || m_windowRectInDips != oldWindowRect)
+ m_rwhv->host()->SendScreenRects();
+
+ if (m_viewRectInDips.size() != oldViewRect.size() || screenInfoChanged)
+ m_rwhv->synchronizeVisualProperties(base::nullopt);
+}
+
+bool RenderWidgetHostViewQtDelegateClient::forwardEvent(QEvent *event)
+{
+ Q_ASSERT(m_rwhv->host()->GetView());
+
+ switch (event->type()) {
+ case QEvent::ShortcutOverride: {
+ QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
+
+ auto acceptKeyOutOfInputField = [](QKeyEvent *keyEvent) -> bool {
+#ifdef Q_OS_MACOS
+ // Check if a shortcut is registered for this key sequence.
+ QKeySequence sequence = QKeySequence((keyEvent->modifiers() | keyEvent->key())
+ & ~(Qt::KeypadModifier | Qt::GroupSwitchModifier));
+ if (QGuiApplicationPrivate::instance()->shortcutMap.hasShortcutForKeySequence(sequence))
+ return false;
+
+ // The following shortcuts are handled out of input field too but
+ // disabled on macOS to let the blinking menu handling to the
+ // embedder application (see kKeyboardCodeKeyDownEntries in
+ // third_party/WebKit/Source/core/editing/EditingBehavior.cpp).
+ // Let them pass on macOS to generate the corresponding edit command.
+ return keyEvent->matches(QKeySequence::Copy) || keyEvent->matches(QKeySequence::Paste)
+ || keyEvent->matches(QKeySequence::Cut)
+ || keyEvent->matches(QKeySequence::SelectAll);
+#else
+ return false;
+#endif
+ };
+
+ if (!inputMethodQuery(Qt::ImEnabled).toBool()
+ && !(inputMethodQuery(Qt::ImHints).toInt() & Qt::ImhHiddenText)
+ && !acceptKeyOutOfInputField(keyEvent))
+ return false;
+
+ Q_ASSERT(m_editCommand.empty());
+ if (WebEventFactory::getEditCommand(keyEvent, &m_editCommand)
+ || QInputControl::isCommonTextEditShortcut(keyEvent)) {
+ event->accept();
+ return true;
+ }
+
+ return false;
+ }
+ case QEvent::MouseButtonPress:
+ m_rwhv->Focus();
+ Q_FALLTHROUGH();
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseMove:
+ // Skip second MouseMove event when a window is being adopted, so that Chromium
+ // can properly handle further move events.
+ // Also make sure the adapter client exists to prevent a null pointer dereference,
+ // because it's possible for a QWebEnginePagePrivate (adapter) instance to be destroyed,
+ // and then the OS (observed on Windows) might still send mouse move events to a still
+ // existing popup RWHVQDW instance.
+ if (m_rwhv->adapterClient() && m_rwhv->adapterClient()->isBeingAdopted())
+ return false;
+ handleMouseEvent(static_cast<QMouseEvent *>(event));
+ break;
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ handleKeyEvent(static_cast<QKeyEvent *>(event));
+ break;
+ case QEvent::Wheel:
+ m_rwhv->handleWheelEvent(static_cast<QWheelEvent *>(event));
+ break;
+ case QEvent::TouchBegin:
+ m_rwhv->Focus();
+ Q_FALLTHROUGH();
+ case QEvent::TouchUpdate:
+ case QEvent::TouchEnd:
+ case QEvent::TouchCancel:
+ handleTouchEvent(static_cast<QTouchEvent *>(event));
+ break;
+#if QT_CONFIG(tabletevent)
+ case QEvent::TabletPress:
+ m_rwhv->Focus();
+ Q_FALLTHROUGH();
+ case QEvent::TabletRelease:
+ case QEvent::TabletMove:
+ handleTabletEvent(static_cast<QTabletEvent *>(event));
+ break;
+#endif
+#if QT_CONFIG(gestures)
+ case QEvent::NativeGesture:
+ handleGestureEvent(static_cast<QNativeGestureEvent *>(event));
+ break;
+#endif
+ case QEvent::HoverMove:
+ handleHoverEvent(static_cast<QHoverEvent *>(event));
+ break;
+ case QEvent::FocusIn:
+ case QEvent::FocusOut:
+ handleFocusEvent(static_cast<QFocusEvent *>(event));
+ break;
+ case QEvent::InputMethod:
+ handleInputMethodEvent(static_cast<QInputMethodEvent *>(event));
+ break;
+ case QEvent::InputMethodQuery:
+ handleInputMethodQueryEvent(static_cast<QInputMethodQueryEvent *>(event));
+ break;
+ case QEvent::Leave:
+#ifdef Q_OS_WIN
+ if (m_mouseButtonPressed > 0)
+ return false;
+#endif
+ case QEvent::HoverLeave:
+ m_rwhv->host()->ForwardMouseEvent(WebEventFactory::toWebMouseEvent(event));
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+QVariant RenderWidgetHostViewQtDelegateClient::inputMethodQuery(Qt::InputMethodQuery query)
+{
+ switch (query) {
+ case Qt::ImEnabled: {
+ ui::TextInputType type = m_rwhv->getTextInputType();
+ bool editorVisible = type != ui::TEXT_INPUT_TYPE_NONE;
+ // IME manager should disable composition on input fields with ImhHiddenText hint if
+ // supported
+ if (m_imeHasHiddenTextCapability)
+ return QVariant(editorVisible);
+
+ bool passwordInput = type == ui::TEXT_INPUT_TYPE_PASSWORD;
+ return QVariant(editorVisible && !passwordInput);
+ }
+ case Qt::ImFont:
+ // TODO: Implement this
+ return QVariant();
+ case Qt::ImCursorRectangle: {
+ if (m_rwhv->GetTextInputManager()) {
+ if (auto *region = m_rwhv->GetTextInputManager()->GetSelectionRegion()) {
+ if (region->focus.GetHeight() > 0) {
+ gfx::Rect caretRect =
+ gfx::RectBetweenSelectionBounds(region->anchor, region->focus);
+ if (caretRect.width() == 0)
+ caretRect.set_width(1); // IME API on Windows expects a width > 0
+ return toQt(caretRect);
+ }
+ }
+ }
+ return QVariant();
+ }
+ case Qt::ImCursorPosition:
+ return m_cursorPosition;
+ case Qt::ImAnchorPosition:
+ return m_rwhv->GetSelectedText().empty() ? m_cursorPosition
+ : m_anchorPositionWithinSelection;
+ case Qt::ImSurroundingText:
+ return m_surroundingText;
+ case Qt::ImCurrentSelection:
+ return toQt(m_rwhv->GetSelectedText());
+ case Qt::ImMaximumTextLength:
+ // TODO: Implement this
+ return QVariant(); // No limit.
+ case Qt::ImHints:
+#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
+ return int(toQtInputMethodHints(m_rwhv->getTextInputType()) | Qt::ImhNoPredictiveText
+ | Qt::ImhNoTextHandles | Qt::ImhNoEditMenu);
+#else
+ return int(toQtInputMethodHints(m_rwhv->getTextInputType()) | Qt::ImhNoPredictiveText);
+#endif
+ default:
+ return QVariant();
+ }
+}
+
+void RenderWidgetHostViewQtDelegateClient::closePopup()
+{
+ // We notify the popup to be closed by telling it that it lost focus. WebKit does the rest
+ // (hiding the widget and automatic memory cleanup via
+ // RenderWidget::CloseWidgetSoon() -> RenderWidgetHostImpl::ShutdownAndDestroyWidget(true).
+ m_rwhv->host()->SetActive(false);
+ m_rwhv->host()->LostFocus();
+}
+
+template<class T>
+void RenderWidgetHostViewQtDelegateClient::handlePointerEvent(T *event)
+{
+ // Currently WebMouseEvent is a subclass of WebPointerProperties, so basically
+ // tablet events are mouse events with extra properties.
+ blink::WebMouseEvent webEvent = WebEventFactory::toWebMouseEvent(event);
+ if ((webEvent.GetType() == blink::WebInputEvent::kMouseDown
+ || webEvent.GetType() == blink::WebInputEvent::kMouseUp)
+ && webEvent.button == blink::WebMouseEvent::Button::kNoButton) {
+ // Blink can only handle the 5 main mouse-buttons and may assert when processing mouse-down
+ // for no button.
+ LOG(INFO) << "Unhandled mouse button";
+ return;
+ }
+
+ if (webEvent.GetType() == blink::WebInputEvent::kMouseDown) {
+ if (event->button() != m_clickHelper.lastPressButton
+ || (event->timestamp() - m_clickHelper.lastPressTimestamp
+ > static_cast<ulong>(qGuiApp->styleHints()->mouseDoubleClickInterval()))
+ || (event->position() - m_clickHelper.lastPressPosition).manhattanLength()
+ > qGuiApp->styleHints()->startDragDistance()
+ || m_clickHelper.clickCounter >= 3)
+ m_clickHelper.clickCounter = 0;
+
+ m_clickHelper.lastPressTimestamp = event->timestamp();
+ webEvent.click_count = ++m_clickHelper.clickCounter;
+ m_clickHelper.lastPressButton = event->button();
+ m_clickHelper.lastPressPosition = event->position().toPoint();
+ }
+
+ if (webEvent.GetType() == blink::WebInputEvent::kMouseUp)
+ webEvent.click_count = m_clickHelper.clickCounter;
+
+ webEvent.movement_x = event->globalPosition().x() - m_previousMousePosition.x();
+ webEvent.movement_y = event->globalPosition().y() - m_previousMousePosition.y();
+
+ if (m_rwhv->IsMouseLocked())
+ QCursor::setPos(m_previousMousePosition);
+ else
+ m_previousMousePosition = event->globalPosition().toPoint();
+
+ if (m_imeInProgress && webEvent.GetType() == blink::WebInputEvent::kMouseDown) {
+ m_imeInProgress = false;
+ // Tell input method to commit the pre-edit string entered so far, and finish the
+ // composition operation.
+#ifdef Q_OS_WIN
+ // Yes the function name is counter-intuitive, but commit isn't actually implemented
+ // by the Windows QPA, and reset does exactly what is necessary in this case.
+ qApp->inputMethod()->reset();
+#else
+ qApp->inputMethod()->commit();
+#endif
+ }
+
+ m_rwhv->host()->ForwardMouseEvent(webEvent);
+}
+
+void RenderWidgetHostViewQtDelegateClient::handleMouseEvent(QMouseEvent *event)
+{
+ if (event->type() == QEvent::MouseButtonPress)
+ m_mouseButtonPressed++;
+ if (event->type() == QEvent::MouseButtonRelease)
+ m_mouseButtonPressed--;
+
+ // Don't forward mouse events synthesized by the system, which are caused by genuine touch
+ // events. Chromium would then process for e.g. a mouse click handler twice, once due to the
+ // system synthesized mouse event, and another time due to a touch-to-gesture-to-mouse
+ // transformation done by Chromium.
+ if (event->source() == Qt::MouseEventSynthesizedBySystem)
+ return;
+ handlePointerEvent<QMouseEvent>(event);
+}
+
+void RenderWidgetHostViewQtDelegateClient::handleKeyEvent(QKeyEvent *event)
+{
+ if (m_rwhv->IsMouseLocked() && event->key() == Qt::Key_Escape
+ && event->type() == QEvent::KeyRelease)
+ m_rwhv->UnlockMouse();
+
+ if (m_receivedEmptyImeEvent) {
+ // IME composition was not finished with a valid commit string.
+ // We're getting the composition result in a key event.
+ if (event->key() != 0) {
+ // The key event is not a result of an IME composition. Cancel IME.
+ m_rwhv->host()->ImeCancelComposition();
+ m_receivedEmptyImeEvent = false;
+ } else {
+ if (event->type() == QEvent::KeyRelease) {
+ m_rwhv->host()->ImeCommitText(toString16(event->text()),
+ std::vector<ui::ImeTextSpan>(),
+ gfx::Range::InvalidRange(), 0);
+ m_receivedEmptyImeEvent = false;
+ m_imeInProgress = false;
+ }
+ return;
+ }
+ }
+
+ // Ignore autorepeating KeyRelease events so that the generated web events
+ // conform to the spec, which requires autorepeat to result in a sequence of
+ // keypress events and only one final keyup event:
+ // https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Auto-repeat_handling
+ // https://w3c.github.io/uievents/#dom-keyboardevent-repeat
+ if (event->type() == QEvent::KeyRelease && event->isAutoRepeat())
+ return;
+
+ content::NativeWebKeyboardEvent webEvent = WebEventFactory::toWebKeyboardEvent(event);
+ if (webEvent.GetType() == blink::WebInputEvent::kRawKeyDown && !m_editCommand.empty()) {
+ ui::LatencyInfo latency;
+ latency.set_source_event_type(ui::SourceEventType::KEY_PRESS);
+ content::EditCommands commands;
+ commands.emplace_back(m_editCommand, "");
+ m_editCommand.clear();
+ m_rwhv->host()->ForwardKeyboardEventWithCommands(webEvent, latency, &commands, nullptr);
+ return;
+ }
+
+ bool keyDownTextInsertion =
+ webEvent.GetType() == blink::WebInputEvent::kRawKeyDown && webEvent.text[0];
+ webEvent.skip_in_browser = keyDownTextInsertion;
+ m_rwhv->host()->ForwardKeyboardEvent(webEvent);
+
+ if (keyDownTextInsertion) {
+ // Blink won't consume the RawKeyDown, but rather the Char event in this case.
+ // The RawKeyDown is skipped on the way back (see above).
+ // The same os_event will be set on both NativeWebKeyboardEvents.
+ webEvent.skip_in_browser = false;
+ webEvent.SetType(blink::WebInputEvent::kChar);
+ m_rwhv->host()->ForwardKeyboardEvent(webEvent);
+ }
+}
+
+void RenderWidgetHostViewQtDelegateClient::handleTouchEvent(QTouchEvent *event)
+{
+ // On macOS instead of handling touch events, we use the OS provided QNativeGestureEvents.
+#ifdef Q_OS_MACOS
+ if (event->spontaneous()) {
+ return;
+ } else {
+ VLOG(1) << "Sending simulated touch events to Chromium does not work properly on macOS. "
+ "Consider using QNativeGestureEvents or QMouseEvents.";
+ }
+#endif
+
+ // Chromium expects the touch event timestamps to be comparable to base::TimeTicks::Now().
+ // Most importantly we also have to preserve the relative time distance between events.
+ // Calculate a delta between event timestamps and Now() on the first received event, and
+ // apply this delta to all successive events. This delta is most likely smaller than it
+ // should by calculating it here but this will hopefully cause less than one frame of delay.
+ base::TimeTicks eventTimestamp =
+ base::TimeTicks() + base::TimeDelta::FromMilliseconds(event->timestamp());
+ static base::TimeDelta eventsToNowDelta = base::TimeTicks::Now() - eventTimestamp;
+ eventTimestamp += eventsToNowDelta;
+
+ QList<QTouchEvent::TouchPoint> touchPoints = mapTouchPointIds(event->touchPoints());
+ // Make sure that ACTION_POINTER_DOWN is delivered before ACTION_MOVE,
+ // and ACTION_MOVE before ACTION_POINTER_UP.
+ std::sort(touchPoints.begin(), touchPoints.end(), compareTouchPoints);
+
+ // Check first if the touch event should be routed to the selectionController
+ if (!touchPoints.isEmpty()) {
+ ui::MotionEvent::Action action;
+ switch (touchPoints[0].state()) {
+ case Qt::TouchPointPressed:
+ action = ui::MotionEvent::Action::DOWN;
+ break;
+ case Qt::TouchPointMoved:
+ action = ui::MotionEvent::Action::MOVE;
+ break;
+ case Qt::TouchPointReleased:
+ action = ui::MotionEvent::Action::UP;
+ break;
+ default:
+ action = ui::MotionEvent::Action::NONE;
+ break;
+ }
+
+ MotionEventQt motionEvent(touchPoints, eventTimestamp, action, event->modifiers(), 0);
+ if (m_rwhv->getTouchSelectionController()->WillHandleTouchEvent(motionEvent)) {
+ m_previousTouchPoints = touchPoints;
+ event->accept();
+ return;
+ }
+ } else {
+ // An empty touchPoints always corresponds to a TouchCancel event.
+ // We can't forward touch cancellations without a previously processed touch event,
+ // as Chromium expects the previous touchPoints for Action::CANCEL.
+ // If both are empty that means the TouchCancel was sent without an ongoing touch,
+ // so there's nothing to cancel anyway.
+ touchPoints = m_previousTouchPoints;
+ if (touchPoints.isEmpty())
+ return;
+
+ MotionEventQt cancelEvent(touchPoints, eventTimestamp, ui::MotionEvent::Action::CANCEL,
+ event->modifiers());
+ if (m_rwhv->getTouchSelectionController()->WillHandleTouchEvent(cancelEvent)) {
+ m_previousTouchPoints.clear();
+ event->accept();
+ return;
+ }
+ }
+
+ switch (event->type()) {
+ case QEvent::TouchBegin:
+ m_sendMotionActionDown = true;
+ m_touchMotionStarted = true;
+ m_rwhv->getTouchSelectionControllerClient()->onTouchDown();
+ break;
+ case QEvent::TouchUpdate:
+ m_touchMotionStarted = true;
+ break;
+ case QEvent::TouchCancel: {
+ // Only process TouchCancel events received following a TouchBegin or TouchUpdate event
+ if (m_touchMotionStarted) {
+ MotionEventQt cancelEvent(touchPoints, eventTimestamp, ui::MotionEvent::Action::CANCEL,
+ event->modifiers());
+ m_rwhv->processMotionEvent(cancelEvent);
+ }
+
+ clearPreviousTouchMotionState();
+ return;
+ }
+ case QEvent::TouchEnd:
+ clearPreviousTouchMotionState();
+ m_rwhv->getTouchSelectionControllerClient()->onTouchUp();
+ break;
+ default:
+ break;
+ }
+
+ if (m_imeInProgress && event->type() == QEvent::TouchBegin) {
+ m_imeInProgress = false;
+ // Tell input method to commit the pre-edit string entered so far, and finish the
+ // composition operation.
+#ifdef Q_OS_WIN
+ // Yes the function name is counter-intuitive, but commit isn't actually implemented
+ // by the Windows QPA, and reset does exactly what is necessary in this case.
+ qApp->inputMethod()->reset();
+#else
+ qApp->inputMethod()->commit();
+#endif
+ }
+
+ for (int i = 0; i < touchPoints.size(); ++i) {
+ ui::MotionEvent::Action action;
+ switch (touchPoints[i].state()) {
+ case Qt::TouchPointPressed:
+ if (m_sendMotionActionDown) {
+ action = ui::MotionEvent::Action::DOWN;
+ m_sendMotionActionDown = false;
+ } else {
+ action = ui::MotionEvent::Action::POINTER_DOWN;
+ }
+ break;
+ case Qt::TouchPointMoved:
+ action = ui::MotionEvent::Action::MOVE;
+ break;
+ case Qt::TouchPointReleased:
+ action = touchPoints.size() > 1 ? ui::MotionEvent::Action::POINTER_UP
+ : ui::MotionEvent::Action::UP;
+ break;
+ default:
+ // Ignore Qt::TouchPointStationary
+ continue;
+ }
+
+ MotionEventQt motionEvent(touchPoints, eventTimestamp, action, event->modifiers(), i);
+ m_rwhv->processMotionEvent(motionEvent);
+ }
+
+ m_previousTouchPoints = touchPoints;
+}
+
+#if QT_CONFIG(tabletevent)
+void RenderWidgetHostViewQtDelegateClient::handleTabletEvent(QTabletEvent *event)
+{
+ handlePointerEvent<QTabletEvent>(event);
+}
+#endif
+
+#if QT_CONFIG(gestures)
+void RenderWidgetHostViewQtDelegateClient::handleGestureEvent(QNativeGestureEvent *event)
+{
+ const Qt::NativeGestureType type = event->gestureType();
+ // These are the only supported gestures by Chromium so far.
+ if (type == Qt::ZoomNativeGesture || type == Qt::SmartZoomNativeGesture) {
+ m_rwhv->host()->ForwardGestureEvent(WebEventFactory::toWebGestureEvent(event));
+ }
+}
+#endif
+
+void RenderWidgetHostViewQtDelegateClient::handleHoverEvent(QHoverEvent *event)
+{
+ m_rwhv->host()->ForwardMouseEvent(WebEventFactory::toWebMouseEvent(event));
+}
+
+void RenderWidgetHostViewQtDelegateClient::handleFocusEvent(QFocusEvent *event)
+{
+ if (event->gotFocus()) {
+ m_rwhv->host()->GotFocus();
+ m_rwhv->host()->SetActive(true);
+ content::RenderViewHostImpl *rvh = content::RenderViewHostImpl::From(m_rwhv->host());
+ Q_ASSERT(rvh);
+ if (event->reason() == Qt::TabFocusReason)
+ rvh->SetInitialFocus(false);
+ else if (event->reason() == Qt::BacktabFocusReason)
+ rvh->SetInitialFocus(true);
+ event->accept();
+
+ m_rwhv->adapterClient()->webContentsAdapter()->handlePendingMouseLockPermission();
+ } else if (event->lostFocus()) {
+ m_rwhv->host()->SetActive(false);
+ m_rwhv->host()->LostFocus();
+ event->accept();
+ }
+}
+
+void RenderWidgetHostViewQtDelegateClient::handleInputMethodEvent(QInputMethodEvent *event)
+{
+ m_rwhv->resetInputManagerState();
+
+ if (!m_rwhv->host())
+ return;
+
+ QString commitString = event->commitString();
+ QString preeditString = event->preeditString();
+
+ int cursorPositionInPreeditString = -1;
+ gfx::Range selectionRange = gfx::Range::InvalidRange();
+
+ const QList<QInputMethodEvent::Attribute> &attributes = event->attributes();
+ std::vector<ui::ImeTextSpan> underlines;
+ bool hasSelection = false;
+
+ for (const auto &attribute : attributes) {
+ switch (attribute.type) {
+ case QInputMethodEvent::TextFormat: {
+ if (preeditString.isEmpty())
+ break;
+
+ int start = qMin(attribute.start, (attribute.start + attribute.length));
+ int end = qMax(attribute.start, (attribute.start + attribute.length));
+
+ // Blink does not support negative position values. Adjust start and end positions
+ // to non-negative values.
+ if (start < 0) {
+ start = 0;
+ end = qMax(0, start + end);
+ }
+
+ underlines.push_back(ui::ImeTextSpan(ui::ImeTextSpan::Type::kComposition, start, end,
+ ui::ImeTextSpan::Thickness::kThin,
+ SK_ColorTRANSPARENT));
+
+ QTextCharFormat format = qvariant_cast<QTextFormat>(attribute.value).toCharFormat();
+ if (format.underlineStyle() != QTextCharFormat::NoUnderline)
+ underlines.back().underline_color = toSk(format.underlineColor());
+
+ break;
+ }
+ case QInputMethodEvent::Cursor:
+ // Always set the position of the cursor, even if it's marked invisible by Qt, otherwise
+ // there is no way the user will know which part of the composition string will be
+ // changed, when performing an IME-specific action (like selecting a different word
+ // suggestion).
+ cursorPositionInPreeditString = attribute.start;
+ break;
+ case QInputMethodEvent::Selection:
+ hasSelection = true;
+
+ // Cancel IME composition
+ if (preeditString.isEmpty() && attribute.start + attribute.length == 0) {
+ selectionRange.set_start(0);
+ selectionRange.set_end(0);
+ break;
+ }
+
+ selectionRange.set_start(qMin(attribute.start, (attribute.start + attribute.length)));
+ selectionRange.set_end(qMax(attribute.start, (attribute.start + attribute.length)));
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (!selectionRange.IsValid()) {
+ // We did not receive a valid selection range, hence the range is going to mark the
+ // cursor position.
+ int newCursorPosition = (cursorPositionInPreeditString < 0) ? preeditString.length()
+ : cursorPositionInPreeditString;
+ selectionRange.set_start(newCursorPosition);
+ selectionRange.set_end(newCursorPosition);
+ }
+
+ if (hasSelection) {
+ content::mojom::FrameInputHandler *frameInputHandler = m_rwhv->getFrameInputHandler();
+ if (frameInputHandler)
+ frameInputHandler->SetEditableSelectionOffsets(selectionRange.start(),
+ selectionRange.end());
+ }
+
+ int replacementLength = event->replacementLength();
+ gfx::Range replacementRange = gfx::Range::InvalidRange();
+
+ if (replacementLength > 0) {
+ int replacementStart = event->replacementStart() < 0
+ ? m_cursorPosition + event->replacementStart()
+ : event->replacementStart();
+ if (replacementStart >= 0 && replacementStart < m_surroundingText.length())
+ replacementRange = gfx::Range(replacementStart, replacementStart + replacementLength);
+ }
+
+ // There are so-far two known cases, when an empty QInputMethodEvent is received.
+ // First one happens when backspace is used to remove the last character in the pre-edit
+ // string, thus signaling the end of the composition.
+ // The second one happens (on Windows) when a Korean char gets composed, but instead of
+ // the event having a commit string, both strings are empty, and the actual char is received
+ // as a QKeyEvent after the QInputMethodEvent is processed.
+ // In lieu of the second case, we can't simply cancel the composition on an empty event,
+ // and then add the Korean char when QKeyEvent is received, because that leads to text
+ // flickering in the textarea (or any other element).
+ // Instead we postpone the processing of the empty QInputMethodEvent by posting it
+ // to the same focused object, and cancelling the composition on the next event loop tick.
+ if (commitString.isEmpty() && preeditString.isEmpty() && replacementLength == 0) {
+ if (!m_receivedEmptyImeEvent && m_imeInProgress && !hasSelection) {
+ m_receivedEmptyImeEvent = true;
+ QInputMethodEvent *eventCopy = new QInputMethodEvent(*event);
+ QGuiApplication::postEvent(qApp->focusObject(), eventCopy);
+ } else {
+ m_receivedEmptyImeEvent = false;
+ if (m_imeInProgress) {
+ m_imeInProgress = false;
+ m_rwhv->host()->ImeCancelComposition();
+ }
+ }
+
+ return;
+ }
+
+ m_receivedEmptyImeEvent = false;
+
+ // Finish compostion: insert or erase text.
+ if (!commitString.isEmpty() || replacementLength > 0) {
+ m_rwhv->host()->ImeCommitText(toString16(commitString), underlines, replacementRange, 0);
+ m_imeInProgress = false;
+ }
+
+ // Update or start new composition.
+ // Be aware of that, we might get a commit string and a pre-edit string in a single event and
+ // this means a new composition.
+ if (!preeditString.isEmpty()) {
+ m_rwhv->host()->ImeSetComposition(toString16(preeditString), underlines, replacementRange,
+ selectionRange.start(), selectionRange.end());
+ m_imeInProgress = true;
+ }
+}
+
+void RenderWidgetHostViewQtDelegateClient::handleInputMethodQueryEvent(
+ QInputMethodQueryEvent *event)
+{
+ Qt::InputMethodQueries queries = event->queries();
+ for (uint i = 0; i < 32; ++i) {
+ Qt::InputMethodQuery query = (Qt::InputMethodQuery)(int)(queries & (1 << i));
+ if (query) {
+ QVariant v = inputMethodQuery(query);
+ event->setValue(query, v);
+ }
+ }
+ event->accept();
+}
+
+void RenderWidgetHostViewQtDelegateClient::clearPreviousTouchMotionState()
+{
+ m_previousTouchPoints.clear();
+ m_touchMotionStarted = false;
+}
+
+void RenderWidgetHostViewQtDelegateClient::selectionChanged()
+{
+ m_rwhv->resetInputManagerState();
+ ui::TextInputType type = m_rwhv->getTextInputType();
+ content::TextInputManager *text_input_manager = m_rwhv->GetTextInputManager();
+
+ // Handle text selection out of an input field
+ if (type == ui::TEXT_INPUT_TYPE_NONE) {
+ if (m_rwhv->GetSelectedText().empty() && m_emptyPreviousSelection)
+ return;
+
+ // Reset position values to emit selectionChanged signal when clearing text selection
+ // by clicking into an input field. These values are intended to be used by inputMethodQuery
+ // so they are not expected to be valid when selection is out of an input field.
+ m_anchorPositionWithinSelection = -1;
+ m_cursorPositionWithinSelection = -1;
+
+ m_emptyPreviousSelection = m_rwhv->GetSelectedText().empty();
+ m_rwhv->adapterClient()->selectionChanged();
+ return;
+ }
+
+ if (m_rwhv->GetSelectedText().empty()) {
+ // RenderWidgetHostViewQt::OnUpdateTextInputStateCalled() does not update the cursor
+ // position if the selection is cleared because TextInputState changes before the
+ // TextSelection change.
+ Q_ASSERT(text_input_manager->GetTextInputState());
+ m_cursorPosition = text_input_manager->GetTextInputState()->selection_start;
+ m_rwhv->delegate()->inputMethodStateChanged(true /*editorVisible*/,
+ type == ui::TEXT_INPUT_TYPE_PASSWORD);
+
+ m_anchorPositionWithinSelection = m_cursorPosition;
+ m_cursorPositionWithinSelection = m_cursorPosition;
+
+ if (!m_emptyPreviousSelection) {
+ m_emptyPreviousSelection = true;
+ m_rwhv->adapterClient()->selectionChanged();
+ }
+
+ return;
+ }
+
+ const content::TextInputManager::TextSelection *selection =
+ text_input_manager->GetTextSelection();
+ if (!selection)
+ return;
+
+ if (!selection->range().IsValid())
+ return;
+
+ int newAnchorPositionWithinSelection = 0;
+ int newCursorPositionWithinSelection = 0;
+
+ if (text_input_manager->GetSelectionRegion()->anchor.type() == gfx::SelectionBound::RIGHT) {
+ newAnchorPositionWithinSelection = selection->range().GetMax() - selection->offset();
+ newCursorPositionWithinSelection = selection->range().GetMin() - selection->offset();
+ } else {
+ newAnchorPositionWithinSelection = selection->range().GetMin() - selection->offset();
+ newCursorPositionWithinSelection = selection->range().GetMax() - selection->offset();
+ }
+
+ if (m_anchorPositionWithinSelection == newAnchorPositionWithinSelection
+ && m_cursorPositionWithinSelection == newCursorPositionWithinSelection) {
+ return;
+ }
+
+ m_anchorPositionWithinSelection = newAnchorPositionWithinSelection;
+ m_cursorPositionWithinSelection = newCursorPositionWithinSelection;
+
+ if (!selection->selected_text().empty())
+ m_cursorPosition = newCursorPositionWithinSelection;
+
+ m_emptyPreviousSelection = selection->selected_text().empty();
+ m_rwhv->delegate()->inputMethodStateChanged(true /*editorVisible*/,
+ type == ui::TEXT_INPUT_TYPE_PASSWORD);
+ m_rwhv->adapterClient()->selectionChanged();
+}
+
+} // namespace QtWebEngineCore
diff --git a/src/core/render_widget_host_view_qt_delegate_client.h b/src/core/render_widget_host_view_qt_delegate_client.h
new file mode 100644
index 000000000..c338df95e
--- /dev/null
+++ b/src/core/render_widget_host_view_qt_delegate_client.h
@@ -0,0 +1,164 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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$
+**
+****************************************************************************/
+
+//
+// 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.
+//
+
+#ifndef RENDER_WIDGET_HOST_VIEW_QT_DELEGATE_CLIENT_H
+#define RENDER_WIDGET_HOST_VIEW_QT_DELEGATE_CLIENT_H
+
+#include "compositor/compositor.h"
+
+#include <QtGui/QCursor>
+#include <QtGui/QTouchEvent>
+
+QT_BEGIN_NAMESPACE
+class QEvent;
+class QVariant;
+class QMouseEvent;
+class QKeyEvent;
+class QTabletEvent;
+class QNativeGestureEvent;
+class QHoverEvent;
+class QFocusEvent;
+class QInputMethodEvent;
+class QInputMethodQueryEvent;
+QT_END_NAMESPACE
+
+namespace QtWebEngineCore {
+
+class RenderWidgetHostViewQt;
+
+struct MultipleMouseClickHelper
+{
+ QPoint lastPressPosition;
+ Qt::MouseButton lastPressButton = Qt::NoButton;
+ int clickCounter = 0;
+ ulong lastPressTimestamp = 0;
+};
+
+class Q_WEBENGINECORE_PRIVATE_EXPORT RenderWidgetHostViewQtDelegateClient
+{
+public:
+ RenderWidgetHostViewQtDelegateClient(RenderWidgetHostViewQt *rwhv);
+
+ Compositor::Id compositorId();
+ void notifyShown();
+ void notifyHidden();
+ void visualPropertiesChanged();
+ bool forwardEvent(QEvent *);
+ QVariant inputMethodQuery(Qt::InputMethodQuery query);
+ void closePopup();
+
+private:
+ friend class RenderWidgetHostViewQt;
+
+ template<class T>
+ void handlePointerEvent(T *);
+ void handleMouseEvent(QMouseEvent *);
+ void handleKeyEvent(QKeyEvent *);
+ void handleTouchEvent(QTouchEvent *);
+#if QT_CONFIG(tabletevent)
+ void handleTabletEvent(QTabletEvent *);
+#endif
+#if QT_CONFIG(gestures)
+ void handleGestureEvent(QNativeGestureEvent *);
+#endif
+ void handleHoverEvent(QHoverEvent *);
+ void handleFocusEvent(QFocusEvent *);
+ void handleInputMethodEvent(QInputMethodEvent *);
+ void handleInputMethodQueryEvent(QInputMethodQueryEvent *);
+
+ QRect viewRectInDips() const { return m_viewRectInDips; }
+ QRect windowRectInDips() const { return m_windowRectInDips; }
+
+ // Mouse
+ void resetPreviousMousePosition() { m_previousMousePosition = QCursor::pos(); }
+
+ // Touch
+ void clearPreviousTouchMotionState();
+
+ // IME
+ void selectionChanged();
+ void setCursorPosition(uint pos) { m_cursorPosition = pos; }
+ void setSurroundingText(const QString &text) { m_surroundingText = text; }
+ bool isPreviousSelectionEmpty() const { return m_emptyPreviousSelection; }
+
+ RenderWidgetHostViewQt *m_rwhv;
+
+ // Mouse
+ bool m_imeHasHiddenTextCapability;
+ uint m_mouseButtonPressed = 0;
+ QPoint m_previousMousePosition;
+ MultipleMouseClickHelper m_clickHelper;
+
+ // Key
+ std::string m_editCommand;
+
+ // Touch
+ QList<QTouchEvent::TouchPoint> m_previousTouchPoints;
+ bool m_touchMotionStarted = false;
+ bool m_sendMotionActionDown = false;
+
+ // IME
+ bool m_receivedEmptyImeEvent = false;
+ bool m_imeInProgress = false;
+ bool m_emptyPreviousSelection = true;
+ uint m_cursorPosition = 0;
+ int m_anchorPositionWithinSelection = -1;
+ int m_cursorPositionWithinSelection = -1;
+ QString m_surroundingText;
+
+ // Geometry of the view in screen DIPs.
+ QRect m_viewRectInDips;
+ // Geometry of the window, including frame, in screen DIPs.
+ QRect m_windowRectInDips;
+};
+
+} // namespace QtWebEngineCore
+
+#endif // RENDER_WIDGET_HOST_VIEW_QT_DELEGATE_CLIENT_H
diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp
index 428697936..3e9e8f299 100644
--- a/src/core/renderer/content_renderer_client_qt.cpp
+++ b/src/core/renderer/content_renderer_client_qt.cpp
@@ -292,7 +292,7 @@ void ContentRendererClientQt::GetNavigationErrorStringsInternal(content::RenderF
const error_page::Error &error,
std::string *errorHtml)
{
- Q_UNUSED(renderFrame)
+ Q_UNUSED(renderFrame);
const bool isPost = QByteArray::fromStdString(httpMethod) == QByteArrayLiteral("POST");
if (errorHtml) {
diff --git a/src/core/renderer/user_resource_controller.cpp b/src/core/renderer/user_resource_controller.cpp
index 5c1bd301f..3c1ad0477 100644
--- a/src/core/renderer/user_resource_controller.cpp
+++ b/src/core/renderer/user_resource_controller.cpp
@@ -197,8 +197,8 @@ void UserResourceController::runScripts(UserScriptData::InjectionPoint p, blink:
if (!renderView)
return;
- QList<uint64_t> scriptsToRun = m_viewUserScriptMap.value(0).toList();
- scriptsToRun.append(m_viewUserScriptMap.value(renderView).toList());
+ QList<uint64_t> scriptsToRun = m_viewUserScriptMap.value(0).values();
+ scriptsToRun.append(m_viewUserScriptMap.value(renderView).values());
for (uint64_t id : qAsConst(scriptsToRun)) {
const UserScriptData &script = m_scripts.value(id);
diff --git a/src/core/renderer/web_channel_ipc_transport.cpp b/src/core/renderer/web_channel_ipc_transport.cpp
index 1fb3bc678..496417329 100644
--- a/src/core/renderer/web_channel_ipc_transport.cpp
+++ b/src/core/renderer/web_channel_ipc_transport.cpp
@@ -152,22 +152,13 @@ void WebChannelTransport::NativeQtSendMessage(gin::Arguments *args)
return;
}
v8::Local<v8::String> jsonString = v8::Local<v8::String>::Cast(jsonValue);
+ std::vector<uint8_t> json(jsonString->Utf8Length(isolate), 0);
+ jsonString->WriteUtf8(isolate, reinterpret_cast<char *>(json.data()), json.size(), nullptr,
+ v8::String::REPLACE_INVALID_UTF8);
- QByteArray json(jsonString->Utf8Length(isolate), 0);
- jsonString->WriteUtf8(isolate, json.data(), json.size(), nullptr, v8::String::REPLACE_INVALID_UTF8);
-
- QJsonParseError error;
- QJsonDocument doc = QJsonDocument::fromJson(json, &error);
- if (error.error != QJsonParseError::NoError) {
- args->ThrowTypeError("Invalid JSON");
- return;
- }
-
- int size = 0;
- const char *rawData = doc.rawData(&size);
mojo::AssociatedRemote<qtwebchannel::mojom::WebChannelTransportHost> webChannelTransport;
renderFrame->GetRemoteAssociatedInterfaces()->GetInterface(&webChannelTransport);
- webChannelTransport->DispatchWebChannelMessage(std::vector<uint8_t>(rawData, rawData + size));
+ webChannelTransport->DispatchWebChannelMessage(json);
}
gin::ObjectTemplateBuilder WebChannelTransport::GetObjectTemplateBuilder(v8::Isolate *isolate)
@@ -213,18 +204,14 @@ void WebChannelIPCTransport::ResetWorldId()
m_worldId = 0;
}
-void WebChannelIPCTransport::DispatchWebChannelMessage(const std::vector<uint8_t> &binaryJson, uint32_t worldId)
+void WebChannelIPCTransport::DispatchWebChannelMessage(const std::vector<uint8_t> &json,
+ uint32_t worldId)
{
DCHECK(m_worldId == worldId);
if (!m_canUseContext)
return;
- QJsonDocument doc = QJsonDocument::fromRawData(reinterpret_cast<const char *>(binaryJson.data()), binaryJson.size(),
- QJsonDocument::BypassValidation);
- DCHECK(doc.isObject());
- QByteArray json = doc.toJson(QJsonDocument::Compact);
-
blink::WebLocalFrame *frame = render_frame()->GetWebFrame();
v8::Isolate *isolate = blink::MainThreadIsolate();
v8::HandleScope handleScope(isolate);
@@ -255,7 +242,9 @@ void WebChannelIPCTransport::DispatchWebChannelMessage(const std::vector<uint8_t
v8::Local<v8::Object> messageObject(v8::Object::New(isolate));
v8::Maybe<bool> wasSet = messageObject->DefineOwnProperty(
context, v8::String::NewFromUtf8(isolate, "data").ToLocalChecked(),
- v8::String::NewFromUtf8(isolate, json.constData(), v8::NewStringType::kNormal, json.size()).ToLocalChecked(),
+ v8::String::NewFromUtf8(isolate, reinterpret_cast<const char *>(json.data()),
+ v8::NewStringType::kNormal, json.size())
+ .ToLocalChecked(),
v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete));
DCHECK(!wasSet.IsNothing() && wasSet.FromJust());
diff --git a/src/core/renderer/web_channel_ipc_transport.h b/src/core/renderer/web_channel_ipc_transport.h
index 15778a7bc..7c3b21eec 100644
--- a/src/core/renderer/web_channel_ipc_transport.h
+++ b/src/core/renderer/web_channel_ipc_transport.h
@@ -61,7 +61,7 @@ private:
// qtwebchannel::mojom::WebChannelTransportRender
void SetWorldId(uint32_t worldId) override;
void ResetWorldId() override;
- void DispatchWebChannelMessage(const std::vector<uint8_t> &binaryJson, uint32_t worldId) override;
+ void DispatchWebChannelMessage(const std::vector<uint8_t> &json, uint32_t worldId) override;
// RenderFrameObserver
void WillReleaseScriptContext(v8::Local<v8::Context> context, int worldId) override;
diff --git a/src/core/renderer_host/web_channel_ipc_transport_host.cpp b/src/core/renderer_host/web_channel_ipc_transport_host.cpp
index 9ed3749ad..5d4356533 100644
--- a/src/core/renderer_host/web_channel_ipc_transport_host.cpp
+++ b/src/core/renderer_host/web_channel_ipc_transport_host.cpp
@@ -93,13 +93,13 @@ uint WebChannelIPCTransportHost::worldId() const
void WebChannelIPCTransportHost::sendMessage(const QJsonObject &message)
{
QJsonDocument doc(message);
- int size = 0;
- const char *rawData = doc.rawData(&size);
+ QByteArray json = doc.toJson(QJsonDocument::Compact);
content::RenderFrameHost *frame = web_contents()->GetMainFrame();
mojo::AssociatedRemote<qtwebchannel::mojom::WebChannelTransportRender> webChannelTransport;
frame->GetRemoteAssociatedInterfaces()->GetInterface(&webChannelTransport);
qCDebug(log).nospace() << "sending webchannel message to " << frame << ": " << doc;
- webChannelTransport->DispatchWebChannelMessage(std::vector<uint8_t>(rawData, rawData + size), m_worldId);
+ webChannelTransport->DispatchWebChannelMessage(std::vector<uint8_t>(json.begin(), json.end()),
+ m_worldId);
}
void WebChannelIPCTransportHost::setWorldId(uint32_t worldId)
@@ -132,7 +132,7 @@ void WebChannelIPCTransportHost::resetWorldId()
}
}
-void WebChannelIPCTransportHost::DispatchWebChannelMessage(const std::vector<uint8_t> &binaryJson)
+void WebChannelIPCTransportHost::DispatchWebChannelMessage(const std::vector<uint8_t> &json)
{
content::RenderFrameHost *frame = web_contents()->GetMainFrame();
@@ -140,7 +140,8 @@ void WebChannelIPCTransportHost::DispatchWebChannelMessage(const std::vector<uin
return;
}
- QJsonDocument doc = QJsonDocument::fromRawData(reinterpret_cast<const char *>(binaryJson.data()), binaryJson.size());
+ QJsonDocument doc = QJsonDocument::fromJson(
+ QByteArray(reinterpret_cast<const char *>(json.data()), json.size()));
if (!doc.isObject()) {
qCCritical(log).nospace() << "received invalid webchannel message from " << frame;
diff --git a/src/core/renderer_host/web_channel_ipc_transport_host.h b/src/core/renderer_host/web_channel_ipc_transport_host.h
index a1575355a..3d15082b8 100644
--- a/src/core/renderer_host/web_channel_ipc_transport_host.h
+++ b/src/core/renderer_host/web_channel_ipc_transport_host.h
@@ -70,13 +70,12 @@ public:
private:
void setWorldId(content::RenderFrameHost *frame, uint32_t worldId);
void resetWorldId();
- void onWebChannelMessage(const std::vector<char> &message);
// WebContentsObserver
void RenderFrameCreated(content::RenderFrameHost *frame) override;
// qtwebchannel::mojom::WebChannelTransportHost
- void DispatchWebChannelMessage(const std::vector<uint8_t> &binaryJson) override;
+ void DispatchWebChannelMessage(const std::vector<uint8_t> &json) override;
// Empty only during construction/destruction. Synchronized to all the
// WebChannelIPCTransports/RenderFrames in the observed WebContents.
diff --git a/src/core/type_conversion.cpp b/src/core/type_conversion.cpp
index 403125784..de507f836 100644
--- a/src/core/type_conversion.cpp
+++ b/src/core/type_conversion.cpp
@@ -296,4 +296,40 @@ QList<QSslCertificate> toCertificateChain(net::X509Certificate *certificate)
return chain;
}
+Qt::InputMethodHints toQtInputMethodHints(ui::TextInputType inputType)
+{
+ switch (inputType) {
+ case ui::TEXT_INPUT_TYPE_TEXT:
+ return Qt::ImhPreferLowercase;
+ case ui::TEXT_INPUT_TYPE_SEARCH:
+ return Qt::ImhPreferLowercase | Qt::ImhNoAutoUppercase;
+ case ui::TEXT_INPUT_TYPE_PASSWORD:
+ return Qt::ImhSensitiveData | Qt::ImhNoPredictiveText | Qt::ImhNoAutoUppercase
+ | Qt::ImhHiddenText;
+ case ui::TEXT_INPUT_TYPE_EMAIL:
+ return Qt::ImhEmailCharactersOnly;
+ case ui::TEXT_INPUT_TYPE_NUMBER:
+ return Qt::ImhFormattedNumbersOnly;
+ case ui::TEXT_INPUT_TYPE_TELEPHONE:
+ return Qt::ImhDialableCharactersOnly;
+ case ui::TEXT_INPUT_TYPE_URL:
+ return Qt::ImhUrlCharactersOnly | Qt::ImhNoPredictiveText | Qt::ImhNoAutoUppercase;
+ case ui::TEXT_INPUT_TYPE_DATE_TIME:
+ case ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL:
+ case ui::TEXT_INPUT_TYPE_DATE_TIME_FIELD:
+ return Qt::ImhDate | Qt::ImhTime;
+ case ui::TEXT_INPUT_TYPE_DATE:
+ case ui::TEXT_INPUT_TYPE_MONTH:
+ case ui::TEXT_INPUT_TYPE_WEEK:
+ return Qt::ImhDate;
+ case ui::TEXT_INPUT_TYPE_TIME:
+ return Qt::ImhTime;
+ case ui::TEXT_INPUT_TYPE_TEXT_AREA:
+ case ui::TEXT_INPUT_TYPE_CONTENT_EDITABLE:
+ return Qt::ImhMultiLine | Qt::ImhPreferLowercase;
+ default:
+ return Qt::ImhNone;
+ }
+}
+
} // namespace QtWebEngineCore
diff --git a/src/core/type_conversion.h b/src/core/type_conversion.h
index 2275ae82e..703b62188 100644
--- a/src/core/type_conversion.h
+++ b/src/core/type_conversion.h
@@ -59,6 +59,7 @@
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkPixelRef.h"
#include "third_party/skia/include/core/SkMatrix44.h"
+#include "ui/base/ime/text_input_type.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_f.h"
#include "url/gurl.h"
@@ -83,9 +84,9 @@ namespace QtWebEngineCore {
inline QString toQt(const base::string16 &string)
{
#if defined(OS_WIN)
- return QString::fromStdWString(string.data());
+ return QString::fromStdWString(string);
#else
- return QString::fromUtf16(string.data());
+ return QString::fromUtf16(reinterpret_cast<const char16_t *>(string.data()), string.size());
#endif
}
@@ -298,6 +299,8 @@ FaviconInfo toFaviconInfo(const content::FaviconURL &);
QList<QSslCertificate> toCertificateChain(net::X509Certificate *certificate);
+Qt::InputMethodHints toQtInputMethodHints(ui::TextInputType inputType);
+
} // namespace QtWebEngineCore
#endif // TYPE_CONVERSION_H
diff --git a/src/core/visited_links_manager_qt.h b/src/core/visited_links_manager_qt.h
index c4e24ce1f..27d46f8ff 100644
--- a/src/core/visited_links_manager_qt.h
+++ b/src/core/visited_links_manager_qt.h
@@ -55,9 +55,7 @@
#include <QList>
#include <QScopedPointer>
-QT_BEGIN_NAMESPACE
-class QUrl;
-QT_END_NAMESPACE
+QT_FORWARD_DECLARE_CLASS(QUrl)
namespace visitedlink {
class VisitedLinkWriter;
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index ef482ef08..2005cdce9 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -115,6 +115,7 @@
#include <QtCore/qmimedata.h>
#include <QtCore/qtemporarydir.h>
#include <QtGui/qdrag.h>
+#include <QtGui/QDragEnterEvent>
#include <QtGui/qpixmap.h>
// Can't include headers as qaccessible.h conflicts with Chromium headers.
@@ -714,8 +715,8 @@ void WebContentsAdapter::load(const QWebEngineHttpRequest &request)
}
// convert the custom headers into the format that chromium expects
- QVector<QByteArray> headers = request.headers();
- for (QVector<QByteArray>::const_iterator it = headers.cbegin(); it != headers.cend(); ++it) {
+ QList<QByteArray> headers = request.headers();
+ for (QList<QByteArray>::const_iterator it = headers.cbegin(); it != headers.cend(); ++it) {
if (params.extra_headers.length() > 0)
params.extra_headers += '\n';
params.extra_headers += (*it).toStdString() + ": " + request.header(*it).toStdString();
@@ -1112,7 +1113,6 @@ void WebContentsAdapter::download(const QUrl &url, const QString &suggestedFileN
if (!dlm)
return;
- dlmd->markNextDownloadAsUserRequested();
dlm->SetDelegate(dlmd);
net::NetworkTrafficAnnotationTag traffic_annotation =
@@ -1635,19 +1635,19 @@ void WebContentsAdapter::enterDrag(QDragEnterEvent *e, const QPointF &screenPos)
content::RenderViewHost *rvh = m_webContents->GetRenderViewHost();
rvh->GetWidget()->FilterDropData(m_currentDropData.get());
- rvh->GetWidget()->DragTargetDragEnter(*m_currentDropData, toGfx(e->posF()), toGfx(screenPos),
+ rvh->GetWidget()->DragTargetDragEnter(*m_currentDropData, toGfx(e->position()), toGfx(screenPos),
toWeb(e->possibleActions()),
- toWeb(e->mouseButtons()) | toWeb(e->keyboardModifiers()));
+ toWeb(e->buttons()) | toWeb(e->modifiers()));
}
Qt::DropAction WebContentsAdapter::updateDragPosition(QDragMoveEvent *e, const QPointF &screenPos)
{
CHECK_INITIALIZED(Qt::DropAction());
content::RenderViewHost *rvh = m_webContents->GetRenderViewHost();
- m_lastDragClientPos = e->posF();
+ m_lastDragClientPos = e->position();
m_lastDragScreenPos = screenPos;
rvh->GetWidget()->DragTargetDragOver(toGfx(m_lastDragClientPos), toGfx(m_lastDragScreenPos), toWeb(e->possibleActions()),
- toWeb(e->mouseButtons()) | toWeb(e->keyboardModifiers()));
+ toWeb(e->buttons()) | toWeb(e->modifiers()));
waitForUpdateDragActionCalled();
return toQt(blink::WebDragOperation(m_currentDropAction));
}
@@ -1690,10 +1690,10 @@ void WebContentsAdapter::endDragging(QDropEvent *e, const QPointF &screenPos)
CHECK_INITIALIZED();
content::RenderViewHost *rvh = m_webContents->GetRenderViewHost();
rvh->GetWidget()->FilterDropData(m_currentDropData.get());
- m_lastDragClientPos = e->posF();
+ m_lastDragClientPos = e->position();
m_lastDragScreenPos = screenPos;
rvh->GetWidget()->DragTargetDrop(*m_currentDropData, toGfx(m_lastDragClientPos), toGfx(m_lastDragScreenPos),
- toWeb(e->mouseButtons()) | toWeb(e->keyboardModifiers()));
+ toWeb(e->buttons()) | toWeb(e->modifiers()));
m_currentDropData.reset();
}
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index d833314f2..acf65f4d5 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -52,6 +52,7 @@
#define WEB_CONTENTS_ADAPTER_H
#include "qtwebenginecoreglobal_p.h"
+#include "qwebenginecontextmenurequest_p.h"
#include "web_contents_adapter_client.h"
#include <memory>
#include <QtGui/qtgui-config.h>
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index 04df99f0e..13f1a4563 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -57,13 +57,10 @@
#include <QFlags>
#include <QRect>
-#include <QSharedPointer>
#include <QString>
#include <QStringList>
#include <QUrl>
-QT_FORWARD_DECLARE_CLASS(CertificateErrorController)
-QT_FORWARD_DECLARE_CLASS(ClientCertSelectController)
QT_FORWARD_DECLARE_CLASS(QKeyEvent)
QT_FORWARD_DECLARE_CLASS(QVariant)
QT_FORWARD_DECLARE_CLASS(QWebEngineFindTextResult)
@@ -71,6 +68,8 @@ QT_FORWARD_DECLARE_CLASS(QWebEngineQuotaRequest)
QT_FORWARD_DECLARE_CLASS(QWebEngineRegisterProtocolHandlerRequest)
QT_FORWARD_DECLARE_CLASS(QWebEngineUrlRequestInfo)
QT_FORWARD_DECLARE_CLASS(QWebEngineUrlRequestInterceptor)
+QT_FORWARD_DECLARE_CLASS(QWebEngineContextMenuRequest)
+QT_FORWARD_DECLARE_CLASS(QWebEngineCertificateError);
namespace content {
struct DropData;
@@ -78,6 +77,8 @@ struct DropData;
namespace QtWebEngineCore {
+class CertificateErrorController;
+class ClientCertSelectController;
class AuthenticationDialogController;
class ColorChooserController;
class FilePickerController;
@@ -91,279 +92,6 @@ class WebContentsAdapter;
class WebContentsDelegateQt;
class WebEngineSettings;
-// Must match blink::WebReferrerPolicy
-enum class ReferrerPolicy {
- Always,
- Default,
- NoReferrerWhenDowngrade,
- Never,
- Origin,
- OriginWhenCrossOrigin,
- NoReferrerWhenDowngradeOriginWhenCrossOrigin,
- SameOrigin,
- StrictOrigin,
- Last = StrictOrigin,
-};
-
-class WebEngineContextMenuSharedData : public QSharedData {
-
-public:
- WebEngineContextMenuSharedData()
- : hasImageContent(false)
- , isEditable(false)
- , isSpellCheckerEnabled(false)
- , mediaType(0)
- , mediaFlags(0)
- , editFlags(0)
- {
- }
- bool hasImageContent;
- bool isEditable;
- bool isSpellCheckerEnabled;
- uint mediaType;
- uint mediaFlags;
- uint editFlags;
- QPoint pos;
- QUrl linkUrl;
- QUrl unfilteredLinkUrl;
- QUrl mediaUrl;
- QString altText;
- QString linkText;
- QString titleText;
- QString selectedText;
- QString suggestedFileName;
- QString misspelledWord;
- QStringList spellCheckerSuggestions;
- QUrl pageUrl;
- QUrl frameUrl;
- ReferrerPolicy referrerPolicy = ReferrerPolicy::Default;
- // Some likely candidates for future additions as we add support for the related actions:
- // bool isImageBlocked;
- // <enum tbd> mediaType;
- // ...
-};
-
-class WebEngineContextMenuData {
-public:
- // Must match blink::WebContextMenuData::MediaType:
- enum MediaType {
- // No special node is in context.
- MediaTypeNone = 0x0,
- // An image node is selected.
- MediaTypeImage,
- // A video node is selected.
- MediaTypeVideo,
- // An audio node is selected.
- MediaTypeAudio,
- // A canvas node is selected.
- MediaTypeCanvas,
- // A file node is selected.
- MediaTypeFile,
- // A plugin node is selected.
- MediaTypePlugin,
- MediaTypeLast = MediaTypePlugin
- };
- // Must match blink::WebContextMenuData::MediaFlags:
- enum MediaFlags {
- MediaNone = 0x0,
- MediaInError = 0x1,
- MediaPaused = 0x2,
- MediaMuted = 0x4,
- MediaLoop = 0x8,
- MediaCanSave = 0x10,
- MediaHasAudio = 0x20,
- MediaCanToggleControls = 0x40,
- MediaControls = 0x80,
- MediaCanPrint = 0x100,
- MediaCanRotate = 0x200,
- };
-
- // Must match blink::WebContextMenuData::EditFlags:
- enum EditFlags {
- CanDoNone = 0x0,
- CanUndo = 0x1,
- CanRedo = 0x2,
- CanCut = 0x4,
- CanCopy = 0x8,
- CanPaste = 0x10,
- CanDelete = 0x20,
- CanSelectAll = 0x40,
- CanTranslate = 0x80,
- CanEditRichly = 0x100,
- };
-
- WebEngineContextMenuData():d(new WebEngineContextMenuSharedData) {
- }
-
- void setPosition(const QPoint &pos) {
- d->pos = pos;
- }
-
- QPoint position() const {
- return d->pos;
- }
-
- void setLinkUrl(const QUrl &url) {
- d->linkUrl = url;
- }
-
- QUrl linkUrl() const {
- return d->linkUrl;
- }
-
- void setUnfilteredLinkUrl(const QUrl &url) {
- d->unfilteredLinkUrl = url;
- }
-
- QUrl unfilteredLinkUrl() const {
- return d->unfilteredLinkUrl;
- }
-
- void setAltText(const QString &text) {
- d->altText = text;
- }
-
- QString altText() const {
- return d->altText;
- }
-
- void setLinkText(const QString &text) {
- d->linkText = text;
- }
-
- QString linkText() const {
- return d->linkText;
- }
-
- void setTitleText(const QString &text) {
- d->titleText = text;
- }
-
- QString titleText() const {
- return d->titleText;
- }
-
- void setSelectedText(const QString &text) {
- d->selectedText = text;
- }
-
- QString selectedText() const {
- return d->selectedText;
- }
-
- void setMediaUrl(const QUrl &url) {
- d->mediaUrl = url;
- }
-
- QUrl mediaUrl() const {
- return d->mediaUrl;
- }
-
- void setMediaType(MediaType type) {
- d->mediaType = type;
- }
-
- MediaType mediaType() const {
- return MediaType(d->mediaType);
- }
-
- void setHasImageContent(bool imageContent) {
- d->hasImageContent = imageContent;
- }
-
- bool hasImageContent() const {
- return d->hasImageContent;
- }
-
- void setMediaFlags(MediaFlags flags) {
- d->mediaFlags = flags;
- }
-
- MediaFlags mediaFlags() const {
- return MediaFlags(d->mediaFlags);
- }
-
- void setEditFlags(EditFlags flags) {
- d->editFlags = flags;
- }
-
- EditFlags editFlags() const {
- return EditFlags(d->editFlags);
- }
-
- void setSuggestedFileName(const QString &filename) {
- d->suggestedFileName = filename;
- }
-
- QString suggestedFileName() const {
- return d->suggestedFileName;
- }
-
- void setIsEditable(bool editable) {
- d->isEditable = editable;
- }
-
- bool isEditable() const {
- return d->isEditable;
- }
-
- void setIsSpellCheckerEnabled(bool spellCheckerEnabled) {
- d->isSpellCheckerEnabled = spellCheckerEnabled;
- }
-
- bool isSpellCheckerEnabled() const {
- return d->isSpellCheckerEnabled;
- }
-
- void setMisspelledWord(const QString &word) {
- d->misspelledWord = word;
- }
-
- QString misspelledWord() const {
- return d->misspelledWord;
- }
-
- void setSpellCheckerSuggestions(const QStringList &suggestions) {
- d->spellCheckerSuggestions = suggestions;
- }
-
- QStringList spellCheckerSuggestions() const {
- return d->spellCheckerSuggestions;
- }
-
- void setFrameUrl(const QUrl &url) {
- d->frameUrl = url;
- }
-
- QUrl frameUrl() const {
- return d->frameUrl;
- }
-
- void setPageUrl(const QUrl &url) {
- d->pageUrl = url;
- }
-
- QUrl pageUrl() const {
- return d->pageUrl;
- }
-
- QUrl referrerUrl() const {
- return !d->frameUrl.isEmpty() ? d->frameUrl : d->pageUrl;
- }
-
- void setReferrerPolicy(ReferrerPolicy referrerPolicy) {
- d->referrerPolicy = referrerPolicy;
- }
-
- ReferrerPolicy referrerPolicy() const {
- return d->referrerPolicy;
- }
-
-private:
- QSharedDataPointer<WebEngineContextMenuSharedData> d;
-};
-
-
class Q_WEBENGINECORE_PRIVATE_EXPORT WebContentsAdapterClient {
public:
// This must match window_open_disposition_list.h.
@@ -465,7 +193,7 @@ public:
virtual QColor backgroundColor() const = 0;
virtual void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) = 0;
virtual void loadCommitted() = 0;
- virtual void loadVisuallyCommitted() = 0;
+ virtual void didFirstVisuallyNonEmptyPaint() = 0;
virtual void loadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()) = 0;
virtual void focusContainer() = 0;
virtual void unhandledKeyEvent(QKeyEvent *event) = 0;
@@ -476,7 +204,7 @@ public:
virtual bool isBeingAdopted() = 0;
virtual void close() = 0;
virtual void windowCloseRejected() = 0;
- virtual void contextMenuRequested(const WebEngineContextMenuData &) = 0;
+ virtual void contextMenuRequested(QWebEngineContextMenuRequest *request) = 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;
@@ -503,7 +231,7 @@ public:
RenderProcessTerminationStatus renderProcessExitStatus(int);
virtual void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode) = 0;
virtual void requestGeometryChange(const QRect &geometry, const QRect &frameGeometry) = 0;
- virtual void allowCertificateError(const QSharedPointer<CertificateErrorController> &errorController) = 0;
+ virtual void allowCertificateError(const QWebEngineCertificateError &error) = 0;
virtual void selectClientCert(const QSharedPointer<ClientCertSelectController> &selectController) = 0;
virtual void updateScrollPosition(const QPointF &position) = 0;
virtual void updateContentsSize(const QSizeF &size) = 0;
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index f13621b99..5318cdf1b 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -60,7 +60,7 @@
#include "web_contents_view_qt.h"
#include "web_engine_context.h"
#include "web_engine_settings.h"
-
+#include "certificate_error_controller.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
#include "components/web_cache/browser/web_cache_manager.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
@@ -233,7 +233,7 @@ QUrl WebContentsDelegateQt::url(content::WebContents* source) const {
}
void WebContentsDelegateQt::AddNewContents(content::WebContents* source, std::unique_ptr<content::WebContents> new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture, bool* was_blocked)
{
- Q_UNUSED(source)
+ Q_UNUSED(source);
QSharedPointer<WebContentsAdapter> newAdapter = createWindow(std::move(new_contents), disposition, initial_pos, user_gesture);
// Chromium can forget to pass user-agent override settings to new windows (see QTBUG-61774 and QTBUG-76249),
// so set it here. Note the actual value doesn't really matter here. Only the second value does, but we try
@@ -336,6 +336,10 @@ void WebContentsDelegateQt::EmitLoadStarted(const QUrl &url, bool isErrorPage)
{
if (m_lastLoadProgress >= 0 && m_lastLoadProgress < 100) // already running
return;
+ for (auto &&wc : m_certificateErrorControllers)
+ if (auto controller = wc.lock())
+ controller->deactivate();
+ m_certificateErrorControllers.clear();
m_viewClient->loadStarted(url, isErrorPage);
m_viewClient->updateNavigationActions();
m_viewClient->loadProgressChanged(0);
@@ -589,7 +593,7 @@ void WebContentsDelegateQt::RunFileChooser(content::RenderFrameHost * /*frameHos
bool WebContentsDelegateQt::DidAddMessageToConsole(content::WebContents *source, blink::mojom::ConsoleMessageLevel log_level,
const base::string16 &message, int32_t line_no, const base::string16 &source_id)
{
- Q_UNUSED(source)
+ Q_UNUSED(source);
m_viewClient->javaScriptConsoleMessage(mapToJavascriptConsoleMessageLevel(log_level), toQt(message), static_cast<int>(line_no), toQt(source_id));
return false;
}
@@ -620,7 +624,7 @@ void WebContentsDelegateQt::SetContentsBounds(content::WebContents *source, cons
void WebContentsDelegateQt::UpdateTargetURL(content::WebContents* source, const GURL& url)
{
- Q_UNUSED(source)
+ Q_UNUSED(source);
m_viewClient->didUpdateTargetURL(toQt(url));
}
@@ -674,9 +678,15 @@ WebContentsDelegateQt::createWindow(std::unique_ptr<content::WebContents> new_co
toQt(initial_pos), m_initialTargetUrl);
}
-void WebContentsDelegateQt::allowCertificateError(const QSharedPointer<CertificateErrorController> &errorController)
+void WebContentsDelegateQt::allowCertificateError(
+ const QSharedPointer<CertificateErrorController> &controller)
{
- m_viewClient->allowCertificateError(errorController);
+ QWebEngineCertificateError error(controller);
+ m_viewClient->allowCertificateError(error);
+ if (!error.isOverridable() || (!controller->deferred() && !controller->answered()))
+ error.rejectCertificate();
+ else
+ m_certificateErrorControllers.append(controller);
}
void WebContentsDelegateQt::selectClientCert(const QSharedPointer<ClientCertSelectController> &selectController)
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h
index 8a9d8be1b..86b697488 100644
--- a/src/core/web_contents_delegate_qt.h
+++ b/src/core/web_contents_delegate_qt.h
@@ -52,11 +52,8 @@
#include "favicon_manager.h"
#include "find_text_helper.h"
#include "javascript_dialog_manager_qt.h"
-
-#include <QtCore/qvector.h>
-
-QT_FORWARD_DECLARE_CLASS(CertificateErrorController)
-QT_FORWARD_DECLARE_CLASS(ClientCertSelectController)
+#include <QtCore/qlist.h>
+#include <QWebEngineCertificateError>
namespace content {
class ColorChooser;
@@ -87,7 +84,7 @@ protected:
private:
WebContentsAdapterClient *m_viewClient;
- QVector<content::FrameTreeNode *> m_observedNodes;
+ QList<content::FrameTreeNode *> m_observedNodes;
};
class SavePageInfo
@@ -216,7 +213,7 @@ private:
int &streamCount(blink::mojom::MediaStreamType type);
WebContentsAdapterClient *m_viewClient;
- QVector<int64_t> m_loadingErrorFrameList;
+ QList<int64_t> m_loadingErrorFrameList;
QScopedPointer<FaviconManager> m_faviconManager;
QScopedPointer<FindTextHelper> m_findTextHelper;
SavePageInfo m_savePageInfo;
@@ -235,6 +232,7 @@ private:
mutable bool m_pendingUrlUpdate = false;
base::WeakPtrFactory<WebContentsDelegateQt> m_weakPtrFactory { this };
+ QList<QWeakPointer<CertificateErrorController>> m_certificateErrorControllers;
};
} // namespace QtWebEngineCore
diff --git a/src/core/web_contents_view_qt.cpp b/src/core/web_contents_view_qt.cpp
index 7f6bfe34f..7a42977fe 100644
--- a/src/core/web_contents_view_qt.cpp
+++ b/src/core/web_contents_view_qt.cpp
@@ -73,7 +73,7 @@ void WebContentsViewQt::setFactoryClient(WebContentsAdapterClient* client)
// Check if a RWHV was created before the pre-initialization.
if (auto view = static_cast<RenderWidgetHostViewQt *>(m_webContents->GetRenderWidgetHostView())) {
- view->setDelegate(m_factoryClient->CreateRenderWidgetHostViewQtDelegate(view));
+ view->setDelegate(m_factoryClient->CreateRenderWidgetHostViewQtDelegate(view->delegateClient()));
}
}
@@ -94,7 +94,7 @@ content::RenderWidgetHostViewBase* WebContentsViewQt::CreateViewForWidget(conten
RenderWidgetHostViewQt *view = new RenderWidgetHostViewQt(render_widget_host);
if (m_factoryClient) {
- view->setDelegate(m_factoryClient->CreateRenderWidgetHostViewQtDelegate(view));
+ view->setDelegate(m_factoryClient->CreateRenderWidgetHostViewQtDelegate(view->delegateClient()));
if (m_client)
view->setAdapterClient(m_client);
}
@@ -107,7 +107,7 @@ content::RenderWidgetHostViewBase* WebContentsViewQt::CreateViewForChildWidget(c
RenderWidgetHostViewQt *view = new RenderWidgetHostViewQt(render_widget_host);
Q_ASSERT(m_client);
- view->setDelegate(m_client->CreateRenderWidgetHostViewQtDelegateForPopup(view));
+ view->setDelegate(m_client->CreateRenderWidgetHostViewQtDelegateForPopup(view->delegateClient()));
view->setAdapterClient(m_client);
return view;
@@ -159,73 +159,85 @@ void WebContentsViewQt::FocusThroughTabTraversal(bool reverse)
web_contents->GetRenderViewHost()->SetInitialFocus(reverse);
}
-
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeNone, blink::ContextMenuDataMediaType::kNone)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeImage, blink::ContextMenuDataMediaType::kImage)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeVideo, blink::ContextMenuDataMediaType::kVideo)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeAudio, blink::ContextMenuDataMediaType::kAudio)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeCanvas, blink::ContextMenuDataMediaType::kCanvas)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeFile, blink::ContextMenuDataMediaType::kFile)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypePlugin, blink::ContextMenuDataMediaType::kPlugin)
-
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaNone, blink::WebContextMenuData::kMediaNone)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaInError, blink::WebContextMenuData::kMediaInError)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaPaused, blink::WebContextMenuData::kMediaPaused)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaMuted, blink::WebContextMenuData::kMediaMuted)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaLoop, blink::WebContextMenuData::kMediaLoop)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaCanSave, blink::WebContextMenuData::kMediaCanSave)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaHasAudio, blink::WebContextMenuData::kMediaHasAudio)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaCanToggleControls, blink::WebContextMenuData::kMediaCanToggleControls)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaControls, blink::WebContextMenuData::kMediaControls)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaCanPrint, blink::WebContextMenuData::kMediaCanPrint)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaCanRotate, blink::WebContextMenuData::kMediaCanRotate)
-
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanDoNone, blink::kCanDoNone)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanUndo, blink::kCanUndo)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanRedo, blink::kCanRedo)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanCut, blink::kCanCut)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanCopy, blink::kCanCopy)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanPaste, blink::kCanPaste)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanDelete, blink::kCanDelete)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanSelectAll, blink::kCanSelectAll)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanTranslate, blink::kCanTranslate)
-ASSERT_ENUMS_MATCH(WebEngineContextMenuData::CanEditRichly, blink::kCanEditRichly)
-
-static inline WebEngineContextMenuData fromParams(const content::ContextMenuParams &params)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaTypeNone,
+ blink::ContextMenuDataMediaType::kNone)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaTypeImage,
+ blink::ContextMenuDataMediaType::kImage)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaTypeVideo,
+ blink::ContextMenuDataMediaType::kVideo)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaTypeAudio,
+ blink::ContextMenuDataMediaType::kAudio)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaTypeCanvas,
+ blink::ContextMenuDataMediaType::kCanvas)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaTypeFile,
+ blink::ContextMenuDataMediaType::kFile)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaTypePlugin,
+ blink::ContextMenuDataMediaType::kPlugin)
+
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaInError,
+ blink::WebContextMenuData::kMediaInError)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaPaused,
+ blink::WebContextMenuData::kMediaPaused)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaMuted, blink::WebContextMenuData::kMediaMuted)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaLoop, blink::WebContextMenuData::kMediaLoop)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaCanSave,
+ blink::WebContextMenuData::kMediaCanSave)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaHasAudio,
+ blink::WebContextMenuData::kMediaHasAudio)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaCanToggleControls,
+ blink::WebContextMenuData::kMediaCanToggleControls)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaControls,
+ blink::WebContextMenuData::kMediaControls)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaCanPrint,
+ blink::WebContextMenuData::kMediaCanPrint)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaCanRotate,
+ blink::WebContextMenuData::kMediaCanRotate)
+
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::CanUndo, blink::kCanUndo)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::CanRedo, blink::kCanRedo)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::CanCut, blink::kCanCut)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::CanCopy, blink::kCanCopy)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::CanPaste, blink::kCanPaste)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::CanDelete, blink::kCanDelete)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::CanSelectAll, blink::kCanSelectAll)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::CanTranslate, blink::kCanTranslate)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::CanEditRichly, blink::kCanEditRichly)
+
+
+WebContentsViewQt::WebContentsViewQt(content::WebContents* webContents)
+: m_webContents(webContents)
+ , m_client(nullptr)
+ , m_factoryClient(nullptr)
+ , m_contextMenuRequest(
+ new QWebEngineContextMenuRequest(new QWebEngineContextMenuRequestPrivate()))
+{ }
+
+
+void WebContentsViewQt::update(QWebEngineContextMenuRequest *request,
+ const content::ContextMenuParams &params, bool spellcheckEnabled)
{
- WebEngineContextMenuData ret;
- ret.setPosition(QPoint(params.x, params.y));
- ret.setLinkUrl(toQt(params.link_url));
- ret.setLinkText(toQt(params.link_text.data()));
- ret.setAltText(toQt(params.alt_text.data()));
- ret.setTitleText(toQt(params.title_text.data()));
- ret.setUnfilteredLinkUrl(toQt(params.unfiltered_link_url));
- ret.setSelectedText(toQt(params.selection_text.data()));
- ret.setMediaUrl(toQt(params.src_url));
- ret.setMediaType((WebEngineContextMenuData::MediaType)params.media_type);
- ret.setHasImageContent(params.has_image_contents);
- ret.setMediaFlags((WebEngineContextMenuData::MediaFlags)params.media_flags);
- ret.setEditFlags((WebEngineContextMenuData::EditFlags)params.edit_flags);
- ret.setSuggestedFileName(toQt(params.suggested_filename.data()));
- ret.setIsEditable(params.is_editable);
+ auto *re = request->d.data();
+ re->m_position = QPoint(params.x, params.y);
+ re->m_filteredLinkUrl = toQt(params.link_url);
+ re->m_linkText = toQt(params.link_text.data());
+ re->m_altText = toQt(params.alt_text.data());
+ re->m_titleText = toQt(params.title_text.data());
+ re->m_unfilteredLinkUrl = toQt(params.unfiltered_link_url);
+ re->m_selectedText = toQt(params.selection_text.data());
+ re->m_mediaUrl = toQt(params.src_url);
+ re->m_mediaType = (QWebEngineContextMenuRequest::MediaType)params.media_type;
+ re->m_hasImageContent = params.has_image_contents;
+ re->m_mediaFlags = (QWebEngineContextMenuRequest::MediaFlags)params.media_flags;
+ re->m_editFlags = (QWebEngineContextMenuRequest::EditFlags)params.edit_flags;
+ re->m_suggestedFileName = toQt(params.suggested_filename.data());
+ re->m_isEditable = params.is_editable;
#if QT_CONFIG(webengine_spellchecker)
- ret.setMisspelledWord(toQt(params.misspelled_word));
- ret.setSpellCheckerSuggestions(fromVector(params.dictionary_suggestions));
+ re->m_misspelledWord = toQt(params.misspelled_word);
+ re->m_spellCheckerSuggestions = fromVector(params.dictionary_suggestions);
#endif
- ret.setFrameUrl(toQt(params.frame_url));
- ret.setPageUrl(toQt(params.page_url));
- ret.setReferrerPolicy((ReferrerPolicy)params.referrer_policy);
- return ret;
-}
-
-void WebContentsViewQt::ShowContextMenu(content::RenderFrameHost *, const content::ContextMenuParams &params)
-{
- if (auto rwhv = static_cast<RenderWidgetHostViewQt *>(m_webContents->GetRenderWidgetHostView())) {
- if (rwhv && rwhv->getTouchSelectionControllerClient()->handleContextMenu(params))
- return;
- }
-
- WebEngineContextMenuData contextMenuData(fromParams(params));
+ re->m_frameUrl = toQt(params.frame_url);
+ re->m_pageUrl = toQt(params.page_url);
+ re->m_referrerPolicy = (ReferrerPolicy)params.referrer_policy;
#if QT_CONFIG(webengine_spellchecker)
// Do not use params.spellcheck_enabled, since it is never
// correctly initialized for chrome asynchronous spellchecking.
@@ -234,9 +246,21 @@ void WebContentsViewQt::ShowContextMenu(content::RenderFrameHost *, const conten
// must be initialized to true due to the way how the initialization sequence
// in SpellCheck works ie. typing the first word triggers the creation
// of the SpellcheckService. Use user preference store instead.
- contextMenuData.setIsSpellCheckerEnabled(m_client->profileAdapter()->isSpellCheckEnabled());
+ re->m_isSpellCheckerEnabled = spellcheckEnabled;
#endif
- m_client->contextMenuRequested(contextMenuData);
+}
+
+void WebContentsViewQt::ShowContextMenu(content::RenderFrameHost *,
+ const content::ContextMenuParams &params)
+{
+ if (auto rwhv =
+ static_cast<RenderWidgetHostViewQt *>(m_webContents->GetRenderWidgetHostView())) {
+ if (rwhv && rwhv->getTouchSelectionControllerClient()->handleContextMenu(params))
+ return;
+ }
+ const bool spellcheckEnabled = m_client->profileAdapter()->isSpellCheckEnabled();
+ update(m_contextMenuRequest.get(), params, spellcheckEnabled);
+ m_client->contextMenuRequested(m_contextMenuRequest.get());
}
Qt::DropActions toQtDropActions(blink::WebDragOperationsMask ops)
diff --git a/src/core/web_contents_view_qt.h b/src/core/web_contents_view_qt.h
index 3dcb648bf..218bebf13 100644
--- a/src/core/web_contents_view_qt.h
+++ b/src/core/web_contents_view_qt.h
@@ -45,6 +45,8 @@
#include "api/qtwebenginecoreglobal_p.h"
+QT_FORWARD_DECLARE_CLASS(QWebEngineContextMenuRequest)
+
namespace content {
class WebContents;
}
@@ -59,12 +61,7 @@ class WebContentsViewQt
public:
static inline WebContentsViewQt *from(WebContentsView *view) { return static_cast<WebContentsViewQt*>(view); }
- WebContentsViewQt(content::WebContents* webContents)
- : m_webContents(webContents)
- , m_client(nullptr)
- , m_factoryClient(nullptr)
- { }
-
+ WebContentsViewQt(content::WebContents* webContents);
void setFactoryClient(WebContentsAdapterClient* client);
void setClient(WebContentsAdapterClient* client);
WebContentsAdapterClient *client() { return m_client; }
@@ -129,9 +126,14 @@ public:
void TakeFocus(bool reverse) override;
private:
+ static void update(QWebEngineContextMenuRequest *request,
+ const content::ContextMenuParams &params, bool spellcheckEnabled);
+
+private:
content::WebContents *m_webContents;
WebContentsAdapterClient *m_client;
WebContentsAdapterClient *m_factoryClient;
+ std::unique_ptr<QWebEngineContextMenuRequest> m_contextMenuRequest;
};
} // namespace QtWebEngineCore
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index 11692c2d1..2a5666776 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -127,16 +127,15 @@
#include <QOffscreenSurface>
#if QT_CONFIG(opengl)
# include <QOpenGLContext>
+# include <qopenglcontext_platform.h>
#endif
#include <QQuickWindow>
#include <QStringList>
#include <QSurfaceFormat>
-#include <QVector>
#include <QNetworkProxy>
#include <QtGui/qpa/qplatformintegration.h>
#include <QtGui/private/qguiapplication_p.h>
-
-using namespace QtWebEngineCore;
+#include <QLoggingCategory>
#if QT_CONFIG(opengl)
QT_BEGIN_NAMESPACE
@@ -144,10 +143,10 @@ Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();
QT_END_NAMESPACE
#endif
-namespace {
+namespace QtWebEngineCore {
#if QT_CONFIG(opengl)
-bool usingANGLE()
+static bool usingANGLE()
{
#if defined(Q_OS_WIN)
if (qt_gl_global_share_context())
@@ -158,7 +157,7 @@ bool usingANGLE()
#endif
}
-bool usingDefaultSGBackend()
+static bool usingDefaultSGBackend()
{
const QStringList args = QGuiApplication::arguments();
@@ -179,16 +178,105 @@ bool usingDefaultSGBackend()
return device.isEmpty();
}
+
+bool usingSoftwareDynamicGL()
+{
+ if (QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL))
+ return true;
+#if defined(Q_OS_WIN)
+ HMODULE handle = QPlatformInterface::QWGLContext::openGLModuleHandle();
+ wchar_t path[MAX_PATH];
+ DWORD size = GetModuleFileName(handle, path, MAX_PATH);
+ QFileInfo openGLModule(QString::fromWCharArray(path, size));
+ return openGLModule.fileName() == QLatin1String("opengl32sw.dll");
+#else
+ return false;
+#endif
+}
+
+static const char *getGLType(bool enableGLSoftwareRendering)
+{
+ const char *glType = nullptr;
+ const bool tryGL = (usingDefaultSGBackend() && !usingSoftwareDynamicGL()
+ && QGuiApplicationPrivate::platformIntegration()->hasCapability(
+ QPlatformIntegration::OpenGL))
+ || enableGLSoftwareRendering;
+ if (tryGL) {
+ if (!qt_gl_global_share_context() || !qt_gl_global_share_context()->isValid()) {
+ qWarning("WebEngineContext used before QtWebEngine::initialize() or OpenGL context "
+ "creation failed.");
+ } else {
+ const QSurfaceFormat sharedFormat = qt_gl_global_share_context()->format();
+ switch (sharedFormat.renderableType()) {
+ case QSurfaceFormat::OpenGL:
+ glType = gl::kGLImplementationDesktopName;
+ // Check if Core profile was requested and is supported.
+ if (sharedFormat.profile() == QSurfaceFormat::CoreProfile) {
+#ifdef Q_OS_MACOS
+ glType = gl::kGLImplementationCoreProfileName;
+#else
+ qWarning("An OpenGL Core Profile was requested, but it is not supported "
+ "on the current platform. Falling back to a non-Core profile. "
+ "Note that this might cause rendering issues.");
+#endif
+ }
+ break;
+ case QSurfaceFormat::OpenGLES:
+ glType = usingANGLE() ? gl::kGLImplementationANGLEName
+ : gl::kGLImplementationEGLName;
+ break;
+ case QSurfaceFormat::OpenVG:
+ case QSurfaceFormat::DefaultRenderableType:
+ default:
+ // Shared contex created but no rederable type set.
+ qWarning("Unsupported rendering surface format. Please open bug report at "
+ "https://bugreports.qt.io");
+ }
+ }
+ }
+ return glType;
+}
+#else
+static cont char *getGLType(bool enableGLSoftwareRendering)
+{
+ return nullptr;
+}
#endif // QT_CONFIG(opengl)
+
#if QT_CONFIG(webengine_pepper_plugins)
void dummyGetPluginCallback(const std::vector<content::WebPluginInfo>&)
{
}
#endif
-} // namespace
-
-namespace QtWebEngineCore {
+static void logContext(const char *glType, base::CommandLine *cmd)
+{
+ QLoggingCategory webEngineContextLog("qt.webenginecontext");
+ if (webEngineContextLog.isInfoEnabled()) {
+ const QSurfaceFormat sharedFormat = qt_gl_global_share_context()->format();
+ const auto profile = QMetaEnum::fromType<QSurfaceFormat::OpenGLContextProfile>().valueToKey(
+ sharedFormat.profile());
+ const auto type = QMetaEnum::fromType<QSurfaceFormat::RenderableType>().valueToKey(
+ sharedFormat.renderableType());
+ const base::CommandLine::SwitchMap switch_map = cmd->GetSwitches();
+ QStringList params;
+ for (const auto &pair : switch_map)
+ params << " * " << toQt(pair.first)
+ << toQt(pair.second) << "\n";
+ qCInfo(webEngineContextLog,
+ "\n\nGLImplementation: %s\n"
+ "Surface Type: %s\n"
+ "Surface Profile: %s\n"
+ "Surface Version: %d.%d\n"
+ "Using Default SG Backend: %s\n"
+ "Using Software Dynamic GL: %s\n"
+ "Using Angle: %s\n\n"
+ "Init Parameters:\n %s",
+ glType, type, profile, sharedFormat.majorVersion(), sharedFormat.minorVersion(),
+ usingDefaultSGBackend() ? "yes" : "no", usingSoftwareDynamicGL() ? "yes" : "no",
+ usingANGLE() ? "yes" : "no", qPrintable(params.join(" ")));
+ }
+}
#if defined(Q_OS_WIN)
sandbox::SandboxInterfaceInfo *staticSandboxInterfaceInfo(sandbox::SandboxInterfaceInfo *info)
@@ -204,36 +292,22 @@ sandbox::SandboxInterfaceInfo *staticSandboxInterfaceInfo(sandbox::SandboxInterf
extern std::unique_ptr<base::MessagePump> messagePumpFactory();
-bool usingSoftwareDynamicGL()
+static void setupProxyPac(base::CommandLine *commandLine)
{
- if (QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL))
- return true;
-#if defined(Q_OS_WIN) && QT_CONFIG(opengl)
- HMODULE handle = static_cast<HMODULE>(QOpenGLContext::openGLModuleHandle());
- wchar_t path[MAX_PATH];
- DWORD size = GetModuleFileName(handle, path, MAX_PATH);
- QFileInfo openGLModule(QString::fromWCharArray(path, size));
- return openGLModule.fileName() == QLatin1String("opengl32sw.dll");
-#else
- return false;
-#endif
-}
-
-void setupProxyPac(base::CommandLine *commandLine){
if (commandLine->HasSwitch(switches::kProxyPacUrl)) {
QUrl pac_url(toQt(commandLine->GetSwitchValueASCII(switches::kProxyPacUrl)));
if (pac_url.isValid() && (pac_url.isLocalFile() ||
- !pac_url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive))) {
+ !pac_url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive))) {
QFile file;
if (pac_url.isLocalFile())
- file.setFileName(pac_url.toLocalFile());
+ file.setFileName(pac_url.toLocalFile());
else
- file.setFileName(pac_url.path().prepend(QChar(':')));
+ file.setFileName(pac_url.path().prepend(QChar(':')));
if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) {
- QByteArray ba = file.readAll();
- commandLine->RemoveSwitch(switches::kProxyPacUrl);
- commandLine->AppendSwitchASCII(switches::kProxyPacUrl,
- ba.toBase64().prepend("data:application/x-javascript-config;base64,").toStdString());
+ QByteArray ba = file.readAll();
+ commandLine->RemoveSwitch(switches::kProxyPacUrl);
+ commandLine->AppendSwitchASCII(switches::kProxyPacUrl,
+ ba.toBase64().prepend("data:application/x-javascript-config;base64,").toStdString());
}
}
}
@@ -360,12 +434,10 @@ void WebEngineContext::destroy()
// Normally the GPU thread is shut down when the GpuProcessHost is destroyed
// on IO thread (triggered by ~BrowserMainRunner). But by that time the UI
// task runner is not working anymore so we need to do this earlier.
- if (features::IsVizDisplayCompositorEnabled()) {
- cleanupVizProcess();
- while (waitForViz) {
- while (delegate->DoWork()){}
- QThread::msleep(50);
- }
+ cleanupVizProcess();
+ while (waitForViz) {
+ while (delegate->DoWork()){}
+ QThread::msleep(50);
}
destroyGpuProcess();
// Flush the UI message loop before quitting.
@@ -562,12 +634,6 @@ WebEngineContext::WebEngineContext()
QStringList appArgs = QCoreApplication::arguments();
- // If user requested GL support instead of using Skia rendering to
- // bitmaps, use software rendering via software OpenGL. This might be less
- // performant, but at least provides WebGL support.
- // TODO(miklocek), check if this still works with latest chromium
- bool enableGLSoftwareRendering = appArgs.contains(QStringLiteral("--enable-webgl-software-rendering"));
-
bool useEmbeddedSwitches = false;
#if defined(QTWEBENGINE_EMBEDDED_SWITCHES)
useEmbeddedSwitches = !appArgs.contains(QStringLiteral("--disable-embedded-switches"));
@@ -594,33 +660,6 @@ WebEngineContext::WebEngineContext()
parsedCommandLine->AppendSwitch(switches::kEnableThreadedCompositing);
-#if defined(Q_OS_WIN)
- // This switch is used in Chromium's gl_context_wgl.cc file to determine whether to create
- // an OpenGL Core Profile context. If the switch is not set, it would always try to create a
- // Core Profile context, even if Qt uses a legacy profile, which causes
- // "Could not share GL contexts" warnings, because it's not possible to share between Core and
- // legacy profiles. See GLContextWGL::Initialize().
- // Given that Desktop GL Core profile is not currently supported on Windows anyway, pass this
- // switch to get rid of the warnings.
- //
- // The switch is also used to determine which version of OpenGL ES to use (2 or 3) when using
- // ANGLE.
- // If the switch is not set, Chromium will always try to create an ES3 context, even if Qt uses
- // an ES2 context, which causes resource sharing issues (black screen),
- // see gpu::gles2::GenerateGLContextAttribs().
- // Make sure to disable ES3 context creation when using ES2.
- const bool isGLES2Context = qt_gl_global_share_context()
- && qt_gl_global_share_context()->isOpenGLES()
- && qt_gl_global_share_context()->format().majorVersion() == 2;
- const bool isDesktopGLOrSoftware = !usingANGLE();
-
- if (isDesktopGLOrSoftware || isGLES2Context)
- parsedCommandLine->AppendSwitch(switches::kDisableES3GLContext);
-#endif
-
- bool enableViz = !parsedCommandLine->HasSwitch("disable-viz-display-compositor");
- parsedCommandLine->RemoveSwitch("disable-viz-display-compositor");
-
// Do not advertise a feature we have removed at compile time
parsedCommandLine->AppendSwitch(switches::kDisableSpeechAPI);
@@ -665,28 +704,6 @@ WebEngineContext::WebEngineContext()
parsedCommandLine->AppendSwitch(cc::switches::kDisableCompositedAntialiasing);
}
- if (!enableViz) {
- // These are currently only default on OS X, and we don't support them:
- parsedCommandLine->AppendSwitch(switches::kDisableZeroCopy);
- parsedCommandLine->AppendSwitch(switches::kDisableGpuMemoryBufferCompositorResources);
-
- // Enabled on OS X and Linux but currently not working. It worked in 5.7 on OS X.
- parsedCommandLine->AppendSwitch(switches::kDisableGpuMemoryBufferVideoFrames);
-
-#if defined(Q_OS_MACOS)
- // Accelerated decoding currently does not work on macOS due to issues with OpenGL Rectangle
- // texture support. See QTBUG-60002.
- parsedCommandLine->AppendSwitch(switches::kDisableAcceleratedVideoDecode);
- // Same problem with Pepper using OpenGL images.
- parsedCommandLine->AppendSwitch(switches::kDisablePepper3DImageChromium);
-#endif
-
- // Viz Display Compositor is enabled by default since 73. Doesn't work for us (also implies SurfaceSynchronization)
- appendToFeatureList(disableFeatures, features::kVizDisplayCompositor.name);
- // VideoSurfaceLayer is enabled by default since 75. We don't support it.
- appendToFeatureList(enableFeatures, media::kDisableSurfaceLayerForVideo.name);
- }
-
appendToFeatureSwitch(parsedCommandLine, switches::kDisableFeatures, disableFeatures);
appendToFeatureSwitch(parsedCommandLine, switches::kEnableFeatures, enableFeatures);
base::FeatureList::InitializeInstance(
@@ -695,74 +712,12 @@ WebEngineContext::WebEngineContext()
GLContextHelper::initialize();
- const char *glType = 0;
-#if QT_CONFIG(opengl)
-
- const bool tryGL = (usingDefaultSGBackend() && !usingSoftwareDynamicGL() &&
- QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL))
- || enableGLSoftwareRendering;
- if (tryGL) {
- if (qt_gl_global_share_context() && qt_gl_global_share_context()->isValid()) {
- // If the native handle is QEGLNativeContext try to use GL ES/2.
- // If there is no native handle, assume we are using wayland and try GL ES/2.
- // If we are using ANGLE on Windows, use OpenGL ES (2 or 3).
- if (qt_gl_global_share_context()->nativeHandle().isNull()
- || !strcmp(qt_gl_global_share_context()->nativeHandle().typeName(),
- "QEGLNativeContext")
- || usingANGLE())
- {
- if (qt_gl_global_share_context()->isOpenGLES()) {
- glType = usingANGLE() ? gl::kGLImplementationANGLEName : gl::kGLImplementationEGLName;
- } else {
- QOpenGLContext context;
- QSurfaceFormat format;
-
- format.setRenderableType(QSurfaceFormat::OpenGL);
- format.setVersion(2, 0);
-
- context.setFormat(format);
- context.setShareContext(qt_gl_global_share_context());
- if (context.create()) {
- QOffscreenSurface surface;
-
- surface.setFormat(format);
- surface.create();
-
- if (context.makeCurrent(&surface)) {
- if (context.hasExtension("GL_ARB_ES2_compatibility"))
- glType = gl::kGLImplementationEGLName;
-
- context.doneCurrent();
- }
-
- surface.destroy();
- }
- }
- } else {
- if (!qt_gl_global_share_context()->isOpenGLES()) {
- // Default to Desktop non-Core profile OpenGL.
- glType = gl::kGLImplementationDesktopName;
-
- // Check if Core profile was requested and is supported.
- QSurfaceFormat globalSharedFormat = qt_gl_global_share_context()->format();
- if (globalSharedFormat.profile() == QSurfaceFormat::CoreProfile) {
-#ifdef Q_OS_MACOS
- glType = gl::kGLImplementationCoreProfileName;
-#else
- qWarning("An OpenGL Core Profile was requested, but it is not supported "
- "on the current platform. Falling back to a non-Core profile. "
- "Note that this might cause rendering issues.");
-#endif
- }
- }
- }
- if (qt_gl_global_share_context()->format().profile() == QSurfaceFormat::CompatibilityProfile)
- parsedCommandLine->AppendSwitch(switches::kCreateDefaultGLContext);
- } else {
- qWarning("WebEngineContext used before QtWebEngine::initialize() or OpenGL context creation failed.");
- }
- }
-#endif // QT_CONFIG(opengl)
+ // If user requested GL support instead of using Skia rendering to
+ // bitmaps, use software rendering via software OpenGL. This might be less
+ // performant, but at least provides WebGL support.
+ // TODO(miklocek), check if this still works with latest chromium
+ const bool enableGLSoftwareRendering = appArgs.contains(QStringLiteral("--enable-webgl-software-rendering"));
+ const char *glType = getGLType(enableGLSoftwareRendering);
if (glType) {
parsedCommandLine->AppendSwitchASCII(switches::kUseGL, glType);
@@ -771,6 +726,29 @@ WebEngineContext::WebEngineContext()
parsedCommandLine->AppendSwitch(switches::kDisableGpuRasterization);
parsedCommandLine->AppendSwitch(switches::kIgnoreGpuBlacklist);
}
+ const QSurfaceFormat sharedFormat = QOpenGLContext::globalShareContext()->format();
+ if (sharedFormat.profile() == QSurfaceFormat::CompatibilityProfile)
+ parsedCommandLine->AppendSwitch(switches::kCreateDefaultGLContext);
+#if defined(Q_OS_WIN)
+ // This switch is used in Chromium's gl_context_wgl.cc file to determine whether to create
+ // an OpenGL Core Profile context. If the switch is not set, it would always try to create a
+ // Core Profile context, even if Qt uses a legacy profile, which causes
+ // "Could not share GL contexts" warnings, because it's not possible to share between Core and
+ // legacy profiles. See GLContextWGL::Initialize().
+ // Given that Desktop GL Core profile is not currently supported on Windows anyway, pass this
+ // switch to get rid of the warnings.
+ //
+ // The switch is also used to determine which version of OpenGL ES to use (2 or 3) when using
+ // ANGLE.
+ // If the switch is not set, Chromium will always try to create an ES3 context, even if Qt uses
+ // an ES2 context, which causes resource sharing issues (black screen),
+ // see gpu::gles2::GenerateGLContextAttribs().
+ // Make sure to disable ES3 context creation when using ES2.
+ const bool isGLES2Context = QOpenGLContext::globalShareContext()->isOpenGLES()
+ && QOpenGLContext::globalShareContext()->format().majorVersion() == 2;
+ if (!usingANGLE() || isGLES2Context)
+ parsedCommandLine->AppendSwitch(switches::kDisableES3GLContext);
+#endif
} else {
parsedCommandLine->AppendSwitch(switches::kDisableGpu);
}
@@ -854,6 +832,8 @@ WebEngineContext::WebEngineContext()
#endif
content::WebUIControllerFactory::RegisterFactory(WebUIControllerFactoryQt::GetInstance());
+
+ logContext(glType, parsedCommandLine);
}
#if QT_CONFIG(webengine_printing_and_pdf)
@@ -872,8 +852,8 @@ gpu::SyncPointManager *WebEngineContext::syncPointManager()
return spm;
QMutexLocker lock(&s_spmMutex);
if (!s_syncPointManager)
- s_syncPointManager.store(new gpu::SyncPointManager());
- return s_syncPointManager.load();
+ s_syncPointManager.storeRelaxed(new gpu::SyncPointManager());
+ return s_syncPointManager.loadRelaxed();
}
base::CommandLine* WebEngineContext::commandLine() {
diff --git a/src/core/web_engine_context.h b/src/core/web_engine_context.h
index e2190f8a2..fcc569969 100644
--- a/src/core/web_engine_context.h
+++ b/src/core/web_engine_context.h
@@ -47,7 +47,7 @@
#include "base/values.h"
#include <QtGui/qtgui-config.h>
-#include <QVector>
+#include <QList>
namespace base {
class RunLoop;
@@ -144,7 +144,7 @@ private:
std::unique_ptr<QObject> m_globalQObject;
std::unique_ptr<ProfileAdapter> m_defaultProfileAdapter;
std::unique_ptr<DevToolsServerQt> m_devtoolsServer;
- QVector<ProfileAdapter*> m_profileAdapters;
+ QList<ProfileAdapter*> m_profileAdapters;
#if QT_CONFIG(accessibility)
std::unique_ptr<AccessibilityActivationObserver> m_accessibilityActivationObserver;
#endif
diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp
index b9aa941a1..837f05bf1 100644
--- a/src/core/web_engine_settings.cpp
+++ b/src/core/web_engine_settings.cpp
@@ -45,7 +45,6 @@
#include "base/command_line.h"
#include "chrome/common/chrome_switches.h"
-#include "components/viz/common/features.h"
#include "content/browser/gpu/gpu_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
@@ -60,7 +59,6 @@
#include <QFont>
#include <QTimer>
-#include <QTouchDevice>
namespace QtWebEngineCore {
@@ -389,11 +387,6 @@ void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *p
prefs->dom_paste_enabled = testAttribute(JavascriptCanPaste);
prefs->dns_prefetching_enabled = testAttribute(DnsPrefetchEnabled);
- if (!features::IsVizDisplayCompositorEnabled()) {
- prefs->accelerated_2d_canvas_enabled = false;
- prefs->disable_features_depending_on_viz = true;
- }
-
// Fonts settings.
prefs->standard_font_family_map[content::kCommonScript] = toString16(fontFamily(StandardFont));
prefs->fixed_font_family_map[content::kCommonScript] = toString16(fontFamily(FixedFont));
diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp
index 5b6c6bd0e..cbf1fecf3 100644
--- a/src/core/web_event_factory.cpp
+++ b/src/core/web_event_factory.cpp
@@ -82,7 +82,7 @@
#include <QMouseEvent>
#include <QStyleHints>
#if QT_CONFIG(tabletevent)
-#include <QTabletEvent>
+#include <QPointingDevice>
#endif
#include <QWheelEvent>
@@ -1416,12 +1416,14 @@ static WebInputEvent::Type webEventTypeForEvent(const QEvent* event)
static WebPointerProperties::PointerType pointerTypeForTabletEvent(const QTabletEvent *ev)
{
switch (ev->pointerType()) {
- case QTabletEvent::UnknownPointer:
+ case QPointingDevice::PointerType::Unknown:
return WebPointerProperties::PointerType::kUnknown;
- case QTabletEvent::Pen:
+ case QPointingDevice::PointerType::Pen:
return WebPointerProperties::PointerType::kPen;
- case QTabletEvent::Eraser:
+ case QPointingDevice::PointerType::Eraser:
return WebPointerProperties::PointerType::kEraser;
+ case QPointingDevice::PointerType::Finger:
+ return WebPointerProperties::PointerType::kTouch;
default:
return WebPointerProperties::PointerType::kMouse;
}
@@ -1431,8 +1433,8 @@ static WebPointerProperties::PointerType pointerTypeForTabletEvent(const QTablet
WebMouseEvent WebEventFactory::toWebMouseEvent(QMouseEvent *ev)
{
WebMouseEvent webKitEvent(webEventTypeForEvent(ev),
- WebFloatPoint(ev->x(), ev->y()),
- WebFloatPoint(ev->globalX(), ev->globalY()),
+ WebFloatPoint(ev->position().x(), ev->position().y()),
+ WebFloatPoint(ev->globalPosition().x(), ev->globalPosition().y()),
mouseButtonForEvent<QMouseEvent>(ev),
0,
modifiersForEvent(ev),
@@ -1450,9 +1452,9 @@ WebMouseEvent WebEventFactory::toWebMouseEvent(QHoverEvent *ev)
webKitEvent.SetModifiers(modifiersForEvent(ev));
webKitEvent.SetType(webEventTypeForEvent(ev));
- webKitEvent.SetPositionInWidget(ev->pos().x(), ev->pos().y());
- webKitEvent.movement_x = ev->pos().x() - ev->oldPos().x();
- webKitEvent.movement_y = ev->pos().y() - ev->oldPos().y();
+ webKitEvent.SetPositionInWidget(ev->position().x(), ev->position().y());
+ webKitEvent.movement_x = ev->position().x() - ev->oldPos().x();
+ webKitEvent.movement_y = ev->position().y() - ev->oldPos().y();
webKitEvent.pointer_type = WebPointerProperties::PointerType::kMouse;
return webKitEvent;
@@ -1462,8 +1464,8 @@ WebMouseEvent WebEventFactory::toWebMouseEvent(QHoverEvent *ev)
WebMouseEvent WebEventFactory::toWebMouseEvent(QTabletEvent *ev)
{
WebMouseEvent webKitEvent(webEventTypeForEvent(ev),
- WebFloatPoint(ev->x(), ev->y()),
- WebFloatPoint(ev->globalX(), ev->globalY()),
+ WebFloatPoint(ev->position().x(), ev->position().y()),
+ WebFloatPoint(ev->globalPosition().x(), ev->globalPosition().y()),
mouseButtonForEvent<QTabletEvent>(ev),
0,
modifiersForEvent(ev),
@@ -1496,11 +1498,11 @@ WebGestureEvent WebEventFactory::toWebGestureEvent(QNativeGestureEvent *ev)
webKitEvent.SetTimeStamp(base::TimeTicks::Now());
webKitEvent.SetModifiers(modifiersForEvent(ev));
- webKitEvent.SetPositionInWidget(WebFloatPoint(ev->localPos().x(),
- ev->localPos().y()));
+ webKitEvent.SetPositionInWidget(WebFloatPoint(ev->position().x(),
+ ev->position().y()));
- webKitEvent.SetPositionInScreen(WebFloatPoint(ev->screenPos().x(),
- ev->screenPos().y()));
+ webKitEvent.SetPositionInScreen(WebFloatPoint(ev->globalPosition().x(),
+ ev->globalPosition().y()));
webKitEvent.SetSourceDevice(blink::WebGestureDevice::kTouchpad);
diff --git a/src/pdf/api/qpdflinkmodel_p_p.h b/src/pdf/api/qpdflinkmodel_p_p.h
index 0454d6755..0606b4746 100644
--- a/src/pdf/api/qpdflinkmodel_p_p.h
+++ b/src/pdf/api/qpdflinkmodel_p_p.h
@@ -82,7 +82,7 @@ public:
};
QPdfDocument *document = nullptr;
- QVector<Link> links;
+ QList<Link> links;
int page = 0;
};
diff --git a/src/pdf/api/qpdfpagerenderer.h b/src/pdf/api/qpdfpagerenderer.h
index c7b8de0df..bb5505462 100644
--- a/src/pdf/api/qpdfpagerenderer.h
+++ b/src/pdf/api/qpdfpagerenderer.h
@@ -42,11 +42,11 @@
#include <QtCore/qobject.h>
#include <QtCore/qsize.h>
+#include <QtPdf/qpdfdocument.h>
#include <QtPdf/qpdfdocumentrenderoptions.h>
QT_BEGIN_NAMESPACE
-class QPdfDocument;
class QPdfPageRendererPrivate;
class Q_PDF_EXPORT QPdfPageRenderer : public QObject
diff --git a/src/pdf/api/qpdfsearchmodel.h b/src/pdf/api/qpdfsearchmodel.h
index eb0fb831f..1a413c763 100644
--- a/src/pdf/api/qpdfsearchmodel.h
+++ b/src/pdf/api/qpdfsearchmodel.h
@@ -66,7 +66,7 @@ public:
explicit QPdfSearchModel(QObject *parent = nullptr);
~QPdfSearchModel();
- QVector<QPdfSearchResult> resultsOnPage(int page) const;
+ QList<QPdfSearchResult> resultsOnPage(int page) const;
QPdfSearchResult resultAtIndex(int index) const;
QPdfDocument *document() const;
diff --git a/src/pdf/api/qpdfsearchmodel_p.h b/src/pdf/api/qpdfsearchmodel_p.h
index 2a23706b2..551eff47c 100644
--- a/src/pdf/api/qpdfsearchmodel_p.h
+++ b/src/pdf/api/qpdfsearchmodel_p.h
@@ -74,8 +74,8 @@ public:
QPdfDocument *document = nullptr;
QString searchString;
- QVector<bool> pagesSearched;
- QVector<QVector<QPdfSearchResult>> searchResults;
+ QList<bool> pagesSearched;
+ QList<QList<QPdfSearchResult>> searchResults;
int rowCountSoFar = 0;
int updateTimerId = -1;
int nextPageToUpdate = 0;
diff --git a/src/pdf/api/qpdfsearchresult.h b/src/pdf/api/qpdfsearchresult.h
index 2dfca2dc4..0acf03d52 100644
--- a/src/pdf/api/qpdfsearchresult.h
+++ b/src/pdf/api/qpdfsearchresult.h
@@ -38,8 +38,8 @@
#define QPDFSEARCHRESULT_H
#include <QtCore/qdebug.h>
+#include <QtCore/qlist.h>
#include <QtCore/qrect.h>
-#include <QtCore/qvector.h>
#include <QtPdf/qpdfdestination.h>
QT_BEGIN_NAMESPACE
@@ -51,7 +51,7 @@ class Q_PDF_EXPORT QPdfSearchResult : public QPdfDestination
Q_GADGET
Q_PROPERTY(QString contextBefore READ contextBefore)
Q_PROPERTY(QString contextAfter READ contextAfter)
- Q_PROPERTY(QVector<QRectF> rectangles READ rectangles)
+ Q_PROPERTY(QList<QRectF> rectangles READ rectangles)
public:
QPdfSearchResult();
@@ -59,10 +59,10 @@ public:
QString contextBefore() const;
QString contextAfter() const;
- QVector<QRectF> rectangles() const;
+ QList<QRectF> rectangles() const;
private:
- QPdfSearchResult(int page, QVector<QRectF> rects, QString contextBefore, QString contextAfter);
+ QPdfSearchResult(int page, QList<QRectF> rects, QString contextBefore, QString contextAfter);
QPdfSearchResult(QPdfSearchResultPrivate *d);
friend class QPdfDocument;
friend class QPdfSearchModelPrivate;
diff --git a/src/pdf/api/qpdfsearchresult_p.h b/src/pdf/api/qpdfsearchresult_p.h
index 615dce4e0..eca37890e 100644
--- a/src/pdf/api/qpdfsearchresult_p.h
+++ b/src/pdf/api/qpdfsearchresult_p.h
@@ -56,7 +56,7 @@ class QPdfSearchResultPrivate : public QPdfDestinationPrivate
{
public:
QPdfSearchResultPrivate() = default;
- QPdfSearchResultPrivate(int page, QVector<QRectF> rects, QString contextBefore, QString contextAfter) :
+ QPdfSearchResultPrivate(int page, QList<QRectF> rects, QString contextBefore, QString contextAfter) :
QPdfDestinationPrivate(page, rects.first().topLeft(), 0),
contextBefore(contextBefore),
contextAfter(contextAfter),
@@ -64,7 +64,7 @@ public:
QString contextBefore;
QString contextAfter;
- QVector<QRectF> rects;
+ QList<QRectF> rects;
};
QT_END_NAMESPACE
diff --git a/src/pdf/api/qpdfselection.h b/src/pdf/api/qpdfselection.h
index 9d91d46c7..70077fdb0 100644
--- a/src/pdf/api/qpdfselection.h
+++ b/src/pdf/api/qpdfselection.h
@@ -52,7 +52,7 @@ class Q_PDF_EXPORT QPdfSelection
{
Q_GADGET
Q_PROPERTY(bool valid READ isValid)
- Q_PROPERTY(QVector<QPolygonF> bounds READ bounds)
+ Q_PROPERTY(QList<QPolygonF> bounds READ bounds)
Q_PROPERTY(QRectF boundingRectangle READ boundingRectangle)
Q_PROPERTY(QString text READ text)
Q_PROPERTY(int startIndex READ startIndex)
@@ -66,7 +66,7 @@ public:
QPdfSelection &operator=(QPdfSelection &&other) noexcept { swap(other); return *this; }
void swap(QPdfSelection &other) noexcept { d.swap(other.d); }
bool isValid() const;
- QVector<QPolygonF> bounds() const;
+ QList<QPolygonF> bounds() const;
QString text() const;
QRectF boundingRectangle() const;
int startIndex() const;
@@ -77,7 +77,7 @@ public:
private:
QPdfSelection();
- QPdfSelection(const QString &text, QVector<QPolygonF> bounds, QRectF boundingRect, int startIndex, int endIndex);
+ QPdfSelection(const QString &text, QList<QPolygonF> bounds, QRectF boundingRect, int startIndex, int endIndex);
QPdfSelection(QPdfSelectionPrivate *d);
friend class QPdfDocument;
friend class QQuickPdfSelection;
diff --git a/src/pdf/api/qpdfselection_p.h b/src/pdf/api/qpdfselection_p.h
index 0577e5a31..37ca3a3ce 100644
--- a/src/pdf/api/qpdfselection_p.h
+++ b/src/pdf/api/qpdfselection_p.h
@@ -37,8 +37,8 @@
#ifndef QPDFSELECTION_P_H
#define QPDFSELECTION_P_H
+#include <QList>
#include <QPolygonF>
-#include <QVector>
QT_BEGIN_NAMESPACE
@@ -46,7 +46,7 @@ class QPdfSelectionPrivate : public QSharedData
{
public:
QPdfSelectionPrivate() = default;
- QPdfSelectionPrivate(const QString &text, QVector<QPolygonF> bounds, QRectF boundingRect, int startIndex, int endIndex)
+ QPdfSelectionPrivate(const QString &text, QList<QPolygonF> bounds, QRectF boundingRect, int startIndex, int endIndex)
: text(text),
bounds(bounds),
boundingRect(boundingRect),
@@ -54,7 +54,7 @@ public:
endIndex(endIndex) { }
QString text;
- QVector<QPolygonF> bounds;
+ QList<QPolygonF> bounds;
QRectF boundingRect;
int startIndex;
int endIndex;
diff --git a/src/pdf/qpdfbookmarkmodel.cpp b/src/pdf/qpdfbookmarkmodel.cpp
index c9c365568..b0e8bbecd 100644
--- a/src/pdf/qpdfbookmarkmodel.cpp
+++ b/src/pdf/qpdfbookmarkmodel.cpp
@@ -128,7 +128,7 @@ public:
}
private:
- QVector<BookmarkNode*> m_childNodes;
+ QList<BookmarkNode*> m_childNodes;
BookmarkNode *m_parentNode;
QString m_title;
@@ -189,7 +189,7 @@ public:
const int titleLength = int(FPDFBookmark_GetTitle(bookmark, nullptr, 0));
- QVector<ushort> titleBuffer(titleLength);
+ QList<char16_t> titleBuffer(titleLength);
FPDFBookmark_GetTitle(bookmark, titleBuffer.data(), quint32(titleBuffer.length()));
const FPDF_DEST dest = FPDFBookmark_GetDest(document, bookmark);
diff --git a/src/pdf/qpdfdocument.cpp b/src/pdf/qpdfdocument.cpp
index e4ec363ce..5a8e0a1af 100644
--- a/src/pdf/qpdfdocument.cpp
+++ b/src/pdf/qpdfdocument.cpp
@@ -52,7 +52,13 @@
QT_BEGIN_NAMESPACE
// The library is not thread-safe at all, it has a lot of global variables.
-Q_GLOBAL_STATIC_WITH_ARGS(QMutex, pdfMutex, (QMutex::Recursive));
+#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
+class QRecursiveMutex : public QMutex
+{
+ QRecursiveMutex() : QMutex(Recursive) {}
+};
+#endif
+Q_GLOBAL_STATIC(QRecursiveMutex, pdfMutex)
static int libraryRefCount;
static const double CharacterHitTolerance = 16.0;
Q_LOGGING_CATEGORY(qLcDoc, "qt.pdf.document")
@@ -395,11 +401,11 @@ void QPdfDocumentPrivate::fpdf_AddSegment(_FX_DOWNLOADHINTS *pThis, size_t offse
QString QPdfDocumentPrivate::getText(FPDF_TEXTPAGE textPage, int startIndex, int count)
{
- QVector<ushort> buf(count + 1);
+ QList<ushort> buf(count + 1);
// TODO is that enough space in case one unicode character is more than one in utf-16?
int len = FPDFText_GetText(textPage, startIndex, count, buf.data());
Q_ASSERT(len - 1 <= count); // len is number of characters written, including the terminator
- return QString::fromUtf16(buf.constData(), len - 1);
+ return QString::fromUtf16(reinterpret_cast<const char16_t *>(buf.constData()), len - 1);
}
QPointF QPdfDocumentPrivate::getCharPosition(FPDF_TEXTPAGE textPage, double pageHeight, int charIndex)
@@ -596,11 +602,11 @@ QVariant QPdfDocument::metaData(MetaDataField field) const
QPdfMutexLocker lock;
const unsigned long len = FPDF_GetMetaText(d->doc, fieldName.constData(), nullptr, 0);
- QVector<ushort> buf(len);
+ QList<ushort> buf(len);
FPDF_GetMetaText(d->doc, fieldName.constData(), buf.data(), buf.length());
lock.unlock();
- QString text = QString::fromUtf16(buf.data());
+ QString text = QString::fromUtf16(reinterpret_cast<const char16_t *>(buf.data()));
switch (field) {
case Title: // fall through
@@ -801,7 +807,7 @@ QPdfSelection QPdfDocument::getSelection(int page, QPointF start, QPointF end)
int count = endIndex - startIndex;
QString text = d->getText(textPage, startIndex, count);
- QVector<QPolygonF> bounds;
+ QList<QPolygonF> bounds;
QRectF hull;
int rectCount = FPDFText_CountRects(textPage, startIndex, endIndex - startIndex);
for (int i = 0; i < rectCount; ++i) {
@@ -838,7 +844,7 @@ QPdfSelection QPdfDocument::getSelectionAtIndex(int page, int startIndex, int ma
int pageCount = FPDFText_CountChars(textPage);
if (startIndex >= pageCount)
return QPdfSelection();
- QVector<QPolygonF> bounds;
+ QList<QPolygonF> bounds;
QRectF hull;
int rectCount = 0;
QString text;
@@ -876,7 +882,7 @@ QPdfSelection QPdfDocument::getAllText(int page)
if (count < 1)
return QPdfSelection();
QString text = d->getText(textPage, 0, count);
- QVector<QPolygonF> bounds;
+ QList<QPolygonF> bounds;
QRectF hull;
int rectCount = FPDFText_CountRects(textPage, 0, count);
for (int i = 0; i < rectCount; ++i) {
diff --git a/src/pdf/qpdflinkmodel.cpp b/src/pdf/qpdflinkmodel.cpp
index 900d3cd9e..5c2596bb9 100644
--- a/src/pdf/qpdflinkmodel.cpp
+++ b/src/pdf/qpdflinkmodel.cpp
@@ -66,7 +66,7 @@ QHash<int, QByteArray> QPdfLinkModel::roleNames() const
int QPdfLinkModel::rowCount(const QModelIndex &parent) const
{
Q_D(const QPdfLinkModel);
- Q_UNUSED(parent)
+ Q_UNUSED(parent);
return d->links.count();
}
@@ -239,10 +239,11 @@ void QPdfLinkModelPrivate::update()
if (len < 1) {
qCWarning(qLcLink) << "skipping link" << i << "with empty URL";
} else {
- QVector<unsigned short> buf(len);
+ QList<unsigned short> buf(len);
int got = FPDFLink_GetURL(webLinks, i, buf.data(), len);
Q_ASSERT(got == len);
- linkData.url = QString::fromUtf16(buf.data(), got - 1);
+ linkData.url = QString::fromUtf16(
+ reinterpret_cast<const char16_t *>(buf.data()), got - 1);
}
FPDFLink_GetTextRange(webLinks, i, &linkData.textStart, &linkData.textCharCount);
len = FPDFLink_CountRects(webLinks, i);
diff --git a/src/pdf/qpdfpagerenderer.cpp b/src/pdf/qpdfpagerenderer.cpp
index 31d9f4e1e..cbff0ea8f 100644
--- a/src/pdf/qpdfpagerenderer.cpp
+++ b/src/pdf/qpdfpagerenderer.cpp
@@ -38,7 +38,6 @@
#include <private/qobject_p.h>
#include <QMutex>
-#include <QPdfDocument>
#include <QPointer>
#include <QThread>
@@ -90,8 +89,8 @@ public:
QPdfDocumentRenderOptions options;
};
- QVector<PageRequest> m_requests;
- QVector<PageRequest> m_pendingRequests;
+ QList<PageRequest> m_requests;
+ QList<PageRequest> m_pendingRequests;
quint64 m_requestIdCounter = 1;
QThread *m_renderThread = nullptr;
diff --git a/src/pdf/qpdfsearchmodel.cpp b/src/pdf/qpdfsearchmodel.cpp
index 27b7833fc..aee28f999 100644
--- a/src/pdf/qpdfsearchmodel.cpp
+++ b/src/pdf/qpdfsearchmodel.cpp
@@ -78,7 +78,7 @@ QHash<int, QByteArray> QPdfSearchModel::roleNames() const
int QPdfSearchModel::rowCount(const QModelIndex &parent) const
{
Q_D(const QPdfSearchModel);
- Q_UNUSED(parent)
+ Q_UNUSED(parent);
return d->rowCountSoFar;
}
@@ -136,7 +136,7 @@ void QPdfSearchModel::setSearchString(QString searchString)
endResetModel();
}
-QVector<QPdfSearchResult> QPdfSearchModel::resultsOnPage(int page) const
+QList<QPdfSearchResult> QPdfSearchModel::resultsOnPage(int page) const
{
Q_D(const QPdfSearchModel);
const_cast<QPdfSearchModelPrivate *>(d)->doSearch(page);
@@ -178,7 +178,7 @@ void QPdfSearchModel::timerEvent(QTimerEvent *event)
return;
if (!d->document || d->nextPageToUpdate >= d->document->pageCount()) {
if (d->document)
- qCDebug(qLcS, "done updating search results on %d pages", d->searchResults.count());
+ qCDebug(qLcS) << "done updating search results on" << d->searchResults.count() << "pages";
killTimer(d->updateTimerId);
d->updateTimerId = -1;
}
@@ -230,12 +230,12 @@ bool QPdfSearchModelPrivate::doSearch(int page)
return false;
}
FPDF_SCHHANDLE sh = FPDFText_FindStart(textPage, searchString.utf16(), 0, 0);
- QVector<QPdfSearchResult> newSearchResults;
+ QList<QPdfSearchResult> newSearchResults;
while (FPDFText_FindNext(sh)) {
int idx = FPDFText_GetSchResultIndex(sh);
int count = FPDFText_GetSchCount(sh);
int rectCount = FPDFText_CountRects(textPage, idx, count);
- QVector<QRectF> rects;
+ QList<QRectF> rects;
int startIndex = -1;
int endIndex = -1;
for (int r = 0; r < rectCount; ++r) {
@@ -258,10 +258,11 @@ bool QPdfSearchModelPrivate::doSearch(int page)
endIndex += ContextChars;
int count = endIndex - startIndex + 1;
if (count > 0) {
- QVector<ushort> buf(count + 1);
+ QList<ushort> buf(count + 1);
int len = FPDFText_GetText(textPage, startIndex, count, buf.data());
Q_ASSERT(len - 1 <= count); // len is number of characters written, including the terminator
- QString context = QString::fromUtf16(buf.constData(), len - 1);
+ QString context = QString::fromUtf16(
+ reinterpret_cast<const char16_t *>(buf.constData()), len - 1);
context = context.replace(QLatin1Char('\n'), QStringLiteral("\u23CE"));
context = context.remove(QLatin1Char('\r'));
// try to find the search string near the middle of the context if possible
diff --git a/src/pdf/qpdfsearchresult.cpp b/src/pdf/qpdfsearchresult.cpp
index 53da1c165..629a8765f 100644
--- a/src/pdf/qpdfsearchresult.cpp
+++ b/src/pdf/qpdfsearchresult.cpp
@@ -42,7 +42,7 @@ QT_BEGIN_NAMESPACE
QPdfSearchResult::QPdfSearchResult() :
QPdfSearchResult(new QPdfSearchResultPrivate()) { }
-QPdfSearchResult::QPdfSearchResult(int page, QVector<QRectF> rects, QString contextBefore, QString contextAfter) :
+QPdfSearchResult::QPdfSearchResult(int page, QList<QRectF> rects, QString contextBefore, QString contextAfter) :
QPdfSearchResult(new QPdfSearchResultPrivate(page, rects, contextBefore, contextAfter)) { }
QPdfSearchResult::QPdfSearchResult(QPdfSearchResultPrivate *d) :
@@ -58,7 +58,7 @@ QString QPdfSearchResult::contextAfter() const
return static_cast<QPdfSearchResultPrivate *>(d.data())->contextAfter;
}
-QVector<QRectF> QPdfSearchResult::rectangles() const
+QList<QRectF> QPdfSearchResult::rectangles() const
{
return static_cast<QPdfSearchResultPrivate *>(d.data())->rects;
}
diff --git a/src/pdf/qpdfselection.cpp b/src/pdf/qpdfselection.cpp
index 5f0ee3b20..b8ad02969 100644
--- a/src/pdf/qpdfselection.cpp
+++ b/src/pdf/qpdfselection.cpp
@@ -67,7 +67,7 @@ QPdfSelection::QPdfSelection()
\a text string, and which take up space on the page within the polygon
regions given in \a bounds.
*/
-QPdfSelection::QPdfSelection(const QString &text, QVector<QPolygonF> bounds, QRectF boundingRect, int startIndex, int endIndex)
+QPdfSelection::QPdfSelection(const QString &text, QList<QPolygonF> bounds, QRectF boundingRect, int startIndex, int endIndex)
: d(new QPdfSelectionPrivate(text, bounds, boundingRect, startIndex, endIndex))
{
}
@@ -119,7 +119,7 @@ bool QPdfSelection::isValid() const
are always rectangles; but in the future it may be possible to represent
more complex regions.
*/
-QVector<QPolygonF> QPdfSelection::bounds() const
+QList<QPolygonF> QPdfSelection::bounds() const
{
return d->bounds;
}
diff --git a/src/pdf/quick/qquickpdflinkmodel_p.h b/src/pdf/quick/qquickpdflinkmodel_p.h
index 23ad6c8c1..6f19daa28 100644
--- a/src/pdf/quick/qquickpdflinkmodel_p.h
+++ b/src/pdf/quick/qquickpdflinkmodel_p.h
@@ -75,7 +75,7 @@ private:
private:
QQuickPdfDocument *m_quickDocument;
- QVector<QPolygonF> m_linksGeometry;
+ QList<QPolygonF> m_linksGeometry;
Q_DISABLE_COPY(QQuickPdfLinkModel)
};
diff --git a/src/pdf/quick/qquickpdfnavigationstack_p.h b/src/pdf/quick/qquickpdfnavigationstack_p.h
index 0d88d62fd..5df00add5 100644
--- a/src/pdf/quick/qquickpdfnavigationstack_p.h
+++ b/src/pdf/quick/qquickpdfnavigationstack_p.h
@@ -88,7 +88,7 @@ Q_SIGNALS:
void jumped(int page, QPointF location, qreal zoom);
private:
- QVector<QExplicitlySharedDataPointer<QPdfDestinationPrivate>> m_pageHistory;
+ QList<QExplicitlySharedDataPointer<QPdfDestinationPrivate>> m_pageHistory;
int m_currentHistoryIndex = 0;
bool m_changing = false;
diff --git a/src/pdf/quick/qquickpdfsearchmodel.cpp b/src/pdf/quick/qquickpdfsearchmodel.cpp
index 1f62fbad0..a39178ba3 100644
--- a/src/pdf/quick/qquickpdfsearchmodel.cpp
+++ b/src/pdf/quick/qquickpdfsearchmodel.cpp
@@ -104,9 +104,9 @@ void QQuickPdfSearchModel::setDocument(QQuickPdfDocument *document)
\sa PathMultiline
*/
-QVector<QPolygonF> QQuickPdfSearchModel::currentResultBoundingPolygons() const
+QList<QPolygonF> QQuickPdfSearchModel::currentResultBoundingPolygons() const
{
- QVector<QPolygonF> ret;
+ QList<QPolygonF> ret;
const auto &results = const_cast<QQuickPdfSearchModel *>(this)->resultsOnPage(m_currentPage);
if (m_currentResult < 0 || m_currentResult >= results.count())
return ret;
@@ -172,7 +172,7 @@ void QQuickPdfSearchModel::onResultsChanged()
\sa PathMultiline
*/
-QVector<QPolygonF> QQuickPdfSearchModel::currentPageBoundingPolygons() const
+QList<QPolygonF> QQuickPdfSearchModel::currentPageBoundingPolygons() const
{
return const_cast<QQuickPdfSearchModel *>(this)->boundingPolygonsOnPage(m_currentPage);
}
@@ -203,14 +203,14 @@ QVector<QPolygonF> QQuickPdfSearchModel::currentPageBoundingPolygons() const
\sa PathMultiline
*/
-QVector<QPolygonF> QQuickPdfSearchModel::boundingPolygonsOnPage(int page)
+QList<QPolygonF> QQuickPdfSearchModel::boundingPolygonsOnPage(int page)
{
if (!document() || searchString().isEmpty() || page < 0 || page > document()->pageCount())
return {};
updatePage(page);
- QVector<QPolygonF> ret;
+ QList<QPolygonF> ret;
auto m = QPdfSearchModel::resultsOnPage(page);
for (auto result : m) {
for (auto rect : result.rectangles())
diff --git a/src/pdf/quick/qquickpdfsearchmodel_p.h b/src/pdf/quick/qquickpdfsearchmodel_p.h
index 66fc583d9..3f0f6f4c1 100644
--- a/src/pdf/quick/qquickpdfsearchmodel_p.h
+++ b/src/pdf/quick/qquickpdfsearchmodel_p.h
@@ -62,8 +62,8 @@ class QQuickPdfSearchModel : public QPdfSearchModel
Q_PROPERTY(QQuickPdfDocument *document READ document WRITE setDocument NOTIFY documentChanged)
Q_PROPERTY(int currentPage READ currentPage WRITE setCurrentPage NOTIFY currentPageChanged)
Q_PROPERTY(int currentResult READ currentResult WRITE setCurrentResult NOTIFY currentResultChanged)
- Q_PROPERTY(QVector<QPolygonF> currentPageBoundingPolygons READ currentPageBoundingPolygons NOTIFY currentPageBoundingPolygonsChanged)
- Q_PROPERTY(QVector<QPolygonF> currentResultBoundingPolygons READ currentResultBoundingPolygons NOTIFY currentResultBoundingPolygonsChanged)
+ Q_PROPERTY(QList<QPolygonF> currentPageBoundingPolygons READ currentPageBoundingPolygons NOTIFY currentPageBoundingPolygonsChanged)
+ Q_PROPERTY(QList<QPolygonF> currentResultBoundingPolygons READ currentResultBoundingPolygons NOTIFY currentResultBoundingPolygonsChanged)
Q_PROPERTY(QRectF currentResultBoundingRect READ currentResultBoundingRect NOTIFY currentResultBoundingRectChanged)
public:
@@ -72,7 +72,7 @@ public:
QQuickPdfDocument *document() const;
void setDocument(QQuickPdfDocument * document);
- Q_INVOKABLE QVector<QPolygonF> boundingPolygonsOnPage(int page);
+ Q_INVOKABLE QList<QPolygonF> boundingPolygonsOnPage(int page);
int currentPage() const { return m_currentPage; }
void setCurrentPage(int currentPage);
@@ -80,8 +80,8 @@ public:
int currentResult() const { return m_currentResult; }
void setCurrentResult(int currentResult);
- QVector<QPolygonF> currentPageBoundingPolygons() const;
- QVector<QPolygonF> currentResultBoundingPolygons() const;
+ QList<QPolygonF> currentPageBoundingPolygons() const;
+ QList<QPolygonF> currentResultBoundingPolygons() const;
QRectF currentResultBoundingRect() const;
signals:
diff --git a/src/pdf/quick/qquickpdfselection.cpp b/src/pdf/quick/qquickpdfselection.cpp
index 23fbb80b9..bdedb4dfb 100644
--- a/src/pdf/quick/qquickpdfselection.cpp
+++ b/src/pdf/quick/qquickpdfselection.cpp
@@ -141,7 +141,7 @@ void QQuickPdfSelection::setDocument(QQuickPdfDocument *document)
\sa PathMultiline
*/
-QVector<QPolygonF> QQuickPdfSelection::geometry() const
+QList<QPolygonF> QQuickPdfSelection::geometry() const
{
return m_geometry;
}
diff --git a/src/pdf/quick/qquickpdfselection_p.h b/src/pdf/quick/qquickpdfselection_p.h
index fb5b2901b..75631a876 100644
--- a/src/pdf/quick/qquickpdfselection_p.h
+++ b/src/pdf/quick/qquickpdfselection_p.h
@@ -54,10 +54,10 @@
#include <QtQml/qqml.h>
#include <QtQuick/qquickitem.h>
-QT_BEGIN_NAMESPACE
+#include "qquickpdfdocument_p.h"
+QT_BEGIN_NAMESPACE
class QPdfSelection;
-class QQuickPdfDocument;
class QQuickPdfSelection : public QQuickItem
{
@@ -70,7 +70,7 @@ class QQuickPdfSelection : public QQuickItem
Q_PROPERTY(bool hold READ hold WRITE setHold NOTIFY holdChanged)
Q_PROPERTY(QString text READ text NOTIFY textChanged)
- Q_PROPERTY(QVector<QPolygonF> geometry READ geometry NOTIFY selectedAreaChanged)
+ Q_PROPERTY(QList<QPolygonF> geometry READ geometry NOTIFY selectedAreaChanged)
public:
explicit QQuickPdfSelection(QQuickItem *parent = nullptr);
@@ -89,7 +89,7 @@ public:
void setHold(bool hold);
QString text() const;
- QVector<QPolygonF> geometry() const;
+ QList<QPolygonF> geometry() const;
Q_INVOKABLE void clear();
Q_INVOKABLE void selectAll();
@@ -131,7 +131,7 @@ private:
mutable qreal m_heightAtCursor = 0;
QString m_text; // selected text
mutable QString m_pageText; // all text on the page
- QVector<QPolygonF> m_geometry;
+ QList<QPolygonF> m_geometry;
int m_page = 0;
int m_fromCharIndex = -1; // same as anchor position
mutable int m_toCharIndex = -1; // same as cursor position
diff --git a/src/pdf/quick/qquicktableviewextra.cpp b/src/pdf/quick/qquicktableviewextra.cpp
index 601dfff7b..2b59d6c6e 100644
--- a/src/pdf/quick/qquicktableviewextra.cpp
+++ b/src/pdf/quick/qquicktableviewextra.cpp
@@ -37,7 +37,6 @@
#include "qquicktableviewextra_p.h"
#include <QtQml>
#include <QQmlContext>
-#include <QtQuick/private/qquicktableview_p.h>
Q_LOGGING_CATEGORY(qLcTVE, "qt.pdf.tableextra")
diff --git a/src/pdf/quick/qquicktableviewextra_p.h b/src/pdf/quick/qquicktableviewextra_p.h
index cd3035be5..11b4955a1 100644
--- a/src/pdf/quick/qquicktableviewextra_p.h
+++ b/src/pdf/quick/qquicktableviewextra_p.h
@@ -53,11 +53,10 @@
#include <QVariant>
#include <QtQml/qqml.h>
#include <QtQuick/qquickitem.h>
+#include <QtQuick/private/qquicktableview_p.h>
QT_BEGIN_NAMESPACE
-class QQuickTableView;
-
class QQuickTableViewExtra : public QObject
{
Q_OBJECT
diff --git a/src/pdfwidgets/qpdfview.cpp b/src/pdfwidgets/qpdfview.cpp
index 35e368633..cd2a8ef82 100644
--- a/src/pdfwidgets/qpdfview.cpp
+++ b/src/pdfwidgets/qpdfview.cpp
@@ -40,6 +40,8 @@
#include "qpdfpagerenderer.h"
#include <QGuiApplication>
+#include <QPainter>
+#include <QPaintEvent>
#include <QPdfDocument>
#include <QPdfPageNavigation>
#include <QScreen>
@@ -48,8 +50,8 @@
QT_BEGIN_NAMESPACE
-QPdfViewPrivate::QPdfViewPrivate()
- : QAbstractScrollAreaPrivate()
+QPdfViewPrivate::QPdfViewPrivate(QPdfView *q)
+ : q_ptr(q)
, m_document(nullptr)
, m_pageNavigation(nullptr)
, m_pageRenderer(nullptr)
@@ -161,8 +163,8 @@ void QPdfViewPrivate::pageRendered(int pageNumber, QSize imageSize, const QImage
{
Q_Q(QPdfView);
- Q_UNUSED(imageSize)
- Q_UNUSED(requestId)
+ Q_UNUSED(imageSize);
+ Q_UNUSED(requestId);
if (!m_cachedPagesLRU.contains(pageNumber)) {
if (m_cachedPagesLRU.length() > m_pageCacheLimit)
@@ -277,7 +279,8 @@ void QPdfViewPrivate::updateDocumentLayout()
QPdfView::QPdfView(QWidget *parent)
- : QAbstractScrollArea(*new QPdfViewPrivate(), parent)
+ : QAbstractScrollArea(parent)
+ , d_ptr(new QPdfViewPrivate(this))
{
Q_D(QPdfView);
@@ -296,14 +299,6 @@ QPdfView::QPdfView(QWidget *parent)
d->calculateViewport();
}
-/*!
- \internal
-*/
-QPdfView::QPdfView(QPdfViewPrivate &dd, QWidget *parent)
- : QAbstractScrollArea(dd, parent)
-{
-}
-
QPdfView::~QPdfView()
{
}
diff --git a/src/pdfwidgets/qpdfview.h b/src/pdfwidgets/qpdfview.h
index cee1cb64c..25c0e7f69 100644
--- a/src/pdfwidgets/qpdfview.h
+++ b/src/pdfwidgets/qpdfview.h
@@ -107,14 +107,13 @@ Q_SIGNALS:
void documentMarginsChanged(QMargins documentMargins);
protected:
- explicit QPdfView(QPdfViewPrivate &, QWidget *);
-
void paintEvent(QPaintEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
void scrollContentsBy(int dx, int dy) override;
private:
Q_DECLARE_PRIVATE(QPdfView)
+ QScopedPointer<QPdfViewPrivate> d_ptr;
};
QT_END_NAMESPACE
diff --git a/src/pdfwidgets/qpdfview_p.h b/src/pdfwidgets/qpdfview_p.h
index 9fd54b4b6..7e758832c 100644
--- a/src/pdfwidgets/qpdfview_p.h
+++ b/src/pdfwidgets/qpdfview_p.h
@@ -51,18 +51,17 @@
#include "qpdfview.h"
#include <QPointer>
-#include <QtWidgets/private/qabstractscrollarea_p.h>
QT_BEGIN_NAMESPACE
class QPdfPageRenderer;
-class QPdfViewPrivate : public QAbstractScrollAreaPrivate
+class QPdfViewPrivate
{
Q_DECLARE_PUBLIC(QPdfView)
public:
- QPdfViewPrivate();
+ QPdfViewPrivate(QPdfView *q);
void init();
void documentStatusChanged();
@@ -86,6 +85,7 @@ public:
DocumentLayout calculateDocumentLayout() const;
void updateDocumentLayout();
+ QPdfView *q_ptr;
QPointer<QPdfDocument> m_document;
QPdfPageNavigation* m_pageNavigation;
QPdfPageRenderer *m_pageRenderer;
@@ -104,7 +104,7 @@ public:
QRect m_viewport;
QHash<int, QImage> m_pageCache;
- QVector<int> m_cachedPagesLRU;
+ QList<int> m_cachedPagesLRU;
int m_pageCacheLimit;
DocumentLayout m_documentLayout;
diff --git a/src/process/process.pro b/src/process/process.pro
index a90548f9c..eadbcc310 100644
--- a/src/process/process.pro
+++ b/src/process/process.pro
@@ -50,7 +50,7 @@ qtConfig(build_all): CONFIG += build_all
qtConfig(framework) {
# Deploy the QtWebEngineProcess app bundle into the QtWebEngineCore framework.
- DESTDIR = $$MODULE_BASE_OUTDIR/lib/QtWebEngineCore.framework/Versions/5/Helpers
+ DESTDIR = $$MODULE_BASE_OUTDIR/lib/QtWebEngineCore.framework/Versions/$$QT_MAJOR_VERSION/Helpers
# Deploy the entitlements file so macdeployqt can use it.
entitlements.files = QtWebEngineProcess.entitlements
@@ -64,7 +64,7 @@ qtConfig(framework) {
msvc: QMAKE_LFLAGS *= /LARGEADDRESSAWARE
qtConfig(framework) {
- target.path = $$[QT_INSTALL_LIBS]/QtWebEngineCore.framework/Versions/5/Helpers
+ target.path = $$[QT_INSTALL_LIBS]/QtWebEngineCore.framework/Versions/$$QT_MAJOR_VERSION/Helpers
} else {
target.path = $$[QT_INSTALL_LIBEXECS]
}
diff --git a/src/src.pro b/src/src.pro
index 6f8bc2fe4..143fd00ab 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -61,4 +61,3 @@ qtConfig(build-qtpdf):qtConfig(webengine-qtpdf-support) {
# this needs to be last line for qmake -r
qtConfig(build-qtwebengine-core):!contains(SUBDIRS, core): SUBDIRS += core
qtConfig(build-qtpdf):!contains(SUBDIRS, pdf): SUBDIRS += pdf
-
diff --git a/src/tools/qwebengine_convert_dict/main.cpp b/src/tools/qwebengine_convert_dict/main.cpp
index 37b6e0171..14d175c00 100644
--- a/src/tools/qwebengine_convert_dict/main.cpp
+++ b/src/tools/qwebengine_convert_dict/main.cpp
@@ -51,9 +51,9 @@ inline base::FilePath toFilePath(const QString &str)
inline QString toQt(const base::string16 &string)
{
#if defined(OS_WIN)
- return QString::fromStdWString(string.data());
+ return QString::fromStdWString(string);
#else
- return QString::fromUtf16(string.data());
+ return QString::fromUtf16(reinterpret_cast<const char16_t *>(string.data()), string.size());
#endif
}
diff --git a/src/webengine/api/qquickwebenginecertificateerror_p.h b/src/webengine/api/qquickwebenginecertificateerror_p.h
deleted file mode 100644
index 4a8ef6ae0..000000000
--- a/src/webengine/api/qquickwebenginecertificateerror_p.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 QQUICKWEBENGINECERTIFICATEERROR_P_H
-#define QQUICKWEBENGINECERTIFICATEERROR_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 <QObject>
-#include "qquickwebengineview_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QQuickWebEngineCertificateErrorPrivate;
-class CertificateErrorController;
-
-class Q_WEBENGINE_EXPORT QQuickWebEngineCertificateError : public QObject {
- Q_OBJECT
- Q_PROPERTY(QUrl url READ url CONSTANT FINAL)
- Q_PROPERTY(Error error READ error CONSTANT FINAL)
- Q_PROPERTY(QString description READ description CONSTANT FINAL)
- Q_PROPERTY(bool overridable READ overridable CONSTANT FINAL)
-
-public:
-
- // Keep this identical to CertificateErrorController::CertificateError, or add mapping layer.
- enum Error {
- SslPinnedKeyNotInCertificateChain = -150,
- CertificateCommonNameInvalid = -200,
- CertificateDateInvalid = -201,
- CertificateAuthorityInvalid = -202,
- CertificateContainsErrors = -203,
- CertificateNoRevocationMechanism = -204,
- CertificateUnableToCheckRevocation = -205,
- CertificateRevoked = -206,
- CertificateInvalid = -207,
- CertificateWeakSignatureAlgorithm = -208,
- CertificateNonUniqueName = -210,
- CertificateWeakKey = -211,
- CertificateNameConstraintViolation = -212,
- CertificateValidityTooLong = -213,
- CertificateTransparencyRequired = -214,
- CertificateKnownInterceptionBlocked = -217,
- };
- Q_ENUM(Error)
-
- QQuickWebEngineCertificateError(const QSharedPointer<CertificateErrorController> &controller, QObject *parent = 0);
- ~QQuickWebEngineCertificateError();
-
- Q_INVOKABLE void defer();
- Q_INVOKABLE void ignoreCertificateError();
- Q_INVOKABLE void rejectCertificate();
- QUrl url() const;
- Error error() const;
- QString description() const;
- bool overridable() const;
- bool deferred() const;
- bool answered() const;
-
-private:
- Q_DISABLE_COPY(QQuickWebEngineCertificateError)
- Q_DECLARE_PRIVATE(QQuickWebEngineCertificateError)
- QScopedPointer<QQuickWebEngineCertificateErrorPrivate> d_ptr;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QQuickWebEngineCertificateError)
-
-#endif // QQUICKWEBENGINECERTIFICATEERROR_P_H
diff --git a/src/webengine/api/qquickwebengineclientcertificateselection.cpp b/src/webengine/api/qquickwebengineclientcertificateselection.cpp
index c48a59887..f6c37a5b0 100644
--- a/src/webengine/api/qquickwebengineclientcertificateselection.cpp
+++ b/src/webengine/api/qquickwebengineclientcertificateselection.cpp
@@ -132,8 +132,9 @@ void QQuickWebEngineClientCertificateOption::select()
\sa {WebEngineView::selectClientCertificate}{WebEngineView.selectClientCertificate}
*/
-QQuickWebEngineClientCertificateSelection::QQuickWebEngineClientCertificateSelection(QSharedPointer<ClientCertSelectController> selectController)
- : QObject(), d_ptr(selectController)
+QQuickWebEngineClientCertificateSelection::QQuickWebEngineClientCertificateSelection(
+ QSharedPointer<QtWebEngineCore::ClientCertSelectController> selectController)
+ : QObject(), d_ptr(selectController)
{}
int QQuickWebEngineClientCertificateSelection::certificates_count(
@@ -162,7 +163,7 @@ QQuickWebEngineClientCertificateOption *QQuickWebEngineClientCertificateSelectio
QQmlListProperty<QQuickWebEngineClientCertificateOption> QQuickWebEngineClientCertificateSelection::certificates()
{
if (m_certificates.empty()) {
- QVector<QSslCertificate> certificates = d_ptr->certificates();
+ QList<QSslCertificate> certificates = d_ptr->certificates();
for (int i = 0; i < certificates.count(); ++i)
m_certificates.push_back(new QQuickWebEngineClientCertificateOption(this, i));
}
diff --git a/src/webengine/api/qquickwebengineclientcertificateselection_p.h b/src/webengine/api/qquickwebengineclientcertificateselection_p.h
index adf8b5f7c..fe868e76c 100644
--- a/src/webengine/api/qquickwebengineclientcertificateselection_p.h
+++ b/src/webengine/api/qquickwebengineclientcertificateselection_p.h
@@ -57,14 +57,17 @@
#include <QtCore/QObject>
#include <QtCore/QSharedPointer>
#include <QtCore/QUrl>
-#include <QtCore/QVector>
+#include <QtCore/QList>
#include <QtQml/QQmlListProperty>
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
+namespace QtWebEngineCore {
+class ClientCertSelectController;
+}
+
QT_BEGIN_NAMESPACE
-class ClientCertSelectController;
class QQuickWebEngineClientCertificateSelection;
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineClientCertificateOption : public QObject {
@@ -114,10 +117,11 @@ private:
static int certificates_count(QQmlListProperty<QQuickWebEngineClientCertificateOption> *p);
static QQuickWebEngineClientCertificateOption *certificates_at(QQmlListProperty<QQuickWebEngineClientCertificateOption> *p, int idx);
- explicit QQuickWebEngineClientCertificateSelection(QSharedPointer<ClientCertSelectController>);
+ explicit QQuickWebEngineClientCertificateSelection(
+ QSharedPointer<QtWebEngineCore::ClientCertSelectController>);
- mutable QVector<QQuickWebEngineClientCertificateOption *> m_certificates;
- QSharedPointer<ClientCertSelectController> d_ptr;
+ mutable QList<QQuickWebEngineClientCertificateOption *> m_certificates;
+ QSharedPointer<QtWebEngineCore::ClientCertSelectController> d_ptr;
};
QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebenginecontextmenurequest.cpp b/src/webengine/api/qquickwebenginecontextmenurequest.cpp
deleted file mode 100644
index e1ebd4c8c..000000000
--- a/src/webengine/api/qquickwebenginecontextmenurequest.cpp
+++ /dev/null
@@ -1,383 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 "qquickwebenginecontextmenurequest_p.h"
-#include "web_contents_adapter_client.h"
-
-QT_BEGIN_NAMESPACE
-
-// Match MediaType enum
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeNone,
- QQuickWebEngineContextMenuRequest::MediaTypeNone)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeImage,
- QQuickWebEngineContextMenuRequest::MediaTypeImage)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeAudio,
- QQuickWebEngineContextMenuRequest::MediaTypeAudio)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeVideo,
- QQuickWebEngineContextMenuRequest::MediaTypeVideo)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeCanvas,
- QQuickWebEngineContextMenuRequest::MediaTypeCanvas)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeFile,
- QQuickWebEngineContextMenuRequest::MediaTypeFile)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypePlugin,
- QQuickWebEngineContextMenuRequest::MediaTypePlugin)
-
-// Match MediaFlag enum
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaInError,
- QQuickWebEngineContextMenuRequest::MediaInError)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaPaused,
- QQuickWebEngineContextMenuRequest::MediaPaused)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaMuted,
- QQuickWebEngineContextMenuRequest::MediaMuted)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaLoop,
- QQuickWebEngineContextMenuRequest::MediaLoop)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaCanSave,
- QQuickWebEngineContextMenuRequest::MediaCanSave)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaHasAudio,
- QQuickWebEngineContextMenuRequest::MediaHasAudio)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaCanToggleControls,
- QQuickWebEngineContextMenuRequest::MediaCanToggleControls)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaControls,
- QQuickWebEngineContextMenuRequest::MediaControls)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaCanPrint,
- QQuickWebEngineContextMenuRequest::MediaCanPrint)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaCanRotate,
- QQuickWebEngineContextMenuRequest::MediaCanRotate)
-
-// Match EditFlag enum
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanUndo,
- QQuickWebEngineContextMenuRequest::CanUndo)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanRedo,
- QQuickWebEngineContextMenuRequest::CanRedo)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanCut,
- QQuickWebEngineContextMenuRequest::CanCut)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanCopy,
- QQuickWebEngineContextMenuRequest::CanCopy)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanPaste,
- QQuickWebEngineContextMenuRequest::CanPaste)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanDelete,
- QQuickWebEngineContextMenuRequest::CanDelete)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanSelectAll,
- QQuickWebEngineContextMenuRequest::CanSelectAll)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanTranslate,
- QQuickWebEngineContextMenuRequest::CanTranslate)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanEditRichly,
- QQuickWebEngineContextMenuRequest::CanEditRichly)
-
-/*!
- \qmltype ContextMenuRequest
- \instantiates QQuickWebEngineContextMenuRequest
- \inqmlmodule QtWebEngine
- \since QtWebEngine 1.4
-
- \brief A request for showing a context menu.
-
- A ContextMenuRequest is passed as an argument of the
- WebEngineView::contextMenuRequested signal. It provides further
- information about the context of the request. The position of the
- request origin can be found via the \l x and \l y properties.
-
- The \l accepted property of the request indicates whether the request
- is handled by the user code or the default context menu should
- be displayed.
-
- The following code uses a custom menu to handle the request:
-
- \code
- WebEngineView {
- id: view
- // ...
- onContextMenuRequested: function(request) {
- request.accepted = true;
- myMenu.x = request.x;
- myMenu.y = request.y;
- myMenu.trigger.connect(view.triggerWebAction);
- myMenu.popup();
- }
- // ...
- }
- \endcode
-*/
-
-QQuickWebEngineContextMenuRequest::QQuickWebEngineContextMenuRequest(
- const QtWebEngineCore::WebEngineContextMenuData &data, QObject *parent):
- QObject(parent)
- , m_data(new QtWebEngineCore::WebEngineContextMenuData(data))
- , m_accepted(false)
-{
-}
-
-QQuickWebEngineContextMenuRequest::~QQuickWebEngineContextMenuRequest()
-{
-}
-
-/*!
- \qmlproperty int ContextMenuRequest::x
- \readonly
-
- The x coordinate of the user action from where the context
- menu request originates.
-*/
-
-int QQuickWebEngineContextMenuRequest::x() const
-{
- return m_data->position().x();
-}
-
-/*!
- \qmlproperty int ContextMenuRequest::y
- \readonly
-
- The y coordinate of the user action from where the context
- menu request originates.
-*/
-
-int QQuickWebEngineContextMenuRequest::y() const
-{
- return m_data->position().y();
-}
-
-/*!
- \qmlproperty string ContextMenuRequest::selectedText
- \readonly
-
- The selected text the context menu was created for.
-*/
-
-QString QQuickWebEngineContextMenuRequest::selectedText() const
-{
- return m_data->selectedText();
-}
-
-/*!
- \qmlproperty string ContextMenuRequest::linkText
- \readonly
-
- The text of the link if the context menu was requested for a link.
-*/
-
-QString QQuickWebEngineContextMenuRequest::linkText() const
-{
- return m_data->linkText();
-}
-
-/*!
- \qmlproperty url ContextMenuRequest::linkUrl
- \readonly
-
- The URL of the link if the selected web page content is a link.
- It is not guaranteed to be a valid URL.
-*/
-
-QUrl QQuickWebEngineContextMenuRequest::linkUrl() const
-{
- return m_data->unfilteredLinkUrl();
-}
-
-/*!
- \qmlproperty url ContextMenuRequest::mediaUrl
- \readonly
-
- The URL of media if the selected web content is a media element.
-*/
-
-QUrl QQuickWebEngineContextMenuRequest::mediaUrl() const
-{
- return m_data->mediaUrl();
-}
-
-/*!
- \qmlproperty enumeration ContextMenuRequest::mediaType
- \readonly
-
- The type of the media element or \c MediaTypeNone if
- the selected web page content is not a media element.
-
- \value ContextMenuRequest.MediaTypeNone
- Not a media.
- \value ContextMenuRequest.MediaTypeImage
- An image.
- \value ContextMenuRequest.MediaTypeVideo
- A video.
- \value ContextMenuRequest.MediaTypeAudio
- An audio element.
- \value ContextMenuRequest.MediaTypeCanvas
- A canvas.
- \value ContextMenuRequest.MediaTypeFile
- A file.
- \value ContextMenuRequest.MediaTypePlugin
- A plugin.
-*/
-
-QQuickWebEngineContextMenuRequest::MediaType QQuickWebEngineContextMenuRequest::mediaType() const
-{
- return static_cast<QQuickWebEngineContextMenuRequest::MediaType>(m_data->mediaType());
-}
-
-/*!
- \qmlproperty bool ContextMenuRequest::isContentEditable
- \readonly
-
- Indicates whether the selected web content is editable.
-*/
-
-bool QQuickWebEngineContextMenuRequest::isContentEditable() const
-{
- return m_data->isEditable();
-}
-
-/*!
- \qmlproperty string ContextMenuRequest::misspelledWord
- \readonly
-
- If the context is a word considered misspelled by the spell-checker,
- returns the misspelled word.
-*/
-
-QString QQuickWebEngineContextMenuRequest::misspelledWord() const
-{
- return m_data->misspelledWord();
-}
-
-/*!
- \qmlproperty stringlist ContextMenuRequest::spellCheckerSuggestions
- \readonly
-
- If the context is a word considered misspelled by the spell-checker,
- returns a list of suggested replacements.
-*/
-
-QStringList QQuickWebEngineContextMenuRequest::spellCheckerSuggestions() const
-{
- return m_data->spellCheckerSuggestions();
-}
-
-/*!
- \qmlproperty bool ContextMenuRequest::accepted
-
- Indicates whether the context menu request has been
- handled by the signal handler.
-
- If the property is \c false after any signal handlers
- for WebEngineView::contextMenuRequested have been executed,
- a default context menu will be shown.
- To prevent this, set \c{request.accepted} to \c true.
-
- The default is \c false.
-
- \note The default content of the context menu depends on the
- web element for which the request was actually generated.
-*/
-
-bool QQuickWebEngineContextMenuRequest::isAccepted() const
-{
- return m_accepted;
-}
-
-void QQuickWebEngineContextMenuRequest::setAccepted(bool accepted)
-{
- m_accepted = accepted;
-}
-
-/*!
- \qmlproperty flags ContextMenuRequest::mediaFlags
- \readonly
- \since QtWebEngine 1.7
-
- The current media element's status and its available operations.
- \c MediaNone if the selected web page content is not a media element.
-
- \value ContextMenuRequest.MediaInError
- An error occurred.
- \value ContextMenuRequest.MediaPaused
- Media is paused.
- \value ContextMenuRequest.MediaMuted
- Media is muted.
- \value ContextMenuRequest.MediaLoop
- Media can be looped.
- \value ContextMenuRequest.MediaCanSave
- Media can be saved.
- \value ContextMenuRequest.MediaHasAudio
- Media has audio.
- \value ContextMenuRequest.MediaCanToggleControls
- Media can show controls.
- \value ContextMenuRequest.MediaControls
- Media controls are shown.
- \value ContextMenuRequest.MediaCanPrint
- Media is printable.
- \value ContextMenuRequest.MediaCanRotate
- Media is rotatable.
-*/
-QQuickWebEngineContextMenuRequest::MediaFlags QQuickWebEngineContextMenuRequest::mediaFlags() const
-{
- return static_cast<QQuickWebEngineContextMenuRequest::MediaFlags>(m_data->mediaFlags());
-}
-
-/*!
- \qmlproperty flags ContextMenuRequest::editFlags
- \readonly
- \since QtWebEngine 1.7
-
- The available edit operations in the current context or \c CanDoNone if no actions are available.
-
- \value ContextMenuRequest.CanUndo
- Undo is available.
- \value ContextMenuRequest.CanRedo
- Redo is available.
- \value ContextMenuRequest.CanCut
- Cut is available.
- \value ContextMenuRequest.CanCopy
- Copy is available.
- \value ContextMenuRequest.CanPaste
- Paste is available.
- \value ContextMenuRequest.CanDelete
- Delete is available.
- \value ContextMenuRequest.CanSelectAll
- Select All is available.
- \value ContextMenuRequest.CanTranslate
- Translate is available.
- \value ContextMenuRequest.CanEditRichly
- Context is richly editable.
-*/
-QQuickWebEngineContextMenuRequest::EditFlags QQuickWebEngineContextMenuRequest::editFlags() const
-{
- return static_cast<QQuickWebEngineContextMenuRequest::EditFlags>(m_data->editFlags());
-}
-
-QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp
deleted file mode 100644
index 767ada58f..000000000
--- a/src/webengine/api/qquickwebenginedownloaditem.cpp
+++ /dev/null
@@ -1,789 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 "qquickwebenginedownloaditem_p.h"
-#include "qquickwebenginedownloaditem_p_p.h"
-
-#include "profile_adapter.h"
-#include "qquickwebengineprofile_p.h"
-
-#include <QDir>
-#include "QFileInfo"
-
-using QtWebEngineCore::ProfileAdapterClient;
-
-QT_BEGIN_NAMESPACE
-
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NoReason, QQuickWebEngineDownloadItem::NoReason)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileFailed, QQuickWebEngineDownloadItem::FileFailed)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileAccessDenied, QQuickWebEngineDownloadItem::FileAccessDenied)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileNoSpace, QQuickWebEngineDownloadItem::FileNoSpace)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileNameTooLong, QQuickWebEngineDownloadItem::FileNameTooLong)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileTooLarge, QQuickWebEngineDownloadItem::FileTooLarge)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileVirusInfected, QQuickWebEngineDownloadItem::FileVirusInfected)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileTransientError, QQuickWebEngineDownloadItem::FileTransientError)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileBlocked, QQuickWebEngineDownloadItem::FileBlocked)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileSecurityCheckFailed, QQuickWebEngineDownloadItem::FileSecurityCheckFailed)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileTooShort, QQuickWebEngineDownloadItem::FileTooShort)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileHashMismatch, QQuickWebEngineDownloadItem::FileHashMismatch)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkFailed, QQuickWebEngineDownloadItem::NetworkFailed)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkTimeout, QQuickWebEngineDownloadItem::NetworkTimeout)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkDisconnected, QQuickWebEngineDownloadItem::NetworkDisconnected)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkServerDown, QQuickWebEngineDownloadItem::NetworkServerDown)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkInvalidRequest, QQuickWebEngineDownloadItem::NetworkInvalidRequest)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerFailed, QQuickWebEngineDownloadItem::ServerFailed)
-//ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerNoRange, QQuickWebEngineDownloadItem::ServerNoRange)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerBadContent, QQuickWebEngineDownloadItem::ServerBadContent)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerUnauthorized, QQuickWebEngineDownloadItem::ServerUnauthorized)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerCertProblem, QQuickWebEngineDownloadItem::ServerCertProblem)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerForbidden, QQuickWebEngineDownloadItem::ServerForbidden)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerUnreachable, QQuickWebEngineDownloadItem::ServerUnreachable)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::UserCanceled, QQuickWebEngineDownloadItem::UserCanceled)
-//ASSERT_ENUMS_MATCH(ProfileAdapterClient::UserShutdown, QQuickWebEngineDownloadItem::UserShutdown)
-//ASSERT_ENUMS_MATCH(ProfileAdapterClient::Crash, QQuickWebEngineDownloadItem::Crash)
-
-static inline QQuickWebEngineDownloadItem::DownloadState toDownloadState(int state) {
- switch (state) {
- case ProfileAdapterClient::DownloadInProgress:
- return QQuickWebEngineDownloadItem::DownloadInProgress;
- case ProfileAdapterClient::DownloadCompleted:
- return QQuickWebEngineDownloadItem::DownloadCompleted;
- case ProfileAdapterClient::DownloadCancelled:
- return QQuickWebEngineDownloadItem::DownloadCancelled;
- case ProfileAdapterClient::DownloadInterrupted:
- return QQuickWebEngineDownloadItem::DownloadInterrupted;
- default:
- Q_UNREACHABLE();
- return QQuickWebEngineDownloadItem::DownloadCancelled;
- }
-}
-
-static inline QQuickWebEngineDownloadItem::DownloadInterruptReason toDownloadInterruptReason(int reason)
-{
- return static_cast<QQuickWebEngineDownloadItem::DownloadInterruptReason>(reason);
-}
-
-QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p, const QUrl &url)
- : profile(p)
- , downloadId(-1)
- , downloadState(QQuickWebEngineDownloadItem::DownloadCancelled)
- , savePageFormat(QQuickWebEngineDownloadItem::UnknownSaveFormat)
- , type(QQuickWebEngineDownloadItem::Attachment)
- , interruptReason(QQuickWebEngineDownloadItem::NoReason)
- , totalBytes(-1)
- , receivedBytes(0)
- , downloadFinished(false)
- , downloadPaused(false)
- , view(nullptr)
- , downloadUrl(url)
- , isCustomFileName(false)
-{
-}
-
-QQuickWebEngineDownloadItemPrivate::~QQuickWebEngineDownloadItemPrivate()
-{
- if (profile)
- profile->d_ptr->downloadDestroyed(downloadId);
-}
-
-/*!
- \qmltype WebEngineDownloadItem
- \instantiates QQuickWebEngineDownloadItem
- \inqmlmodule QtWebEngine
- \since QtWebEngine 1.1
- \brief Provides information about a download.
-
- WebEngineDownloadItem models a download throughout its life cycle, starting
- with a pending download request and finishing with a completed download. It
- can be used, for example, to get information about new downloads, to monitor
- progress, and to pause, resume, and cancel downloads.
-
- Downloads are usually triggered by user interaction on a web page. It is the
- WebEngineProfile's responsibility to notify the application of new download
- requests, which it does by emitting the
- \l{WebEngineProfile::downloadRequested}{downloadRequested} signal together
- with a newly created WebEngineDownloadItem. The application can then examine
- this item and decide whether to accept it or not. A signal handler must
- explicitly call accept() on the item for \QWE to actually start
- downloading and writing data to disk. If no signal handler calls accept(),
- then the download request will be automatically rejected and nothing will be
- written to disk.
-
- \note Some properties, like the \l path under which the file will be saved,
- can only be changed before calling accept().
-
- \section2 Object Life Cycle
-
- All items are guaranteed to be valid during the emission of the
- \l{WebEngineProfile::downloadRequested}{downloadRequested} signal. If
- accept() is \e not called by any signal handler, then the item will be
- deleted \e immediately after signal emission. This means that the
- application \b{must not} keep references to rejected download items.
-
- \section2 Web Page Downloads
-
- In addition to normal file downloads, which consist simply of retrieving
- some raw bytes from the network and writing them to disk, \QWE also
- supports saving complete web pages, which involves parsing the page's HTML,
- downloading any dependent resources, and potentially packaging everything
- into a special file format (\l savePageFormat). To check if a download is
- for a file or a web page, use \l isSavePageDownload.
-
- \sa WebEngineProfile, WebEngineProfile::downloadRequested,
- WebEngineProfile::downloadFinished
-*/
-
-void QQuickWebEngineDownloadItemPrivate::update(const ProfileAdapterClient::DownloadItemInfo &info)
-{
- Q_Q(QQuickWebEngineDownloadItem);
-
- updateState(toDownloadState(info.state));
-
- if (toDownloadInterruptReason(info.downloadInterruptReason) != interruptReason) {
- interruptReason = toDownloadInterruptReason(info.downloadInterruptReason);
- Q_EMIT q->interruptReasonChanged();
- }
-
- if (info.receivedBytes != receivedBytes) {
- receivedBytes = info.receivedBytes;
- Q_EMIT q->receivedBytesChanged();
- }
-
- if (info.totalBytes != totalBytes) {
- totalBytes = info.totalBytes;
- Q_EMIT q->totalBytesChanged();
- }
-
- if (info.done)
- setFinished();
-
- if (info.paused != downloadPaused) {
- downloadPaused = info.paused;
- Q_EMIT q->isPausedChanged();
- }
-}
-
-void QQuickWebEngineDownloadItemPrivate::updateState(QQuickWebEngineDownloadItem::DownloadState newState)
-{
- Q_Q(QQuickWebEngineDownloadItem);
-
- if (downloadState != newState) {
- downloadState = newState;
- Q_EMIT q->stateChanged();
- }
-}
-
-void QQuickWebEngineDownloadItemPrivate::setFinished()
-{
- Q_Q(QQuickWebEngineDownloadItem);
-
- if (downloadFinished)
- return;
-
- downloadFinished = true;
- Q_EMIT q->isFinishedChanged();
-}
-
-/*!
- \qmlmethod void WebEngineDownloadItem::accept()
-
- Accepts the download request, which will start the download.
-
- If the item is in the \c DownloadRequested state, then it will transition
- into the \c DownloadInProgress state and the downloading will begin. If the
- item is in any other state, then nothing will happen.
-
- \sa state
-*/
-
-void QQuickWebEngineDownloadItem::accept()
-{
- Q_D(QQuickWebEngineDownloadItem);
-
- if (d->downloadState != QQuickWebEngineDownloadItem::DownloadRequested)
- return;
-
- d->updateState(QQuickWebEngineDownloadItem::DownloadInProgress);
-}
-
-/*!
- \qmlmethod void WebEngineDownloadItem::cancel()
-
- Cancels the download.
-
- If the item is in the \c DownloadInProgress state, then it will transition
- into the \c DownloadCancelled state, the downloading will stop, and
- partially downloaded files will be deleted from disk.
-
- If the item is in the \c DownloadCompleted state, then nothing will happen.
- If the item is in any other state, then it will transition into the \c
- DownloadCancelled state without further effect.
-
- \sa state
-*/
-
-void QQuickWebEngineDownloadItem::cancel()
-{
- Q_D(QQuickWebEngineDownloadItem);
-
- QQuickWebEngineDownloadItem::DownloadState state = d->downloadState;
-
- if (state == QQuickWebEngineDownloadItem::DownloadCompleted
- || state == QQuickWebEngineDownloadItem::DownloadCancelled)
- return;
-
- d->updateState(QQuickWebEngineDownloadItem::DownloadCancelled);
- d->setFinished();
-
- // We directly cancel the download if the user cancels before
- // it even started, so no need to notify the profile here.
- if (state == QQuickWebEngineDownloadItem::DownloadInProgress) {
- if (d->profile)
- d->profile->d_ptr->cancelDownload(d->downloadId);
- }
-}
-
-
-/*!
- \qmlmethod void WebEngineDownloadItem::pause()
- \since QtWebEngine 1.6
-
- Pauses the download.
-
- Has no effect if the state is not \c DownloadInProgress. Does not change the
- state.
-
- \sa resume, isPaused
-*/
-
-void QQuickWebEngineDownloadItem::pause()
-{
- Q_D(QQuickWebEngineDownloadItem);
-
- QQuickWebEngineDownloadItem::DownloadState state = d->downloadState;
-
- if (state != QQuickWebEngineDownloadItem::DownloadInProgress)
- return;
-
- if (d->profile)
- d->profile->d_ptr->profileAdapter()->pauseDownload(d->downloadId);
-}
-
-/*!
- \qmlmethod void WebEngineDownloadItem::resume()
- \since QtWebEngine 1.6
-
- Resumes the download if it was paused or interrupted.
-
- Has no effect if the state is not \c DownloadInProgress or \c
- DownloadInterrupted. Does not change the state.
-
- \sa pause, isPaused
-*/
-void QQuickWebEngineDownloadItem::resume()
-{
- Q_D(QQuickWebEngineDownloadItem);
-
- QQuickWebEngineDownloadItem::DownloadState state = d->downloadState;
-
- if (d->downloadFinished || (state != QQuickWebEngineDownloadItem::DownloadInProgress && state != QQuickWebEngineDownloadItem::DownloadInterrupted))
- return;
-
- if (d->profile)
- d->profile->d_ptr->profileAdapter()->resumeDownload(d->downloadId);
-}
-
-/*!
- \qmlproperty int WebEngineDownloadItem::id
-
- Holds the download item's ID.
-*/
-
-quint32 QQuickWebEngineDownloadItem::id() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->downloadId;
-}
-
-/*!
- \qmlproperty enumeration WebEngineDownloadItem::state
-
- Describes the state of the download:
-
- \value WebEngineDownloadItem.DownloadRequested
- Download has been requested, but it has not been accepted yet.
- \value WebEngineDownloadItem.DownloadInProgress
- Download is in progress.
- \value WebEngineDownloadItem.DownloadCompleted
- Download completed successfully.
- \value WebEngineDownloadItem.DownloadCancelled
- Download was cancelled by the user.
- \value WebEngineDownloadItem.DownloadInterrupted
- Download has been interrupted (by the server or because of lost connectivity).
-*/
-
-QQuickWebEngineDownloadItem::DownloadState QQuickWebEngineDownloadItem::state() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->downloadState;
-}
-
-/*!
- \qmlproperty int WebEngineDownloadItem::totalBytes
-
- Holds the total amount of data to download in bytes.
-
- \c -1 means the total size is unknown.
-*/
-
-qint64 QQuickWebEngineDownloadItem::totalBytes() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->totalBytes;
-}
-
-/*!
- \qmlproperty int WebEngineDownloadItem::receivedBytes
-
- Holds the amount of data in bytes that has been downloaded so far.
-*/
-
-qint64 QQuickWebEngineDownloadItem::receivedBytes() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->receivedBytes;
-}
-
-/*!
- \qmlproperty url WebEngineDownloadItem::url
- \readonly
- \since QtWebEngine 1.10
-
- Returns the download's origin URL.
-*/
-
-QUrl QQuickWebEngineDownloadItem::url() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->downloadUrl;
-}
-
-/*!
- \qmlproperty string WebEngineDownloadItem::mimeType
- \since QtWebEngine 1.2
-
- Holds the MIME type of the download.
-*/
-
-QString QQuickWebEngineDownloadItem::mimeType() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->mimeType;
-}
-
-/*!
- \qmlproperty string WebEngineDownloadItem::path
- \obsolete
-
- Use \l suggestedFileName, \l downloadDirectory, and
- \l downloadFileName instead.
-
- Holds the full target path where data is being downloaded to.
-
- The path includes the file name. The default suggested path is the standard
- download location and file name is deduced not to overwrite already existing files.
-
- The download path can only be set in the
- \l{WebEngineProfile::downloadRequested}{downloadRequested} handler before
- the download is accepted.
-
- \sa WebEngineProfile::downloadRequested(), accept()
-*/
-
-QString QQuickWebEngineDownloadItem::path() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return QDir::cleanPath(QDir(d->downloadDirectory).filePath(d->downloadFileName));
-}
-
-void QQuickWebEngineDownloadItem::setPath(QString path)
-{
- Q_D(QQuickWebEngineDownloadItem);
- if (d->downloadState != QQuickWebEngineDownloadItem::DownloadRequested) {
- qWarning("Setting the download path is not allowed after the download has been accepted.");
- return;
- }
- if (QDir(d->downloadDirectory).filePath(d->downloadFileName) != path) {
- if (QFileInfo(path).fileName().isEmpty()) {
- qWarning("The download path does not include file name.");
- return;
- }
-
- if (QFileInfo(path).isDir()) {
- qWarning("The download path matches with an already existing directory path.");
- return;
- }
-
- QString newDirectory;
- QString newFileName;
-
- if (QFileInfo(path).fileName() == path) {
- newDirectory = QStringLiteral("");
- newFileName = path;
- } else {
- newDirectory = QFileInfo(path).path();
- newFileName = QFileInfo(path).fileName();
- }
-
- if (d->downloadDirectory != newDirectory) {
- d->downloadDirectory = newDirectory;
- Q_EMIT pathChanged();
- Q_EMIT downloadDirectoryChanged();
- }
-
- if (d->downloadFileName != newFileName) {
- d->downloadFileName = newFileName;
- Q_EMIT pathChanged();
- Q_EMIT downloadFileNameChanged();
- }
- }
-}
-
-/*!
- \qmlproperty string WebEngineDownloadItem::downloadDirectory
- \since QtWebEngine 1.10
-
- Holds the full target path without file name where data is being downloaded to.
-
- The download directory can only be set in the
- \l{WebEngineProfile::downloadRequested}{downloadRequested} handler before
- the download is accepted.
-
- \sa WebEngineProfile::downloadRequested(), accept()
-*/
-
-QString QQuickWebEngineDownloadItem::downloadDirectory() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->downloadDirectory;
-}
-
-void QQuickWebEngineDownloadItem::setDownloadDirectory(const QString &directory)
-{
- Q_D(QQuickWebEngineDownloadItem);
- if (d->downloadState != QQuickWebEngineDownloadItem::DownloadRequested) {
- qWarning("Setting the download directory is not allowed after the download has been accepted.");
- return;
- }
-
- bool isPathChanged = false;
- QString changeDirectory = d->downloadDirectory;
- if (!directory.isEmpty() && changeDirectory != directory) {
- changeDirectory = directory;
-
- if (d->downloadDirectory != changeDirectory) {
- d->downloadDirectory = changeDirectory;
- Q_EMIT downloadDirectoryChanged();
- isPathChanged = true;
- }
-
- if (!d->isCustomFileName) {
- QString newFileName = QFileInfo(d->profile->d_ptr->profileAdapter()->determineDownloadPath(d->downloadDirectory,
- d->suggestedFileName,
- d->startTime)).fileName();
- if (d->downloadFileName != newFileName) {
- d->downloadFileName = newFileName;
- Q_EMIT downloadFileNameChanged();
- isPathChanged = true;
- }
- }
- }
-
- if (isPathChanged)
- Q_EMIT pathChanged();
-}
-
-/*!
- \qmlproperty string WebEngineDownloadItem::downloadFileName
- \since QtWebEngine 1.10
-
- Holds the name of the file to which data is being downloaded.
-
- The download file name can only be set in the
- \l{WebEngineProfile::downloadRequested}{downloadRequested} handler before
- the download is accepted.
-
- \sa WebEngineProfile::downloadRequested(), accept()
-*/
-
-QString QQuickWebEngineDownloadItem::downloadFileName() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->downloadFileName;
-}
-
-void QQuickWebEngineDownloadItem::setDownloadFileName(const QString &fileName)
-{
- Q_D(QQuickWebEngineDownloadItem);
- if (d->downloadState != QQuickWebEngineDownloadItem::DownloadRequested) {
- qWarning("Setting the download file name is not allowed after the download has been accepted.");
- return;
- }
-
- if (d->downloadFileName != fileName && !fileName.isEmpty()) {
- d->downloadFileName = fileName;
- d->isCustomFileName = true;
- Q_EMIT downloadFileNameChanged();
- Q_EMIT pathChanged();
- }
-}
-
-/*!
- \qmlproperty string WebEngineDownloadItem::suggestedFileName
- \since QtWebEngine 1.10
-
- Returns the suggested file name.
-*/
-
-QString QQuickWebEngineDownloadItem::suggestedFileName() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->suggestedFileName;
-}
-
-/*!
- \qmlproperty enumeration WebEngineDownloadItem::savePageFormat
- \since QtWebEngine 1.3
-
- Describes the format that is used to save a web page.
-
- \value WebEngineDownloadItem.UnknownSaveFormat
- This is not a request for downloading a complete web page.
- \value WebEngineDownloadItem.SingleHtmlSaveFormat
- The page is saved as a single HTML page. Resources such as images
- are not saved.
- \value WebEngineDownloadItem.CompleteHtmlSaveFormat
- The page is saved as a complete HTML page, for example a directory
- containing the single HTML page and the resources.
- \value WebEngineDownloadItem.MimeHtmlSaveFormat
- The page is saved as a complete web page in the MIME HTML format.
-*/
-
-QQuickWebEngineDownloadItem::SavePageFormat QQuickWebEngineDownloadItem::savePageFormat() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->savePageFormat;
-}
-
-void QQuickWebEngineDownloadItem::setSavePageFormat(QQuickWebEngineDownloadItem::SavePageFormat format)
-{
- Q_D(QQuickWebEngineDownloadItem);
- if (d->savePageFormat != format) {
- d->savePageFormat = format;
- Q_EMIT savePageFormatChanged();
- }
-}
-
-/*!
- \qmlproperty enumeration WebEngineDownloadItem::type
- \readonly
- \since QtWebEngine 1.4
- \obsolete
-
- Describes the requested download's type.
-
- \note This property works unreliably, except for \c SavePage
- downloads. Use \l isSavePageDownload instead.
-
- \value WebEngineDownloadItem.Attachment The web server's response includes a
- \c Content-Disposition header with the \c attachment directive. If \c Content-Disposition
- is present in the reply, the web server is indicating that the client should prompt the
- user to save the content regardless of the content type.
- See \l {RFC 2616 section 19.5.1} for details.
- \value WebEngineDownloadItem.DownloadAttribute The user clicked a link with the \c download
- attribute.
- \value WebEngineDownloadItem.UserRequested The user initiated the download, for example by
- selecting a web action.
- \value WebEngineDownloadItem.SavePage Saving of the current page was requested (for example by
- the \l{WebEngineView::WebAction}{WebEngineView.SavePage} web action).
-
-*/
-
-QQuickWebEngineDownloadItem::DownloadType QQuickWebEngineDownloadItem::type() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->type;
-}
-
-/*!
- \qmlproperty bool WebEngineDownloadItem::isSavePageDownload
- \readonly
- \since QtWebEngine 1.7
-
- Whether this is a download request for saving a web page or a file.
-
- \sa savePageFormat
-*/
-bool QQuickWebEngineDownloadItem::isSavePageDownload() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->type == QQuickWebEngineDownloadItem::SavePage;
-}
-
-/*!
- \qmlproperty enumeration WebEngineDownloadItem::interruptReason
- \readonly
- \since QtWebEngine 1.5
-
- Returns the reason why the download was interrupted:
-
- \value WebEngineDownloadItem.NoReason Unknown reason or not interrupted.
- \value WebEngineDownloadItem.FileFailed General file operation failure.
- \value WebEngineDownloadItem.FileAccessDenied The file cannot be written locally, due to access restrictions.
- \value WebEngineDownloadItem.FileNoSpace Insufficient space on the target drive.
- \value WebEngineDownloadItem.FileNameTooLong The directory or file name is too long.
- \value WebEngineDownloadItem.FileTooLarge The file size exceeds the file system limitation.
- \value WebEngineDownloadItem.FileVirusInfected The file is infected with a virus.
- \value WebEngineDownloadItem.FileTransientError Temporary problem (for example the file is in use,
- out of memory, or too many files are opened at once).
- \value WebEngineDownloadItem.FileBlocked The file was blocked due to local policy.
- \value WebEngineDownloadItem.FileSecurityCheckFailed An attempt to check the safety of the download
- failed due to unexpected reasons.
- \value WebEngineDownloadItem.FileTooShort An attempt was made to seek past the end of a file when
- opening a file (as part of resuming a previously interrupted download).
- \value WebEngineDownloadItem.FileHashMismatch The partial file did not match the expected hash.
-
- \value WebEngineDownloadItem.NetworkFailed General network failure.
- \value WebEngineDownloadItem.NetworkTimeout The network operation has timed out.
- \value WebEngineDownloadItem.NetworkDisconnected The network connection has been terminated.
- \value WebEngineDownloadItem.NetworkServerDown The server has gone down.
- \value WebEngineDownloadItem.NetworkInvalidRequest The network request was invalid (for example, the
- original or redirected URL is invalid, has an unsupported scheme, or is disallowed by policy).
-
- \value WebEngineDownloadItem.ServerFailed General server failure.
- \value WebEngineDownloadItem.ServerBadContent The server does not have the requested data.
- \value WebEngineDownloadItem.ServerUnauthorized The server did not authorize access to the resource.
- \value WebEngineDownloadItem.ServerCertProblem A problem with the server certificate occurred.
- \value WebEngineDownloadItem.ServerForbidden Access forbidden by the server.
- \value WebEngineDownloadItem.ServerUnreachable Unexpected server response (might indicate that
- the responding server may not be the intended server).
- \value WebEngineDownloadItem.UserCanceled The user canceled the download.
-
- \sa interruptReasonString
-*/
-
-QQuickWebEngineDownloadItem::DownloadInterruptReason QQuickWebEngineDownloadItem::interruptReason() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->interruptReason;
-}
-
-/*!
- \qmlproperty string WebEngineDownloadItem::interruptReasonString
- Returns a human-readable description of the reason for interrupting the download.
- \since QtWebEngine 1.5
-
- \sa interruptReason
-*/
-QString QQuickWebEngineDownloadItem::interruptReasonString() const
-{
- return ProfileAdapterClient::downloadInterruptReasonToString(
- static_cast<ProfileAdapterClient::DownloadInterruptReason>(interruptReason()));
-}
-
-/*!
- \qmlproperty bool WebEngineDownloadItem::isFinished
- \readonly
- \since QtWebEngine 1.6
-
- Whether this download is finished (completed, cancelled, or non-resumable interrupted state).
- */
-
-bool QQuickWebEngineDownloadItem::isFinished() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->downloadFinished;
-}
-
-/*!
- \qmlproperty bool WebEngineDownloadItem::isPaused
- \readonly
- \since QtWebEngine 1.6
-
- Whether this download is paused.
-
- \sa pause, resume
- */
-
-bool QQuickWebEngineDownloadItem::isPaused() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->downloadPaused;
-}
-
-/*!
- \qmlproperty WebEngineView WebEngineDownloadItem::view
- \readonly
- \since QtWebEngine 1.8
-
- Returns the view the download was requested on. If the download was not triggered by content in a view,
- \c nullptr is returned.
-
- \sa WebEngineView
-*/
-QQuickWebEngineView *QQuickWebEngineDownloadItem::view() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->view;
-}
-
-QQuickWebEngineDownloadItem::QQuickWebEngineDownloadItem(QQuickWebEngineDownloadItemPrivate *p, QObject *parent)
- : QObject(parent)
- , d_ptr(p)
-{
- p->q_ptr = this;
-}
-
-QQuickWebEngineDownloadItem::~QQuickWebEngineDownloadItem()
-{
- if (!isFinished())
- cancel();
-}
-
-QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebenginedownloaditem_p_p.h b/src/webengine/api/qquickwebenginedownloaditem_p_p.h
deleted file mode 100644
index acd7fe806..000000000
--- a/src/webengine/api/qquickwebenginedownloaditem_p_p.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 QQUICKWEBENGINEDOWNLOADITEM_P_P_H
-#define QQUICKWEBENGINEDOWNLOADITEM_P_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 "profile_adapter_client.h"
-#include "qquickwebenginedownloaditem_p.h"
-#include "qquickwebengineprofile.h"
-#include <QString>
-#include <QPointer>
-
-QT_BEGIN_NAMESPACE
-class QQuickWebEngineProfilePrivate;
-class QQuickWebEngineView;
-
-class QQuickWebEngineDownloadItemPrivate {
- QQuickWebEngineDownloadItem *q_ptr;
- QPointer<QQuickWebEngineProfile> profile;
- friend class QQuickWebEngineProfilePrivate;
-public:
- Q_DECLARE_PUBLIC(QQuickWebEngineDownloadItem)
- QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p, const QUrl &url);
- ~QQuickWebEngineDownloadItemPrivate();
-
- quint32 downloadId;
- qint64 startTime;
- QQuickWebEngineDownloadItem::DownloadState downloadState;
- QQuickWebEngineDownloadItem::SavePageFormat savePageFormat;
- QQuickWebEngineDownloadItem::DownloadType type;
- QQuickWebEngineDownloadItem::DownloadInterruptReason interruptReason;
- qint64 totalBytes;
- qint64 receivedBytes;
- QString mimeType;
- QString downloadPath;
- bool downloadFinished;
- bool downloadPaused;
- QQuickWebEngineView *view;
- QUrl downloadUrl;
- QString suggestedFileName;
- QString downloadDirectory;
- QString downloadFileName;
- bool isCustomFileName;
-
- void update(const QtWebEngineCore::ProfileAdapterClient::DownloadItemInfo &info);
- void updateState(QQuickWebEngineDownloadItem::DownloadState newState);
- void setFinished();
-};
-
-QT_END_NAMESPACE
-
-#endif // QQUICKWEBENGINEDOWNLOADITEM_P_P_H
diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp
index 834bb6a05..2022306b0 100644
--- a/src/webengine/api/qquickwebengineprofile.cpp
+++ b/src/webengine/api/qquickwebengineprofile.cpp
@@ -39,8 +39,6 @@
#include "qquickwebengineprofile.h"
-#include "qquickwebenginedownloaditem_p.h"
-#include "qquickwebenginedownloaditem_p_p.h"
#include "qquickwebengineprofile_p.h"
#include "qquickwebenginescript_p.h"
#include "qquickwebenginesettings_p.h"
@@ -56,17 +54,13 @@
#include "renderer_host/user_resource_controller_host.h"
#include "web_engine_settings.h"
+#include <QtWebEngineCore/private/qwebenginedownloadrequest_p.h>
#include <QtWebEngineCore/qwebengineurlscheme.h>
using QtWebEngineCore::ProfileAdapter;
QT_BEGIN_NAMESPACE
-ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::UnknownSaveFormat, QtWebEngineCore::ProfileAdapterClient::UnknownSavePageFormat)
-ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::SingleHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::SingleHtmlSaveFormat)
-ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::CompleteHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::CompleteHtmlSaveFormat)
-ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::MimeHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::MimeHtmlSaveFormat)
-
/*!
\class QQuickWebEngineProfile
\brief The QQuickWebEngineProfile class provides a web engine profile shared by multiple pages.
@@ -133,12 +127,12 @@ ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::MimeHtmlSaveFormat, QtWebEngineC
*/
/*!
- \fn QQuickWebEngineProfile::downloadRequested(QQuickWebEngineDownloadItem *download)
+ \fn QQuickWebEngineProfile::downloadRequested(QWebEngineDownloadRequest *download)
This signal is emitted whenever a download has been triggered.
The \a download argument holds the state of the download.
The download has to be explicitly accepted with
- \c{QQuickWebEngineDownloadItem::accept()} or it will be
+ \c{QWebEngineDownloadRequest::accept()} or it will be
cancelled by default.
The download item is parented by the profile. If it is not accepted, it
will be deleted immediately after the signal emission.
@@ -146,7 +140,7 @@ ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::MimeHtmlSaveFormat, QtWebEngineC
*/
/*!
- \fn QQuickWebEngineProfile::downloadFinished(QQuickWebEngineDownloadItem *download)
+ \fn QQuickWebEngineProfile::downloadFinished(QWebEngineDownloadRequest *download)
This signal is emitted whenever downloading stops, because it finished successfully, was
cancelled, or was interrupted (for example, because connectivity was lost).
@@ -242,38 +236,38 @@ void QQuickWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info)
Q_Q(QQuickWebEngineProfile);
Q_ASSERT(!m_ongoingDownloads.contains(info.id));
- QQuickWebEngineDownloadItemPrivate *itemPrivate = new QQuickWebEngineDownloadItemPrivate(q, info.url);
+ QWebEngineDownloadRequestPrivate *itemPrivate = new QWebEngineDownloadRequestPrivate(m_profileAdapter, info.url);
itemPrivate->downloadId = info.id;
- itemPrivate->downloadState = QQuickWebEngineDownloadItem::DownloadRequested;
+ itemPrivate->downloadState = QWebEngineDownloadRequest::DownloadRequested;
itemPrivate->startTime = info.startTime;
itemPrivate->totalBytes = info.totalBytes;
itemPrivate->mimeType = info.mimeType;
itemPrivate->downloadDirectory = QFileInfo(info.path).path();
itemPrivate->downloadFileName = QFileInfo(info.path).fileName();
itemPrivate->suggestedFileName = info.suggestedFileName;
- itemPrivate->savePageFormat = static_cast<QQuickWebEngineDownloadItem::SavePageFormat>(
+ itemPrivate->savePageFormat = static_cast<QWebEngineDownloadRequest::SavePageFormat>(
info.savePageFormat);
- itemPrivate->type = static_cast<QQuickWebEngineDownloadItem::DownloadType>(info.downloadType);
+ itemPrivate->isSavePageDownload = info.isSavePageDownload;
if (info.page && info.page->clientType() == QtWebEngineCore::WebContentsAdapterClient::QmlClient)
- itemPrivate->view = static_cast<QQuickWebEngineViewPrivate *>(info.page)->q_ptr;
+ itemPrivate->page = static_cast<QQuickWebEngineViewPrivate *>(info.page)->q_ptr;
else
- itemPrivate->view = nullptr;
+ itemPrivate->page = nullptr;
- QQuickWebEngineDownloadItem *download = new QQuickWebEngineDownloadItem(itemPrivate, q);
+ QWebEngineDownloadRequest *download = new QWebEngineDownloadRequest(itemPrivate, q);
m_ongoingDownloads.insert(info.id, download);
- QObject::connect(download, &QQuickWebEngineDownloadItem::destroyed, q, [id = info.id, this] () { downloadDestroyed(id); });
+ QObject::connect(download, &QWebEngineDownloadRequest::destroyed, q, [id = info.id, this] () { downloadDestroyed(id); });
QQmlEngine::setObjectOwnership(download, QQmlEngine::JavaScriptOwnership);
Q_EMIT q->downloadRequested(download);
- QQuickWebEngineDownloadItem::DownloadState state = download->state();
+ QWebEngineDownloadRequest::DownloadState state = download->state();
info.path = QDir(download->downloadDirectory()).filePath(download->downloadFileName());
info.savePageFormat = itemPrivate->savePageFormat;
- info.accepted = state != QQuickWebEngineDownloadItem::DownloadCancelled
- && state != QQuickWebEngineDownloadItem::DownloadRequested;
+ info.accepted = state != QWebEngineDownloadRequest::DownloadCancelled
+ && state != QWebEngineDownloadRequest::DownloadRequested;
- if (state == QQuickWebEngineDownloadItem::DownloadRequested) {
+ if (state == QWebEngineDownloadRequest::DownloadRequested) {
// Delete unaccepted downloads.
info.accepted = false;
delete download;
@@ -287,7 +281,7 @@ void QQuickWebEngineProfilePrivate::downloadUpdated(const DownloadItemInfo &info
Q_Q(QQuickWebEngineProfile);
- QQuickWebEngineDownloadItem* download = m_ongoingDownloads.value(info.id).data();
+ QWebEngineDownloadRequest* download = m_ongoingDownloads.value(info.id).data();
if (!download) {
downloadDestroyed(info.id);
diff --git a/src/webengine/api/qquickwebengineprofile.h b/src/webengine/api/qquickwebengineprofile.h
index e5f7ff713..ca90d7ae8 100644
--- a/src/webengine/api/qquickwebengineprofile.h
+++ b/src/webengine/api/qquickwebengineprofile.h
@@ -50,7 +50,7 @@
QT_BEGIN_NAMESPACE
-class QQuickWebEngineDownloadItem;
+class QWebEngineDownloadRequest;
class QQuickWebEngineProfilePrivate;
class QQuickWebEngineScript;
class QQuickWebEngineSettings;
@@ -173,8 +173,8 @@ Q_SIGNALS:
Q_REVISION(5) void useForGlobalCertificateVerificationChanged();
Q_REVISION(5) void downloadPathChanged();
- void downloadRequested(QQuickWebEngineDownloadItem *download);
- void downloadFinished(QQuickWebEngineDownloadItem *download);
+ void downloadRequested(QWebEngineDownloadRequest *download);
+ void downloadFinished(QWebEngineDownloadRequest *download);
Q_REVISION(5) void presentNotification(QWebEngineNotification *notification);
@@ -186,8 +186,6 @@ private:
friend class QQuickWebEngineSettings;
friend class QQuickWebEngineSingleton;
friend class QQuickWebEngineViewPrivate;
- friend class QQuickWebEngineDownloadItem;
- friend class QQuickWebEngineDownloadItemPrivate;
friend class QQuickWebEngineView;
QScopedPointer<QQuickWebEngineProfilePrivate> d_ptr;
};
diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h
index c6d412ab3..f1fd93543 100644
--- a/src/webengine/api/qquickwebengineprofile_p.h
+++ b/src/webengine/api/qquickwebengineprofile_p.h
@@ -62,7 +62,7 @@
QT_BEGIN_NAMESPACE
-class QQuickWebEngineDownloadItem;
+class QWebEngineDownloadRequest;
class QQuickWebEngineSettings;
class QQuickWebEngineViewPrivate;
@@ -100,7 +100,7 @@ private:
QQuickWebEngineProfile *q_ptr;
QScopedPointer<QQuickWebEngineSettings> m_settings;
QPointer<QtWebEngineCore::ProfileAdapter> m_profileAdapter;
- QMap<quint32, QPointer<QQuickWebEngineDownloadItem> > m_ongoingDownloads;
+ QMap<quint32, QPointer<QWebEngineDownloadRequest> > m_ongoingDownloads;
QList<QQuickWebEngineScript *> m_userScripts;
};
diff --git a/src/webengine/api/qquickwebenginesingleton_p.h b/src/webengine/api/qquickwebenginesingleton_p.h
index ba63382e5..5edf95303 100644
--- a/src/webengine/api/qquickwebenginesingleton_p.h
+++ b/src/webengine/api/qquickwebenginesingleton_p.h
@@ -52,11 +52,12 @@
//
#include <QtWebEngine/private/qtwebengineglobal_p.h>
+
+#include <QtWebEngine/qquickwebengineprofile.h>
+#include <QtWebEngine/private/qquickwebenginesettings_p.h>
#include <QObject>
QT_BEGIN_NAMESPACE
-class QQuickWebEngineProfile;
-class QQuickWebEngineSettings;
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineSingleton : public QObject {
Q_OBJECT
Q_PROPERTY(QQuickWebEngineSettings* settings READ settings CONSTANT FINAL)
diff --git a/src/webengine/api/qquickwebenginetouchhandleprovider.cpp b/src/webengine/api/qquickwebenginetouchhandleprovider.cpp
index 80f4727b6..56162b223 100644
--- a/src/webengine/api/qquickwebenginetouchhandleprovider.cpp
+++ b/src/webengine/api/qquickwebenginetouchhandleprovider.cpp
@@ -67,7 +67,7 @@ void QQuickWebEngineTouchHandleProvider::init(const QMap<int, QImage> &images)
return;
}
- m_touchHandleMap.unite(images);
+ m_touchHandleMap.insert(images);
}
QImage QQuickWebEngineTouchHandleProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 7b875bf55..4bf957c3b 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -41,7 +41,6 @@
#include "qquickwebengineview_p_p.h"
#include "authentication_dialog_controller.h"
#include "profile_adapter.h"
-#include "certificate_error_controller.h"
#include "file_picker_controller.h"
#include "find_text_helper.h"
#include "javascript_dialog_controller.h"
@@ -50,9 +49,7 @@
#include "qquickwebengineaction_p.h"
#include "qquickwebengineaction_p_p.h"
#include "qquickwebenginehistory_p.h"
-#include "qquickwebenginecertificateerror_p.h"
#include "qquickwebengineclientcertificateselection_p.h"
-#include "qquickwebenginecontextmenurequest_p.h"
#include "qquickwebenginedialogrequests_p.h"
#include "qquickwebenginefaviconprovider_p_p.h"
#include "qquickwebengineloadrequest_p.h"
@@ -62,6 +59,7 @@
#include "qquickwebenginesettings_p.h"
#include "qquickwebenginescript_p.h"
#include "qquickwebenginetouchhandleprovider_p_p.h"
+#include "qwebenginecertificateerror.h"
#include "qwebenginefindtextresult.h"
#include "qwebenginequotarequest.h"
#include "qwebengineregisterprotocolhandlerrequest.h"
@@ -98,7 +96,6 @@
#include <QTimer>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/qpa/qplatformintegration.h>
-
QT_BEGIN_NAMESPACE
using namespace QtWebEngineCore;
@@ -135,6 +132,7 @@ QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate()
, m_zoomFactor(1.0)
, m_ui2Enabled(false)
, m_profileInitialized(false)
+ , m_contextMenuRequest(nullptr)
{
memset(actions, 0, sizeof(actions));
@@ -229,13 +227,15 @@ RenderWidgetHostViewQtDelegate *QQuickWebEngineViewPrivate::CreateRenderWidgetHo
return quickDelegate;
}
-void QQuickWebEngineViewPrivate::contextMenuRequested(const WebEngineContextMenuData &data)
+void QQuickWebEngineViewPrivate::contextMenuRequested(QWebEngineContextMenuRequest *request)
{
Q_Q(QQuickWebEngineView);
- m_contextMenuData = data;
+ m_contextMenuRequest = request;
- QQuickWebEngineContextMenuRequest *request = new QQuickWebEngineContextMenuRequest(data);
+ // FIXME: we most liekly do not need to make any copy here
+ auto *r = new QWebEngineContextMenuRequest(
+ new QWebEngineContextMenuRequestPrivate(*request->d.data()));
QQmlEngine *engine = qmlEngine(q);
// TODO: this is a workaround for QTBUG-65044
@@ -243,19 +243,19 @@ void QQuickWebEngineViewPrivate::contextMenuRequested(const WebEngineContextMenu
return;
// mark the object for gc by creating temporary jsvalue
- engine->newQObject(request);
- Q_EMIT q->contextMenuRequested(request);
+ engine->newQObject(r);
+ Q_EMIT q->contextMenuRequested(r);
- if (request->isAccepted())
+ if (r->isAccepted())
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());
+ QObject *menu = ui()->addMenu(q, QString(), r->position());
if (!menu)
return;
- QQuickContextMenuBuilder contextMenuBuilder(data, q, menu);
+ QQuickContextMenuBuilder contextMenuBuilder(r, q, menu);
// Populate our menu
contextMenuBuilder.initMenu();
@@ -290,21 +290,14 @@ void QQuickWebEngineViewPrivate::javascriptDialog(QSharedPointer<JavaScriptDialo
ui()->showDialog(dialog);
}
-void QQuickWebEngineViewPrivate::allowCertificateError(const QSharedPointer<CertificateErrorController> &errorController)
+void QQuickWebEngineViewPrivate::allowCertificateError(const QWebEngineCertificateError &error)
{
Q_Q(QQuickWebEngineView);
-
- QQuickWebEngineCertificateError *quickController = new QQuickWebEngineCertificateError(errorController);
- // mark the object for gc by creating temporary jsvalue
- qmlEngine(q)->newQObject(quickController);
- Q_EMIT q->certificateError(quickController);
- if (!quickController->overridable() || (!quickController->deferred() && !quickController->answered()))
- quickController->rejectCertificate();
- else
- m_certificateErrorControllers.append(errorController);
+ Q_EMIT q->certificateError(error);
}
-void QQuickWebEngineViewPrivate::selectClientCert(const QSharedPointer<ClientCertSelectController> &controller)
+void QQuickWebEngineViewPrivate::selectClientCert(
+ const QSharedPointer<QtWebEngineCore::ClientCertSelectController> &controller)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
Q_Q(QQuickWebEngineView);
@@ -468,7 +461,6 @@ void QQuickWebEngineViewPrivate::loadStarted(const QUrl &provisionalUrl, bool is
isLoading = true;
m_history->reset();
- m_certificateErrorControllers.clear();
QTimer::singleShot(0, q, [q, provisionalUrl]() {
QQuickWebEngineLoadRequest loadRequest(provisionalUrl, QQuickWebEngineView::LoadStartedStatus);
@@ -482,11 +474,29 @@ void QQuickWebEngineViewPrivate::loadCommitted()
m_history->reset();
}
-void QQuickWebEngineViewPrivate::loadVisuallyCommitted()
+void QQuickWebEngineViewPrivate::didFirstVisuallyNonEmptyPaint()
{
#if QT_CONFIG(webengine_testsupport)
- if (m_testSupport)
- Q_EMIT m_testSupport->loadVisuallyCommitted();
+ if (m_loadVisuallyCommittedState == NotCommitted) {
+ m_loadVisuallyCommittedState = DidFirstVisuallyNonEmptyPaint;
+ } else if (m_loadVisuallyCommittedState == DidFirstCompositorFrameSwap) {
+ if (m_testSupport)
+ Q_EMIT m_testSupport->loadVisuallyCommitted();
+ m_loadVisuallyCommittedState = NotCommitted;
+ }
+#endif
+}
+
+void QQuickWebEngineViewPrivate::didCompositorFrameSwap()
+{
+#if QT_CONFIG(webengine_testsupport)
+ if (m_loadVisuallyCommittedState == NotCommitted) {
+ m_loadVisuallyCommittedState = DidFirstCompositorFrameSwap;
+ } else if (m_loadVisuallyCommittedState == DidFirstVisuallyNonEmptyPaint) {
+ if (m_testSupport)
+ Q_EMIT m_testSupport->loadVisuallyCommitted();
+ m_loadVisuallyCommittedState = NotCommitted;
+ }
#endif
}
@@ -1554,7 +1564,7 @@ void QQuickWebEngineView::setWebChannel(QQmlWebChannel *webChannel)
d->adapter->setWebChannel(webChannel, d->m_webChannelWorld);
Q_EMIT webChannelChanged();
#else
- Q_UNUSED(webChannel)
+ Q_UNUSED(webChannel);
qWarning("WebEngine compiled without webchannel support");
#endif
}
@@ -1576,7 +1586,7 @@ void QQuickWebEngineView::setWebChannelWorld(uint webChannelWorld)
d->adapter->setWebChannel(d->m_webChannel, d->m_webChannelWorld);
Q_EMIT webChannelWorldChanged(webChannelWorld);
#else
- Q_UNUSED(webChannelWorld)
+ Q_UNUSED(webChannelWorld);
qWarning("WebEngine compiled without webchannel support");
#endif
}
@@ -1700,9 +1710,9 @@ void QQuickWebEngineView::fullScreenCancelled()
d->adapter->exitFullScreen();
}
-void QQuickWebEngineView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+void QQuickWebEngineView::geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
{
- QQuickItem::geometryChanged(newGeometry, oldGeometry);
+ QQuickItem::geometryChange(newGeometry, oldGeometry);
Q_D(QQuickWebEngineView);
if (d->widget)
d->widget->setSize(newGeometry.size());
@@ -1720,16 +1730,16 @@ void QQuickWebEngineView::itemChange(ItemChange change, const ItemChangeData &va
}
#if QT_CONFIG(draganddrop)
-static QPoint mapToScreen(const QQuickItem *item, const QPoint &clientPos)
+static QPointF mapToScreen(const QQuickItem *item, const QPointF &clientPos)
{
- return item->window()->position() + item->mapToScene(clientPos).toPoint();
+ return item->window()->position() + item->mapToScene(clientPos);
}
void QQuickWebEngineView::dragEnterEvent(QDragEnterEvent *e)
{
Q_D(QQuickWebEngineView);
e->accept();
- d->adapter->enterDrag(e, mapToScreen(this, e->pos()));
+ d->adapter->enterDrag(e, mapToScreen(this, e->position()));
}
void QQuickWebEngineView::dragLeaveEvent(QDragLeaveEvent *e)
@@ -1742,7 +1752,7 @@ void QQuickWebEngineView::dragLeaveEvent(QDragLeaveEvent *e)
void QQuickWebEngineView::dragMoveEvent(QDragMoveEvent *e)
{
Q_D(QQuickWebEngineView);
- Qt::DropAction dropAction = d->adapter->updateDragPosition(e, mapToScreen(this, e->pos()));
+ Qt::DropAction dropAction = d->adapter->updateDragPosition(e, mapToScreen(this, e->position()));
if (Qt::IgnoreAction == dropAction) {
e->ignore();
} else {
@@ -1755,7 +1765,7 @@ void QQuickWebEngineView::dropEvent(QDropEvent *e)
{
Q_D(QQuickWebEngineView);
e->accept();
- d->adapter->endDragging(e, mapToScreen(this, e->pos()));
+ d->adapter->endDragging(e, mapToScreen(this, e->position()));
}
#endif // QT_CONFIG(draganddrop)
@@ -1803,32 +1813,33 @@ void QQuickWebEngineView::triggerWebAction(WebAction action)
d->adapter->unselect();
break;
case OpenLinkInThisWindow:
- if (d->m_contextMenuData.linkUrl().isValid())
- setUrl(d->m_contextMenuData.linkUrl());
+ if (d->m_contextMenuRequest->filteredLinkUrl().isValid())
+ setUrl(d->m_contextMenuRequest->filteredLinkUrl());
break;
case OpenLinkInNewWindow:
- if (d->m_contextMenuData.linkUrl().isValid()) {
+ if (d->m_contextMenuRequest->filteredLinkUrl().isValid()) {
QQuickWebEngineNewViewRequest request;
- request.m_requestedUrl = d->m_contextMenuData.linkUrl();
+ request.m_requestedUrl = d->m_contextMenuRequest->filteredLinkUrl();
request.m_isUserInitiated = true;
request.m_destination = NewViewInWindow;
Q_EMIT newViewRequested(&request);
}
break;
case OpenLinkInNewTab:
- if (d->m_contextMenuData.linkUrl().isValid()) {
+ if (d->m_contextMenuRequest->filteredLinkUrl().isValid()) {
QQuickWebEngineNewViewRequest request;
- request.m_requestedUrl = d->m_contextMenuData.linkUrl();
+ request.m_requestedUrl = d->m_contextMenuRequest->filteredLinkUrl();
request.m_isUserInitiated = true;
request.m_destination = NewViewInBackgroundTab;
Q_EMIT newViewRequested(&request);
}
break;
case CopyLinkToClipboard:
- if (!d->m_contextMenuData.unfilteredLinkUrl().isEmpty()) {
- QString urlString = d->m_contextMenuData.unfilteredLinkUrl().toString(QUrl::FullyEncoded);
- QString linkText = d->m_contextMenuData.linkText().toHtmlEscaped();
- QString title = d->m_contextMenuData.titleText();
+ if (!d->m_contextMenuRequest->linkUrl().isEmpty()) {
+ QString urlString =
+ d->m_contextMenuRequest->linkUrl().toString(QUrl::FullyEncoded);
+ QString linkText = d->m_contextMenuRequest->linkText().toHtmlEscaped();
+ QString title = d->m_contextMenuRequest->titleText();
if (!title.isEmpty())
title = QStringLiteral(" title=\"%1\"").arg(title.toHtmlEscaped());
QMimeData *data = new QMimeData();
@@ -1836,99 +1847,118 @@ void QQuickWebEngineView::triggerWebAction(WebAction action)
QString html = QStringLiteral("<a href=\"") + urlString + QStringLiteral("\"") + title + QStringLiteral(">")
+ linkText + QStringLiteral("</a>");
data->setHtml(html);
- data->setUrls(QList<QUrl>() << d->m_contextMenuData.unfilteredLinkUrl());
+ data->setUrls(QList<QUrl>() << d->m_contextMenuRequest->linkUrl());
qApp->clipboard()->setMimeData(data);
}
break;
case DownloadLinkToDisk:
- if (d->m_contextMenuData.linkUrl().isValid())
- d->adapter->download(d->m_contextMenuData.linkUrl(), d->m_contextMenuData.suggestedFileName(),
- d->m_contextMenuData.referrerUrl(), d->m_contextMenuData.referrerPolicy());
+ if (d->m_contextMenuRequest->filteredLinkUrl().isValid())
+ d->adapter->download(d->m_contextMenuRequest->filteredLinkUrl(),
+ d->m_contextMenuRequest->suggestedFileName(),
+ d->m_contextMenuRequest->referrerUrl(),
+ d->m_contextMenuRequest->referrerPolicy());
break;
case CopyImageToClipboard:
- if (d->m_contextMenuData.hasImageContent() &&
- (d->m_contextMenuData.mediaType() == WebEngineContextMenuData::MediaTypeImage ||
- d->m_contextMenuData.mediaType() == WebEngineContextMenuData::MediaTypeCanvas))
- {
- d->adapter->copyImageAt(d->m_contextMenuData.position());
+ if (d->m_contextMenuRequest->hasImageContent()
+ && (d->m_contextMenuRequest->mediaType() == QWebEngineContextMenuRequest::MediaTypeImage
+ || d->m_contextMenuRequest->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeCanvas)) {
+ d->adapter->copyImageAt(d->m_contextMenuRequest->position());
}
break;
case CopyImageUrlToClipboard:
- if (d->m_contextMenuData.mediaUrl().isValid() && d->m_contextMenuData.mediaType() == WebEngineContextMenuData::MediaTypeImage) {
- QString urlString = d->m_contextMenuData.mediaUrl().toString(QUrl::FullyEncoded);
- QString alt = d->m_contextMenuData.altText();
+ if (d->m_contextMenuRequest->mediaUrl().isValid()
+ && d->m_contextMenuRequest->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeImage) {
+ QString urlString = d->m_contextMenuRequest->mediaUrl().toString(QUrl::FullyEncoded);
+ QString alt = d->m_contextMenuRequest->altText();
if (!alt.isEmpty())
alt = QStringLiteral(" alt=\"%1\"").arg(alt.toHtmlEscaped());
- QString title = d->m_contextMenuData.titleText();
+ QString title = d->m_contextMenuRequest->titleText();
if (!title.isEmpty())
title = QStringLiteral(" title=\"%1\"").arg(title.toHtmlEscaped());
QMimeData *data = new QMimeData();
data->setText(urlString);
QString html = QStringLiteral("<img src=\"") + urlString + QStringLiteral("\"") + title + alt + QStringLiteral("></img>");
data->setHtml(html);
- data->setUrls(QList<QUrl>() << d->m_contextMenuData.mediaUrl());
+ data->setUrls(QList<QUrl>() << d->m_contextMenuRequest->mediaUrl());
qApp->clipboard()->setMimeData(data);
}
break;
case DownloadImageToDisk:
case DownloadMediaToDisk:
- if (d->m_contextMenuData.mediaUrl().isValid())
- d->adapter->download(d->m_contextMenuData.mediaUrl(), d->m_contextMenuData.suggestedFileName(),
- d->m_contextMenuData.referrerUrl(), d->m_contextMenuData.referrerPolicy());
+ if (d->m_contextMenuRequest->mediaUrl().isValid())
+ d->adapter->download(d->m_contextMenuRequest->mediaUrl(),
+ d->m_contextMenuRequest->suggestedFileName(),
+ d->m_contextMenuRequest->referrerUrl(),
+ d->m_contextMenuRequest->referrerPolicy());
break;
case CopyMediaUrlToClipboard:
- if (d->m_contextMenuData.mediaUrl().isValid() &&
- (d->m_contextMenuData.mediaType() == WebEngineContextMenuData::MediaTypeAudio ||
- d->m_contextMenuData.mediaType() == WebEngineContextMenuData::MediaTypeVideo))
- {
- QString urlString = d->m_contextMenuData.mediaUrl().toString(QUrl::FullyEncoded);
- QString title = d->m_contextMenuData.titleText();
+ if (d->m_contextMenuRequest->mediaUrl().isValid()
+ && (d->m_contextMenuRequest->mediaType() == QWebEngineContextMenuRequest::MediaTypeAudio
+ || d->m_contextMenuRequest->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeVideo)) {
+ QString urlString = d->m_contextMenuRequest->mediaUrl().toString(QUrl::FullyEncoded);
+ QString title = d->m_contextMenuRequest->titleText();
if (!title.isEmpty())
title = QStringLiteral(" title=\"%1\"").arg(title.toHtmlEscaped());
QMimeData *data = new QMimeData();
data->setText(urlString);
- if (d->m_contextMenuData.mediaType() == WebEngineContextMenuData::MediaTypeAudio)
+ if (d->m_contextMenuRequest->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeAudio)
data->setHtml(QStringLiteral("<audio src=\"") + urlString + QStringLiteral("\"") + title +
QStringLiteral("></audio>"));
else
data->setHtml(QStringLiteral("<video src=\"") + urlString + QStringLiteral("\"") + title +
QStringLiteral("></video>"));
- data->setUrls(QList<QUrl>() << d->m_contextMenuData.mediaUrl());
+ data->setUrls(QList<QUrl>() << d->m_contextMenuRequest->mediaUrl());
qApp->clipboard()->setMimeData(data);
}
break;
case ToggleMediaControls:
- if (d->m_contextMenuData.mediaUrl().isValid() && d->m_contextMenuData.mediaFlags() & WebEngineContextMenuData::MediaCanToggleControls) {
- bool enable = !(d->m_contextMenuData.mediaFlags() & WebEngineContextMenuData::MediaControls);
- d->adapter->executeMediaPlayerActionAt(d->m_contextMenuData.position(), WebContentsAdapter::MediaPlayerControls, enable);
+ if (d->m_contextMenuRequest->mediaUrl().isValid()
+ && d->m_contextMenuRequest->mediaFlags()
+ & QWebEngineContextMenuRequest::MediaCanToggleControls) {
+ bool enable = !(d->m_contextMenuRequest->mediaFlags()
+ & QWebEngineContextMenuRequest::MediaControls);
+ d->adapter->executeMediaPlayerActionAt(d->m_contextMenuRequest->position(),
+ WebContentsAdapter::MediaPlayerControls, enable);
}
break;
case ToggleMediaLoop:
- if (d->m_contextMenuData.mediaUrl().isValid() &&
- (d->m_contextMenuData.mediaType() == WebEngineContextMenuData::MediaTypeAudio ||
- d->m_contextMenuData.mediaType() == WebEngineContextMenuData::MediaTypeVideo))
- {
- bool enable = !(d->m_contextMenuData.mediaFlags() & WebEngineContextMenuData::MediaLoop);
- d->adapter->executeMediaPlayerActionAt(d->m_contextMenuData.position(), WebContentsAdapter::MediaPlayerLoop, enable);
+ if (d->m_contextMenuRequest->mediaUrl().isValid()
+ && (d->m_contextMenuRequest->mediaType() == QWebEngineContextMenuRequest::MediaTypeAudio
+ || d->m_contextMenuRequest->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeVideo)) {
+ bool enable = !(d->m_contextMenuRequest->mediaFlags()
+ & QWebEngineContextMenuRequest::MediaLoop);
+ d->adapter->executeMediaPlayerActionAt(d->m_contextMenuRequest->position(),
+ WebContentsAdapter::MediaPlayerLoop, enable);
}
break;
case ToggleMediaPlayPause:
- if (d->m_contextMenuData.mediaUrl().isValid() &&
- (d->m_contextMenuData.mediaType() == WebEngineContextMenuData::MediaTypeAudio ||
- d->m_contextMenuData.mediaType() == WebEngineContextMenuData::MediaTypeVideo))
- {
- bool enable = (d->m_contextMenuData.mediaFlags() & WebEngineContextMenuData::MediaPaused);
- d->adapter->executeMediaPlayerActionAt(d->m_contextMenuData.position(), WebContentsAdapter::MediaPlayerPlay, enable);
+ if (d->m_contextMenuRequest->mediaUrl().isValid()
+ && (d->m_contextMenuRequest->mediaType() == QWebEngineContextMenuRequest::MediaTypeAudio
+ || d->m_contextMenuRequest->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeVideo)) {
+ bool enable = (d->m_contextMenuRequest->mediaFlags()
+ & QWebEngineContextMenuRequest::MediaPaused);
+ d->adapter->executeMediaPlayerActionAt(d->m_contextMenuRequest->position(),
+ WebContentsAdapter::MediaPlayerPlay, enable);
}
break;
case ToggleMediaMute:
- if (d->m_contextMenuData.mediaUrl().isValid() && d->m_contextMenuData.mediaFlags() & WebEngineContextMenuData::MediaHasAudio) {
- bool enable = !(d->m_contextMenuData.mediaFlags() & WebEngineContextMenuData::MediaMuted);
- d->adapter->executeMediaPlayerActionAt(d->m_contextMenuData.position(), WebContentsAdapter::MediaPlayerMute, enable);
+ if (d->m_contextMenuRequest->mediaUrl().isValid()
+ && d->m_contextMenuRequest->mediaFlags()
+ & QWebEngineContextMenuRequest::MediaHasAudio) {
+ bool enable = !(d->m_contextMenuRequest->mediaFlags()
+ & QWebEngineContextMenuRequest::MediaMuted);
+ d->adapter->executeMediaPlayerActionAt(d->m_contextMenuRequest->position(),
+ WebContentsAdapter::MediaPlayerMute, enable);
}
break;
case InspectElement:
- d->adapter->inspectElementAt(d->m_contextMenuData.position());
+ d->adapter->inspectElementAt(d->m_contextMenuRequest->position());
break;
case ExitFullScreen:
d->adapter->exitFullScreen();
@@ -2281,12 +2311,9 @@ void QQuickWebEngineFullScreenRequest::reject()
m_viewPrivate->setFullScreenMode(!m_toggleOn);
}
-QQuickContextMenuBuilder::QQuickContextMenuBuilder(const QtWebEngineCore::WebEngineContextMenuData &data,
- QQuickWebEngineView *view,
- QObject *menu)
- : QtWebEngineCore::RenderViewContextMenuQt(data)
- , m_view(view)
- , m_menu(menu)
+QQuickContextMenuBuilder::QQuickContextMenuBuilder(QWebEngineContextMenuRequest *request,
+ QQuickWebEngineView *view, QObject *menu)
+ : QtWebEngineCore::RenderViewContextMenuQt(request), m_view(view), m_menu(menu)
{
}
@@ -2394,9 +2421,9 @@ void QQuickContextMenuBuilder::addMenuItem(ContextMenuItem menuItem)
case ContextMenuItem::SpellingSuggestions:
{
QPointer<QQuickWebEngineView> thisRef(m_view);
- for (int i=0; i < m_contextData.spellCheckerSuggestions().count() && i < 4; i++) {
+ for (int i = 0; i < m_contextData->spellCheckerSuggestions().count() && i < 4; i++) {
action = new QQuickWebEngineAction(m_menu);
- QString replacement = m_contextData.spellCheckerSuggestions().at(i);
+ QString replacement = m_contextData->spellCheckerSuggestions().at(i);
QObject::connect(action, &QQuickWebEngineAction::triggered, [thisRef, replacement] { thisRef->replaceMisspelledWord(replacement); });
m_view->d_ptr->ui()->addMenuItem(action, m_menu);
}
@@ -2421,19 +2448,19 @@ bool QQuickContextMenuBuilder::isMenuItemEnabled(ContextMenuItem menuItem)
case ContextMenuItem::Reload:
return true;
case ContextMenuItem::Cut:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanCut;
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanCut;
case ContextMenuItem::Copy:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanCopy;
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanCopy;
case ContextMenuItem::Paste:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanPaste;
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanPaste;
case ContextMenuItem::Undo:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanUndo;
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanUndo;
case ContextMenuItem::Redo:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanRedo;
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanRedo;
case ContextMenuItem::SelectAll:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanSelectAll;
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanSelectAll;
case ContextMenuItem::PasteAndMatchStyle:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanPaste;
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanPaste;
case ContextMenuItem::OpenLinkInNewWindow:
case ContextMenuItem::OpenLinkInNewTab:
case ContextMenuItem::CopyLinkToClipboard:
@@ -2498,3 +2525,4 @@ void QQuickWebEngineTouchHandle::setOpacity(float opacity)
QT_END_NAMESPACE
+#include "moc_qquickwebengineview_p.cpp"
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index ab84b2600..800c1c491 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -51,22 +51,26 @@
// We mean it.
//
+#include <QtWebEngineCore/qtwebenginecoreglobal.h>
#include <QtWebEngine/private/qtwebengineglobal_p.h>
#include <QQuickItem>
#include <QtGui/qcolor.h>
+#include "qquickwebengineprofile.h"
#include "qquickwebenginescript.h"
+namespace QtWebEngineCore {
+class RenderWidgetHostViewQtDelegateQuick;
+}
+
QT_BEGIN_NAMESPACE
class QQmlWebChannel;
class QQuickContextMenuBuilder;
class QQuickWebEngineAction;
class QQuickWebEngineAuthenticationDialogRequest;
-class QQuickWebEngineCertificateError;
class QQuickWebEngineClientCertificateSelection;
class QQuickWebEngineColorDialogRequest;
-class QQuickWebEngineContextMenuRequest;
class QQuickWebEngineFaviconProvider;
class QQuickWebEngineFileDialogRequest;
class QQuickWebEngineHistory;
@@ -74,14 +78,15 @@ class QQuickWebEngineJavaScriptDialogRequest;
class QQuickWebEngineLoadRequest;
class QQuickWebEngineNavigationRequest;
class QQuickWebEngineNewViewRequest;
-class QQuickWebEngineProfile;
class QQuickWebEngineSettings;
class QQuickWebEngineTooltipRequest;
class QQuickWebEngineFormValidationMessageRequest;
class QQuickWebEngineViewPrivate;
+class QWebEngineCertificateError;
class QWebEngineFindTextResult;
class QWebEngineQuotaRequest;
class QWebEngineRegisterProtocolHandlerRequest;
+class QWebEngineContextMenuRequest;
#if QT_CONFIG(webengine_testsupport)
class QQuickWebEngineTestSupport;
@@ -123,7 +128,9 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_PROPERTY(QQuickWebEngineProfile *profile READ profile WRITE setProfile NOTIFY profileChanged FINAL REVISION 1)
Q_PROPERTY(QQuickWebEngineSettings *settings READ settings REVISION 1 CONSTANT FINAL)
Q_PROPERTY(QQuickWebEngineHistory *navigationHistory READ navigationHistory CONSTANT FINAL REVISION 1)
+#if QT_CONFIG(webengine_webchannel)
Q_PROPERTY(QQmlWebChannel *webChannel READ webChannel WRITE setWebChannel NOTIFY webChannelChanged REVISION 1 FINAL)
+#endif
Q_PROPERTY(QQmlListProperty<QQuickWebEngineScript> userScripts READ userScripts FINAL REVISION 1)
Q_PROPERTY(bool activeFocusOnPress READ activeFocusOnPress WRITE setActiveFocusOnPress NOTIFY activeFocusOnPressChanged REVISION 2 FINAL)
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged REVISION 2 FINAL)
@@ -545,7 +552,7 @@ Q_SIGNALS:
void linkHovered(const QUrl &hoveredUrl);
void navigationRequested(QQuickWebEngineNavigationRequest *request);
void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID);
- Q_REVISION(1) void certificateError(QQuickWebEngineCertificateError *error);
+ Q_REVISION(1) void certificateError(QWebEngineCertificateError error);
Q_REVISION(1) void fullScreenRequested(const QQuickWebEngineFullScreenRequest &request);
Q_REVISION(1) void isFullScreenChanged();
Q_REVISION(1) void featurePermissionRequested(const QUrl &securityOrigin, Feature feature);
@@ -562,7 +569,7 @@ Q_SIGNALS:
Q_REVISION(3) void audioMutedChanged(bool muted);
Q_REVISION(3) void recentlyAudibleChanged(bool recentlyAudible);
Q_REVISION(3) void webChannelWorldChanged(uint);
- Q_REVISION(4) void contextMenuRequested(QQuickWebEngineContextMenuRequest *request);
+ Q_REVISION(4) void contextMenuRequested(QWebEngineContextMenuRequest *request);
Q_REVISION(4) void authenticationDialogRequested(QQuickWebEngineAuthenticationDialogRequest *request);
Q_REVISION(4) void javaScriptDialogRequested(QQuickWebEngineJavaScriptDialogRequest *request);
Q_REVISION(4) void colorDialogRequested(QQuickWebEngineColorDialogRequest *request);
@@ -587,7 +594,7 @@ Q_SIGNALS:
#endif
protected:
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
void itemChange(ItemChange, const ItemChangeData &) override;
#if QT_CONFIG(draganddrop)
void dragEnterEvent(QDragEnterEvent *e) override;
@@ -600,6 +607,7 @@ private:
Q_DECLARE_PRIVATE(QQuickWebEngineView)
QScopedPointer<QQuickWebEngineViewPrivate> d_ptr;
+ friend class QtWebEngineCore::RenderWidgetHostViewQtDelegateQuick;
friend class QQuickContextMenuBuilder;
friend class QQuickWebEngineNewViewRequest;
friend class QQuickWebEngineFaviconProvider;
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 68d65410a..83cf16592 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -75,7 +75,7 @@ QT_BEGIN_NAMESPACE
class QQuickWebEngineView;
class QQmlComponent;
class QQmlContext;
-class QQuickWebEngineContextMenuRequest;
+class QWebEngineContextMenuRequest;
class QQuickWebEngineSettings;
class QQuickWebEngineFaviconProvider;
class QQuickWebEngineProfilePrivate;
@@ -115,7 +115,7 @@ public:
QColor backgroundColor() const override;
void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) override;
void loadCommitted() override;
- void loadVisuallyCommitted() override;
+ void didFirstVisuallyNonEmptyPaint() override;
void loadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()) override;
void focusContainer() override;
void unhandledKeyEvent(QKeyEvent *event) override;
@@ -128,7 +128,7 @@ public:
void windowCloseRejected() override;
void requestFullScreenMode(const QUrl &origin, bool fullscreen) override;
bool isFullScreenMode() const override;
- void contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &) override;
+ void contextMenuRequested(QWebEngineContextMenuRequest *request) 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;
@@ -147,8 +147,9 @@ public:
void runRegisterProtocolHandlerRequest(QWebEngineRegisterProtocolHandlerRequest) override;
QObject *accessibilityParentObject() override;
QtWebEngineCore::WebEngineSettings *webEngineSettings() const override;
- void allowCertificateError(const QSharedPointer<CertificateErrorController> &errorController) override;
- void selectClientCert(const QSharedPointer<ClientCertSelectController> &selectController) override;
+ void allowCertificateError(const QWebEngineCertificateError &error) override;
+ void selectClientCert(const QSharedPointer<QtWebEngineCore::ClientCertSelectController>
+ &selectController) override;
void runFeaturePermissionRequest(QtWebEngineCore::ProfileAdapter::PermissionType permission, const QUrl &securityOrigin) override;
void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode) override;
void requestGeometryChange(const QRect &geometry, const QRect &frameGeometry) override;
@@ -173,6 +174,8 @@ public:
void widgetChanged(QtWebEngineCore::RenderWidgetHostViewQtDelegate *newWidgetBase) override;
void findTextFinished(const QWebEngineFindTextResult &result) override;
+ void didCompositorFrameSwap();
+
void updateAction(QQuickWebEngineView::WebAction) const;
void adoptWebContents(QtWebEngineCore::WebContentsAdapter *webContents);
void setProfile(QQuickWebEngineProfile *profile);
@@ -198,7 +201,6 @@ public:
QQuickWebEngineTestSupport *m_testSupport;
#endif
QQmlComponent *contextMenuExtraItems;
- QtWebEngineCore::WebEngineContextMenuData m_contextMenuData;
QUrl m_url;
QString m_html;
QUrl iconUrl;
@@ -210,7 +212,6 @@ public:
bool m_navigationActionTriggered;
qreal devicePixelRatio;
QMap<quint64, QJSValue> m_callbacks;
- QList<QSharedPointer<CertificateErrorController> > m_certificateErrorControllers;
QQmlWebChannel *m_webChannel;
QPointer<QQuickWebEngineView> inspectedView;
QPointer<QQuickWebEngineView> devToolsView;
@@ -223,12 +224,20 @@ public:
bool profileInitialized() const;
private:
+ enum LoadVisuallyCommittedState {
+ NotCommitted,
+ DidFirstVisuallyNonEmptyPaint,
+ DidFirstCompositorFrameSwap
+ };
+
QScopedPointer<QtWebEngineCore::UIDelegatesManager> m_uIDelegatesManager;
QList<QQuickWebEngineScript *> m_userScripts;
QColor m_backgroundColor;
qreal m_zoomFactor;
bool m_ui2Enabled;
bool m_profileInitialized;
+ QWebEngineContextMenuRequest *m_contextMenuRequest;
+ LoadVisuallyCommittedState m_loadVisuallyCommittedState = NotCommitted;
};
#ifndef QT_NO_ACCESSIBILITY
@@ -254,7 +263,8 @@ private:
class QQuickContextMenuBuilder : public QtWebEngineCore::RenderViewContextMenuQt
{
public:
- QQuickContextMenuBuilder(const QtWebEngineCore::WebEngineContextMenuData &data, QQuickWebEngineView *view, QObject *menu);
+ QQuickContextMenuBuilder(QWebEngineContextMenuRequest *data, QQuickWebEngineView *view,
+ QObject *menu);
void appendExtraItems(QQmlEngine *engine);
private:
diff --git a/src/webengine/api/qtwebengineglobal.cpp b/src/webengine/api/qtwebengineglobal.cpp
index 4346832c9..825805888 100644
--- a/src/webengine/api/qtwebengineglobal.cpp
+++ b/src/webengine/api/qtwebengineglobal.cpp
@@ -39,6 +39,7 @@
#include "qtwebengineglobal.h"
#include <QCoreApplication>
+#include <QQuickWindow>
namespace QtWebEngineCore
{
@@ -72,15 +73,16 @@ namespace QtWebEngine {
*/
void initialize()
{
- QCoreApplication *app = QCoreApplication::instance();
- if (app) {
+ QCoreApplication *app = QCoreApplication::instance();
+ if (app) {
qWarning("QtWebEngine::initialize() called with QCoreApplication object already created and should be call before. "\
"This is depreciated and may fail in the future.");
QtWebEngineCore::initialize();
return;
- }
- // call initialize the same way as widgets do
- qAddPreRoutine(QtWebEngineCore::initialize);
+ }
+ // call initialize the same way as widgets do
+ qAddPreRoutine(QtWebEngineCore::initialize);
+ QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGLRhi);
}
} // namespace QtWebEngine
diff --git a/src/webengine/doc/src/context_menu_request.qdoc b/src/webengine/doc/src/context_menu_request.qdoc
new file mode 100644
index 000000000..cc812dcf2
--- /dev/null
+++ b/src/webengine/doc/src/context_menu_request.qdoc
@@ -0,0 +1,218 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \qmltype ContextMenuRequest
+ \instantiates QQuickWebEngineContextMenuRequest
+ \inqmlmodule QtWebEngine
+ \since QtWebEngine 1.4
+
+ \brief A request for showing a context menu.
+
+ A ContextMenuRequest is passed as an argument of the
+ WebEngineView::contextMenuRequested signal. It provides further
+ information about the context of the request. The position of the
+ request origin can be found via the \l x and \l y properties.
+
+ The \l accepted property of the request indicates whether the request
+ is handled by the user code or the default context menu should
+ be displayed.
+
+ The following code uses a custom menu to handle the request:
+
+ \code
+ WebEngineView {
+ id: view
+ // ...
+ onContextMenuRequested: function(request) {
+ request.accepted = true;
+ myMenu.x = request.x;
+ myMenu.y = request.y;
+ myMenu.trigger.connect(view.triggerWebAction);
+ myMenu.popup();
+ }
+ // ...
+ }
+ \endcode
+*/
+
+/*!
+ \qmlproperty point ContextMenuRequest::position
+ \readonly
+
+ The position of the user action from where the context
+ menu request originates.
+*/
+
+/*!
+ \qmlproperty string ContextMenuRequest::selectedText
+ \readonly
+
+ The selected text the context menu was created for.
+*/
+
+/*!
+ \qmlproperty string ContextMenuRequest::linkText
+ \readonly
+
+ The text of the link if the context menu was requested for a link.
+*/
+
+/*!
+ \qmlproperty url ContextMenuRequest::linkUrl
+ \readonly
+
+ The URL of the link if the selected web page content is a link.
+ It is not guaranteed to be a valid URL.
+*/
+
+/*!
+ \qmlproperty url ContextMenuRequest::mediaUrl
+ \readonly
+
+ The URL of media if the selected web content is a media element.
+*/
+
+/*!
+ \qmlproperty enumeration ContextMenuRequest::mediaType
+ \readonly
+
+ The type of the media element or \c MediaTypeNone if
+ the selected web page content is not a media element.
+
+ \value ContextMenuRequest.MediaTypeNone
+ Not a media.
+ \value ContextMenuRequest.MediaTypeImage
+ An image.
+ \value ContextMenuRequest.MediaTypeVideo
+ A video.
+ \value ContextMenuRequest.MediaTypeAudio
+ An audio element.
+ \value ContextMenuRequest.MediaTypeCanvas
+ A canvas.
+ \value ContextMenuRequest.MediaTypeFile
+ A file.
+ \value ContextMenuRequest.MediaTypePlugin
+ A plugin.
+*/
+
+/*!
+ \qmlproperty bool ContextMenuRequest::isContentEditable
+ \readonly
+
+ Indicates whether the selected web content is editable.
+*/
+
+/*!
+ \qmlproperty string ContextMenuRequest::misspelledWord
+ \readonly
+
+ If the context is a word considered misspelled by the spell-checker,
+ returns the misspelled word.
+*/
+
+/*!
+ \qmlproperty stringlist ContextMenuRequest::spellCheckerSuggestions
+ \readonly
+
+ If the context is a word considered misspelled by the spell-checker,
+ returns a list of suggested replacements.
+*/
+
+/*!
+ \qmlproperty bool ContextMenuRequest::accepted
+
+ Indicates whether the context menu request has been
+ handled by the signal handler.
+
+ If the property is \c false after any signal handlers
+ for WebEngineView::contextMenuRequested have been executed,
+ a default context menu will be shown.
+ To prevent this, set \c{request.accepted} to \c true.
+
+ The default is \c false.
+
+ \note The default content of the context menu depends on the
+ web element for which the request was actually generated.
+*/
+
+/*!
+ \qmlproperty flags ContextMenuRequest::mediaFlags
+ \readonly
+ \since QtWebEngine 1.7
+
+ The current media element's status and its available operations.
+ \c MediaNone if the selected web page content is not a media element.
+
+ \value ContextMenuRequest.MediaInError
+ An error occurred.
+ \value ContextMenuRequest.MediaPaused
+ Media is paused.
+ \value ContextMenuRequest.MediaMuted
+ Media is muted.
+ \value ContextMenuRequest.MediaLoop
+ Media can be looped.
+ \value ContextMenuRequest.MediaCanSave
+ Media can be saved.
+ \value ContextMenuRequest.MediaHasAudio
+ Media has audio.
+ \value ContextMenuRequest.MediaCanToggleControls
+ Media can show controls.
+ \value ContextMenuRequest.MediaControls
+ Media controls are shown.
+ \value ContextMenuRequest.MediaCanPrint
+ Media is printable.
+ \value ContextMenuRequest.MediaCanRotate
+ Media is rotatable.
+*/
+
+/*!
+ \qmlproperty flags ContextMenuRequest::editFlags
+ \readonly
+ \since QtWebEngine 1.7
+
+ The available edit operations in the current context or \c CanDoNone if no actions are available.
+
+ \value ContextMenuRequest.CanUndo
+ Undo is available.
+ \value ContextMenuRequest.CanRedo
+ Redo is available.
+ \value ContextMenuRequest.CanCut
+ Cut is available.
+ \value ContextMenuRequest.CanCopy
+ Copy is available.
+ \value ContextMenuRequest.CanPaste
+ Paste is available.
+ \value ContextMenuRequest.CanDelete
+ Delete is available.
+ \value ContextMenuRequest.CanSelectAll
+ Select All is available.
+ \value ContextMenuRequest.CanTranslate
+ Translate is available.
+ \value ContextMenuRequest.CanEditRichly
+ Context is richly editable.
+*/
diff --git a/src/webengine/doc/src/fullscreen_request.qdoc b/src/webengine/doc/src/fullscreen_request.qdoc
new file mode 100644
index 000000000..230d62e50
--- /dev/null
+++ b/src/webengine/doc/src/fullscreen_request.qdoc
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \qmltype FullScreenRequest
+ \instantiates QQuickWebEngineFullScreenRequest
+ \inqmlmodule QtWebEngine
+ \since QtWebEngine 1.1
+
+ \brief A utility type for the WebEngineView::fullScreenRequested() signal.
+
+ \sa WebEngineView::fullScreenRequested()
+*/
+
+/*!
+ \qmlproperty url FullScreenRequest::origin
+ \readonly
+ The URL of the web page that issued the fullscreen request.
+*/
+
+/*!
+ \qmlproperty bool FullScreenRequest::toggleOn
+ \readonly
+
+ Returns \c{true} if the application should toggle fullscreen mode on, \c{false} otherwise.
+
+ \sa accept()
+*/
+
+/*!
+ \qmlmethod void FullScreenRequest::accept()
+
+ Call this method to accept the fullscreen request. It sets the WebEngineView::isFullScreen
+ property to be equal to toggleOn.
+
+ \qml
+ ApplicationWindow {
+ id: window
+ WebEngineView {
+ onFullScreenRequested: function(request) {
+ if (request.toggleOn)
+ window.showFullScreen()
+ else
+ window.showNormal()
+ request.accept()
+ }
+ }
+ }
+ \endqml
+
+ \sa toggleOn
+*/
+
+/*!
+ \qmlmethod void FullScreenRequest::reject()
+ Rejects a fullscreen request.
+*/
+
diff --git a/src/webengine/doc/src/quota_request.qdoc b/src/webengine/doc/src/quota_request.qdoc
new file mode 100644
index 000000000..ee64c0484
--- /dev/null
+++ b/src/webengine/doc/src/quota_request.qdoc
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \qmltype QuotaRequest
+ \instantiates QWebEngineQuotaRequest
+ \inqmlmodule QtWebEngine
+ \since QtWebEngine 1.7
+
+ \brief A utility type for the WebEngineView::quotaRequested() signal.
+
+ \sa WebEngineView::quotaRequested()
+*/
+
+/*!
+ \qmlproperty url QuotaRequest::origin
+ \readonly
+
+ The URL of the web page that issued the quota request.
+*/
+
+/*!
+ \qmlproperty qint64 QuotaRequest::requestedSize
+ \readonly
+
+ Contains the size of the requested disk space in bytes.
+*/
+
+/*!
+ \qmlmethod void QuotaRequest::accept()
+
+ Accepts the quota request.
+
+ \qml
+ WebEngineView {
+ onQuotaRequested: function(request) {
+ if (request.requestedSize <= 5 * 1024 * 1024)
+ request.accept();
+ else
+ request.reject();
+ }
+ }
+ \endqml
+*/
+
+/*!
+ \qmlmethod void QuotaRequest::reject()
+ Rejects the quota request.
+*/
+
diff --git a/src/webengine/doc/src/register_protocol_handler_request.qdoc b/src/webengine/doc/src/register_protocol_handler_request.qdoc
new file mode 100644
index 000000000..b3ebcb31b
--- /dev/null
+++ b/src/webengine/doc/src/register_protocol_handler_request.qdoc
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \qmltype RegisterProtocolHandlerRequest
+ \instantiates QWebEngineRegisterProtocolHandlerRequest
+ \inqmlmodule QtWebEngine
+ \since QtWebEngine 1.7
+ \brief The RegisterProtocolHandlerRequest type enables accepting
+ or rejecting requests from the \l registerProtocolHandler API.
+
+ \sa WebEngineView::registerProtocolHandlerRequested()
+*/
+
+/*!
+ \qmlproperty url RegisterProtocolHandlerRequest::origin
+ \brief The URL template for the protocol handler.
+
+ This is the second parameter from the \l registerProtocolHandler call.
+*/
+
+/*!
+ \qmlproperty string RegisterProtocolHandlerRequest::scheme
+ \brief The URL scheme for the protocol handler.
+
+ This is the first parameter from the \l registerProtocolHandler call.
+*/
+
+/*!
+ \qmlmethod void RegisterProtocolHandlerRequest::accept()
+ \brief Accepts the request.
+
+ Subsequent calls to accept() and reject() are ignored.
+*/
+
+/*!
+ \qmlmethod void RegisterProtocolHandlerRequest::reject()
+ \brief Accepts the request.
+
+ Subsequent calls to accept() and reject() are ignored.
+*/
+
diff --git a/src/webengine/api/qquickwebenginecertificateerror.cpp b/src/webengine/doc/src/webengine_certificate_error.qdoc
index 63beb1bae..8c032dc8b 100644
--- a/src/webengine/api/qquickwebenginecertificateerror.cpp
+++ b/src/webengine/doc/src/webengine_certificate_error.qdoc
@@ -1,11 +1,11 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
+** This file is part of the documentation of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL$
+** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -14,56 +14,20 @@
** 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.
-**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/
-#include <qquickwebenginecertificateerror_p.h>
-#include "certificate_error_controller.h"
-QT_BEGIN_NAMESPACE
-
-class QQuickWebEngineCertificateErrorPrivate {
-public:
- QQuickWebEngineCertificateErrorPrivate(const QSharedPointer<CertificateErrorController> &controller)
- : weakRefCertErrorController(controller),
- error(static_cast<QQuickWebEngineCertificateError::Error>(static_cast<int>(controller->error()))),
- description(controller->errorString()),
- overridable(controller->overridable()),
- async(false),
- answered(false)
- {
- }
-
- const QWeakPointer<CertificateErrorController> weakRefCertErrorController;
- QQuickWebEngineCertificateError::Error error;
- QString description;
- bool overridable;
- bool async;
- bool answered;
-};
-
/*!
\qmltype WebEngineCertificateError
- \instantiates QQuickWebEngineCertificateError
+ \instantiates QWebEngineCertificateError
\inqmlmodule QtWebEngine
\since QtWebEngine 1.1
@@ -85,20 +49,6 @@ public:
\sa WebEngineView::certificateError
*/
-QQuickWebEngineCertificateError::QQuickWebEngineCertificateError(const QSharedPointer<CertificateErrorController> &controller, QObject *parent)
- : QObject(parent)
- , d_ptr(new QQuickWebEngineCertificateErrorPrivate(controller))
-{
-}
-
-QQuickWebEngineCertificateError::~QQuickWebEngineCertificateError()
-{
- Q_D(QQuickWebEngineCertificateError);
- if (!d->answered)
- rejectCertificate();
-}
-
-
/*!
\qmlmethod void WebEngineCertificateError::defer()
@@ -107,58 +57,22 @@ QQuickWebEngineCertificateError::~QQuickWebEngineCertificateError()
URL request until WebEngineCertificateError::ignoreCertificateError() or
WebEngineCertificateError::rejectCertificate() is called.
*/
-void QQuickWebEngineCertificateError::defer()
-{
- Q_D(QQuickWebEngineCertificateError);
- d->async = true;
-}
/*!
\qmlmethod void WebEngineCertificateError::ignoreCertificateError()
The certificate error is ignored, and the web engine view continues to load the requested URL.
*/
-void QQuickWebEngineCertificateError::ignoreCertificateError()
-{
- Q_D(QQuickWebEngineCertificateError);
-
- d->answered = true;
-
- QSharedPointer<CertificateErrorController> strongRefCert = d->weakRefCertErrorController.toStrongRef();
- if (strongRefCert)
- strongRefCert->accept(true);
-}
-
/*!
\qmlmethod void WebEngineCertificateError::rejectCertificate()
The certificate is rejected, and the web engine view stops loading the requested URL.
*/
-void QQuickWebEngineCertificateError::rejectCertificate()
-{
- Q_D(QQuickWebEngineCertificateError);
-
- d->answered = true;
-
- QSharedPointer<CertificateErrorController> strongRefCert = d->weakRefCertErrorController.toStrongRef();
- if (strongRefCert)
- strongRefCert->accept(false);
-}
-
/*!
\qmlproperty url WebEngineCertificateError::url
\readonly
The URL that triggered the error.
*/
-QUrl QQuickWebEngineCertificateError::url() const
-{
- Q_D(const QQuickWebEngineCertificateError);
- QSharedPointer<CertificateErrorController> strongRefCert = d->weakRefCertErrorController.toStrongRef();
- if (strongRefCert)
- return strongRefCert->url();
- return QUrl();
-}
-
/*!
\qmlproperty enumeration WebEngineCertificateError::error
\readonly
@@ -205,47 +119,15 @@ QUrl QQuickWebEngineCertificateError::url() const
the device owner. (Added in 5.15)
*/
-QQuickWebEngineCertificateError::Error QQuickWebEngineCertificateError::error() const
-{
- Q_D(const QQuickWebEngineCertificateError);
- return d->error;
-}
-
/*!
\qmlproperty string WebEngineCertificateError::description
\readonly
A short localized human-readable description of the error.
*/
-QString QQuickWebEngineCertificateError::description() const
-{
- Q_D(const QQuickWebEngineCertificateError);
- return d->description;
-}
-
/*!
\qmlproperty bool WebEngineCertificateError::overridable
\readonly
A boolean that indicates whether the certificate error can be overridden and ignored.
*/
-bool QQuickWebEngineCertificateError::overridable() const
-{
- Q_D(const QQuickWebEngineCertificateError);
- return d->overridable;
-}
-
-bool QQuickWebEngineCertificateError::deferred() const
-{
- Q_D(const QQuickWebEngineCertificateError);
- return d->async;
-}
-
-bool QQuickWebEngineCertificateError::answered() const
-{
- Q_D(const QQuickWebEngineCertificateError);
- return d->answered;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/webengine/doc/src/webengine_download_request.qdoc b/src/webengine/doc/src/webengine_download_request.qdoc
new file mode 100644
index 000000000..2b96ec45b
--- /dev/null
+++ b/src/webengine/doc/src/webengine_download_request.qdoc
@@ -0,0 +1,302 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \qmltype WebEngineDownloadRequest
+ \instantiates QWebEngineDownloadRequest
+ \inqmlmodule QtWebEngine
+ \brief Provides information about a download.
+
+ WebEngineDownloadRequest models a download throughout its life cycle, starting
+ with a pending download request and finishing with a completed download. It
+ can be used, for example, to get information about new downloads, to monitor
+ progress, and to pause, resume, and cancel downloads.
+
+ Downloads are usually triggered by user interaction on a web page. It is the
+ WebEngineProfile's responsibility to notify the application of new download
+ requests, which it does by emitting the
+ \l{WebEngineProfile::downloadRequested}{downloadRequested} signal together
+ with a newly created WebEngineDownloadRequest. The application can then examine
+ this item and decide whether to accept it or not. A signal handler must
+ explicitly call accept() on the item for \QWE to actually start
+ downloading and writing data to disk. If no signal handler calls accept(),
+ then the download request will be automatically rejected and nothing will be
+ written to disk.
+
+ \note Some properties, like the \l path under which the file will be saved,
+ can only be changed before calling accept().
+
+ \section2 Object Life Cycle
+
+ All items are guaranteed to be valid during the emission of the
+ \l{WebEngineProfile::downloadRequested}{downloadRequested} signal. If
+ accept() is \e not called by any signal handler, then the item will be
+ deleted \e immediately after signal emission. This means that the
+ application \b{must not} keep references to rejected download items.
+
+ \section2 Web Page Downloads
+
+ In addition to normal file downloads, which consist simply of retrieving
+ some raw bytes from the network and writing them to disk, \QWE also
+ supports saving complete web pages, which involves parsing the page's HTML,
+ downloading any dependent resources, and potentially packaging everything
+ into a special file format (\l savePageFormat). To check if a download is
+ for a file or a web page, use \l isSavePageDownload.
+
+ \sa WebEngineProfile, WebEngineProfile::downloadRequested,
+ WebEngineProfile::downloadFinished
+*/
+
+/*!
+ \qmlmethod void WebEngineDownloadRequest::accept()
+
+ Accepts the download request, which will start the download.
+
+ If the item is in the \c DownloadRequested state, then it will transition
+ into the \c DownloadInProgress state and the downloading will begin. If the
+ item is in any other state, then nothing will happen.
+
+ \sa state
+*/
+
+/*!
+ \qmlmethod void WebEngineDownloadRequest::cancel()
+
+ Cancels the download.
+
+ If the item is in the \c DownloadInProgress state, then it will transition
+ into the \c DownloadCancelled state, the downloading will stop, and
+ partially downloaded files will be deleted from disk.
+
+ If the item is in the \c DownloadCompleted state, then nothing will happen.
+ If the item is in any other state, then it will transition into the \c
+ DownloadCancelled state without further effect.
+
+ \sa state
+*/
+
+/*!
+ \qmlmethod void WebEngineDownloadRequest::pause()
+
+ Pauses the download.
+
+ Has no effect if the state is not \c DownloadInProgress. Does not change the
+ state.
+
+ \sa resume, isPaused
+*/
+
+/*!
+ \qmlmethod void WebEngineDownloadRequest::resume()
+
+ Resumes the download if it was paused or interrupted.
+
+ Has no effect if the state is not \c DownloadInProgress or \c
+ DownloadInterrupted. Does not change the state.
+
+ \sa pause, isPaused
+*/
+
+/*!
+ \qmlproperty int WebEngineDownloadRequest::id
+
+ Holds the download item's ID.
+*/
+
+/*!
+ \qmlproperty enumeration WebEngineDownloadRequest::state
+
+ Describes the state of the download:
+
+ \value WebEngineDownloadRequest.DownloadRequested
+ Download has been requested, but it has not been accepted yet.
+ \value WebEngineDownloadRequest.DownloadInProgress
+ Download is in progress.
+ \value WebEngineDownloadRequest.DownloadCompleted
+ Download completed successfully.
+ \value WebEngineDownloadRequest.DownloadCancelled
+ Download was cancelled by the user.
+ \value WebEngineDownloadRequest.DownloadInterrupted
+ Download has been interrupted (by the server or because of lost connectivity).
+*/
+
+/*!
+ \qmlproperty int WebEngineDownloadRequest::totalBytes
+
+ Holds the total amount of data to download in bytes.
+
+ \c -1 means the total size is unknown.
+*/
+
+/*!
+ \qmlproperty int WebEngineDownloadRequest::receivedBytes
+
+ Holds the amount of data in bytes that has been downloaded so far.
+*/
+
+/*!
+ \qmlproperty url WebEngineDownloadRequest::url
+ \readonly
+
+ Returns the download's origin URL.
+*/
+
+/*!
+ \qmlproperty string WebEngineDownloadRequest::mimeType
+
+ Holds the MIME type of the download.
+*/
+
+/*!
+ \qmlproperty string WebEngineDownloadRequest::downloadDirectory
+
+ Holds the full target path without file name where data is being downloaded to.
+
+ The download directory can only be set in the
+ \l{WebEngineProfile::downloadRequested}{downloadRequested} handler before
+ the download is accepted.
+
+ \sa WebEngineProfile::downloadRequested(), accept()
+*/
+
+/*!
+ \qmlproperty string WebEngineDownloadRequest::downloadFileName
+
+ Holds the name of the file to which data is being downloaded.
+
+ The download file name can only be set in the
+ \l{WebEngineProfile::downloadRequested}{downloadRequested} handler before
+ the download is accepted.
+
+ \sa WebEngineProfile::downloadRequested(), accept()
+*/
+
+/*!
+ \qmlproperty string WebEngineDownloadRequest::suggestedFileName
+
+ Returns the suggested file name.
+*/
+
+/*!
+ \qmlproperty enumeration WebEngineDownloadRequest::savePageFormat
+
+ Describes the format that is used to save a web page.
+
+ \value WebEngineDownloadRequest.UnknownSaveFormat
+ This is not a request for downloading a complete web page.
+ \value WebEngineDownloadRequest.SingleHtmlSaveFormat
+ The page is saved as a single HTML page. Resources such as images
+ are not saved.
+ \value WebEngineDownloadRequest.CompleteHtmlSaveFormat
+ The page is saved as a complete HTML page, for example a directory
+ containing the single HTML page and the resources.
+ \value WebEngineDownloadRequest.MimeHtmlSaveFormat
+ The page is saved as a complete web page in the MIME HTML format.
+*/
+
+/*!
+ \qmlproperty bool WebEngineDownloadItem::isSavePageDownload
+ \readonly
+
+ Whether this is a download request for saving a web page or a file.
+
+ \sa savePageFormat
+*/
+
+/*!
+ \qmlproperty enumeration WebEngineDownloadRequest::interruptReason
+ \readonly
+
+ Returns the reason why the download was interrupted:
+
+ \value WebEngineDownloadRequest.NoReason Unknown reason or not interrupted.
+ \value WebEngineDownloadRequest.FileFailed General file operation failure.
+ \value WebEngineDownloadRequest.FileAccessDenied The file cannot be written locally, due to access restrictions.
+ \value WebEngineDownloadRequest.FileNoSpace Insufficient space on the target drive.
+ \value WebEngineDownloadRequest.FileNameTooLong The directory or file name is too long.
+ \value WebEngineDownloadRequest.FileTooLarge The file size exceeds the file system limitation.
+ \value WebEngineDownloadRequest.FileVirusInfected The file is infected with a virus.
+ \value WebEngineDownloadRequest.FileTransientError Temporary problem (for example the file is in use,
+ out of memory, or too many files are opened at once).
+ \value WebEngineDownloadRequest.FileBlocked The file was blocked due to local policy.
+ \value WebEngineDownloadRequest.FileSecurityCheckFailed An attempt to check the safety of the download
+ failed due to unexpected reasons.
+ \value WebEngineDownloadRequest.FileTooShort An attempt was made to seek past the end of a file when
+ opening a file (as part of resuming a previously interrupted download).
+ \value WebEngineDownloadRequest.FileHashMismatch The partial file did not match the expected hash.
+
+ \value WebEngineDownloadRequest.NetworkFailed General network failure.
+ \value WebEngineDownloadRequest.NetworkTimeout The network operation has timed out.
+ \value WebEngineDownloadRequest.NetworkDisconnected The network connection has been terminated.
+ \value WebEngineDownloadRequest.NetworkServerDown The server has gone down.
+ \value WebEngineDownloadRequest.NetworkInvalidRequest The network request was invalid (for example, the
+ original or redirected URL is invalid, has an unsupported scheme, or is disallowed by policy).
+
+ \value WebEngineDownloadRequest.ServerFailed General server failure.
+ \value WebEngineDownloadRequest.ServerBadContent The server does not have the requested data.
+ \value WebEngineDownloadRequest.ServerUnauthorized The server did not authorize access to the resource.
+ \value WebEngineDownloadRequest.ServerCertProblem A problem with the server certificate occurred.
+ \value WebEngineDownloadRequest.ServerForbidden Access forbidden by the server.
+ \value WebEngineDownloadRequest.ServerUnreachable Unexpected server response (might indicate that
+ the responding server may not be the intended server).
+ \value WebEngineDownloadRequest.UserCanceled The user canceled the download.
+
+ \sa interruptReasonString
+*/
+
+/*!
+ \qmlproperty string WebEngineDownloadRequest::interruptReasonString
+ Returns a human-readable description of the reason for interrupting the download.
+
+ \sa interruptReason
+*/
+
+/*!
+ \qmlproperty bool WebEngineDownloadRequest::isFinished
+ \readonly
+
+ Whether this download is finished (completed, cancelled, or non-resumable interrupted state).
+ */
+
+/*!
+ \qmlproperty bool WebEngineDownloadRequest::isPaused
+ \readonly
+
+ Whether this download is paused.
+
+ \sa pause, resume
+ */
+
+/*!
+ \qmlproperty WebEngineView WebEngineDownloadRequest::view
+ \readonly
+
+ Returns the view the download was requested on. If the download was not triggered by content in a view,
+ \c nullptr is returned.
+
+ \sa WebEngineView
+*/
diff --git a/src/webengine/doc/src/webengineview_lgpl.qdoc b/src/webengine/doc/src/webengineview_lgpl.qdoc
index 0cd8441cf..2be475903 100644
--- a/src/webengine/doc/src/webengineview_lgpl.qdoc
+++ b/src/webengine/doc/src/webengineview_lgpl.qdoc
@@ -1065,61 +1065,6 @@
*/
/*!
- \qmltype FullScreenRequest
- \instantiates QQuickWebEngineFullScreenRequest
- \inqmlmodule QtWebEngine
- \since QtWebEngine 1.1
-
- \brief A utility type for the WebEngineView::fullScreenRequested() signal.
-
- \sa WebEngineView::fullScreenRequested()
-*/
-
-/*!
- \qmlproperty url FullScreenRequest::origin
- \readonly
- The URL of the web page that issued the fullscreen request.
-*/
-
-/*!
- \qmlproperty bool FullScreenRequest::toggleOn
- \readonly
-
- Returns \c{true} if the application should toggle fullscreen mode on, \c{false} otherwise.
-
- \sa accept()
-*/
-
-/*!
- \qmlmethod void FullScreenRequest::accept()
-
- Call this method to accept the fullscreen request. It sets the WebEngineView::isFullScreen
- property to be equal to toggleOn.
-
- \qml
- ApplicationWindow {
- id: window
- WebEngineView {
- onFullScreenRequested: function(request) {
- if (request.toggleOn)
- window.showFullScreen()
- else
- window.showNormal()
- request.accept()
- }
- }
- }
- \endqml
-
- \sa toggleOn
-*/
-
-/*!
- \qmlmethod void FullScreenRequest::reject()
- Rejects a fullscreen request.
-*/
-
-/*!
\qmlproperty bool WebEngineView::audioMuted
\brief The state of whether the current page audio is muted.
\since QtWebEngine 1.3
@@ -1332,53 +1277,6 @@
*/
/*!
- \qmltype QuotaRequest
- \instantiates QWebEngineQuotaRequest
- \inqmlmodule QtWebEngine
- \since QtWebEngine 1.7
-
- \brief A utility type for the WebEngineView::quotaRequested() signal.
-
- \sa WebEngineView::quotaRequested()
-*/
-
-/*!
- \qmlproperty url QuotaRequest::origin
- \readonly
-
- The URL of the web page that issued the quota request.
-*/
-
-/*!
- \qmlproperty qint64 QuotaRequest::requestedSize
- \readonly
-
- Contains the size of the requested disk space in bytes.
-*/
-
-/*!
- \qmlmethod void QuotaRequest::accept()
-
- Accepts the quota request.
-
- \qml
- WebEngineView {
- onQuotaRequested: function(request) {
- if (request.requestedSize <= 5 * 1024 * 1024)
- request.accept();
- else
- request.reject();
- }
- }
- \endqml
-*/
-
-/*!
- \qmlmethod void QuotaRequest::reject()
- Rejects the quota request.
-*/
-
-/*!
\qmlsignal WebEngineView::registerProtocolHandlerRequested(RegisterProtocolHandlerRequest request)
\since QtWebEngine 1.7
@@ -1389,45 +1287,6 @@
*/
/*!
- \qmltype RegisterProtocolHandlerRequest
- \instantiates QWebEngineRegisterProtocolHandlerRequest
- \inqmlmodule QtWebEngine
- \since QtWebEngine 1.7
- \brief The RegisterProtocolHandlerRequest type enables accepting
- or rejecting requests from the \l registerProtocolHandler API.
-
- \sa WebEngineView::registerProtocolHandlerRequested()
-*/
-
-/*!
- \qmlproperty url RegisterProtocolHandlerRequest::origin
- \brief The URL template for the protocol handler.
-
- This is the second parameter from the \l registerProtocolHandler call.
-*/
-
-/*!
- \qmlproperty string RegisterProtocolHandlerRequest::scheme
- \brief The URL scheme for the protocol handler.
-
- This is the first parameter from the \l registerProtocolHandler call.
-*/
-
-/*!
- \qmlmethod void RegisterProtocolHandlerRequest::accept()
- \brief Accepts the request.
-
- Subsequent calls to accept() and reject() are ignored.
-*/
-
-/*!
- \qmlmethod void RegisterProtocolHandlerRequest::reject()
- \brief Accepts the request.
-
- Subsequent calls to accept() and reject() are ignored.
-*/
-
-/*!
\qmlsignal WebEngineView::geometryChangeRequested(rect geometry, rect frameGeometry)
\since QtWebEngine 1.7
@@ -1626,7 +1485,6 @@
\sa renderProcessPidChanged
*/
-
/*!
\qmlsignal WebEngineView::renderProcessPidChanged(qint64 pid)
\since QtWebEngine 1.11
diff --git a/src/webengine/module.pro b/src/webengine/module.pro
index 49a1086b2..8b1cab596 100644
--- a/src/webengine/module.pro
+++ b/src/webengine/module.pro
@@ -1,5 +1,5 @@
include($$QTWEBENGINE_OUT_ROOT/src/webengine/qtwebengine-config.pri)
-QT_FOR_CONFIG += webengine-private
+QT_FOR_CONFIG += webengine-private webenginecore-private
TARGET = QtWebEngine
MODULE = webengine
@@ -16,11 +16,8 @@ INCLUDEPATH += $$PWD api ../core ../core/api
SOURCES = \
api/qquickwebengineaction.cpp \
- api/qquickwebenginecertificateerror.cpp \
api/qquickwebengineclientcertificateselection.cpp \
- api/qquickwebenginecontextmenurequest.cpp \
api/qquickwebenginedialogrequests.cpp \
- api/qquickwebenginedownloaditem.cpp \
api/qquickwebenginehistory.cpp \
api/qquickwebenginefaviconprovider.cpp \
api/qquickwebengineloadrequest.cpp \
@@ -42,12 +39,8 @@ HEADERS = \
api/qtwebengineglobal_p.h \
api/qquickwebengineaction_p.h \
api/qquickwebengineaction_p_p.h \
- api/qquickwebenginecertificateerror_p.h \
api/qquickwebengineclientcertificateselection_p.h \
- api/qquickwebenginecontextmenurequest_p.h \
api/qquickwebenginedialogrequests_p.h \
- api/qquickwebenginedownloaditem_p.h \
- api/qquickwebenginedownloaditem_p_p.h \
api/qquickwebenginehistory_p.h \
api/qquickwebenginefaviconprovider_p_p.h \
api/qquickwebengineloadrequest_p.h \
diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp
index a74373b23..2dad9fefc 100644
--- a/src/webengine/plugin/plugin.cpp
+++ b/src/webengine/plugin/plugin.cpp
@@ -40,11 +40,8 @@
#include <QtQml/qqmlextensionplugin.h>
#include <QtWebEngine/QQuickWebEngineProfile>
-#include <QtWebEngine/private/qquickwebenginecertificateerror_p.h>
#include <QtWebEngine/private/qquickwebengineclientcertificateselection_p.h>
-#include <QtWebEngine/private/qquickwebenginecontextmenurequest_p.h>
#include <QtWebEngine/private/qquickwebenginedialogrequests_p.h>
-#include <QtWebEngine/private/qquickwebenginedownloaditem_p.h>
#include <QtWebEngine/private/qquickwebenginehistory_p.h>
#include <QtWebEngine/private/qquickwebenginefaviconprovider_p_p.h>
#include <QtWebEngine/private/qquickwebengineloadrequest_p.h>
@@ -55,10 +52,13 @@
#include <QtWebEngine/private/qquickwebenginetouchhandleprovider_p_p.h>
#include <QtWebEngine/private/qquickwebengineview_p.h>
#include <QtWebEngine/private/qquickwebengineaction_p.h>
+#include <QtWebEngineCore/qwebenginecertificateerror.h>
#include <QtWebEngineCore/qwebenginefindtextresult.h>
#include <QtWebEngineCore/qwebenginenotification.h>
#include <QtWebEngineCore/qwebenginequotarequest.h>
#include <QtWebEngineCore/qwebengineregisterprotocolhandlerrequest.h>
+#include <QtWebEngineCore/qwebenginecontextmenurequest.h>
+#include <QtWebEngineCore/qwebenginedownloadrequest.h>
QT_BEGIN_NAMESPACE
@@ -105,25 +105,10 @@ public:
qmlRegisterType<QQuickWebEngineProfile, 4>(uri, 1, 5, "WebEngineProfile");
qmlRegisterType<QQuickWebEngineProfile, 5>(uri, 1, 9, "WebEngineProfile");
qmlRegisterType<QQuickWebEngineScript>(uri, 1, 1, "WebEngineScript");
- qmlRegisterUncreatableType<QQuickWebEngineCertificateError>(uri, 1, 1, "WebEngineCertificateError", msgUncreatableType("WebEngineCertificateError"));
- qmlRegisterUncreatableType<QQuickWebEngineDownloadItem>(uri, 1, 1, "WebEngineDownloadItem",
- msgUncreatableType("WebEngineDownloadItem"));
- qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 1>(uri, 1, 2, "WebEngineDownloadItem",
- msgUncreatableType("WebEngineDownloadItem"));
- qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 2>(uri, 1, 3, "WebEngineDownloadItem",
- msgUncreatableType("WebEngineDownloadItem"));
- qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 3>(uri, 1, 4, "WebEngineDownloadItem",
- msgUncreatableType("WebEngineDownloadItem"));
- qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 4>(uri, 1, 5, "WebEngineDownloadItem",
- msgUncreatableType("WebEngineDownloadItem"));
- qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 5>(uri, 1, 6, "WebEngineDownloadItem",
- msgUncreatableType("WebEngineDownloadItem"));
- qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 6>(uri, 1, 7, "WebEngineDownloadItem",
- msgUncreatableType("WebEngineDownloadItem"));
- qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 7>(uri, 1, 8, "WebEngineDownloadItem",
- msgUncreatableType("WebEngineDownloadItem"));
- qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 10>(uri, 1, 10, "WebEngineDownloadItem",
- msgUncreatableType("WebEngineDownloadItem"));
+ qRegisterMetaType<QWebEngineCertificateError>();
+ qmlRegisterUncreatableType<QWebEngineCertificateError>(uri, 1, 1, "WebEngineCertificateError", msgUncreatableType("WebEngineCertificateError"));
+ qmlRegisterUncreatableType<QWebEngineDownloadRequest>(uri, 1, 1, "WebEngineDownloadRequest",
+ msgUncreatableType("WebEngineDownloadRequest"));
qmlRegisterUncreatableType<QQuickWebEngineNewViewRequest>(uri, 1, 1, "WebEngineNewViewRequest", msgUncreatableType("WebEngineNewViewRequest"));
qmlRegisterUncreatableType<QQuickWebEngineNewViewRequest, 1>(uri, 1, 5, "WebEngineNewViewRequest", tr("Cannot create separate instance of WebEngineNewViewRequest"));
qmlRegisterUncreatableType<QQuickWebEngineSettings>(uri, 1, 1, "WebEngineSettings", msgUncreatableType("WebEngineSettings"));
@@ -144,10 +129,8 @@ public:
qmlRegisterUncreatableType<QQuickWebEngineFullScreenRequest>(uri, 1, 1, "FullScreenRequest",
msgUncreatableType("FullScreenRequest"));
- qmlRegisterUncreatableType<QQuickWebEngineContextMenuRequest>(uri, 1, 4, "ContextMenuRequest",
- msgUncreatableType("ContextMenuRequest"));
- qmlRegisterUncreatableType<QQuickWebEngineContextMenuRequest, 1>(uri, 1, 7, "ContextMenuRequest",
- msgUncreatableType("ContextMenuRequest"));
+ qmlRegisterUncreatableType<QWebEngineContextMenuRequest, 1>(
+ uri, 1, 7, "ContextMenuRequest", msgUncreatableType("ContextMenuRequest"));
qmlRegisterUncreatableType<QQuickWebEngineAuthenticationDialogRequest>(uri, 1, 4, "AuthenticationDialogRequest",
msgUncreatableType("AuthenticationDialogRequest"));
qmlRegisterUncreatableType<QQuickWebEngineJavaScriptDialogRequest>(uri, 1, 4, "JavaScriptDialogRequest",
diff --git a/src/webengine/plugin/plugins.qmltypes b/src/webengine/plugin/plugins.qmltypes
index 24b073290..8f0a848d5 100644
--- a/src/webengine/plugin/plugins.qmltypes
+++ b/src/webengine/plugin/plugins.qmltypes
@@ -320,8 +320,7 @@ Module {
Method { name: "dialogReject" }
}
Component {
- name: "QQuickWebEngineCertificateError"
- prototype: "QObject"
+ name: "QWebEngineCertificateError"
exports: ["QtWebEngine/WebEngineCertificateError 1.1"]
isCreatable: false
exportMetaObjectRevisions: [0]
@@ -1371,7 +1370,7 @@ Module {
Signal {
name: "certificateError"
revision: 1
- Parameter { name: "error"; type: "QQuickWebEngineCertificateError"; isPointer: true }
+ Parameter { name: "error"; type: "QWebEngineCertificateError" }
}
Signal {
name: "fullScreenRequested"
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
index 6a5bef16d..6fcf7f3ac 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
+++ b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
@@ -39,14 +39,18 @@
#include "render_widget_host_view_qt_delegate_quick.h"
+#include "render_widget_host_view_qt_delegate_client.h"
+
#include "qquickwebengineview_p.h"
#include "qquickwebengineview_p_p.h"
#include <QGuiApplication>
+#include <QOpenGLContext>
#include <QQuickPaintedItem>
#include <QQuickWindow>
#include <QSurfaceFormat>
#include <QVariant>
#include <QWindow>
+#include <QtQuick/qsgimagenode.h>
#include <QtQuick/private/qquickwindow_p.h>
namespace QtWebEngineCore {
@@ -62,29 +66,12 @@ RenderWidgetHostViewQtDelegateQuick::RenderWidgetHostViewQtDelegateQuick(RenderW
return;
setFocus(true);
setActiveFocusOnTab(true);
-
-#if defined(Q_OS_MACOS) && QT_CONFIG(opengl)
- // Check that the default QSurfaceFormat OpenGL profile is compatible with the global OpenGL
- // shared context profile, otherwise this could lead to a nasty crash.
- QOpenGLContext *globalSharedContext = QOpenGLContext::globalShareContext();
- if (globalSharedContext) {
- QSurfaceFormat sharedFormat = globalSharedContext->format();
- QSurfaceFormat defaultFormat = QSurfaceFormat::defaultFormat();
-
- if (defaultFormat.profile() != sharedFormat.profile()
- && defaultFormat.profile() == QSurfaceFormat::CoreProfile
- && defaultFormat.version() >= qMakePair(3, 2)) {
- qFatal("QWebEngine: Default QSurfaceFormat OpenGL profile is not compatible with the "
- "global shared context OpenGL profile. Please make sure you set a compatible "
- "QSurfaceFormat before the QtGui application instance is created.");
- }
- }
-#endif
-
+ bind(client->compositorId());
}
RenderWidgetHostViewQtDelegateQuick::~RenderWidgetHostViewQtDelegateQuick()
{
+ unbind();
QQuickWebEngineViewPrivate::bindViewAndWidget(nullptr, this);
}
@@ -163,30 +150,10 @@ QWindow* RenderWidgetHostViewQtDelegateQuick::window() const
return QQuickItem::window();
}
-QSGTexture *RenderWidgetHostViewQtDelegateQuick::createTextureFromImage(const QImage &image)
-{
- return QQuickItem::window()->createTextureFromImage(image, QQuickWindow::TextureCanUseAtlas);
-}
-
-QSGLayer *RenderWidgetHostViewQtDelegateQuick::createLayer()
-{
- QSGRenderContext *renderContext = QQuickWindowPrivate::get(QQuickItem::window())->context;
- return renderContext->sceneGraphContext()->createLayer(renderContext);
-}
-
-QSGImageNode *RenderWidgetHostViewQtDelegateQuick::createImageNode()
-{
- return QQuickItem::window()->createImageNode();
-}
-
-QSGRectangleNode *RenderWidgetHostViewQtDelegateQuick::createRectangleNode()
+void RenderWidgetHostViewQtDelegateQuick::readyToSwap()
{
- return QQuickItem::window()->createRectangleNode();
-}
-
-void RenderWidgetHostViewQtDelegateQuick::update()
-{
- QQuickItem::update();
+ // Call update() on UI thread.
+ QMetaObject::invokeMethod(this, &QQuickItem::update, Qt::QueuedConnection);
}
void RenderWidgetHostViewQtDelegateQuick::updateCursor(const QCursor &cursor)
@@ -305,7 +272,8 @@ void RenderWidgetHostViewQtDelegateQuick::hoverMoveEvent(QHoverEvent *event)
{
QQuickItem *parent = parentItem();
if ((!m_isPopup && parent && !parent->property("activeFocusOnPress").toBool()
- && !parent->hasActiveFocus()) || event->posF() == event->oldPosF()) {
+ && !parent->hasActiveFocus())
+ || event->position() == event->oldPosF()) {
event->ignore();
return;
}
@@ -327,9 +295,9 @@ void RenderWidgetHostViewQtDelegateQuick::inputMethodEvent(QInputMethodEvent *ev
m_client->forwardEvent(event);
}
-void RenderWidgetHostViewQtDelegateQuick::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+void RenderWidgetHostViewQtDelegateQuick::geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
{
- QQuickItem::geometryChanged(newGeometry, oldGeometry);
+ QQuickItem::geometryChange(newGeometry, oldGeometry);
m_client->visualPropertiesChanged();
}
@@ -341,6 +309,8 @@ void RenderWidgetHostViewQtDelegateQuick::itemChange(ItemChange change, const It
disconnect(c);
m_windowConnections.clear();
if (value.window) {
+ m_windowConnections.append(connect(value.window, SIGNAL(beforeRendering()),
+ SLOT(onBeforeRendering()), Qt::DirectConnection));
m_windowConnections.append(connect(value.window, SIGNAL(xChanged(int)), SLOT(onWindowPosChanged())));
m_windowConnections.append(connect(value.window, SIGNAL(yChanged(int)), SLOT(onWindowPosChanged())));
if (!m_isPopup)
@@ -355,7 +325,55 @@ void RenderWidgetHostViewQtDelegateQuick::itemChange(ItemChange change, const It
QSGNode *RenderWidgetHostViewQtDelegateQuick::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
{
- return m_client->updatePaintNode(oldNode);
+ auto comp = compositor();
+ if (!comp)
+ return nullptr;
+
+ QQuickWindow *win = QQuickItem::window();
+
+ // Delete old node before swapFrame to decrement refcount of
+ // QImage in software mode.
+ delete oldNode;
+ QSGImageNode *node = win->createImageNode();
+ node->setOwnsTexture(true);
+
+ comp->swapFrame();
+
+ QSize texSize = comp->size();
+ QSizeF texSizeInDips = QSizeF(texSize) / comp->devicePixelRatio();
+ node->setRect(QRectF(QPointF(0, 0), texSizeInDips));
+
+ if (comp->type() == Compositor::Type::Software) {
+ QImage image = comp->image();
+ node->setTexture(win->createTextureFromImage(image));
+ } else if (comp->type() == Compositor::Type::OpenGL) {
+ QQuickWindow::CreateTextureOptions texOpts;
+ if (comp->hasAlphaChannel())
+ texOpts.setFlag(QQuickWindow::TextureHasAlphaChannel);
+ int texId = comp->textureId();
+ node->setTexture(win->createTextureFromNativeObject(QQuickWindow::NativeObjectTexture,
+ texId, 0, texSize, texOpts));
+ node->setTextureCoordinatesTransform(QSGImageNode::MirrorVertically);
+ } else {
+ Q_UNREACHABLE();
+ }
+
+#if QT_CONFIG(webengine_testsupport)
+ if (m_view)
+ QMetaObject::invokeMethod(
+ m_view, [view = m_view]() { view->d_ptr->didCompositorFrameSwap(); },
+ Qt::QueuedConnection);
+#endif
+
+ return node;
+}
+
+void RenderWidgetHostViewQtDelegateQuick::onBeforeRendering()
+{
+ auto comp = compositor();
+ if (!comp || comp->type() != Compositor::Type::OpenGL)
+ return;
+ comp->waitForTexture();
}
void RenderWidgetHostViewQtDelegateQuick::onWindowPosChanged()
@@ -369,17 +387,6 @@ void RenderWidgetHostViewQtDelegateQuick::onHide()
m_client->forwardEvent(&event);
}
-bool RenderWidgetHostViewQtDelegateQuick::copySurface(const QRect &rect, const QSize &size, QImage &image)
-{
- image = QQuickItem::window()->grabWindow();
- if (image.isNull())
- return false;
- QRect subrect = !rect.isEmpty() ? rect : image.rect();
- image = image.copy(subrect);
- image = image.scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
- return true;
-}
-
#if QT_CONFIG(accessibility)
RenderWidgetHostViewQtDelegateQuickAccessible::RenderWidgetHostViewQtDelegateQuickAccessible(RenderWidgetHostViewQtDelegateQuick *o, QQuickWebEngineView *view)
: QAccessibleObject(o)
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.h b/src/webengine/render_widget_host_view_qt_delegate_quick.h
index f70de50d7..d7ff0ffe9 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quick.h
+++ b/src/webengine/render_widget_host_view_qt_delegate_quick.h
@@ -40,6 +40,7 @@
#ifndef RENDER_WIDGET_HOST_VIEW_QT_DELEGATE_QUICK_H
#define RENDER_WIDGET_HOST_VIEW_QT_DELEGATE_QUICK_H
+#include "compositor/compositor.h"
#include "render_widget_host_view_qt_delegate.h"
#include <QAccessibleObject>
@@ -53,7 +54,11 @@ QT_END_NAMESPACE
namespace QtWebEngineCore {
-class RenderWidgetHostViewQtDelegateQuick : public QQuickItem, public RenderWidgetHostViewQtDelegate
+class RenderWidgetHostViewQtDelegateClient;
+
+class RenderWidgetHostViewQtDelegateQuick : public QQuickItem,
+ public RenderWidgetHostViewQtDelegate,
+ public Compositor::Observer
{
Q_OBJECT
public:
@@ -71,11 +76,6 @@ public:
void hide() override;
bool isVisible() const override;
QWindow* window() const override;
- QSGTexture *createTextureFromImage(const QImage &) override;
- QSGLayer *createLayer() override;
- QSGImageNode *createImageNode() override;
- QSGRectangleNode *createRectangleNode() override;
- void update() override;
void updateCursor(const QCursor &) override;
void resize(int width, int height) override;
void move(const QPoint&) override { }
@@ -83,7 +83,8 @@ public:
void setInputMethodHints(Qt::InputMethodHints) override { }
// The QtQuick view doesn't have a backbuffer of its own and doesn't need this
void setClearColor(const QColor &) override { }
- bool copySurface(const QRect &rect, const QSize &size, QImage &image) override;
+
+ void readyToSwap() override;
protected:
bool event(QEvent *event) override;
@@ -100,11 +101,12 @@ protected:
void hoverLeaveEvent(QHoverEvent *event) override;
QVariant inputMethodQuery(Qt::InputMethodQuery query) const override;
void inputMethodEvent(QInputMethodEvent *event) override;
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
void itemChange(ItemChange change, const ItemChangeData &value) override;
QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
private slots:
+ void onBeforeRendering();
void onWindowPosChanged();
void onHide();
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp
index 1de4d8835..0b7e736ad 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp
+++ b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp
@@ -121,32 +121,6 @@ QWindow *RenderWidgetHostViewQtDelegateQuickWindow::window() const
return const_cast<RenderWidgetHostViewQtDelegateQuickWindow*>(this);
}
-QSGTexture *RenderWidgetHostViewQtDelegateQuickWindow::createTextureFromImage(const QImage &image)
-{
- return m_realDelegate->createTextureFromImage(image);
-}
-
-QSGLayer *RenderWidgetHostViewQtDelegateQuickWindow::createLayer()
-{
- return m_realDelegate->createLayer();
-}
-
-QSGImageNode *RenderWidgetHostViewQtDelegateQuickWindow::createImageNode()
-{
- return m_realDelegate->createImageNode();
-}
-
-QSGRectangleNode *RenderWidgetHostViewQtDelegateQuickWindow::createRectangleNode()
-{
- return m_realDelegate->createRectangleNode();
-}
-
-void RenderWidgetHostViewQtDelegateQuickWindow::update()
-{
- QQuickWindow::update();
- m_realDelegate->update();
-}
-
void RenderWidgetHostViewQtDelegateQuickWindow::updateCursor(const QCursor &cursor)
{
setCursor(cursor);
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h
index bebbfa439..c05e14266 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h
+++ b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h
@@ -66,18 +66,12 @@ public:
void hide() override;
bool isVisible() const override;
QWindow* window() const override;
- QSGTexture *createTextureFromImage(const QImage &) override;
- QSGLayer *createLayer() override;
- QSGImageNode *createImageNode() override;
- QSGRectangleNode *createRectangleNode() override;
- void update() override;
void updateCursor(const QCursor &) override;
void resize(int width, int height) override;
void move(const QPoint &screenPos) override;
void inputMethodStateChanged(bool, bool) override {}
void setInputMethodHints(Qt::InputMethodHints) override { }
void setClearColor(const QColor &) override { }
- bool copySurface(const QRect &, const QSize &, QImage &) override { return false; }
void setVirtualParent(QQuickItem *virtualParent);
diff --git a/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp b/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp
index 5949f3d6e..76f422e9d 100644
--- a/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp
+++ b/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp
@@ -41,6 +41,7 @@
#include <QCoreApplication>
#include <QOpenGLContext>
+#include <QQuickWindow>
namespace QtWebEngineCore
{
@@ -67,6 +68,7 @@ static void initialize()
}
//QCoreApplication is not yet instantiated, ensuring the call will be deferred
qAddPreRoutine(QtWebEngineCore::initialize);
+ QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGLRhi);
#endif // QT_CONFIG(opengl)
}
diff --git a/src/webenginewidgets/api/qwebengineclientcertificateselection.cpp b/src/webenginewidgets/api/qwebengineclientcertificateselection.cpp
index 9eca01bbe..febfe0a21 100644
--- a/src/webenginewidgets/api/qwebengineclientcertificateselection.cpp
+++ b/src/webenginewidgets/api/qwebengineclientcertificateselection.cpp
@@ -38,9 +38,6 @@
****************************************************************************/
#include "qwebengineclientcertificateselection.h"
-
-#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
-
#include "client_cert_select_controller.h"
QT_BEGIN_NAMESPACE
@@ -63,8 +60,9 @@ QT_BEGIN_NAMESPACE
/*! \internal
*/
-QWebEngineClientCertificateSelection::QWebEngineClientCertificateSelection(QSharedPointer<ClientCertSelectController> selectController)
- : d_ptr(selectController)
+QWebEngineClientCertificateSelection::QWebEngineClientCertificateSelection(
+ QSharedPointer<QtWebEngineCore::ClientCertSelectController> selectController)
+ : d_ptr(selectController)
{}
QWebEngineClientCertificateSelection::QWebEngineClientCertificateSelection(const QWebEngineClientCertificateSelection &other)
@@ -86,7 +84,7 @@ QWebEngineClientCertificateSelection::~QWebEngineClientCertificateSelection()
\sa select()
*/
-QVector<QSslCertificate> QWebEngineClientCertificateSelection::certificates() const
+QList<QSslCertificate> QWebEngineClientCertificateSelection::certificates() const
{
return d_ptr->certificates();
}
@@ -124,4 +122,3 @@ QUrl QWebEngineClientCertificateSelection::host() const
QT_END_NAMESPACE
-#endif // !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
diff --git a/src/webenginewidgets/api/qwebengineclientcertificateselection.h b/src/webenginewidgets/api/qwebengineclientcertificateselection.h
index d451d09ae..165194aac 100644
--- a/src/webenginewidgets/api/qwebengineclientcertificateselection.h
+++ b/src/webenginewidgets/api/qwebengineclientcertificateselection.h
@@ -42,15 +42,15 @@
#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
#include <QtNetwork/qtnetwork-config.h>
-
-#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
-
+#include <QtCore/qlist.h>
#include <QtCore/qscopedpointer.h>
-#include <QtCore/qvector.h>
#include <QtNetwork/qsslcertificate.h>
-QT_BEGIN_NAMESPACE
+namespace QtWebEngineCore {
class ClientCertSelectController;
+}
+
+QT_BEGIN_NAMESPACE
class QWEBENGINEWIDGETS_EXPORT QWebEngineClientCertificateSelection {
public:
@@ -63,18 +63,17 @@ public:
void select(const QSslCertificate &certificate);
void selectNone();
- QVector<QSslCertificate> certificates() const;
+ QList<QSslCertificate> certificates() const;
private:
friend class QWebEnginePagePrivate;
- QWebEngineClientCertificateSelection(QSharedPointer<ClientCertSelectController>);
+ QWebEngineClientCertificateSelection(
+ QSharedPointer<QtWebEngineCore::ClientCertSelectController>);
- QSharedPointer<ClientCertSelectController> d_ptr;
+ QSharedPointer<QtWebEngineCore::ClientCertSelectController> d_ptr;
};
QT_END_NAMESPACE
-#endif // !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
-
#endif // QWEBENGINECLIENTCERTSELECTION_H
diff --git a/src/webenginewidgets/api/qwebenginecontextmenudata.cpp b/src/webenginewidgets/api/qwebenginecontextmenudata.cpp
deleted file mode 100644
index 377ffe1b5..000000000
--- a/src/webenginewidgets/api/qwebenginecontextmenudata.cpp
+++ /dev/null
@@ -1,306 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 "qwebenginecontextmenudata.h"
-
-#include "web_contents_adapter_client.h"
-
-QT_BEGIN_NAMESPACE
-
-// Match MediaType enum
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeNone, QWebEngineContextMenuData::MediaTypeNone)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeImage, QWebEngineContextMenuData::MediaTypeImage)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeAudio, QWebEngineContextMenuData::MediaTypeAudio)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeVideo, QWebEngineContextMenuData::MediaTypeVideo)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeCanvas, QWebEngineContextMenuData::MediaTypeCanvas)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeFile, QWebEngineContextMenuData::MediaTypeFile)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypePlugin, QWebEngineContextMenuData::MediaTypePlugin)
-
-// Match MediaFlag enum
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaInError, QWebEngineContextMenuData::MediaInError)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaPaused, QWebEngineContextMenuData::MediaPaused)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaMuted, QWebEngineContextMenuData::MediaMuted)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaLoop, QWebEngineContextMenuData::MediaLoop)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaCanSave, QWebEngineContextMenuData::MediaCanSave)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaHasAudio, QWebEngineContextMenuData::MediaHasAudio)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaCanToggleControls, QWebEngineContextMenuData::MediaCanToggleControls)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaControls, QWebEngineContextMenuData::MediaControls)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaCanPrint, QWebEngineContextMenuData::MediaCanPrint)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaCanRotate, QWebEngineContextMenuData::MediaCanRotate)
-
-// Match EditFlag enum
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanUndo, QWebEngineContextMenuData::CanUndo)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanRedo, QWebEngineContextMenuData::CanRedo)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanCut, QWebEngineContextMenuData::CanCut)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanCopy, QWebEngineContextMenuData::CanCopy)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanPaste, QWebEngineContextMenuData::CanPaste)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanDelete, QWebEngineContextMenuData::CanDelete)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanSelectAll, QWebEngineContextMenuData::CanSelectAll)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanTranslate, QWebEngineContextMenuData::CanTranslate)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanEditRichly, QWebEngineContextMenuData::CanEditRichly)
-
-/*!
- \class QWebEngineContextMenuData
- \since 5.7
- \brief The QWebEngineContextMenuData class provides context data for populating or extending a context menu with actions.
-
- \inmodule QtWebEngineWidgets
-
- QWebEngineContextMenuData is returned by QWebEnginePage::contextMenuData() after a context menu event,
- and contains information about where the context menu event took place. This is also in the context
- in which any context specific QWebEnginePage::WebAction will be performed.
-*/
-
-/*!
- \enum QWebEngineContextMenuData::MediaType
-
- This enum describes the media type of the context if any.
-
- \value MediaTypeNone The context is not a media type.
- \value MediaTypeImage The context is an image element.
- \value MediaTypeVideo The context is a video element.
- \value MediaTypeAudio The context is an audio element.
- \value MediaTypeCanvas The context is a canvas element.
- \value MediaTypeFile The context is a file.
- \value MediaTypePlugin The context is a plugin element.
-*/
-
-/*!
- \enum QWebEngineContextMenuData::EditFlag
- \readonly
- \since 5.11
-
- The available edit operations in the current context.
-
- \value CanUndo Undo is available.
- \value CanRedo Redo is available.
- \value CanCut Cut is available.
- \value CanCopy Copy is available.
- \value CanPaste Paste is available.
- \value CanDelete Delete is available.
- \value CanSelectAll Select All is available.
- \value CanTranslate Translate is available.
- \value CanEditRichly Context is richly editable.
-*/
-
-/*!
- \enum QWebEngineContextMenuData::MediaFlag
- \readonly
- \since 5.11
-
- The current media element's status and its available operations.
- \c MediaNone if the selected web page content is not a media element.
-
- \value MediaInError An error occurred.
- \value MediaPaused Media is paused.
- \value MediaMuted Media is muted.
- \value MediaLoop Media can be looped.
- \value MediaCanSave Media can be saved.
- \value MediaHasAudio Media has audio.
- \value MediaCanToggleControls Media can show controls.
- \value MediaControls Media controls are shown.
- \value MediaCanPrint Media is printable.
- \value MediaCanRotate Media is rotatable.
-*/
-
-/*!
- Constructs null context menu data.
-*/
-QWebEngineContextMenuData::QWebEngineContextMenuData() : d(nullptr)
-{
-}
-
-/*!
- Constructs context menu data from \a other.
-*/
-QWebEngineContextMenuData::QWebEngineContextMenuData(const QWebEngineContextMenuData &other)
-{
- d = new QtWebEngineCore::WebEngineContextMenuData(*other.d);
-}
-
-/*!
- Assigns the \a other context menu data to this.
-*/
-QWebEngineContextMenuData &QWebEngineContextMenuData::operator=(const QWebEngineContextMenuData &other)
-{
- delete d;
- d = new QtWebEngineCore::WebEngineContextMenuData(*other.d);
- return *this;
-}
-
-/*!
- Destroys the context menu data.
-*/
-QWebEngineContextMenuData::~QWebEngineContextMenuData()
-{
- delete d;
-}
-
-/*!
- Returns \c true if the context data is valid; otherwise returns \c false.
-*/
-bool QWebEngineContextMenuData::isValid() const
-{
- return d;
-}
-
-/*!
- Resets the context data, making it invalid.
- \internal
-
- \sa isValid()
-*/
-void QWebEngineContextMenuData::reset()
-{
- delete d;
- d = nullptr;
-}
-
-/*!
- Returns the position of the context, usually the mouse position where the context menu event was triggered.
-*/
-QPoint QWebEngineContextMenuData::position() const
-{
- return d ? d->position() : QPoint();
-}
-
-/*!
- Returns the text of a link if the context is a link.
-*/
-QString QWebEngineContextMenuData::linkText() const
-{
- return d ? d->linkText() : QString();
-}
-
-/*!
- Returns the URL of a link if the context is a link.
- It is not guaranteed to be a valid URL.
-*/
-QUrl QWebEngineContextMenuData::linkUrl() const
-{
- return d ? d->unfilteredLinkUrl() : QUrl();
-}
-
-/*!
- Returns the selected text of the context.
-*/
-QString QWebEngineContextMenuData::selectedText() const
-{
- return d ? d->selectedText() : QString();
-}
-
-/*!
- If the context is a media element, returns the URL of that media.
-*/
-QUrl QWebEngineContextMenuData::mediaUrl() const
-{
- return d ? d->mediaUrl() : QUrl();
-}
-
-/*!
- Returns the type of the media element or \c MediaTypeNone if the context is not a media element.
-*/
-QWebEngineContextMenuData::MediaType QWebEngineContextMenuData::mediaType() const
-{
- return d ? static_cast<QWebEngineContextMenuData::MediaType>(d->mediaType()) : MediaTypeNone;
-}
-
-/*!
- Returns \c true if the content is editable by the user; otherwise returns \c false.
-*/
-bool QWebEngineContextMenuData::isContentEditable() const
-{
- return d ? d->isEditable() : false;
-}
-
-/*!
- If the context is a word considered misspelled by the spell-checker, returns the misspelled word.
-
- For possible replacements of the word, see spellCheckerSuggestions().
-
- \since 5.8
-*/
-QString QWebEngineContextMenuData::misspelledWord() const
-{
- if (d)
- return d->misspelledWord();
- return QString();
-}
-
-/*!
- If the context is a word considered misspelled by the spell-checker, returns a list of suggested replacements
- for misspelledWord().
-
- \since 5.8
-*/
-QStringList QWebEngineContextMenuData::spellCheckerSuggestions() const
-{
- if (d)
- return d->spellCheckerSuggestions();
- return QStringList();
-}
-
-/*!
- \internal
-*/
-QWebEngineContextMenuData &QWebEngineContextMenuData::operator=(const QWebEngineContextDataPrivate &priv)
-{
- delete d;
- d = new QtWebEngineCore::WebEngineContextMenuData(priv);
- return *this;
-}
-
-/*!
- Returns the current media element's status and its available operations.
- \c MediaNone if the selected web page content is not a media element.
-*/
-QWebEngineContextMenuData::MediaFlags QWebEngineContextMenuData::mediaFlags() const
-{
- return static_cast<QWebEngineContextMenuData::MediaFlags>(d->mediaFlags());
-}
-
-/*!
- Returns the available edit operations in the current context or \c CanDoNone if no actions are available.
-*/
-QWebEngineContextMenuData::EditFlags QWebEngineContextMenuData::editFlags() const
-{
- return static_cast<QWebEngineContextMenuData::EditFlags>(d->editFlags());
-}
-
-QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginecontextmenudata.h b/src/webenginewidgets/api/qwebenginecontextmenudata.h
deleted file mode 100644
index 5834df31a..000000000
--- a/src/webenginewidgets/api/qwebenginecontextmenudata.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 QWEBENGINECONTEXTDATA_H
-#define QWEBENGINECONTEXTDATA_H
-
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-#include <QtCore/qpoint.h>
-#include <QtCore/qstring.h>
-#include <QtCore/qurl.h>
-
-namespace QtWebEngineCore {
-class WebEngineContextMenuData;
-}
-
-QT_BEGIN_NAMESPACE
-
-class QWEBENGINEWIDGETS_EXPORT QWebEngineContextMenuData {
- Q_GADGET
-
-public:
- QWebEngineContextMenuData();
- QWebEngineContextMenuData(const QWebEngineContextMenuData &other);
- QWebEngineContextMenuData &operator=(const QWebEngineContextMenuData &other);
- ~QWebEngineContextMenuData();
-
- enum MediaType {
- MediaTypeNone,
- MediaTypeImage,
- MediaTypeVideo,
- MediaTypeAudio,
- MediaTypeCanvas,
- MediaTypeFile,
- MediaTypePlugin
- };
-
- // Must match QWebEngineCore::WebEngineContextMenuData::MediaFlags:
- enum MediaFlag {
- MediaInError = 0x1,
- MediaPaused = 0x2,
- MediaMuted = 0x4,
- MediaLoop = 0x8,
- MediaCanSave = 0x10,
- MediaHasAudio = 0x20,
- MediaCanToggleControls = 0x40,
- MediaControls = 0x80,
- MediaCanPrint = 0x100,
- MediaCanRotate = 0x200,
- };
- Q_DECLARE_FLAGS(MediaFlags, MediaFlag)
- Q_FLAG(MediaFlags)
-
- // Must match QWebEngineCore::WebEngineContextMenuData::EditFlags:
- enum EditFlag {
- CanUndo = 0x1,
- CanRedo = 0x2,
- CanCut = 0x4,
- CanCopy = 0x8,
- CanPaste = 0x10,
- CanDelete = 0x20,
- CanSelectAll = 0x40,
- CanTranslate = 0x80,
- CanEditRichly = 0x100,
- };
- Q_DECLARE_FLAGS(EditFlags, EditFlag)
- Q_FLAG(EditFlags)
-
- bool isValid() const;
-
- QPoint position() const;
- QString selectedText() const;
- QString linkText() const;
- QUrl linkUrl() const;
- QUrl mediaUrl() const;
- MediaType mediaType() const;
- bool isContentEditable() const;
- QString misspelledWord() const;
- QStringList spellCheckerSuggestions() const;
- MediaFlags mediaFlags() const;
- EditFlags editFlags() const;
-
-private:
- void reset();
- typedef QtWebEngineCore::WebEngineContextMenuData QWebEngineContextDataPrivate;
- QWebEngineContextMenuData &operator=(const QWebEngineContextDataPrivate &priv);
- const QWebEngineContextDataPrivate *d;
-
- friend class QWebEnginePagePrivate;
- friend class QWebEnginePage;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QWebEngineContextMenuData::MediaFlags)
-Q_DECLARE_OPERATORS_FOR_FLAGS(QWebEngineContextMenuData::EditFlags)
-
-QT_END_NAMESPACE
-
-#endif // QWEBENGINECONTEXTDATA_H
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.h b/src/webenginewidgets/api/qwebenginedownloaditem.h
deleted file mode 100644
index 094054079..000000000
--- a/src/webenginewidgets/api/qwebenginedownloaditem.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 QWEBENGINEDOWNLOADITEM_H
-#define QWEBENGINEDOWNLOADITEM_H
-
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_NAMESPACE
-
-class QWebEnginePage;
-class QWebEngineDownloadItemPrivate;
-class QWebEngineProfilePrivate;
-
-class QWEBENGINEWIDGETS_EXPORT QWebEngineDownloadItem : public QObject
-{
- Q_OBJECT
-public:
- ~QWebEngineDownloadItem();
-
- enum DownloadState {
- DownloadRequested,
- DownloadInProgress,
- DownloadCompleted,
- DownloadCancelled,
- DownloadInterrupted
- };
- Q_ENUM(DownloadState)
-
- enum SavePageFormat {
- UnknownSaveFormat = -1,
- SingleHtmlSaveFormat,
- CompleteHtmlSaveFormat,
- MimeHtmlSaveFormat
- };
- Q_ENUM(SavePageFormat)
-
- enum DownloadInterruptReason {
- NoReason = 0,
- FileFailed = 1,
- FileAccessDenied = 2,
- FileNoSpace = 3,
- FileNameTooLong = 5,
- FileTooLarge = 6,
- FileVirusInfected = 7,
- FileTransientError = 10,
- FileBlocked = 11,
- FileSecurityCheckFailed = 12,
- FileTooShort = 13,
- FileHashMismatch = 14,
- NetworkFailed = 20,
- NetworkTimeout = 21,
- NetworkDisconnected = 22,
- NetworkServerDown = 23,
- NetworkInvalidRequest = 24,
- ServerFailed = 30,
- //ServerNoRange = 31,
- ServerBadContent = 33,
- ServerUnauthorized = 34,
- ServerCertProblem = 35,
- ServerForbidden = 36,
- ServerUnreachable = 37,
- UserCanceled = 40,
- //UserShutdown = 41,
- //Crash = 50
- };
- Q_ENUM(DownloadInterruptReason)
-
- enum DownloadType {
- Attachment = 0,
- DownloadAttribute,
- UserRequested,
- SavePage
- };
- Q_ENUM(DownloadType)
-
- quint32 id() const;
- DownloadState state() const;
- qint64 totalBytes() const;
- qint64 receivedBytes() const;
- QUrl url() const;
- QString mimeType() const;
-#if QT_DEPRECATED_SINCE(5, 14)
-#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
- QT_DEPRECATED_VERSION_X(5, 14, "Use downloadDirectory() and downloadFileName() instead")
- QString path() const;
- QT_DEPRECATED_VERSION_X(5, 14, "Use setDownloadDirectory() and setDownloadFileName() instead")
- void setPath(QString path);
-#else
- QT_DEPRECATED_X("Use downloadDirectory() and downloadFileName() instead")
- QString path() const;
- QT_DEPRECATED_X("Use setDownloadDirectory() and setDownloadFileName() instead")
- void setPath(QString path);
-#endif
-#endif
- bool isFinished() const;
- bool isPaused() const;
- SavePageFormat savePageFormat() const;
- void setSavePageFormat(SavePageFormat format);
- DownloadType Q_DECL_DEPRECATED type() const;
- DownloadInterruptReason interruptReason() const;
- QString interruptReasonString() const;
- bool isSavePageDownload() const;
- QString suggestedFileName() const;
- QString downloadDirectory() const;
- void setDownloadDirectory(const QString &directory);
- QString downloadFileName() const;
- void setDownloadFileName(const QString &fileName);
-
- QWebEnginePage *page() const;
-
-public Q_SLOTS:
- void accept();
- void cancel();
- void pause();
- void resume();
-
-Q_SIGNALS:
- void finished();
- void stateChanged(QWebEngineDownloadItem::DownloadState state);
- void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
- void isPausedChanged(bool isPaused);
-
-private:
- Q_DISABLE_COPY(QWebEngineDownloadItem)
- Q_DECLARE_PRIVATE(QWebEngineDownloadItem)
-
- friend class QWebEngineProfilePrivate;
-
- QWebEngineDownloadItem(QWebEngineDownloadItemPrivate*, QObject *parent = Q_NULLPTR);
- QScopedPointer<QWebEngineDownloadItemPrivate> d_ptr;
-};
-
-QT_END_NAMESPACE
-
-#endif // QWEBENGINEDOWNLOADITEM_H
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 6fb3c5c43..dce3142bb 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -42,7 +42,6 @@
#include "authentication_dialog_controller.h"
#include "profile_adapter.h"
-#include "certificate_error_controller.h"
#include "color_chooser_controller.h"
#include "favicon_manager.h"
#include "find_text_helper.h"
@@ -278,7 +277,7 @@ void QWebEnginePagePrivate::loadStarted(const QUrl &provisionalUrl, bool isError
return;
isLoading = true;
- m_certificateErrorControllers.clear();
+
QTimer::singleShot(0, q, &QWebEnginePage::loadStarted);
}
@@ -548,7 +547,7 @@ QObject *QWebEnginePagePrivate::accessibilityParentObject()
void QWebEnginePagePrivate::updateAction(QWebEnginePage::WebAction action) const
{
#ifdef QT_NO_ACTION
- Q_UNUSED(action)
+ Q_UNUSED(action);
#else
QAction *a = actions[action];
if (!a)
@@ -1041,8 +1040,8 @@ void QWebEnginePage::setWebChannel(QWebChannel *channel, uint worldId)
d->adapter->setWebChannel(channel, worldId);
}
#else
- Q_UNUSED(channel)
- Q_UNUSED(worldId)
+ Q_UNUSED(channel);
+ Q_UNUSED(worldId);
qWarning("WebEngine compiled without webchannel support");
#endif
}
@@ -1087,11 +1086,11 @@ void QWebEnginePage::setBackgroundColor(const QColor &color)
*
* This function issues an asynchronous download request for the web page and returns immediately.
*
- * \sa QWebEngineDownloadItem::SavePageFormat
+ * \sa QWebEngineDownloadRequest::SavePageFormat
* \since 5.8
*/
void QWebEnginePage::save(const QString &filePath,
- QWebEngineDownloadItem::SavePageFormat format) const
+ QWebEngineDownloadRequest::SavePageFormat format) const
{
Q_D(const QWebEnginePage);
d->ensureInitialized();
@@ -1360,7 +1359,6 @@ void QWebEnginePage::triggerAction(WebAction action, bool)
{
Q_D(QWebEnginePage);
d->ensureInitialized();
- const QtWebEngineCore::WebEngineContextMenuData *menuData = d->contextData.d;
switch (action) {
case Back:
d->adapter->navigateBack();
@@ -1402,35 +1400,36 @@ void QWebEnginePage::triggerAction(WebAction action, bool)
d->adapter->unselect();
break;
case OpenLinkInThisWindow:
- if (menuData && menuData->linkUrl().isValid())
- setUrl(menuData->linkUrl());
+ if (d->view && d->view->lastContextMenuRequest()->filteredLinkUrl().isValid())
+ setUrl(d->view->lastContextMenuRequest()->filteredLinkUrl());
break;
case OpenLinkInNewWindow:
- if (menuData && menuData->linkUrl().isValid()) {
+ if (d->view && d->view->lastContextMenuRequest()->filteredLinkUrl().isValid()) {
QWebEnginePage *newPage = createWindow(WebBrowserWindow);
if (newPage)
- newPage->setUrl(menuData->linkUrl());
+ newPage->setUrl(d->view->lastContextMenuRequest()->filteredLinkUrl());
}
break;
case OpenLinkInNewTab:
- if (menuData && menuData->linkUrl().isValid()) {
+ if (d->view && d->view->lastContextMenuRequest()->filteredLinkUrl().isValid()) {
QWebEnginePage *newPage = createWindow(WebBrowserTab);
if (newPage)
- newPage->setUrl(menuData->linkUrl());
+ newPage->setUrl(d->view->lastContextMenuRequest()->filteredLinkUrl());
}
break;
case OpenLinkInNewBackgroundTab:
- if (menuData && menuData->linkUrl().isValid()) {
+ if (d->view && d->view->lastContextMenuRequest()->filteredLinkUrl().isValid()) {
QWebEnginePage *newPage = createWindow(WebBrowserBackgroundTab);
if (newPage)
- newPage->setUrl(menuData->linkUrl());
+ newPage->setUrl(d->view->lastContextMenuRequest()->filteredLinkUrl());
}
break;
case CopyLinkToClipboard:
- if (menuData && !menuData->unfilteredLinkUrl().isEmpty()) {
- QString urlString = menuData->unfilteredLinkUrl().toString(QUrl::FullyEncoded);
- QString linkText = menuData->linkText().toHtmlEscaped();
- QString title = menuData->titleText();
+ if (d->view && !d->view->lastContextMenuRequest()->linkUrl().isEmpty()) {
+ QString urlString = d->view->lastContextMenuRequest()->linkUrl().toString(
+ QUrl::FullyEncoded);
+ QString linkText = d->view->lastContextMenuRequest()->linkText().toHtmlEscaped();
+ QString title = d->view->lastContextMenuRequest()->titleText();
if (!title.isEmpty())
title = QStringLiteral(" title=\"%1\"").arg(title.toHtmlEscaped());
QMimeData *data = new QMimeData();
@@ -1438,102 +1437,127 @@ void QWebEnginePage::triggerAction(WebAction action, bool)
QString html = QStringLiteral("<a href=\"") + urlString + QStringLiteral("\"") + title + QStringLiteral(">")
+ linkText + QStringLiteral("</a>");
data->setHtml(html);
- data->setUrls(QList<QUrl>() << menuData->unfilteredLinkUrl());
+ data->setUrls(QList<QUrl>() << d->view->lastContextMenuRequest()->linkUrl());
qApp->clipboard()->setMimeData(data);
}
break;
case DownloadLinkToDisk:
- if (menuData && menuData->linkUrl().isValid())
- d->adapter->download(menuData->linkUrl(), menuData->suggestedFileName(),
- menuData->referrerUrl(), menuData->referrerPolicy());
+ if (d->view && d->view->lastContextMenuRequest()->filteredLinkUrl().isValid())
+ d->adapter->download(d->view->lastContextMenuRequest()->filteredLinkUrl(),
+ d->view->lastContextMenuRequest()->suggestedFileName(),
+ d->view->lastContextMenuRequest()->referrerUrl(),
+ d->view->lastContextMenuRequest()->referrerPolicy());
break;
case CopyImageToClipboard:
- if (menuData && menuData->hasImageContent() &&
- (menuData->mediaType() == WebEngineContextMenuData::MediaTypeImage ||
- menuData->mediaType() == WebEngineContextMenuData::MediaTypeCanvas))
- {
- d->adapter->copyImageAt(menuData->position());
+ if (d->view && d->view->lastContextMenuRequest()->hasImageContent()
+ && (d->view->lastContextMenuRequest()->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeImage
+ || d->view->lastContextMenuRequest()->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeCanvas)) {
+ d->adapter->copyImageAt(d->view->lastContextMenuRequest()->position());
}
break;
case CopyImageUrlToClipboard:
- if (menuData && menuData->mediaUrl().isValid() && menuData->mediaType() == WebEngineContextMenuData::MediaTypeImage) {
- QString urlString = menuData->mediaUrl().toString(QUrl::FullyEncoded);
- QString alt = menuData->altText();
+ if (d->view && d->view->lastContextMenuRequest()->mediaUrl().isValid()
+ && d->view->lastContextMenuRequest()->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeImage) {
+ QString urlString =
+ d->view->lastContextMenuRequest()->mediaUrl().toString(QUrl::FullyEncoded);
+ QString alt = d->view->lastContextMenuRequest()->altText();
if (!alt.isEmpty())
alt = QStringLiteral(" alt=\"%1\"").arg(alt.toHtmlEscaped());
- QString title = menuData->titleText();
+ QString title = d->view->lastContextMenuRequest()->titleText();
if (!title.isEmpty())
title = QStringLiteral(" title=\"%1\"").arg(title.toHtmlEscaped());
QMimeData *data = new QMimeData();
data->setText(urlString);
QString html = QStringLiteral("<img src=\"") + urlString + QStringLiteral("\"") + title + alt + QStringLiteral("></img>");
data->setHtml(html);
- data->setUrls(QList<QUrl>() << menuData->mediaUrl());
+ data->setUrls(QList<QUrl>() << d->view->lastContextMenuRequest()->mediaUrl());
qApp->clipboard()->setMimeData(data);
}
break;
case DownloadImageToDisk:
case DownloadMediaToDisk:
- if (menuData && menuData->mediaUrl().isValid())
- d->adapter->download(menuData->mediaUrl(), menuData->suggestedFileName(),
- menuData->referrerUrl(), menuData->referrerPolicy());
+ if (d->view && d->view->lastContextMenuRequest()->mediaUrl().isValid())
+ d->adapter->download(d->view->lastContextMenuRequest()->mediaUrl(),
+ d->view->lastContextMenuRequest()->suggestedFileName(),
+ d->view->lastContextMenuRequest()->referrerUrl(),
+ d->view->lastContextMenuRequest()->referrerPolicy());
break;
case CopyMediaUrlToClipboard:
- if (menuData && menuData->mediaUrl().isValid() &&
- (menuData->mediaType() == WebEngineContextMenuData::MediaTypeAudio ||
- menuData->mediaType() == WebEngineContextMenuData::MediaTypeVideo))
- {
- QString urlString = menuData->mediaUrl().toString(QUrl::FullyEncoded);
- QString title = menuData->titleText();
+ if (d->view && d->view->lastContextMenuRequest()->mediaUrl().isValid()
+ && (d->view->lastContextMenuRequest()->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeAudio
+ || d->view->lastContextMenuRequest()->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeVideo)) {
+ QString urlString =
+ d->view->lastContextMenuRequest()->mediaUrl().toString(QUrl::FullyEncoded);
+ QString title = d->view->lastContextMenuRequest()->titleText();
if (!title.isEmpty())
title = QStringLiteral(" title=\"%1\"").arg(title.toHtmlEscaped());
QMimeData *data = new QMimeData();
data->setText(urlString);
- if (menuData->mediaType() == WebEngineContextMenuData::MediaTypeAudio)
+ if (d->view->lastContextMenuRequest()->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeAudio)
data->setHtml(QStringLiteral("<audio src=\"") + urlString + QStringLiteral("\"") + title +
QStringLiteral("></audio>"));
else
data->setHtml(QStringLiteral("<video src=\"") + urlString + QStringLiteral("\"") + title +
QStringLiteral("></video>"));
- data->setUrls(QList<QUrl>() << menuData->mediaUrl());
+ data->setUrls(QList<QUrl>() << d->view->lastContextMenuRequest()->mediaUrl());
qApp->clipboard()->setMimeData(data);
}
break;
case ToggleMediaControls:
- if (menuData && menuData->mediaUrl().isValid() && menuData->mediaFlags() & WebEngineContextMenuData::MediaCanToggleControls) {
- bool enable = !(menuData->mediaFlags() & WebEngineContextMenuData::MediaControls);
- d->adapter->executeMediaPlayerActionAt(menuData->position(), WebContentsAdapter::MediaPlayerControls, enable);
+ if (d->view && d->view->lastContextMenuRequest()->mediaUrl().isValid()
+ && d->view->lastContextMenuRequest()->mediaFlags()
+ & QWebEngineContextMenuRequest::MediaCanToggleControls) {
+ bool enable = !(d->view->lastContextMenuRequest()->mediaFlags()
+ & QWebEngineContextMenuRequest::MediaControls);
+ d->adapter->executeMediaPlayerActionAt(d->view->lastContextMenuRequest()->position(),
+ WebContentsAdapter::MediaPlayerControls, enable);
}
break;
case ToggleMediaLoop:
- if (menuData && menuData->mediaUrl().isValid() &&
- (menuData->mediaType() == WebEngineContextMenuData::MediaTypeAudio ||
- menuData->mediaType() == WebEngineContextMenuData::MediaTypeVideo))
- {
- bool enable = !(menuData->mediaFlags() & WebEngineContextMenuData::MediaLoop);
- d->adapter->executeMediaPlayerActionAt(menuData->position(), WebContentsAdapter::MediaPlayerLoop, enable);
+ if (d->view && d->view->lastContextMenuRequest()->mediaUrl().isValid()
+ && (d->view->lastContextMenuRequest()->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeAudio
+ || d->view->lastContextMenuRequest()->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeVideo)) {
+ bool enable = !(d->view->lastContextMenuRequest()->mediaFlags()
+ & QWebEngineContextMenuRequest::MediaLoop);
+ d->adapter->executeMediaPlayerActionAt(d->view->lastContextMenuRequest()->position(),
+ WebContentsAdapter::MediaPlayerLoop, enable);
}
break;
case ToggleMediaPlayPause:
- if (menuData && menuData->mediaUrl().isValid() &&
- (menuData->mediaType() == WebEngineContextMenuData::MediaTypeAudio ||
- menuData->mediaType() == WebEngineContextMenuData::MediaTypeVideo))
- {
- bool enable = (menuData->mediaFlags() & WebEngineContextMenuData::MediaPaused);
- d->adapter->executeMediaPlayerActionAt(menuData->position(), WebContentsAdapter::MediaPlayerPlay, enable);
+ if (d->view && d->view->lastContextMenuRequest()->mediaUrl().isValid()
+ && (d->view->lastContextMenuRequest()->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeAudio
+ || d->view->lastContextMenuRequest()->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeVideo)) {
+ bool enable = (d->view->lastContextMenuRequest()->mediaFlags()
+ & QWebEngineContextMenuRequest::MediaPaused);
+ d->adapter->executeMediaPlayerActionAt(d->view->lastContextMenuRequest()->position(),
+ WebContentsAdapter::MediaPlayerPlay, enable);
}
break;
case ToggleMediaMute:
- if (menuData && menuData->mediaUrl().isValid() && menuData->mediaFlags() & WebEngineContextMenuData::MediaHasAudio) {
+ if (d->view && d->view->lastContextMenuRequest()->mediaUrl().isValid()
+ && d->view->lastContextMenuRequest()->mediaFlags()
+ & QWebEngineContextMenuRequest::MediaHasAudio) {
// Make sure to negate the value, so that toggling actually works.
- bool enable = !(menuData->mediaFlags() & WebEngineContextMenuData::MediaMuted);
- d->adapter->executeMediaPlayerActionAt(menuData->position(), WebContentsAdapter::MediaPlayerMute, enable);
+ bool enable = !(d->view->lastContextMenuRequest()->mediaFlags()
+ & QWebEngineContextMenuRequest::MediaMuted);
+ d->adapter->executeMediaPlayerActionAt(d->view->lastContextMenuRequest()->position(),
+ WebContentsAdapter::MediaPlayerMute, enable);
}
break;
case InspectElement:
- if (menuData)
- d->adapter->inspectElementAt(menuData->position());
+ if (d->view)
+ d->adapter->inspectElementAt(d->view->lastContextMenuRequest()->position());
break;
case ExitFullScreen:
// See under ViewSource, anything that can trigger a delete of the current view is dangerous to call directly here.
@@ -1604,8 +1628,8 @@ void QWebEnginePage::triggerAction(WebAction action, bool)
* \since 5.8
* Replace the current misspelled word with \a replacement.
*
- * The current misspelled word can be found in QWebEngineContextMenuData::misspelledWord(),
- * and suggested replacements in QWebEngineContextMenuData::spellCheckerSuggestions().
+ * The current misspelled word can be found in QWebEngineContextMenuRequest::misspelledWord(),
+ * and suggested replacements in QWebEngineContextMenuRequest::spellCheckerSuggestions().
*
* \sa contextMenuData(),
*/
@@ -1635,40 +1659,10 @@ bool QWebEnginePage::event(QEvent *e)
return QObject::event(e);
}
-void QWebEnginePagePrivate::contextMenuRequested(const WebEngineContextMenuData &data)
+void QWebEnginePagePrivate::contextMenuRequested(QWebEngineContextMenuRequest *data)
{
-#if QT_CONFIG(action)
- if (!view)
- return;
-
- contextData.reset();
- switch (view->contextMenuPolicy()) {
- case Qt::DefaultContextMenu:
- {
- contextData = data;
- QContextMenuEvent event(QContextMenuEvent::Mouse, data.position(), view->mapToGlobal(data.position()));
- view->contextMenuEvent(&event);
- return;
- }
- case Qt::CustomContextMenu:
- contextData = data;
- Q_EMIT view->customContextMenuRequested(data.position());
- 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);
- }
- return;
- case Qt::PreventContextMenu:
- case Qt::NoContextMenu:
- return;
- }
-
- Q_UNREACHABLE();
-#else
- Q_UNUSED(data);
-#endif // QT_CONFIG(action)
+ if (view)
+ view->d_ptr->contextMenuRequested(data);
}
void QWebEnginePagePrivate::navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame)
@@ -1725,32 +1719,20 @@ void QWebEnginePagePrivate::javascriptDialog(QSharedPointer<JavaScriptDialogCont
controller->reject();
}
-void QWebEnginePagePrivate::allowCertificateError(const QSharedPointer<CertificateErrorController> &controller)
+void QWebEnginePagePrivate::allowCertificateError(const QWebEngineCertificateError &error)
{
Q_Q(QWebEnginePage);
- bool accepted = false;
-
- QWebEngineCertificateError error(controller);
- accepted = q->certificateError(error);
- if (error.deferred() && !error.answered())
- m_certificateErrorControllers.append(controller);
- else if (!error.answered())
- controller->accept(error.isOverridable() && accepted);
+ q->certificateError(error);
}
void QWebEnginePagePrivate::selectClientCert(const QSharedPointer<ClientCertSelectController> &controller)
{
-#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
Q_Q(QWebEnginePage);
QWebEngineClientCertificateSelection certSelection(controller);
Q_EMIT q->selectClientCertificate(certSelection);
-#else
- Q_UNUSED(controller);
-#endif
}
-#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
/*!
\fn void QWebEnginePage::selectClientCertificate(QWebEngineClientCertificateSelection clientCertificateSelection)
\since 5.12
@@ -1766,7 +1748,6 @@ void QWebEnginePagePrivate::selectClientCert(const QSharedPointer<ClientCertSele
\sa QWebEngineClientCertificateSelection
*/
-#endif
void QWebEnginePagePrivate::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID)
{
@@ -1886,27 +1867,6 @@ void QWebEnginePage::setUrlRequestInterceptor(QWebEngineUrlRequestInterceptor *i
d->adapter->setRequestInterceptor(interceptor);
}
-#if QT_CONFIG(menu)
-QMenu *QWebEnginePage::createStandardContextMenu()
-{
- Q_D(QWebEnginePage);
- if (!d->contextData.d)
- return nullptr;
- d->ensureInitialized();
-
- QMenu *menu = new QMenu(d->view);
- const WebEngineContextMenuData &contextMenuData = *d->contextData.d;
-
- QContextMenuBuilder contextMenuBuilder(contextMenuData, this, menu);
-
- contextMenuBuilder.initMenu();
-
- menu->setAttribute(Qt::WA_DeleteOnClose, true);
-
- return menu;
-}
-#endif // QT_CONFIG(menu)
-
void QWebEnginePage::setFeaturePermission(const QUrl &securityOrigin, QWebEnginePage::Feature feature, QWebEnginePage::PermissionPolicy policy)
{
Q_D(QWebEnginePage);
@@ -2416,10 +2376,7 @@ void QWebEnginePage::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel leve
}
}
-bool QWebEnginePage::certificateError(const QWebEngineCertificateError &)
-{
- return false;
-}
+void QWebEnginePage::certificateError(QWebEngineCertificateError) { }
bool QWebEnginePage::acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame)
{
@@ -2545,19 +2502,6 @@ void QWebEnginePage::print(QPrinter *printer, const QWebEngineCallback<bool> &re
#endif
}
-/*!
- \since 5.7
-
- Returns additional data about the current context menu. It is only guaranteed to be valid during the call to the QWebEngineView::contextMenuEvent()
- handler of the associated QWebEngineView.
-
- \sa createStandardContextMenu()
-*/
-const QWebEngineContextMenuData &QWebEnginePage::contextMenuData() const
-{
- Q_D(const QWebEnginePage);
- return d->contextData;
-}
/*!
\enum QWebEnginePage::LifecycleState
@@ -2673,173 +2617,6 @@ void QWebEnginePage::setVisible(bool visible)
d->adapter->setVisible(visible);
}
-#if QT_CONFIG(action)
-QContextMenuBuilder::QContextMenuBuilder(const QtWebEngineCore::WebEngineContextMenuData &data,
- QWebEnginePage *page,
- QMenu *menu)
- : QtWebEngineCore::RenderViewContextMenuQt(data)
- , m_page(page)
- , m_menu(menu)
-{
-}
-
-bool QContextMenuBuilder::hasInspector()
-{
- return m_page->d_ptr->adapter->hasInspector();
-}
-
-bool QContextMenuBuilder::isFullScreenMode()
-{
- return m_page->d_ptr->isFullScreenMode();
-}
-
-void QContextMenuBuilder::addMenuItem(ContextMenuItem menuItem)
-{
- QPointer<QWebEnginePage> thisRef(m_page);
- QAction *action = 0;
-
- switch (menuItem) {
- case ContextMenuItem::Back:
- action = thisRef->action(QWebEnginePage::Back);
- break;
- case ContextMenuItem::Forward:
- action = thisRef->action(QWebEnginePage::Forward);
- break;
- case ContextMenuItem::Reload:
- action = thisRef->action(QWebEnginePage::Reload);
- break;
- case ContextMenuItem::Cut:
- action = thisRef->action(QWebEnginePage::Cut);
- break;
- case ContextMenuItem::Copy:
- action = thisRef->action(QWebEnginePage::Copy);
- break;
- case ContextMenuItem::Paste:
- action = thisRef->action(QWebEnginePage::Paste);
- break;
- case ContextMenuItem::Undo:
- action = thisRef->action(QWebEnginePage::Undo);
- break;
- case ContextMenuItem::Redo:
- action = thisRef->action(QWebEnginePage::Redo);
- break;
- case ContextMenuItem::SelectAll:
- action = thisRef->action(QWebEnginePage::SelectAll);
- break;
- case ContextMenuItem::PasteAndMatchStyle:
- action = thisRef->action(QWebEnginePage::PasteAndMatchStyle);
- break;
- case ContextMenuItem::OpenLinkInNewWindow:
- action = thisRef->action(QWebEnginePage::OpenLinkInNewWindow);
- break;
- case ContextMenuItem::OpenLinkInNewTab:
- action = thisRef->action(QWebEnginePage::OpenLinkInNewTab);
- break;
- case ContextMenuItem::CopyLinkToClipboard:
- action = thisRef->action(QWebEnginePage::CopyLinkToClipboard);
- break;
- case ContextMenuItem::DownloadLinkToDisk:
- action = thisRef->action(QWebEnginePage::DownloadLinkToDisk);
- break;
- case ContextMenuItem::CopyImageToClipboard:
- action = thisRef->action(QWebEnginePage::CopyImageToClipboard);
- break;
- case ContextMenuItem::CopyImageUrlToClipboard:
- action = thisRef->action(QWebEnginePage::CopyImageUrlToClipboard);
- break;
- case ContextMenuItem::DownloadImageToDisk:
- action = thisRef->action(QWebEnginePage::DownloadImageToDisk);
- break;
- case ContextMenuItem::CopyMediaUrlToClipboard:
- action = thisRef->action(QWebEnginePage::CopyMediaUrlToClipboard);
- break;
- case ContextMenuItem::ToggleMediaControls:
- action = thisRef->action(QWebEnginePage::ToggleMediaControls);
- break;
- case ContextMenuItem::ToggleMediaLoop:
- action = thisRef->action(QWebEnginePage::ToggleMediaLoop);
- break;
- case ContextMenuItem::DownloadMediaToDisk:
- action = thisRef->action(QWebEnginePage::DownloadMediaToDisk);
- break;
- case ContextMenuItem::InspectElement:
- action = thisRef->action(QWebEnginePage::InspectElement);
- break;
- case ContextMenuItem::ExitFullScreen:
- action = thisRef->action(QWebEnginePage::ExitFullScreen);
- break;
- case ContextMenuItem::SavePage:
- action = thisRef->action(QWebEnginePage::SavePage);
- break;
- case ContextMenuItem::ViewSource:
- action = thisRef->action(QWebEnginePage::ViewSource);
- break;
- case ContextMenuItem::SpellingSuggestions:
- for (int i=0; i < m_contextData.spellCheckerSuggestions().count() && i < 4; i++) {
- action = new QAction(m_menu);
- QString replacement = m_contextData.spellCheckerSuggestions().at(i);
- QObject::connect(action, &QAction::triggered, [thisRef, replacement] { if (thisRef) thisRef->replaceMisspelledWord(replacement); });
- action->setText(replacement);
- m_menu->addAction(action);
- }
- return;
- case ContextMenuItem::Separator:
- if (!m_menu->isEmpty())
- m_menu->addSeparator();
- return;
- }
- action->setEnabled(isMenuItemEnabled(menuItem));
- m_menu->addAction(action);
-}
-
-bool QContextMenuBuilder::isMenuItemEnabled(ContextMenuItem menuItem)
-{
- switch (menuItem) {
- case ContextMenuItem::Back:
- return m_page->d_ptr->adapter->canGoBack();
- case ContextMenuItem::Forward:
- return m_page->d_ptr->adapter->canGoForward();
- case ContextMenuItem::Reload:
- return true;
- case ContextMenuItem::Cut:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanCut;
- case ContextMenuItem::Copy:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanCopy;
- case ContextMenuItem::Paste:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanPaste;
- case ContextMenuItem::Undo:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanUndo;
- case ContextMenuItem::Redo:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanRedo;
- case ContextMenuItem::SelectAll:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanSelectAll;
- case ContextMenuItem::PasteAndMatchStyle:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanPaste;
- case ContextMenuItem::OpenLinkInNewWindow:
- case ContextMenuItem::OpenLinkInNewTab:
- case ContextMenuItem::CopyLinkToClipboard:
- case ContextMenuItem::DownloadLinkToDisk:
- case ContextMenuItem::CopyImageToClipboard:
- case ContextMenuItem::CopyImageUrlToClipboard:
- case ContextMenuItem::DownloadImageToDisk:
- case ContextMenuItem::CopyMediaUrlToClipboard:
- case ContextMenuItem::ToggleMediaControls:
- case ContextMenuItem::ToggleMediaLoop:
- case ContextMenuItem::DownloadMediaToDisk:
- case ContextMenuItem::InspectElement:
- case ContextMenuItem::ExitFullScreen:
- case ContextMenuItem::SavePage:
- return true;
- case ContextMenuItem::ViewSource:
- return m_page->d_ptr->adapter->canViewSource();
- case ContextMenuItem::SpellingSuggestions:
- case ContextMenuItem::Separator:
- return true;
- }
- Q_UNREACHABLE();
-}
-#endif // QT_CONFIG(action)
-
QT_END_NAMESPACE
#include "moc_qwebenginepage.cpp"
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h
index 3bf79526d..5ac30863f 100644
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ b/src/webenginewidgets/api/qwebenginepage.h
@@ -42,7 +42,7 @@
#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
#include <QtWebEngineWidgets/qwebengineclientcertificateselection.h>
-#include <QtWebEngineWidgets/qwebenginedownloaditem.h>
+#include <QtWebEngineCore/qwebenginedownloadrequest.h>
#include <QtWebEngineCore/qwebenginecallback.h>
#include <QtWebEngineCore/qwebenginehttprequest.h>
@@ -61,7 +61,6 @@ class QContextMenuBuilder;
class QWebChannel;
class QWebEngineCertificateError;
class QWebEngineClientCertificateSelection;
-class QWebEngineContextMenuData;
class QWebEngineFindTextResult;
class QWebEngineFullScreenRequest;
class QWebEngineHistory;
@@ -259,10 +258,6 @@ public:
void findText(const QString &subString, FindFlags options = FindFlags(), const QWebEngineCallback<bool> &resultCallback = QWebEngineCallback<bool>());
-#if QT_CONFIG(menu)
- QMenu *createStandardContextMenu();
-#endif
-
void setFeaturePermission(const QUrl &securityOrigin, Feature feature, PermissionPolicy policy);
void load(const QUrl &url);
@@ -300,8 +295,8 @@ public:
QColor backgroundColor() const;
void setBackgroundColor(const QColor &color);
- void save(const QString &filePath, QWebEngineDownloadItem::SavePageFormat format
- = QWebEngineDownloadItem::MimeHtmlSaveFormat) const;
+ void save(const QString &filePath, QWebEngineDownloadRequest::SavePageFormat format
+ = QWebEngineDownloadRequest::MimeHtmlSaveFormat) const;
bool isAudioMuted() const;
void setAudioMuted(bool muted);
@@ -319,8 +314,6 @@ public:
void setUrlRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor);
- const QWebEngineContextMenuData &contextMenuData() const;
-
LifecycleState lifecycleState() const;
void setLifecycleState(LifecycleState state);
@@ -344,10 +337,7 @@ Q_SIGNALS:
void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest);
void quotaRequested(QWebEngineQuotaRequest quotaRequest);
void registerProtocolHandlerRequested(QWebEngineRegisterProtocolHandlerRequest request);
-#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
void selectClientCertificate(QWebEngineClientCertificateSelection clientCertSelection);
-#endif
-
void authenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator);
void proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator, const QString &proxyHost);
@@ -382,7 +372,7 @@ protected:
virtual bool javaScriptConfirm(const QUrl &securityOrigin, const QString& msg);
virtual bool javaScriptPrompt(const QUrl &securityOrigin, const QString& msg, const QString& defaultValue, QString* result);
virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID);
- virtual bool certificateError(const QWebEngineCertificateError &certificateError);
+ virtual void certificateError(QWebEngineCertificateError certificateError);
virtual bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame);
private:
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index 3ddf4b3d6..8bda737da 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -54,9 +54,7 @@
#include "qwebenginepage.h"
#include "qwebenginecallback_p.h"
-#include "qwebenginecontextmenudata.h"
#include "qwebenginescriptcollection.h"
-#include "render_view_context_menu_qt.h"
#include "web_contents_adapter_client.h"
#include <QtCore/qcompilerdetection.h>
@@ -106,7 +104,7 @@ public:
QColor backgroundColor() const override;
void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) override;
void loadCommitted() override { }
- void loadVisuallyCommitted() override { }
+ void didFirstVisuallyNonEmptyPaint() override { }
void loadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()) override;
void focusContainer() override;
void unhandledKeyEvent(QKeyEvent *event) override;
@@ -117,7 +115,7 @@ public:
bool isBeingAdopted() override;
void close() override;
void windowCloseRejected() override;
- void contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &data) override;
+ void contextMenuRequested(QWebEngineContextMenuRequest *request) 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;
@@ -140,8 +138,9 @@ public:
void runRegisterProtocolHandlerRequest(QWebEngineRegisterProtocolHandlerRequest) override;
QObject *accessibilityParentObject() override;
QtWebEngineCore::WebEngineSettings *webEngineSettings() const override;
- void allowCertificateError(const QSharedPointer<CertificateErrorController> &controller) override;
- void selectClientCert(const QSharedPointer<ClientCertSelectController> &controller) override;
+ void allowCertificateError(const QWebEngineCertificateError &error) override;
+ void selectClientCert(
+ const QSharedPointer<QtWebEngineCore::ClientCertSelectController> &controller) override;
void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode) override;
void requestGeometryChange(const QRect &geometry, const QRect &frameGeometry) override;
void updateScrollPosition(const QPointF &position) override;
@@ -184,7 +183,6 @@ public:
QWebEngineSettings *settings;
QWebEngineView *view;
QUrl url;
- QWebEngineContextMenuData contextData;
bool isLoading;
QWebEngineScriptCollection scriptCollection;
bool m_isBeingAdopted;
@@ -206,24 +204,6 @@ public:
#if QT_CONFIG(webengine_printing_and_pdf)
QPrinter *currentPrinter;
#endif
-
- QList<QSharedPointer<CertificateErrorController>> m_certificateErrorControllers;
-};
-
-class QContextMenuBuilder : public QtWebEngineCore::RenderViewContextMenuQt
-{
-public:
- QContextMenuBuilder(const QtWebEngineCore::WebEngineContextMenuData &data, QWebEnginePage *page, QMenu *menu);
-
-private:
- virtual bool hasInspector() override;
- virtual bool isFullScreenMode() override;
-
- virtual void addMenuItem(ContextMenuItem entry) override;
- virtual bool isMenuItemEnabled(ContextMenuItem entry) override;
-
- QWebEnginePage *m_page;
- QMenu *m_menu;
};
QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp
index 4c49be709..ea9db34c4 100644
--- a/src/webenginewidgets/api/qwebengineprofile.cpp
+++ b/src/webenginewidgets/api/qwebengineprofile.cpp
@@ -41,8 +41,8 @@
#include "qwebengineprofile_p.h"
#include "qwebenginecookiestore.h"
-#include "qwebenginedownloaditem.h"
-#include "qwebenginedownloaditem_p.h"
+#include "qwebenginedownloadrequest.h"
+#include "qwebenginedownloadrequest_p.h"
#include "qwebenginenotificationpresenter_p.h"
#include "qwebenginepage.h"
#include "qwebenginepage_p.h"
@@ -58,10 +58,10 @@
QT_BEGIN_NAMESPACE
-ASSERT_ENUMS_MATCH(QWebEngineDownloadItem::UnknownSaveFormat, QtWebEngineCore::ProfileAdapterClient::UnknownSavePageFormat)
-ASSERT_ENUMS_MATCH(QWebEngineDownloadItem::SingleHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::SingleHtmlSaveFormat)
-ASSERT_ENUMS_MATCH(QWebEngineDownloadItem::CompleteHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::CompleteHtmlSaveFormat)
-ASSERT_ENUMS_MATCH(QWebEngineDownloadItem::MimeHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::MimeHtmlSaveFormat)
+ASSERT_ENUMS_MATCH(QWebEngineDownloadRequest::UnknownSaveFormat, QtWebEngineCore::ProfileAdapterClient::UnknownSavePageFormat)
+ASSERT_ENUMS_MATCH(QWebEngineDownloadRequest::SingleHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::SingleHtmlSaveFormat)
+ASSERT_ENUMS_MATCH(QWebEngineDownloadRequest::CompleteHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::CompleteHtmlSaveFormat)
+ASSERT_ENUMS_MATCH(QWebEngineDownloadRequest::MimeHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::MimeHtmlSaveFormat)
using QtWebEngineCore::ProfileAdapter;
@@ -151,19 +151,19 @@ void QWebEngineProfilePrivate::showNotification(QSharedPointer<QtWebEngineCore::
}
/*!
- \fn QWebEngineProfile::downloadRequested(QWebEngineDownloadItem *download)
+ \fn QWebEngineProfile::downloadRequested(QWebEngineDownloadRequest *download)
\since 5.5
This signal is emitted whenever a download has been triggered.
The \a download argument holds the state of the download.
- The download has to be explicitly accepted with QWebEngineDownloadItem::accept() or it will be
+ The download has to be explicitly accepted with QWebEngineDownloadRequest::accept() or it will be
cancelled by default.
The download item is parented by the profile. If it is not accepted, it
will be deleted immediately after the signal emission.
This signal cannot be used with a queued connection.
- \sa QWebEngineDownloadItem, QWebEnginePage::download()
+ \sa QWebEngineDownloadRequest, QWebEnginePage::download()
*/
QWebEngineProfilePrivate::QWebEngineProfilePrivate(ProfileAdapter* profileAdapter)
@@ -223,37 +223,37 @@ void QWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info)
Q_Q(QWebEngineProfile);
Q_ASSERT(!m_ongoingDownloads.contains(info.id));
- QWebEngineDownloadItemPrivate *itemPrivate = new QWebEngineDownloadItemPrivate(this, info.url);
+ QWebEngineDownloadRequestPrivate *itemPrivate = new QWebEngineDownloadRequestPrivate(m_profileAdapter, info.url);
itemPrivate->downloadId = info.id;
- itemPrivate->downloadState = info.accepted ? QWebEngineDownloadItem::DownloadInProgress
- : QWebEngineDownloadItem::DownloadRequested;
+ itemPrivate->downloadState = info.accepted ? QWebEngineDownloadRequest::DownloadInProgress
+ : QWebEngineDownloadRequest::DownloadRequested;
itemPrivate->startTime = info.startTime;
itemPrivate->downloadDirectory = QFileInfo(info.path).path();
itemPrivate->downloadFileName = QFileInfo(info.path).fileName();
itemPrivate->suggestedFileName = info.suggestedFileName;
itemPrivate->mimeType = info.mimeType;
- itemPrivate->savePageFormat = static_cast<QWebEngineDownloadItem::SavePageFormat>(info.savePageFormat);
- itemPrivate->type = static_cast<QWebEngineDownloadItem::DownloadType>(info.downloadType);
+ itemPrivate->savePageFormat = static_cast<QWebEngineDownloadRequest::SavePageFormat>(info.savePageFormat);
+ itemPrivate->isSavePageDownload = info.isSavePageDownload;
if (info.page && info.page->clientType() == QtWebEngineCore::WebContentsAdapterClient::WidgetsClient)
itemPrivate->page = static_cast<QWebEnginePagePrivate *>(info.page)->q_ptr;
else
itemPrivate->page = nullptr;
- QWebEngineDownloadItem *download = new QWebEngineDownloadItem(itemPrivate, q);
+ QWebEngineDownloadRequest *download = new QWebEngineDownloadRequest(itemPrivate, q);
m_ongoingDownloads.insert(info.id, download);
- QObject::connect(download, &QWebEngineDownloadItem::destroyed, q, [id = info.id, this] () { downloadDestroyed(id); });
+ QObject::connect(download, &QWebEngineDownloadRequest::destroyed, q, [id = info.id, this] () { downloadDestroyed(id); });
Q_EMIT q->downloadRequested(download);
- QWebEngineDownloadItem::DownloadState state = download->state();
+ QWebEngineDownloadRequest::DownloadState state = download->state();
info.path = QDir(download->downloadDirectory()).filePath(download->downloadFileName());
info.savePageFormat = static_cast<QtWebEngineCore::ProfileAdapterClient::SavePageFormat>(
download->savePageFormat());
- info.accepted = state != QWebEngineDownloadItem::DownloadCancelled;
+ info.accepted = state != QWebEngineDownloadRequest::DownloadCancelled;
- if (state == QWebEngineDownloadItem::DownloadRequested) {
+ if (state == QWebEngineDownloadRequest::DownloadRequested) {
// Delete unaccepted downloads.
info.accepted = false;
delete download;
@@ -265,7 +265,7 @@ void QWebEngineProfilePrivate::downloadUpdated(const DownloadItemInfo &info)
if (!m_ongoingDownloads.contains(info.id))
return;
- QWebEngineDownloadItem* download = m_ongoingDownloads.value(info.id).data();
+ QWebEngineDownloadRequest* download = m_ongoingDownloads.value(info.id).data();
if (!download) {
downloadDestroyed(info.id);
diff --git a/src/webenginewidgets/api/qwebengineprofile.h b/src/webenginewidgets/api/qwebengineprofile.h
index 794ba6279..a8bf70856 100644
--- a/src/webenginewidgets/api/qwebengineprofile.h
+++ b/src/webenginewidgets/api/qwebengineprofile.h
@@ -55,7 +55,7 @@ class QObject;
class QUrl;
class QWebEngineClientCertificateStore;
class QWebEngineCookieStore;
-class QWebEngineDownloadItem;
+class QWebEngineDownloadRequest;
class QWebEngineNotification;
class QWebEnginePage;
class QWebEnginePagePrivate;
@@ -149,7 +149,7 @@ public:
static QWebEngineProfile *defaultProfile();
Q_SIGNALS:
- void downloadRequested(QWebEngineDownloadItem *download);
+ void downloadRequested(QWebEngineDownloadRequest *download);
private:
Q_DISABLE_COPY(QWebEngineProfile)
diff --git a/src/webenginewidgets/api/qwebengineprofile_p.h b/src/webenginewidgets/api/qwebengineprofile_p.h
index 64e9500b0..60fa4632f 100644
--- a/src/webenginewidgets/api/qwebengineprofile_p.h
+++ b/src/webenginewidgets/api/qwebengineprofile_p.h
@@ -99,7 +99,7 @@ private:
QWebEngineSettings *m_settings;
QPointer<QtWebEngineCore::ProfileAdapter> m_profileAdapter;
QScopedPointer<QWebEngineScriptCollection> m_scriptCollection;
- QMap<quint32, QPointer<QWebEngineDownloadItem> > m_ongoingDownloads;
+ QMap<quint32, QPointer<QWebEngineDownloadRequest> > m_ongoingDownloads;
std::function<void(std::unique_ptr<QWebEngineNotification>)> m_notificationPresenter;
};
diff --git a/src/webenginewidgets/api/qwebengineview.cpp b/src/webenginewidgets/api/qwebengineview.cpp
index b06d99478..203682c79 100644
--- a/src/webenginewidgets/api/qwebengineview.cpp
+++ b/src/webenginewidgets/api/qwebengineview.cpp
@@ -125,6 +125,38 @@ void QWebEngineViewPrivate::widgetChanged(QtWebEngineCore::RenderWidgetHostViewQ
}
}
+void QWebEngineViewPrivate::contextMenuRequested(QWebEngineContextMenuRequest *request)
+{
+#if QT_CONFIG(action)
+ m_contextRequest = request;
+ switch (q_ptr->contextMenuPolicy()) {
+ case Qt::DefaultContextMenu: {
+ QContextMenuEvent event(QContextMenuEvent::Mouse, request->position(),
+ q_ptr->mapToGlobal(request->position()));
+ q_ptr->contextMenuEvent(&event);
+ return;
+ }
+ case Qt::CustomContextMenu:
+ Q_EMIT q_ptr->customContextMenuRequested(request->position());
+ return;
+ case Qt::ActionsContextMenu:
+ if (q_ptr->actions().count()) {
+ QContextMenuEvent event(QContextMenuEvent::Mouse, request->position(),
+ q_ptr->mapToGlobal(request->position()));
+ QMenu::exec(q_ptr->actions(), event.globalPos(), 0, q_ptr);
+ }
+ return;
+ case Qt::PreventContextMenu:
+ case Qt::NoContextMenu:
+ return;
+ }
+
+ Q_UNREACHABLE();
+#else
+ Q_UNUSED(data);
+#endif // QT_CONFIG(action)
+}
+
#ifndef QT_NO_ACCESSIBILITY
static QAccessibleInterface *webAccessibleFactory(const QString &, QObject *object)
{
@@ -135,9 +167,7 @@ static QAccessibleInterface *webAccessibleFactory(const QString &, QObject *obje
#endif // QT_NO_ACCESSIBILITY
QWebEngineViewPrivate::QWebEngineViewPrivate()
- : page(0)
- , m_dragEntered(false)
- , m_ownsPage(false)
+ : page(0), m_dragEntered(false), m_ownsPage(false), m_contextRequest(nullptr)
{
#ifndef QT_NO_ACCESSIBILITY
QAccessible::installFactory(&webAccessibleFactory);
@@ -326,7 +356,7 @@ void QWebEngineView::reload()
QWebEngineView *QWebEngineView::createWindow(QWebEnginePage::WebWindowType type)
{
- Q_UNUSED(type)
+ Q_UNUSED(type);
return 0;
}
@@ -378,7 +408,7 @@ bool QWebEngineView::event(QEvent *ev)
#if QT_CONFIG(contextmenu)
void QWebEngineView::contextMenuEvent(QContextMenuEvent *event)
{
- QMenu *menu = page()->createStandardContextMenu();
+ QMenu *menu = createStandardContextMenu();
menu->popup(event->globalPos());
}
#endif // QT_CONFIG(contextmenu)
@@ -421,7 +451,7 @@ void QWebEngineView::dragEnterEvent(QDragEnterEvent *e)
e->accept();
if (d->m_dragEntered)
d->page->d_ptr->adapter->leaveDrag();
- d->page->d_ptr->adapter->enterDrag(e, mapToGlobal(e->pos()));
+ d->page->d_ptr->adapter->enterDrag(e, mapToGlobal(e->position().toPoint()));
d->m_dragEntered = true;
}
@@ -447,7 +477,8 @@ void QWebEngineView::dragMoveEvent(QDragMoveEvent *e)
if (!d->m_dragEntered)
return;
QtWebEngineCore::WebContentsAdapter *adapter = d->page->d_ptr->adapter.data();
- Qt::DropAction dropAction = adapter->updateDragPosition(e, mapToGlobal(e->pos()));
+ Qt::DropAction dropAction =
+ adapter->updateDragPosition(e, mapToGlobal(e->position().toPoint()));
if (Qt::IgnoreAction == dropAction) {
e->ignore();
} else {
@@ -465,11 +496,40 @@ void QWebEngineView::dropEvent(QDropEvent *e)
if (!d->m_dragEntered)
return;
e->accept();
- d->page->d_ptr->adapter->endDragging(e, mapToGlobal(e->pos()));
+ d->page->d_ptr->adapter->endDragging(e, mapToGlobal(e->position().toPoint()));
d->m_dragEntered = false;
}
#endif // QT_CONFIG(draganddrop)
+#if QT_CONFIG(menu)
+QMenu *QWebEngineView::createStandardContextMenu()
+{
+ Q_D(QWebEngineView);
+ QMenu *menu = new QMenu(this);
+ QContextMenuBuilder contextMenuBuilder(d->m_contextRequest, this, menu);
+
+ contextMenuBuilder.initMenu();
+
+ menu->setAttribute(Qt::WA_DeleteOnClose, true);
+
+ return menu;
+}
+#endif // QT_CONFIG(menu)
+
+/*!
+ \since 6.0
+
+ Returns additional data about the current context menu. It is only guaranteed to be valid during
+ the call to the contextMenuEvent()
+
+ \sa createStandardContextMenu()
+*/
+QWebEngineContextMenuRequest *QWebEngineView::lastContextMenuRequest() const
+{
+ Q_D(const QWebEngineView);
+ return d->m_contextRequest;
+}
+
#ifndef QT_NO_ACCESSIBILITY
bool QWebEngineViewAccessible::isValid() const
{
@@ -509,6 +569,174 @@ int QWebEngineViewAccessible::indexOfChild(const QAccessibleInterface *c) const
}
#endif // QT_NO_ACCESSIBILITY
+#if QT_CONFIG(action)
+QContextMenuBuilder::QContextMenuBuilder(QWebEngineContextMenuRequest *request,
+ QWebEngineView *view, QMenu *menu)
+ : QtWebEngineCore::RenderViewContextMenuQt(request), m_view(view), m_menu(menu)
+{
+ m_view->page()->d_ptr->ensureInitialized();
+}
+
+bool QContextMenuBuilder::hasInspector()
+{
+ return m_view->page()->d_ptr->adapter->hasInspector();
+}
+
+bool QContextMenuBuilder::isFullScreenMode()
+{
+ return m_view->page()->d_ptr->isFullScreenMode();
+}
+
+void QContextMenuBuilder::addMenuItem(ContextMenuItem menuItem)
+{
+ QPointer<QWebEnginePage> thisRef(m_view->page());
+ QAction *action = 0;
+
+ switch (menuItem) {
+ case ContextMenuItem::Back:
+ action = thisRef->action(QWebEnginePage::Back);
+ break;
+ case ContextMenuItem::Forward:
+ action = thisRef->action(QWebEnginePage::Forward);
+ break;
+ case ContextMenuItem::Reload:
+ action = thisRef->action(QWebEnginePage::Reload);
+ break;
+ case ContextMenuItem::Cut:
+ action = thisRef->action(QWebEnginePage::Cut);
+ break;
+ case ContextMenuItem::Copy:
+ action = thisRef->action(QWebEnginePage::Copy);
+ break;
+ case ContextMenuItem::Paste:
+ action = thisRef->action(QWebEnginePage::Paste);
+ break;
+ case ContextMenuItem::Undo:
+ action = thisRef->action(QWebEnginePage::Undo);
+ break;
+ case ContextMenuItem::Redo:
+ action = thisRef->action(QWebEnginePage::Redo);
+ break;
+ case ContextMenuItem::SelectAll:
+ action = thisRef->action(QWebEnginePage::SelectAll);
+ break;
+ case ContextMenuItem::PasteAndMatchStyle:
+ action = thisRef->action(QWebEnginePage::PasteAndMatchStyle);
+ break;
+ case ContextMenuItem::OpenLinkInNewWindow:
+ action = thisRef->action(QWebEnginePage::OpenLinkInNewWindow);
+ break;
+ case ContextMenuItem::OpenLinkInNewTab:
+ action = thisRef->action(QWebEnginePage::OpenLinkInNewTab);
+ break;
+ case ContextMenuItem::CopyLinkToClipboard:
+ action = thisRef->action(QWebEnginePage::CopyLinkToClipboard);
+ break;
+ case ContextMenuItem::DownloadLinkToDisk:
+ action = thisRef->action(QWebEnginePage::DownloadLinkToDisk);
+ break;
+ case ContextMenuItem::CopyImageToClipboard:
+ action = thisRef->action(QWebEnginePage::CopyImageToClipboard);
+ break;
+ case ContextMenuItem::CopyImageUrlToClipboard:
+ action = thisRef->action(QWebEnginePage::CopyImageUrlToClipboard);
+ break;
+ case ContextMenuItem::DownloadImageToDisk:
+ action = thisRef->action(QWebEnginePage::DownloadImageToDisk);
+ break;
+ case ContextMenuItem::CopyMediaUrlToClipboard:
+ action = thisRef->action(QWebEnginePage::CopyMediaUrlToClipboard);
+ break;
+ case ContextMenuItem::ToggleMediaControls:
+ action = thisRef->action(QWebEnginePage::ToggleMediaControls);
+ break;
+ case ContextMenuItem::ToggleMediaLoop:
+ action = thisRef->action(QWebEnginePage::ToggleMediaLoop);
+ break;
+ case ContextMenuItem::DownloadMediaToDisk:
+ action = thisRef->action(QWebEnginePage::DownloadMediaToDisk);
+ break;
+ case ContextMenuItem::InspectElement:
+ action = thisRef->action(QWebEnginePage::InspectElement);
+ break;
+ case ContextMenuItem::ExitFullScreen:
+ action = thisRef->action(QWebEnginePage::ExitFullScreen);
+ break;
+ case ContextMenuItem::SavePage:
+ action = thisRef->action(QWebEnginePage::SavePage);
+ break;
+ case ContextMenuItem::ViewSource:
+ action = thisRef->action(QWebEnginePage::ViewSource);
+ break;
+ case ContextMenuItem::SpellingSuggestions:
+ for (int i = 0; i < m_contextData->spellCheckerSuggestions().count() && i < 4; i++) {
+ action = new QAction(m_menu);
+ QString replacement = m_contextData->spellCheckerSuggestions().at(i);
+ QObject::connect(action, &QAction::triggered, [thisRef, replacement] {
+ if (thisRef)
+ thisRef->replaceMisspelledWord(replacement);
+ });
+ action->setText(replacement);
+ m_menu->addAction(action);
+ }
+ return;
+ case ContextMenuItem::Separator:
+ if (!m_menu->isEmpty())
+ m_menu->addSeparator();
+ return;
+ }
+ action->setEnabled(isMenuItemEnabled(menuItem));
+ m_menu->addAction(action);
+}
+
+bool QContextMenuBuilder::isMenuItemEnabled(ContextMenuItem menuItem)
+{
+ switch (menuItem) {
+ case ContextMenuItem::Back:
+ return m_view->page()->d_ptr->adapter->canGoBack();
+ case ContextMenuItem::Forward:
+ return m_view->page()->d_ptr->adapter->canGoForward();
+ case ContextMenuItem::Reload:
+ return true;
+ case ContextMenuItem::Cut:
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanCut;
+ case ContextMenuItem::Copy:
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanCopy;
+ case ContextMenuItem::Paste:
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanPaste;
+ case ContextMenuItem::Undo:
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanUndo;
+ case ContextMenuItem::Redo:
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanRedo;
+ case ContextMenuItem::SelectAll:
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanSelectAll;
+ case ContextMenuItem::PasteAndMatchStyle:
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanPaste;
+ case ContextMenuItem::OpenLinkInNewWindow:
+ case ContextMenuItem::OpenLinkInNewTab:
+ case ContextMenuItem::CopyLinkToClipboard:
+ case ContextMenuItem::DownloadLinkToDisk:
+ case ContextMenuItem::CopyImageToClipboard:
+ case ContextMenuItem::CopyImageUrlToClipboard:
+ case ContextMenuItem::DownloadImageToDisk:
+ case ContextMenuItem::CopyMediaUrlToClipboard:
+ case ContextMenuItem::ToggleMediaControls:
+ case ContextMenuItem::ToggleMediaLoop:
+ case ContextMenuItem::DownloadMediaToDisk:
+ case ContextMenuItem::InspectElement:
+ case ContextMenuItem::ExitFullScreen:
+ case ContextMenuItem::SavePage:
+ return true;
+ case ContextMenuItem::ViewSource:
+ return m_view->page()->d_ptr->adapter->canViewSource();
+ case ContextMenuItem::SpellingSuggestions:
+ case ContextMenuItem::Separator:
+ return true;
+ }
+ Q_UNREACHABLE();
+}
+#endif // QT_CONFIG(action)
+
QT_END_NAMESPACE
#include "moc_qwebengineview.cpp"
diff --git a/src/webenginewidgets/api/qwebengineview.h b/src/webenginewidgets/api/qwebengineview.h
index 04c8ece74..06fbc5ddf 100644
--- a/src/webenginewidgets/api/qwebengineview.h
+++ b/src/webenginewidgets/api/qwebengineview.h
@@ -47,6 +47,7 @@
#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
#include <QtWebEngineWidgets/qwebenginepage.h>
#include <QtWebEngineCore/qwebenginehttprequest.h>
+#include <QtWebEngineCore/qwebenginecontextmenurequest.h>
QT_BEGIN_NAMESPACE
class QContextMenuEvent;
@@ -101,6 +102,11 @@ public:
QSize sizeHint() const override;
QWebEngineSettings *settings() const;
+#if QT_CONFIG(menu)
+ QMenu *createStandardContextMenu();
+#endif
+ QWebEngineContextMenuRequest *lastContextMenuRequest() const;
+
public Q_SLOTS:
void stop();
void back();
diff --git a/src/webenginewidgets/api/qwebengineview_p.h b/src/webenginewidgets/api/qwebengineview_p.h
index a3c619cea..29e39d081 100644
--- a/src/webenginewidgets/api/qwebengineview_p.h
+++ b/src/webenginewidgets/api/qwebengineview_p.h
@@ -52,7 +52,8 @@
//
#include <QtWebEngineWidgets/qwebengineview.h>
-
+#include "qwebenginecontextmenurequest.h"
+#include "render_view_context_menu_qt.h"
#include <QtWidgets/qaccessiblewidget.h>
namespace QtWebEngineCore {
@@ -72,12 +73,14 @@ public:
void pageChanged(QWebEnginePage *oldPage, QWebEnginePage *newPage);
void widgetChanged(QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *oldWidget,
QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *newWidget);
+ void contextMenuRequested(QWebEngineContextMenuRequest *request);
QWebEngineViewPrivate();
QWebEnginePage *page;
bool m_dragEntered;
mutable bool m_ownsPage;
+ QWebEngineContextMenuRequest *m_contextRequest;
};
#ifndef QT_NO_ACCESSIBILITY
@@ -98,6 +101,22 @@ private:
};
#endif // QT_NO_ACCESSIBILITY
+class QContextMenuBuilder : public QtWebEngineCore::RenderViewContextMenuQt
+{
+public:
+ QContextMenuBuilder(QWebEngineContextMenuRequest *reqeust, QWebEngineView *view, QMenu *menu);
+
+private:
+ virtual bool hasInspector() override;
+ virtual bool isFullScreenMode() override;
+
+ virtual void addMenuItem(ContextMenuItem entry) override;
+ virtual bool isMenuItemEnabled(ContextMenuItem entry) override;
+
+ QWebEngineView *m_view;
+ QMenu *m_menu;
+};
+
QT_END_NAMESPACE
#endif // QWEBENGINEVIEW_P_H
diff --git a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
index 789d9794e..5def0d65c 100644
--- a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
@@ -513,16 +513,13 @@
*/
/*!
- \fn bool QWebEnginePage::certificateError(const QWebEngineCertificateError & certificateError)
+ \fn void QWebEnginePage::certificateError(const QWebEngineCertificateError & certificateError)
This function is called when an invalid certificate error is raised while loading a given request.
- The \a certificateError parameter contains information about the certificate and details of the error.
-
- Return \c true to ignore the error and complete the request. Return \c false to stop loading
+ The \a certificateError parameter contains information about the certificate and details of the error,
+ it also provides the way to ignore the error and complete the request or stop loading
the request.
- \note If the error was successfully deferred then the returned value will be ignored.
-
\sa QWebEngineCertificateError
*/
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
index 1dfcc4c5a..0fd425580 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -39,6 +39,8 @@
#include "render_widget_host_view_qt_delegate_widget.h"
+#include "render_widget_host_view_qt_delegate_client.h"
+
#include "qwebenginepage_p.h"
#include "qwebengineview.h"
#include "qwebengineview_p.h"
@@ -47,21 +49,26 @@
#include <QMouseEvent>
#include <QOpenGLContext>
#include <QResizeEvent>
-#include <QSGAbstractRenderer>
#include <QSGNode>
#include <QWindow>
+#include <QtQuick/qsgimagenode.h>
#include <QtQuick/private/qquickwindow_p.h>
namespace QtWebEngineCore {
-class RenderWidgetHostViewQuickItem : public QQuickItem {
+class RenderWidgetHostViewQuickItem : public QQuickItem, public Compositor::Observer
+{
public:
RenderWidgetHostViewQuickItem(RenderWidgetHostViewQtDelegateClient *client) : m_client(client)
{
setFlag(ItemHasContents, true);
// Mark that this item should receive focus when the parent QQuickWidget receives focus.
setFocus(true);
+
+ bind(client->compositorId());
}
+ ~RenderWidgetHostViewQuickItem() { unbind(); }
+
protected:
bool event(QEvent *event) override
{
@@ -82,17 +89,77 @@ protected:
{
m_client->forwardEvent(event);
}
- QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override
+ void itemChange(ItemChange change, const ItemChangeData &value) override
{
- return m_client->updatePaintNode(oldNode);
+ QQuickItem::itemChange(change, value);
+ if (change == QQuickItem::ItemSceneChange) {
+ for (const QMetaObject::Connection &c : qAsConst(m_windowConnections))
+ disconnect(c);
+ m_windowConnections.clear();
+ if (value.window) {
+ m_windowConnections.append(connect(
+ value.window, &QQuickWindow::beforeRendering, this,
+ &RenderWidgetHostViewQuickItem::onBeforeRendering, Qt::DirectConnection));
+ }
+ }
}
+ QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override
+ {
+ auto comp = compositor();
+ if (!comp)
+ return nullptr;
+
+ QQuickWindow *win = QQuickItem::window();
+
+ // Delete old node before swapFrame to decrement refcount of
+ // QImage in software mode.
+ delete oldNode;
+ QSGImageNode *node = win->createImageNode();
+ node->setOwnsTexture(true);
+
+ comp->swapFrame();
+
+ QSize texSize = comp->size();
+ QSizeF texSizeInDips = QSizeF(texSize) / comp->devicePixelRatio();
+ node->setRect(QRectF(QPointF(0, 0), texSizeInDips));
+
+ if (comp->type() == Compositor::Type::Software) {
+ QImage image = comp->image();
+ node->setTexture(win->createTextureFromImage(image));
+ } else if (comp->type() == Compositor::Type::OpenGL) {
+ QQuickWindow::CreateTextureOptions texOpts;
+ if (comp->hasAlphaChannel())
+ texOpts.setFlag(QQuickWindow::TextureHasAlphaChannel);
+ int texId = comp->textureId();
+ node->setTexture(win->createTextureFromNativeObject(QQuickWindow::NativeObjectTexture,
+ texId, 0, texSize, texOpts));
+ node->setTextureCoordinatesTransform(QSGImageNode::MirrorVertically);
+ } else {
+ Q_UNREACHABLE();
+ }
+ return node;
+ }
+ void onBeforeRendering()
+ {
+ auto comp = compositor();
+ if (!comp || comp->type() != Compositor::Type::OpenGL)
+ return;
+ comp->waitForTexture();
+ }
QVariant inputMethodQuery(Qt::InputMethodQuery query) const override
{
return m_client->inputMethodQuery(query);
}
+ void readyToSwap() override
+ {
+ // Call update() on UI thread.
+ QMetaObject::invokeMethod(this, &QQuickItem::update, Qt::QueuedConnection);
+ }
+
private:
RenderWidgetHostViewQtDelegateClient *m_client;
+ QList<QMetaObject::Connection> m_windowConnections;
};
RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(RenderWidgetHostViewQtDelegateClient *client, QWidget *parent)
@@ -102,62 +169,6 @@ RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(Rende
, m_isPopup(false)
{
setFocusPolicy(Qt::StrongFocus);
-
- QSurfaceFormat format;
- format.setDepthBufferSize(24);
- format.setStencilBufferSize(8);
-
-#if QT_CONFIG(opengl)
- QOpenGLContext *globalSharedContext = QOpenGLContext::globalShareContext();
- if (globalSharedContext) {
- QSurfaceFormat sharedFormat = globalSharedContext->format();
-
-#ifdef Q_OS_OSX
- // Check that the default QSurfaceFormat OpenGL profile is compatible with the global OpenGL
- // shared context profile, otherwise this could lead to a nasty crash.
- QSurfaceFormat defaultFormat = QSurfaceFormat::defaultFormat();
-
- if (defaultFormat.profile() != sharedFormat.profile()
- && defaultFormat.profile() == QSurfaceFormat::CoreProfile
- && defaultFormat.version() >= qMakePair(3, 2)) {
- qFatal("QWebEngine: Default QSurfaceFormat OpenGL profile is not compatible with the "
- "global shared context OpenGL profile. Please make sure you set a compatible "
- "QSurfaceFormat before the QtGui application instance is created.");
- }
-#endif
- int major;
- int minor;
- QSurfaceFormat::OpenGLContextProfile profile;
-#ifdef Q_OS_MACOS
- // Due to QTBUG-63180, requesting the sharedFormat.majorVersion() on macOS will lead to
- // a failed creation of QQuickWidget shared context. Thus make sure to request the
- // major version specified in the defaultFormat instead.
- major = defaultFormat.majorVersion();
- minor = defaultFormat.minorVersion();
- profile = defaultFormat.profile();
-#else
- major = sharedFormat.majorVersion();
- minor = sharedFormat.minorVersion();
- profile = sharedFormat.profile();
-#endif
-
- // Make sure the OpenGL profile of the QQuickWidget matches the shared context profile.
- // It covers the following cases:
- // 1) Desktop OpenGL Core Profile.
- // 2) Windows ANGLE OpenGL ES profile.
- if (sharedFormat.profile() == QSurfaceFormat::CoreProfile
-#ifdef Q_OS_WIN
- || globalSharedContext->isOpenGLES()
-#endif
- ) {
- format.setMajorVersion(major);
- format.setMinorVersion(minor);
- format.setProfile(profile);
- }
- }
-
- setFormat(format);
-#endif
setMouseTracking(true);
setAttribute(Qt::WA_AcceptTouchEvents);
setAttribute(Qt::WA_OpaquePaintEvent);
@@ -291,32 +302,6 @@ QWindow* RenderWidgetHostViewQtDelegateWidget::window() const
return root ? root->windowHandle() : 0;
}
-QSGTexture *RenderWidgetHostViewQtDelegateWidget::createTextureFromImage(const QImage &image)
-{
- return quickWindow()->createTextureFromImage(image, QQuickWindow::TextureCanUseAtlas);
-}
-
-QSGLayer *RenderWidgetHostViewQtDelegateWidget::createLayer()
-{
- QSGRenderContext *renderContext = QQuickWindowPrivate::get(quickWindow())->context;
- return renderContext->sceneGraphContext()->createLayer(renderContext);
-}
-
-QSGImageNode *RenderWidgetHostViewQtDelegateWidget::createImageNode()
-{
- return quickWindow()->createImageNode();
-}
-
-QSGRectangleNode *RenderWidgetHostViewQtDelegateWidget::createRectangleNode()
-{
- return quickWindow()->createRectangleNode();
-}
-
-void RenderWidgetHostViewQtDelegateWidget::update()
-{
- m_rootItem->update();
-}
-
void RenderWidgetHostViewQtDelegateWidget::updateCursor(const QCursor &cursor)
{
QQuickWidget::setCursor(cursor);
@@ -393,15 +378,6 @@ void RenderWidgetHostViewQtDelegateWidget::hideEvent(QHideEvent *event)
m_client->notifyHidden();
}
-bool RenderWidgetHostViewQtDelegateWidget::copySurface(const QRect &rect, const QSize &size, QImage &image)
-{
- QPixmap pixmap = rect.isEmpty() ? QQuickWidget::grab(QQuickWidget::rect()) : QQuickWidget::grab(rect);
- if (pixmap.isNull())
- return false;
- image = pixmap.toImage().scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
- return true;
-}
-
bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event)
{
bool handled = false;
@@ -465,8 +441,9 @@ bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event)
// QtQuick is different by sending both the Press and DblClick events for the second press
// where we can simply ignore the DblClick event.
QMouseEvent *dblClick = static_cast<QMouseEvent *>(event);
- QMouseEvent press(QEvent::MouseButtonPress, dblClick->localPos(), dblClick->windowPos(), dblClick->screenPos(),
- dblClick->button(), dblClick->buttons(), dblClick->modifiers(), dblClick->source());
+ QMouseEvent press(QEvent::MouseButtonPress, dblClick->position(), dblClick->scenePosition(),
+ dblClick->globalPosition(), dblClick->button(), dblClick->buttons(),
+ dblClick->modifiers(), dblClick->source());
press.setTimestamp(dblClick->timestamp());
handled = m_client->forwardEvent(&press);
} else
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
index 034fdd65c..0dd5f1cc3 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
@@ -79,18 +79,12 @@ public:
void hide() override;
bool isVisible() const override;
QWindow* window() const override;
- QSGTexture *createTextureFromImage(const QImage &) override;
- QSGLayer *createLayer() override;
- QSGImageNode *createImageNode() override;
- QSGRectangleNode *createRectangleNode() override;
- void update() override;
void updateCursor(const QCursor &) override;
void resize(int width, int height) override;
void move(const QPoint &screenPos) override;
void inputMethodStateChanged(bool editorVisible, bool passwordInput) override;
void setInputMethodHints(Qt::InputMethodHints) override;
void setClearColor(const QColor &color) override;
- bool copySurface(const QRect &, const QSize &, QImage &) override;
void unhandledWheelEvent(QWheelEvent *ev) override;
protected:
diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro
index d4fb40dc7..697f97493 100644
--- a/src/webenginewidgets/webenginewidgets.pro
+++ b/src/webenginewidgets/webenginewidgets.pro
@@ -13,10 +13,7 @@ INCLUDEPATH += $$PWD api ../core ../core/api ../webengine/api
SOURCES = \
api/qtwebenginewidgetsglobal.cpp \
- api/qwebenginecertificateerror.cpp \
api/qwebengineclientcertificateselection.cpp \
- api/qwebenginecontextmenudata.cpp \
- api/qwebenginedownloaditem.cpp \
api/qwebenginefullscreenrequest.cpp \
api/qwebenginehistory.cpp \
api/qwebenginenotificationpresenter.cpp \
@@ -30,11 +27,7 @@ SOURCES = \
HEADERS = \
api/qtwebenginewidgetsglobal.h \
- api/qwebenginecertificateerror.h \
api/qwebengineclientcertificateselection.h \
- api/qwebenginecontextmenudata.h \
- api/qwebenginedownloaditem.h \
- api/qwebenginedownloaditem_p.h \
api/qwebenginefullscreenrequest.h \
api/qwebenginehistory.h \
api/qwebenginenotificationpresenter_p.h \