summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
m---------src/3rdparty0
-rw-r--r--src/buildtools/configure.json11
-rw-r--r--src/buildtools/gn.pro4
-rw-r--r--src/core/accessibility_tree_formatter_qt.cpp49
-rw-r--r--src/core/api/core_api.pro47
-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.cpp179
-rw-r--r--src/core/api/qtwebenginecoreglobal.h3
-rw-r--r--src/core/api/qwebenginecallback_p.h2
-rw-r--r--src/core/api/qwebenginecertificateerror.cpp (renamed from src/webenginewidgets/api/qwebenginecertificateerror.cpp)118
-rw-r--r--src/core/api/qwebenginecertificateerror.h (renamed from src/webenginewidgets/api/qwebenginecertificateerror.h)51
-rw-r--r--src/core/api/qwebengineclientcertificateselection.cpp (renamed from src/webenginewidgets/api/qwebengineclientcertificateselection.cpp)11
-rw-r--r--src/core/api/qwebengineclientcertificateselection.h (renamed from src/webenginewidgets/api/qwebengineclientcertificateselection.h)23
-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)79
-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)424
-rw-r--r--src/core/api/qwebenginedownloadrequest.h (renamed from src/webengine/api/qquickwebenginedownloaditem_p.h)142
-rw-r--r--src/core/api/qwebenginedownloadrequest_p.h (renamed from src/webenginewidgets/api/qwebenginedownloaditem_p.h)50
-rw-r--r--src/core/api/qwebenginefullscreenrequest.cpp (renamed from src/webenginewidgets/api/qwebenginefullscreenrequest.cpp)71
-rw-r--r--src/core/api/qwebenginefullscreenrequest.h (renamed from src/webenginewidgets/api/qwebenginefullscreenrequest.h)32
-rw-r--r--src/core/api/qwebenginehistory.cpp (renamed from src/webenginewidgets/api/qwebenginehistory.cpp)102
-rw-r--r--src/core/api/qwebenginehistory.h (renamed from src/webenginewidgets/api/qwebenginehistory.h)15
-rw-r--r--src/core/api/qwebenginehistory_p.h (renamed from src/webenginewidgets/api/qwebenginehistory_p.h)18
-rw-r--r--src/core/api/qwebenginehttprequest.cpp10
-rw-r--r--src/core/api/qwebenginehttprequest.h6
-rw-r--r--src/core/api/qwebengineloadrequest.cpp192
-rw-r--r--src/core/api/qwebengineloadrequest.h (renamed from src/webengine/api/qquickwebengineloadrequest_p.h)75
-rw-r--r--src/core/api/qwebenginepage.cpp (renamed from src/webenginewidgets/api/qwebenginepage.cpp)788
-rw-r--r--src/core/api/qwebenginepage.h (renamed from src/webenginewidgets/api/qwebenginepage.h)39
-rw-r--r--src/core/api/qwebenginepage_p.h (renamed from src/webenginewidgets/api/qwebenginepage_p.h)76
-rw-r--r--src/core/api/qwebengineprofile.cpp (renamed from src/webenginewidgets/api/qwebengineprofile.cpp)91
-rw-r--r--src/core/api/qwebengineprofile.h (renamed from src/webenginewidgets/api/qwebengineprofile.h)11
-rw-r--r--src/core/api/qwebengineprofile_p.h (renamed from src/webenginewidgets/api/qwebengineprofile_p.h)4
-rw-r--r--src/core/api/qwebenginescript.cpp (renamed from src/webenginewidgets/api/qwebenginescript.cpp)49
-rw-r--r--src/core/api/qwebenginescript.h (renamed from src/webenginewidgets/api/qwebenginescript.h)35
-rw-r--r--src/core/api/qwebenginescriptcollection.cpp (renamed from src/webenginewidgets/api/qwebenginescriptcollection.cpp)29
-rw-r--r--src/core/api/qwebenginescriptcollection.h (renamed from src/webenginewidgets/api/qwebenginescriptcollection.h)19
-rw-r--r--src/core/api/qwebenginescriptcollection_p.h (renamed from src/webenginewidgets/api/qwebenginescriptcollection_p.h)11
-rw-r--r--src/core/api/qwebenginesettings.cpp142
-rw-r--r--src/core/api/qwebenginesettings.h (renamed from src/webenginewidgets/api/qwebenginesettings.h)26
-rw-r--r--src/core/api/qwebengineurlrequestinfo.cpp2
-rw-r--r--src/core/browser_accessibility_manager_qt.cpp2
-rw-r--r--src/core/browser_accessibility_manager_qt.h4
-rw-r--r--src/core/browser_accessibility_qt.cpp8
-rw-r--r--src/core/browser_message_filter_qt.cpp5
-rw-r--r--src/core/certificate_error_controller.cpp201
-rw-r--r--src/core/certificate_error_controller.h89
-rw-r--r--src/core/chromium_overrides.cpp3
-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/clipboard_qt.cpp29
-rw-r--r--src/core/clipboard_qt.h28
-rw-r--r--src/core/compositor/compositor.cpp197
-rw-r--r--src/core/compositor/compositor.h195
-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.cpp64
-rw-r--r--src/core/compositor/display_gl_output_surface.h20
-rw-r--r--src/core/compositor/display_gl_output_surface_qsg.cpp122
-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/content_browser_client_qt.cpp208
-rw-r--r--src/core/content_browser_client_qt.h20
-rw-r--r--src/core/content_client_qt.cpp97
-rw-r--r--src/core/content_main_delegate_qt.cpp4
-rw-r--r--src/core/content_utility_client_qt.cpp7
-rw-r--r--src/core/content_utility_client_qt.h2
-rw-r--r--src/core/core_chromium.pri19
-rw-r--r--src/core/core_common.pri5
-rw-r--r--src/core/doc/src/qwebenginesettings_lgpl.qdoc (renamed from src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc)11
-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/extensions/mime_handler_view_guest_delegate_qt.cpp9
-rw-r--r--src/core/extensions/mime_handler_view_guest_delegate_qt.h5
-rw-r--r--src/core/extensions/plugin_service_filter_qt.cpp4
-rw-r--r--src/core/favicon_manager.cpp10
-rw-r--r--src/core/file_picker_controller.cpp2
-rw-r--r--src/core/gn_run.pro6
-rw-r--r--src/core/location_provider_qt.cpp4
-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/media_capture_devices_dispatcher.cpp38
-rw-r--r--src/core/native_web_keyboard_event_qt.cpp6
-rw-r--r--src/core/net/client_cert_override.cpp1
-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/net/plugin_response_interceptor_url_loader_throttle.cpp4
-rw-r--r--src/core/net/proxying_url_loader_factory_qt.cpp37
-rw-r--r--src/core/ozone/gl_context_qt.cpp22
-rw-r--r--src/core/ozone/gl_context_qt.h2
-rw-r--r--src/core/ozone/gl_ozone_egl_qt.cpp6
-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/webengine/api/qquickwebenginescript_p.h)86
-rw-r--r--src/core/ozone/gl_surface_glx_qt.cpp30
-rw-r--r--src/core/ozone/gl_surface_glx_qt.h4
-rw-r--r--src/core/ozone/gl_surface_qt.cpp35
-rw-r--r--src/core/ozone/platform_window_qt.cpp2
-rw-r--r--src/core/ozone/platform_window_qt.h2
-rw-r--r--src/core/ozone/surface_factory_qt.cpp10
-rw-r--r--src/core/ozone/surface_factory_qt.h2
-rw-r--r--src/core/permission_manager_qt.cpp16
-rw-r--r--src/core/pref_service_adapter.h6
-rw-r--r--src/core/printing/print_view_manager_base_qt.cpp81
-rw-r--r--src/core/printing/print_view_manager_base_qt.h2
-rw-r--r--src/core/printing/printer_worker.cpp (renamed from src/webenginewidgets/printer_worker.cpp)24
-rw-r--r--src/core/printing/printer_worker.h (renamed from src/webenginewidgets/printer_worker.h)4
-rw-r--r--src/core/printing/printing_message_filter_qt.cpp58
-rw-r--r--src/core/printing/printing_message_filter_qt.h12
-rw-r--r--src/core/profile_adapter.cpp4
-rw-r--r--src/core/profile_adapter.h3
-rw-r--r--src/core/profile_adapter_client.h9
-rw-r--r--src/core/profile_qt.h3
-rw-r--r--src/core/qtwebengine_resources.gni2
-rw-r--r--src/core/qtwebengine_sources.gni13
-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.cpp1050
-rw-r--r--src/core/render_widget_host_view_qt.h181
-rw-r--r--src/core/render_widget_host_view_qt_delegate.h33
-rw-r--r--src/core/render_widget_host_view_qt_delegate_client.cpp1016
-rw-r--r--src/core/render_widget_host_view_qt_delegate_client.h168
-rw-r--r--src/core/renderer/content_renderer_client_qt.cpp29
-rw-r--r--src/core/renderer/content_renderer_client_qt.h7
-rw-r--r--src/core/renderer/pepper/pepper_flash_renderer_host_qt.cpp432
-rw-r--r--src/core/renderer/pepper/pepper_flash_renderer_host_qt.h107
-rw-r--r--src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp23
-rw-r--r--src/core/renderer/user_resource_controller.cpp9
-rw-r--r--src/core/renderer/user_resource_controller.h2
-rw-r--r--src/core/renderer/web_channel_ipc_transport.cpp30
-rw-r--r--src/core/renderer/web_channel_ipc_transport.h2
-rw-r--r--src/core/renderer_host/pepper/pepper_flash_browser_host_qt.cpp127
-rw-r--r--src/core/renderer_host/pepper/pepper_flash_browser_host_qt.h85
-rw-r--r--src/core/renderer_host/pepper/pepper_host_factory_qt.cpp15
-rw-r--r--src/core/renderer_host/user_resource_controller_host.cpp4
-rw-r--r--src/core/renderer_host/user_resource_controller_host.h1
-rw-r--r--src/core/renderer_host/web_channel_ipc_transport_host.cpp10
-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/user_script.cpp119
-rw-r--r--src/core/user_script.h22
-rw-r--r--src/core/visited_links_manager_qt.h4
-rw-r--r--src/core/web_contents_adapter.cpp45
-rw-r--r--src/core/web_contents_adapter.h1
-rw-r--r--src/core/web_contents_adapter_client.h294
-rw-r--r--src/core/web_contents_delegate_qt.cpp61
-rw-r--r--src/core/web_contents_delegate_qt.h11
-rw-r--r--src/core/web_contents_view_qt.cpp165
-rw-r--r--src/core/web_contents_view_qt.h15
-rw-r--r--src/core/web_engine_context.cpp305
-rw-r--r--src/core/web_engine_context.h4
-rw-r--r--src/core/web_engine_library_info.cpp14
-rw-r--r--src/core/web_engine_settings.cpp240
-rw-r--r--src/core/web_engine_settings.h117
-rw-r--r--src/core/web_event_factory.cpp30
-rw-r--r--src/pdf/api/qpdfdocument_p.h4
-rw-r--r--src/pdf/api/qpdflinkmodel_p_p.h2
-rw-r--r--src/pdf/api/qpdfpagenavigation.h2
-rw-r--r--src/pdf/api/qpdfpagerenderer.h4
-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/config/common.pri8
-rw-r--r--src/pdf/pdfcore.pro2
-rw-r--r--src/pdf/qpdfbookmarkmodel.cpp4
-rw-r--r--src/pdf/qpdfdocument.cpp50
-rw-r--r--src/pdf/qpdflinkmodel.cpp7
-rw-r--r--src/pdf/qpdfpagenavigation.cpp90
-rw-r--r--src/pdf/qpdfpagerenderer.cpp87
-rw-r--r--src/pdf/qpdfsearchmodel.cpp18
-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.h9
-rw-r--r--src/process/process.pro4
-rw-r--r--src/src.pro21
-rw-r--r--src/tools/qwebengine_convert_dict/main.cpp6
-rw-r--r--src/webengine/api/qquickwebenginecertificateerror_p.h115
-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/qquickwebengineloadrequest.cpp162
-rw-r--r--src/webengine/api/qquickwebenginescript.cpp446
-rw-r--r--src/webengine/api/qquickwebenginescript.h114
-rw-r--r--src/webenginequick/api/qquickwebengineaction.cpp (renamed from src/webengine/api/qquickwebengineaction.cpp)0
-rw-r--r--src/webenginequick/api/qquickwebengineaction_p.h (renamed from src/webengine/api/qquickwebengineaction_p.h)0
-rw-r--r--src/webenginequick/api/qquickwebengineaction_p_p.h (renamed from src/webengine/api/qquickwebengineaction_p_p.h)0
-rw-r--r--src/webenginequick/api/qquickwebengineclientcertificateselection.cpp (renamed from src/webengine/api/qquickwebengineclientcertificateselection.cpp)11
-rw-r--r--src/webenginequick/api/qquickwebengineclientcertificateselection_p.h (renamed from src/webengine/api/qquickwebengineclientcertificateselection_p.h)20
-rw-r--r--src/webenginequick/api/qquickwebenginedialogrequests.cpp (renamed from src/webengine/api/qquickwebenginedialogrequests.cpp)0
-rw-r--r--src/webenginequick/api/qquickwebenginedialogrequests_p.h (renamed from src/webengine/api/qquickwebenginedialogrequests_p.h)2
-rw-r--r--src/webenginequick/api/qquickwebenginefaviconprovider.cpp (renamed from src/webengine/api/qquickwebenginefaviconprovider.cpp)0
-rw-r--r--src/webenginequick/api/qquickwebenginefaviconprovider_p_p.h (renamed from src/webengine/api/qquickwebenginefaviconprovider_p_p.h)2
-rw-r--r--src/webenginequick/api/qquickwebenginehistory.cpp (renamed from src/webengine/api/qquickwebenginehistory.cpp)1
-rw-r--r--src/webenginequick/api/qquickwebenginehistory_p.h (renamed from src/webengine/api/qquickwebenginehistory_p.h)3
-rw-r--r--src/webenginequick/api/qquickwebenginehistory_p_p.h (renamed from src/webengine/api/qquickwebenginehistory_p_p.h)0
-rw-r--r--src/webenginequick/api/qquickwebenginenavigationrequest.cpp (renamed from src/webengine/api/qquickwebenginenavigationrequest.cpp)0
-rw-r--r--src/webenginequick/api/qquickwebenginenavigationrequest_p.h (renamed from src/webengine/api/qquickwebenginenavigationrequest_p.h)0
-rw-r--r--src/webenginequick/api/qquickwebenginenewviewrequest.cpp (renamed from src/webengine/api/qquickwebenginenewviewrequest.cpp)0
-rw-r--r--src/webenginequick/api/qquickwebenginenewviewrequest_p.h (renamed from src/webengine/api/qquickwebenginenewviewrequest_p.h)2
-rw-r--r--src/webenginequick/api/qquickwebengineprofile.cpp (renamed from src/webengine/api/qquickwebengineprofile.cpp)134
-rw-r--r--src/webenginequick/api/qquickwebengineprofile.h (renamed from src/webengine/api/qquickwebengineprofile.h)26
-rw-r--r--src/webenginequick/api/qquickwebengineprofile_p.h (renamed from src/webengine/api/qquickwebengineprofile_p.h)13
-rw-r--r--src/webenginequick/api/qquickwebenginescriptcollection.cpp157
-rw-r--r--src/webenginequick/api/qquickwebenginescriptcollection.h86
-rw-r--r--src/webenginequick/api/qquickwebenginesettings.cpp (renamed from src/webengine/api/qquickwebenginesettings.cpp)191
-rw-r--r--src/webenginequick/api/qquickwebenginesettings_p.h (renamed from src/webengine/api/qquickwebenginesettings_p.h)7
-rw-r--r--src/webenginequick/api/qquickwebenginesingleton.cpp (renamed from src/webengine/api/qquickwebenginesingleton.cpp)10
-rw-r--r--src/webenginequick/api/qquickwebenginesingleton_p.h (renamed from src/webengine/api/qquickwebenginesingleton_p.h)11
-rw-r--r--src/webenginequick/api/qquickwebenginetestsupport.cpp (renamed from src/webengine/api/qquickwebenginetestsupport.cpp)10
-rw-r--r--src/webenginequick/api/qquickwebenginetestsupport_p.h (renamed from src/webengine/api/qquickwebenginetestsupport_p.h)8
-rw-r--r--src/webenginequick/api/qquickwebenginetouchhandleprovider.cpp (renamed from src/webengine/api/qquickwebenginetouchhandleprovider.cpp)0
-rw-r--r--src/webenginequick/api/qquickwebenginetouchhandleprovider_p_p.h (renamed from src/webengine/api/qquickwebenginetouchhandleprovider_p_p.h)2
-rw-r--r--src/webenginequick/api/qquickwebengineview.cpp (renamed from src/webengine/api/qquickwebengineview.cpp)429
-rw-r--r--src/webenginequick/api/qquickwebengineview_p.h (renamed from src/webengine/api/qquickwebengineview_p.h)65
-rw-r--r--src/webenginequick/api/qquickwebengineview_p_p.h (renamed from src/webengine/api/qquickwebengineview_p_p.h)46
-rw-r--r--src/webenginequick/api/qtwebengineglobal.cpp (renamed from src/webengine/api/qtwebengineglobal.cpp)10
-rw-r--r--src/webenginequick/api/qtwebengineglobal.h (renamed from src/webengine/api/qtwebengineglobal.h)2
-rw-r--r--src/webenginequick/api/qtwebengineglobal_p.h (renamed from src/webengine/api/qtwebengineglobal_p.h)4
-rw-r--r--src/webenginequick/configure.json (renamed from src/webengine/configure.json)24
-rw-r--r--src/webenginequick/doc/QtWebEngineDoc (renamed from src/webengine/doc/QtWebEngineDoc)0
-rw-r--r--src/webenginequick/doc/images/qtwebengine-architecture.png (renamed from src/webengine/doc/images/qtwebengine-architecture.png)bin9890 -> 9890 bytes
-rw-r--r--src/webenginequick/doc/images/qtwebengine-model.png (renamed from src/webengine/doc/images/qtwebengine-model.png)bin8656 -> 8656 bytes
-rw-r--r--src/webenginequick/doc/images/qtwebengine-model.qmodel (renamed from src/webengine/doc/images/qtwebengine-model.qmodel)0
-rw-r--r--src/webenginequick/doc/images/qtwebengine-modules-model.qmodel (renamed from src/webengine/doc/images/qtwebengine-modules-model.qmodel)0
-rw-r--r--src/webenginequick/doc/images/qtwebenginewidgets-model.png (renamed from src/webengine/doc/images/qtwebenginewidgets-model.png)bin9749 -> 9749 bytes
-rw-r--r--src/webenginequick/doc/images/qtwebenginewidgets-model.qmodel (renamed from src/webengine/doc/images/qtwebenginewidgets-model.qmodel)0
-rw-r--r--src/webenginequick/doc/qtwebengine.qdocconf (renamed from src/webengine/doc/qtwebengine.qdocconf)0
-rw-r--r--src/webenginequick/doc/snippets/qtwebengine_build_snippet.qdoc (renamed from src/webengine/doc/snippets/qtwebengine_build_snippet.qdoc)0
-rw-r--r--src/webenginequick/doc/snippets/qtwebengine_webengineview_newviewrequested.qml (renamed from src/webengine/doc/snippets/qtwebengine_webengineview_newviewrequested.qml)0
-rw-r--r--src/webenginequick/doc/src/context_menu_request.qdoc218
-rw-r--r--src/webenginequick/doc/src/external-resources.qdoc (renamed from src/webengine/doc/src/external-resources.qdoc)0
-rw-r--r--src/webenginequick/doc/src/fullscreen_request.qdoc82
-rw-r--r--src/webenginequick/doc/src/load_request.qdoc86
-rw-r--r--src/webenginequick/doc/src/qtwebengine-debugging.qdoc (renamed from src/webengine/doc/src/qtwebengine-debugging.qdoc)0
-rw-r--r--src/webenginequick/doc/src/qtwebengine-deploying.qdoc (renamed from src/webengine/doc/src/qtwebengine-deploying.qdoc)0
-rw-r--r--src/webenginequick/doc/src/qtwebengine-examples.qdoc (renamed from src/webengine/doc/src/qtwebengine-examples.qdoc)0
-rw-r--r--src/webenginequick/doc/src/qtwebengine-features.qdoc (renamed from src/webengine/doc/src/qtwebengine-features.qdoc)0
-rw-r--r--src/webenginequick/doc/src/qtwebengine-index.qdoc (renamed from src/webengine/doc/src/qtwebengine-index.qdoc)0
-rw-r--r--src/webenginequick/doc/src/qtwebengine-module.qdoc (renamed from src/webengine/doc/src/qtwebengine-module.qdoc)0
-rw-r--r--src/webenginequick/doc/src/qtwebengine-modules.qdoc (renamed from src/webengine/doc/src/qtwebengine-modules.qdoc)0
-rw-r--r--src/webenginequick/doc/src/qtwebengine-overview.qdoc (renamed from src/webengine/doc/src/qtwebengine-overview.qdoc)0
-rw-r--r--src/webenginequick/doc/src/qtwebengine-platform-notes.qdoc (renamed from src/webengine/doc/src/qtwebengine-platform-notes.qdoc)0
-rw-r--r--src/webenginequick/doc/src/qtwebengine-qmlmodule.qdoc (renamed from src/webengine/doc/src/qtwebengine-qmlmodule.qdoc)0
-rw-r--r--src/webenginequick/doc/src/quota_request.qdoc74
-rw-r--r--src/webenginequick/doc/src/qwebengine-licensing.qdoc (renamed from src/webengine/doc/src/qwebengine-licensing.qdoc)0
-rw-r--r--src/webenginequick/doc/src/register_protocol_handler_request.qdoc66
-rw-r--r--src/webenginequick/doc/src/webengine_certificate_error.qdoc (renamed from src/webengine/api/qquickwebenginecertificateerror.cpp)146
-rw-r--r--src/webenginequick/doc/src/webengine_download_request.qdoc302
-rw-r--r--src/webenginequick/doc/src/webengineview_lgpl.qdoc (renamed from src/webengine/doc/src/webengineview_lgpl.qdoc)142
-rw-r--r--src/webenginequick/module.pro (renamed from src/webengine/module.pro)24
-rw-r--r--src/webenginequick/plugin/dependencies.json (renamed from src/webengine/plugin/dependencies.json)0
-rw-r--r--src/webenginequick/plugin/plugin.cpp (renamed from src/webengine/plugin/plugin.cpp)71
-rw-r--r--src/webenginequick/plugin/plugin.pro (renamed from src/webengine/plugin/plugin.pro)2
-rw-r--r--src/webenginequick/plugin/plugins.qmltypes (renamed from src/webengine/plugin/plugins.qmltypes)9
-rw-r--r--src/webenginequick/plugin/qmldir (renamed from src/webengine/plugin/qmldir)0
-rw-r--r--src/webenginequick/render_widget_host_view_qt_delegate_quick.cpp (renamed from src/webengine/render_widget_host_view_qt_delegate_quick.cpp)108
-rw-r--r--src/webenginequick/render_widget_host_view_qt_delegate_quick.h (renamed from src/webengine/render_widget_host_view_qt_delegate_quick.h)16
-rw-r--r--src/webenginequick/render_widget_host_view_qt_delegate_quickwindow.cpp (renamed from src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp)16
-rw-r--r--src/webenginequick/render_widget_host_view_qt_delegate_quickwindow.h (renamed from src/webengine/render_widget_host_view_qt_delegate_quickwindow.h)6
-rw-r--r--src/webenginequick/testsupport/plugin.cpp (renamed from src/webengine/testsupport/plugin.cpp)2
-rw-r--r--src/webenginequick/testsupport/plugins.qmltypes (renamed from src/webengine/testsupport/plugins.qmltypes)2
-rw-r--r--src/webenginequick/testsupport/qmldir (renamed from src/webengine/testsupport/qmldir)0
-rw-r--r--src/webenginequick/testsupport/testsupport.pro (renamed from src/webengine/testsupport/testsupport.pro)2
-rw-r--r--src/webenginequick/ui/AlertDialog.qml (renamed from src/webengine/ui/AlertDialog.qml)0
-rw-r--r--src/webenginequick/ui/AuthenticationDialog.qml (renamed from src/webengine/ui/AuthenticationDialog.qml)0
-rw-r--r--src/webenginequick/ui/ColorDialog.qml (renamed from src/webengine/ui/ColorDialog.qml)0
-rw-r--r--src/webenginequick/ui/ConfirmDialog.qml (renamed from src/webengine/ui/ConfirmDialog.qml)0
-rw-r--r--src/webenginequick/ui/FilePicker.qml (renamed from src/webengine/ui/FilePicker.qml)0
-rw-r--r--src/webenginequick/ui/Menu.qml (renamed from src/webengine/ui/Menu.qml)0
-rw-r--r--src/webenginequick/ui/MenuItem.qml (renamed from src/webengine/ui/MenuItem.qml)0
-rw-r--r--src/webenginequick/ui/MenuSeparator.qml (renamed from src/webengine/ui/MenuSeparator.qml)0
-rw-r--r--src/webenginequick/ui/PromptDialog.qml (renamed from src/webengine/ui/PromptDialog.qml)0
-rw-r--r--src/webenginequick/ui/ToolTip.qml (renamed from src/webengine/ui/ToolTip.qml)0
-rw-r--r--src/webenginequick/ui/TouchHandle.qml (renamed from src/webengine/ui/TouchHandle.qml)0
-rw-r--r--src/webenginequick/ui/TouchSelectionMenu.qml (renamed from src/webengine/ui/TouchSelectionMenu.qml)0
-rw-r--r--src/webenginequick/ui/qmldir (renamed from src/webengine/ui/qmldir)0
-rw-r--r--src/webenginequick/ui/ui.pro (renamed from src/webengine/ui/ui.pro)0
-rw-r--r--src/webenginequick/ui2/AlertDialog.qml (renamed from src/webengine/ui2/AlertDialog.qml)0
-rw-r--r--src/webenginequick/ui2/AuthenticationDialog.qml (renamed from src/webengine/ui2/AuthenticationDialog.qml)0
-rw-r--r--src/webenginequick/ui2/ConfirmDialog.qml (renamed from src/webengine/ui2/ConfirmDialog.qml)0
-rw-r--r--src/webenginequick/ui2/Menu.qml (renamed from src/webengine/ui2/Menu.qml)0
-rw-r--r--src/webenginequick/ui2/MenuItem.qml (renamed from src/webengine/ui2/MenuItem.qml)0
-rw-r--r--src/webenginequick/ui2/MenuSeparator.qml (renamed from src/webengine/ui2/MenuSeparator.qml)0
-rw-r--r--src/webenginequick/ui2/PromptDialog.qml (renamed from src/webengine/ui2/PromptDialog.qml)0
-rw-r--r--src/webenginequick/ui2/ToolTip.qml (renamed from src/webengine/ui2/ToolTip.qml)0
-rw-r--r--src/webenginequick/ui2/information.png (renamed from src/webengine/ui2/information.png)bin254 -> 254 bytes
-rw-r--r--src/webenginequick/ui2/qmldir (renamed from src/webengine/ui2/qmldir)0
-rw-r--r--src/webenginequick/ui2/question.png (renamed from src/webengine/ui2/question.png)bin257 -> 257 bytes
-rw-r--r--src/webenginequick/ui2/ui2.pro (renamed from src/webengine/ui2/ui2.pro)0
-rw-r--r--src/webenginequick/ui_delegates_manager.cpp (renamed from src/webengine/ui_delegates_manager.cpp)0
-rw-r--r--src/webenginequick/ui_delegates_manager.h (renamed from src/webengine/ui_delegates_manager.h)0
-rw-r--r--src/webenginequick/webenginequick.pro (renamed from src/webengine/webengine.pro)4
-rw-r--r--src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp75
-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/qwebenginesettings.cpp254
-rw-r--r--src/webenginewidgets/api/qwebengineview.cpp591
-rw-r--r--src/webenginewidgets/api/qwebengineview.h8
-rw-r--r--src/webenginewidgets/api/qwebengineview_p.h52
-rw-r--r--src/webenginewidgets/doc/snippets/simple/main.cpp2
-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.h11
-rw-r--r--src/webenginewidgets/webenginewidgets.pro33
324 files changed, 7505 insertions, 10562 deletions
diff --git a/src/3rdparty b/src/3rdparty
-Subproject 6c7b4ffb3fe19e7c6a2db60ce2d05c3b50c16ff
+Subproject 07af1bb4559d63ffe80a15603622dc2b75792da
diff --git a/src/buildtools/configure.json b/src/buildtools/configure.json
index 812a91f9c..0ea575c35 100644
--- a/src/buildtools/configure.json
+++ b/src/buildtools/configure.json
@@ -238,8 +238,7 @@
},
"headers": [ "vpx/vpx_encoder.h", "vpx/vp8cx.h", "vpx/vpx_image.h" ],
"sources": [
- { "type": "pkgConfig", "args": "vpx" },
- "-lvpx"
+ { "type": "pkgConfig", "args": "vpx >= 1.10.0" }
]
}
},
@@ -287,7 +286,8 @@
},
"webengine-ninja": {
"label": "system ninja",
- "type": "detectNinja"
+ "type": "detectNinja",
+ "log": "path"
},
"webengine-python2": {
"label": "python2",
@@ -453,7 +453,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/accessibility_tree_formatter_qt.cpp b/src/core/accessibility_tree_formatter_qt.cpp
index 51d33534b..e30ebb617 100644
--- a/src/core/accessibility_tree_formatter_qt.cpp
+++ b/src/core/accessibility_tree_formatter_qt.cpp
@@ -58,18 +58,17 @@ public:
explicit AccessibilityTreeFormatterQt();
~AccessibilityTreeFormatterQt() override;
- std::unique_ptr<base::DictionaryValue> BuildAccessibilityTreeForSelector(const content::AccessibilityTreeFormatter::TreeSelector &)
- { return nullptr; }
- std::unique_ptr<base::DictionaryValue> BuildAccessibilityTreeForWindow(gfx::AcceleratedWidget) override { return nullptr; }
std::unique_ptr<base::DictionaryValue> BuildAccessibilityTree(content::BrowserAccessibility *) override;
+ base::Value BuildTreeForWindow(gfx::AcceleratedWidget hwnd) const override
+ {
+ return base::Value{};
+ }
+ base::Value BuildTreeForSelector(const AXTreeSelector &selector) const override
+ {
+ return base::Value{};
+ }
private:
- base::FilePath::StringType GetExpectedFileSuffix() override;
- const std::string GetAllowEmptyString() override;
- const std::string GetAllowString() override;
- const std::string GetDenyString() override;
- const std::string GetDenyNodeString() override;
- const std::string GetRunUntilEventString() override;
void RecursiveBuildAccessibilityTree(const content::BrowserAccessibility &node, base::DictionaryValue *dict) const;
void AddProperties(const BrowserAccessibility &node, base::DictionaryValue *dict) const;
std::string ProcessTreeForOutput(const base::DictionaryValue &node, base::DictionaryValue * = nullptr) override;
@@ -209,40 +208,10 @@ std::string AccessibilityTreeFormatterQt::ProcessTreeForOutput(const base::Dicti
return line + "\n";
}
-base::FilePath::StringType AccessibilityTreeFormatterQt::GetExpectedFileSuffix()
-{
- return FILE_PATH_LITERAL("-expected-qt.txt");
-}
-
-const std::string AccessibilityTreeFormatterQt::GetAllowEmptyString()
-{
- return "@QT-ALLOW-EMPTY:";
-}
-
-const std::string AccessibilityTreeFormatterQt::GetAllowString()
-{
- return "@QT-ALLOW:";
-}
-
-const std::string AccessibilityTreeFormatterQt::GetDenyString()
-{
- return "@QT-DENY:";
-}
-
-const std::string AccessibilityTreeFormatterQt::GetDenyNodeString()
-{
- return "@QT-DENY-NODE:";
-}
-
-const std::string AccessibilityTreeFormatterQt::GetRunUntilEventString()
-{
- return "@QT-RUN-UNTIL-EVENT:";
-}
-
#endif // QT_CONFIG(accessibility)
// static
-std::unique_ptr<AccessibilityTreeFormatter> AccessibilityTreeFormatter::Create()
+std::unique_ptr<ui::AXTreeFormatter> AccessibilityTreeFormatter::Create()
{
#if QT_CONFIG(accessibility)
return std::unique_ptr<AccessibilityTreeFormatter>(new AccessibilityTreeFormatterQt());
diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro
index 2ddd0d69f..7b0c3eb0c 100644
--- a/src/core/api/core_api.pro
+++ b/src/core/api/core_api.pro
@@ -1,10 +1,15 @@
+include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri)
+QT_FOR_CONFIG += webenginecore webenginecore-private
+
TARGET = qtwebenginecoreapi$$qtPlatformTargetSuffix()
DESTDIR = $$OUT_PWD/$$getConfigDir()
TEMPLATE = lib
CONFIG += staticlib
-QT += network core-private webenginecoreheaders-private
+QT += network core-private webenginecoreheaders-private quick qml
+
+qtConfig(webengine-printing-and-pdf): QT += printsupport
# Don't create .prl file for this intermediate library because
# their contents get used when linking against them, breaking
@@ -37,9 +42,11 @@ HEADERS = \
qwebengineclientcertificatestore.h \
qtwebenginecoreglobal.h \
qtwebenginecoreglobal_p.h \
+ qwebenginecertificateerror.h \
qwebenginecookiestore.h \
qwebenginecookiestore_p.h \
qwebenginefindtextresult.h \
+ qwebenginefullscreenrequest.h \
qwebenginehttprequest.h \
qwebenginemessagepumpscheduler_p.h \
qwebenginenotification.h \
@@ -50,13 +57,31 @@ HEADERS = \
qwebengineurlrequestinfo_p.h \
qwebengineurlrequestjob.h \
qwebengineurlscheme.h \
- qwebengineurlschemehandler.h
+ qwebengineurlschemehandler.h \
+ qwebenginecontextmenurequest.h \
+ qwebenginecontextmenurequest_p.h \
+ qwebenginedownloadrequest.h \
+ qwebenginedownloadrequest_p.h \
+ qwebengineloadrequest.h \
+ qwebenginesettings.h \
+ qwebenginescript.h \
+ qwebenginescriptcollection.h \
+ qwebenginescriptcollection_p.h \
+ qwebengineprofile.h \
+ qwebengineprofile_p.h \
+ qwebengineclientcertificateselection.h \
+ qwebenginehistory.h \
+ qwebenginehistory_p.h \
+ qwebenginepage.h \
+ qwebenginepage_p.h
SOURCES = \
qtwebenginecoreglobal.cpp \
+ qwebenginecertificateerror.cpp \
qwebengineclientcertificatestore.cpp \
qwebenginecookiestore.cpp \
qwebenginefindtextresult.cpp \
+ qwebenginefullscreenrequest.cpp \
qwebenginehttprequest.cpp \
qwebenginemessagepumpscheduler.cpp \
qwebenginenotification.cpp \
@@ -65,13 +90,17 @@ 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 \
+ qwebengineloadrequest.cpp \
+ qwebenginesettings.cpp \
+ qwebenginescript.cpp \
+ qwebenginescriptcollection.cpp \
+ qwebengineprofile.cpp \
+ qwebengineclientcertificateselection.cpp \
+ qwebenginehistory.cpp \
+ qwebenginepage.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..e6a551e65 100644
--- a/src/core/api/qtwebenginecoreglobal.cpp
+++ b/src/core/api/qtwebenginecoreglobal.cpp
@@ -50,6 +50,7 @@
#endif
#endif
#include <QThread>
+#include <QQuickWindow>
#if QT_CONFIG(opengl)
QT_BEGIN_NAMESPACE
@@ -105,83 +106,125 @@ 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
+
+static void initialize()
+{
+#if QT_CONFIG(opengl)
+ if (QCoreApplication::instance()) {
+ // On window/ANGLE, calling QtWebEngine::initialize from DllMain will result in a crash.
+ if (!qt_gl_global_share_context()) {
+ qWarning("Qt WebEngine seems to be initialized from a plugin. Please "
+ "set Qt::AA_ShareOpenGLContexts using QCoreApplication::setAttribute and "
+ "QSGRendererInterface::OpenGLRhi using QQuickWindow::setGraphicsApi "
+ "before constructing QGuiApplication.");
+ }
+ return;
+ }
+ // QCoreApplication is not yet instantiated, ensuring the call will be deferred
+ qAddPreRoutine(QtWebEngineCore::initialize);
+ QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGLRhi);
+#endif // QT_CONFIG(opengl)
+}
+
+Q_CONSTRUCTOR_FUNCTION(initialize)
diff --git a/src/core/api/qtwebenginecoreglobal.h b/src/core/api/qtwebenginecoreglobal.h
index c425d1478..a20884d7d 100644
--- a/src/core/api/qtwebenginecoreglobal.h
+++ b/src/core/api/qtwebenginecoreglobal.h
@@ -53,6 +53,9 @@ QT_BEGIN_NAMESPACE
#define ASSERT_ENUMS_MATCH(A, B) Q_STATIC_ASSERT_X(static_cast<int>(A) == static_cast<int>(B), "The enum values must match");
+Q_WEBENGINECORE_EXPORT Q_DECL_CONST_FUNCTION const char *qWebEngineVersion() noexcept;
+Q_WEBENGINECORE_EXPORT Q_DECL_CONST_FUNCTION const char *qWebEngineChromiumVersion() noexcept;
+
QT_END_NAMESPACE
#endif // QTWEBENGINECOREGLOBAL_H
diff --git a/src/core/api/qwebenginecallback_p.h b/src/core/api/qwebenginecallback_p.h
index 133a86f6d..9cc25b7fd 100644
--- a/src/core/api/qwebenginecallback_p.h
+++ b/src/core/api/qwebenginecallback_p.h
@@ -244,7 +244,7 @@ inline void CallbackDirectory::CallbackSharedDataPointer<T>::invokeEmpty()
parent->invokeEmptyInternal(callback);
}
-#define CHECK_RELOCATABLE(x) Q_STATIC_ASSERT((QTypeInfoQuery<QWebEngineCallback<x>>::isRelocatable));
+#define CHECK_RELOCATABLE(x) Q_STATIC_ASSERT((QTypeInfo<QWebEngineCallback<x>>::isRelocatable));
FOR_EACH_TYPE(CHECK_RELOCATABLE)
#undef CHECK_RELOCATABLE
diff --git a/src/webenginewidgets/api/qwebenginecertificateerror.cpp b/src/core/api/qwebenginecertificateerror.cpp
index d86019af8..40c9a1c7b 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.
@@ -150,36 +98,37 @@ QWebEngineCertificateError::~QWebEngineCertificateError()
\value CertificateKnownInterceptionBlocked The certificate is known to be
used for interception by an entity other the device owner. (Added in
5.15)
+ \value SslObsoleteVersion The connection uses an obsolete version of SSL/TLS. (Added in Qt 6.0)
*/
/*!
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 +136,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 +146,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 +156,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 +182,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..ffcebaf9b 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,32 @@ public:
CertificateNameConstraintViolation = -212,
CertificateValidityTooLong = -213,
CertificateTransparencyRequired = -214,
+ CertificateSymantecLegacy = -215,
CertificateKnownInterceptionBlocked = -217,
+ SslObsoleteVersion = -218,
};
+ 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/webenginewidgets/api/qwebengineclientcertificateselection.cpp b/src/core/api/qwebengineclientcertificateselection.cpp
index 9eca01bbe..febfe0a21 100644
--- a/src/webenginewidgets/api/qwebengineclientcertificateselection.cpp
+++ b/src/core/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/core/api/qwebengineclientcertificateselection.h
index d451d09ae..81c626f73 100644
--- a/src/webenginewidgets/api/qwebengineclientcertificateselection.h
+++ b/src/core/api/qwebengineclientcertificateselection.h
@@ -40,19 +40,19 @@
#ifndef QWEBENGINECLIENTCERTSELECTION_H
#define QWEBENGINECLIENTCERTSELECTION_H
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
+#include <QtWebEngineCore/qtwebenginecoreglobal.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;
+}
-class QWEBENGINEWIDGETS_EXPORT QWebEngineClientCertificateSelection {
+QT_BEGIN_NAMESPACE
+
+class Q_WEBENGINECORE_EXPORT QWebEngineClientCertificateSelection {
public:
QWebEngineClientCertificateSelection(const QWebEngineClientCertificateSelection &);
~QWebEngineClientCertificateSelection();
@@ -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/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..d9041d797 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,43 @@
**
****************************************************************************/
-#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 extensions {
+class MimeHandlerViewGuestDelegateQt;
+}
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 +118,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 +131,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 +147,27 @@ 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 extensions::MimeHandlerViewGuestDelegateQt;
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..eae48b017 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)
+ , m_adapterClient(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,38 +508,41 @@ 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;
}
- if (!directory.isEmpty() && d->downloadDirectory != directory)
+ if (!directory.isEmpty() && d->downloadDirectory != directory) {
d->downloadDirectory = directory;
+ Q_EMIT downloadDirectoryChanged();
+ }
- if (!d->isCustomFileName)
- d->downloadFileName = QFileInfo(d->profile->profileAdapter()->determineDownloadPath(d->downloadDirectory,
- d->suggestedFileName,
- d->startTime)).fileName();
+ if (!d->isCustomFileName && d->m_profileAdapter) {
+ QString newFileName = QFileInfo(d->m_profileAdapter->determineDownloadPath(d->downloadDirectory,
+ d->suggestedFileName,
+ d->startTime)).fileName();
+ if (d->downloadFileName != newFileName) {
+ d->downloadFileName = newFileName;
+ Q_EMIT downloadFileNameChanged();
+ }
+ }
}
/*!
- \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 +550,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;
}
@@ -639,18 +561,17 @@ void QWebEngineDownloadItem::setDownloadFileName(const QString &fileName)
if (!fileName.isEmpty()) {
d->downloadFileName = fileName;
d->isCustomFileName = true;
+ Q_EMIT downloadFileNameChanged();
}
}
/*!
- \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 +581,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 +593,84 @@ 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);
- return d->page;
+ Q_D(const QWebEngineDownloadRequest);
+ //TODO: come back here when page is in core
+ Q_UNREACHABLE();
+ return nullptr;
}
-QWebEngineDownloadItem::QWebEngineDownloadItem(QWebEngineDownloadItemPrivate *p, QObject *parent)
+QWebEngineDownloadRequest::QWebEngineDownloadRequest(QWebEngineDownloadRequestPrivate *p, QObject *parent)
: QObject(parent)
, d_ptr(p)
{
@@ -775,7 +679,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..3e0e0d044 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,58 @@ 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;
+ friend class QWebEnginePage;
+ 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..db2e70852 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,33 @@
// 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;
+class WebContentsAdapterClient;
+}
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 +86,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;
+ QtWebEngineCore::WebContentsAdapterClient *m_adapterClient;
+ Q_DECLARE_PUBLIC(QWebEngineDownloadRequest)
};
QT_END_NAMESPACE
-#endif // QWEBENGINEDOWNLOADITEM_P_H
+#endif // QWEBENGINEDOWNLOADREQUEST_P_H
diff --git a/src/webenginewidgets/api/qwebenginefullscreenrequest.cpp b/src/core/api/qwebenginefullscreenrequest.cpp
index bcf2d5d22..facc8910d 100644
--- a/src/webenginewidgets/api/qwebenginefullscreenrequest.cpp
+++ b/src/core/api/qwebenginefullscreenrequest.cpp
@@ -38,7 +38,6 @@
****************************************************************************/
#include "qwebenginefullscreenrequest.h"
-#include "qwebenginepage_p.h"
QT_BEGIN_NAMESPACE
@@ -49,7 +48,7 @@ QT_BEGIN_NAMESPACE
\since 5.6
- \inmodule QtWebEngineWidgets
+ \inmodule QtWebEngineCore
To allow elements such as videos to be shown in the fullscreen mode,
applications must set QWebEngineSettings::FullScreenSupportEnabled and
@@ -85,39 +84,37 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QWebEngineFullScreenRequest::toggleOn() const
- Returns \c true if the web page has issued a request to enter the fullscreen
- mode, otherwise returns \c false.
-*/
-
-/*!
- \fn QWebEngineFullScreenRequest::origin() const
- Returns the URL to be opened in the fullscreen mode.
-*/
-
-/*!
Creates a request for opening the \a page from the URL specified by
\a origin in the fullscreen mode if \a fullscreen is \c true.
*/
-QWebEngineFullScreenRequest::QWebEngineFullScreenRequest(QWebEnginePage *page, const QUrl &origin, bool fullscreen)
- : m_page(page)
- , m_origin(origin)
- , m_toggleOn(fullscreen)
-{
-}
+class QWebEngineFullScreenRequestPrivate : public QSharedData {
+public:
+ QWebEngineFullScreenRequestPrivate(const QUrl &origin, bool toggleOn, const std::function<void (bool)> &setFullScreenCallback)
+ : m_origin(origin)
+ , m_toggleOn(toggleOn)
+ , m_setFullScreenCallback(setFullScreenCallback) { }
+
+ const QUrl m_origin;
+ const bool m_toggleOn;
+ const std::function<void (bool)> m_setFullScreenCallback;
+};
+
+QWebEngineFullScreenRequest::QWebEngineFullScreenRequest(const QUrl &origin, bool toggleOn, const std::function<void (bool)> &setFullScreenCallback)
+ : d_ptr(new QWebEngineFullScreenRequestPrivate(origin, toggleOn, setFullScreenCallback)) { }
+
+QWebEngineFullScreenRequest::QWebEngineFullScreenRequest(const QWebEngineFullScreenRequest &other) = default;
+QWebEngineFullScreenRequest& QWebEngineFullScreenRequest::operator=(const QWebEngineFullScreenRequest &other) = default;
+QWebEngineFullScreenRequest::QWebEngineFullScreenRequest(QWebEngineFullScreenRequest &&other) = default;
+QWebEngineFullScreenRequest& QWebEngineFullScreenRequest::operator=(QWebEngineFullScreenRequest &&other) = default;
+QWebEngineFullScreenRequest::~QWebEngineFullScreenRequest() = default;
/*!
Rejects a request to enter or exit the fullscreen mode.
*/
void QWebEngineFullScreenRequest::reject()
{
- if (!m_page) {
- qWarning("Cannot reject QWebEngineFullScreenRequest: Originating page is already deleted");
- return;
- }
-
- m_page->d_func()->setFullScreenMode(!m_toggleOn);
+ d_ptr->m_setFullScreenCallback(!d_ptr->m_toggleOn);
}
/*!
@@ -125,12 +122,26 @@ void QWebEngineFullScreenRequest::reject()
*/
void QWebEngineFullScreenRequest::accept()
{
- if (!m_page) {
- qWarning("Cannot accept QWebEngineFullScreenRequest: Originating page is already deleted");
- return;
- }
+ d_ptr->m_setFullScreenCallback(d_ptr->m_toggleOn);
+}
- m_page->d_func()->setFullScreenMode(m_toggleOn);
+/*!
+ \fn QWebEngineFullScreenRequest::toggleOn() const
+ Returns \c true if the web page has issued a request to enter the fullscreen
+ mode, otherwise returns \c false.
+*/
+bool QWebEngineFullScreenRequest::toggleOn() const
+{
+ return d_ptr->m_toggleOn;
+}
+
+/*!
+ \fn QWebEngineFullScreenRequest::origin() const
+ Returns the URL to be opened in the fullscreen mode.
+*/
+QUrl QWebEngineFullScreenRequest::origin() const
+{
+ return d_ptr->m_origin;
}
QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginefullscreenrequest.h b/src/core/api/qwebenginefullscreenrequest.h
index 08505a410..95911ed0a 100644
--- a/src/webenginewidgets/api/qwebenginefullscreenrequest.h
+++ b/src/core/api/qwebenginefullscreenrequest.h
@@ -40,29 +40,41 @@
#ifndef QWEBENGINEFULLSCREENREQUEST_H
#define QWEBENGINEFULLSCREENREQUEST_H
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
+#include <QtWebEngineCore/qtwebenginecoreglobal.h>
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qshareddata.h>
#include <QtCore/qurl.h>
-#include <QtCore/qpointer.h>
+
+#include <functional>
QT_BEGIN_NAMESPACE
-class QWebEnginePage;
-class QWEBENGINEWIDGETS_EXPORT QWebEngineFullScreenRequest {
+class QWebEngineFullScreenRequestPrivate;
+
+class Q_WEBENGINECORE_EXPORT QWebEngineFullScreenRequest
+{
Q_GADGET
Q_PROPERTY(bool toggleOn READ toggleOn CONSTANT)
Q_PROPERTY(QUrl origin READ origin CONSTANT)
+
public:
+ QWebEngineFullScreenRequest(const QWebEngineFullScreenRequest &other);
+ QWebEngineFullScreenRequest &operator=(const QWebEngineFullScreenRequest &other);
+ QWebEngineFullScreenRequest(QWebEngineFullScreenRequest &&other);
+ QWebEngineFullScreenRequest &operator=(QWebEngineFullScreenRequest &&other);
+ ~QWebEngineFullScreenRequest();
+
Q_INVOKABLE void reject();
Q_INVOKABLE void accept();
- bool toggleOn() const { return m_toggleOn; }
- const QUrl &origin() const { return m_origin; }
+ bool toggleOn() const;
+ QUrl origin() const;
private:
- QWebEngineFullScreenRequest(QWebEnginePage *page, const QUrl &origin, bool toggleOn);
- QPointer<QWebEnginePage> m_page;
- const QUrl m_origin;
- const bool m_toggleOn;
friend class QWebEnginePagePrivate;
+ friend class QQuickWebEngineViewPrivate;
+ QWebEngineFullScreenRequest(const QUrl &origin, bool toggleOn, const std::function<void (bool)> &setFullScreenCallback);
+ QExplicitlySharedDataPointer<QWebEngineFullScreenRequestPrivate> d_ptr;
};
QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginehistory.cpp b/src/core/api/qwebenginehistory.cpp
index 6a85b984e..08119d78c 100644
--- a/src/webenginewidgets/api/qwebenginehistory.cpp
+++ b/src/core/api/qwebenginehistory.cpp
@@ -40,7 +40,6 @@
#include "qwebenginehistory.h"
#include "qwebenginehistory_p.h"
-#include "qwebenginepage_p.h"
#include "web_contents_adapter.h"
QT_BEGIN_NAMESPACE
@@ -50,21 +49,15 @@ QT_BEGIN_NAMESPACE
Swaps the history item with the \a other item.
*/
-QWebEngineHistoryItemPrivate::QWebEngineHistoryItemPrivate(QWebEnginePagePrivate *page, int index)
- : page(page)
- , index(index)
+QWebEngineHistoryItemPrivate::QWebEngineHistoryItemPrivate(
+ QtWebEngineCore::WebContentsAdapterClient *adapter, int index)
+ : m_adapter(adapter), index(index)
{
}
-QWebEngineHistoryItem::QWebEngineHistoryItem(QWebEngineHistoryItemPrivate *d)
- : d(d)
-{
-}
+QWebEngineHistoryItem::QWebEngineHistoryItem(QWebEngineHistoryItemPrivate *d) : d(d) { }
-QWebEngineHistoryItem::QWebEngineHistoryItem(const QWebEngineHistoryItem &other)
- : d(other.d)
-{
-}
+QWebEngineHistoryItem::QWebEngineHistoryItem(const QWebEngineHistoryItem &other) : d(other.d) { }
QWebEngineHistoryItem &QWebEngineHistoryItem::operator=(const QWebEngineHistoryItem &other)
{
@@ -72,32 +65,35 @@ QWebEngineHistoryItem &QWebEngineHistoryItem::operator=(const QWebEngineHistoryI
return *this;
}
-QWebEngineHistoryItem::~QWebEngineHistoryItem()
-{
-}
+QWebEngineHistoryItem::~QWebEngineHistoryItem() { }
QUrl QWebEngineHistoryItem::originalUrl() const
{
Q_D(const QWebEngineHistoryItem);
- return d->page ? d->page->webContents()->getNavigationEntryOriginalUrl(d->index) : QUrl();
+ return d->m_adapter
+ ? d->m_adapter->webContentsAdapter()->getNavigationEntryOriginalUrl(d->index)
+ : QUrl();
}
QUrl QWebEngineHistoryItem::url() const
{
Q_D(const QWebEngineHistoryItem);
- return d->page ? d->page->webContents()->getNavigationEntryUrl(d->index) : QUrl();
+ return d->m_adapter ? d->m_adapter->webContentsAdapter()->getNavigationEntryUrl(d->index)
+ : QUrl();
}
QString QWebEngineHistoryItem::title() const
{
Q_D(const QWebEngineHistoryItem);
- return d->page ? d->page->webContents()->getNavigationEntryTitle(d->index) : QString();
+ return d->m_adapter ? d->m_adapter->webContentsAdapter()->getNavigationEntryTitle(d->index)
+ : QString();
}
QDateTime QWebEngineHistoryItem::lastVisited() const
{
Q_D(const QWebEngineHistoryItem);
- return d->page ? d->page->webContents()->getNavigationEntryTimestamp(d->index) : QDateTime();
+ return d->m_adapter ? d->m_adapter->webContentsAdapter()->getNavigationEntryTimestamp(d->index)
+ : QDateTime();
}
/*!
@@ -108,19 +104,21 @@ QDateTime QWebEngineHistoryItem::lastVisited() const
QUrl QWebEngineHistoryItem::iconUrl() const
{
Q_D(const QWebEngineHistoryItem);
- return d->page ? d->page->webContents()->getNavigationEntryIconUrl(d->index) : QUrl();
+ return d->m_adapter ? d->m_adapter->webContentsAdapter()->getNavigationEntryIconUrl(d->index)
+ : QUrl();
}
bool QWebEngineHistoryItem::isValid() const
{
Q_D(const QWebEngineHistoryItem);
- if (!d->page)
+ if (!d->m_adapter)
return false;
- return d->index >= 0 && d->index < d->page->webContents()->navigationEntryCount();
+ return d->index >= 0 && d->index < d->m_adapter->webContentsAdapter()->navigationEntryCount();
}
-QWebEngineHistoryPrivate::QWebEngineHistoryPrivate(QWebEnginePagePrivate *page)
- : page(page)
+QWebEngineHistoryPrivate::QWebEngineHistoryPrivate(
+ QtWebEngineCore::WebContentsAdapterClient *adapter)
+ : m_adapter(adapter)
{
}
@@ -129,38 +127,33 @@ QWebEngineHistoryPrivate::~QWebEngineHistoryPrivate()
// Invalidate shared item references possibly still out there.
QList<QWebEngineHistoryItem>::iterator it, end;
for (it = items.begin(), end = items.end(); it != end; ++it)
- it->d->page = 0;
+ it->d->m_adapter = nullptr;
}
void QWebEngineHistoryPrivate::updateItems() const
{
// Keep track of items we return to be able to invalidate them
- // and avoid dangling references to our page.
- int entryCount = page->webContents()->navigationEntryCount();
+ // and avoid dangling references to our m_adapter.
+ int entryCount = m_adapter->webContentsAdapter()->navigationEntryCount();
while (items.size() > entryCount) {
- items.last().d->page = 0;
+ items.last().d->m_adapter = nullptr;
items.removeLast();
}
while (items.size() < entryCount) {
int nextIndex = items.size();
- items.append(QWebEngineHistoryItem(new QWebEngineHistoryItemPrivate(page, nextIndex)));
+ items.append(QWebEngineHistoryItem(new QWebEngineHistoryItemPrivate(m_adapter, nextIndex)));
}
}
-QWebEngineHistory::QWebEngineHistory(QWebEngineHistoryPrivate *d)
- : d_ptr(d)
-{
-}
+QWebEngineHistory::QWebEngineHistory(QWebEngineHistoryPrivate *d) : d_ptr(d) { }
-QWebEngineHistory::~QWebEngineHistory()
-{
-}
+QWebEngineHistory::~QWebEngineHistory() { }
void QWebEngineHistory::clear()
{
Q_D(const QWebEngineHistory);
- d->page->webContents()->clearNavigationHistory();
- d->page->updateNavigationActions();
+ d->m_adapter->webContentsAdapter()->clearNavigationHistory();
+ d->m_adapter->updateNavigationActions();
}
QList<QWebEngineHistoryItem> QWebEngineHistory::items() const
@@ -191,32 +184,32 @@ QList<QWebEngineHistoryItem> QWebEngineHistory::forwardItems(int maxItems) const
bool QWebEngineHistory::canGoBack() const
{
Q_D(const QWebEngineHistory);
- return d->page->webContents()->canGoToOffset(-1);
+ return d->m_adapter->webContentsAdapter()->canGoToOffset(-1);
}
bool QWebEngineHistory::canGoForward() const
{
Q_D(const QWebEngineHistory);
- return d->page->webContents()->canGoToOffset(1);
+ return d->m_adapter->webContentsAdapter()->canGoToOffset(1);
}
void QWebEngineHistory::back()
{
Q_D(const QWebEngineHistory);
- d->page->webContents()->navigateToOffset(-1);
+ d->m_adapter->webContentsAdapter()->navigateToOffset(-1);
}
void QWebEngineHistory::forward()
{
Q_D(const QWebEngineHistory);
- d->page->webContents()->navigateToOffset(1);
+ d->m_adapter->webContentsAdapter()->navigateToOffset(1);
}
void QWebEngineHistory::goToItem(const QWebEngineHistoryItem &item)
{
Q_D(const QWebEngineHistory);
- Q_ASSERT(item.d->page == d->page);
- d->page->webContents()->navigateToIndex(item.d->index);
+ Q_ASSERT(item.d->m_adapter == d->m_adapter);
+ d->m_adapter->webContentsAdapter()->navigateToIndex(item.d->index);
}
QWebEngineHistoryItem QWebEngineHistory::backItem() const
@@ -251,30 +244,15 @@ QWebEngineHistoryItem QWebEngineHistory::itemAt(int i) const
int QWebEngineHistory::currentItemIndex() const
{
Q_D(const QWebEngineHistory);
- return d->page->webContents()->currentNavigationEntryIndex();
+ return d->m_adapter->webContentsAdapter()->currentNavigationEntryIndex();
}
int QWebEngineHistory::count() const
{
Q_D(const QWebEngineHistory);
- if (!d->page->webContents()->isInitialized())
+ if (!d->m_adapter->webContentsAdapter()->isInitialized())
return 0;
- return d->page->webContents()->navigationEntryCount();
-}
-
-QDataStream& operator<<(QDataStream& stream, const QWebEngineHistory& history)
-{
- QtWebEngineCore::WebContentsAdapter *adapter = history.d_func()->page->webContents();
- if (!adapter->isInitialized())
- adapter->loadDefault();
- adapter->serializeNavigationHistory(stream);
- return stream;
-}
-
-QDataStream& operator>>(QDataStream& stream, QWebEngineHistory& history)
-{
- history.d_func()->page->recreateFromSerializedHistory(stream);
- return stream;
+ return d->m_adapter->webContentsAdapter()->navigationEntryCount();
}
QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginehistory.h b/src/core/api/qwebenginehistory.h
index 33d91d523..f7e591e38 100644
--- a/src/webenginewidgets/api/qwebenginehistory.h
+++ b/src/core/api/qwebenginehistory.h
@@ -40,12 +40,12 @@
#ifndef QWEBENGINEHISTORY_H
#define QWEBENGINEHISTORY_H
+#include <QtWebEngineCore/qtwebenginecoreglobal.h>
#include <QtCore/qurl.h>
#include <QtCore/qstring.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qshareddata.h>
#include <QtGui/qicon.h>
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
QT_BEGIN_NAMESPACE
@@ -54,7 +54,8 @@ class QWebEngineHistoryItemPrivate;
class QWebEnginePage;
class QWebEnginePagePrivate;
-class QWEBENGINEWIDGETS_EXPORT QWebEngineHistoryItem {
+class Q_WEBENGINECORE_EXPORT QWebEngineHistoryItem
+{
public:
QWebEngineHistoryItem(const QWebEngineHistoryItem &other);
QWebEngineHistoryItem &operator=(const QWebEngineHistoryItem &other);
@@ -82,7 +83,8 @@ private:
Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QWebEngineHistoryItem)
class QWebEngineHistoryPrivate;
-class QWEBENGINEWIDGETS_EXPORT QWebEngineHistory {
+class Q_WEBENGINECORE_EXPORT QWebEngineHistory
+{
public:
void clear();
@@ -114,15 +116,12 @@ private:
Q_DECLARE_PRIVATE(QWebEngineHistory)
QScopedPointer<QWebEngineHistoryPrivate> d_ptr;
- friend QWEBENGINEWIDGETS_EXPORT QDataStream& operator>>(QDataStream&, QWebEngineHistory&);
- friend QWEBENGINEWIDGETS_EXPORT QDataStream& operator<<(QDataStream&, const QWebEngineHistory&);
+ friend Q_WEBENGINECORE_EXPORT QDataStream &operator>>(QDataStream &, QWebEngineHistory &);
+ friend Q_WEBENGINECORE_EXPORT QDataStream &operator<<(QDataStream &, const QWebEngineHistory &);
friend class QWebEnginePage;
friend class QWebEnginePagePrivate;
};
-QWEBENGINEWIDGETS_EXPORT QDataStream& operator<<(QDataStream& stream, const QWebEngineHistory& history);
-QWEBENGINEWIDGETS_EXPORT QDataStream& operator>>(QDataStream& stream, QWebEngineHistory& history);
-
QT_END_NAMESPACE
#endif // QWEBENGINEHISTORY_H
diff --git a/src/webenginewidgets/api/qwebenginehistory_p.h b/src/core/api/qwebenginehistory_p.h
index 8f7001967..2ca944e5b 100644
--- a/src/webenginewidgets/api/qwebenginehistory_p.h
+++ b/src/core/api/qwebenginehistory_p.h
@@ -50,29 +50,33 @@
//
// We mean it.
//
-
+#include "qtwebenginecoreglobal_p.h"
#include <QtCore/qshareddata.h>
+namespace QtWebEngineCore {
+class WebContentsAdapterClient;
+}
+
QT_BEGIN_NAMESPACE
class QWebEnginePagePrivate;
class QWebEngineHistoryItemPrivate : public QSharedData
{
public:
- QWebEngineHistoryItemPrivate(QWebEnginePagePrivate *page = 0, int index = 0);
-
- QWebEnginePagePrivate *page;
+ QWebEngineHistoryItemPrivate(QtWebEngineCore::WebContentsAdapterClient *adapter = nullptr,
+ int index = 0);
+ QtWebEngineCore::WebContentsAdapterClient *m_adapter;
int index;
};
-class QWebEngineHistoryPrivate
+class Q_WEBENGINECORE_PRIVATE_EXPORT QWebEngineHistoryPrivate
{
public:
- QWebEngineHistoryPrivate(QWebEnginePagePrivate *page);
+ QWebEngineHistoryPrivate(QtWebEngineCore::WebContentsAdapterClient *adapter);
~QWebEngineHistoryPrivate();
void updateItems() const;
- QWebEnginePagePrivate *page;
+ QtWebEngineCore::WebContentsAdapterClient *m_adapter;
mutable QList<QWebEngineHistoryItem> items;
};
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/api/qwebengineloadrequest.cpp b/src/core/api/qwebengineloadrequest.cpp
new file mode 100644
index 000000000..f260e8252
--- /dev/null
+++ b/src/core/api/qwebengineloadrequest.cpp
@@ -0,0 +1,192 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 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 <qwebengineloadrequest.h>
+
+#include <web_engine_error.h>
+
+QT_BEGIN_NAMESPACE
+
+using LoadStatus = QWebEngineLoadRequest::LoadStatus;
+using ErrorDomain = QWebEngineLoadRequest::ErrorDomain;
+
+Q_STATIC_ASSERT(static_cast<int>(WebEngineError::NoErrorDomain) == static_cast<int>(ErrorDomain::NoErrorDomain));
+Q_STATIC_ASSERT(static_cast<int>(WebEngineError::InternalErrorDomain) == static_cast<int>(ErrorDomain::InternalErrorDomain));
+Q_STATIC_ASSERT(static_cast<int>(WebEngineError::ConnectionErrorDomain) == static_cast<int>(ErrorDomain::ConnectionErrorDomain));
+Q_STATIC_ASSERT(static_cast<int>(WebEngineError::CertificateErrorDomain) == static_cast<int>(ErrorDomain::CertificateErrorDomain));
+Q_STATIC_ASSERT(static_cast<int>(WebEngineError::HttpErrorDomain) == static_cast<int>(ErrorDomain::HttpErrorDomain));
+Q_STATIC_ASSERT(static_cast<int>(WebEngineError::FtpErrorDomain) == static_cast<int>(ErrorDomain::FtpErrorDomain));
+Q_STATIC_ASSERT(static_cast<int>(WebEngineError::DnsErrorDomain) == static_cast<int>(ErrorDomain::DnsErrorDomain));
+
+class QWebEngineLoadRequest::QWebEngineLoadRequestPrivate : public QSharedData {
+public:
+ QWebEngineLoadRequestPrivate(const QUrl& url, LoadStatus status, const QString& errorString, int errorCode, ErrorDomain errorDomain)
+ : url(url)
+ , status(status)
+ , errorString(errorString)
+ , errorCode(errorCode)
+ , errorDomain(errorDomain)
+ {
+ }
+
+ QUrl url;
+ LoadStatus status;
+ QString errorString;
+ int errorCode;
+ ErrorDomain errorDomain;
+};
+
+/*!
+ \class QWebEngineLoadRequest
+ \brief A utility type for the WebEngineView::loadingChanged signal.
+ \inmodule QtWebEngineCore
+ \since 6.2
+
+ Contains information about a web page loading status change, such as the URL and
+ current loading status (started, succeeded, stopped, failed).
+
+ \sa QWebEnginePage::loadStarted, QWebEnginePage::loadFinished, WebEngineView::loadingChanged
+*/
+QWebEngineLoadRequest::QWebEngineLoadRequest(const QUrl& url, LoadStatus status, const QString& errorString,
+ int errorCode, ErrorDomain errorDomain)
+ : d_ptr(new QWebEngineLoadRequestPrivate(url, status, errorString, errorCode, errorDomain))
+{
+}
+
+QWebEngineLoadRequest::QWebEngineLoadRequest(const QWebEngineLoadRequest &other) = default;
+QWebEngineLoadRequest& QWebEngineLoadRequest::operator=(const QWebEngineLoadRequest &other) = default;
+QWebEngineLoadRequest::QWebEngineLoadRequest(QWebEngineLoadRequest &&other) = default;
+QWebEngineLoadRequest& QWebEngineLoadRequest::operator=(QWebEngineLoadRequest &&other) = default;
+
+QWebEngineLoadRequest::~QWebEngineLoadRequest()
+{
+}
+/*!
+ \property QWebEngineLoadRequest::url
+ \brief Holds the URL of the load request.
+*/
+/*!
+ Returns the URL of the load request.
+*/
+QUrl QWebEngineLoadRequest::url() const
+{
+ Q_D(const QWebEngineLoadRequest);
+ return d->url;
+}
+/*!
+ \enum QWebEngineLoadRequest::status
+
+ This enumeration represents the load status of a web page load request:
+
+ \value LoadStartedStatus Page is currently loading.
+ \value LoadStoppedStatus
+ Loading the page was stopped by the stop() method or by the loader
+ code or network stack in Chromium.
+ \value LoadSucceededStatus Page has been loaded with success.
+ \value LoadFailedStatus Page could not be loaded.
+*/
+/*!
+ \property Holds the page's load status.
+*/
+/*!
+ Returns the page's load status.
+*/
+LoadStatus QWebEngineLoadRequest::status() const
+{
+ Q_D(const QWebEngineLoadRequest);
+ return d->status;
+}
+/*!
+ \property QWebEngineLoadRequest::errorString
+ \brief Holds the error message.
+*/
+/*
+ Returns the error message.
+*/
+QString QWebEngineLoadRequest::errorString() const
+{
+ Q_D(const QWebEngineLoadRequest);
+ return d->errorString;
+}
+/*!
+ \enum enumeration QWebEngineLoadRequest::errorDomain
+ This enumeration holds the type of a load error:
+
+ \value NoErrorDomain
+ Error type is not known.
+ \value InternalErrorDomain
+ Content cannot be interpreted by \QWE.
+ \value ConnectionErrorDomain
+ Error results from a faulty network connection.
+ \value CertificateErrorDomain
+ Error is related to the SSL/TLS certificate.
+ \value HttpErrorDomain
+ Error is related to the HTTP connection.
+ \value FtpErrorDomain
+ Error is related to the FTP connection.
+ \value DnsErrorDomain
+ Error is related to the DNS connection.
+*/
+/*
+ \property QWebEngineLoadRequest::errorDomain
+ \brief Holds the error domain
+*/
+/*
+ Returns the error domain.
+*/
+ErrorDomain QWebEngineLoadRequest::errorDomain() const
+{
+ Q_D(const QWebEngineLoadRequest);
+ return d->errorDomain;
+}
+
+/*!
+ \property int QWebEngineLoadRequest::errorCode
+ \brief Holds the error code.
+*/
+/*
+ Returns the error code.
+*/
+int QWebEngineLoadRequest::errorCode() const
+{
+ Q_D(const QWebEngineLoadRequest);
+ return d->errorCode;
+}
+
+QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebengineloadrequest_p.h b/src/core/api/qwebengineloadrequest.h
index 6d8dd8061..6520d8982 100644
--- a/src/webengine/api/qquickwebengineloadrequest_p.h
+++ b/src/core/api/qwebengineloadrequest.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
@@ -37,51 +37,68 @@
**
****************************************************************************/
-#ifndef QQUICKWEBENGINELOADREQUEST_P_H
-#define QQUICKWEBENGINELOADREQUEST_P_H
+#ifndef QWEBENGINELOADREQUEST_H
+#define QWEBENGINELOADREQUEST_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 <QtWebEngineCore/qtwebenginecoreglobal.h>
-#include <QtWebEngine/private/qtwebengineglobal_p.h>
-#include "qquickwebengineview_p.h"
+#include <QObject>
+#include <QUrl>
QT_BEGIN_NAMESPACE
-class QQuickWebEngineLoadRequestPrivate;
-class Q_WEBENGINE_EXPORT QQuickWebEngineLoadRequest : public QObject {
- Q_OBJECT
+class Q_WEBENGINECORE_EXPORT QWebEngineLoadRequest
+{
+ Q_GADGET
Q_PROPERTY(QUrl url READ url CONSTANT FINAL)
- Q_PROPERTY(QQuickWebEngineView::LoadStatus status READ status CONSTANT FINAL)
+ Q_PROPERTY(LoadStatus status READ status CONSTANT FINAL)
Q_PROPERTY(QString errorString READ errorString CONSTANT FINAL)
- Q_PROPERTY(QQuickWebEngineView::ErrorDomain errorDomain READ errorDomain CONSTANT FINAL)
+ Q_PROPERTY(ErrorDomain errorDomain READ errorDomain CONSTANT FINAL)
Q_PROPERTY(int errorCode READ errorCode CONSTANT FINAL)
public:
- QQuickWebEngineLoadRequest(const QUrl& url, QQuickWebEngineView::LoadStatus status, const QString& errorString = QString(), int errorCode = 0, QQuickWebEngineView::ErrorDomain errorDomain = QQuickWebEngineView::NoErrorDomain, QObject* parent = 0);
- ~QQuickWebEngineLoadRequest();
+ enum LoadStatus {
+ LoadStartedStatus,
+ LoadStoppedStatus,
+ LoadSucceededStatus,
+ LoadFailedStatus
+ };
+ Q_ENUM(LoadStatus)
+
+ enum ErrorDomain {
+ NoErrorDomain,
+ InternalErrorDomain,
+ ConnectionErrorDomain,
+ CertificateErrorDomain,
+ HttpErrorDomain,
+ FtpErrorDomain,
+ DnsErrorDomain
+ };
+ Q_ENUM(ErrorDomain)
+
+ QWebEngineLoadRequest(const QWebEngineLoadRequest &other);
+ QWebEngineLoadRequest &operator=(const QWebEngineLoadRequest &other);
+ QWebEngineLoadRequest(QWebEngineLoadRequest &&other);
+ QWebEngineLoadRequest &operator=(QWebEngineLoadRequest &&other);
+ ~QWebEngineLoadRequest();
+
QUrl url() const;
- QQuickWebEngineView::LoadStatus status() const;
+ LoadStatus status() const;
QString errorString() const;
- QQuickWebEngineView::ErrorDomain errorDomain() const;
+ ErrorDomain errorDomain() const;
int errorCode() const;
private:
- Q_DECLARE_PRIVATE(QQuickWebEngineLoadRequest)
- QScopedPointer<QQuickWebEngineLoadRequestPrivate> d_ptr;
+ QWebEngineLoadRequest(const QUrl& url, LoadStatus status, const QString& errorString = QString(),
+ int errorCode = 0, ErrorDomain errorDomain = NoErrorDomain);
+ class QWebEngineLoadRequestPrivate;
+ Q_DECLARE_PRIVATE(QWebEngineLoadRequest)
+ QExplicitlySharedDataPointer<QWebEngineLoadRequestPrivate> d_ptr;
+ friend class QQuickWebEngineViewPrivate;
+ friend class QQuickWebEngineErrorPage;
};
QT_END_NAMESPACE
-QML_DECLARE_TYPE(QQuickWebEngineLoadRequest)
-
-#endif // QQUICKWEBENGINELOADREQUEST_P_H
+#endif // QWEBENGINELOADREQUEST_H
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/core/api/qwebenginepage.cpp
index b32c15039..367688c88 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/core/api/qwebenginepage.cpp
@@ -40,16 +40,16 @@
#include "qwebenginepage.h"
#include "qwebenginepage_p.h"
+#include "qwebenginedownloadrequest_p.h"
#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"
#include "file_picker_controller.h"
#include "javascript_dialog_controller.h"
#if QT_CONFIG(webengine_printing_and_pdf)
-#include "printer_worker.h"
+#include "printing/printer_worker.h"
#endif
#include "qwebenginecertificateerror.h"
#include "qwebenginefindtextresult.h"
@@ -63,45 +63,25 @@
#include "qwebengineregisterprotocolhandlerrequest.h"
#include "qwebenginescriptcollection_p.h"
#include "qwebenginesettings.h"
-#include "qwebengineview.h"
-#include "qwebengineview_p.h"
#include "user_notification_controller.h"
-#include "render_widget_host_view_qt_delegate_widget.h"
+#include "render_widget_host_view_qt_delegate.h"
#include "web_contents_adapter.h"
#include "web_engine_settings.h"
#include "qwebenginescript.h"
-
+#include "render_view_context_menu_qt.h"
+#include "render_widget_host_view_qt_delegate_client.h"
#include <QAction>
-#include <QApplication>
+#include <QGuiApplication>
#include <QAuthenticator>
#include <QClipboard>
-#if QT_CONFIG(colordialog)
-#include <QColorDialog>
-#endif
-#include <QContextMenuEvent>
-#if QT_CONFIG(filedialog)
-#include <QFileDialog>
-#endif
#include <QKeyEvent>
#include <QIcon>
-#if QT_CONFIG(inputdialog)
-#include <QInputDialog>
-#endif
-#include <QLayout>
#include <QLoggingCategory>
-#if QT_CONFIG(menu)
-#include <QMenu>
-#endif
-#if QT_CONFIG(messagebox)
-#include <QMessageBox>
-#endif
#include <QMimeData>
#if QT_CONFIG(webengine_printing_and_pdf)
#include <QPrinter>
#include <QThread>
#endif
-#include <QStandardPaths>
-#include <QStyle>
#include <QTimer>
#include <QUrl>
@@ -111,6 +91,49 @@ using namespace QtWebEngineCore;
static const int MaxTooltipLength = 1024;
+// add temporary dummy code to cover the case when page is loading and there is no view
+class DummyDelegate : public QObject, public QtWebEngineCore::RenderWidgetHostViewQtDelegate
+{
+public:
+ DummyDelegate(RenderWidgetHostViewQtDelegateClient *client) : m_delegateClient(client) {};
+ ~DummyDelegate() = default;
+ void initAsPopup(const QRect &) override { Q_UNREACHABLE(); }
+ QRectF viewGeometry() const override { return QRectF(m_pos, m_size); }
+ void setKeyboardFocus() override { }
+ bool hasKeyboardFocus() override { return false; }
+ void lockMouse() override { Q_UNREACHABLE(); }
+ void unlockMouse() override { Q_UNREACHABLE(); }
+ void show() override { m_delegateClient->notifyShown(); }
+ void hide() override { m_delegateClient->notifyHidden(); }
+ bool isVisible() const override { Q_UNREACHABLE(); }
+ QWindow *window() const override { return nullptr; }
+ void updateCursor(const QCursor &cursor) override
+ { /*setCursor(cursor);*/
+ }
+ void resize(int width, int height) override
+ {
+ m_size = QSize(width, height);
+ m_delegateClient->visualPropertiesChanged();
+ }
+ void move(const QPoint &) override { Q_UNREACHABLE(); }
+ void inputMethodStateChanged(bool, bool) override { }
+ void setInputMethodHints(Qt::InputMethodHints) override { }
+ void setClearColor(const QColor &) override { }
+ void adapterClientChanged(WebContentsAdapterClient *client) override { }
+ bool copySurface(const QRect &rect, const QSize &size, QImage &image)
+ {
+ Q_UNREACHABLE();
+ return false;
+ }
+ QRect windowGeometry() const override { return QRect(m_pos, m_size); }
+ bool forwardEvent(QEvent *ev) { return m_delegateClient->forwardEvent(ev); }
+
+private:
+ RenderWidgetHostViewQtDelegateClient *m_delegateClient;
+ QPoint m_pos;
+ QSize m_size;
+};
+
static QWebEnginePage::WebWindowType toWindowType(WebContentsAdapterClient::WindowOpenDisposition disposition)
{
switch (disposition) {
@@ -177,7 +200,7 @@ RenderWidgetHostViewQtDelegate *QWebEnginePagePrivate::CreateRenderWidgetHostVie
// The new delegate will not be deleted by the parent view though, because we unset the parent
// when the parent is destroyed. The delegate will be destroyed by Chromium when the popup is
// dismissed.
- return new RenderWidgetHostViewQtDelegateWidget(client, this->view);
+ return view ? view->CreateRenderWidgetHostViewQtDelegate(client) : new DummyDelegate(client);
}
void QWebEnginePagePrivate::initializationFinished()
@@ -261,7 +284,7 @@ void QWebEnginePagePrivate::renderProcessPidChanged(qint64 pid)
QRectF QWebEnginePagePrivate::viewportRect() const
{
- return view ? view->rect() : QRectF();
+ return view ? view->viewportRect() : QRectF();
}
QColor QWebEnginePagePrivate::backgroundColor() const
@@ -278,7 +301,7 @@ void QWebEnginePagePrivate::loadStarted(const QUrl &provisionalUrl, bool isError
return;
isLoading = true;
- m_certificateErrorControllers.clear();
+
QTimer::singleShot(0, q, &QWebEnginePage::loadStarted);
}
@@ -307,15 +330,15 @@ void QWebEnginePagePrivate::didPrintPageToPdf(const QString &filePath, bool succ
void QWebEnginePagePrivate::focusContainer()
{
if (view) {
- view->activateWindow();
- view->setFocus();
+ view->focusContainer();
}
}
void QWebEnginePagePrivate::unhandledKeyEvent(QKeyEvent *event)
{
- if (view && view->parentWidget())
- QGuiApplication::sendEvent(view->parentWidget(), event);
+ if (view) {
+ view->unhandledKeyEvent(event);
+ }
}
QSharedPointer<WebContentsAdapter>
@@ -429,9 +452,7 @@ void QWebEnginePagePrivate::didPrintPage(quint64 requestId, QSharedPointer<QByte
bool QWebEnginePagePrivate::passOnFocus(bool reverse)
{
- if (view)
- return view->focusNextPrevChild(!reverse);
- return false;
+ return view ? view->passOnFocus(reverse) : false;
}
void QWebEnginePagePrivate::authenticationRequired(QSharedPointer<AuthenticationDialogController> controller)
@@ -463,20 +484,8 @@ void QWebEnginePagePrivate::releaseProfile()
void QWebEnginePagePrivate::showColorDialog(QSharedPointer<ColorChooserController> controller)
{
-#if QT_CONFIG(colordialog)
- QColorDialog *dialog = new QColorDialog(controller.data()->initialColor(), view);
-
- QColorDialog::connect(dialog, SIGNAL(colorSelected(QColor)), controller.data(), SLOT(accept(QColor)));
- QColorDialog::connect(dialog, SIGNAL(rejected()), controller.data(), SLOT(reject()));
-
- // Delete when done
- QColorDialog::connect(dialog, SIGNAL(colorSelected(QColor)), dialog, SLOT(deleteLater()));
- QColorDialog::connect(dialog, SIGNAL(rejected()), dialog, SLOT(deleteLater()));
-
- dialog->open();
-#else
- Q_UNUSED(controller);
-#endif
+ if (view)
+ view->showColorDialog(controller);
}
void QWebEnginePagePrivate::runMediaAccessPermissionRequest(const QUrl &securityOrigin, WebContentsAdapterClient::MediaRequestFlags requestFlags)
@@ -538,13 +547,13 @@ void QWebEnginePagePrivate::runRegisterProtocolHandlerRequest(QWebEngineRegister
QObject *QWebEnginePagePrivate::accessibilityParentObject()
{
- return view;
+ return view ? view->accessibilityParentObject() : nullptr;
}
void QWebEnginePagePrivate::updateAction(QWebEnginePage::WebAction action) const
{
#ifdef QT_NO_ACTION
- Q_UNUSED(action)
+ Q_UNUSED(action);
#else
QAction *a = actions[action];
if (!a)
@@ -670,12 +679,6 @@ const QObject *QWebEnginePagePrivate::holdingQObject() const
return q;
}
-void QWebEnginePagePrivate::widgetChanged(RenderWidgetHostViewQtDelegate *newWidgetBase)
-{
- Q_Q(QWebEnginePage);
- bindPageAndWidget(q, static_cast<RenderWidgetHostViewQtDelegateWidget *>(newWidgetBase));
-}
-
void QWebEnginePagePrivate::findTextFinished(const QWebEngineFindTextResult &result)
{
Q_Q(QWebEnginePage);
@@ -688,90 +691,6 @@ void QWebEnginePagePrivate::ensureInitialized() const
adapter->loadDefault();
}
-void QWebEnginePagePrivate::bindPageAndView(QWebEnginePage *page, QWebEngineView *view)
-{
- auto oldView = page ? page->d_func()->view : nullptr;
- auto oldPage = view ? view->d_func()->page : nullptr;
-
- bool ownNewPage = false;
- bool deleteOldPage = false;
-
- // Change pointers first.
-
- if (page && oldView != view) {
- if (oldView) {
- ownNewPage = oldView->d_func()->m_ownsPage;
- oldView->d_func()->page = nullptr;
- oldView->d_func()->m_ownsPage = false;
- }
- page->d_func()->view = view;
- }
-
- if (view && oldPage != page) {
- if (oldPage) {
- if (oldPage->d_func())
- oldPage->d_func()->view = nullptr;
- deleteOldPage = view->d_func()->m_ownsPage;
- }
- view->d_func()->m_ownsPage = ownNewPage;
- view->d_func()->page = page;
- }
-
- // Then notify.
-
- auto widget = page ? page->d_func()->widget : nullptr;
- auto oldWidget = (oldPage && oldPage->d_func()) ? oldPage->d_func()->widget : nullptr;
-
- if (page && oldView != view && oldView) {
- oldView->d_func()->pageChanged(page, nullptr);
- if (widget)
- oldView->d_func()->widgetChanged(widget, nullptr);
- }
-
- if (view && oldPage != page) {
- if (oldPage && oldPage->d_func())
- view->d_func()->pageChanged(oldPage, page);
- else
- view->d_func()->pageChanged(nullptr, page);
- if (oldWidget != widget)
- view->d_func()->widgetChanged(oldWidget, widget);
- }
- if (deleteOldPage)
- delete oldPage;
-}
-
-void QWebEnginePagePrivate::bindPageAndWidget(QWebEnginePage *page, RenderWidgetHostViewQtDelegateWidget *widget)
-{
- auto oldPage = widget ? widget->m_page : nullptr;
- auto oldWidget = page ? page->d_func()->widget : nullptr;
-
- // Change pointers first.
-
- if (widget && oldPage != page) {
- if (oldPage && oldPage->d_func())
- oldPage->d_func()->widget = nullptr;
- widget->m_page = page;
- }
-
- if (page && oldWidget != widget) {
- if (oldWidget)
- oldWidget->m_page = nullptr;
- page->d_func()->widget = widget;
- }
-
- // Then notify.
-
- if (widget && oldPage != page && oldPage && oldPage->d_func()) {
- if (auto oldView = oldPage->d_func()->view)
- oldView->d_func()->widgetChanged(widget, nullptr);
- }
-
- if (page && oldWidget != widget) {
- if (auto view = page->d_func()->view)
- view->d_func()->widgetChanged(oldWidget, widget);
- }
-}
-
QWebEnginePage::QWebEnginePage(QObject* parent)
: QObject(parent)
, d_ptr(new QWebEnginePagePrivate())
@@ -853,15 +772,15 @@ QWebEnginePage::QWebEnginePage(QObject* parent)
*/
/*!
- \fn QWebEnginePage::registerProtocolHandlerRequested(QWebEngineRegisterProtocolHandlerRequest request)
- \since 5.11
+ \fn QWebEnginePage::registerProtocolHandlerRequested(QWebEngineRegisterProtocolHandlerRequest
+ request) \since 5.11
This signal is emitted when the web page tries to register a custom protocol
using the \l registerProtocolHandler API.
The request object \a request can be used to accept or reject the request:
- \snippet webenginewidgets/simplebrowser/webpage.cpp registerProtocolHandlerRequested
+ \snippet webenginewidgets/simplebrowser/webview.cpp registerProtocolHandlerRequested
*/
/*!
@@ -960,8 +879,7 @@ QWebEnginePage::~QWebEnginePage()
if (d_ptr) {
// d_ptr might be exceptionally null if profile adapter got deleted first
setDevToolsPage(nullptr);
- QWebEnginePagePrivate::bindPageAndView(this, nullptr);
- QWebEnginePagePrivate::bindPageAndWidget(this, nullptr);
+ emit _q_aboutToDelete();
}
}
@@ -1037,8 +955,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
}
@@ -1083,11 +1001,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();
@@ -1147,17 +1065,6 @@ qint64 QWebEnginePage::renderProcessPid() const
return d->adapter->renderProcessPid();
}
-void QWebEnginePage::setView(QWidget *newViewBase)
-{
- QWebEnginePagePrivate::bindPageAndView(this, qobject_cast<QWebEngineView *>(newViewBase));
-}
-
-QWidget *QWebEnginePage::view() const
-{
- Q_D(const QWebEnginePage);
- return d->view;
-}
-
/*!
Returns the web engine profile the page belongs to.
\since 5.5
@@ -1189,29 +1096,21 @@ QAction *QWebEnginePage::action(WebAction action) const
return d->actions[action];
QString text;
- QIcon icon;
- QStyle *style = d->view ? d->view->style() : qApp->style();
-
switch (action) {
case Back:
text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::Back);
- icon = style->standardIcon(QStyle::SP_ArrowBack);
break;
case Forward:
text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::Forward);
- icon = style->standardIcon(QStyle::SP_ArrowForward);
break;
case Stop:
text = tr("Stop");
- icon = style->standardIcon(QStyle::SP_BrowserStop);
break;
case Reload:
text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::Reload);
- icon = style->standardIcon(QStyle::SP_BrowserReload);
break;
case ReloadAndBypassCache:
text = tr("Reload and Bypass Cache");
- icon = style->standardIcon(QStyle::SP_BrowserReload);
break;
case Cut:
text = RenderViewContextMenuQt::getMenuItemName(RenderViewContextMenuQt::ContextMenuItem::Cut);
@@ -1342,7 +1241,6 @@ QAction *QWebEnginePage::action(WebAction action) const
QAction *a = new QAction(const_cast<QWebEnginePage*>(this));
a->setText(text);
a->setData(action);
- a->setIcon(icon);
connect(a, SIGNAL(triggered(bool)), this, SLOT(_q_webActionTriggered(bool)));
@@ -1356,7 +1254,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();
@@ -1398,35 +1295,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();
@@ -1434,102 +1332,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());
- qApp->clipboard()->setMimeData(data);
+ data->setUrls(QList<QUrl>() << d->view->lastContextMenuRequest()->linkUrl());
+ QGuiApplication::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());
- qApp->clipboard()->setMimeData(data);
+ data->setUrls(QList<QUrl>() << d->view->lastContextMenuRequest()->mediaUrl());
+ QGuiApplication::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());
- qApp->clipboard()->setMimeData(data);
+ data->setUrls(QList<QUrl>() << d->view->lastContextMenuRequest()->mediaUrl());
+ QGuiApplication::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.
@@ -1600,8 +1523,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(),
*/
@@ -1631,40 +1554,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->contextMenuRequested(data);
}
void QWebEnginePagePrivate::navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame)
@@ -1679,8 +1572,8 @@ void QWebEnginePagePrivate::navigationRequested(int navigationType, const QUrl &
void QWebEnginePagePrivate::requestFullScreenMode(const QUrl &origin, bool fullscreen)
{
Q_Q(QWebEnginePage);
- QWebEngineFullScreenRequest request(q, origin, fullscreen);
- Q_EMIT q->fullScreenRequested(request);
+ QWebEngineFullScreenRequest request(origin, fullscreen, [q = QPointer(q)] (bool toggleOn) { if (q) q->d_ptr->setFullScreenMode(toggleOn); });
+ Q_EMIT q->fullScreenRequested(std::move(request));
}
bool QWebEnginePagePrivate::isFullScreenMode() const
@@ -1710,9 +1603,8 @@ void QWebEnginePagePrivate::javascriptDialog(QSharedPointer<JavaScriptDialogCont
accepted = q->javaScriptConfirm(controller->securityOrigin(), QCoreApplication::translate("QWebEnginePage", "Are you sure you want to leave this page? Changes that you made may not be saved."));
break;
case InternalAuthorizationDialog:
-#if QT_CONFIG(messagebox)
- accepted = (QMessageBox::question(view, controller->title(), controller->message(), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes);
-#endif // QT_CONFIG(messagebox)
+ accepted = view ? view->showAuthorizationDialog(controller->title(), controller->message())
+ : false;
break;
}
if (accepted)
@@ -1721,32 +1613,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
@@ -1762,7 +1642,6 @@ void QWebEnginePagePrivate::selectClientCert(const QSharedPointer<ClientCertSele
\sa QWebEngineClientCertificateSelection
*/
-#endif
void QWebEnginePagePrivate::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID)
{
@@ -1785,29 +1664,17 @@ void QWebEnginePagePrivate::requestGeometryChange(const QRect &geometry, const Q
Q_EMIT q->geometryChangeRequested(frameGeometry);
}
-void QWebEnginePagePrivate::startDragging(const content::DropData &dropData,
- Qt::DropActions allowedActions, const QPixmap &pixmap,
- const QPoint &offset)
+QObject *QWebEnginePagePrivate::dragSource() const
{
#if !QT_CONFIG(draganddrop)
- Q_UNUSED(dropData);
- Q_UNUSED(allowedActions);
- Q_UNUSED(pixmap);
- Q_UNUSED(offset);
+ return view;
#else
- adapter->startDragging(view, dropData, allowedActions, pixmap, offset);
+ return nullptr;
#endif // QT_CONFIG(draganddrop)
}
-bool QWebEnginePagePrivate::supportsDragging() const
-{
- return true;
-}
-
bool QWebEnginePagePrivate::isEnabled() const
{
- const Q_Q(QWebEnginePage);
- const QWidget *view = q->view();
if (view)
return view->isEnabled();
return true;
@@ -1815,23 +1682,8 @@ bool QWebEnginePagePrivate::isEnabled() const
void QWebEnginePagePrivate::setToolTip(const QString &toolTipText)
{
- if (!view)
- return;
-
- // Hide tooltip if shown.
- if (toolTipText.isEmpty()) {
- if (!view->toolTip().isEmpty())
- view->setToolTip(QString());
-
- return;
- }
-
- // Update tooltip if text was changed.
- QString wrappedTip = QLatin1String("<p style=\"white-space:pre-wrap\">")
- % toolTipText.toHtmlEscaped().left(MaxTooltipLength)
- % QLatin1String("</p>");
- if (view->toolTip() != wrappedTip)
- view->setToolTip(wrappedTip);
+ if (view)
+ view->setToolTip(toolTipText);
}
void QWebEnginePagePrivate::printRequested()
@@ -1882,27 +1734,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);
@@ -1999,9 +1830,9 @@ void QWebEnginePagePrivate::runFileChooser(QSharedPointer<FilePickerController>
controller->rejected();
}
-WebEngineSettings *QWebEnginePagePrivate::webEngineSettings() const
+QWebEngineSettings *QWebEnginePagePrivate::webEngineSettings() const
{
- return settings->d_func();
+ return settings;
}
/*!
@@ -2205,12 +2036,7 @@ QWebEngineScriptCollection &QWebEnginePage::scripts()
QWebEnginePage *QWebEnginePage::createWindow(WebWindowType type)
{
Q_D(QWebEnginePage);
- if (d->view) {
- QWebEngineView *newView = d->view->createWindow(type);
- if (newView)
- return newView->page();
- }
- return nullptr;
+ return d->view ? d->view->createPageForWindow(type) : nullptr;
}
/*!
@@ -2305,89 +2131,33 @@ void QWebEnginePage::setDevToolsPage(QWebEnginePage *devToolsPage)
ASSERT_ENUMS_MATCH(FilePickerController::Open, QWebEnginePage::FileSelectOpen)
ASSERT_ENUMS_MATCH(FilePickerController::OpenMultiple, QWebEnginePage::FileSelectOpenMultiple)
+// TODO: remove virtuals
QStringList QWebEnginePage::chooseFiles(FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes)
{
-#if QT_CONFIG(filedialog)
- const QStringList &filter = FilePickerController::nameFilters(acceptedMimeTypes);
- QStringList ret;
- QString str;
- switch (static_cast<FilePickerController::FileChooserMode>(mode)) {
- case FilePickerController::OpenMultiple:
- ret = QFileDialog::getOpenFileNames(view(), QString(), QString(), filter.join(QStringLiteral(";;")), nullptr, QFileDialog::HideNameFilterDetails);
- break;
- // Chromium extension, not exposed as part of the public API for now.
- case FilePickerController::UploadFolder:
- str = QFileDialog::getExistingDirectory(view(), tr("Select folder to upload"));
- if (!str.isNull())
- ret << str;
- break;
- case FilePickerController::Save:
- str = QFileDialog::getSaveFileName(view(), QString(), (QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + oldFiles.first()));
- if (!str.isNull())
- ret << str;
- break;
- case FilePickerController::Open:
- str = QFileDialog::getOpenFileName(view(), QString(), oldFiles.first(), filter.join(QStringLiteral(";;")), nullptr, QFileDialog::HideNameFilterDetails);
- if (!str.isNull())
- ret << str;
- break;
- }
- return ret;
-#else
- Q_UNUSED(mode);
- Q_UNUSED(oldFiles);
- Q_UNUSED(acceptedMimeTypes);
-
- return QStringList();
-#endif // QT_CONFIG(filedialog)
+ Q_D(const QWebEnginePage);
+ return d->view ? d->view->chooseFiles(mode, oldFiles, acceptedMimeTypes) : QStringList();
}
void QWebEnginePage::javaScriptAlert(const QUrl &securityOrigin, const QString &msg)
{
Q_UNUSED(securityOrigin);
-#if QT_CONFIG(messagebox)
- QMessageBox::information(view(),
- QStringLiteral("Javascript Alert - %1").arg(url().toString()),
- msg.toHtmlEscaped());
-#else
- Q_UNUSED(msg);
-#endif // QT_CONFIG(messagebox)
+ Q_D(const QWebEnginePage);
+ if (d->view)
+ d->view->javaScriptAlert(url(), msg);
}
bool QWebEnginePage::javaScriptConfirm(const QUrl &securityOrigin, const QString &msg)
{
Q_UNUSED(securityOrigin);
-#if QT_CONFIG(messagebox)
- return (QMessageBox::information(view(),
- QStringLiteral("Javascript Confirm - %1").arg(url().toString()),
- msg.toHtmlEscaped(),
- QMessageBox::Ok,
- QMessageBox::Cancel) == QMessageBox::Ok);
-#else
- Q_UNUSED(msg);
- return false;
-#endif // QT_CONFIG(messagebox)
+ Q_D(const QWebEnginePage);
+ return d->view ? d->view->javaScriptConfirm(url(), msg) : false;
}
bool QWebEnginePage::javaScriptPrompt(const QUrl &securityOrigin, const QString &msg, const QString &defaultValue, QString *result)
{
Q_UNUSED(securityOrigin);
-#if QT_CONFIG(inputdialog)
- bool ret = false;
- if (result)
- *result = QInputDialog::getText(view(),
- QStringLiteral("Javascript Prompt - %1").arg(url().toString()),
- msg.toHtmlEscaped(),
- QLineEdit::Normal,
- defaultValue.toHtmlEscaped(),
- &ret);
- return ret;
-#else
- Q_UNUSED(msg);
- Q_UNUSED(defaultValue);
- Q_UNUSED(result);
- return false;
-#endif // QT_CONFIG(inputdialog)
+ Q_D(const QWebEnginePage);
+ return d->view ? d->view->javaScriptPrompt(url(), msg, defaultValue, result) : false;
}
void QWebEnginePage::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID)
@@ -2412,10 +2182,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 +2312,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,172 +2427,26 @@ 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)
-{
+QWebEnginePage* QWebEnginePage::fromDownloadRequest(QWebEngineDownloadRequest *request) {
+ return static_cast<QWebEnginePagePrivate *>(request->d_ptr->m_adapterClient)->q_ptr;
}
-bool QContextMenuBuilder::hasInspector()
+QDataStream &operator<<(QDataStream &stream, const QWebEngineHistory &history)
{
- return m_page->d_ptr->adapter->hasInspector();
-}
-
-bool QContextMenuBuilder::isFullScreenMode()
-{
- return m_page->d_ptr->isFullScreenMode();
+ QtWebEngineCore::WebContentsAdapter *adapter =
+ history.d_func()->m_adapter->webContentsAdapter();
+ if (!adapter->isInitialized())
+ adapter->loadDefault();
+ adapter->serializeNavigationHistory(stream);
+ return stream;
}
-void QContextMenuBuilder::addMenuItem(ContextMenuItem menuItem)
+QDataStream &operator>>(QDataStream &stream, QWebEngineHistory &history)
{
- 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();
+ static_cast<QWebEnginePagePrivate *>(history.d_func()->m_adapter)
+ ->recreateFromSerializedHistory(stream);
+ return stream;
}
-#endif // QT_CONFIG(action)
QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/core/api/qwebenginepage.h
index 3bf79526d..09b7b54df 100644
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ b/src/core/api/qwebenginepage.h
@@ -40,9 +40,9 @@
#ifndef QWEBENGINEPAGE_H
#define QWEBENGINEPAGE_H
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-#include <QtWebEngineWidgets/qwebengineclientcertificateselection.h>
-#include <QtWebEngineWidgets/qwebenginedownloaditem.h>
+#include <QtWebEngineCore/qtwebenginecoreglobal.h>
+#include <QtWebEngineCore/qwebengineclientcertificateselection.h>
+#include <QtWebEngineCore/qwebenginedownloadrequest.h>
#include <QtWebEngineCore/qwebenginecallback.h>
#include <QtWebEngineCore/qwebenginehttprequest.h>
@@ -50,8 +50,8 @@
#include <QtCore/qurl.h>
#include <QtCore/qvariant.h>
#include <QtGui/qpagelayout.h>
+#include <QtGui/qaction.h>
#include <QtNetwork/qnetworkaccessmanager.h>
-#include <QtWidgets/qwidget.h>
QT_BEGIN_NAMESPACE
class QMenu;
@@ -61,7 +61,6 @@ class QContextMenuBuilder;
class QWebChannel;
class QWebEngineCertificateError;
class QWebEngineClientCertificateSelection;
-class QWebEngineContextMenuData;
class QWebEngineFindTextResult;
class QWebEngineFullScreenRequest;
class QWebEngineHistory;
@@ -74,7 +73,7 @@ class QWebEngineScriptCollection;
class QWebEngineSettings;
class QWebEngineUrlRequestInterceptor;
-class QWEBENGINEWIDGETS_EXPORT QWebEnginePage : public QObject {
+class Q_WEBENGINECORE_EXPORT QWebEnginePage : public QObject {
Q_OBJECT
Q_PROPERTY(QString selectedText READ selectedText)
Q_PROPERTY(bool hasSelection READ hasSelection)
@@ -240,9 +239,6 @@ public:
~QWebEnginePage();
QWebEngineHistory *history() const;
- void setView(QWidget *view);
- QWidget *view() const;
-
bool hasSelection() const;
QString selectedText() const;
@@ -259,10 +255,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 +292,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 +311,6 @@ public:
void setUrlRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor);
- const QWebEngineContextMenuData &contextMenuData() const;
-
LifecycleState lifecycleState() const;
void setLifecycleState(LifecycleState state);
@@ -329,6 +319,8 @@ public:
bool isVisible() const;
void setVisible(bool visible);
+ static QWebEnginePage* fromDownloadRequest(QWebEngineDownloadRequest * request);
+
Q_SIGNALS:
void loadStarted();
void loadProgress(int progress);
@@ -344,10 +336,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);
@@ -375,6 +364,9 @@ Q_SIGNALS:
void findTextFinished(const QWebEngineFindTextResult &result);
+ // TODO: fixme / rewrite bindPageToView
+ void _q_aboutToDelete();
+
protected:
virtual QWebEnginePage *createWindow(WebWindowType type);
virtual QStringList chooseFiles(FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes);
@@ -382,9 +374,8 @@ 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:
Q_DISABLE_COPY(QWebEnginePage)
Q_DECLARE_PRIVATE(QWebEnginePage)
@@ -404,6 +395,10 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QWebEnginePage::FindFlags)
+Q_WEBENGINECORE_EXPORT QDataStream &operator<<(QDataStream &stream,
+ const QWebEngineHistory &history);
+Q_WEBENGINECORE_EXPORT QDataStream &operator>>(QDataStream &stream, QWebEngineHistory &history);
+
QT_END_NAMESPACE
#endif // QWEBENGINEPAGE_H
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/core/api/qwebenginepage_p.h
index ae3ab5d25..081287889 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/core/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>
@@ -66,6 +64,7 @@
namespace QtWebEngineCore {
class RenderWidgetHostViewQtDelegate;
class RenderWidgetHostViewQtDelegateWidget;
+class RenderWidgetHostViewQtDelegateClient;
class TouchHandleDrawableClient;
class TouchSelectionMenuController;
class WebContentsAdapter;
@@ -79,13 +78,41 @@ class QWebEngineProfile;
class QWebEngineSettings;
class QWebEngineView;
-class QWebEnginePagePrivate : public QtWebEngineCore::WebContentsAdapterClient
+class PageView
+{
+public:
+ virtual void contextMenuRequested(QWebEngineContextMenuRequest *request) = 0;
+ virtual QStringList chooseFiles(QWebEnginePage::FileSelectionMode mode,
+ const QStringList &oldFiles,
+ const QStringList &acceptedMimeTypes) = 0;
+ virtual void
+ showColorDialog(QSharedPointer<QtWebEngineCore::ColorChooserController> controller) = 0;
+ virtual bool showAuthorizationDialog(const QString &title, const QString &message) = 0;
+ virtual void javaScriptAlert(const QUrl &url, const QString &msg) = 0;
+ virtual bool javaScriptConfirm(const QUrl &url, const QString &msg) = 0;
+ virtual bool javaScriptPrompt(const QUrl &url, const QString &msg, const QString &defaultValue,
+ QString *result) = 0;
+ virtual void setToolTip(const QString &toolTipText) = 0;
+ virtual QtWebEngineCore::RenderWidgetHostViewQtDelegate *CreateRenderWidgetHostViewQtDelegate(
+ QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) = 0;
+ virtual QWebEngineContextMenuRequest *lastContextMenuRequest() const = 0;
+ virtual QWebEnginePage *createPageForWindow(QWebEnginePage::WebWindowType type) = 0;
+ virtual bool isEnabled() const = 0;
+ virtual bool isVisible() const = 0;
+ virtual QRect viewportRect() const = 0;
+ virtual void focusContainer() = 0;
+ virtual void unhandledKeyEvent(QKeyEvent *event) = 0;
+ virtual bool passOnFocus(bool reverse) = 0;
+ virtual QObject *accessibilityParentObject() = 0;
+};
+
+class Q_WEBENGINECORE_PRIVATE_EXPORT QWebEnginePagePrivate : public QtWebEngineCore::WebContentsAdapterClient
{
public:
Q_DECLARE_PUBLIC(QWebEnginePage)
QWebEnginePage *q_ptr;
- QWebEnginePagePrivate(QWebEngineProfile *profile = 0);
+ QWebEnginePagePrivate(QWebEngineProfile *profile = nullptr);
~QWebEnginePagePrivate();
QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) override;
@@ -106,7 +133,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, int errorCode, const QString &errorDescription) override;
void focusContainer() override;
void unhandledKeyEvent(QKeyEvent *event) override;
@@ -117,7 +144,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;
@@ -139,18 +166,17 @@ public:
void runQuotaRequest(QWebEngineQuotaRequest) override;
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;
+ QWebEngineSettings *webEngineSettings() const 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;
void updateContentsSize(const QSizeF &size) override;
void updateNavigationActions() override;
void updateEditActions() override;
- void startDragging(const content::DropData &dropData, Qt::DropActions allowedActions,
- const QPixmap &pixmap, const QPoint &offset) override;
- bool supportsDragging() const override;
+ QObject *dragSource() const override;
bool isEnabled() const override;
void setToolTip(const QString &toolTipText) override;
void printRequested() override;
@@ -159,7 +185,6 @@ public:
void hideTouchSelectionMenu() override { }
const QObject *holdingQObject() const override;
ClientType clientType() override { return QtWebEngineCore::WebContentsAdapterClient::WidgetsClient; }
- void widgetChanged(QtWebEngineCore::RenderWidgetHostViewQtDelegate *newWidget) override;
void findTextFinished(const QWebEngineFindTextResult &result) override;
QtWebEngineCore::ProfileAdapter *profileAdapter() override;
@@ -174,17 +199,12 @@ public:
void setFullScreenMode(bool);
void ensureInitialized() const;
- static void bindPageAndView(QWebEnginePage *page, QWebEngineView *view);
- static void bindPageAndWidget(QWebEnginePage *page,
- QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *widget);
-
QSharedPointer<QtWebEngineCore::WebContentsAdapter> adapter;
QWebEngineHistory *history;
QWebEngineProfile *profile;
QWebEngineSettings *settings;
- QWebEngineView *view;
+ PageView *view;
QUrl url;
- QWebEngineContextMenuData contextData;
bool isLoading;
QWebEngineScriptCollection scriptCollection;
bool m_isBeingAdopted;
@@ -206,24 +226,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/core/api/qwebengineprofile.cpp
index 223d3b114..6f0e9d82c 100644
--- a/src/webenginewidgets/api/qwebengineprofile.cpp
+++ b/src/core/api/qwebengineprofile.cpp
@@ -39,13 +39,11 @@
#include "qwebengineprofile.h"
#include "qwebengineprofile_p.h"
-
+#include "qwebenginenotification.h"
#include "qwebenginecookiestore.h"
-#include "qwebenginedownloaditem.h"
-#include "qwebenginedownloaditem_p.h"
-#include "qwebenginenotificationpresenter_p.h"
-#include "qwebenginepage.h"
-#include "qwebenginepage_p.h"
+#include "qwebenginedownloadrequest.h"
+#include "qwebenginedownloadrequest_p.h"
+#include "qwebenginenotification.h"
#include "qwebenginesettings.h"
#include "qwebenginescriptcollection_p.h"
#include "qtwebenginecoreglobal.h"
@@ -58,10 +56,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 +149,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)
@@ -173,7 +171,6 @@ QWebEngineProfilePrivate::QWebEngineProfilePrivate(ProfileAdapter* profileAdapte
new QWebEngineScriptCollectionPrivate(profileAdapter->userResourceController())))
{
m_profileAdapter->addClient(this);
- m_settings->d_ptr->initDefaults();
}
QWebEngineProfilePrivate::~QWebEngineProfilePrivate()
@@ -223,37 +220,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;
+ itemPrivate->m_adapterClient = info.page;
else
- itemPrivate->page = nullptr;
+ itemPrivate->m_adapterClient = 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 +262,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);
@@ -585,34 +582,6 @@ QWebEngineCookieStore* QWebEngineProfile::cookieStore()
return d->profileAdapter()->cookieStore();
}
-#if QT_DEPRECATED_SINCE(5, 13)
-/*!
- Registers a request interceptor singleton \a interceptor to intercept URL requests.
-
- The profile does not take ownership of the pointer.
-
- \obsolete
-
- Interceptors installed with this method will call
- QWebEngineUrlRequestInterceptor::interceptRequest on the I/O thread. Therefore
- the user has to provide thread-safe interaction with the other user classes.
- For a duration of this call ui thread is blocked.
- Use setUrlRequestInterceptor instead.
-
- \since 5.6
- \sa QWebEngineUrlRequestInfo
-
-*/
-void QWebEngineProfile::setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor)
-{
- Q_D(QWebEngineProfile);
- if (interceptor)
- interceptor->setProperty("deprecated", true);
- d->profileAdapter()->setRequestInterceptor(interceptor);
- if (interceptor)
- qDebug("Use of deprecated not thread-safe setter, use setUrlRequestInterceptor instead.");
-}
-#endif
/*!
Registers a request interceptor singleton \a interceptor to intercept URL requests.
@@ -685,6 +654,16 @@ void QWebEngineProfile::setNotificationPresenter(std::function<void(std::unique_
}
/*!
+ Returns presenter responsible for presenting sent notifications
+ \since 6.0
+ */
+std::function<void(std::unique_ptr<QWebEngineNotification>)> QWebEngineProfile::notificationPresenter()
+{
+ Q_D(QWebEngineProfile);
+ return d->m_notificationPresenter;
+}
+
+/*!
Returns the default profile.
The default profile uses the storage name "Default".
@@ -696,8 +675,6 @@ QWebEngineProfile *QWebEngineProfile::defaultProfile()
static QWebEngineProfile* profile = new QWebEngineProfile(
new QWebEngineProfilePrivate(ProfileAdapter::createDefaultProfileAdapter()),
ProfileAdapter::globalQObjectRoot());
- if (!profile->d_ptr->m_notificationPresenter)
- profile->setNotificationPresenter(&defaultNotificationPresenter);
return profile;
}
diff --git a/src/webenginewidgets/api/qwebengineprofile.h b/src/core/api/qwebengineprofile.h
index 794ba6279..b2088cf5d 100644
--- a/src/webenginewidgets/api/qwebengineprofile.h
+++ b/src/core/api/qwebengineprofile.h
@@ -40,7 +40,7 @@
#ifndef QWEBENGINEPROFILE_H
#define QWEBENGINEPROFILE_H
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
+#include <QtWebEngineCore/qtwebenginecoreglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qscopedpointer.h>
@@ -55,17 +55,15 @@ class QObject;
class QUrl;
class QWebEngineClientCertificateStore;
class QWebEngineCookieStore;
-class QWebEngineDownloadItem;
+class QWebEngineDownloadRequest;
class QWebEngineNotification;
-class QWebEnginePage;
-class QWebEnginePagePrivate;
class QWebEngineProfilePrivate;
class QWebEngineSettings;
class QWebEngineScriptCollection;
class QWebEngineUrlRequestInterceptor;
class QWebEngineUrlSchemeHandler;
-class QWEBENGINEWIDGETS_EXPORT QWebEngineProfile : public QObject {
+class Q_WEBENGINECORE_EXPORT QWebEngineProfile : public QObject {
Q_OBJECT
public:
explicit QWebEngineProfile(QObject *parent = Q_NULLPTR);
@@ -143,13 +141,14 @@ public:
void setDownloadPath(const QString &path);
void setNotificationPresenter(std::function<void(std::unique_ptr<QWebEngineNotification>)> notificationPresenter);
+ std::function<void(std::unique_ptr<QWebEngineNotification>)> notificationPresenter();
QWebEngineClientCertificateStore *clientCertificateStore();
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/core/api/qwebengineprofile_p.h
index 64e9500b0..4bec7d6dc 100644
--- a/src/webenginewidgets/api/qwebengineprofile_p.h
+++ b/src/core/api/qwebengineprofile_p.h
@@ -73,7 +73,7 @@ class QWebEngineProfilePrivate;
class QWebEngineNotification;
class QWebEngineSettings;
-class QWebEngineProfilePrivate : public QtWebEngineCore::ProfileAdapterClient {
+class Q_WEBENGINECORE_PRIVATE_EXPORT QWebEngineProfilePrivate : public QtWebEngineCore::ProfileAdapterClient {
public:
Q_DECLARE_PUBLIC(QWebEngineProfile)
QWebEngineProfilePrivate(QtWebEngineCore::ProfileAdapter *profileAdapter);
@@ -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/qwebenginescript.cpp b/src/core/api/qwebenginescript.cpp
index af6b9aa8d..650ad5c53 100644
--- a/src/webenginewidgets/api/qwebenginescript.cpp
+++ b/src/core/api/qwebenginescript.cpp
@@ -41,12 +41,15 @@
#include "user_script.h"
#include <QtCore/QDebug>
+#include <QtCore/QFile>
using QtWebEngineCore::UserScript;
+QT_BEGIN_NAMESPACE
+
/*!
\class QWebEngineScript
- \inmodule QtWebEngineWidgets
+ \inmodule QtWebEngineCore
\since 5.5
\brief The QWebEngineScript class encapsulates a JavaScript program.
@@ -143,14 +146,6 @@ QWebEngineScript &QWebEngineScript::operator=(const QWebEngineScript &other)
}
/*!
- Returns \c true is the script is null; otherwise returns \c false.
-*/
-bool QWebEngineScript::isNull() const
-{
- return d->isNull();
-}
-
-/*!
* Returns the name of the script. Can be useful to retrieve a particular script from a
* QWebEngineScriptCollection.
*
@@ -172,6 +167,37 @@ void QWebEngineScript::setName(const QString &scriptName)
d->setName(scriptName);
}
+
+QUrl QWebEngineScript::sourceUrl() const
+{
+ return d->sourceUrl();
+}
+
+void QWebEngineScript::setSourceUrl(const QUrl &url)
+{
+ if (url == sourceUrl())
+ return;
+
+ d->setSourceUrl(url);
+
+ QFile file;
+ if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0) {
+ if (url.authority().isEmpty())
+ file.setFileName(QLatin1Char(':') + url.path());
+ return;
+ } else {
+ file.setFileName(url.toLocalFile());
+ }
+
+ if (!file.open(QIODevice::ReadOnly)) {
+ qWarning() << "Can't open user script " << url;
+ return;
+ }
+
+ QString source = QString::fromUtf8(file.readAll());
+ setSourceCode(source);
+}
+
/*!
Returns the source of the script.
*/
@@ -271,9 +297,6 @@ QWebEngineScript::QWebEngineScript(const UserScript &coreScript)
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug d, const QWebEngineScript &script)
{
- if (script.isNull())
- return d.maybeSpace() << "QWebEngineScript()";
-
d.nospace() << "QWebEngineScript(" << script.name() << ", ";
switch (script.injectionPoint()) {
case QWebEngineScript::DocumentCreation:
@@ -291,3 +314,5 @@ QDebug operator<<(QDebug d, const QWebEngineScript &script)
return d.space();
}
#endif
+
+QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginescript.h b/src/core/api/qwebenginescript.h
index e3f65ec59..0c1849dac 100644
--- a/src/webenginewidgets/api/qwebenginescript.h
+++ b/src/core/api/qwebenginescript.h
@@ -40,10 +40,10 @@
#ifndef QWEBENGINESCRIPT_H
#define QWEBENGINESCRIPT_H
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-
-#include <QtCore/qshareddata.h>
-#include <QtCore/qstring.h>
+#include <QtWebEngineCore/qtwebenginecoreglobal.h>
+#include <QtCore/QUrl>
+#include <QtCore/QObject>
+#include <QtCore/QSharedDataPointer>
namespace QtWebEngineCore {
class UserScript;
@@ -51,31 +51,46 @@ class UserScript;
QT_BEGIN_NAMESPACE
-class QWEBENGINEWIDGETS_EXPORT QWebEngineScript {
+class Q_WEBENGINECORE_EXPORT QWebEngineScript {
+
+ Q_GADGET
+ Q_PROPERTY(QString name READ name WRITE setName FINAL)
+ Q_PROPERTY(QUrl sourceUrl READ sourceUrl WRITE setSourceUrl FINAL)
+ Q_PROPERTY(QString sourceCode READ sourceCode WRITE setSourceCode FINAL)
+ Q_PROPERTY(InjectionPoint injectionPoint READ injectionPoint WRITE setInjectionPoint FINAL)
+ Q_PROPERTY(quint32 worldId READ worldId WRITE setWorldId FINAL)
+ Q_PROPERTY(bool runsOnSubFrames READ runsOnSubFrames WRITE setRunsOnSubFrames FINAL)
+
public:
+
enum InjectionPoint {
Deferred,
DocumentReady,
DocumentCreation
};
+ Q_ENUM(InjectionPoint)
+
enum ScriptWorldId {
MainWorld = 0,
ApplicationWorld,
UserWorld
};
+ Q_ENUM(ScriptWorldId)
+
QWebEngineScript();
QWebEngineScript(const QWebEngineScript &other);
~QWebEngineScript();
QWebEngineScript &operator=(const QWebEngineScript &other);
- bool isNull() const;
-
QString name() const;
void setName(const QString &);
+ QUrl sourceUrl() const;
+ void setSourceUrl(const QUrl &url);
+
QString sourceCode() const;
void setSourceCode(const QString &);
@@ -93,8 +108,8 @@ public:
{ return !operator==(other); }
void swap(QWebEngineScript &other) { qSwap(d, other.d); }
-
private:
+ friend class QQuickWebEngineScriptCollectionPrivate;
friend class QWebEngineScriptCollectionPrivate;
friend class QWebEngineScriptCollection;
QWebEngineScript(const QtWebEngineCore::UserScript &);
@@ -102,10 +117,10 @@ private:
QSharedDataPointer<QtWebEngineCore::UserScript> d;
};
-Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QWebEngineScript)
+Q_DECLARE_TYPEINFO(QWebEngineScript, Q_MOVABLE_TYPE);
#ifndef QT_NO_DEBUG_STREAM
-QWEBENGINEWIDGETS_EXPORT QDebug operator<<(QDebug, const QWebEngineScript &);
+Q_WEBENGINECORE_EXPORT QDebug operator<<(QDebug, const QWebEngineScript &);
#endif
QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginescriptcollection.cpp b/src/core/api/qwebenginescriptcollection.cpp
index 8cbeeb804..6dfa12c46 100644
--- a/src/webenginewidgets/api/qwebenginescriptcollection.cpp
+++ b/src/core/api/qwebenginescriptcollection.cpp
@@ -46,7 +46,7 @@ using QtWebEngineCore::UserScript;
/*!
\class QWebEngineScriptCollection
- \inmodule QtWebEngineWidgets
+ \inmodule QtWebEngineCore
\since 5.5
\brief The QWebEngineScriptCollection class represents a collection of user scripts.
@@ -103,24 +103,11 @@ bool QWebEngineScriptCollection::contains(const QWebEngineScript &value) const
}
/*!
- * Returns the first script found in the collection with the name \a name, or a null
- * QWebEngineScript if none was found.
- * \note The order in which the script collection is traversed is undefined, which means this should
- * be used when the unicity is guaranteed at the application level.
- * \sa findScripts()
- */
-
-QWebEngineScript QWebEngineScriptCollection::findScript(const QString &name) const
-{
- return d->find(name);
-}
-
-/*!
Returns the list of scripts in the collection with the name \a name, or an empty list if none
was found.
*/
-QList<QWebEngineScript> QWebEngineScriptCollection::findScripts(const QString &name) const
+QList<QWebEngineScript> QWebEngineScriptCollection::find(const QString &name) const
{
return d->toList(name);
}
@@ -187,8 +174,6 @@ bool QWebEngineScriptCollectionPrivate::contains(const QWebEngineScript &s) cons
void QWebEngineScriptCollectionPrivate::insert(const QWebEngineScript &script)
{
- if (!script.d || script.d->isNull())
- return;
m_scripts.append(script);
if (!m_contents || m_contents->isInitialized())
m_scriptController->addUserScript(*script.d, m_contents.data());
@@ -196,8 +181,6 @@ void QWebEngineScriptCollectionPrivate::insert(const QWebEngineScript &script)
bool QWebEngineScriptCollectionPrivate::remove(const QWebEngineScript &script)
{
- if (!script.d || script.d->isNull())
- return false;
if (!m_contents || m_contents->isInitialized())
m_scriptController->removeUserScript(*script.d, m_contents.data());
return m_scripts.removeAll(script);
@@ -215,14 +198,6 @@ QList<QWebEngineScript> QWebEngineScriptCollectionPrivate::toList(const QString
return ret;
}
-QWebEngineScript QWebEngineScriptCollectionPrivate::find(const QString &name) const
-{
- for (const QWebEngineScript &script : qAsConst(m_scripts))
- if (name == script.name())
- return script;
- return QWebEngineScript();
-}
-
void QWebEngineScriptCollectionPrivate::clear()
{
m_scripts.clear();
diff --git a/src/webenginewidgets/api/qwebenginescriptcollection.h b/src/core/api/qwebenginescriptcollection.h
index e68dfce8f..2a1ab7dbf 100644
--- a/src/webenginewidgets/api/qwebenginescriptcollection.h
+++ b/src/core/api/qwebenginescriptcollection.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.
@@ -40,9 +40,8 @@
#ifndef QWEBENGINESCRIPTCOLLECTION_H
#define QWEBENGINESCRIPTCOLLECTION_H
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-#include <QtWebEngineWidgets/qwebenginescript.h>
-
+#include <QtWebEngineCore/qtwebenginecoreglobal.h>
+#include <QtWebEngineCore/qwebenginescript.h>
#include <QtCore/qscopedpointer.h>
#include <QtCore/qlist.h>
#include <QtCore/qset.h>
@@ -50,20 +49,16 @@
QT_BEGIN_NAMESPACE
class QWebEngineScriptCollectionPrivate;
-class QWEBENGINEWIDGETS_EXPORT QWebEngineScriptCollection {
+class Q_WEBENGINECORE_EXPORT QWebEngineScriptCollection {
public:
~QWebEngineScriptCollection();
+
bool isEmpty() const { return !count(); }
int count() const;
- inline int size() const { return count(); }
bool contains(const QWebEngineScript &value) const;
-
- QWebEngineScript findScript(const QString &name) const;
- QList<QWebEngineScript> findScripts(const QString &name) const;
-
+ QList<QWebEngineScript> find(const QString &name) const;
void insert(const QWebEngineScript &);
void insert(const QList<QWebEngineScript> &list);
-
bool remove(const QWebEngineScript &);
void clear();
@@ -73,6 +68,8 @@ private:
Q_DISABLE_COPY(QWebEngineScriptCollection)
friend class QWebEnginePagePrivate;
friend class QWebEngineProfilePrivate;
+ friend class QQuickWebEngineProfilePrivate;
+ friend class QQuickWebEngineViewPrivate;
QWebEngineScriptCollection(QWebEngineScriptCollectionPrivate *);
QScopedPointer<QWebEngineScriptCollectionPrivate> d;
diff --git a/src/webenginewidgets/api/qwebenginescriptcollection_p.h b/src/core/api/qwebenginescriptcollection_p.h
index 322ade3b6..442f8fe3d 100644
--- a/src/webenginewidgets/api/qwebenginescriptcollection_p.h
+++ b/src/core/api/qwebenginescriptcollection_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.
@@ -51,8 +51,7 @@
// We mean it.
//
-#include "qtwebenginewidgetsglobal.h"
-
+#include "qtwebenginecoreglobal.h"
#include "qwebenginescript.h"
#include "web_contents_adapter.h"
@@ -64,17 +63,13 @@ class UserResourceControllerHost;
} // namespace
QT_BEGIN_NAMESPACE
-class QWebEngineScriptCollectionPrivate {
+class Q_WEBENGINECORE_PRIVATE_EXPORT QWebEngineScriptCollectionPrivate {
public:
QWebEngineScriptCollectionPrivate(QtWebEngineCore::UserResourceControllerHost *, QSharedPointer<QtWebEngineCore::WebContentsAdapter> = QSharedPointer<QtWebEngineCore::WebContentsAdapter>());
-
int count() const;
bool contains(const QWebEngineScript &) const;
QList<QWebEngineScript> toList(const QString &scriptName = QString()) const;
- QWebEngineScript find(const QString & name) const;
-
void initializationFinished(QSharedPointer<QtWebEngineCore::WebContentsAdapter> contents);
-
void insert(const QWebEngineScript &);
bool remove(const QWebEngineScript &);
void clear();
diff --git a/src/core/api/qwebenginesettings.cpp b/src/core/api/qwebenginesettings.cpp
new file mode 100644
index 000000000..c7c0a47b2
--- /dev/null
+++ b/src/core/api/qwebenginesettings.cpp
@@ -0,0 +1,142 @@
+/****************************************************************************
+**
+** 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 "qwebenginesettings.h"
+#include "web_engine_settings.h"
+
+QT_BEGIN_NAMESPACE
+
+using QtWebEngineCore::WebEngineSettings;
+
+QWebEngineSettings::QWebEngineSettings(QWebEngineSettings *parentSettings)
+ : d_ptr(new WebEngineSettings(parentSettings ? parentSettings->d_ptr.data() : nullptr))
+{
+ d_ptr->scheduleApplyRecursively();
+}
+
+QWebEngineSettings::~QWebEngineSettings() { }
+
+/*!
+ Returns the settings for a web engine page that belongs to the default
+ profile. All web pages not specifically created with another profile belong
+ to the default profile.
+
+QWebEngineSettings *QWebEngineSettings::defaultSettings()
+{
+ return QWebEngineProfile::defaultProfile()->settings();
+}
+*/
+
+void QWebEngineSettings::setFontFamily(QWebEngineSettings::FontFamily which, const QString &family)
+{
+ d_ptr->setFontFamily(which, family);
+}
+
+QString QWebEngineSettings::fontFamily(QWebEngineSettings::FontFamily which) const
+{
+ return d_ptr->fontFamily(which);
+}
+
+void QWebEngineSettings::resetFontFamily(QWebEngineSettings::FontFamily which)
+{
+ d_ptr->resetFontFamily(which);
+}
+
+void QWebEngineSettings::setFontSize(QWebEngineSettings::FontSize type, int size)
+{
+ d_ptr->setFontSize(type, size);
+}
+
+int QWebEngineSettings::fontSize(QWebEngineSettings::FontSize type) const
+{
+ return d_ptr->fontSize(type);
+}
+
+void QWebEngineSettings::resetFontSize(QWebEngineSettings::FontSize type)
+{
+ d_ptr->resetFontSize(type);
+}
+
+QString QWebEngineSettings::defaultTextEncoding() const
+{
+ return d_ptr->defaultTextEncoding();
+}
+
+QWebEngineSettings::UnknownUrlSchemePolicy QWebEngineSettings::unknownUrlSchemePolicy() const
+{
+ return d_ptr->unknownUrlSchemePolicy();
+}
+
+void QWebEngineSettings::resetUnknownUrlSchemePolicy()
+{
+ d_ptr->setUnknownUrlSchemePolicy(QWebEngineSettings::InheritedUnknownUrlSchemePolicy);
+}
+
+void QWebEngineSettings::setAttribute(QWebEngineSettings::WebAttribute attr, bool on)
+{
+ d_ptr->setAttribute(attr, on);
+}
+
+bool QWebEngineSettings::testAttribute(QWebEngineSettings::WebAttribute attr) const
+{
+ return d_ptr->testAttribute(attr);
+}
+
+void QWebEngineSettings::resetAttribute(QWebEngineSettings::WebAttribute attr)
+{
+ d_ptr->resetAttribute(attr);
+}
+
+void QWebEngineSettings::setDefaultTextEncoding(const QString &encoding)
+{
+ d_ptr->setDefaultTextEncoding(encoding);
+}
+
+void QWebEngineSettings::setUnknownUrlSchemePolicy(
+ QWebEngineSettings::UnknownUrlSchemePolicy policy)
+{
+ d_ptr->setUnknownUrlSchemePolicy(policy);
+}
+
+void QWebEngineSettings::setParentSettings(QWebEngineSettings *parentSettings)
+{
+ d_ptr->setParentSettings(parentSettings->d_ptr.data());
+}
+
+QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginesettings.h b/src/core/api/qwebenginesettings.h
index d39291fed..f565f8ee2 100644
--- a/src/webenginewidgets/api/qwebenginesettings.h
+++ b/src/core/api/qwebenginesettings.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.
@@ -40,7 +40,7 @@
#ifndef QWEBENGINESETTINGS_H
#define QWEBENGINESETTINGS_H
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
+#include <QtWebEngineCore/qtwebenginecoreglobal.h>
#include <QtCore/qscopedpointer.h>
#include <QtCore/qstring.h>
@@ -54,7 +54,7 @@ class QIcon;
class QPixmap;
class QUrl;
-class QWEBENGINEWIDGETS_EXPORT QWebEngineSettings {
+class Q_WEBENGINECORE_EXPORT QWebEngineSettings {
public:
enum FontFamily {
StandardFont,
@@ -65,6 +65,7 @@ public:
FantasyFont,
PictographFont
};
+
enum WebAttribute {
AutoLoadImages,
JavascriptEnabled,
@@ -107,16 +108,16 @@ public:
};
enum UnknownUrlSchemePolicy {
+ InheritedUnknownUrlSchemePolicy = 0, // TODO: hide
DisallowUnknownUrlSchemes = 1,
AllowUnknownUrlSchemesFromUserInteraction,
AllowAllUnknownUrlSchemes
};
-#if QT_DEPRECATED_SINCE(5, 5)
- static QWebEngineSettings *globalSettings();
-#endif
- static QWebEngineSettings *defaultSettings();
-
+ //TODO: see if we still need it
+ //static QWebEngineSettings *defaultSettings();
+public:
+ ~QWebEngineSettings();
void setFontFamily(FontFamily which, const QString &family);
QString fontFamily(FontFamily which) const;
void resetFontFamily(FontFamily which);
@@ -137,16 +138,15 @@ public:
void resetUnknownUrlSchemePolicy();
private:
+ explicit QWebEngineSettings(QWebEngineSettings *parentSettings = nullptr);
+ void setParentSettings(QWebEngineSettings *parentSettings);
Q_DISABLE_COPY(QWebEngineSettings)
typedef ::QtWebEngineCore::WebEngineSettings QWebEngineSettingsPrivate;
- QWebEngineSettingsPrivate* d_func() { return d_ptr.data(); }
- const QWebEngineSettingsPrivate* d_func() const { return d_ptr.data(); }
QScopedPointer<QWebEngineSettingsPrivate> d_ptr;
friend class QWebEnginePagePrivate;
friend class QWebEngineProfilePrivate;
-
- ~QWebEngineSettings();
- explicit QWebEngineSettings(QWebEngineSettings *parentSettings = Q_NULLPTR);
+ friend class QQuickWebEngineSettings;
+ friend class QtWebEngineCore::WebEngineSettings;
};
QT_END_NAMESPACE
diff --git a/src/core/api/qwebengineurlrequestinfo.cpp b/src/core/api/qwebengineurlrequestinfo.cpp
index 040305f66..10661ec8f 100644
--- a/src/core/api/qwebengineurlrequestinfo.cpp
+++ b/src/core/api/qwebengineurlrequestinfo.cpp
@@ -87,7 +87,7 @@ ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::RedirectNavigation
*/
/*!
- \fn QWebEngineUrlRequestInterceptor::QWebEngineUrlRequestInterceptor(QObject * p = 0)
+ \fn QWebEngineUrlRequestInterceptor::QWebEngineUrlRequestInterceptor(QObject *p = nullptr)
Creates a new QWebEngineUrlRequestInterceptor object with \a p as parent.
*/
diff --git a/src/core/browser_accessibility_manager_qt.cpp b/src/core/browser_accessibility_manager_qt.cpp
index 1d635a6e9..2d1d9f1ae 100644
--- a/src/core/browser_accessibility_manager_qt.cpp
+++ b/src/core/browser_accessibility_manager_qt.cpp
@@ -151,7 +151,7 @@ void BrowserAccessibilityManagerQt::FireGeneratedEvent(ui::AXEventGenerator::Eve
BrowserAccessibilityQt *iface = static_cast<BrowserAccessibilityQt*>(node);
switch (event_type) {
- case ui::AXEventGenerator::Event::VALUE_CHANGED:
+ case ui::AXEventGenerator::Event::VALUE_IN_TEXT_FIELD_CHANGED:
if (iface->role() == QAccessible::EditableText) {
QAccessibleTextUpdateEvent event(iface, -1, QString(), QString());
QAccessible::updateAccessibility(&event);
diff --git a/src/core/browser_accessibility_manager_qt.h b/src/core/browser_accessibility_manager_qt.h
index 600ad673c..2a1d273b9 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/browser_accessibility_qt.cpp b/src/core/browser_accessibility_qt.cpp
index fabad0609..eb2cf64f0 100644
--- a/src/core/browser_accessibility_qt.cpp
+++ b/src/core/browser_accessibility_qt.cpp
@@ -334,6 +334,11 @@ QAccessible::Role BrowserAccessibilityQt::role() const
case ax::mojom::Role::kDocIndex:
case ax::mojom::Role::kDocIntroduction:
case ax::mojom::Role::kDocNotice:
+ return QAccessible::Section;
+ case ax::mojom::Role::kDocPageFooter:
+ return QAccessible::Footer;
+ case ax::mojom::Role::kDocPageHeader:
+ return QAccessible::Heading;
case ax::mojom::Role::kDocPageList:
case ax::mojom::Role::kDocPart:
case ax::mojom::Role::kDocPreface:
@@ -359,7 +364,8 @@ QAccessible::Role BrowserAccessibilityQt::role() const
case ax::mojom::Role::kFigure:
return QAccessible::Section;
case ax::mojom::Role::kFooter:
- return QAccessible::Footer;
+ // CORE-AAM recommends LANDMARK instead of FOOTER.
+ return QAccessible::Section;
case ax::mojom::Role::kFooterAsNonLandmark:
return QAccessible::Section;
case ax::mojom::Role::kForm:
diff --git a/src/core/browser_message_filter_qt.cpp b/src/core/browser_message_filter_qt.cpp
index 54d6551e4..500644593 100644
--- a/src/core/browser_message_filter_qt.cpp
+++ b/src/core/browser_message_filter_qt.cpp
@@ -56,11 +56,6 @@ BrowserMessageFilterQt::BrowserMessageFilterQt(int /*render_process_id*/, Profil
{
}
-// The following is based on chrome/browser/plugins/plugin_info_message_filter.cc:
-// 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.
-
bool BrowserMessageFilterQt::OnMessageReceived(const IPC::Message& message)
{
IPC_BEGIN_MESSAGE_MAP(BrowserMessageFilterQt, message)
diff --git a/src/core/certificate_error_controller.cpp b/src/core/certificate_error_controller.cpp
index d9043bf8e..0c0137ca4 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,136 @@
#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_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::SslObsoleteVersion, net::ERR_SSL_OBSOLETE_VERSION)
-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::SslObsoleteVersion,
+ net::ERR_SSL_OBSOLETE_VERSION)
+// 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_NO_REVOCATION_MECHANISM:
+ case net::ERR_CERT_UNABLE_TO_CHECK_REVOCATION:
+ 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:
+ case net::ERR_CERT_KNOWN_INTERCEPTION_BLOCKED:
+ case net::ERR_SSL_OBSOLETE_VERSION:
+ return false;
+ case net::ERR_CERT_CONTAINS_ERRORS:
+ case net::ERR_CERT_REVOKED:
+ case net::ERR_CERT_INVALID:
+ 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,43 +189,43 @@ 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_DESCRIPTION);
- 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 SslObsoleteVersion:
+ case QWebEngineCertificateError::SslObsoleteVersion:
return getQStringForMessageId(IDS_SSL_ERROR_OBSOLETE_VERSION_DESCRIPTION);
- case CertificateUnableToCheckRevocation: // Deprecated in Chromium.
+ case QWebEngineCertificateError::CertificateUnableToCheckRevocation: // Deprecated in Chromium.
default:
break;
}
@@ -194,7 +235,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 740f7a9d4..ec3e26806 100644
--- a/src/core/certificate_error_controller.h
+++ b/src/core/certificate_error_controller.h
@@ -52,84 +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,
- SslObsoleteVersion = -218,
- CertificateErrorEnd = -219 // 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/chromium_overrides.cpp b/src/core/chromium_overrides.cpp
index 8a385e4a8..6783175fe 100644
--- a/src/core/chromium_overrides.cpp
+++ b/src/core/chromium_overrides.cpp
@@ -111,8 +111,7 @@ std::unique_ptr<base::ListValue> GetFontList_SlowBlocking()
{
std::unique_ptr<base::ListValue> font_list(new base::ListValue);
- QFontDatabase database;
- for (auto family : database.families()){
+ for (auto family : QFontDatabase::families()){
std::unique_ptr<base::ListValue> font_item(new base::ListValue());
font_item->AppendString(family.toStdString());
font_item->AppendString(family.toStdString()); // localized name.
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/clipboard_qt.cpp b/src/core/clipboard_qt.cpp
index 65e3e90ac..ca222813d 100644
--- a/src/core/clipboard_qt.cpp
+++ b/src/core/clipboard_qt.cpp
@@ -51,7 +51,6 @@
#include "ui/base/clipboard/custom_data_helper.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/clipboard_constants.h"
-#include "ui/base/clipboard/clipboard_data_endpoint.h"
#include "ui/base/clipboard/clipboard_format_type.h"
#include <QGuiApplication>
@@ -107,7 +106,7 @@ Clipboard *Clipboard::Create()
namespace QtWebEngineCore {
-void ClipboardQt::WritePortableRepresentations(ui::ClipboardBuffer type, const ObjectMap &objects, std::unique_ptr<ui::ClipboardDataEndpoint> data_src)
+void ClipboardQt::WritePortableRepresentations(ui::ClipboardBuffer type, const ObjectMap &objects, std::unique_ptr<ui::DataTransferEndpoint> data_src)
{
DCHECK(CalledOnValidThread());
DCHECK(IsSupportedClipboardBuffer(type));
@@ -134,7 +133,7 @@ void ClipboardQt::WritePortableRepresentations(ui::ClipboardBuffer type, const O
void ClipboardQt::WritePlatformRepresentations(ui::ClipboardBuffer buffer,
std::vector<ui::Clipboard::PlatformRepresentation> platform_representations,
- std::unique_ptr<ui::ClipboardDataEndpoint> data_src)
+ std::unique_ptr<ui::DataTransferEndpoint> data_src)
{
DCHECK(CalledOnValidThread());
DCHECK(IsSupportedClipboardBuffer(buffer));
@@ -194,7 +193,7 @@ void ClipboardQt::WriteData(const ui::ClipboardFormatType &format, const char *d
bool ClipboardQt::IsFormatAvailable(const ui::ClipboardFormatType &format,
ui::ClipboardBuffer type,
- const ui::ClipboardDataEndpoint *data_dst) const
+ const ui::DataTransferEndpoint *data_dst) const
{
const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData(
type == ui::ClipboardBuffer::kCopyPaste ? QClipboard::Clipboard : QClipboard::Selection);
@@ -208,7 +207,7 @@ void ClipboardQt::Clear(ui::ClipboardBuffer type)
}
void ClipboardQt::ReadAvailableTypes(ui::ClipboardBuffer type,
- const ui::ClipboardDataEndpoint *data_dst,
+ const ui::DataTransferEndpoint *data_dst,
std::vector<base::string16> *types) const
{
if (!types) {
@@ -232,7 +231,7 @@ void ClipboardQt::ReadAvailableTypes(ui::ClipboardBuffer type,
}
void ClipboardQt::ReadText(ui::ClipboardBuffer type,
- const ui::ClipboardDataEndpoint *data_dst,
+ const ui::DataTransferEndpoint *data_dst,
base::string16 *result) const
{
const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData(
@@ -242,7 +241,7 @@ void ClipboardQt::ReadText(ui::ClipboardBuffer type,
}
void ClipboardQt::ReadAsciiText(ui::ClipboardBuffer type,
- const ui::ClipboardDataEndpoint *data_dst,
+ const ui::DataTransferEndpoint *data_dst,
std::string *result) const
{
const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData(
@@ -252,7 +251,7 @@ void ClipboardQt::ReadAsciiText(ui::ClipboardBuffer type,
}
void ClipboardQt::ReadHTML(ui::ClipboardBuffer type,
- const ui::ClipboardDataEndpoint *data_dst,
+ const ui::DataTransferEndpoint *data_dst,
base::string16 *markup, std::string *src_url,
uint32_t *fragment_start, uint32_t *fragment_end) const
{
@@ -271,7 +270,7 @@ void ClipboardQt::ReadHTML(ui::ClipboardBuffer type,
}
void ClipboardQt::ReadRTF(ui::ClipboardBuffer type,
- const ui::ClipboardDataEndpoint *data_dst,
+ const ui::DataTransferEndpoint *data_dst,
std::string *result) const
{
const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData(
@@ -283,7 +282,7 @@ void ClipboardQt::ReadRTF(ui::ClipboardBuffer type,
}
void ClipboardQt::ReadImage(ui::ClipboardBuffer type,
- const ui::ClipboardDataEndpoint *data_dst,
+ const ui::DataTransferEndpoint *data_dst,
ReadImageCallback callback) const
{
const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData(
@@ -311,7 +310,7 @@ void ClipboardQt::ReadImage(ui::ClipboardBuffer type,
}
void ClipboardQt::ReadCustomData(ui::ClipboardBuffer clipboard_type, const base::string16 &type,
- const ui::ClipboardDataEndpoint *data_dst,
+ const ui::DataTransferEndpoint *data_dst,
base::string16 *result) const
{
const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData(
@@ -322,13 +321,13 @@ void ClipboardQt::ReadCustomData(ui::ClipboardBuffer clipboard_type, const base:
ui::ReadCustomDataForType(customData.constData(), customData.size(), type, result);
}
-void ClipboardQt::ReadBookmark(const ui::ClipboardDataEndpoint *data_dst, base::string16 *title, std::string *url) const
+void ClipboardQt::ReadBookmark(const ui::DataTransferEndpoint *data_dst, base::string16 *title, std::string *url) const
{
NOTIMPLEMENTED();
}
void ClipboardQt::ReadSvg(ui::ClipboardBuffer clipboard_type,
- const ui::ClipboardDataEndpoint *,
+ const ui::DataTransferEndpoint *,
base::string16 *result) const
{
const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData(
@@ -347,7 +346,7 @@ void ClipboardQt::WriteSvg(const char *svg_data, size_t data_len)
}
void ClipboardQt::ReadData(const ui::ClipboardFormatType &format,
- const ui::ClipboardDataEndpoint *data_dst,
+ const ui::DataTransferEndpoint *data_dst,
std::string *result) const
{
const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData();
@@ -371,7 +370,7 @@ bool ClipboardQt::IsSelectionBufferAvailable() const
}
#endif
-std::vector<base::string16> ClipboardQt::ReadAvailablePlatformSpecificFormatNames(ui::ClipboardBuffer buffer, const ui::ClipboardDataEndpoint *data_dst) const
+std::vector<base::string16> ClipboardQt::ReadAvailablePlatformSpecificFormatNames(ui::ClipboardBuffer buffer, const ui::DataTransferEndpoint *data_dst) const
{
// based on ClipboardAura
std::vector<base::string16> types;
diff --git a/src/core/clipboard_qt.h b/src/core/clipboard_qt.h
index b4c9d4c7d..e313f7de8 100644
--- a/src/core/clipboard_qt.h
+++ b/src/core/clipboard_qt.h
@@ -50,37 +50,37 @@ public:
uint64_t GetSequenceNumber(ui::ClipboardBuffer type) const override;
bool IsFormatAvailable(const ui::ClipboardFormatType &format,
ui::ClipboardBuffer buffer,
- const ui::ClipboardDataEndpoint *data_dst) const override;
+ const ui::DataTransferEndpoint *data_dst) const override;
void Clear(ui::ClipboardBuffer type) override;
void ReadAvailableTypes(ui::ClipboardBuffer type,
- const ui::ClipboardDataEndpoint *data_dst,
+ const ui::DataTransferEndpoint *data_dst,
std::vector<base::string16> *types) const override;
- void ReadText(ui::ClipboardBuffer type, const ui::ClipboardDataEndpoint *data_dst, base::string16 *result) const override;
- void ReadAsciiText(ui::ClipboardBuffer type, const ui::ClipboardDataEndpoint *data_dst, std::string *result) const override;
- void ReadHTML(ui::ClipboardBuffer type, const ui::ClipboardDataEndpoint *data_dst, base::string16 *markup, std::string *src_url, uint32_t *fragment_start,
+ void ReadText(ui::ClipboardBuffer type, const ui::DataTransferEndpoint *data_dst, base::string16 *result) const override;
+ void ReadAsciiText(ui::ClipboardBuffer type, const ui::DataTransferEndpoint *data_dst, std::string *result) const override;
+ void ReadHTML(ui::ClipboardBuffer type, const ui::DataTransferEndpoint *data_dst, base::string16 *markup, std::string *src_url, uint32_t *fragment_start,
uint32_t *fragment_end) const override;
- void ReadRTF(ui::ClipboardBuffer type, const ui::ClipboardDataEndpoint *data_dst, std::string *result) const override;
- void ReadImage(ui::ClipboardBuffer buffer, const ui::ClipboardDataEndpoint *data_dst, ReadImageCallback callback) const override;
- void ReadCustomData(ui::ClipboardBuffer clipboard_type, const base::string16 &type, const ui::ClipboardDataEndpoint *data_dst, base::string16 *result) const override;
- void ReadBookmark(const ui::ClipboardDataEndpoint *data_dst, base::string16 *title, std::string *url) const override;
- void ReadData(const ui::ClipboardFormatType &format, const ui::ClipboardDataEndpoint *data_dst, std::string *result) const override;
+ void ReadRTF(ui::ClipboardBuffer type, const ui::DataTransferEndpoint *data_dst, std::string *result) const override;
+ void ReadImage(ui::ClipboardBuffer buffer, const ui::DataTransferEndpoint *data_dst, ReadImageCallback callback) const override;
+ void ReadCustomData(ui::ClipboardBuffer clipboard_type, const base::string16 &type, const ui::DataTransferEndpoint *data_dst, base::string16 *result) const override;
+ void ReadBookmark(const ui::DataTransferEndpoint *data_dst, base::string16 *title, std::string *url) const override;
+ void ReadData(const ui::ClipboardFormatType &format, const ui::DataTransferEndpoint *data_dst, std::string *result) const override;
#if defined(USE_OZONE)
bool IsSelectionBufferAvailable() const override;
#endif
void OnPreShutdown() override {}
- void ReadSvg(ui::ClipboardBuffer, const ui::ClipboardDataEndpoint *, base::string16 *) const override;
+ void ReadSvg(ui::ClipboardBuffer, const ui::DataTransferEndpoint *, base::string16 *) const override;
void WriteSvg(const char *, size_t) override;
- std::vector<base::string16> ReadAvailablePlatformSpecificFormatNames(ui::ClipboardBuffer buffer, const ui::ClipboardDataEndpoint *data_dst) const override;
+ std::vector<base::string16> ReadAvailablePlatformSpecificFormatNames(ui::ClipboardBuffer buffer, const ui::DataTransferEndpoint *data_dst) const override;
protected:
void WritePortableRepresentations(
ui::ClipboardBuffer buffer,
const ObjectMap &objects,
- std::unique_ptr<ui::ClipboardDataEndpoint> data_src) override;
+ std::unique_ptr<ui::DataTransferEndpoint> data_src) override;
void WritePlatformRepresentations(
ui::ClipboardBuffer buffer,
std::vector<Clipboard::PlatformRepresentation> platform_representations,
- std::unique_ptr<ui::ClipboardDataEndpoint> data_src) override;
+ std::unique_ptr<ui::DataTransferEndpoint> data_src) override;
void WriteText(const char *text_data, size_t text_len) override;
void WriteHTML(const char *markup_data, size_t markup_len, const char *url_data, size_t url_len) override;
void WriteRTF(const char *rtf_data, size_t data_len) override;
diff --git a/src/core/compositor/compositor.cpp b/src/core/compositor/compositor.cpp
new file mode 100644
index 000000000..655126f20
--- /dev/null
+++ b/src/core/compositor/compositor.cpp
@@ -0,0 +1,197 @@
+/****************************************************************************
+**
+** 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 "compositor.h"
+
+#include "base/memory/ref_counted.h"
+#include "components/viz/common/surfaces/frame_sink_id.h"
+
+#include <QHash>
+#include <QImage>
+#include <QMutex>
+
+namespace QtWebEngineCore {
+
+// Compositor::Id
+
+Compositor::Id::Id(viz::FrameSinkId fid) : client_id(fid.client_id()), sink_id(fid.sink_id()) { }
+
+static size_t qHash(Compositor::Id id, size_t seed = 0)
+{
+ QtPrivate::QHashCombine hasher;
+ seed = hasher(seed, id.client_id);
+ seed = hasher(seed, id.sink_id);
+ return seed;
+}
+
+static bool operator==(Compositor::Id id1, Compositor::Id id2)
+{
+ return id1.client_id == id2.client_id && id1.sink_id == id2.sink_id;
+}
+
+// Compositor::Binding and Compositor::Bindings
+
+struct Compositor::Binding
+{
+ const Id id;
+ Compositor *compositor = nullptr;
+ Observer *observer = nullptr;
+
+ Binding(Id id) : id(id) { }
+ ~Binding();
+};
+
+class Compositor::BindingMap
+{
+public:
+ void lock() { m_mutex.lock(); }
+
+ void unlock() { m_mutex.unlock(); }
+
+ 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;
+ }
+
+ void remove(Id id) { m_map.remove(id); }
+
+private:
+ QMutex m_mutex;
+ QHash<Id, Binding *> m_map;
+} static g_bindings;
+
+Compositor::Binding::~Binding()
+{
+ g_bindings.remove(id);
+}
+
+// Compositor::Observer
+
+void Compositor::Observer::bind(Id id)
+{
+ DCHECK(!m_binding);
+ g_bindings.lock();
+ m_binding = g_bindings.findOrCreate(id);
+ DCHECK(!m_binding->observer);
+ m_binding->observer = this;
+ g_bindings.unlock();
+}
+
+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();
+}
+
+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;
+}
+
+// Compositor
+
+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::unbind()
+{
+ DCHECK(m_binding);
+ g_bindings.lock();
+ m_binding->compositor = nullptr;
+ if (m_binding->observer == nullptr)
+ delete m_binding;
+ m_binding = nullptr;
+ g_bindings.unlock();
+}
+
+Compositor::Handle<Compositor::Observer> Compositor::observer()
+{
+ if (!m_binding)
+ return nullptr;
+ g_bindings.lock();
+ if (m_binding->observer)
+ return m_binding->observer; // delay unlock
+ g_bindings.unlock();
+ return nullptr;
+}
+
+QImage Compositor::image()
+{
+ Q_UNREACHABLE();
+ return {};
+}
+
+void Compositor::waitForTexture()
+{
+ Q_UNREACHABLE();
+}
+
+int Compositor::textureId()
+{
+ 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
new file mode 100644
index 000000000..316178891
--- /dev/null
+++ b/src/core/compositor/compositor.h
@@ -0,0 +1,195 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#ifndef COMPOSITOR_H
+#define COMPOSITOR_H
+
+#include "qtwebenginecoreglobal_p.h"
+
+QT_BEGIN_NAMESPACE
+class QImage;
+class QSize;
+QT_END_NAMESPACE
+
+namespace viz {
+class FrameSinkId;
+} // namespace viz
+
+namespace QtWebEngineCore {
+
+// Produces composited frames for display.
+//
+// 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:
+ // 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;
+
+private:
+ template<typename T>
+ friend class Handle;
+
+ class BindingMap;
+ static void unlockBindings();
+
+ const Type m_type;
+ Binding *m_binding = nullptr;
+};
+
+} // namespace QtWebEngineCore
+
+#endif // !COMPOSITOR_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 370eb07e6..b44a08452 100644
--- a/src/core/compositor/display_gl_output_surface.cpp
+++ b/src/core/compositor/display_gl_output_surface.cpp
@@ -39,6 +39,8 @@
#include "display_gl_output_surface.h"
+#include "type_conversion.h"
+
#include "base/threading/thread_task_runner_handle.h"
#include "components/viz/service/display/display.h"
#include "components/viz/service/display/output_surface_frame.h"
@@ -51,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)
@@ -63,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 +215,8 @@ void DisplayGLOutputSurface::swapBuffersOnGpuThread(unsigned int id, std::unique
m_readyToUpdate = true;
}
- m_sink->scheduleUpdate();
+ if (auto obs = observer())
+ obs->readyToSwap();
}
void DisplayGLOutputSurface::swapBuffersOnVizThread()
@@ -276,28 +279,59 @@ unsigned DisplayGLOutputSurface::UpdateGpuFence()
return 0;
}
-scoped_refptr<gpu::GpuTaskSchedulerHelper> DisplayGLOutputSurface::GetGpuTaskSchedulerHelper()
+void DisplayGLOutputSurface::SetUpdateVSyncParametersCallback(viz::UpdateVSyncParametersCallback callback)
{
- return m_vizContextProvider->GetGpuTaskSchedulerHelper();
+ m_vizContextProvider->SetUpdateVSyncParametersCallback(std::move(callback));
}
-gpu::MemoryTracker *DisplayGLOutputSurface::GetMemoryTracker()
+void DisplayGLOutputSurface::SetDisplayTransformHint(gfx::OverlayTransform)
{
- return m_vizContextProvider->GetMemoryTracker();
}
-void DisplayGLOutputSurface::SetUpdateVSyncParametersCallback(viz::UpdateVSyncParametersCallback callback)
+gfx::OverlayTransform DisplayGLOutputSurface::GetDisplayTransform()
{
- m_vizContextProvider->SetUpdateVSyncParametersCallback(std::move(callback));
+ return gfx::OVERLAY_TRANSFORM_NONE;
}
-void DisplayGLOutputSurface::SetDisplayTransformHint(gfx::OverlayTransform)
+void DisplayGLOutputSurface::swapFrame()
{
+ QMutexLocker locker(&m_mutex);
+ if (m_readyToUpdate) {
+ std::swap(m_middleBuffer, m_frontBuffer);
+ m_taskRunner->PostTask(FROM_HERE,
+ base::BindOnce(&DisplayGLOutputSurface::swapBuffersOnVizThread,
+ base::Unretained(this)));
+ m_taskRunner.reset();
+ m_readyToUpdate = false;
+ }
}
-gfx::OverlayTransform DisplayGLOutputSurface::GetDisplayTransform()
+void DisplayGLOutputSurface::waitForTexture()
{
- return gfx::OVERLAY_TRANSFORM_NONE;
+ 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 d2e203b4e..71856e70b 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);
@@ -85,11 +85,14 @@ public:
void SetUpdateVSyncParametersCallback(viz::UpdateVSyncParametersCallback callback) override;
void SetDisplayTransformHint(gfx::OverlayTransform transform) override;
gfx::OverlayTransform GetDisplayTransform() override;
- scoped_refptr<gpu::GpuTaskSchedulerHelper> GetGpuTaskSchedulerHelper() override;
- gpu::MemoryTracker *GetMemoryTracker() 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
@@ -136,7 +139,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 0e9fff6e3..000000000
--- a/src/core/compositor/display_gl_output_surface_qsg.cpp
+++ /dev/null
@@ -1,122 +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_readyToUpdate) {
- std::swap(m_middleBuffer, m_frontBuffer);
- m_taskRunner->PostTask(
- FROM_HERE,
- base::BindOnce(&DisplayGLOutputSurface::swapBuffersOnVizThread, base::Unretained(this)));
- m_taskRunner.reset();
- m_readyToUpdate = false;
- }
- }
-
- 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/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index 24aa19c91..d68cad2b0 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -45,6 +45,8 @@
#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
#include "chrome/browser/tab_contents/form_interaction_tab_helper.h"
+#include "components/error_page/common/error.h"
+#include "components/error_page/common/localized_error.h"
#include "components/navigation_interception/intercept_navigation_throttle.h"
#include "components/navigation_interception/navigation_params.h"
#include "components/network_hints/browser/simple_network_hints_handler_impl.h"
@@ -78,10 +80,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/browser/qtwebengine_content_browser_overlay_manifest.h"
@@ -93,7 +91,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"
@@ -103,6 +100,7 @@
#include "net/proxying_restricted_cookie_manager_qt.h"
#include "net/proxying_url_loader_factory_qt.h"
#include "net/system_network_context_manager.h"
+#include "ozone/gl_share_context_qt.h"
#include "platform_notification_service_qt.h"
#include "profile_qt.h"
#include "profile_io_data_qt.h"
@@ -172,11 +170,6 @@
#include "net/plugin_response_interceptor_url_loader_throttle.h"
#endif
-#if BUILDFLAG(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS)
-#include "media/mojo/interfaces/constants.mojom.h"
-#include "media/mojo/services/media_service_factory.h"
-#endif
-
#include <QGuiApplication>
#include <QStandardPaths>
#include <qpa/qplatformnativeinterface.h>
@@ -231,93 +224,6 @@ void MaybeAddThrottle(
throttles->push_back(std::move(maybe_throttle));
}
-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 CheckStickyGraphicsResetStatusImpl() 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 MakeCurrentImpl(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 +272,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()
@@ -398,55 +304,18 @@ scoped_refptr<content::QuotaPermissionContext> ContentBrowserClientQt::CreateQuo
return new QuotaPermissionContextQt;
}
-// 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_NO_REVOCATION_MECHANISM:
- case net::ERR_CERT_UNABLE_TO_CHECK_REVOCATION:
- 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:
- case net::ERR_CERT_KNOWN_INTERCEPTION_BLOCKED:
- case net::ERR_SSL_OBSOLETE_VERSION:
- return false;
- case net::ERR_CERT_CONTAINS_ERRORS:
- case net::ERR_CERT_REVOKED:
- case net::ERR_CERT_INVALID:
- 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);
}
@@ -682,13 +551,6 @@ void ContentBrowserClientQt::ExposeInterfacesToRenderer(service_manager::BinderR
void ContentBrowserClientQt::RunServiceInstance(const service_manager::Identity &identity,
mojo::PendingReceiver<service_manager::mojom::Service> *receiver)
{
-#if BUILDFLAG(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS)
- if (identity.name() == media::mojom::kMediaServiceName) {
- service_manager::Service::RunAsyncUntilTermination(media::CreateMediaService(std::move(*receiver)));
- return;
- }
-#endif
-
content::ContentBrowserClient::RunServiceInstance(identity, receiver);
}
@@ -797,26 +659,11 @@ bool ContentBrowserClientQt::AllowAppCache(const GURL &manifest_url,
}
content::AllowServiceWorkerResult
-ContentBrowserClientQt::AllowServiceWorkerOnIO(const GURL &scope,
- const GURL &site_for_cookies,
- const base::Optional<url::Origin> & /*top_frame_origin*/,
- const GURL & /*script_url*/,
- content::ResourceContext *context)
-{
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- // FIXME: Chrome also checks if javascript is enabled here to check if has been disabled since the service worker
- // was started.
- return ProfileIODataQt::FromResourceContext(context)->canGetCookies(toQt(site_for_cookies), toQt(scope))
- ? content::AllowServiceWorkerResult::Yes()
- : content::AllowServiceWorkerResult::No();
-}
-
-content::AllowServiceWorkerResult
-ContentBrowserClientQt::AllowServiceWorkerOnUI(const GURL &scope,
- const GURL &site_for_cookies,
- const base::Optional<url::Origin> & /*top_frame_origin*/,
- const GURL & /*script_url*/,
- content::BrowserContext *context)
+ContentBrowserClientQt::AllowServiceWorker(const GURL &scope,
+ const GURL &site_for_cookies,
+ const base::Optional<url::Origin> & /*top_frame_origin*/,
+ const GURL & /*script_url*/,
+ content::BrowserContext *context)
{
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (!context || context->ShutdownStarted())
@@ -1034,6 +881,21 @@ bool ContentBrowserClientQt::IsHandledURL(const GURL &url)
return url::IsHandledProtocol(url.scheme());
}
+bool ContentBrowserClientQt::HasErrorPage(int httpStatusCode, content::WebContents *contents)
+{
+ if (contents) {
+ WebEngineSettings *settings = nullptr;
+ WebContentsDelegateQt *delegate =
+ static_cast<WebContentsDelegateQt*>(contents->GetDelegate());
+ if (delegate)
+ settings = delegate->webEngineSettings();
+ if (settings && !settings->testAttribute(QWebEngineSettings::ErrorPageEnabled))
+ return false;
+ }
+ // Use an internal error page, if we have one for the status code.
+ return error_page::LocalizedError::HasStrings(error_page::Error::kHttpErrorDomain, httpStatusCode);
+}
+
std::unique_ptr<content::LoginDelegate> ContentBrowserClientQt::CreateLoginDelegate(
const net::AuthChallengeInfo &authInfo,
content::WebContents *web_contents,
@@ -1168,16 +1030,14 @@ void ContentBrowserClientQt::ConfigureNetworkContextParams(
std::vector<base::FilePath> ContentBrowserClientQt::GetNetworkContextsParentDirectory()
{
return {
- toFilePath(QStandardPaths::writableLocation(QStandardPaths::DataLocation)),
+ toFilePath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)),
toFilePath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)) };
}
void ContentBrowserClientQt::RegisterNonNetworkNavigationURLLoaderFactories(int frame_tree_node_id,
- base::UkmSourceId ukm_source_id,
- NonNetworkURLLoaderFactoryDeprecatedMap *uniquely_owned_factories,
+ ukm::SourceIdObj ukm_source_id,
NonNetworkURLLoaderFactoryMap *factories)
{
- Q_UNUSED(uniquely_owned_factories);
content::WebContents *web_contents = content::WebContents::FromFrameTreeNodeId(frame_tree_node_id);
Profile *profile = Profile::FromBrowserContext(web_contents->GetBrowserContext());
ProfileAdapter *profileAdapter = static_cast<ProfileQt *>(profile)->profileAdapter();
@@ -1222,10 +1082,8 @@ void ContentBrowserClientQt::RegisterNonNetworkServiceWorkerUpdateURLLoaderFacto
}
void ContentBrowserClientQt::RegisterNonNetworkSubresourceURLLoaderFactories(int render_process_id, int render_frame_id,
- NonNetworkURLLoaderFactoryDeprecatedMap *uniquely_owned_factories,
NonNetworkURLLoaderFactoryMap *factories)
{
- Q_UNUSED(uniquely_owned_factories);
content::RenderProcessHost *process_host = content::RenderProcessHost::FromID(render_process_id);
Profile *profile = Profile::FromBrowserContext(process_host->GetBrowserContext());
ProfileAdapter *profileAdapter = static_cast<ProfileQt *>(profile)->profileAdapter();
@@ -1248,7 +1106,7 @@ void ContentBrowserClientQt::RegisterNonNetworkSubresourceURLLoaderFactories(int
#endif
if (!install_file_scheme && web_contents) {
const auto *settings = static_cast<WebContentsDelegateQt *>(web_contents->GetDelegate())->webEngineSettings();
- if (settings->testAttribute(WebEngineSettings::LocalContentCanAccessFileUrls)) {
+ if (settings->testAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls)) {
for (const auto &local_scheme : url::GetLocalSchemes()) {
if (url.SchemeIs(local_scheme)) {
install_file_scheme = true;
@@ -1332,7 +1190,7 @@ bool ContentBrowserClientQt::WillCreateURLLoaderFactory(
URLLoaderFactoryType type,
const url::Origin &request_initiator,
base::Optional<int64_t> navigation_id,
- base::UkmSourceId ukm_source_id,
+ ukm::SourceIdObj ukm_source_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory> *factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient> *header_client,
bool *bypass_redirect_checks,
diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h
index 7c8aa3ac9..bac155c8c 100644
--- a/src/core/content_browser_client_qt.h
+++ b/src/core/content_browser_client_qt.h
@@ -66,7 +66,7 @@ class GLShareGroup;
namespace QtWebEngineCore {
-class ShareGroupQtQuick;
+class ShareGroupQt;
class ContentBrowserClientQt : public content::ContentBrowserClient
{
@@ -145,13 +145,7 @@ public:
const GURL &first_party,
const base::Optional<url::Origin> &top_frame_origin,
content::BrowserContext *context) override;
- content::AllowServiceWorkerResult AllowServiceWorkerOnIO(
- const GURL &scope,
- const GURL &site_for_cookies,
- const base::Optional<url::Origin> &top_frame_origin,
- const GURL &script_url,
- content::ResourceContext *context) override;
- content::AllowServiceWorkerResult AllowServiceWorkerOnUI(
+ content::AllowServiceWorkerResult AllowServiceWorker(
const GURL &scope,
const GURL &site_for_cookies,
const base::Optional<url::Origin> &top_frame_origin,
@@ -223,6 +217,7 @@ public:
content::NavigationHandle *navigation_handle) override;
bool IsHandledURL(const GURL &url) override;
+ bool HasErrorPage(int http_status_code, content::WebContents *contents) override;
bool WillCreateURLLoaderFactory(content::BrowserContext *browser_context,
content::RenderFrameHost *frame,
@@ -230,7 +225,7 @@ public:
URLLoaderFactoryType type,
const url::Origin &request_initiator,
base::Optional<int64_t> navigation_id,
- base::UkmSourceId ukm_source_id,
+ ukm::SourceIdObj ukm_source_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory> *factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient> *header_client,
bool *bypass_redirect_checks,
@@ -246,11 +241,10 @@ public:
network::mojom::CertVerifierCreationParams *cert_verifier_creation_params) override;
std::vector<base::FilePath> GetNetworkContextsParentDirectory() override;
- void RegisterNonNetworkNavigationURLLoaderFactories(int frame_tree_node_id, base::UkmSourceId ukm_source_id,
- NonNetworkURLLoaderFactoryDeprecatedMap *uniquely_owned_factories,
+ void RegisterNonNetworkNavigationURLLoaderFactories(int frame_tree_node_id,
+ ukm::SourceIdObj ukm_source_id,
NonNetworkURLLoaderFactoryMap *factories) override;
void RegisterNonNetworkSubresourceURLLoaderFactories(int render_process_id, int render_frame_id,
- NonNetworkURLLoaderFactoryDeprecatedMap *uniquely_owned_factories,
NonNetworkURLLoaderFactoryMap *factories) override;
void RegisterNonNetworkWorkerMainResourceURLLoaderFactories(content::BrowserContext* browser_context,
NonNetworkURLLoaderFactoryMap* factories) override;
@@ -268,7 +262,7 @@ public:
std::string GetProduct() override;
private:
- scoped_refptr<ShareGroupQtQuick> m_shareGroupQtQuick;
+ scoped_refptr<ShareGroupQt> m_shareGroupQt;
};
} // namespace QtWebEngineCore
diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp
index 560cdbf54..36f4e380d 100644
--- a/src/core/content_client_qt.cpp
+++ b/src/core/content_client_qt.cpp
@@ -135,12 +135,6 @@ static QString getProgramFilesDir(bool x86Dir = false)
#include "content/public/common/pepper_plugin_info.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
-static const int32_t kPepperFlashPermissions = ppapi::PERMISSION_DEV |
- ppapi::PERMISSION_PRIVATE |
- ppapi::PERMISSION_BYPASS_USER_GESTURE |
- ppapi::PERMISSION_FLASH |
- ppapi::PERMISSION_SOCKET;
-
namespace switches {
const char kPpapiFlashPath[] = "ppapi-flash-path";
const char kPpapiFlashVersion[] = "ppapi-flash-version";
@@ -160,95 +154,6 @@ static QString ppapiPluginsPath()
return potentialPluginsPath;
}
-
-content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, const std::string& version)
-{
- content::PepperPluginInfo plugin;
-
- plugin.is_out_of_process = true;
- plugin.name = content::kFlashPluginName;
- plugin.path = path;
- plugin.permissions = kPepperFlashPermissions;
-
- std::vector<std::string> flash_version_numbers = base::SplitString(version, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
- if (flash_version_numbers.size() < 1)
- flash_version_numbers.push_back("11");
- else if (flash_version_numbers[0].empty())
- flash_version_numbers[0] = "11";
- if (flash_version_numbers.size() < 2)
- flash_version_numbers.push_back("2");
- if (flash_version_numbers.size() < 3)
- flash_version_numbers.push_back("999");
- if (flash_version_numbers.size() < 4)
- flash_version_numbers.push_back("999");
-
- // E.g., "Shockwave Flash 10.2 r154":
- plugin.description = plugin.name + " " + flash_version_numbers[0] + "." + flash_version_numbers[1] + " r" + flash_version_numbers[2];
- plugin.version = base::JoinString(flash_version_numbers, ".");
- content::WebPluginMimeType swf_mime_type(content::kFlashPluginSwfMimeType,
- content::kFlashPluginSwfExtension,
- content::kFlashPluginSwfDescription);
- plugin.mime_types.push_back(swf_mime_type);
- content::WebPluginMimeType spl_mime_type(content::kFlashPluginSplMimeType,
- content::kFlashPluginSplExtension,
- content::kFlashPluginSplDescription);
- plugin.mime_types.push_back(spl_mime_type);
-
- return plugin;
-}
-
-void AddPepperFlashFromSystem(std::vector<content::PepperPluginInfo>* plugins)
-{
- QStringList pluginPaths;
-#if defined(Q_OS_WIN)
- QString winDir = QDir::fromNativeSeparators(qEnvironmentVariable("WINDIR"));
- if (winDir.isEmpty())
- winDir = QString::fromLatin1("C:/Windows");
- QDir pluginDir(winDir + "/System32/Macromed/Flash");
- pluginDir.setFilter(QDir::Files);
- const QFileInfoList infos = pluginDir.entryInfoList(QStringList("pepflashplayer*.dll"));
- for (const QFileInfo &info : infos)
- pluginPaths << info.absoluteFilePath();
- pluginPaths << ppapiPluginsPath() + QStringLiteral("/pepflashplayer.dll");
-#endif
-#if defined(Q_OS_OSX)
- pluginPaths << "/Library/Internet Plug-Ins/PepperFlashPlayer/PepperFlashPlayer.plugin"; // System path
- QDir potentialDir(QDir::homePath() + "/Library/Application Support/Google/Chrome/PepperFlash");
- if (potentialDir.exists()) {
- QFileInfoList versionDirs = potentialDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name | QDir::Reversed);
- for (int i = 0; i < versionDirs.size(); ++i) {
- pluginPaths << versionDirs.at(i).absoluteFilePath() + "/PepperFlashPlayer.plugin";
- }
- }
- pluginPaths << ppapiPluginsPath() + QStringLiteral("/PepperFlashPlayer.plugin");
-#endif
-#if defined(Q_OS_LINUX)
- pluginPaths << "/opt/google/chrome/PepperFlash/libpepflashplayer.so" // Google Chrome
- << "/usr/lib/pepperflashplugin-nonfree/libpepflashplayer.so" // Ubuntu, package pepperflashplugin-nonfree
- << "/usr/lib/adobe-flashplugin/libpepflashplayer.so" // Ubuntu, package adobe-flashplugin
- << "/usr/lib/PepperFlash/libpepflashplayer.so" // Arch
- << "/usr/lib64/chromium/PepperFlash/libpepflashplayer.so"; // OpenSuSE
- pluginPaths << ppapiPluginsPath() + QStringLiteral("/libpepflashplayer.so");
-#endif
- std::string flash_version = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kPpapiFlashVersion);
- for (auto it = pluginPaths.constBegin(); it != pluginPaths.constEnd(); ++it) {
- if (!QFile::exists(*it))
- continue;
- plugins->push_back(CreatePepperFlashInfo(QtWebEngineCore::toFilePath(*it), flash_version));
- }
-}
-
-void AddPepperFlashFromCommandLine(std::vector<content::PepperPluginInfo>* plugins)
-{
- const base::CommandLine::StringType flash_path = base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(switches::kPpapiFlashPath);
- if (flash_path.empty() || !QFile::exists(QtWebEngineCore::toQt(flash_path)))
- return;
-
- // Read pepper flash plugin version from command-line. (e.g. 16.0.0.235)
- std::string flash_version = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kPpapiFlashVersion);
- plugins->push_back(CreatePepperFlashInfo(base::FilePath(flash_path), flash_version));
-}
-
void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins)
{
#if QT_CONFIG(webengine_printing_and_pdf)
@@ -273,8 +178,6 @@ namespace QtWebEngineCore {
void ContentClientQt::AddPepperPlugins(std::vector<content::PepperPluginInfo>* plugins)
{
ComputeBuiltInPlugins(plugins);
- AddPepperFlashFromSystem(plugins);
- AddPepperFlashFromCommandLine(plugins);
}
} // namespace QtWebEngineCore
diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp
index 6137b0bea..62d033f00 100644
--- a/src/core/content_main_delegate_qt.cpp
+++ b/src/core/content_main_delegate_qt.cpp
@@ -196,11 +196,11 @@ void ContentMainDelegateQt::PreSandboxStartup()
false //enable_tickcount
);
- if (logging::GetMinLogLevel() >= logging::LOG_INFO) {
+ if (logging::GetMinLogLevel() >= logging::LOGGING_INFO) {
if (parsedCommandLine->HasSwitch(switches::kLoggingLevel)) {
std::string logLevelValue = parsedCommandLine->GetSwitchValueASCII(switches::kLoggingLevel);
int level = 0;
- if (base::StringToInt(logLevelValue, &level) && level >= logging::LOG_INFO && level < logging::LOG_NUM_SEVERITIES)
+ if (base::StringToInt(logLevelValue, &level) && level >= logging::LOGGING_INFO && level < logging::LOGGING_NUM_SEVERITIES)
logging::SetMinLogLevel(level);
}
}
diff --git a/src/core/content_utility_client_qt.cpp b/src/core/content_utility_client_qt.cpp
index 3582e15a7..f3b1e764d 100644
--- a/src/core/content_utility_client_qt.cpp
+++ b/src/core/content_utility_client_qt.cpp
@@ -56,12 +56,9 @@ auto RunProxyResolver(mojo::PendingReceiver<proxy_resolver::mojom::ProxyResolver
return std::make_unique<proxy_resolver::ProxyResolverFactoryImpl>(std::move(receiver));
}
-mojo::ServiceFactory *ContentUtilityClientQt::GetIOThreadServiceFactory()
+void ContentUtilityClientQt::RegisterIOThreadServices(mojo::ServiceFactory &services)
{
- static base::NoDestructor<mojo::ServiceFactory> factory {
- RunProxyResolver,
- };
- return factory.get();
+ services.Add(RunProxyResolver);
}
} // namespace
diff --git a/src/core/content_utility_client_qt.h b/src/core/content_utility_client_qt.h
index fc1d1eb05..bcdf077f3 100644
--- a/src/core/content_utility_client_qt.h
+++ b/src/core/content_utility_client_qt.h
@@ -53,7 +53,7 @@ public:
~ContentUtilityClientQt() override;
// content::ContentUtilityClient:
- mojo::ServiceFactory *GetIOThreadServiceFactory() override;
+ void RegisterIOThreadServices(mojo::ServiceFactory &services) override;
};
} // namespace
diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri
index e978d20a1..b3cd7d518 100644
--- a/src/core/core_chromium.pri
+++ b/src/core/core_chromium.pri
@@ -52,8 +52,8 @@ SOURCES = \
color_chooser_controller.cpp \
common/qt_ipc_logging.cpp \
common/qt_messages.cpp \
+ compositor/compositor.cpp \
compositor/content_gpu_client_qt.cpp \
- compositor/display_frame_sink.cpp \
compositor/display_overrides.cpp \
compositor/display_software_output_surface.cpp \
content_client_qt.cpp \
@@ -88,6 +88,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 \
@@ -107,6 +108,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 \
@@ -144,7 +146,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 \
@@ -153,8 +154,8 @@ HEADERS = \
color_chooser_controller_p.h \
color_chooser_controller.h \
common/qt_messages.h \
+ compositor/compositor.h \
compositor/content_gpu_client_qt.h \
- compositor/display_frame_sink.h \
compositor/display_software_output_surface.h \
content_client_qt.h \
content_browser_client_qt.h \
@@ -187,6 +188,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 \
@@ -211,6 +213,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 \
@@ -249,18 +252,14 @@ qtConfig(webengine-ozone-x11) {
qtConfig(webengine-pepper-plugins) {
SOURCES += \
- renderer_host/pepper/pepper_flash_browser_host_qt.cpp \
renderer_host/pepper/pepper_host_factory_qt.cpp \
renderer_host/pepper/pepper_isolated_file_system_message_filter.cpp \
- renderer/pepper/pepper_flash_renderer_host_qt.cpp \
renderer/pepper/pepper_renderer_host_factory_qt.cpp \
renderer/plugins/loadable_plugin_placeholder_qt.cpp
HEADERS += \
- renderer_host/pepper/pepper_flash_browser_host_qt.h \
renderer_host/pepper/pepper_host_factory_qt.h \
renderer_host/pepper/pepper_isolated_file_system_message_filter.h \
- renderer/pepper/pepper_flash_renderer_host_qt.h \
renderer/pepper/pepper_renderer_host_factory_qt.h \
renderer/plugins/loadable_plugin_placeholder_qt.h
}
@@ -271,12 +270,14 @@ qtConfig(webengine-printing-and-pdf) {
printing/printing_message_filter_qt.cpp \
printing/print_view_manager_base_qt.cpp \
printing/print_view_manager_qt.cpp \
+ printing/printer_worker.cpp \
renderer/print_web_view_helper_delegate_qt.cpp
HEADERS += \
printing/printing_message_filter_qt.h \
printing/print_view_manager_base_qt.h \
printing/print_view_manager_qt.h \
+ printing/printer_worker.h \
renderer/print_web_view_helper_delegate_qt.h
# pdf sources
@@ -287,11 +288,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/display_gl_output_surface.cpp
HEADERS += \
compositor/compositor_resource_fence.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/core_common.pri b/src/core/core_common.pri
index e10d14267..9e06b37fa 100644
--- a/src/core/core_common.pri
+++ b/src/core/core_common.pri
@@ -7,6 +7,7 @@ QT_FOR_CONFIG += buildtools-private webenginecore webenginecore-private
TARGET = QtWebEngineCore
QT += qml-private quick-private gui-private core-private
+qtConfig(webengine-printing-and-pdf): QT += printsupport
QT_PRIVATE += webenginecoreheaders-private
qtConfig(webengine-geolocation): QT += positioning
@@ -15,6 +16,6 @@ qtConfig(webengine-webchannel): QT += webchannel
# LTO does not work for Chromium at the moment, so disable it completely for core.
CONFIG -= ltcg
-# Chromium requires C++14
-CONFIG += c++14
+# QtBase requires C++17
+CONFIG += c++17
diff --git a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc b/src/core/doc/src/qwebenginesettings_lgpl.qdoc
index b83da9440..a62abfbab 100644
--- a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc
+++ b/src/core/doc/src/qwebenginesettings_lgpl.qdoc
@@ -22,22 +22,13 @@
// by its LGPL license. Documentation written from scratch for new methods should be
// placed inline in the code as usual.
-#if QT_DEPRECATED_SINCE(5, 5)
-/*!
- \fn static QWebEngineSettings *QWebEngineSettings::globalSettings()
- \obsolete
-
- Use defaultSettings() instead.
-*/
-#endif
-
/*!
\class QWebEngineSettings
\since 5.4
\brief The QWebEngineSettings class provides an object to store the settings used
by QWebEnginePage.
- \inmodule QtWebEngineWidgets
+ \inmodule QtWebEngineCore
QWebEngineSettings allows configuration of browser properties, such as font sizes and
families, the location of a custom style sheet, and generic attributes, such as JavaScript
diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp
index f1ad1e677..b7b744603 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);
}
@@ -144,17 +143,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());
@@ -200,7 +188,7 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(download::DownloadItem *
false /* accepted */,
false /* paused */,
false /* done */,
- downloadType,
+ false /* isSavePageDownload */,
item->GetLastReason(),
adapterClient,
suggestedFilename,
@@ -303,7 +291,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 7f4f33702..eda1e4f21 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/extensions/mime_handler_view_guest_delegate_qt.cpp b/src/core/extensions/mime_handler_view_guest_delegate_qt.cpp
index 89d3d6f20..16a747929 100644
--- a/src/core/extensions/mime_handler_view_guest_delegate_qt.cpp
+++ b/src/core/extensions/mime_handler_view_guest_delegate_qt.cpp
@@ -49,6 +49,8 @@
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
#include "profile_adapter.h"
+#include "qwebenginecontextmenurequest.h"
+#include "qwebenginecontextmenurequest_p.h"
#include "render_widget_host_view_qt.h"
#include "touch_selection_controller_client_qt.h"
#include "web_contents_adapter.h"
@@ -59,11 +61,13 @@ namespace extensions {
MimeHandlerViewGuestDelegateQt::MimeHandlerViewGuestDelegateQt(MimeHandlerViewGuest *)
: MimeHandlerViewGuestDelegate()
+ , m_contextMenuRequest(new QWebEngineContextMenuRequest(new QWebEngineContextMenuRequestPrivate))
{
}
MimeHandlerViewGuestDelegateQt::~MimeHandlerViewGuestDelegateQt()
{
+ delete m_contextMenuRequest;
}
bool MimeHandlerViewGuestDelegateQt::HandleContextMenu(content::WebContents *web_contents, const content::ContextMenuParams &params)
@@ -74,9 +78,8 @@ bool MimeHandlerViewGuestDelegateQt::HandleContextMenu(content::WebContents *web
return true;
QtWebEngineCore::WebContentsAdapterClient *adapterClient = rwhv->adapterClient();
- QtWebEngineCore::WebEngineContextMenuData contextMenuData(QtWebEngineCore::WebContentsViewQt::buildContextMenuData(params));
- contextMenuData.setIsSpellCheckerEnabled(adapterClient->profileAdapter()->isSpellCheckEnabled());
- adapterClient->contextMenuRequested(contextMenuData);
+ QtWebEngineCore::WebContentsViewQt::update(m_contextMenuRequest, params, adapterClient->profileAdapter()->isSpellCheckEnabled());
+ adapterClient->contextMenuRequested(m_contextMenuRequest);
return true;
}
diff --git a/src/core/extensions/mime_handler_view_guest_delegate_qt.h b/src/core/extensions/mime_handler_view_guest_delegate_qt.h
index 8b2e29508..c9b822aa1 100644
--- a/src/core/extensions/mime_handler_view_guest_delegate_qt.h
+++ b/src/core/extensions/mime_handler_view_guest_delegate_qt.h
@@ -48,6 +48,10 @@
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h"
#include "api/qtwebenginecoreglobal_p.h"
+QT_BEGIN_NAMESPACE
+class QWebEngineContextMenuRequest;
+QT_END_NAMESPACE
+
namespace content {
struct ContextMenuParams;
}
@@ -65,6 +69,7 @@ public:
const content::ContextMenuParams &params) override;
private:
+ QWebEngineContextMenuRequest *m_contextMenuRequest;
DISALLOW_COPY_AND_ASSIGN(MimeHandlerViewGuestDelegateQt);
};
diff --git a/src/core/extensions/plugin_service_filter_qt.cpp b/src/core/extensions/plugin_service_filter_qt.cpp
index b29dbbeab..94cf5cb27 100644
--- a/src/core/extensions/plugin_service_filter_qt.cpp
+++ b/src/core/extensions/plugin_service_filter_qt.cpp
@@ -74,8 +74,8 @@ bool PluginServiceFilterQt::IsPluginAvailable(int render_process_id,
if (auto *delegate = static_cast<WebContentsDelegateQt *>(web_contents->GetDelegate())) {
const WebEngineSettings *settings = delegate->webEngineSettings();
- if (!settings->testAttribute(WebEngineSettings::PdfViewerEnabled)
- || !settings->testAttribute(WebEngineSettings::PluginsEnabled))
+ if (!settings->testAttribute(QWebEngineSettings::PdfViewerEnabled)
+ || !settings->testAttribute(QWebEngineSettings::PluginsEnabled))
return false;
}
diff --git a/src/core/favicon_manager.cpp b/src/core/favicon_manager.cpp
index 4496606f9..3cb417c4f 100644
--- a/src/core/favicon_manager.cpp
+++ b/src/core/favicon_manager.cpp
@@ -192,8 +192,8 @@ void FaviconManager::storeIcon(int id, const QIcon &icon)
m_inProgressRequests.remove(id);
if (m_inProgressRequests.isEmpty()) {
- WebEngineSettings *settings = m_viewClient->webEngineSettings();
- bool touchIconsEnabled = settings->testAttribute(WebEngineSettings::TouchIconsEnabled);
+ QWebEngineSettings *settings = m_viewClient->webEngineSettings();
+ bool touchIconsEnabled = settings->testAttribute(QWebEngineSettings::TouchIconsEnabled);
generateCandidateIcon(touchIconsEnabled);
const QUrl &iconUrl = candidateIconUrl(touchIconsEnabled);
@@ -248,13 +248,13 @@ void FaviconManager::update(const QList<FaviconInfo> &candidates)
{
updateCandidates(candidates);
- WebEngineSettings *settings = m_viewClient->webEngineSettings();
- if (!settings->testAttribute(WebEngineSettings::AutoLoadIconsForPage)) {
+ QWebEngineSettings *settings = m_viewClient->webEngineSettings();
+ if (!settings->testAttribute(QWebEngineSettings::AutoLoadIconsForPage)) {
m_viewClient->iconChanged(QUrl());
return;
}
- bool touchIconsEnabled = settings->testAttribute(WebEngineSettings::TouchIconsEnabled);
+ bool touchIconsEnabled = settings->testAttribute(QWebEngineSettings::TouchIconsEnabled);
const QList<FaviconInfo> &faviconInfoList = getFaviconInfoList(true /* candidates only */);
for (auto it = faviconInfoList.cbegin(), end = faviconInfoList.cend(); it != end; ++it) {
diff --git a/src/core/file_picker_controller.cpp b/src/core/file_picker_controller.cpp
index 334321273..d8b5b520e 100644
--- a/src/core/file_picker_controller.cpp
+++ b/src/core/file_picker_controller.cpp
@@ -154,7 +154,7 @@ void FilePickerController::accepted(const QVariant &files)
{
QStringList stringList;
- if (files.canConvert(QVariant::StringList)) {
+ if (files.canConvert(QMetaType::QStringList)) {
stringList = files.toStringList();
} else if (files.canConvert<QList<QUrl> >()) {
const QList<QUrl> urls = files.value<QList<QUrl>>();
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/location_provider_qt.cpp b/src/core/location_provider_qt.cpp
index 94f6c6c9a..71f95157b 100644
--- a/src/core/location_provider_qt.cpp
+++ b/src/core/location_provider_qt.cpp
@@ -228,14 +228,14 @@ inline void QtPositioningHelper::postToLocationProvider(const base::Closure &tas
}
LocationProviderQt::LocationProviderQt()
- : m_positioningHelper(0)
+ : m_positioningHelper(nullptr)
{
}
LocationProviderQt::~LocationProviderQt()
{
if (m_positioningHelper) {
- m_positioningHelper->m_locationProvider = 0;
+ m_positioningHelper->m_locationProvider = nullptr;
m_positioningHelper->m_locationProviderFactory.InvalidateWeakPtrs();
m_positioningHelper->deleteLater();
}
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/media_capture_devices_dispatcher.cpp b/src/core/media_capture_devices_dispatcher.cpp
index ef5d65745..3a1c20718 100644
--- a/src/core/media_capture_devices_dispatcher.cpp
+++ b/src/core/media_capture_devices_dispatcher.cpp
@@ -227,8 +227,13 @@ WebContentsAdapterClient::MediaRequestFlags mediaRequestFlagsForRequest(const co
request.video_type == MediaStreamType::DISPLAY_VIDEO_CAPTURE)
return {WebContentsAdapterClient::MediaDesktopAudioCapture, WebContentsAdapterClient::MediaDesktopVideoCapture};
+ if (request.audio_type == MediaStreamType::DISPLAY_AUDIO_CAPTURE &&
+ request.video_type == MediaStreamType::DISPLAY_VIDEO_CAPTURE_THIS_TAB)
+ return {WebContentsAdapterClient::MediaDesktopAudioCapture, WebContentsAdapterClient::MediaDesktopVideoCapture};
+
if (request.video_type == MediaStreamType::GUM_DESKTOP_VIDEO_CAPTURE ||
- request.video_type == MediaStreamType::DISPLAY_VIDEO_CAPTURE)
+ request.video_type == MediaStreamType::DISPLAY_VIDEO_CAPTURE ||
+ request.video_type == MediaStreamType::DISPLAY_VIDEO_CAPTURE_THIS_TAB)
return {WebContentsAdapterClient::MediaDesktopVideoCapture};
return {};
@@ -249,21 +254,41 @@ public:
{
if (m_started && m_delegate)
m_delegate->removeDevices(m_devices);
+ m_onStop.Reset();
}
private:
- gfx::NativeViewId OnStarted(base::OnceClosure, SourceCallback) override
+ gfx::NativeViewId OnStarted(base::OnceClosure stop, SourceCallback source,
+ const std::string& label,
+ std::vector<content::DesktopMediaID> screen_capture_ids,
+ StateChangeCallback state_change) override
{
- DCHECK(!m_started);
+ if (m_started) {
+ // Ignore possibly-compromised renderers that might call
+ // MediaStreamDispatcherHost::OnStreamStarted() more than once.
+ // See: https://crbug.com/1155426
+ return 0;
+ }
m_started = true;
+ m_onStop = std::move(stop);
if (m_delegate)
m_delegate->addDevices(m_devices);
return 0;
}
+ void OnDeviceStopped(const std::string &label, const content::DesktopMediaID &media_id) override
+ {
+ NOTIMPLEMENTED();
+ }
+
+ void SetStopCallback(base::OnceClosure stop) override
+ {
+ m_onStop = std::move(stop);
+ }
base::WeakPtr<WebContentsDelegateQt> m_delegate;
const blink::MediaStreamDevices m_devices;
bool m_started = false;
+ base::OnceClosure m_onStop; // currently unused
DISALLOW_COPY_AND_ASSIGN(MediaStreamUIQt);
};
@@ -395,8 +420,8 @@ void MediaCaptureDevicesDispatcher::processMediaAccessRequest(content::WebConten
WebContentsAdapterClient *adapterClient = delegate->adapterClient();
if (flags.testFlag(WebContentsAdapterClient::MediaDesktopVideoCapture)) {
- const bool screenCaptureEnabled =
- adapterClient->webEngineSettings()->testAttribute(WebEngineSettings::ScreenCaptureEnabled);
+ const bool screenCaptureEnabled = adapterClient->webEngineSettings()->testAttribute(
+ QWebEngineSettings::ScreenCaptureEnabled);
const bool originIsSecure = blink::network_utils::IsOriginSecure(request.security_origin);
if (!screenCaptureEnabled || !originIsSecure) {
std::move(callback).Run(blink::MediaStreamDevices(), MediaStreamRequestResult::INVALID_STATE, std::unique_ptr<content::MediaStreamUI>());
@@ -441,7 +466,8 @@ void MediaCaptureDevicesDispatcher::processDesktopCaptureAccessRequest(content::
}
// Audio is only supported for screen capture streams.
- bool audioRequested = request.audio_type == MediaStreamType::GUM_DESKTOP_AUDIO_CAPTURE;
+ bool audioRequested = (request.audio_type == MediaStreamType::GUM_DESKTOP_AUDIO_CAPTURE ||
+ request.audio_type == MediaStreamType::DISPLAY_AUDIO_CAPTURE);
bool audioSupported = (mediaId.type == content::DesktopMediaID::TYPE_SCREEN && m_loopbackAudioSupported);
bool captureAudio = (audioRequested && audioSupported);
diff --git a/src/core/native_web_keyboard_event_qt.cpp b/src/core/native_web_keyboard_event_qt.cpp
index b2e857aaf..edd27ccec 100644
--- a/src/core/native_web_keyboard_event_qt.cpp
+++ b/src/core/native_web_keyboard_event_qt.cpp
@@ -52,7 +52,11 @@ namespace {
// event is destroyed.
gfx::NativeEvent CopyEvent(gfx::NativeEvent event)
{
- return event ? reinterpret_cast<gfx::NativeEvent>(new QKeyEvent(*reinterpret_cast<QKeyEvent*>(event))) : 0;
+ if (!event)
+ return nullptr;
+
+ QKeyEvent *keyEvent = reinterpret_cast<QKeyEvent *>(event);
+ return reinterpret_cast<gfx::NativeEvent>(keyEvent->clone());
}
void DestroyEvent(gfx::NativeEvent event)
diff --git a/src/core/net/client_cert_override.cpp b/src/core/net/client_cert_override.cpp
index d768092e8..9c2ff31d7 100644
--- a/src/core/net/client_cert_override.cpp
+++ b/src/core/net/client_cert_override.cpp
@@ -40,7 +40,6 @@
#include "client_cert_override.h"
#include "base/bind.h"
-#include "base/bind_helpers.h"
#include "base/task/post_task.h"
#include "base/callback_forward.h"
#include "content/public/browser/browser_task_traits.h"
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 fe1ed5be6..9078bcd58 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/net/plugin_response_interceptor_url_loader_throttle.cpp b/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp
index d868e4f54..bca059ae6 100644
--- a/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp
+++ b/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp
@@ -89,8 +89,8 @@ void PluginResponseInterceptorURLLoaderThrottle::WillProcessResponse(const GURL
return;
WebEngineSettings *settings = contentsDelegate->webEngineSettings();
- if (!settings->testAttribute(WebEngineSettings::PdfViewerEnabled)
- || !settings->testAttribute(WebEngineSettings::PluginsEnabled)) {
+ if (!settings->testAttribute(QWebEngineSettings::PdfViewerEnabled)
+ || !settings->testAttribute(QWebEngineSettings::PluginsEnabled)) {
// PluginServiceFilterQt will inform the URLLoader about the disabled state of plugins
// and we can expect the download to be triggered automatically. It's unnecessary to
// go further and start the guest view embedding process.
diff --git a/src/core/net/proxying_url_loader_factory_qt.cpp b/src/core/net/proxying_url_loader_factory_qt.cpp
index fe9176f1f..c945ee4d5 100644
--- a/src/core/net/proxying_url_loader_factory_qt.cpp
+++ b/src/core/net/proxying_url_loader_factory_qt.cpp
@@ -136,8 +136,10 @@ public:
void PauseReadingBodyFromNet() override;
void ResumeReadingBodyFromNet() override;
- void InterceptOnUIThread(QWebEngineUrlRequestInterceptor *profileInterceptor);
- void InterceptOnIOThread(base::WaitableEvent *event, QWebEngineUrlRequestInterceptor *profileInterceptor);
+ static inline void cleanup(QWebEngineUrlRequestInfo *info) { delete info; }
+
+private:
+ void InterceptOnUIThread();
void ContinueAfterIntercept();
// This is called when the original URLLoaderClient has a connection error.
@@ -172,7 +174,6 @@ public:
const net::MutableNetworkTrafficAnnotationTag traffic_annotation_;
- static inline void cleanup(QWebEngineUrlRequestInfo *info) { delete info; }
QScopedPointer<QWebEngineUrlRequestInfo, InterceptedRequest> request_info_;
mojo::Receiver<network::mojom::URLLoader> proxied_loader_receiver_;
@@ -273,37 +274,15 @@ void InterceptedRequest::Restart()
Q_ASSERT(!request_info_);
request_info_.reset(new QWebEngineUrlRequestInfo(info));
- // TODO: remove for Qt6
- bool isDeprecatedProfileInterceptor = profileInterceptor == nullptr;
- if (profileInterceptor && profileInterceptor->property("deprecated").toBool()) {
- isDeprecatedProfileInterceptor = true;
- // sync call supports depracated call of an interceptor on io thread
- base::WaitableEvent event;
- base::PostTask(FROM_HERE, { content::BrowserThread::IO },
- base::BindOnce(&InterceptedRequest::InterceptOnIOThread,
- base::Unretained(this), &event, profileInterceptor));
- event.Wait();
- if (request_info_->changed()) {
- ContinueAfterIntercept();
- return;
- }
- }
- InterceptOnUIThread(isDeprecatedProfileInterceptor ? nullptr : profileInterceptor);
+ InterceptOnUIThread();
ContinueAfterIntercept();
}
-void InterceptedRequest::InterceptOnIOThread(base::WaitableEvent *event, QWebEngineUrlRequestInterceptor *interceptor)
-{
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- interceptor->interceptRequest(*request_info_);
- event->Signal();
-}
-
-void InterceptedRequest::InterceptOnUIThread(QWebEngineUrlRequestInterceptor *profileInterceptor)
+void InterceptedRequest::InterceptOnUIThread()
{
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- if (profileInterceptor)
- profileInterceptor->interceptRequest(*request_info_);
+ if (auto interceptor = getProfileInterceptor())
+ interceptor->interceptRequest(*request_info_);
if (!request_info_->changed()) {
if (auto interceptor = getPageInterceptor())
diff --git a/src/core/ozone/gl_context_qt.cpp b/src/core/ozone/gl_context_qt.cpp
index 9a24f6bf4..1b1cef485 100644
--- a/src/core/ozone/gl_context_qt.cpp
+++ b/src/core/ozone/gl_context_qt.cpp
@@ -53,7 +53,7 @@
QT_BEGIN_NAMESPACE
Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();
-GLContextHelper* GLContextHelper::contextHelper = 0;
+GLContextHelper* GLContextHelper::contextHelper = nullptr;
namespace {
@@ -95,7 +95,7 @@ void GLContextHelper::initialize()
void GLContextHelper::destroy()
{
delete contextHelper;
- contextHelper = 0;
+ contextHelper = nullptr;
}
bool GLContextHelper::initializeContextOnBrowserThread(gl::GLContext* context, gl::GLSurface* surface, gl::GLContextAttribs attribs)
@@ -173,6 +173,24 @@ QFunctionPointer GLContextHelper::getEglGetProcAddress()
return get_proc_address;
}
+void *GLContextHelper::getGlxPlatformInterface()
+{
+#if QT_CONFIG(opengl) && defined(USE_GLX)
+ if (QOpenGLContext *context = qt_gl_global_share_context())
+ return context->nativeInterface<QNativeInterface::QGLXContext>();
+#endif
+ return nullptr;
+}
+
+void *GLContextHelper::getEglPlatformInterface()
+{
+#if QT_CONFIG(opengl) && QT_CONFIG(egl)
+ if (QOpenGLContext *context = qt_gl_global_share_context())
+ return context->nativeInterface<QNativeInterface::QEGLContext>();
+#endif
+ return nullptr;
+}
+
bool GLContextHelper::isCreateContextRobustnessSupported()
{
return contextHelper->m_robustness;
diff --git a/src/core/ozone/gl_context_qt.h b/src/core/ozone/gl_context_qt.h
index cc4f6b0d1..612aae3f5 100644
--- a/src/core/ozone/gl_context_qt.h
+++ b/src/core/ozone/gl_context_qt.h
@@ -65,6 +65,8 @@ public:
static QFunctionPointer getGlXGetProcAddress();
static QFunctionPointer getEglGetProcAddress();
static bool isCreateContextRobustnessSupported();
+ static void *getGlxPlatformInterface();
+ static void *getEglPlatformInterface();
private:
Q_INVOKABLE bool initializeContextOnBrowserThread(gl::GLContext* context, gl::GLSurface* surface, gl::GLContextAttribs attribs);
diff --git a/src/core/ozone/gl_ozone_egl_qt.cpp b/src/core/ozone/gl_ozone_egl_qt.cpp
index 04b336990..14ba5e8d9 100644
--- a/src/core/ozone/gl_ozone_egl_qt.cpp
+++ b/src/core/ozone/gl_ozone_egl_qt.cpp
@@ -38,11 +38,10 @@
****************************************************************************/
#if defined(USE_OZONE)
-#include <QtCore/qobject.h>
-#include <QtGui/qtgui-config.h>
#include "gl_context_qt.h"
#include "gl_ozone_egl_qt.h"
#include "gl_surface_egl_qt.h"
+
#include "base/files/file_path.h"
#include "base/native_library.h"
#include "ui/gl/gl_context_egl.h"
@@ -51,7 +50,6 @@
#include "ui/gl/init/gl_factory.h"
#include "ui/gl/init/gl_initializer.h"
-
#include <EGL/egl.h>
#include <dlfcn.h>
@@ -79,13 +77,11 @@ bool GLOzoneEGLQt::LoadGLES2Bindings(gl::GLImplementation /*implementation*/)
reinterpret_cast<gl::GLGetProcAddressProc>(
base::GetFunctionPointerFromNativeLibrary(eglgles2Library,
"eglGetProcAddress"));
-#if QT_CONFIG(opengl)
if (!get_proc_address) {
// QTBUG-63341 most likely libgles2 not linked with libegl -> fallback to qpa
get_proc_address =
reinterpret_cast<gl::GLGetProcAddressProc>(GLContextHelper::getEglGetProcAddress());
}
-#endif
if (!get_proc_address) {
LOG(ERROR) << "eglGetProcAddress not found.";
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..a17321455
--- /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->nativeInterface<QNativeInterface::QCocoaGLContext>();
+ if (ctx)
+ m_handle = cglContext(ctx->nativeContext());
+#endif
+#if defined(Q_OS_WIN)
+ auto *ctx = context->nativeInterface<QNativeInterface::QWGLContext>();
+#endif
+#if defined(Q_OS_LINUX)
+ auto *ctx = context->nativeInterface<QNativeInterface::QGLXContext>();
+#endif
+ if (ctx && !m_handle)
+ m_handle = (void *)ctx->nativeContext();
+#if QT_CONFIG(egl)
+ if (!m_handle) {
+ auto *ctx = context->nativeInterface<QNativeInterface::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::CheckStickyGraphicsResetStatusImpl()
+{
+#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/webengine/api/qquickwebenginescript_p.h b/src/core/ozone/gl_share_context_qt.h
index 30b47a654..b07f5123e 100644
--- a/src/webengine/api/qquickwebenginescript_p.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,51 +37,63 @@
**
****************************************************************************/
-#ifndef QQUICKWEBENGINESCRIPT_P_H
-#define QQUICKWEBENGINESCRIPT_P_H
+#ifndef GL_SHARE_CONTEXT_QT
+#define GL_SHARE_CONTEXT_QT
-//
-// 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 "ui/gl/gpu_timing.h"
+#include "ui/gl/gl_context.h"
+#include "ui/gl/gl_share_group.h"
+#include "qtwebenginecoreglobal.h"
-#include "qquickwebenginescript.h"
-
-#include <QtCore/QBasicTimer>
-#include "user_script.h"
-#include "web_contents_adapter.h"
+QT_FORWARD_DECLARE_CLASS(QOpenGLContext)
namespace QtWebEngineCore {
-class UserResourceControllerHost;
-class WebContentsAdapter;
-} // namespace
-QT_BEGIN_NAMESPACE
+class QtShareGLContext : public gl::GLContext
+{
-class QQuickWebEngineScriptPrivate {
public:
- Q_DECLARE_PUBLIC(QQuickWebEngineScript)
- QQuickWebEngineScriptPrivate();
- void aboutToUpdateUnderlyingScript();
- void bind(QtWebEngineCore::UserResourceControllerHost *, QtWebEngineCore::WebContentsAdapter * = 0);
-
- QtWebEngineCore::UserScript coreScript;
- QBasicTimer m_basicTimer;
- QtWebEngineCore::UserResourceControllerHost *m_controllerHost;
- QtWebEngineCore::WebContentsAdapter *m_adapter;
- QUrl m_sourceUrl;
+ QtShareGLContext(QOpenGLContext *qtContext);
+ void *GetHandle() override { return m_handle; }
+ unsigned int CheckStickyGraphicsResetStatusImpl() 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
+ {
+ Q_UNREACHABLE();
+ return false;
+ }
+ bool MakeCurrentImpl(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:
- QQuickWebEngineScript *q_ptr;
-
+ void *m_handle;
};
-QT_END_NAMESPACE
+class ShareGroupQt : public gl::GLShareGroup
+{
-#endif // QQUICKWEBENGINESCRIPT_P_H
+public:
+ gl::GLContext *GetContext() override { return m_shareContextQt.get(); }
+ void AboutToAddFirstContext() override;
+
+private:
+ scoped_refptr<QtShareGLContext> m_shareContextQt;
+};
+} // namespace
+#endif
diff --git a/src/core/ozone/gl_surface_glx_qt.cpp b/src/core/ozone/gl_surface_glx_qt.cpp
index 188a92729..5ccf5037a 100644
--- a/src/core/ozone/gl_surface_glx_qt.cpp
+++ b/src/core/ozone/gl_surface_glx_qt.cpp
@@ -45,17 +45,9 @@
#include "ozone/gl_surface_glx_qt.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_surface_glx.h"
-#include "ui/gfx/x/x11_types.h"
namespace gl {
-bool GLSurfaceGLXQt::s_initialized = false;
-
-GLSurfaceGLXQt::~GLSurfaceGLXQt()
-{
- Destroy();
-}
-
void GLSurfaceGLX::ShutdownOneOff()
{
}
@@ -115,13 +107,25 @@ const char* GLSurfaceGLX::GetGLXExtensions()
return GLSurfaceQt::g_extensions;
}
+
+bool GLSurfaceGLXQt::s_initialized = false;
+
+GLSurfaceGLXQt::GLSurfaceGLXQt(const gfx::Size& size)
+ : GLSurfaceQt(size),
+ m_surfaceBuffer(0)
+{
+}
+
+GLSurfaceGLXQt::~GLSurfaceGLXQt()
+{
+ Destroy();
+}
+
bool GLSurfaceGLXQt::InitializeOneOff()
{
if (s_initialized)
return true;
- XInitThreads();
-
g_display = GLContextHelper::getXDisplay();
if (!g_display) {
LOG(ERROR) << "GLContextHelper::getXDisplay() failed.";
@@ -199,12 +203,6 @@ void GLSurfaceGLXQt::Destroy()
}
}
-GLSurfaceGLXQt::GLSurfaceGLXQt(const gfx::Size& size)
- : GLSurfaceQt(size),
- m_surfaceBuffer(0)
-{
-}
-
void* GLSurfaceGLXQt::GetHandle()
{
return reinterpret_cast<void*>(m_surfaceBuffer);
diff --git a/src/core/ozone/gl_surface_glx_qt.h b/src/core/ozone/gl_surface_glx_qt.h
index e894423b7..fb17c5aca 100644
--- a/src/core/ozone/gl_surface_glx_qt.h
+++ b/src/core/ozone/gl_surface_glx_qt.h
@@ -42,8 +42,6 @@
#include "gl_surface_qt.h"
-#include "ui/gfx/x/x11_types.h"
-
namespace gl {
class GLSurfaceGLXQt: public GLSurfaceQt {
@@ -62,7 +60,7 @@ protected:
private:
static bool s_initialized;
- XID m_surfaceBuffer;
+ int m_surfaceBuffer;
DISALLOW_COPY_AND_ASSIGN(GLSurfaceGLXQt);
};
diff --git a/src/core/ozone/gl_surface_qt.cpp b/src/core/ozone/gl_surface_qt.cpp
index 2c464c11c..3fb4746f4 100644
--- a/src/core/ozone/gl_surface_qt.cpp
+++ b/src/core/ozone/gl_surface_qt.cpp
@@ -41,41 +41,27 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE.Chromium file.
-#include "gl_surface_qt.h"
-
#if !defined(OS_MAC)
-#include <QGuiApplication>
-#include "gl_context_qt.h"
+#include "gl_surface_qt.h"
#include "qtwebenginecoreglobal_p.h"
-#include "web_engine_context.h"
-#include "ozone/gl_surface_egl_qt.h"
#include "base/logging.h"
-#include "base/threading/thread_restrictions.h"
-#include "gpu/ipc/service/image_transport_surface.h"
-#include "ui/gl/gl_bindings.h"
-#include "ui/gl/gl_context.h"
-#include "ui/gl/gl_implementation.h"
-#include "ui/gl/init/gl_initializer.h"
-#include "ui/gl/init/gl_factory.h"
-#include "ui/gl/gl_gl_api_implementation.h"
+
#if defined(OS_WIN)
+#include "web_engine_context.h"
#include "ozone/gl_surface_wgl_qt.h"
+#include "ozone/gl_surface_egl_qt.h"
+#include "gpu/ipc/service/image_transport_surface.h"
+#include "ui/gl/gl_implementation.h"
#include "ui/gl/direct_composition_surface_win.h"
#include "ui/gl/vsync_provider_win.h"
#endif
-#include "ozone/gl_surface_egl_qt.h"
-#include "ui/gl/gl_egl_api_implementation.h"
namespace gl {
-namespace {
-bool g_initializedEGL = false;
-}
-
void* GLSurfaceQt::g_display = nullptr;
void* GLSurfaceQt::g_config = nullptr;
const char* GLSurfaceQt::g_extensions = nullptr;
@@ -143,16 +129,9 @@ bool InitializeGLOneOffPlatform()
if (GetGLImplementation() == kGLImplementationEGLGLES2 || GetGLImplementation() == kGLImplementationEGLANGLE)
return GLSurfaceEGLQt::InitializeOneOff();
- if (GetGLImplementation() == kGLImplementationDesktopGL) {
+ if (GetGLImplementation() == kGLImplementationDesktopGL)
return GLSurfaceWGLQt::InitializeOneOff();
- // Fallback to trying EGL with desktop GL.
- if (GLSurfaceEGLQt::InitializeOneOff()) {
- g_initializedEGL = true;
- return true;
- }
- }
-
return false;
}
diff --git a/src/core/ozone/platform_window_qt.cpp b/src/core/ozone/platform_window_qt.cpp
index 757c042f0..42af77774 100644
--- a/src/core/ozone/platform_window_qt.cpp
+++ b/src/core/ozone/platform_window_qt.cpp
@@ -59,7 +59,7 @@ PlatformWindowQt::~PlatformWindowQt()
ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
}
-gfx::Rect PlatformWindowQt::GetBounds()
+gfx::Rect PlatformWindowQt::GetBounds() const
{
return bounds_;
}
diff --git a/src/core/ozone/platform_window_qt.h b/src/core/ozone/platform_window_qt.h
index b1021df9d..dbeb320ac 100644
--- a/src/core/ozone/platform_window_qt.h
+++ b/src/core/ozone/platform_window_qt.h
@@ -56,7 +56,7 @@ public:
PlatformWindowQt(PlatformWindowDelegate* delegate, const gfx::Rect& bounds);
~PlatformWindowQt() override;
// PlatformWindow:
- gfx::Rect GetBounds() override;
+ gfx::Rect GetBounds() const override;
void SetBounds(const gfx::Rect& bounds) override;
void Show(bool inactive = false) override { }
void Hide() override { }
diff --git a/src/core/ozone/surface_factory_qt.cpp b/src/core/ozone/surface_factory_qt.cpp
index 12b997148..846d930d6 100644
--- a/src/core/ozone/surface_factory_qt.cpp
+++ b/src/core/ozone/surface_factory_qt.cpp
@@ -51,13 +51,13 @@ namespace QtWebEngineCore {
SurfaceFactoryQt::SurfaceFactoryQt()
{
#if defined(USE_GLX)
- if (GLContextHelper::getGlXConfig()) {
- m_impl = gl::kGLImplementationDesktopGL;
+ if (GLContextHelper::getGlxPlatformInterface()) {
+ m_impl = { gl::kGLImplementationDesktopGL };
m_ozone.reset(new ui::GLOzoneGLXQt());
} else
#endif
- if (GLContextHelper::getEGLConfig()) {
- m_impl = gl::kGLImplementationEGLGLES2;
+ if (GLContextHelper::getEglPlatformInterface()) {
+ m_impl = { gl::kGLImplementationDesktopGL, gl::kGLImplementationEGLGLES2 };
m_ozone.reset(new ui::GLOzoneEGLQt());
} else {
qFatal("No suitable graphics backend found\n");
@@ -66,7 +66,7 @@ SurfaceFactoryQt::SurfaceFactoryQt()
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/permission_manager_qt.cpp b/src/core/permission_manager_qt.cpp
index 40090f8ec..e0a26e012 100644
--- a/src/core/permission_manager_qt.cpp
+++ b/src/core/permission_manager_qt.cpp
@@ -217,8 +217,8 @@ int PermissionManagerQt::RequestPermission(content::PermissionType permission,
ProfileAdapter::PermissionType permissionType = toQt(permission);
if (permissionType == ProfileAdapter::ClipboardRead) {
WebEngineSettings *settings = contentsDelegate->webEngineSettings();
- if (settings->testAttribute(WebEngineSettings::JavascriptCanAccessClipboard)
- && settings->testAttribute(WebEngineSettings::JavascriptCanPaste))
+ if (settings->testAttribute(QWebEngineSettings::JavascriptCanAccessClipboard)
+ && settings->testAttribute(QWebEngineSettings::JavascriptCanPaste))
std::move(callback).Run(blink::mojom::PermissionStatus::GRANTED);
else
std::move(callback).Run(blink::mojom::PermissionStatus::DENIED);
@@ -259,8 +259,8 @@ int PermissionManagerQt::RequestPermissions(const std::vector<content::Permissio
result.push_back(blink::mojom::PermissionStatus::DENIED);
else if (permissionType == ProfileAdapter::ClipboardRead) {
WebEngineSettings *settings = contentsDelegate->webEngineSettings();
- if (settings->testAttribute(WebEngineSettings::JavascriptCanAccessClipboard)
- && settings->testAttribute(WebEngineSettings::JavascriptCanPaste))
+ if (settings->testAttribute(QWebEngineSettings::JavascriptCanAccessClipboard)
+ && settings->testAttribute(QWebEngineSettings::JavascriptCanPaste))
result.push_back(blink::mojom::PermissionStatus::GRANTED);
else
result.push_back(blink::mojom::PermissionStatus::DENIED);
@@ -311,10 +311,12 @@ blink::mojom::PermissionStatus PermissionManagerQt::GetPermissionStatusForFrame(
permission == content::PermissionType::CLIPBOARD_SANITIZED_WRITE) {
WebContentsDelegateQt *delegate = static_cast<WebContentsDelegateQt *>(
content::WebContents::FromRenderFrameHost(render_frame_host)->GetDelegate());
- if (!delegate->webEngineSettings()->testAttribute(WebEngineSettings::JavascriptCanAccessClipboard))
+ if (!delegate->webEngineSettings()->testAttribute(
+ QWebEngineSettings::JavascriptCanAccessClipboard))
return blink::mojom::PermissionStatus::DENIED;
- if (permission == content::PermissionType::CLIPBOARD_READ_WRITE &&
- !delegate->webEngineSettings()->testAttribute(WebEngineSettings::JavascriptCanPaste))
+ if (permission == content::PermissionType::CLIPBOARD_READ_WRITE
+ && !delegate->webEngineSettings()->testAttribute(
+ QWebEngineSettings::JavascriptCanPaste))
return blink::mojom::PermissionStatus::DENIED;
return blink::mojom::PermissionStatus::GRANTED;
}
diff --git a/src/core/pref_service_adapter.h b/src/core/pref_service_adapter.h
index 1c7c44a96..93a61302f 100644
--- a/src/core/pref_service_adapter.h
+++ b/src/core/pref_service_adapter.h
@@ -44,12 +44,6 @@
#include "components/prefs/pref_service.h"
#include "qtwebenginecoreglobal_p.h"
-QT_BEGIN_NAMESPACE
-class QStringList;
-QT_END_NAMESPACE
-
-class ProfileAdapter;
-
namespace QtWebEngineCore {
class ProfileAdapter;
diff --git a/src/core/printing/print_view_manager_base_qt.cpp b/src/core/printing/print_view_manager_base_qt.cpp
index ad35209f1..3e740726a 100644
--- a/src/core/printing/print_view_manager_base_qt.cpp
+++ b/src/core/printing/print_view_manager_base_qt.cpp
@@ -132,6 +132,66 @@ void GetDefaultPrintSettingsOnIO(printing::mojom::PrintManagerHost::GetDefaultPr
std::move(printer_query), std::move(callback)));
}
+// Runs |callback| with |params| to reply to
+// mojom::PrintManagerHost::UpdatePrintSettings.
+void UpdatePrintSettingsReply(printing::mojom::PrintManagerHost::UpdatePrintSettingsCallback callback,
+ printing::mojom::PrintPagesParamsPtr params, bool canceled)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ if (!params) {
+ // Fills |params| with initial values.
+ params = printing::mojom::PrintPagesParams::New();
+ params->params = printing::mojom::PrintParams::New();
+ }
+ std::move(callback).Run(std::move(params), canceled);
+}
+
+void UpdatePrintSettingsReplyOnIO(scoped_refptr<printing::PrintQueriesQueue> queue,
+ std::unique_ptr<printing::PrinterQuery> printer_query,
+ printing::mojom::PrintManagerHost::UpdatePrintSettingsCallback callback,
+ int process_id, int routing_id)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ DCHECK(printer_query);
+ auto params = printing::mojom::PrintPagesParams::New();
+ params->params = printing::mojom::PrintParams::New();
+ if (printer_query->last_status() == printing::PrintingContext::OK) {
+ RenderParamsFromPrintSettings(printer_query->settings(), params->params.get());
+ params->params->document_cookie = printer_query->cookie();
+ params->pages = printing::PageRange::GetPages(printer_query->settings().ranges());
+ }
+ bool canceled = printer_query->last_status() == printing::PrintingContext::CANCEL;
+
+ content::GetUIThreadTaskRunner({})->PostTask(
+ FROM_HERE,
+ base::BindOnce(&UpdatePrintSettingsReply, std::move(callback), std::move(params), canceled));
+
+ if (printer_query->cookie() && printer_query->settings().dpi()) {
+ queue->QueuePrinterQuery(std::move(printer_query));
+ } else {
+ printer_query->StopWorker();
+ }
+}
+
+void UpdatePrintSettingsOnIO(int32_t cookie,
+ printing::mojom::PrintManagerHost::UpdatePrintSettingsCallback callback,
+ scoped_refptr<printing::PrintQueriesQueue> queue,
+ base::Value job_settings,
+ int process_id, int routing_id)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ std::unique_ptr<printing::PrinterQuery> printer_query = queue->PopPrinterQuery(cookie);
+ if (!printer_query)
+ printer_query = queue->CreatePrinterQuery(content::ChildProcessHost::kInvalidUniqueID, MSG_ROUTING_NONE);
+
+ auto *printer_query_ptr = printer_query.get();
+ printer_query_ptr->SetSettings(
+ std::move(job_settings),
+ base::BindOnce(&UpdatePrintSettingsReplyOnIO,
+ queue, std::move(printer_query), std::move(callback),
+ process_id, routing_id));
+}
+
} // namespace
PrintViewManagerBaseQt::PrintViewManagerBaseQt(content::WebContents *contents)
@@ -602,4 +662,25 @@ void PrintViewManagerBaseQt::SendPrintingEnabled(bool enabled, content::RenderFr
GetPrintRenderFrame(rfh)->SetPrintingEnabled(enabled);
}
+void PrintViewManagerBaseQt::UpdatePrintSettings(int32_t cookie, base::Value job_settings,
+ UpdatePrintSettingsCallback callback)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ if (!job_settings.FindIntKey(printing::kSettingPrinterType)) {
+ UpdatePrintSettingsReply(std::move(callback), nullptr, false);
+ return;
+ }
+
+ content::RenderFrameHost *render_frame_host =
+ print_manager_host_receivers_.GetCurrentTargetFrame();
+
+ content::GetIOThreadTaskRunner({})->PostTask(
+ FROM_HERE,
+ base::BindOnce(&UpdatePrintSettingsOnIO, cookie, std::move(callback),
+ m_printerQueriesQueue, std::move(job_settings),
+ render_frame_host->GetProcess()->GetID(),
+ render_frame_host->GetRoutingID()));
+}
+
} // namespace QtWebEngineCore
diff --git a/src/core/printing/print_view_manager_base_qt.h b/src/core/printing/print_view_manager_base_qt.h
index 3086d5d3a..14adb928a 100644
--- a/src/core/printing/print_view_manager_base_qt.h
+++ b/src/core/printing/print_view_manager_base_qt.h
@@ -82,6 +82,8 @@ public:
// mojom::PrintManagerHost:
void DidGetPrintedPagesCount(int32_t cookie, uint32_t number_pages) override;
void GetDefaultPrintSettings(GetDefaultPrintSettingsCallback callback) override;
+ void UpdatePrintSettings(int32_t cookie, base::Value job_settings,
+ UpdatePrintSettingsCallback callback) override;
void ShowInvalidPrinterSettingsError() override;
void PrintingFailed(int32_t cookie) override;
diff --git a/src/webenginewidgets/printer_worker.cpp b/src/core/printing/printer_worker.cpp
index 8e1c2a985..cbd6b8da3 100644
--- a/src/webenginewidgets/printer_worker.cpp
+++ b/src/core/printing/printer_worker.cpp
@@ -47,14 +47,11 @@
namespace QtWebEngineCore {
PrinterWorker::PrinterWorker(QSharedPointer<QByteArray> data, QPrinter *printer)
- : m_data(data)
- , m_printer(printer)
+ : m_data(data), m_printer(printer)
{
}
-PrinterWorker::~PrinterWorker()
-{
-}
+PrinterWorker::~PrinterWorker() { }
void PrinterWorker::print()
{
@@ -107,15 +104,17 @@ void PrinterWorker::print()
for (int i = 0; true; i++) {
QSizeF documentSize = (pdfiumWrapper.pageSize(currentPageIndex - 1) * resolution);
bool isLandscape = documentSize.width() > documentSize.height();
- m_printer->setPageOrientation(isLandscape ? QPageLayout::Landscape : QPageLayout::Portrait);
+ m_printer->setPageOrientation(isLandscape ? QPageLayout::Landscape
+ : QPageLayout::Portrait);
QRectF pageRect = m_printer->pageRect(QPrinter::DevicePixel);
documentSize = documentSize.scaled(pageRect.size(), Qt::KeepAspectRatio);
- // setPageOrientation has to be called before qpainter.begin() or before qprinter.newPage() so correct metrics is used,
- // therefore call begin now for only first page
+ // setPageOrientation has to be called before qpainter.begin() or before
+ // qprinter.newPage() so correct metrics is used, therefore call begin now for only
+ // first page
if (!painter.isActive() && !painter.begin(m_printer)) {
qWarning("Failure to print on printer %ls: Could not open printer for painting.",
- qUtf16Printable(m_printer->printerName()));
+ qUtf16Printable(m_printer->printerName()));
Q_EMIT resultReady(false);
return;
}
@@ -125,7 +124,7 @@ void PrinterWorker::print()
for (int printedPages = 0; printedPages < pageCopies; printedPages++) {
if (m_printer->printerState() == QPrinter::Aborted
- || m_printer->printerState() == QPrinter::Error) {
+ || m_printer->printerState() == QPrinter::Error) {
Q_EMIT resultReady(false);
return;
}
@@ -133,12 +132,13 @@ void PrinterWorker::print()
if (printedPages > 0)
m_printer->newPage();
- QImage currentImage = pdfiumWrapper.pageAsQImage(currentPageIndex - 1,documentSize.width(),documentSize.height());
+ QImage currentImage = pdfiumWrapper.pageAsQImage(
+ currentPageIndex - 1, documentSize.width(), documentSize.height());
if (currentImage.isNull()) {
Q_EMIT resultReady(false);
return;
}
- painter.drawImage(0,0, currentImage);
+ painter.drawImage(0, 0, currentImage);
}
if (currentPageIndex == toPage)
diff --git a/src/webenginewidgets/printer_worker.h b/src/core/printing/printer_worker.h
index 96025c90e..9d1192bd2 100644
--- a/src/webenginewidgets/printer_worker.h
+++ b/src/core/printing/printer_worker.h
@@ -61,7 +61,7 @@ QT_END_NAMESPACE
namespace QtWebEngineCore {
-class PrinterWorker : public QObject
+class Q_WEBENGINECORE_PRIVATE_EXPORT PrinterWorker : public QObject
{
Q_OBJECT
public:
@@ -83,6 +83,6 @@ private:
} // namespace QtWebEngineCore
-Q_DECLARE_METATYPE(QtWebEngineCore::PrinterWorker*)
+Q_DECLARE_METATYPE(QtWebEngineCore::PrinterWorker *)
#endif // PRINTER_WORKER_H
diff --git a/src/core/printing/printing_message_filter_qt.cpp b/src/core/printing/printing_message_filter_qt.cpp
index 8d6833dce..f31a8a6a8 100644
--- a/src/core/printing/printing_message_filter_qt.cpp
+++ b/src/core/printing/printing_message_filter_qt.cpp
@@ -51,8 +51,6 @@
#include "chrome/browser/printing/printer_query.h"
#include "components/printing/browser/print_manager_utils.h"
#include "components/printing/common/print_messages.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/common/child_process_host.h"
namespace QtWebEngineCore {
@@ -75,8 +73,6 @@ bool PrintingMessageFilterQt::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PrintingMessageFilterQt, message)
IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_ScriptedPrint, OnScriptedPrint)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_UpdatePrintSettings,
- OnUpdatePrintSettings)
IPC_MESSAGE_HANDLER(PrintHostMsg_CheckForCancel, OnCheckForCancel)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -127,61 +123,9 @@ void PrintingMessageFilterQt::OnScriptedPrintReply(
}
}
-void PrintingMessageFilterQt::OnUpdatePrintSettings(int document_cookie,
- base::Value job_settings,
- IPC::Message* reply_msg) {
- if (!job_settings.is_dict() ||
- !job_settings.FindIntKey(printing::kSettingPrinterType)) {
- // Reply with null query.
- OnUpdatePrintSettingsReply(nullptr, reply_msg);
- return;
- }
-
- std::unique_ptr<printing::PrinterQuery> printer_query =
- queue_->PopPrinterQuery(document_cookie);
- if (!printer_query.get()) {
- printer_query = queue_->CreatePrinterQuery(
- content::ChildProcessHost::kInvalidUniqueID, MSG_ROUTING_NONE);
- }
- auto* printer_query_ptr = printer_query.get();
- printer_query_ptr->SetSettings(
- std::move(job_settings),
- base::BindOnce(&PrintingMessageFilterQt::OnUpdatePrintSettingsReply, this,
- std::move(printer_query), reply_msg));
-}
-
-void PrintingMessageFilterQt::OnUpdatePrintSettingsReply(std::unique_ptr<printing::PrinterQuery> printer_query,
- IPC::Message* reply_msg) {
- printing::mojom::PrintPagesParams params;
- params.params = printing::mojom::PrintParams::New();
- if (!printer_query.get() ||
- printer_query->last_status() != printing::PrintingContext::OK) {
- params.params.reset();
- } else {
- RenderParamsFromPrintSettings(printer_query->settings(), params.params.get());
- params.params->document_cookie = printer_query->cookie();
- params.pages = printing::PageRange::GetPages(printer_query->settings().ranges());
- }
-
- PrintHostMsg_UpdatePrintSettings::WriteReplyParams(
- reply_msg,
- params,
- printer_query.get() &&
- (printer_query->last_status() == printing::PrintingContext::CANCEL));
- Send(reply_msg);
- // If user hasn't cancelled.
- if (printer_query) {
- if (printer_query->cookie() && printer_query->settings().dpi()) {
- queue_->QueuePrinterQuery(std::move(printer_query));
- } else {
- printer_query->StopWorker();
- }
- }
-}
-
void PrintingMessageFilterQt::OnCheckForCancel(const printing::mojom::PreviewIds& ids,
bool* cancel) {
*cancel = false;
}
-} // namespace printing
+} // namespace QtWebEngineCore
diff --git a/src/core/printing/printing_message_filter_qt.h b/src/core/printing/printing_message_filter_qt.h
index 3a449af70..4597f7e6a 100644
--- a/src/core/printing/printing_message_filter_qt.h
+++ b/src/core/printing/printing_message_filter_qt.h
@@ -58,6 +58,7 @@ class PrinterQuery;
}
namespace QtWebEngineCore {
+
// This class filters out incoming printing related IPC messages for the
// renderer process on the IPC thread.
class PrintingMessageFilterQt : public content::BrowserMessageFilter {
@@ -83,15 +84,6 @@ class PrintingMessageFilterQt : public content::BrowserMessageFilter {
void OnScriptedPrintReply(std::unique_ptr<printing::PrinterQuery> printer_query,
IPC::Message* reply_msg);
- // Modify the current print settings based on |job_settings|. The task is
- // handled by the print worker thread and the UI thread. The reply occurs on
- // the IO thread.
- void OnUpdatePrintSettings(int document_cookie,
- base::Value job_settings,
- IPC::Message* reply_msg);
- void OnUpdatePrintSettingsReply(std::unique_ptr<printing::PrinterQuery> printer_query,
- IPC::Message* reply_msg);
-
// Check to see if print preview has been cancelled.
void OnCheckForCancel(const printing::mojom::PreviewIds& ids, bool* cancel);
@@ -102,6 +94,6 @@ class PrintingMessageFilterQt : public content::BrowserMessageFilter {
DISALLOW_COPY_AND_ASSIGN(PrintingMessageFilterQt);
};
-} // namespace printing
+} // namespace QtWebEngineCore
#endif // PRINTING_PRINTING_MESSAGE_FILTER_QT_H_
diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp
index 4dab8aa34..9a6275a84 100644
--- a/src/core/profile_adapter.cpp
+++ b/src/core/profile_adapter.cpp
@@ -260,7 +260,7 @@ QString ProfileAdapter::dataPath() const
name = QStringLiteral("OffTheRecord");
else if (m_name.isEmpty())
name = QStringLiteral("UnknownProfile");
- return buildLocationFromStandardPath(QStandardPaths::writableLocation(QStandardPaths::DataLocation), name);
+ return buildLocationFromStandardPath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), name);
}
void ProfileAdapter::setDataPath(const QString &path)
@@ -588,7 +588,7 @@ void ProfileAdapter::setHttpAcceptLanguage(const QString &httpAcceptLanguage)
std::vector<content::WebContentsImpl *> list = content::WebContentsImpl::GetAllWebContents();
for (content::WebContentsImpl *web_contents : list) {
if (web_contents->GetBrowserContext() == m_profile.data()) {
- blink::mojom::RendererPreferences *rendererPrefs = web_contents->GetMutableRendererPrefs();
+ blink::RendererPreferences *rendererPrefs = web_contents->GetMutableRendererPrefs();
rendererPrefs->accept_languages = http_accept_language;
web_contents->SyncRendererPrefs();
}
diff --git a/src/core/profile_adapter.h b/src/core/profile_adapter.h
index caeff246a..e6e9ab7cb 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"
@@ -248,7 +247,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..11b567b97 100644
--- a/src/core/profile_qt.h
+++ b/src/core/profile_qt.h
@@ -48,9 +48,6 @@
#include "profile_io_data_qt.h"
#include <QtGlobal>
-QT_BEGIN_NAMESPACE
-class QStringList;
-QT_END_NAMESPACE
class InMemoryPrefStore;
class PrefService;
diff --git a/src/core/qtwebengine_resources.gni b/src/core/qtwebengine_resources.gni
index 3bf1a5d57..7ba7050df 100644
--- a/src/core/qtwebengine_resources.gni
+++ b/src/core/qtwebengine_resources.gni
@@ -34,6 +34,7 @@ repack("qtwebengine_repack_resources") {
"$root_gen_dir/net/net_resources.pak",
"$root_gen_dir/third_party/blink/public/resources/blink_resources.pak",
"$root_gen_dir/ui/resources/webui_resources.pak",
+ "$root_gen_dir/ui/resources/webui_generated_resources.pak",
]
output = "$root_out_dir/qtwebengine_resources.pak"
deps = [
@@ -51,6 +52,7 @@ repack("qtwebengine_repack_resources") {
"//net:net_resources_grit",
"//third_party/blink/public:resources_grit",
"//ui/resources:webui_resources_grd_grit",
+ "//ui/resources:webui_generated_resources_grd",
]
if (enable_extensions) {
diff --git a/src/core/qtwebengine_sources.gni b/src/core/qtwebengine_sources.gni
index 81a48cab4..473c58d72 100644
--- a/src/core/qtwebengine_sources.gni
+++ b/src/core/qtwebengine_sources.gni
@@ -39,8 +39,19 @@ source_set("qtwebengine_spellcheck_sources") {
}
}
+config("cpp17_config") {
+ # static initialized constexpr expressions must be compiled always as c++14 or always as c++17
+ # and our qtwebengine core sources use them as c++17
+ if (is_win) {
+ cflags_cc = [ "/std:c++17" ]
+ } else {
+ cflags_cc = [ "-std=c++17" ]
+ }
+}
+
source_set("qtwebengine_sources") {
configs += [
+ ":cpp17_config",
"//skia:skia_config",
"//third_party/boringssl:external_config",
]
@@ -168,8 +179,6 @@ source_set("qtwebengine_sources") {
if (enable_plugins) {
sources += [
- "//chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.cc",
- "//chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h",
"//chrome/renderer/pepper/pepper_flash_font_file_host.cc",
"//chrome/renderer/pepper/pepper_flash_font_file_host.h",
"//chrome/renderer/pepper/pepper_shared_memory_message_filter.cc",
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 e98c69c66..a35ab1b2d 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -44,9 +44,8 @@
#include "common/qt_messages.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 +57,6 @@
#include "components/viz/common/surfaces/frame_sink_id_allocator.h"
#include "components/viz/host/host_frame_sink_manager.h"
#include "content/browser/compositor/image_transport_factory.h"
-#include "content/browser/compositor/surface_utils.h"
#include "content/browser/renderer_host/display_util.h"
#include "content/browser/renderer_host/frame_tree.h"
#include "content/browser/renderer_host/frame_tree_node.h"
@@ -79,9 +77,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"
@@ -96,24 +92,11 @@
#include "content/app/resources/grit/content_resources.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 <QScopeGuard>
#include <QScreen>
-#include <QStyleHints>
-#include <QVariant>
-#include <QWheelEvent>
#include <QWindow>
-#include <QtGui/private/qinputcontrol_p.h>
namespace QtWebEngineCore {
@@ -136,50 +119,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.
@@ -189,83 +128,6 @@ static inline ui::GestureProvider::Config QtGestureProviderConfig() {
return config;
}
-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<QPair<int, QTouchEvent::TouchPoint>> &points, const base::TimeTicks &eventTime,
- Action action, const Qt::KeyboardModifiers modifiers, int index = -1)
- : touchPoints(points)
- , eventTime(eventTime)
- , action(action)
- , eventId(++s_eventId)
- , flags(flagsFromModifiers(modifiers))
- , index(index)
- {
- // index is only valid for ACTION_DOWN and ACTION_UP and should correspond to the point causing it
- // see blink_event_util.cc:ToWebTouchPointState for details
- Q_ASSERT_X((action != Action::POINTER_DOWN && action != Action::POINTER_UP && index == -1)
- || (action == Action::POINTER_DOWN && index >= 0 && touchPoint(index).state() == Qt::TouchPointPressed)
- || (action == Action::POINTER_UP && index >= 0 && touchPoint(index).state() == Qt::TouchPointReleased),
- "MotionEventQt", qPrintable(QString("action: %1, index: %2, state: %3").arg(int(action)).arg(index).arg(touchPoint(index).state())));
- }
-
- 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[pointer_index].first; }
- float GetX(size_t pointer_index) const override { return touchPoint(pointer_index).pos().x(); }
- float GetY(size_t pointer_index) const override { return touchPoint(pointer_index).pos().y(); }
- float GetRawX(size_t pointer_index) const override { return touchPoint(pointer_index).screenPos().x(); }
- float GetRawY(size_t pointer_index) const override { return touchPoint(pointer_index).screenPos().y(); }
- float GetTouchMajor(size_t pointer_index) const override
- {
- QSizeF diams = touchPoint(pointer_index).ellipseDiameters();
- return std::max(diams.height(), diams.width());
- }
- float GetTouchMinor(size_t pointer_index) const override
- {
- QSizeF diams = touchPoint(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 touchPoint(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 {
- bool isPen = touchPoint(pointer_index).flags() & QTouchEvent::TouchPoint::InfoFlag::Pen;
- return isPen ? ui::MotionEvent::ToolType::STYLUS : ui::MotionEvent::ToolType::FINGER;
- }
- int GetButtonState() const override { return 0; }
-
-private:
- QList<QPair<int, QTouchEvent::TouchPoint>> touchPoints;
- base::TimeTicks eventTime;
- Action action;
- const uint32_t eventId;
- int flags;
- int index;
- const QTouchEvent::TouchPoint& touchPoint(size_t i) const { return touchPoints[i].second; }
-};
-
extern display::Display toDisplayDisplay(int id, const QScreen *screen);
static blink::ScreenInfo screenInfoFromQScreen(QScreen *screen)
@@ -333,30 +195,13 @@ 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_guestInputEventObserver(new GuestInputEventObserverQt(this))
- , m_visible(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);
-
m_rootLayer.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
m_rootLayer->SetColor(SK_ColorTRANSPARENT);
@@ -376,9 +221,6 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget
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);
-
if (host()->delegate() && host()->delegate()->GetInputEventRouter())
host()->delegate()->GetInputEventRouter()->AddFrameSinkIdOwner(GetFrameSinkId(), this);
@@ -403,8 +245,6 @@ RenderWidgetHostViewQt::~RenderWidgetHostViewQt()
QObject::disconnect(m_adapterClientDestroyedConnection);
- m_displayFrameSink->disconnect(this);
-
if (text_input_manager_)
text_input_manager_->RemoveObserver(this);
@@ -422,7 +262,7 @@ void RenderWidgetHostViewQt::setDelegate(RenderWidgetHostViewQtDelegate* delegat
m_deferredShow = false;
Show();
}
- visualPropertiesChanged();
+ delegateClient()->visualPropertiesChanged();
}
void RenderWidgetHostViewQt::setAdapterClient(WebContentsAdapterClient *adapterClient)
@@ -464,7 +304,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());
}
@@ -501,7 +341,7 @@ content::BrowserAccessibilityManager* RenderWidgetHostViewQt::CreateBrowserAcces
// Set focus to the associated View component.
void RenderWidgetHostViewQt::Focus()
{
- if (!IsPopup())
+ if (!isPopup())
m_delegate->setKeyboardFocus();
host()->Focus();
}
@@ -556,7 +396,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()
@@ -571,7 +411,6 @@ void RenderWidgetHostViewQt::UpdateBackgroundColor()
m_rootLayer->SetColor(color);
m_uiCompositor->SetBackgroundColor(color);
- content::RenderViewHost *rvh = content::RenderViewHost::From(host());
if (color == SK_ColorTRANSPARENT)
host()->owner_delegate()->SetBackgroundOpaque(false);
}
@@ -582,7 +421,7 @@ blink::mojom::PointerLockResult RenderWidgetHostViewQt::LockMouse(bool request_u
if (request_unadjusted_movement)
return blink::mojom::PointerLockResult::kUnsupportedOptions;
- m_previousMousePosition = QCursor::pos();
+ delegateClient()->resetPreviousMousePosition();
m_delegate->lockMouse();
m_isMouseLocked = true;
qApp->setOverrideCursor(Qt::BlankCursor);
@@ -849,7 +688,7 @@ void RenderWidgetHostViewQt::GetScreenInfo(blink::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)
@@ -871,16 +710,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.has_value())
- 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);
}
@@ -890,14 +731,14 @@ void RenderWidgetHostViewQt::OnUpdateTextInputStateCalled(content::TextInputMana
}
// Ignore selection change triggered by ime composition unless it clears an actual text selection
- if (state->composition.has_value() && m_emptyPreviousSelection) {
+ if (state->composition.has_value() && 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)
@@ -908,7 +749,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();
}
}
@@ -932,82 +773,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
@@ -1062,36 +831,12 @@ 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;
- }
-}
-
-void RenderWidgetHostViewQt::scheduleUpdate()
-{
- m_taskRunner->PostTask(
- FROM_HERE,
- base::BindOnce(&RenderWidgetHostViewQt::callUpdate, m_weakPtrFactory.GetWeakPtr()));
+ m_adapterClient->didFirstVisuallyNonEmptyPaint();
}
-void RenderWidgetHostViewQt::callUpdate()
+Compositor::Id RenderWidgetHostViewQt::compositorId()
{
- 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)
-{
- return m_displayFrameSink->updatePaintNode(oldNode, m_delegate.get());
+ return m_uiCompositor->frame_sink_id();
}
void RenderWidgetHostViewQt::notifyShown()
@@ -1107,7 +852,7 @@ void RenderWidgetHostViewQt::notifyShown()
m_delegatedFrameHost->AttachToCompositor(m_uiCompositor.get());
m_delegatedFrameHost->WasShown(GetLocalSurfaceId(),
- m_viewRectInDips.size(),
+ toGfx(delegateClient()->viewRectInDips().size()),
nullptr);
}
@@ -1121,208 +866,7 @@ void RenderWidgetHostViewQt::notifyHidden()
m_delegatedFrameHost->DetachFromCompositor();
}
-void RenderWidgetHostViewQt::visualPropertiesChanged()
-{
- if (!m_delegate)
- 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();
- blink::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: {
- if (host()->delegate() && host()->delegate()->GetInputEventRouter()) {
- auto webEvent = WebEventFactory::toWebMouseEvent(event);
- host()->delegate()->GetInputEventRouter()->RouteMouseEvent(this, &webEvent, ui::LatencyInfo());
- }
- }
- 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();
-}
-
-void RenderWidgetHostViewQt::ProcessAckedTouchEvent(const content::TouchEventWithLatencyInfo &touch, blink::mojom::InputEventResultState ack_result)
-{
+void RenderWidgetHostViewQt::ProcessAckedTouchEvent(const content::TouchEventWithLatencyInfo &touch, blink::mojom::InputEventResultState ack_result) {
Q_UNUSED(touch);
const bool eventConsumed = ack_result == blink::mojom::InputEventResultState::kConsumed;
const bool isSetNonBlocking = content::InputEventResultStateIsSetNonBlocking(ack_result);
@@ -1341,284 +885,37 @@ void RenderWidgetHostViewQt::processMotionEvent(const ui::MotionEvent &motionEve
host()->delegate()->GetInputEventRouter()->RouteTouchEvent(this, &touchEvent, CreateLatencyInfo(touchEvent));
}
-QList<RenderWidgetHostViewQt::TouchPoint> RenderWidgetHostViewQt::mapTouchPoints(const QList<QTouchEvent::TouchPoint> &input)
-{
- QList<TouchPoint> output;
- for (int i = 0; i < input.size(); ++i) {
- const QTouchEvent::TouchPoint &point = input[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));
-
- output.append(qMakePair(it.value(), point));
- }
-
- Q_ASSERT(output.size() == std::accumulate(output.cbegin(), output.cend(), QSet<int>(),
- [] (QSet<int> s, const TouchPoint &p) { s.insert(p.second.id()); return s; }).size());
-
- for (auto &&point : qAsConst(input))
- if (point.state() == Qt::TouchPointReleased)
- m_touchIdMapping.remove(point.id());
-
- return output;
-}
-
-bool RenderWidgetHostViewQt::IsPopup() const
+bool RenderWidgetHostViewQt::isPopup() const
{
return widget_type_ == content::WidgetType::kPopup;
}
-void RenderWidgetHostViewQt::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 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::Type::kRawKeyDown && !m_editCommand.empty()) {
- ui::LatencyInfo latency;
- latency.set_source_event_type(ui::SourceEventType::KEY_PRESS);
- std::vector<blink::mojom::EditCommandPtr> commands;
- commands.emplace_back(blink::mojom::EditCommand::New(m_editCommand, ""));
- m_editCommand.clear();
- GetFocusedWidget()->ForwardKeyboardEventWithCommands(webEvent, latency, std::move(commands), nullptr);
- return;
- }
-
- bool keyDownTextInsertion = webEvent.GetType() == blink::WebInputEvent::Type::kRawKeyDown && webEvent.text[0];
- webEvent.skip_in_browser = keyDownTextInsertion;
- GetFocusedWidget()->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::Type::kChar);
- GetFocusedWidget()->ForwardKeyboardEvent(webEvent);
- }
-}
-
-void RenderWidgetHostViewQt::handleInputMethodEvent(QInputMethodEvent *ev)
+bool RenderWidgetHostViewQt::updateScreenInfo()
{
- // 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, ui::ImeTextSpan::UnderlineStyle::kSolid,
- 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) {
- if (auto *frameWidgetInputHandler = getFrameWidgetInputHandler())
- frameWidgetInputHandler->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;
-
- // Finish compostion: insert or erase text.
- if (!commitString.isEmpty() || replacementLength > 0) {
- 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()) {
- host()->ImeSetComposition(toString16(preeditString),
- underlines,
- replacementRange,
- selectionRange.start(),
- selectionRange.end());
- m_imeInProgress = true;
- }
-}
+ blink::ScreenInfo oldScreenInfo = m_screenInfo;
+ QScreen *screen = m_delegate->window() ? m_delegate->window()->screen() : nullptr;
+ m_screenInfo = screenInfoFromQScreen(screen);
-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();
+ return (m_screenInfo != oldScreenInfo);
}
-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, true);
+ GetMouseWheelPhaseHandler()->AddPhaseIfNeededAndScheduleEndEvent(webEvent, true);
if (host()->delegate() && host()->delegate()->GetInputEventRouter())
host()->delegate()->GetInputEventRouter()->RouteMouseWheelEvent(this, &webEvent, ui::LatencyInfo());
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, blink::mojom::InputEventResultState /*ack_result*/)
@@ -1656,277 +953,6 @@ content::MouseWheelPhaseHandler *RenderWidgetHostViewQt::GetMouseWheelPhaseHandl
return &m_mouseWheelPhaseHandler;
}
-#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) {
- if (host()->delegate() && host()->delegate()->GetInputEventRouter()) {
- auto webEvent = WebEventFactory::toWebGestureEvent(ev);
- host()->delegate()->GetInputEventRouter()->RouteGestureEvent(this, &webEvent, ui::LatencyInfo());
- }
- }
-}
-#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;
-
- auto touchPoints = mapTouchPoints(ev->touchPoints());
- // Make sure that POINTER_DOWN action is delivered before MOVE, and MOVE before POINTER_UP
- std::sort(touchPoints.begin(), touchPoints.end(), [] (const TouchPoint &l, const TouchPoint &r) {
- return l.second.state() < r.second.state();
- });
-
- auto sc = qScopeGuard([&] () {
- switch (ev->type()) {
- case QEvent::TouchCancel:
- for (auto &&it : qAsConst(touchPoints))
- m_touchIdMapping.remove(it.second.id());
- Q_FALLTHROUGH();
-
- case QEvent::TouchEnd:
- m_previousTouchPoints.clear();
- m_touchMotionStarted = false;
- break;
-
- default:
- m_previousTouchPoints = touchPoints;
- break;
- }
- });
-
- ui::MotionEvent::Action action;
- // Check first if the touch event should be routed to the selectionController
- if (!touchPoints.isEmpty()) {
- switch (touchPoints[0].second.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;
- }
- } 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.
- Q_ASSERT(ev->type() == QEvent::TouchCancel);
- touchPoints = m_previousTouchPoints;
- if (touchPoints.isEmpty())
- return;
-
- action = ui::MotionEvent::Action::CANCEL;
- }
-
- MotionEventQt me(touchPoints, eventTimestamp, action, ev->modifiers());
- if (m_touchSelectionController->WillHandleTouchEvent(me))
- 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);
- }
-
- return;
- }
- case QEvent::TouchEnd:
- 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
- }
-
- // MEMO for the basis of this logic look into:
- // * blink_event_util.cc:ToWebTouchPointState: which is used later to forward touch event
- // composed from motion event after gesture recognition
- // * gesture_detector.cc:GestureDetector::OnTouchEvent: contains logic for every motion
- // event action and corresponding gesture recognition routines
- // * input_router_imp.cc:InputRouterImp::SetMovementXYForTouchPoints: expectation about
- // touch event content like number of points for different states
-
- int lastPressIndex = -1;
- while ((lastPressIndex + 1) < touchPoints.size() && touchPoints[lastPressIndex + 1].second.state() == Qt::TouchPointPressed)
- ++lastPressIndex;
-
- switch (ev->type()) {
- case QEvent::TouchBegin:
- processMotionEvent(MotionEventQt(touchPoints.mid(lastPressIndex),
- eventTimestamp, ui::MotionEvent::Action::DOWN, ev->modifiers()));
- --lastPressIndex;
- Q_FALLTHROUGH();
-
- case QEvent::TouchUpdate:
- for (; lastPressIndex >= 0; --lastPressIndex) {
- Q_ASSERT(touchPoints[lastPressIndex].second.state() == Qt::TouchPointPressed);
- MotionEventQt me(touchPoints.mid(lastPressIndex), eventTimestamp, ui::MotionEvent::Action::POINTER_DOWN, ev->modifiers(), 0);
- processMotionEvent(me);
- }
-
- if (ev->touchPointStates() & Qt::TouchPointMoved)
- processMotionEvent(MotionEventQt(touchPoints, eventTimestamp, ui::MotionEvent::Action::MOVE, ev->modifiers()));
-
- Q_FALLTHROUGH();
-
- case QEvent::TouchEnd:
- while (!touchPoints.isEmpty() && touchPoints.back().second.state() == Qt::TouchPointReleased) {
- auto action = touchPoints.size() > 1 ? ui::MotionEvent::Action::POINTER_UP : ui::MotionEvent::Action::UP;
- int index = action == ui::MotionEvent::Action::POINTER_UP ? touchPoints.size() - 1 : -1;
- processMotionEvent(MotionEventQt(touchPoints, eventTimestamp, action, ev->modifiers(), index));
- touchPoints.pop_back();
- }
- break;
-
- default:
- Q_ASSERT_X(false, __FUNCTION__, "Other event types are expected to be already handled.");
- break;
- }
-}
-
-#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::Type::kMouseDown || webEvent.GetType() == blink::WebInputEvent::Type::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::Type::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::Type::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::Type::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
- }
-
- if (host()->delegate() && host()->delegate()->GetInputEventRouter())
- host()->delegate()->GetInputEventRouter()->RouteMouseEvent(this, &webEvent, ui::LatencyInfo());
-}
-
-void RenderWidgetHostViewQt::handleHoverEvent(QHoverEvent *ev)
-{
- if (host()->delegate() && host()->delegate()->GetInputEventRouter()) {
- auto webEvent = WebEventFactory::toWebMouseEvent(ev);
- host()->delegate()->GetInputEventRouter()->RouteMouseEvent(this, &webEvent, ui::LatencyInfo());
- }
-}
-
-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();
- }
-}
-
blink::mojom::FrameWidgetInputHandler *RenderWidgetHostViewQt::getFrameWidgetInputHandler()
{
auto *focused_widget = GetFocusedWidget();
@@ -2045,4 +1071,14 @@ ui::Compositor *RenderWidgetHostViewQt::GetCompositor()
return m_uiCompositor.get();
}
+base::Optional<content::DisplayFeature> RenderWidgetHostViewQt::GetDisplayFeature()
+{
+ return base::nullopt;
+}
+
+void RenderWidgetHostViewQt::SetDisplayFeatureForTesting(const content::DisplayFeature *)
+{
+ NOTIMPLEMENTED();
+}
+
} // namespace QtWebEngineCore
diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h
index 9c843e2a9..7e7b13fda 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;
@@ -76,43 +67,19 @@ class TouchSelectionController;
namespace QtWebEngineCore {
+class RenderWidgetHostViewQtDelegateClient;
class GuestInputEventObserverQt;
-class TouchHandleDrawableClient;
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 content::RenderFrameMetadataProvider::Observer
- , public DisplayConsumer
{
public:
- enum LoadVisuallyCommittedState {
- NotCommitted,
- DidFirstVisuallyNonEmptyPaint,
- DidFirstCompositorFrameSwap
- };
-
RenderWidgetHostViewQt(content::RenderWidgetHost* widget);
~RenderWidgetHostViewQt();
@@ -120,6 +87,7 @@ public:
void setDelegate(RenderWidgetHostViewQtDelegate *delegate);
WebContentsAdapterClient *adapterClient() { return m_adapterClient; }
void setAdapterClient(WebContentsAdapterClient *adapterClient);
+ RenderWidgetHostViewQtDelegateClient *delegateClient() const { return m_delegateClient.get(); }
void setGuest(content::RenderWidgetHostImpl *);
void InitAsChild(gfx::NativeView) override;
@@ -183,63 +151,45 @@ public:
void DidStopFlinging() override;
std::unique_ptr<content::SyntheticGestureTarget> CreateSyntheticGestureTarget() override;
ui::Compositor *GetCompositor() override;
+ base::Optional<content::DisplayFeature> GetDisplayFeature() override;
+ void SetDisplayFeatureForTesting(const content::DisplayFeature*) override;
+#if defined(OS_MAC)
+ void SetActive(bool active) override { QT_NOT_YET_IMPLEMENTED }
+ void SpeakSelection() override { QT_NOT_YET_IMPLEMENTED }
+ void ShowDefinitionForSelection() override { QT_NOT_YET_IMPLEMENTED }
+ void SetWindowFrameInScreen(const gfx::Rect&) override { QT_NOT_YET_IMPLEMENTED }
+#endif // defined(OS_MAC)
// 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_MAC)
- void SetActive(bool active) override { QT_NOT_YET_IMPLEMENTED }
- void SpeakSelection() override { QT_NOT_YET_IMPLEMENTED }
- void ShowDefinitionForSelection() override { QT_NOT_YET_IMPLEMENTED }
- void SetWindowFrameInScreen(const gfx::Rect&) override { QT_NOT_YET_IMPLEMENTED }
-#endif // defined(OS_MAC)
-
// 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;
void OnRenderFrameMetadataChangedBeforeActivation(const cc::RenderFrameMetadata &) override {}
void OnRenderFrameSubmission() override {}
void OnLocalSurfaceIdChanged(const cc::RenderFrameMetadata &) 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; }
@@ -248,88 +198,59 @@ public:
blink::mojom::FrameWidgetInputHandler *getFrameWidgetInputHandler();
ui::TextInputType getTextInputType() const;
+ void synchronizeVisualProperties(
+ const base::Optional<viz::LocalSurfaceId> &childSurfaceId);
+
private:
friend class DelegatedFrameHostClientQt;
- void processMotionEvent(const ui::MotionEvent &motionEvent);
- typedef QPair<int, QTouchEvent::TouchPoint> TouchPoint;
- QList<TouchPoint> mapTouchPoints(const QList<QTouchEvent::TouchPoint> &input);
-
- bool IsPopup() const;
-
- void selectionChanged();
-
- void synchronizeVisualProperties(const base::Optional<viz::LocalSurfaceId> &childSurfaceId);
-
- void callUpdate();
+ bool isPopup() const;
bool updateCursorFromResource(ui::mojom::CursorType type);
- // Geometry of the view in screen DIPs.
- gfx::Rect m_viewRectInDips;
- // Geometry of the window, including frame, in screen DIPs.
- gfx::Rect m_windowRectInDips;
- blink::ScreenInfo m_screenInfo;
-
scoped_refptr<base::SingleThreadTaskRunner> m_taskRunner;
+
std::unique_ptr<content::CursorManager> m_cursorManager;
ui::FilteredGestureProvider m_gestureProvider;
- base::TimeDelta m_eventsToNowDelta;
- bool m_sendMotionActionDown;
- bool m_touchMotionStarted;
- QMap<int, int> m_touchIdMapping;
- QList<TouchPoint> m_previousTouchPoints;
- std::unique_ptr<RenderWidgetHostViewQtDelegate> m_delegate;
std::unique_ptr<GuestInputEventObserverQt> m_guestInputEventObserver;
- bool m_visible;
- bool m_deferredShow = false;
- DelegatedFrameHostClientQt m_delegatedFrameHostClient{this};
- 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;
- LoadVisuallyCommittedState m_loadVisuallyCommittedState;
-
+ viz::FrameSinkId m_frameSinkId;
+ std::unique_ptr<RenderWidgetHostViewQtDelegateClient> m_delegateClient;
+ std::unique_ptr<RenderWidgetHostViewQtDelegate> m_delegate;
QMetaObject::Connection m_adapterClientDestroyedConnection;
- WebContentsAdapterClient *m_adapterClient;
- MultipleMouseClickHelper m_clickHelper;
-
- bool m_imeInProgress;
- bool m_receivedEmptyImeEvent;
- QPoint m_previousMousePosition;
- bool m_isMouseLocked;
+ WebContentsAdapterClient *m_adapterClient = nullptr;
+ bool m_isMouseLocked = false;
+ bool m_visible = false;
+ bool m_deferredShow = false;
gfx::Vector2dF m_lastScrollOffset;
gfx::SizeF m_lastContentsSize;
+ DelegatedFrameHostClientQt m_delegatedFrameHostClient { this };
+
+ // VIZ
+ blink::ScreenInfo m_screenInfo;
+ std::unique_ptr<content::DelegatedFrameHost> m_delegatedFrameHost;
+ std::unique_ptr<ui::Layer> m_rootLayer;
+ std::unique_ptr<ui::Compositor> m_uiCompositor;
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 5fda0eeb7..f9306dba9 100644
--- a/src/core/render_widget_host_view_qt_delegate.h
+++ b/src/core/render_widget_host_view_qt_delegate.h
@@ -53,37 +53,19 @@
#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 QSGNode;
-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() { }
@@ -98,16 +80,13 @@ public:
virtual void hide() = 0;
virtual bool isVisible() const = 0;
virtual QWindow* window() const = 0;
- virtual QSGTexture *createTextureFromImage(const QImage &) = 0;
- virtual QSGImageNode *createImageNode() = 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 adapterClientChanged(WebContentsAdapterClient *client) = 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..eb0a0ff12
--- /dev/null
+++ b/src/core/render_widget_host_view_qt_delegate_client.cpp
@@ -0,0 +1,1016 @@
+/****************************************************************************
+**
+** 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 "content/browser/renderer_host/render_widget_host_input_event_router.h"
+#include "ui/touch_selection/touch_selection_controller.h"
+
+#include <QEvent>
+#include <QInputMethodEvent>
+#include <QScopeGuard>
+#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();
+}
+
+typedef QPair<int, QTouchEvent::TouchPoint> TouchPoint;
+QList<TouchPoint> RenderWidgetHostViewQtDelegateClient::mapTouchPointIds(const QList<QTouchEvent::TouchPoint> &input)
+{
+ QList<TouchPoint> output;
+ for (int i = 0; i < input.size(); ++i) {
+ const QTouchEvent::TouchPoint &point = input[i];
+
+ int qtId = point.id();
+ QMap<int, int>::const_iterator it = m_touchIdMapping.find(qtId);
+ if (it == m_touchIdMapping.end()) {
+ Q_ASSERT_X(m_touchIdMapping.size() <= 16, "", "Number of mapped ids can't exceed 16 for velocity tracker");
+ it = m_touchIdMapping.insert(qtId, firstAvailableId(m_touchIdMapping));
+ }
+
+ output.append(qMakePair(it.value(), point));
+ }
+
+ Q_ASSERT(output.size() == std::accumulate(output.cbegin(), output.cend(), QSet<int>(),
+ [] (QSet<int> s, const TouchPoint &p) { s.insert(p.second.id()); return s; }).size());
+
+ for (auto &&point : qAsConst(input))
+ if (point.state() == QEventPoint::Released)
+ m_touchIdMapping.remove(point.id());
+
+ return output;
+}
+
+static uint32_t s_eventId = 0;
+class MotionEventQt : public ui::MotionEvent
+{
+public:
+ MotionEventQt(const QList<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)
+ {
+ // index is only valid for ACTION_DOWN and ACTION_UP and should correspond to the point causing it
+ // see blink_event_util.cc:ToWebTouchPointState for details
+ Q_ASSERT_X((action != Action::POINTER_DOWN && action != Action::POINTER_UP && index == -1)
+ || (action == Action::POINTER_DOWN && index >= 0 && touchPoint(index).state() == QEventPoint::Pressed)
+ || (action == Action::POINTER_UP && index >= 0 && touchPoint(index).state() == QEventPoint::Released),
+ "MotionEventQt", qPrintable(QString("action: %1, index: %2, state: %3").arg(int(action)).arg(index).arg(touchPoint(index).state())));
+ }
+
+ 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[pointer_index].first;
+ }
+ float GetX(size_t pointer_index) const override
+ {
+ return touchPoint(pointer_index).position().x();
+ }
+ float GetY(size_t pointer_index) const override
+ {
+ return touchPoint(pointer_index).position().y();
+ }
+ float GetRawX(size_t pointer_index) const override
+ {
+ return touchPoint(pointer_index).globalPosition().x();
+ }
+ float GetRawY(size_t pointer_index) const override
+ {
+ return touchPoint(pointer_index).globalPosition().y();
+ }
+ float GetTouchMajor(size_t pointer_index) const override
+ {
+ QSizeF diams = touchPoint(pointer_index).ellipseDiameters();
+ return std::max(diams.height(), diams.width());
+ }
+ float GetTouchMinor(size_t pointer_index) const override
+ {
+ QSizeF diams = touchPoint(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 touchPoint(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<TouchPoint> touchPoints;
+ base::TimeTicks eventTime;
+ Action action;
+ const uint32_t eventId;
+ int flags;
+ int index;
+ const QTouchEvent::TouchPoint& touchPoint(size_t i) const { return touchPoints[i].second; }
+};
+
+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:
+ if (m_rwhv->host()->delegate() && m_rwhv->host()->delegate()->GetInputEventRouter()) {
+ auto webEvent = WebEventFactory::toWebMouseEvent(event);
+ m_rwhv->host()->delegate()->GetInputEventRouter()->RouteMouseEvent(m_rwhv, &webEvent, ui::LatencyInfo());
+ }
+ 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::Type::kMouseDown
+ || webEvent.GetType() == blink::WebInputEvent::Type::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::Type::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::Type::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::Type::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
+ }
+
+ if (m_rwhv->host()->delegate() && m_rwhv->host()->delegate()->GetInputEventRouter())
+ m_rwhv->host()->delegate()->GetInputEventRouter()->RouteMouseEvent(m_rwhv, &webEvent, ui::LatencyInfo());
+}
+
+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::Type::kRawKeyDown && !m_editCommand.empty()) {
+ ui::LatencyInfo latency;
+ latency.set_source_event_type(ui::SourceEventType::KEY_PRESS);
+ std::vector<blink::mojom::EditCommandPtr> commands;
+ commands.emplace_back(blink::mojom::EditCommand::New(m_editCommand, ""));
+ m_editCommand.clear();
+ m_rwhv->GetFocusedWidget()->ForwardKeyboardEventWithCommands(webEvent, latency, std::move(commands), nullptr);
+ return;
+ }
+
+ bool keyDownTextInsertion =
+ webEvent.GetType() == blink::WebInputEvent::Type::kRawKeyDown && webEvent.text[0];
+ webEvent.skip_in_browser = keyDownTextInsertion;
+ m_rwhv->GetFocusedWidget()->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::Type::kChar);
+ m_rwhv->GetFocusedWidget()->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());
+ if (m_eventsToNowDelta == 0)
+ m_eventsToNowDelta = (base::TimeTicks::Now() - eventTimestamp).InMicroseconds();
+ eventTimestamp += base::TimeDelta::FromMicroseconds(m_eventsToNowDelta);
+
+ auto touchPoints = mapTouchPointIds(event->touchPoints());
+ // Make sure that POINTER_DOWN action is delivered before MOVE, and MOVE before POINTER_UP
+ std::sort(touchPoints.begin(), touchPoints.end(), [] (const TouchPoint &l, const TouchPoint &r) {
+ return l.second.state() < r.second.state();
+ });
+
+ auto sc = qScopeGuard([&] () {
+ switch (event->type()) {
+ case QEvent::TouchCancel:
+ for (auto &&it : qAsConst(touchPoints))
+ m_touchIdMapping.remove(it.second.id());
+ Q_FALLTHROUGH();
+
+ case QEvent::TouchEnd:
+ m_previousTouchPoints.clear();
+ m_touchMotionStarted = false;
+ break;
+
+ default:
+ m_previousTouchPoints = touchPoints;
+ break;
+ }
+ });
+
+ ui::MotionEvent::Action action;
+ // Check first if the touch event should be routed to the selectionController
+ if (!touchPoints.isEmpty()) {
+ switch (touchPoints[0].second.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;
+ }
+ } 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.
+ Q_ASSERT(event->type() == QEvent::TouchCancel);
+ touchPoints = m_previousTouchPoints;
+ if (touchPoints.isEmpty())
+ return;
+
+ action = ui::MotionEvent::Action::CANCEL;
+ }
+
+ MotionEventQt me(touchPoints, eventTimestamp, action, event->modifiers());
+ if (m_rwhv->getTouchSelectionController()->WillHandleTouchEvent(me))
+ 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);
+ }
+
+ return;
+ }
+ case QEvent::TouchEnd:
+ 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
+ }
+
+ // MEMO for the basis of this logic look into:
+ // * blink_event_util.cc:ToWebTouchPointState: which is used later to forward touch event
+ // composed from motion event after gesture recognition
+ // * gesture_detector.cc:GestureDetector::OnTouchEvent: contains logic for every motion
+ // event action and corresponding gesture recognition routines
+ // * input_router_imp.cc:InputRouterImp::SetMovementXYForTouchPoints: expectation about
+ // touch event content like number of points for different states
+
+ int lastPressIndex = -1;
+ while ((lastPressIndex + 1) < touchPoints.size() && touchPoints[lastPressIndex + 1].second.state() == QEventPoint::Pressed)
+ ++lastPressIndex;
+
+ switch (event->type()) {
+ case QEvent::TouchBegin:
+ m_rwhv->processMotionEvent(MotionEventQt(touchPoints.mid(lastPressIndex),
+ eventTimestamp, ui::MotionEvent::Action::DOWN, event->modifiers()));
+ --lastPressIndex;
+ Q_FALLTHROUGH();
+
+ case QEvent::TouchUpdate:
+ for (; lastPressIndex >= 0; --lastPressIndex) {
+ Q_ASSERT(touchPoints[lastPressIndex].second.state() == QEventPoint::Pressed);
+ MotionEventQt me(touchPoints.mid(lastPressIndex), eventTimestamp, ui::MotionEvent::Action::POINTER_DOWN, event->modifiers(), 0);
+ m_rwhv->processMotionEvent(me);
+ }
+
+ if (event->touchPointStates() & Qt::TouchPointMoved)
+ m_rwhv->processMotionEvent(MotionEventQt(touchPoints, eventTimestamp, ui::MotionEvent::Action::MOVE, event->modifiers()));
+
+ Q_FALLTHROUGH();
+
+ case QEvent::TouchEnd:
+ while (!touchPoints.isEmpty() && touchPoints.back().second.state() == QEventPoint::Released) {
+ auto action = touchPoints.size() > 1 ? ui::MotionEvent::Action::POINTER_UP : ui::MotionEvent::Action::UP;
+ int index = action == ui::MotionEvent::Action::POINTER_UP ? touchPoints.size() - 1 : -1;
+ m_rwhv->processMotionEvent(MotionEventQt(touchPoints, eventTimestamp, action, event->modifiers(), index));
+ touchPoints.pop_back();
+ }
+ break;
+
+ default:
+ Q_ASSERT_X(false, __FUNCTION__, "Other event types are expected to be already handled.");
+ break;
+ }
+}
+
+#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) {
+ auto *hostDelegate = m_rwhv->host()->delegate();
+ if (hostDelegate && hostDelegate->GetInputEventRouter()) {
+ auto webEvent = WebEventFactory::toWebGestureEvent(event);
+ hostDelegate->GetInputEventRouter()->RouteGestureEvent(m_rwhv, &webEvent, ui::LatencyInfo());
+ }
+ }
+}
+#endif
+
+void RenderWidgetHostViewQtDelegateClient::handleHoverEvent(QHoverEvent *event)
+{
+ auto *hostDelegate = m_rwhv->host()->delegate();
+ if (hostDelegate && hostDelegate->GetInputEventRouter()) {
+ auto webEvent = WebEventFactory::toWebMouseEvent(event);
+ hostDelegate->GetInputEventRouter()->RouteMouseEvent(m_rwhv, &webEvent, ui::LatencyInfo());
+ }
+}
+
+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,
+ ui::ImeTextSpan::UnderlineStyle::kSolid,
+ 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) {
+ if (auto *frameWidgetInputHandler = m_rwhv->getFrameWidgetInputHandler())
+ frameWidgetInputHandler->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;
+ QGuiApplication::postEvent(qApp->focusObject(), event->clone());
+ } 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..4ba5da227
--- /dev/null
+++ b/src/core/render_widget_host_view_qt_delegate_client.h
@@ -0,0 +1,168 @@
+/****************************************************************************
+**
+** 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
+ typedef QPair<int, QTouchEvent::TouchPoint> TouchPoint;
+ QList<TouchPoint> mapTouchPointIds(const QList<QTouchEvent::TouchPoint> &input);
+ QMap<int, int> m_touchIdMapping;
+ QList<TouchPoint> m_previousTouchPoints;
+ bool m_touchMotionStarted = false;
+ bool m_sendMotionActionDown = false;
+ int64_t m_eventsToNowDelta = 0; // delta for first touch in microseconds
+
+ // 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 d704e81b1..99e98985b 100644
--- a/src/core/renderer/content_renderer_client_qt.cpp
+++ b/src/core/renderer/content_renderer_client_qt.cpp
@@ -71,7 +71,6 @@
#include "third_party/blink/public/platform/web_url_error.h"
#include "third_party/blink/public/platform/web_url_request.h"
#include "third_party/blink/public/web/web_security_policy.h"
-#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/webui/jstemplate_builder.h"
@@ -153,7 +152,7 @@ void ContentRendererClientQt::RenderThreadStarted()
// Allow XMLHttpRequests from qrc to file.
// ### consider removing for Qt6
- blink::WebURL qrc(blink::KURL("qrc:"));
+ blink::WebURL qrc(GURL("qrc:"));
blink::WebString file(blink::WebString::FromASCII("file"));
blink::WebSecurityPolicy::AddOriginAccessAllowListEntry(
qrc, file, blink::WebString(), 0, network::mojom::CorsDomainMatchMode::kAllowSubdomains,
@@ -162,7 +161,7 @@ void ContentRendererClientQt::RenderThreadStarted()
#if BUILDFLAG(ENABLE_EXTENSIONS)
// Allow the pdf viewer extension to access chrome resources
- blink::WebURL pdfViewerExtension(blink::KURL("chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai"));
+ blink::WebURL pdfViewerExtension(GURL("chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai"));
blink::WebString chromeResources(blink::WebString::FromASCII("chrome"));
blink::WebSecurityPolicy::AddOriginAccessAllowListEntry(
pdfViewerExtension, chromeResources, blink::WebString(), 0,
@@ -265,16 +264,6 @@ void ContentRendererClientQt::RunScriptsAtDocumentIdle(content::RenderFrame *ren
#endif
}
-bool ContentRendererClientQt::HasErrorPage(int httpStatusCode)
-{
- // Use an internal error page, if we have one for the status code.
- if (!error_page::LocalizedError::HasStrings(error_page::Error::kHttpErrorDomain, httpStatusCode)) {
- return false;
- }
-
- return true;
-}
-
// To tap into the chromium localized strings. Ripped from the chrome layer (highly simplified).
void ContentRendererClientQt::PrepareErrorPage(content::RenderFrame *renderFrame,
const blink::WebURLError &web_error,
@@ -288,13 +277,13 @@ void ContentRendererClientQt::PrepareErrorPage(content::RenderFrame *renderFrame
}
void ContentRendererClientQt::PrepareErrorPageForHttpStatusError(content::RenderFrame *renderFrame,
- const GURL &unreachable_url,
+ const blink::WebURLError &error,
const std::string &httpMethod,
int http_status,
std::string *errorHtml)
{
GetNavigationErrorStringsInternal(renderFrame, httpMethod,
- error_page::Error::HttpError(unreachable_url, http_status),
+ error_page::Error::HttpError(error.url(), http_status),
errorHtml);
}
@@ -303,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) {
@@ -390,7 +379,7 @@ bool ContentRendererClientQt::OverrideCreatePlugin(content::RenderFrame *render_
if (!found)
*plugin = LoadablePluginPlaceholderQt::CreateLoadableMissingPlugin(render_frame, params)->plugin();
else
- *plugin = render_frame->CreatePlugin(info, params, nullptr);
+ *plugin = render_frame->CreatePlugin(info, params);
#endif // BUILDFLAG(ENABLE_PLUGINS)
return true;
}
@@ -637,10 +626,4 @@ void ContentRendererClientQt::WillSendRequest(blink::WebLocalFrame *frame,
#endif
}
-bool ContentRendererClientQt::RequiresWebComponentsV0(const GURL &url)
-{
- Q_UNUSED(url);
- return false;
-}
-
} // namespace QtWebEngineCore
diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h
index a0faec531..3b2e5e9d6 100644
--- a/src/core/renderer/content_renderer_client_qt.h
+++ b/src/core/renderer/content_renderer_client_qt.h
@@ -92,17 +92,16 @@ public:
void RenderThreadStarted() override;
void ExposeInterfacesToBrowser(mojo::BinderMap* binders) override;
void RenderFrameCreated(content::RenderFrame *render_frame) override;
- bool HasErrorPage(int http_status_code) override;
void PrepareErrorPage(content::RenderFrame *render_frame,
const blink::WebURLError &error,
const std::string &http_method,
std::string *error_html) override;
void PrepareErrorPageForHttpStatusError(content::RenderFrame *render_frame,
- const GURL &unreachable_url,
+ const blink::WebURLError &error,
const std::string &http_method,
int http_status,
- std::string *error_html) override;
+ std::string *error_html) override;
uint64_t VisitedLinkHash(const char *canonical_url, size_t length) override;
bool IsLinkVisited(uint64_t linkHash) override;
@@ -129,8 +128,6 @@ public:
GURL *new_url,
bool *attach_same_site_cookies) override;
- bool RequiresWebComponentsV0(const GURL &url) override;
-
#if QT_CONFIG(webengine_webrtc) && QT_CONFIG(webengine_extensions)
chrome::WebRtcLoggingAgentImpl *GetWebRtcLoggingAgent();
#endif
diff --git a/src/core/renderer/pepper/pepper_flash_renderer_host_qt.cpp b/src/core/renderer/pepper/pepper_flash_renderer_host_qt.cpp
deleted file mode 100644
index 9af05fd08..000000000
--- a/src/core/renderer/pepper/pepper_flash_renderer_host_qt.cpp
+++ /dev/null
@@ -1,432 +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$
-**
-****************************************************************************/
-
-// This is based on chrome/renderer/pepper/pepper_flash_renderer_host.cc:
-// 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 "pepper_flash_renderer_host_qt.h"
-
-#include <map>
-#include <vector>
-
-#include "base/lazy_instance.h"
-#include "base/macros.h"
-#include "base/metrics/histogram_macros.h"
-#include "base/strings/string_util.h"
-#include "content/public/renderer/pepper_plugin_instance.h"
-#include "content/public/renderer/render_thread.h"
-#include "content/public/renderer/renderer_ppapi_host.h"
-#include "ipc/ipc_message_macros.h"
-#include "net/http/http_util.h"
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/c/trusted/ppb_browser_font_trusted.h"
-#include "ppapi/host/dispatch_host_message.h"
-#include "ppapi/proxy/host_dispatcher.h"
-#include "ppapi/proxy/ppapi_messages.h"
-#include "ppapi/proxy/resource_message_params.h"
-#include "ppapi/proxy/serialized_structs.h"
-#include "ppapi/thunk/enter.h"
-#include "ppapi/thunk/ppb_image_data_api.h"
-#include "skia/ext/platform_canvas.h"
-#include "third_party/skia/include/core/SkCanvas.h"
-#include "third_party/skia/include/core/SkMatrix.h"
-#include "third_party/skia/include/core/SkPaint.h"
-#include "third_party/skia/include/core/SkPoint.h"
-#include "third_party/skia/include/core/SkTextBlob.h"
-#include "third_party/skia/include/core/SkTypeface.h"
-#include "third_party/skia/include/private/SkTemplates.h"
-#include "ui/gfx/geometry/rect.h"
-#include "url/gurl.h"
-
-using ppapi::thunk::EnterResourceNoLock;
-using ppapi::thunk::PPB_ImageData_API;
-
-namespace {
-
-// Some non-simple HTTP request headers that Flash may set.
-// (Please see http://www.w3.org/TR/cors/#simple-header for the definition of
-// simple headers.)
-//
-// The list and the enum defined below are used to collect data about request
-// headers used in PPB_Flash.Navigate() calls, in order to understand the impact
-// of rejecting PPB_Flash.Navigate() requests with non-simple headers.
-//
-// TODO(yzshen): We should be able to remove the histogram recording code once
-// we get the answer.
-const char* const kRejectedHttpRequestHeaders[] = {
- "authorization", //
- "cache-control", //
- "content-encoding", //
- "content-md5", //
- "content-type", // If the media type is not one of those covered by the
- // simple header definition.
- "expires", //
- "from", //
- "if-match", //
- "if-none-match", //
- "if-range", //
- "if-unmodified-since", //
- "pragma", //
- "referer" //
-};
-
-// Please note that new entries should be added right above
-// FLASH_NAVIGATE_USAGE_ENUM_COUNT, and existing entries shouldn't be re-ordered
-// or removed, since this ordering is used in a histogram.
-enum FlashNavigateUsage {
- // This section must be in the same order as kRejectedHttpRequestHeaders.
- REJECT_AUTHORIZATION = 0,
- REJECT_CACHE_CONTROL,
- REJECT_CONTENT_ENCODING,
- REJECT_CONTENT_MD5,
- REJECT_CONTENT_TYPE,
- REJECT_EXPIRES,
- REJECT_FROM,
- REJECT_IF_MATCH,
- REJECT_IF_NONE_MATCH,
- REJECT_IF_RANGE,
- REJECT_IF_UNMODIFIED_SINCE,
- REJECT_PRAGMA,
- REJECT_REFERER,
-
- // The navigate request is rejected because of headers not listed above
- // (e.g., custom headers).
- REJECT_OTHER_HEADERS,
-
- // Total number of rejected navigate requests.
- TOTAL_REJECTED_NAVIGATE_REQUESTS,
-
- // Total number of navigate requests.
- TOTAL_NAVIGATE_REQUESTS,
- FLASH_NAVIGATE_USAGE_ENUM_COUNT
-};
-
-static base::LazyInstance<std::map<std::string, FlashNavigateUsage>>::
- DestructorAtExit g_rejected_headers = LAZY_INSTANCE_INITIALIZER;
-
-bool IsSimpleHeader(const std::string& lower_case_header_name,
- const std::string& header_value)
-{
- if (lower_case_header_name == "accept" ||
- lower_case_header_name == "accept-language" ||
- lower_case_header_name == "content-language")
- return true;
-
- if (lower_case_header_name == "content-type") {
- std::string lower_case_mime_type;
- std::string lower_case_charset;
- bool had_charset = false;
- net::HttpUtil::ParseContentType(header_value,
- &lower_case_mime_type,
- &lower_case_charset,
- &had_charset,
- NULL);
- return lower_case_mime_type == "application/x-www-form-urlencoded" ||
- lower_case_mime_type == "multipart/form-data" ||
- lower_case_mime_type == "text/plain";
- }
-
- return false;
-}
-
-void RecordFlashNavigateUsage(FlashNavigateUsage usage)
-{
- DCHECK_NE(FLASH_NAVIGATE_USAGE_ENUM_COUNT, usage);
- UMA_HISTOGRAM_ENUMERATION(
- "Plugin.FlashNavigateUsage",
- usage,
- FLASH_NAVIGATE_USAGE_ENUM_COUNT);
-}
-
-} // namespace
-
-namespace QtWebEngineCore {
-
-PepperFlashRendererHostQt::PepperFlashRendererHostQt(
- content::RendererPpapiHost* host,
- PP_Instance instance,
- PP_Resource resource)
- : ResourceHost(host->GetPpapiHost(), instance, resource),
- host_(host),
- weak_factory_(this)
-{
-}
-
-PepperFlashRendererHostQt::~PepperFlashRendererHostQt() {
- // This object may be destroyed in the middle of a sync message. If that is
- // the case, make sure we respond to all the pending navigate calls.
- std::vector<ppapi::host::ReplyMessageContext>::reverse_iterator it;
- for (it = navigate_replies_.rbegin(); it != navigate_replies_.rend(); ++it)
- SendReply(*it, IPC::Message());
-}
-
-int32_t PepperFlashRendererHostQt::OnResourceMessageReceived(
- const IPC::Message& msg,
- ppapi::host::HostMessageContext* context)
-{
- PPAPI_BEGIN_MESSAGE_MAP(PepperFlashRendererHostQt, msg)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_GetProxyForURL,
- OnGetProxyForURL)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_SetInstanceAlwaysOnTop,
- OnSetInstanceAlwaysOnTop)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_DrawGlyphs,
- OnDrawGlyphs)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_Navigate, OnNavigate)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_IsRectTopmost,
- OnIsRectTopmost)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_Flash_InvokePrinting,
- OnInvokePrinting)
- PPAPI_END_MESSAGE_MAP()
- return PP_ERROR_FAILED;
-}
-
-int32_t PepperFlashRendererHostQt::OnGetProxyForURL(
- ppapi::host::HostMessageContext* host_context,
- const std::string& url)
-{
- GURL gurl(url);
- if (!gurl.is_valid())
- return PP_ERROR_FAILED;
- std::string proxy;
- bool result = content::RenderThread::Get()->ResolveProxy(gurl, &proxy);
- if (!result)
- return PP_ERROR_FAILED;
- host_context->reply_msg = PpapiPluginMsg_Flash_GetProxyForURLReply(proxy);
- return PP_OK;
-}
-
-int32_t PepperFlashRendererHostQt::OnSetInstanceAlwaysOnTop(
- ppapi::host::HostMessageContext* host_context,
- bool on_top)
-{
- content::PepperPluginInstance* plugin_instance =
- host_->GetPluginInstance(pp_instance());
- if (plugin_instance)
- plugin_instance->SetAlwaysOnTop(on_top);
- return PP_OK;
-}
-
-int32_t PepperFlashRendererHostQt::OnDrawGlyphs(
- ppapi::host::HostMessageContext* host_context,
- ppapi::proxy::PPBFlash_DrawGlyphs_Params params)
-{
- if (params.glyph_indices.size() != params.glyph_advances.size() ||
- params.glyph_indices.empty())
- return PP_ERROR_FAILED;
-
- int weight = (params.font_desc.weight + 1) * 100;
- SkFontStyle::Slant slant = SkFontStyle::kUpright_Slant;
- if (params.font_desc.italic)
- slant = SkFontStyle::kItalic_Slant;
- SkFontStyle style(weight, SkFontStyle::kNormal_Width, slant);
- sk_sp<SkTypeface> typeface(
- SkTypeface::MakeFromName(params.font_desc.face.c_str(), style));
- if (!typeface)
- return PP_ERROR_FAILED;
-
- EnterResourceNoLock<PPB_ImageData_API> enter(params.image_data.host_resource(), true);
- if (enter.failed())
- return PP_ERROR_FAILED;
-
- PPB_ImageData_API* image = static_cast<PPB_ImageData_API*>(enter.object());
- SkCanvas* canvas = image->GetCanvas();
- bool needs_unmapping = false;
- if (!canvas) {
- needs_unmapping = true;
- image->Map();
- canvas = image->GetCanvas();
- if (!canvas)
- return PP_ERROR_FAILED; // Failure mapping.
- }
-
- SkAutoCanvasRestore acr(canvas, true);
-
- // Clip is applied in pixels before the transform.
- SkRect clip_rect = {
- SkIntToScalar(params.clip.point.x), SkIntToScalar(params.clip.point.y),
- SkIntToScalar(params.clip.point.x + params.clip.size.width),
- SkIntToScalar(params.clip.point.y + params.clip.size.height)};
- canvas->clipRect(clip_rect);
-
- SkMatrix matrix;
- matrix.set(SkMatrix::kMScaleX, SkFloatToScalar(params.transformation[0][0]));
- matrix.set(SkMatrix::kMSkewX, SkFloatToScalar(params.transformation[0][1]));
- matrix.set(SkMatrix::kMTransX, SkFloatToScalar(params.transformation[0][2]));
- matrix.set(SkMatrix::kMSkewY, SkFloatToScalar(params.transformation[1][0]));
- matrix.set(SkMatrix::kMScaleY, SkFloatToScalar(params.transformation[1][1]));
- matrix.set(SkMatrix::kMTransY, SkFloatToScalar(params.transformation[1][2]));
- matrix.set(SkMatrix::kMPersp0, SkFloatToScalar(params.transformation[2][0]));
- matrix.set(SkMatrix::kMPersp1, SkFloatToScalar(params.transformation[2][1]));
- matrix.set(SkMatrix::kMPersp2, SkFloatToScalar(params.transformation[2][2]));
- canvas->concat(matrix);
-
- SkPaint paint;
- paint.setColor(params.color);
-
- SkFont font(std::move(typeface), SkIntToScalar(params.font_desc.size));
- font.setHinting(SkFontHinting::kFull);
- if (params.allow_subpixel_aa) {
- font.setSubpixel(true);
- font.setEdging(SkFont::Edging::kSubpixelAntiAlias);
- }
-
- SkScalar x = SkIntToScalar(params.position.x);
- SkScalar y = SkIntToScalar(params.position.y);
-
- // Build up the skia advances.
- size_t glyph_count = params.glyph_indices.size();
- if (glyph_count) {
- SkTextBlobBuilder builder;
- auto rec = builder.allocRunPos(font, glyph_count);
- memcpy(rec.glyphs, &params.glyph_indices[0], glyph_count * 2);
- SkPoint* pos = reinterpret_cast<SkPoint*>(rec.pos);
- for (uint32_t i = 0; i < glyph_count; i++) {
- pos[i].set(x, y);
- x += SkFloatToScalar(params.glyph_advances[i].x);
- y += SkFloatToScalar(params.glyph_advances[i].y);
- }
- canvas->drawTextBlob(builder.make(), 0, 0, paint);
- }
-
- if (needs_unmapping)
- image->Unmap();
-
- return PP_OK;
-}
-
-// CAUTION: This code is subtle because Navigate is a sync call which may
-// cause re-entrancy or cause the instance to be destroyed. If the instance
-// is destroyed we need to ensure that we respond to all outstanding sync
-// messages so that the plugin process does not remain blocked.
-int32_t PepperFlashRendererHostQt::OnNavigate(
- ppapi::host::HostMessageContext* host_context,
- const ppapi::URLRequestInfoData& data,
- const std::string& target,
- bool from_user_action)
-{
- // If our PepperPluginInstance is already destroyed, just return a failure.
- content::PepperPluginInstance* plugin_instance =
- host_->GetPluginInstance(pp_instance());
- if (!plugin_instance)
- return PP_ERROR_FAILED;
-
- std::map<std::string, FlashNavigateUsage>& rejected_headers =
- g_rejected_headers.Get();
- if (rejected_headers.empty()) {
- for (size_t i = 0; i < base::size(kRejectedHttpRequestHeaders); ++i)
- rejected_headers[kRejectedHttpRequestHeaders[i]] =
- static_cast<FlashNavigateUsage>(i);
- }
-
- net::HttpUtil::HeadersIterator header_iter(
- data.headers.begin(), data.headers.end(), "\n\r");
- bool rejected = false;
- while (header_iter.GetNext()) {
- std::string lower_case_header_name =
- base::ToLowerASCII(header_iter.name());
- if (!IsSimpleHeader(lower_case_header_name, header_iter.values())) {
- rejected = true;
-
- std::map<std::string, FlashNavigateUsage>::const_iterator iter =
- rejected_headers.find(lower_case_header_name);
- FlashNavigateUsage usage =
- iter != rejected_headers.end() ? iter->second : REJECT_OTHER_HEADERS;
- RecordFlashNavigateUsage(usage);
- }
- }
-
- RecordFlashNavigateUsage(TOTAL_NAVIGATE_REQUESTS);
- if (rejected) {
- RecordFlashNavigateUsage(TOTAL_REJECTED_NAVIGATE_REQUESTS);
- return PP_ERROR_NOACCESS;
- }
-
- // Navigate may call into Javascript (e.g. with a "javascript:" URL),
- // or do things like navigate away from the page, either one of which will
- // need to re-enter into the plugin. It is safe, because it is essentially
- // equivalent to NPN_GetURL, where Flash would expect re-entrancy.
- ppapi::proxy::HostDispatcher* host_dispatcher =
- ppapi::proxy::HostDispatcher::GetForInstance(pp_instance());
- host_dispatcher->set_allow_plugin_reentrancy();
-
- // Grab a weak pointer to ourselves on the stack so we can check if we are
- // still alive.
- base::WeakPtr<PepperFlashRendererHostQt> weak_ptr = weak_factory_.GetWeakPtr();
- // Keep track of reply contexts in case we are destroyed during a Navigate
- // call. Even if we are destroyed, we still need to send these replies to
- // unblock the plugin process.
- navigate_replies_.push_back(host_context->MakeReplyMessageContext());
- plugin_instance->Navigate(data, target.c_str(), from_user_action);
- // This object might have been destroyed by this point. If it is destroyed
- // the reply will be sent in the destructor. Otherwise send the reply here.
- if (weak_ptr.get()) {
- SendReply(navigate_replies_.back(), IPC::Message());
- navigate_replies_.pop_back();
- }
-
- // Return PP_OK_COMPLETIONPENDING so that no reply is automatically sent.
- return PP_OK_COMPLETIONPENDING;
-}
-
-int32_t PepperFlashRendererHostQt::OnIsRectTopmost(
- ppapi::host::HostMessageContext* host_context,
- const PP_Rect& rect)
-{
- content::PepperPluginInstance* plugin_instance =
- host_->GetPluginInstance(pp_instance());
- if (plugin_instance &&
- plugin_instance->IsRectTopmost(
- gfx::Rect(
- rect.point.x,
- rect.point.y,
- rect.size.width,
- rect.size.height)))
- return PP_OK;
- return PP_ERROR_FAILED;
-}
-
-int32_t PepperFlashRendererHostQt::OnInvokePrinting(
- ppapi::host::HostMessageContext* host_context)
-{
- return PP_ERROR_FAILED;
-}
-
-} //QtWebEngineCore
diff --git a/src/core/renderer/pepper/pepper_flash_renderer_host_qt.h b/src/core/renderer/pepper/pepper_flash_renderer_host_qt.h
deleted file mode 100644
index ae6bc0876..000000000
--- a/src/core/renderer/pepper/pepper_flash_renderer_host_qt.h
+++ /dev/null
@@ -1,107 +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 PEPPER_FLASH_RENDERER_HOST_QT_H
-#define PEPPER_FLASH_RENDERER_HOST_QT_H
-
-#include <string>
-#include <vector>
-
-#include "base/memory/weak_ptr.h"
-#include "ppapi/host/host_message_context.h"
-#include "ppapi/host/resource_host.h"
-
-struct PP_Rect;
-
-namespace ppapi {
-struct URLRequestInfoData;
-}
-
-namespace ppapi {
-namespace proxy {
-struct PPBFlash_DrawGlyphs_Params;
-}
-}
-
-namespace content {
-class RendererPpapiHost;
-}
-
-namespace QtWebEngineCore {
-
-class PepperFlashRendererHostQt : public ppapi::host::ResourceHost {
-public:
- PepperFlashRendererHostQt(content::RendererPpapiHost* host,
- PP_Instance instance,
- PP_Resource resource);
- ~PepperFlashRendererHostQt() override;
-
- // ppapi::host::ResourceHost override.
- int32_t OnResourceMessageReceived(
- const IPC::Message& msg,
- ppapi::host::HostMessageContext* context) override;
-
-private:
- int32_t OnGetProxyForURL(ppapi::host::HostMessageContext* host_context,
- const std::string& url);
- int32_t OnSetInstanceAlwaysOnTop(
- ppapi::host::HostMessageContext* host_context,
- bool on_top);
- int32_t OnDrawGlyphs(ppapi::host::HostMessageContext* host_context,
- ppapi::proxy::PPBFlash_DrawGlyphs_Params params);
- int32_t OnNavigate(ppapi::host::HostMessageContext* host_context,
- const ppapi::URLRequestInfoData& data,
- const std::string& target,
- bool from_user_action);
- int32_t OnIsRectTopmost(ppapi::host::HostMessageContext* host_context,
- const PP_Rect& rect);
- int32_t OnInvokePrinting(ppapi::host::HostMessageContext* host_context);
-
- // A stack of ReplyMessageContexts to track Navigate() calls which have not
- // yet been replied to.
- std::vector<ppapi::host::ReplyMessageContext> navigate_replies_;
-
- content::RendererPpapiHost* host_;
- base::WeakPtrFactory<PepperFlashRendererHostQt> weak_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(PepperFlashRendererHostQt);
-};
-
-} //QtWebEngineCore
-#endif // PEPPER_FLASH_RENDERER_HOST_QT_H
diff --git a/src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp b/src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp
index 1b9de4d4d..83dcf8157 100644
--- a/src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp
+++ b/src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp
@@ -43,7 +43,6 @@
// found in the LICENSE.Chromium file.
#include "pepper_renderer_host_factory_qt.h"
-#include "pepper_flash_renderer_host_qt.h"
#include "qtwebenginecoreglobal_p.h"
#include "base/memory/ptr_util.h"
@@ -82,25 +81,6 @@ std::unique_ptr<ppapi::host::ResourceHost> PepperRendererHostFactoryQt::CreateRe
if (!host_->IsValidInstance(instance))
return nullptr;
- if (host_->GetPpapiHost()->permissions().HasPermission(ppapi::PERMISSION_FLASH)) {
- switch (message.type()) {
- case PpapiHostMsg_Flash_Create::ID:
- return base::WrapUnique(new PepperFlashRendererHostQt(host_, instance, resource));
- case PpapiHostMsg_FlashMenu_Create::ID: {
- ppapi::host::ReplyMessageContext reply_context(
- ppapi::proxy::ResourceMessageReplyParams(resource, 0),
- NULL,
- MSG_ROUTING_NONE);
- reply_context.params.set_result(PP_ERROR_USERCANCEL);
- host_->GetPpapiHost()->SendReply(reply_context, PpapiPluginMsg_FlashMenu_ShowReply(-1));
- break;
- }
- case PpapiHostMsg_FlashFullscreen_Create::ID:
- // Not implemented
- break;
- }
- }
-
// TODO(raymes): PDF also needs access to the FlashFontFileHost currently.
// We should either rename PPB_FlashFont_File to PPB_FontFile_Private or get
// rid of its use in PDF if possible.
@@ -114,9 +94,6 @@ std::unique_ptr<ppapi::host::ResourceHost> PepperRendererHostFactoryQt::CreateRe
return base::WrapUnique(new PepperFlashFontFileHost(host_, instance, resource, description, charset));
break;
}
- case PpapiHostMsg_FlashDRM_Create::ID:
- // Not implemented
- break;
}
}
diff --git a/src/core/renderer/user_resource_controller.cpp b/src/core/renderer/user_resource_controller.cpp
index c7b220fe6..89730e83f 100644
--- a/src/core/renderer/user_resource_controller.cpp
+++ b/src/core/renderer/user_resource_controller.cpp
@@ -198,8 +198,8 @@ void UserResourceController::runScripts(QtWebEngineCore::UserScriptData::Injecti
return;
const bool isMainFrame = renderFrame->IsMainFrame();
- QList<uint64_t> scriptsToRun = m_frameUserScriptMap.value(globalScriptsIndex).toList();
- scriptsToRun.append(m_frameUserScriptMap.value(renderFrame).toList());
+ QList<uint64_t> scriptsToRun = m_frameUserScriptMap.value(globalScriptsIndex);
+ scriptsToRun.append(m_frameUserScriptMap.value(renderFrame));
for (uint64_t id : qAsConst(scriptsToRun)) {
const QtWebEngineCore::UserScriptData &script = m_scripts.value(id);
@@ -346,7 +346,8 @@ void UserResourceController::addScriptForFrame(const QtWebEngineCore::UserScript
if (it == m_frameUserScriptMap.end())
it = m_frameUserScriptMap.insert(frame, UserScriptSet());
- (*it).insert(script.scriptId);
+ if (!(*it).contains(script.scriptId))
+ (*it).append(script.scriptId);
m_scripts.insert(script.scriptId, script);
}
@@ -357,7 +358,7 @@ void UserResourceController::removeScriptForFrame(const QtWebEngineCore::UserScr
if (it == m_frameUserScriptMap.end())
return;
- (*it).remove(script.scriptId);
+ (*it).removeOne(script.scriptId);
m_scripts.remove(script.scriptId);
}
diff --git a/src/core/renderer/user_resource_controller.h b/src/core/renderer/user_resource_controller.h
index 6c79d96fc..37e7175a4 100644
--- a/src/core/renderer/user_resource_controller.h
+++ b/src/core/renderer/user_resource_controller.h
@@ -91,7 +91,7 @@ private:
void runScripts(QtWebEngineCore::UserScriptData::InjectionPoint, blink::WebLocalFrame *);
- typedef QSet<uint64_t> UserScriptSet;
+ typedef QList<uint64_t> UserScriptSet;
typedef QHash<const content::RenderFrame *, UserScriptSet> FrameUserScriptMap;
FrameUserScriptMap m_frameUserScriptMap;
QHash<uint64_t, QtWebEngineCore::UserScriptData> m_scripts;
diff --git a/src/core/renderer/web_channel_ipc_transport.cpp b/src/core/renderer/web_channel_ipc_transport.cpp
index 520c492ea..1efefc1d0 100644
--- a/src/core/renderer/web_channel_ipc_transport.cpp
+++ b/src/core/renderer/web_channel_ipc_transport.cpp
@@ -153,19 +153,9 @@ void WebChannelTransport::NativeQtSendMessage(gin::Arguments *args)
return;
}
v8::Local<v8::String> jsonString = v8::Local<v8::String>::Cast(jsonValue);
-
- 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);
+ 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);
if (!m_remote) {
renderFrame->GetRemoteAssociatedInterfaces()->GetInterface(&m_remote);
@@ -173,7 +163,7 @@ void WebChannelTransport::NativeQtSendMessage(gin::Arguments *args)
}
DCHECK(renderFrame == m_renderFrame);
- m_remote->DispatchWebChannelMessage(std::vector<uint8_t>(rawData, rawData + size));
+ m_remote->DispatchWebChannelMessage(json);
}
gin::ObjectTemplateBuilder WebChannelTransport::GetObjectTemplateBuilder(v8::Isolate *isolate)
@@ -222,18 +212,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);
@@ -264,7 +250,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 4bed5f26d..276167a67 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/pepper/pepper_flash_browser_host_qt.cpp b/src/core/renderer_host/pepper/pepper_flash_browser_host_qt.cpp
deleted file mode 100644
index 8fa277e78..000000000
--- a/src/core/renderer_host/pepper/pepper_flash_browser_host_qt.cpp
+++ /dev/null
@@ -1,127 +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$
-**
-****************************************************************************/
-
-// This is based on chrome/browser/renderer_host/pepper/pepper_flash_browser_host.cc:
-// 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 "pepper_flash_browser_host_qt.h"
-
-#include "base/time/time.h"
-#include "content/public/browser/browser_ppapi_host.h"
-#include "ipc/ipc_message_macros.h"
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/host/dispatch_host_message.h"
-#include "ppapi/proxy/ppapi_messages.h"
-#include "ppapi/proxy/resource_message_params.h"
-#include "ppapi/shared_impl/time_conversion.h"
-#include "qtwebenginecoreglobal_p.h"
-
-#if defined(OS_WIN)
-#include <windows.h>
-#elif defined(OS_MAC)
-#include <CoreServices/CoreServices.h>
-#endif
-
-using content::BrowserPpapiHost;
-
-namespace QtWebEngineCore {
-
-PepperFlashBrowserHostQt::PepperFlashBrowserHostQt(BrowserPpapiHost* host,
- PP_Instance instance,
- PP_Resource resource)
- : ResourceHost(host->GetPpapiHost(), instance, resource),
- weak_factory_(this)
-{
-}
-
-PepperFlashBrowserHostQt::~PepperFlashBrowserHostQt() {}
-
-int32_t PepperFlashBrowserHostQt::OnResourceMessageReceived(
- const IPC::Message& msg,
- ppapi::host::HostMessageContext* context)
-{
- PPAPI_BEGIN_MESSAGE_MAP(PepperFlashBrowserHostQt, msg)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_Flash_UpdateActivity,
- OnUpdateActivity)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_GetLocalTimeZoneOffset,
- OnGetLocalTimeZoneOffset)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_Flash_GetLocalDataRestrictions,
- OnGetLocalDataRestrictions)
- PPAPI_END_MESSAGE_MAP()
- return PP_ERROR_FAILED;
-}
-
-int32_t PepperFlashBrowserHostQt::OnUpdateActivity(ppapi::host::HostMessageContext* host_context)
-{
-#if defined(OS_WIN)
- // Reading then writing back the same value to the screensaver timeout system
- // setting resets the countdown which prevents the screensaver from turning
- // on "for a while". As long as the plugin pings us with this message faster
- // than the screensaver timeout, it won't go on.
- int value = 0;
- if (SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &value, 0))
- SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, value, NULL, 0);
-#elif defined(OS_MAC)
- UpdateSystemActivity(OverallAct);
-#endif
- return PP_OK;
-}
-
-int32_t PepperFlashBrowserHostQt::OnGetLocalTimeZoneOffset(
- ppapi::host::HostMessageContext* host_context,
- const base::Time& t)
-{
- // The reason for this processing being in the browser process is that on
- // Linux, the localtime calls require filesystem access prohibited by the
- // sandbox.
- host_context->reply_msg = PpapiPluginMsg_Flash_GetLocalTimeZoneOffsetReply(
- ppapi::PPGetLocalTimeZoneOffset(t));
- return PP_OK;
-}
-
-int32_t PepperFlashBrowserHostQt::OnGetLocalDataRestrictions(
- ppapi::host::HostMessageContext* context)
-{
- QT_NOT_YET_IMPLEMENTED
- return PP_OK;
-}
-
-} // namespace QtWebEngineCore
diff --git a/src/core/renderer_host/pepper/pepper_flash_browser_host_qt.h b/src/core/renderer_host/pepper/pepper_flash_browser_host_qt.h
deleted file mode 100644
index d6d2c8656..000000000
--- a/src/core/renderer_host/pepper/pepper_flash_browser_host_qt.h
+++ /dev/null
@@ -1,85 +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 PEPPER_FLASH_BROWSER_HOST_QT_H
-#define PEPPER_FLASH_BROWSER_HOST_QT_H
-
-#include "base/memory/weak_ptr.h"
-#include "ppapi/host/host_message_context.h"
-#include "ppapi/host/resource_host.h"
-
-namespace base {
-class Time;
-}
-
-namespace content {
-class BrowserPpapiHost;
-}
-
-class GURL;
-
-namespace QtWebEngineCore {
-
-class PepperFlashBrowserHostQt : public ppapi::host::ResourceHost {
-public:
- PepperFlashBrowserHostQt(content::BrowserPpapiHost* host,
- PP_Instance instance,
- PP_Resource resource);
- ~PepperFlashBrowserHostQt() override;
-
- // ppapi::host::ResourceHost override.
- int32_t OnResourceMessageReceived(
- const IPC::Message& msg,
- ppapi::host::HostMessageContext* context) override;
-
-private:
- int32_t OnUpdateActivity(ppapi::host::HostMessageContext* host_context);
- int32_t OnGetLocalTimeZoneOffset(
- ppapi::host::HostMessageContext* host_context,
- const base::Time& t);
- int32_t OnGetLocalDataRestrictions(ppapi::host::HostMessageContext* context);
-
- base::WeakPtrFactory<PepperFlashBrowserHostQt> weak_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(PepperFlashBrowserHostQt);
-};
-
-} // namespace QtWebEngineCore
-
-#endif // PEPPER_FLASH_BROWSER_HOST_QT_H
diff --git a/src/core/renderer_host/pepper/pepper_host_factory_qt.cpp b/src/core/renderer_host/pepper/pepper_host_factory_qt.cpp
index 00ab4963b..6686f8b12 100644
--- a/src/core/renderer_host/pepper/pepper_host_factory_qt.cpp
+++ b/src/core/renderer_host/pepper/pepper_host_factory_qt.cpp
@@ -46,7 +46,6 @@
#include "base/memory/ptr_util.h"
#include "build/build_config.h"
-#include "chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h"
#include "content/public/browser/browser_ppapi_host.h"
#include "ppapi/host/message_filter_host.h"
#include "ppapi/host/ppapi_host.h"
@@ -54,7 +53,6 @@
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
-#include "pepper_flash_browser_host_qt.h"
#include "pepper_isolated_file_system_message_filter.h"
using ppapi::host::MessageFilterHost;
@@ -80,19 +78,6 @@ std::unique_ptr<ppapi::host::ResourceHost> PepperHostFactoryQt::CreateResourceHo
if (!host_->IsValidInstance(instance))
return nullptr;
- // Flash interfaces.
- if (host_->GetPpapiHost()->permissions().HasPermission(ppapi::PERMISSION_FLASH)) {
- switch (message.type()) {
- case PpapiHostMsg_Flash_Create::ID:
- return base::WrapUnique(new PepperFlashBrowserHostQt(host_, instance, resource));
- case PpapiHostMsg_FlashClipboard_Create::ID: {
- scoped_refptr<ResourceMessageFilter> clipboard_filter(new PepperFlashClipboardMessageFilter);
- return base::WrapUnique(new MessageFilterHost(
- host_->GetPpapiHost(), instance, resource, clipboard_filter));
- }
- }
- }
-
// Permissions for the following interfaces will be checked at the
// time of the corresponding instance's methods calls (because
// permission check can be performed only on the UI
diff --git a/src/core/renderer_host/user_resource_controller_host.cpp b/src/core/renderer_host/user_resource_controller_host.cpp
index cea246c37..58559848f 100644
--- a/src/core/renderer_host/user_resource_controller_host.cpp
+++ b/src/core/renderer_host/user_resource_controller_host.cpp
@@ -129,8 +129,6 @@ void UserResourceControllerHost::RenderProcessObserverHelper::RenderProcessHostD
void UserResourceControllerHost::addUserScript(const UserScript &script, WebContentsAdapter *adapter)
{
- if (script.isNull())
- return;
// Global scripts should be dispatched to all our render processes.
const bool isProfileWideScript = !adapter;
if (isProfileWideScript) {
@@ -161,8 +159,6 @@ void UserResourceControllerHost::addUserScript(const UserScript &script, WebCont
bool UserResourceControllerHost::removeUserScript(const UserScript &script, WebContentsAdapter *adapter)
{
- if (script.isNull())
- return false;
const bool isProfileWideScript = !adapter;
if (isProfileWideScript) {
QList<UserScript>::iterator it = std::find(m_profileWideScripts.begin(), m_profileWideScripts.end(), script);
diff --git a/src/core/renderer_host/user_resource_controller_host.h b/src/core/renderer_host/user_resource_controller_host.h
index 8b6099dcf..a88264f2d 100644
--- a/src/core/renderer_host/user_resource_controller_host.h
+++ b/src/core/renderer_host/user_resource_controller_host.h
@@ -78,6 +78,7 @@ class UserResourceControllerRenderFrame;
namespace QtWebEngineCore {
+class UserScript;
using UserResourceControllerRemote = mojo::AssociatedRemote<qtwebengine::mojom::UserResourceController>;
using UserResourceControllerRenderFrameRemote = mojo::AssociatedRemote<qtwebengine::mojom::UserResourceControllerRenderFrame>;
class WebContentsAdapter;
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 087e0e83b..ca6fb895e 100644
--- a/src/core/renderer_host/web_channel_ipc_transport_host.cpp
+++ b/src/core/renderer_host/web_channel_ipc_transport_host.cpp
@@ -93,12 +93,11 @@ 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();
qCDebug(log).nospace() << "sending webchannel message to " << frame << ": " << doc;
GetWebChannelIPCTransportRemote(frame)->DispatchWebChannelMessage(
- std::vector<uint8_t>(rawData, rawData + size), m_worldId);
+ std::vector<uint8_t>(json.begin(), json.end()), m_worldId);
}
void WebChannelIPCTransportHost::setWorldId(uint32_t worldId)
@@ -127,7 +126,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();
@@ -135,7 +134,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 d06483ee6..794238667 100644
--- a/src/core/renderer_host/web_channel_ipc_transport_host.h
+++ b/src/core/renderer_host/web_channel_ipc_transport_host.h
@@ -71,7 +71,6 @@ public:
private:
void setWorldId(content::RenderFrameHost *frame, uint32_t worldId);
void resetWorldId();
- void onWebChannelMessage(const std::vector<char> &message);
const mojo::AssociatedRemote<qtwebchannel::mojom::WebChannelTransportRender> &
GetWebChannelIPCTransportRemote(content::RenderFrameHost *rfh);
@@ -81,7 +80,7 @@ private:
void RenderFrameDeleted(content::RenderFrameHost *render_frame_host) 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 3723f97ea..a4cc57b76 100644
--- a/src/core/type_conversion.cpp
+++ b/src/core/type_conversion.cpp
@@ -311,4 +311,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 1152ed9a9..85fd763b4 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"
@@ -79,9 +80,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
}
@@ -275,6 +276,8 @@ FaviconInfo toFaviconInfo(const blink::mojom::FaviconURLPtr &favicon_url);
QList<QSslCertificate> toCertificateChain(net::X509Certificate *certificate);
+Qt::InputMethodHints toQtInputMethodHints(ui::TextInputType inputType);
+
} // namespace QtWebEngineCore
#endif // TYPE_CONVERSION_H
diff --git a/src/core/user_script.cpp b/src/core/user_script.cpp
index f4daaf7c6..1c8a78cd3 100644
--- a/src/core/user_script.cpp
+++ b/src/core/user_script.cpp
@@ -72,30 +72,19 @@ ASSERT_ENUMS_MATCH(UserScript::DocumentElementCreation, UserScriptData::Document
UserScript::UserScript()
: QSharedData()
{
+ static uint64_t idCount = 0;
+ m_scriptData.scriptId = idCount++;
}
-UserScript::UserScript(const UserScript &other)
- : QSharedData(other)
-{
- if (other.isNull())
- return;
- scriptData.reset(new UserScriptData(*other.scriptData));
- m_name = other.m_name;
-}
+UserScript::UserScript(const UserScript &other) = default;
-UserScript::~UserScript()
-{
-}
+UserScript::~UserScript() = default;
UserScript &UserScript::operator=(const UserScript &other)
{
- if (other.isNull()) {
- scriptData.reset();
- m_name = QString();
- return *this;
- }
- scriptData.reset(new UserScriptData(*other.scriptData));
+ m_scriptData = other.m_scriptData;
m_name = other.m_name;
+ m_url = other.m_url;
return *this;
}
@@ -107,104 +96,82 @@ QString UserScript::name() const
void UserScript::setName(const QString &name)
{
m_name = name;
- initData();
- scriptData->url = GURL(QStringLiteral("userScript:%1").arg(name).toStdString());
+ m_scriptData.url = GURL(QStringLiteral("userScript:%1").arg(name).toStdString());
}
QString UserScript::sourceCode() const
{
- if (isNull())
- return QString();
- return toQt(scriptData->source);
+ return toQt(m_scriptData.source);
}
void UserScript::setSourceCode(const QString &source)
{
- initData();
- scriptData->source = source.toStdString();
+ m_scriptData.source = source.toStdString();
parseMetadataHeader();
}
-UserScript::InjectionPoint UserScript::injectionPoint() const
+QUrl UserScript::sourceUrl() const
{
- if (isNull())
- return UserScript::AfterLoad;
- return static_cast<UserScript::InjectionPoint>(scriptData->injectionPoint);
+ return m_url;
}
-void UserScript::setInjectionPoint(UserScript::InjectionPoint p)
+void UserScript::setSourceUrl(const QUrl &url)
{
- initData();
- scriptData->injectionPoint = p;
+ m_url = url;
}
-uint UserScript::worldId() const
+UserScript::InjectionPoint UserScript::injectionPoint() const
{
- if (isNull())
- return 1;
- return scriptData->worldId;
+ return static_cast<UserScript::InjectionPoint>(m_scriptData.injectionPoint);
}
-void UserScript::setWorldId(uint id)
+void UserScript::setInjectionPoint(UserScript::InjectionPoint p)
{
- initData();
- scriptData->worldId = id;
+ m_scriptData.injectionPoint = p;
}
-bool UserScript::runsOnSubFrames() const
+quint32 UserScript::worldId() const
{
- if (isNull())
- return false;
- return scriptData->injectForSubframes;
+ return m_scriptData.worldId;
}
-void UserScript::setRunsOnSubFrames(bool on)
+void UserScript::setWorldId(quint32 id)
{
- initData();
- scriptData->injectForSubframes = on;
+ m_scriptData.worldId = id;
}
-bool UserScript::operator==(const UserScript &other) const
+bool UserScript::runsOnSubFrames() const
{
- if (isNull() != other.isNull())
- return false;
- if (isNull()) // neither is valid
- return true;
- return worldId() == other.worldId()
- && runsOnSubFrames() == other.runsOnSubFrames()
- && injectionPoint() == other.injectionPoint()
- && name() == other.name() && sourceCode() == other.sourceCode();
+ return m_scriptData.injectForSubframes;
}
-void UserScript::initData()
+void UserScript::setRunsOnSubFrames(bool on)
{
- static uint64_t idCount = 0;
- if (scriptData.isNull()) {
- scriptData.reset(new UserScriptData);
- scriptData->scriptId = idCount++;
- }
+ m_scriptData.injectForSubframes = on;
}
-bool UserScript::isNull() const
+const UserScriptData &UserScript::data() const
{
- return scriptData.isNull();
+ return m_scriptData;
}
-UserScriptData &UserScript::data() const
+bool UserScript::operator==(const UserScript &other) const
{
- return *(scriptData.data());
+ return worldId() == other.worldId() && runsOnSubFrames() == other.runsOnSubFrames()
+ && injectionPoint() == other.injectionPoint() && name() == other.name()
+ && sourceCode() == other.sourceCode() && sourceUrl() == other.sourceUrl();
}
void UserScript::parseMetadataHeader()
{
// Clear previous values
- scriptData->globs.clear();
- scriptData->excludeGlobs.clear();
- scriptData->urlPatterns.clear();
+ m_scriptData.globs.clear();
+ m_scriptData.excludeGlobs.clear();
+ m_scriptData.urlPatterns.clear();
// Logic taken from Chromium (extensions/browser/user_script_loader.cc)
// http://wiki.greasespot.net/Metadata_block
- const std::string &script_text = scriptData->source;
+ const std::string &script_text = m_scriptData.source;
base::StringPiece line;
size_t line_start = 0;
size_t line_end = line_start;
@@ -250,7 +217,7 @@ void UserScript::parseMetadataHeader()
base::ReplaceSubstringsAfterOffset(&value, 0, "\\", "\\\\");
base::ReplaceSubstringsAfterOffset(&value, 0, "?", "\\?");
}
- scriptData->globs.push_back(value);
+ m_scriptData.globs.push_back(value);
} else if (GetDeclarationValue(line, kExcludeDeclaration, &value)) {
if (value.front() != '/' || value.back() != '/') {
// The greasemonkey spec only allows for wildcards (*), so
@@ -258,16 +225,16 @@ void UserScript::parseMetadataHeader()
base::ReplaceSubstringsAfterOffset(&value, 0, "\\", "\\\\");
base::ReplaceSubstringsAfterOffset(&value, 0, "?", "\\?");
}
- scriptData->excludeGlobs.push_back(value);
+ m_scriptData.excludeGlobs.push_back(value);
} else if (GetDeclarationValue(line, kMatchDeclaration, &value)) {
- scriptData->urlPatterns.push_back(value);
+ m_scriptData.urlPatterns.push_back(value);
} else if (GetDeclarationValue(line, kRunAtDeclaration, &value)) {
if (value == kRunAtDocumentStartValue)
- scriptData->injectionPoint = DocumentElementCreation;
+ m_scriptData.injectionPoint = DocumentElementCreation;
else if (value == kRunAtDocumentEndValue)
- scriptData->injectionPoint = DocumentLoadFinished;
+ m_scriptData.injectionPoint = DocumentLoadFinished;
else if (value == kRunAtDocumentIdleValue)
- scriptData->injectionPoint = AfterLoad;
+ m_scriptData.injectionPoint = AfterLoad;
}
}
@@ -276,8 +243,8 @@ void UserScript::parseMetadataHeader()
// If no patterns were specified, default to @include *. This is what
// Greasemonkey does.
- if (scriptData->globs.empty() && scriptData->urlPatterns.empty())
- scriptData->globs.push_back("*");
+ if (m_scriptData.globs.empty() && m_scriptData.urlPatterns.empty())
+ m_scriptData.globs.push_back("*");
}
} // namespace QtWebEngineCore
diff --git a/src/core/user_script.h b/src/core/user_script.h
index e06141259..2be1b4ed0 100644
--- a/src/core/user_script.h
+++ b/src/core/user_script.h
@@ -53,16 +53,19 @@
#include "qtwebenginecoreglobal_p.h"
+#include "qtwebengine/userscript/user_script_data.h"
+
#include <QtCore/QScopedPointer>
#include <QtCore/QSharedData>
#include <QtCore/QString>
+#include <QtCore/QUrl>
namespace QtWebEngineCore {
-struct UserScriptData;
class UserResourceControllerHost;
-class Q_WEBENGINECORE_PRIVATE_EXPORT UserScript : public QSharedData {
+class UserScript : public QSharedData
+{
public:
enum InjectionPoint {
AfterLoad,
@@ -75,19 +78,20 @@ public:
~UserScript();
UserScript &operator=(const UserScript &other);
- bool isNull() const;
-
QString name() const;
void setName(const QString &);
QString sourceCode() const;
void setSourceCode(const QString &);
+ QUrl sourceUrl() const;
+ void setSourceUrl(const QUrl &);
+
InjectionPoint injectionPoint() const;
void setInjectionPoint(InjectionPoint);
- uint worldId() const;
- void setWorldId(uint id);
+ quint32 worldId() const;
+ void setWorldId(quint32 id);
bool runsOnSubFrames() const;
void setRunsOnSubFrames(bool on);
@@ -95,13 +99,13 @@ public:
bool operator==(const UserScript &) const;
private:
- void initData();
- UserScriptData &data() const;
+ const UserScriptData &data() const;
void parseMetadataHeader();
friend class UserResourceControllerHost;
- QScopedPointer<UserScriptData> scriptData;
+ UserScriptData m_scriptData;
QString m_name;
+ QUrl m_url;
};
} // namespace QtWebEngineCore
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 2cd48907b..f5656f571 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -84,11 +84,11 @@
#include "content/public/common/content_constants.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/drop_data.h"
-#include "content/public/common/page_state.h"
#include "content/public/common/page_zoom.h"
#include "content/public/common/url_constants.h"
#include "extensions/buildflags/buildflags.h"
#include "third_party/blink/public/common/page/page_zoom.h"
+#include "third_party/blink/public/common/page_state/page_state.h"
#include "third_party/blink/public/common/peerconnection/webrtc_ip_handling_policy.h"
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
#include "third_party/blink/public/mojom/frame/media_player_action.mojom.h"
@@ -119,6 +119,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.
@@ -355,7 +356,7 @@ static void deserializeNavigationHistory(QDataStream &input, int *currentIndex,
nullptr);
entry->SetTitle(toString16(title));
- entry->SetPageState(content::PageState::CreateFromEncodedData(std::string(pageState.data(), pageState.size())));
+ entry->SetPageState(blink::PageState::CreateFromEncodedData(std::string(pageState.data(), pageState.size())));
entry->SetHasPostData(hasPostData);
entry->SetOriginalRequestURL(toGurl(originalRequestUrl));
entry->SetIsOverridingUserAgent(isOverridingUserAgent);
@@ -435,7 +436,7 @@ QSharedPointer<WebContentsAdapter> WebContentsAdapter::createFromSerializedNavig
// TODO(joth): This is duplicated from chrome/.../session_restore.cc and
// should be shared e.g. in NavigationController. http://crbug.com/68222
const int id = newWebContents->GetMainFrame()->GetProcess()->GetID();
- const content::PageState& pageState = controller.GetActiveEntry()->GetPageState();
+ const blink::PageState& pageState = controller.GetActiveEntry()->GetPageState();
const std::vector<base::FilePath>& filePaths = pageState.GetReferencedFiles();
for (std::vector<base::FilePath>::const_iterator file = filePaths.begin(); file != filePaths.end(); ++file)
content::ChildProcessSecurityPolicy::GetInstance()->GrantReadFile(id, *file);
@@ -491,7 +492,7 @@ void WebContentsAdapter::setClient(WebContentsAdapterClient *adapterClient)
Q_ASSERT(m_profileAdapter);
// This might replace any adapter that has been initialized with this WebEngineSettings.
- adapterClient->webEngineSettings()->setWebContentsAdapter(this);
+ WebEngineSettings::get(adapterClient->webEngineSettings())->setWebContentsAdapter(this);
}
bool WebContentsAdapter::isInitialized() const
@@ -551,7 +552,7 @@ void WebContentsAdapter::initialize(content::SiteInstance *site)
void WebContentsAdapter::initializeRenderPrefs()
{
- blink::mojom::RendererPreferences *rendererPrefs = m_webContents->GetMutableRendererPrefs();
+ blink::RendererPreferences *rendererPrefs = m_webContents->GetMutableRendererPrefs();
rendererPrefs->use_custom_colors = true;
// Qt returns a flash time (the whole cycle) in ms, chromium expects just the interval in
// seconds
@@ -567,7 +568,8 @@ void WebContentsAdapter::initializeRenderPrefs()
commandLine->GetSwitchValueASCII(switches::kForceWebRtcIPHandlingPolicy);
else
rendererPrefs->webrtc_ip_handling_policy =
- m_adapterClient->webEngineSettings()->testAttribute(WebEngineSettings::WebRTCPublicInterfacesOnly)
+ m_adapterClient->webEngineSettings()->testAttribute(
+ QWebEngineSettings::WebRTCPublicInterfacesOnly)
? blink::kWebRTCIPHandlingDefaultPublicInterfaceOnly
: blink::kWebRTCIPHandlingDefault;
#endif
@@ -623,7 +625,7 @@ void WebContentsAdapter::reload()
bool wasDiscarded = (m_lifecycleState == LifecycleState::Discarded);
setLifecycleState(LifecycleState::Active);
CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost());
- WebEngineSettings *settings = m_adapterClient->webEngineSettings();
+ WebEngineSettings *settings = WebEngineSettings::get(m_adapterClient->webEngineSettings());
settings->doApply();
if (!wasDiscarded) // undiscard() already triggers a reload
m_webContents->GetController().Reload(content::ReloadType::NORMAL, /*checkRepost = */false);
@@ -638,7 +640,7 @@ void WebContentsAdapter::reloadAndBypassCache()
bool wasDiscarded = (m_lifecycleState == LifecycleState::Discarded);
setLifecycleState(LifecycleState::Active);
CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost());
- WebEngineSettings *settings = m_adapterClient->webEngineSettings();
+ WebEngineSettings *settings = WebEngineSettings::get(m_adapterClient->webEngineSettings());
settings->doApply();
if (!wasDiscarded) // undiscard() already triggers a reload
m_webContents->GetController().Reload(content::ReloadType::BYPASSING_CACHE, /*checkRepost = */false);
@@ -671,8 +673,7 @@ void WebContentsAdapter::load(const QWebEngineHttpRequest &request)
CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost());
- WebEngineSettings *settings = m_adapterClient->webEngineSettings();
- settings->doApply();
+ WebEngineSettings::get(m_adapterClient->webEngineSettings())->doApply();
// The situation can occur when relying on the editingFinished signal in QML to set the url
// of the WebView.
@@ -726,8 +727,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();
@@ -759,8 +760,7 @@ void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeT
CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost());
- WebEngineSettings *settings = m_adapterClient->webEngineSettings();
- settings->doApply();
+ WebEngineSettings::get(m_adapterClient->webEngineSettings())->doApply();
QByteArray encodedData = data.toPercentEncoding();
std::string urlString;
@@ -1131,7 +1131,6 @@ void WebContentsAdapter::download(const QUrl &url, const QString &suggestedFileN
if (!dlm)
return;
- dlmd->markNextDownloadAsUserRequested();
dlm->SetDelegate(dlmd);
net::NetworkTrafficAnnotationTag traffic_annotation =
@@ -1669,19 +1668,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::DragOperation(m_currentDropAction));
}
@@ -1724,10 +1723,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();
}
@@ -1752,8 +1751,8 @@ void WebContentsAdapter::replaceMisspelling(const QString &word)
void WebContentsAdapter::focusIfNecessary()
{
CHECK_INITIALIZED();
- const WebEngineSettings *settings = m_adapterClient->webEngineSettings();
- bool focusOnNavigation = settings->testAttribute(WebEngineSettings::FocusOnNavigationEnabled);
+ const QWebEngineSettings *settings = m_adapterClient->webEngineSettings();
+ bool focusOnNavigation = settings->testAttribute(QWebEngineSettings::FocusOnNavigationEnabled);
if (focusOnNavigation)
m_webContents->Focus();
}
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index 78dda6060..ef710579b 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 afc43806a..1e2c7bbec 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,9 @@ 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);
+QT_FORWARD_DECLARE_CLASS(QWebEngineSettings)
namespace content {
struct DropData;
@@ -78,6 +78,8 @@ struct DropData;
namespace QtWebEngineCore {
+class CertificateErrorController;
+class ClientCertSelectController;
class AuthenticationDialogController;
class ColorChooserController;
class FilePickerController;
@@ -91,279 +93,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 +194,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, int errorCode, const QString &errorDescription) = 0;
virtual void focusContainer() = 0;
virtual void unhandledKeyEvent(QKeyEvent *event) = 0;
@@ -476,7 +205,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;
@@ -499,25 +228,22 @@ public:
virtual void runMouseLockPermissionRequest(const QUrl &securityOrigin) = 0;
virtual void runQuotaRequest(QWebEngineQuotaRequest) = 0;
virtual void runRegisterProtocolHandlerRequest(QWebEngineRegisterProtocolHandlerRequest) = 0;
- virtual WebEngineSettings *webEngineSettings() const = 0;
+ virtual QWebEngineSettings *webEngineSettings() const = 0;
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;
virtual void updateNavigationActions() = 0;
virtual void updateEditActions() = 0;
- virtual void startDragging(const content::DropData &dropData, Qt::DropActions allowedActions,
- const QPixmap &pixmap, const QPoint &offset) = 0;
- virtual bool supportsDragging() const = 0;
+ virtual QObject *dragSource() const = 0;
virtual bool isEnabled() const = 0;
virtual const QObject *holdingQObject() const = 0;
virtual void setToolTip(const QString& toolTipText) = 0;
virtual ClientType clientType() = 0;
virtual void printRequested() = 0;
- virtual void widgetChanged(RenderWidgetHostViewQtDelegate *newWidget) = 0;
virtual TouchHandleDrawableClient *createTouchHandle(const QMap<int, QImage> &images) = 0;
virtual void showTouchSelectionMenu(TouchSelectionMenuController *menuController, const QRect &bounds, const QSize &handleSize) = 0;
virtual void hideTouchSelectionMenu() = 0;
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index d52b07df3..5d11f43c3 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/error_page/common/error.h"
#include "components/error_page/common/localized_error.h"
@@ -77,7 +77,6 @@
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/common/frame_navigate_params.h"
#include "content/public/common/url_constants.h"
#include "net/base/data_url.h"
#include "net/base/url_util.h"
@@ -328,12 +327,18 @@ void WebContentsDelegateQt::RenderViewHostChanged(content::RenderViewHost *, con
{
if (newHost && newHost->GetWidget() && newHost->GetWidget()->GetView()) {
auto rwhv = static_cast<RenderWidgetHostViewQt *>(newHost->GetWidget()->GetView());
- m_viewClient->widgetChanged(rwhv->delegate());
+ Q_ASSERT(rwhv->delegate());
+ rwhv->delegate()->adapterClientChanged(m_viewClient);
}
}
void WebContentsDelegateQt::emitLoadStarted(bool isErrorPage)
{
+ for (auto &&wc : m_certificateErrorControllers)
+ if (auto controller = wc.lock())
+ controller->deactivate();
+ m_certificateErrorControllers.clear();
+
// only report first ever load start or separate one for error page only
if (!isErrorPage && m_loadingInfo.isLoading()) // already running
return;
@@ -351,7 +356,7 @@ void WebContentsDelegateQt::emitLoadStarted(bool isErrorPage)
void WebContentsDelegateQt::DidStartNavigation(content::NavigationHandle *navigation_handle)
{
- if (!webEngineSettings()->testAttribute(WebEngineSettings::ErrorPageEnabled))
+ if (!webEngineSettings()->testAttribute(QWebEngineSettings::ErrorPageEnabled))
navigation_handle->SetSilentlyIgnoreErrors();
if (!navigation_handle->IsInMainFrame() || !web_contents()->IsLoadingToDifferentDocument())
@@ -370,8 +375,8 @@ void WebContentsDelegateQt::emitLoadFinished(bool isErrorPage)
if (!m_loadingInfo.isLoading()) // not currently running
return;
- Q_ASSERT(!isErrorPage || webEngineSettings()->testAttribute(WebEngineSettings::ErrorPageEnabled));
- Q_ASSERT((m_loadingInfo.triggersErrorPage && webEngineSettings()->testAttribute(WebEngineSettings::ErrorPageEnabled)) || !m_loadingInfo.triggersErrorPage);
+ Q_ASSERT(!isErrorPage || webEngineSettings()->testAttribute(QWebEngineSettings::ErrorPageEnabled));
+ Q_ASSERT((m_loadingInfo.triggersErrorPage && webEngineSettings()->testAttribute(QWebEngineSettings::ErrorPageEnabled)) || !m_loadingInfo.triggersErrorPage);
if (!isErrorPage) {
if (m_loadingInfo.progress < 100) {
@@ -476,7 +481,7 @@ void WebContentsDelegateQt::DidStopLoading()
void WebContentsDelegateQt::didFailLoad(const QUrl &url, int errorCode, const QString &errorDescription)
{
m_viewClient->iconChanged(QUrl());
- bool errorPageEnabled = webEngineSettings()->testAttribute(WebEngineSettings::ErrorPageEnabled);
+ bool errorPageEnabled = webEngineSettings()->testAttribute(QWebEngineSettings::ErrorPageEnabled);
// Delay notifying failure until the error-page is done loading.
// Error-pages are not loaded on failures due to abort.
bool aborted = (errorCode == -3 /* ERR_ABORTED*/ );
@@ -533,7 +538,7 @@ void WebContentsDelegateQt::DidFinishLoad(content::RenderFrameHost* render_frame
content::NavigationEntry *entry = web_contents()->GetController().GetActiveEntry();
int http_statuscode = entry ? entry->GetHttpStatusCode() : 0;
- bool errorPageEnabled = webEngineSettings()->testAttribute(WebEngineSettings::ErrorPageEnabled);
+ bool errorPageEnabled = webEngineSettings()->testAttribute(QWebEngineSettings::ErrorPageEnabled);
bool triggersErrorPage = errorPageEnabled && (http_statuscode >= 400) && m_isDocumentEmpty;
m_loadingInfo.success = http_statuscode < 400;
@@ -626,7 +631,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;
}
@@ -657,7 +662,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));
}
@@ -678,8 +683,8 @@ void WebContentsDelegateQt::DidFirstVisuallyNonEmptyPaint()
void WebContentsDelegateQt::ActivateContents(content::WebContents* contents)
{
- WebEngineSettings *settings = m_viewClient->webEngineSettings();
- if (settings->testAttribute(settings->Attribute::AllowWindowActivationFromJavaScript))
+ QWebEngineSettings *settings = m_viewClient->webEngineSettings();
+ if (settings->testAttribute(QWebEngineSettings::AllowWindowActivationFromJavaScript))
contents->Focus();
}
@@ -695,7 +700,7 @@ void WebContentsDelegateQt::RequestToLockMouse(content::WebContents *web_content
void WebContentsDelegateQt::overrideWebPreferences(content::WebContents *webContents, blink::web_pref::WebPreferences *webPreferences)
{
- m_viewClient->webEngineSettings()->overrideWebPreferences(webContents, webPreferences);
+ WebEngineSettings::get(m_viewClient->webEngineSettings())->overrideWebPreferences(webContents, webPreferences);
}
QSharedPointer<WebContentsAdapter>
@@ -711,9 +716,15 @@ WebContentsDelegateQt::createWindow(std::unique_ptr<content::WebContents> new_co
toQt(initial_pos), url);
}
-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)
@@ -730,17 +741,17 @@ extern WebContentsAdapterClient::NavigationType pageTransitionToNavigationType(u
void WebContentsDelegateQt::launchExternalURL(const QUrl &url, ui::PageTransition page_transition, bool is_main_frame, bool has_user_gesture)
{
- WebEngineSettings *settings = m_viewClient->webEngineSettings();
+ QWebEngineSettings *settings = m_viewClient->webEngineSettings();
bool navigationAllowedByPolicy = false;
bool navigationRequestAccepted = true;
switch (settings->unknownUrlSchemePolicy()) {
- case WebEngineSettings::DisallowUnknownUrlSchemes:
+ case QWebEngineSettings::DisallowUnknownUrlSchemes:
break;
- case WebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction:
+ case QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction:
navigationAllowedByPolicy = has_user_gesture;
break;
- case WebEngineSettings::AllowAllUnknownUrlSchemes:
+ case QWebEngineSettings::AllowAllUnknownUrlSchemes:
navigationAllowedByPolicy = true;
break;
default:
@@ -844,15 +855,6 @@ void WebContentsDelegateQt::ContentsZoomChange(bool zoom_in)
adapter->setZoomFactor(adapter->currentZoomFactor() - 0.1f);
}
-bool WebContentsDelegateQt::ShouldNavigateOnBackForwardMouseButtons()
-{
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
- return false;
-#else
- return true;
-#endif
-}
-
void WebContentsDelegateQt::ResourceLoadComplete(content::RenderFrameHost* render_frame_host,
const content::GlobalRequestID& request_id,
const blink::mojom::ResourceLoadInfo& resource_load_info)
@@ -876,7 +878,7 @@ FindTextHelper *WebContentsDelegateQt::findTextHelper()
}
WebEngineSettings *WebContentsDelegateQt::webEngineSettings() const {
- return m_viewClient->webEngineSettings();
+ return WebEngineSettings::get(m_viewClient->webEngineSettings());
}
WebContentsAdapter *WebContentsDelegateQt::webContentsAdapter() const
@@ -933,6 +935,7 @@ int &WebContentsDelegateQt::streamCount(blink::mojom::MediaStreamType type)
case blink::mojom::MediaStreamType::GUM_DESKTOP_AUDIO_CAPTURE:
case blink::mojom::MediaStreamType::DISPLAY_VIDEO_CAPTURE:
case blink::mojom::MediaStreamType::DISPLAY_AUDIO_CAPTURE:
+ case blink::mojom::MediaStreamType::DISPLAY_VIDEO_CAPTURE_THIS_TAB:
return m_desktopStreamCount;
case blink::mojom::MediaStreamType::NO_SERVICE:
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h
index 50027b6a8..c3676d996 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 blink {
namespace web_pref {
@@ -92,7 +89,7 @@ protected:
private:
WebContentsAdapterClient *m_viewClient;
- QVector<content::FrameTreeNode *> m_observedNodes;
+ QList<content::FrameTreeNode *> m_observedNodes;
};
class SavePageInfo
@@ -173,7 +170,6 @@ public:
void OnVisibilityChanged(content::Visibility visibility) override;
void DidFirstVisuallyNonEmptyPaint() override;
void ActivateContents(content::WebContents* contents) override;
- bool ShouldNavigateOnBackForwardMouseButtons() override;
void ResourceLoadComplete(content::RenderFrameHost* render_frame_host,
const content::GlobalRequestID& request_id,
const blink::mojom::ResourceLoadInfo& resource_load_info) override;
@@ -253,6 +249,7 @@ private:
bool m_isDocumentEmpty = true;
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 900c53829..10154e733 100644
--- a/src/core/web_contents_view_qt.cpp
+++ b/src/core/web_contents_view_qt.cpp
@@ -68,6 +68,8 @@ WebContentsViewQt::WebContentsViewQt(content::WebContents *webContents)
: m_webContents(webContents)
, m_client(nullptr)
, m_factoryClient(nullptr)
+ , m_contextMenuRequest(
+ new QWebEngineContextMenuRequest(new QWebEngineContextMenuRequestPrivate()))
{
}
@@ -79,7 +81,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()));
}
}
@@ -100,7 +102,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);
}
@@ -113,7 +115,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;
@@ -154,81 +156,79 @@ void WebContentsViewQt::SetInitialFocus()
void WebContentsViewQt::FocusThroughTabTraversal(bool reverse)
{
content::WebContentsImpl *web_contents = static_cast<content::WebContentsImpl*>(m_webContents);
- content::RenderWidgetHostView *fullscreen_view = web_contents->GetFullscreenRenderWidgetHostView();
- if (fullscreen_view) {
- fullscreen_view->Focus();
- return;
- }
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)
-
-WebEngineContextMenuData WebContentsViewQt::buildContextMenuData(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)
+
+// static
+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));
- ret.setAltText(toQt(params.alt_text));
- ret.setTitleText(toQt(params.title_text));
- ret.setUnfilteredLinkUrl(toQt(params.unfiltered_link_url));
- ret.setSelectedText(toQt(params.selection_text));
- 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));
- 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);
+ re->m_altText = toQt(params.alt_text);
+ re->m_titleText = toQt(params.title_text);
+ re->m_unfilteredLinkUrl = toQt(params.unfiltered_link_url);
+ re->m_selectedText = toQt(params.selection_text);
+ 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);
+ 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(buildContextMenuData(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.
@@ -237,9 +237,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());
}
static Qt::DropActions toQtDropActions(blink::DragOperationsMask ops)
@@ -264,7 +276,8 @@ void WebContentsViewQt::StartDragging(const content::DropData &drop_data,
#if QT_CONFIG(draganddrop)
Q_UNUSED(event_info);
- if (!m_client->supportsDragging()) {
+ QObject *dragSource = m_client->dragSource();
+ if (!dragSource) {
if (source_rwh)
source_rwh->DragSourceSystemDragEnded();
return;
@@ -278,7 +291,7 @@ void WebContentsViewQt::StartDragging(const content::DropData &drop_data,
hotspot.setY(image_offset.y());
}
- m_client->startDragging(drop_data, toQtDropActions(allowed_ops), pixmap, hotspot);
+ m_client->webContentsAdapter()->startDragging(dragSource, drop_data, toQtDropActions(allowed_ops), pixmap, hotspot);
#endif // QT_CONFIG(draganddrop)
}
diff --git a/src/core/web_contents_view_qt.h b/src/core/web_contents_view_qt.h
index da0c5d20c..ff3b9d632 100644
--- a/src/core/web_contents_view_qt.h
+++ b/src/core/web_contents_view_qt.h
@@ -46,6 +46,12 @@
#include "api/qtwebenginecoreglobal_p.h"
#include "web_contents_adapter_client.h"
+QT_FORWARD_DECLARE_CLASS(QWebEngineContextMenuRequest)
+
+namespace extensions {
+class MimeHandlerViewGuestDelegateQt;
+}
+
namespace content {
class WebContents;
}
@@ -60,7 +66,7 @@ class WebContentsViewQt
public:
static inline WebContentsViewQt *from(WebContentsView *view) { return static_cast<WebContentsViewQt*>(view); }
- WebContentsViewQt(content::WebContents *webContents);
+ WebContentsViewQt(content::WebContents* webContents);
void setFactoryClient(WebContentsAdapterClient* client);
void setClient(WebContentsAdapterClient* client);
@@ -121,12 +127,17 @@ public:
void LostFocus(content::RenderWidgetHostImpl *render_widget_host) override;
void TakeFocus(bool reverse) override;
- static WebEngineContextMenuData buildContextMenuData(const content::ContextMenuParams &params);
+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;
+
+ friend class extensions::MimeHandlerViewGuestDelegateQt;
};
} // namespace QtWebEngineCore
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index f342e788d..b3a44def6 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -133,16 +133,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
@@ -150,10 +149,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())
@@ -164,8 +163,11 @@ bool usingANGLE()
#endif
}
-bool usingDefaultSGBackend()
+static bool usingDefaultSGBackend()
{
+ if (QQuickWindow::graphicsApi() != QSGRendererInterface::OpenGL)
+ return false;
+
const QStringList args = QGuiApplication::arguments();
//folow logic from contextFactory in src/quick/scenegraph/qsgcontextplugin.cpp
@@ -185,16 +187,105 @@ bool usingDefaultSGBackend()
return device.isEmpty();
}
+
+bool usingSoftwareDynamicGL()
+{
+ if (QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL))
+ return true;
+#if defined(Q_OS_WIN)
+ HMODULE handle = QNativeInterface::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)
@@ -210,36 +301,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());
}
}
}
@@ -604,12 +681,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"));
@@ -625,6 +696,9 @@ WebEngineContext::WebEngineContext()
// Enable sandboxing on OS X and Linux (Desktop / Embedded) by default.
bool disable_sandbox = qEnvironmentVariableIsSet(kDisableSandboxEnv);
+#if defined(Q_OS_WIN)
+ disable_sandbox = true; // FIXME: Windows sandbox no longer works on CI, but works fine locally.
+#endif
if (!disable_sandbox) {
#if defined(Q_OS_LINUX)
parsedCommandLine->AppendSwitch(sandbox::policy::switches::kDisableSetuidSandbox);
@@ -636,30 +710,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
-
// Do not advertise a feature we have removed at compile time
parsedCommandLine->AppendSwitch(switches::kDisableSpeechAPI);
@@ -694,7 +744,7 @@ WebEngineContext::WebEngineContext()
// Explicitly tell Chromium about default-on features we do not support
disableFeatures.push_back(features::kBackgroundFetch.name);
- disableFeatures.push_back(features::kSmsReceiver.name);
+ disableFeatures.push_back(features::kWebOTP.name);
disableFeatures.push_back(features::kWebPayments.name);
disableFeatures.push_back(features::kWebUsb.name);
disableFeatures.push_back(media::kPictureInPicture.name);
@@ -711,74 +761,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);
@@ -787,6 +775,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);
}
@@ -869,6 +880,8 @@ WebEngineContext::WebEngineContext()
#endif
content::WebUIControllerFactory::RegisterFactory(WebUIControllerFactoryQt::GetInstance());
+
+ logContext(glType, parsedCommandLine);
}
#if QT_CONFIG(webengine_printing_and_pdf)
@@ -897,8 +910,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() {
@@ -932,3 +945,31 @@ base::CommandLine* WebEngineContext::commandLine() {
}
} // namespace
+
+QT_BEGIN_NAMESPACE
+/*!
+ \relates <qtwebenginecoreglobal.h>
+ \since 6.2
+
+ Returns the version number of Qt WebEngine at run-time as a string
+ (for example, "6.2.0"). This may be a different version than the
+ version the application was compiled against, and a different version
+ than Qt.
+*/
+const char *qWebEngineVersion() noexcept
+{
+ return QTWEBENGINECORE_VERSION_STR;
+}
+
+/*!
+ \relates <qtwebenginecoreglobal.h>
+ \since 6.2
+
+ Returns the version number of Chromium used by Qt WebEngine at run-time
+ as a string (for example, "83.0.4103.122").
+*/
+const char *qWebEngineChromiumVersion() noexcept
+{
+ return CHROMIUM_VERSION;
+}
+QT_END_NAMESPACE
diff --git a/src/core/web_engine_context.h b/src/core/web_engine_context.h
index f60082059..9ac598c67 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;
@@ -149,7 +149,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_library_info.cpp b/src/core/web_engine_library_info.cpp
index 3a6492273..407bd50bc 100644
--- a/src/core/web_engine_library_info.cpp
+++ b/src/core/web_engine_library_info.cpp
@@ -168,7 +168,7 @@ QString subProcessPath()
candidatePaths << getPath(frameworkBundle())
% QStringLiteral("/Helpers/" QTWEBENGINEPROCESS_NAME ".app/Contents/MacOS/" QTWEBENGINEPROCESS_NAME);
#else
- candidatePaths << QLibraryInfo::location(QLibraryInfo::LibraryExecutablesPath)
+ candidatePaths << QLibraryInfo::path(QLibraryInfo::LibraryExecutablesPath)
% QLatin1Char('/') % processBinary;
#endif
candidatePaths << QCoreApplication::applicationDirPath()
@@ -205,7 +205,7 @@ QString localesPath()
#if defined(OS_MAC) && defined(QT_MAC_FRAMEWORK_BUILD)
getResourcesPath(frameworkBundle()) % QLatin1String("/qtwebengine_locales");
#else
- QLibraryInfo::location(QLibraryInfo::TranslationsPath) % QDir::separator() % QLatin1String("qtwebengine_locales");
+ QLibraryInfo::path(QLibraryInfo::TranslationsPath) % QDir::separator() % QLatin1String("qtwebengine_locales");
#endif
if (!initialized) {
@@ -254,7 +254,7 @@ QString dictionariesPath()
candidatePaths << frameworkDictionariesPath;
#endif
- QString libraryDictionariesPath = QLibraryInfo::location(QLibraryInfo::DataPath)
+ QString libraryDictionariesPath = QLibraryInfo::path(QLibraryInfo::DataPath)
% QDir::separator() % QLatin1String("qtwebengine_dictionaries");
candidatePaths << libraryDictionariesPath;
}
@@ -280,13 +280,13 @@ QString resourcesDataPath()
#elif defined(OS_MAC)
QLibraryInfo::location(QLibraryInfo::DataPath) % QLatin1String("/Resources");
#else
- QLibraryInfo::location(QLibraryInfo::DataPath) % QLatin1String("/resources");
+ QLibraryInfo::path(QLibraryInfo::DataPath) % QLatin1String("/resources");
#endif
if (!initialized) {
initialized = true;
if (!QFileInfo::exists(potentialResourcesPath % QLatin1String("/qtwebengine_resources.pak"))) {
qWarning("Qt WebEngine resources not found at %s. Trying parent directory...", qPrintable(potentialResourcesPath));
- potentialResourcesPath = QLibraryInfo::location(QLibraryInfo::DataPath);
+ potentialResourcesPath = QLibraryInfo::path(QLibraryInfo::DataPath);
}
if (!QFileInfo::exists(potentialResourcesPath % QLatin1String("/qtwebengine_resources.pak"))) {
qWarning("Qt WebEngine resources not found at %s. Trying application directory...", qPrintable(potentialResourcesPath));
@@ -385,8 +385,8 @@ bool WebEngineLibraryInfo::isUNCPath(const QString &path)
{
return (base::FilePath::IsSeparator(path.at(0).toLatin1())
&& base::FilePath::IsSeparator(path.at(1).toLatin1())
- && path.at(2) != "." && path.at(2) != "?"
- && path.at(2).isLetter() && path.at(3) != ":");
+ && path.at(2) != QLatin1Char('.') && path.at(2) != QLatin1Char('?')
+ && path.at(2).isLetter() && path.at(3) != QLatin1Char(':'));
}
#endif
diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp
index 4115d10d7..461647e67 100644
--- a/src/core/web_engine_settings.cpp
+++ b/src/core/web_engine_settings.cpp
@@ -51,21 +51,20 @@
#include "content/public/common/content_switches.h"
#include "media/base/media_switches.h"
#include "third_party/blink/public/common/peerconnection/webrtc_ip_handling_policy.h"
+#include "third_party/blink/public/common/renderer_preferences/renderer_preferences.h"
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
-#include "third_party/blink/public/mojom/renderer_preferences.mojom.h"
#include "ui/base/ui_base_switches.h"
#include "ui/events/event_switches.h"
#include "ui/native_theme/native_theme.h"
#include <QFont>
#include <QTimer>
-#include <QTouchDevice>
namespace QtWebEngineCore {
-QHash<WebEngineSettings::Attribute, bool> WebEngineSettings::s_defaultAttributes;
-QHash<WebEngineSettings::FontFamily, QString> WebEngineSettings::s_defaultFontFamilies;
-QHash<WebEngineSettings::FontSize, int> WebEngineSettings::s_defaultFontSizes;
+QHash<QWebEngineSettings::WebAttribute, bool> WebEngineSettings::s_defaultAttributes;
+QHash<QWebEngineSettings::FontFamily, QString> WebEngineSettings::s_defaultFontFamilies;
+QHash<QWebEngineSettings::FontSize, int> WebEngineSettings::s_defaultFontSizes;
static const int batchTimerTimeout = 0;
@@ -93,13 +92,14 @@ static inline bool isTouchEventsAPIEnabled() {
}
WebEngineSettings::WebEngineSettings(WebEngineSettings *_parentSettings)
- : m_adapter(0)
+ : m_adapter(nullptr)
, parentSettings(_parentSettings)
- , m_unknownUrlSchemePolicy(WebEngineSettings::InheritedUnknownUrlSchemePolicy)
+ , m_unknownUrlSchemePolicy(QWebEngineSettings::InheritedUnknownUrlSchemePolicy)
{
if (parentSettings)
parentSettings->childSettings.insert(this);
-
+ else
+ initDefaults();
m_batchTimer.setSingleShot(true);
m_batchTimer.setInterval(batchTimerTimeout);
QObject::connect(&m_batchTimer, &QTimer::timeout, [this]() {
@@ -132,13 +132,13 @@ void WebEngineSettings::overrideWebPreferences(content::WebContents *webContents
}
}
-void WebEngineSettings::setAttribute(WebEngineSettings::Attribute attr, bool on)
+void WebEngineSettings::setAttribute(QWebEngineSettings::WebAttribute attr, bool on)
{
m_attributes.insert(attr, on);
scheduleApplyRecursively();
}
-bool WebEngineSettings::testAttribute(WebEngineSettings::Attribute attr) const
+bool WebEngineSettings::testAttribute(QWebEngineSettings::WebAttribute attr) const
{
auto it = m_attributes.constFind(attr);
if (it != m_attributes.constEnd())
@@ -151,7 +151,7 @@ bool WebEngineSettings::testAttribute(WebEngineSettings::Attribute attr) const
return s_defaultAttributes.value(attr);
}
-bool WebEngineSettings::isAttributeExplicitlySet(Attribute attr) const
+bool WebEngineSettings::isAttributeExplicitlySet(QWebEngineSettings::WebAttribute attr) const
{
if (m_attributes.contains(attr))
return true;
@@ -162,19 +162,19 @@ bool WebEngineSettings::isAttributeExplicitlySet(Attribute attr) const
return false;
}
-void WebEngineSettings::resetAttribute(WebEngineSettings::Attribute attr)
+void WebEngineSettings::resetAttribute(QWebEngineSettings::WebAttribute attr)
{
m_attributes.remove(attr);
scheduleApplyRecursively();
}
-void WebEngineSettings::setFontFamily(WebEngineSettings::FontFamily which, const QString &family)
+void WebEngineSettings::setFontFamily(QWebEngineSettings::FontFamily which, const QString &family)
{
m_fontFamilies.insert(which, family);
scheduleApplyRecursively();
}
-QString WebEngineSettings::fontFamily(WebEngineSettings::FontFamily which)
+QString WebEngineSettings::fontFamily(QWebEngineSettings::FontFamily which)
{
if (!parentSettings) {
Q_ASSERT(s_defaultFontFamilies.contains(which));
@@ -183,19 +183,19 @@ QString WebEngineSettings::fontFamily(WebEngineSettings::FontFamily which)
return m_fontFamilies.value(which, parentSettings->fontFamily(which));
}
-void WebEngineSettings::resetFontFamily(WebEngineSettings::FontFamily which)
+void WebEngineSettings::resetFontFamily(QWebEngineSettings::FontFamily which)
{
m_fontFamilies.remove(which);
scheduleApplyRecursively();
}
-void WebEngineSettings::setFontSize(WebEngineSettings::FontSize type, int size)
+void WebEngineSettings::setFontSize(QWebEngineSettings::FontSize type, int size)
{
m_fontSizes.insert(type, size);
scheduleApplyRecursively();
}
-int WebEngineSettings::fontSize(WebEngineSettings::FontSize type) const
+int WebEngineSettings::fontSize(QWebEngineSettings::FontSize type) const
{
if (!parentSettings) {
Q_ASSERT(s_defaultFontSizes.contains(type));
@@ -204,7 +204,7 @@ int WebEngineSettings::fontSize(WebEngineSettings::FontSize type) const
return m_fontSizes.value(type, parentSettings->fontSize(type));
}
-void WebEngineSettings::resetFontSize(WebEngineSettings::FontSize type)
+void WebEngineSettings::resetFontSize(QWebEngineSettings::FontSize type)
{
m_fontSizes.remove(type);
scheduleApplyRecursively();
@@ -223,42 +223,42 @@ QString WebEngineSettings::defaultTextEncoding() const
return m_defaultEncoding.isEmpty()? parentSettings->defaultTextEncoding() : m_defaultEncoding;
}
-void WebEngineSettings::setUnknownUrlSchemePolicy(WebEngineSettings::UnknownUrlSchemePolicy policy)
+void WebEngineSettings::setUnknownUrlSchemePolicy(QWebEngineSettings::UnknownUrlSchemePolicy policy)
{
m_unknownUrlSchemePolicy = policy;
}
-WebEngineSettings::UnknownUrlSchemePolicy WebEngineSettings::unknownUrlSchemePolicy() const
+QWebEngineSettings::UnknownUrlSchemePolicy WebEngineSettings::unknownUrlSchemePolicy() const
{
// value InheritedUnknownUrlSchemePolicy means it is taken from parent, if possible. If there
// is no parent, then AllowUnknownUrlSchemesFromUserInteraction (the default behavior) is used.
- if (m_unknownUrlSchemePolicy != InheritedUnknownUrlSchemePolicy)
+ if (m_unknownUrlSchemePolicy != QWebEngineSettings::InheritedUnknownUrlSchemePolicy)
return m_unknownUrlSchemePolicy;
if (parentSettings)
return parentSettings->unknownUrlSchemePolicy();
- return AllowUnknownUrlSchemesFromUserInteraction;
+ return QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction;
}
void WebEngineSettings::initDefaults()
{
if (s_defaultAttributes.isEmpty()) {
// Initialize the default settings.
- s_defaultAttributes.insert(AutoLoadImages, true);
- s_defaultAttributes.insert(JavascriptEnabled, true);
- s_defaultAttributes.insert(JavascriptCanOpenWindows, true);
- s_defaultAttributes.insert(JavascriptCanAccessClipboard, false);
- s_defaultAttributes.insert(LinksIncludedInFocusChain, true);
- s_defaultAttributes.insert(LocalStorageEnabled, true);
- s_defaultAttributes.insert(LocalContentCanAccessRemoteUrls, false);
- s_defaultAttributes.insert(XSSAuditingEnabled, false);
- s_defaultAttributes.insert(SpatialNavigationEnabled, false);
- s_defaultAttributes.insert(LocalContentCanAccessFileUrls, true);
- s_defaultAttributes.insert(HyperlinkAuditingEnabled, false);
- s_defaultAttributes.insert(ErrorPageEnabled, true);
- s_defaultAttributes.insert(PluginsEnabled, false);
- s_defaultAttributes.insert(FullScreenSupportEnabled, false);
- s_defaultAttributes.insert(ScreenCaptureEnabled, false);
- s_defaultAttributes.insert(ShowScrollBars, true);
+ s_defaultAttributes.insert(QWebEngineSettings::AutoLoadImages, true);
+ s_defaultAttributes.insert(QWebEngineSettings::JavascriptEnabled, true);
+ s_defaultAttributes.insert(QWebEngineSettings::JavascriptCanOpenWindows, true);
+ s_defaultAttributes.insert(QWebEngineSettings::JavascriptCanAccessClipboard, false);
+ s_defaultAttributes.insert(QWebEngineSettings::LinksIncludedInFocusChain, true);
+ s_defaultAttributes.insert(QWebEngineSettings::LocalStorageEnabled, true);
+ s_defaultAttributes.insert(QWebEngineSettings::LocalContentCanAccessRemoteUrls, false);
+ s_defaultAttributes.insert(QWebEngineSettings::XSSAuditingEnabled, false);
+ s_defaultAttributes.insert(QWebEngineSettings::SpatialNavigationEnabled, false);
+ s_defaultAttributes.insert(QWebEngineSettings::LocalContentCanAccessFileUrls, true);
+ s_defaultAttributes.insert(QWebEngineSettings::HyperlinkAuditingEnabled, false);
+ s_defaultAttributes.insert(QWebEngineSettings::ErrorPageEnabled, true);
+ s_defaultAttributes.insert(QWebEngineSettings::PluginsEnabled, false);
+ s_defaultAttributes.insert(QWebEngineSettings::FullScreenSupportEnabled, false);
+ s_defaultAttributes.insert(QWebEngineSettings::ScreenCaptureEnabled, false);
+ s_defaultAttributes.insert(QWebEngineSettings::ShowScrollBars, true);
// The following defaults matches logic in render_view_host_impl.cc
// But first we must ensure the WebContext has been initialized
QtWebEngineCore::WebEngineContext::current();
@@ -270,27 +270,30 @@ void WebEngineSettings::initDefaults()
bool accelerated2dCanvas =
!commandLine->HasSwitch(switches::kDisableAccelerated2dCanvas);
bool allowRunningInsecureContent = commandLine->HasSwitch(switches::kAllowRunningInsecureContent);
- s_defaultAttributes.insert(ScrollAnimatorEnabled, smoothScrolling);
- s_defaultAttributes.insert(WebGLEnabled, webGL);
- s_defaultAttributes.insert(Accelerated2dCanvasEnabled, accelerated2dCanvas);
- s_defaultAttributes.insert(AutoLoadIconsForPage, true);
- s_defaultAttributes.insert(TouchIconsEnabled, false);
- s_defaultAttributes.insert(FocusOnNavigationEnabled, false);
- s_defaultAttributes.insert(PrintElementBackgrounds, true);
- s_defaultAttributes.insert(AllowRunningInsecureContent, allowRunningInsecureContent);
- s_defaultAttributes.insert(AllowGeolocationOnInsecureOrigins, false);
- s_defaultAttributes.insert(AllowWindowActivationFromJavaScript, false);
+ s_defaultAttributes.insert(QWebEngineSettings::ScrollAnimatorEnabled, smoothScrolling);
+ s_defaultAttributes.insert(QWebEngineSettings::WebGLEnabled, webGL);
+ s_defaultAttributes.insert(QWebEngineSettings::Accelerated2dCanvasEnabled,
+ accelerated2dCanvas);
+ s_defaultAttributes.insert(QWebEngineSettings::AutoLoadIconsForPage, true);
+ s_defaultAttributes.insert(QWebEngineSettings::TouchIconsEnabled, false);
+ s_defaultAttributes.insert(QWebEngineSettings::FocusOnNavigationEnabled, false);
+ s_defaultAttributes.insert(QWebEngineSettings::PrintElementBackgrounds, true);
+ s_defaultAttributes.insert(QWebEngineSettings::AllowRunningInsecureContent,
+ allowRunningInsecureContent);
+ s_defaultAttributes.insert(QWebEngineSettings::AllowGeolocationOnInsecureOrigins, false);
+ s_defaultAttributes.insert(QWebEngineSettings::AllowWindowActivationFromJavaScript, false);
bool playbackRequiresUserGesture = false;
if (commandLine->HasSwitch(switches::kAutoplayPolicy))
playbackRequiresUserGesture = (commandLine->GetSwitchValueASCII(switches::kAutoplayPolicy) != switches::autoplay::kNoUserGestureRequiredPolicy);
- s_defaultAttributes.insert(PlaybackRequiresUserGesture, playbackRequiresUserGesture);
- s_defaultAttributes.insert(WebRTCPublicInterfacesOnly, false);
- s_defaultAttributes.insert(JavascriptCanPaste, false);
- s_defaultAttributes.insert(DnsPrefetchEnabled, false);
+ s_defaultAttributes.insert(QWebEngineSettings::PlaybackRequiresUserGesture,
+ playbackRequiresUserGesture);
+ s_defaultAttributes.insert(QWebEngineSettings::WebRTCPublicInterfacesOnly, false);
+ s_defaultAttributes.insert(QWebEngineSettings::JavascriptCanPaste, false);
+ s_defaultAttributes.insert(QWebEngineSettings::DnsPrefetchEnabled, false);
#if QT_CONFIG(webengine_extensions)
- s_defaultAttributes.insert(PdfViewerEnabled, true);
+ s_defaultAttributes.insert(QWebEngineSettings::PdfViewerEnabled, true);
#else
- s_defaultAttributes.insert(PdfViewerEnabled, false);
+ s_defaultAttributes.insert(QWebEngineSettings::PdfViewerEnabled, false);
#endif
}
@@ -298,32 +301,34 @@ void WebEngineSettings::initDefaults()
// Default fonts
QFont defaultFont;
defaultFont.setStyleHint(QFont::Serif);
- s_defaultFontFamilies.insert(StandardFont, defaultFont.defaultFamily());
- s_defaultFontFamilies.insert(SerifFont, defaultFont.defaultFamily());
- s_defaultFontFamilies.insert(PictographFont, defaultFont.defaultFamily());
+ s_defaultFontFamilies.insert(QWebEngineSettings::StandardFont, defaultFont.defaultFamily());
+ s_defaultFontFamilies.insert(QWebEngineSettings::SerifFont, defaultFont.defaultFamily());
+ s_defaultFontFamilies.insert(QWebEngineSettings::PictographFont,
+ defaultFont.defaultFamily());
defaultFont.setStyleHint(QFont::Fantasy);
- s_defaultFontFamilies.insert(FantasyFont, defaultFont.defaultFamily());
+ s_defaultFontFamilies.insert(QWebEngineSettings::FantasyFont, defaultFont.defaultFamily());
defaultFont.setStyleHint(QFont::Cursive);
- s_defaultFontFamilies.insert(CursiveFont, defaultFont.defaultFamily());
+ s_defaultFontFamilies.insert(QWebEngineSettings::CursiveFont, defaultFont.defaultFamily());
defaultFont.setStyleHint(QFont::SansSerif);
- s_defaultFontFamilies.insert(SansSerifFont, defaultFont.defaultFamily());
+ s_defaultFontFamilies.insert(QWebEngineSettings::SansSerifFont,
+ defaultFont.defaultFamily());
defaultFont.setStyleHint(QFont::Monospace);
- s_defaultFontFamilies.insert(FixedFont, defaultFont.defaultFamily());
+ s_defaultFontFamilies.insert(QWebEngineSettings::FixedFont, defaultFont.defaultFamily());
}
if (s_defaultFontSizes.isEmpty()) {
- s_defaultFontSizes.insert(MinimumFontSize, 0);
- s_defaultFontSizes.insert(MinimumLogicalFontSize, 6);
- s_defaultFontSizes.insert(DefaultFixedFontSize, 13);
- s_defaultFontSizes.insert(DefaultFontSize, 16);
+ s_defaultFontSizes.insert(QWebEngineSettings::MinimumFontSize, 0);
+ s_defaultFontSizes.insert(QWebEngineSettings::MinimumLogicalFontSize, 6);
+ s_defaultFontSizes.insert(QWebEngineSettings::DefaultFixedFontSize, 13);
+ s_defaultFontSizes.insert(QWebEngineSettings::DefaultFontSize, 16);
}
m_defaultEncoding = QStringLiteral("ISO-8859-1");
- m_unknownUrlSchemePolicy = InheritedUnknownUrlSchemePolicy;
+ m_unknownUrlSchemePolicy = QWebEngineSettings::InheritedUnknownUrlSchemePolicy;
}
void WebEngineSettings::scheduleApply()
@@ -363,46 +368,59 @@ void WebEngineSettings::applySettingsToWebPreferences(blink::web_pref::WebPrefer
}
// Attributes mapping.
- prefs->loads_images_automatically = testAttribute(AutoLoadImages);
- prefs->javascript_enabled = testAttribute(JavascriptEnabled);
- prefs->javascript_can_access_clipboard = testAttribute(JavascriptCanAccessClipboard);
- prefs->tabs_to_links = testAttribute(LinksIncludedInFocusChain);
- prefs->local_storage_enabled = testAttribute(LocalStorageEnabled);
- prefs->databases_enabled = testAttribute(LocalStorageEnabled);
- prefs->allow_universal_access_from_file_urls = testAttribute(LocalContentCanAccessRemoteUrls);
- prefs->spatial_navigation_enabled = testAttribute(SpatialNavigationEnabled);
- prefs->allow_file_access_from_file_urls = testAttribute(LocalContentCanAccessFileUrls);
- prefs->hyperlink_auditing_enabled = testAttribute(HyperlinkAuditingEnabled);
- prefs->enable_scroll_animator = testAttribute(ScrollAnimatorEnabled);
- prefs->enable_error_page = testAttribute(ErrorPageEnabled);
- prefs->plugins_enabled = testAttribute(PluginsEnabled);
- prefs->fullscreen_supported = testAttribute(FullScreenSupportEnabled);
- prefs->accelerated_2d_canvas_enabled = testAttribute(Accelerated2dCanvasEnabled);
- prefs->webgl1_enabled = prefs->webgl2_enabled = testAttribute(WebGLEnabled);
- prefs->should_print_backgrounds = testAttribute(PrintElementBackgrounds);
- prefs->allow_running_insecure_content = testAttribute(AllowRunningInsecureContent);
- prefs->allow_geolocation_on_insecure_origins = testAttribute(AllowGeolocationOnInsecureOrigins);
- prefs->hide_scrollbars = !testAttribute(ShowScrollBars);
- if (isAttributeExplicitlySet(PlaybackRequiresUserGesture)) {
- prefs->autoplay_policy = testAttribute(PlaybackRequiresUserGesture)
- ? blink::web_pref::AutoplayPolicy::kUserGestureRequired
- : blink::web_pref::AutoplayPolicy::kNoUserGestureRequired;
+ prefs->loads_images_automatically = testAttribute(QWebEngineSettings::AutoLoadImages);
+ prefs->javascript_enabled = testAttribute(QWebEngineSettings::JavascriptEnabled);
+ prefs->javascript_can_access_clipboard =
+ testAttribute(QWebEngineSettings::JavascriptCanAccessClipboard);
+ prefs->tabs_to_links = testAttribute(QWebEngineSettings::LinksIncludedInFocusChain);
+ prefs->local_storage_enabled = testAttribute(QWebEngineSettings::LocalStorageEnabled);
+ prefs->databases_enabled = testAttribute(QWebEngineSettings::LocalStorageEnabled);
+ prefs->allow_universal_access_from_file_urls =
+ testAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls);
+ prefs->spatial_navigation_enabled = testAttribute(QWebEngineSettings::SpatialNavigationEnabled);
+ prefs->allow_file_access_from_file_urls =
+ testAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls);
+ prefs->hyperlink_auditing_enabled = testAttribute(QWebEngineSettings::HyperlinkAuditingEnabled);
+ prefs->enable_scroll_animator = testAttribute(QWebEngineSettings::ScrollAnimatorEnabled);
+ prefs->enable_error_page = testAttribute(QWebEngineSettings::ErrorPageEnabled);
+ prefs->plugins_enabled = testAttribute(QWebEngineSettings::PluginsEnabled);
+ prefs->fullscreen_supported = testAttribute(QWebEngineSettings::FullScreenSupportEnabled);
+ prefs->accelerated_2d_canvas_enabled =
+ testAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled);
+ prefs->webgl1_enabled = prefs->webgl2_enabled = testAttribute(QWebEngineSettings::WebGLEnabled);
+ prefs->should_print_backgrounds = testAttribute(QWebEngineSettings::PrintElementBackgrounds);
+ prefs->allow_running_insecure_content =
+ testAttribute(QWebEngineSettings::AllowRunningInsecureContent);
+ prefs->allow_geolocation_on_insecure_origins =
+ testAttribute(QWebEngineSettings::AllowGeolocationOnInsecureOrigins);
+ prefs->hide_scrollbars = !testAttribute(QWebEngineSettings::ShowScrollBars);
+ if (isAttributeExplicitlySet(QWebEngineSettings::PlaybackRequiresUserGesture)) {
+ prefs->autoplay_policy = testAttribute(QWebEngineSettings::PlaybackRequiresUserGesture)
+ ? blink::mojom::AutoplayPolicy::kUserGestureRequired
+ : blink::mojom::AutoplayPolicy::kNoUserGestureRequired;
}
- prefs->dom_paste_enabled = testAttribute(JavascriptCanPaste);
- prefs->dns_prefetching_enabled = testAttribute(DnsPrefetchEnabled);
+ prefs->dom_paste_enabled = testAttribute(QWebEngineSettings::JavascriptCanPaste);
+ prefs->dns_prefetching_enabled = testAttribute(QWebEngineSettings::DnsPrefetchEnabled);
// Fonts settings.
- prefs->standard_font_family_map[blink::web_pref::kCommonScript] = toString16(fontFamily(StandardFont));
- prefs->fixed_font_family_map[blink::web_pref::kCommonScript] = toString16(fontFamily(FixedFont));
- prefs->serif_font_family_map[blink::web_pref::kCommonScript] = toString16(fontFamily(SerifFont));
- prefs->sans_serif_font_family_map[blink::web_pref::kCommonScript] = toString16(fontFamily(SansSerifFont));
- prefs->cursive_font_family_map[blink::web_pref::kCommonScript] = toString16(fontFamily(CursiveFont));
- prefs->fantasy_font_family_map[blink::web_pref::kCommonScript] = toString16(fontFamily(FantasyFont));
- prefs->pictograph_font_family_map[blink::web_pref::kCommonScript] = toString16(fontFamily(PictographFont));
- prefs->default_font_size = fontSize(DefaultFontSize);
- prefs->default_fixed_font_size = fontSize(DefaultFixedFontSize);
- prefs->minimum_font_size = fontSize(MinimumFontSize);
- prefs->minimum_logical_font_size = fontSize(MinimumLogicalFontSize);
+ prefs->standard_font_family_map[blink::web_pref::kCommonScript] =
+ toString16(fontFamily(QWebEngineSettings::StandardFont));
+ prefs->fixed_font_family_map[blink::web_pref::kCommonScript] =
+ toString16(fontFamily(QWebEngineSettings::FixedFont));
+ prefs->serif_font_family_map[blink::web_pref::kCommonScript] =
+ toString16(fontFamily(QWebEngineSettings::SerifFont));
+ prefs->sans_serif_font_family_map[blink::web_pref::kCommonScript] =
+ toString16(fontFamily(QWebEngineSettings::SansSerifFont));
+ prefs->cursive_font_family_map[blink::web_pref::kCommonScript] =
+ toString16(fontFamily(QWebEngineSettings::CursiveFont));
+ prefs->fantasy_font_family_map[blink::web_pref::kCommonScript] =
+ toString16(fontFamily(QWebEngineSettings::FantasyFont));
+ prefs->pictograph_font_family_map[blink::web_pref::kCommonScript] =
+ toString16(fontFamily(QWebEngineSettings::PictographFont));
+ prefs->default_font_size = fontSize(QWebEngineSettings::DefaultFontSize);
+ prefs->default_fixed_font_size = fontSize(QWebEngineSettings::DefaultFixedFontSize);
+ prefs->minimum_font_size = fontSize(QWebEngineSettings::MinimumFontSize);
+ prefs->minimum_logical_font_size = fontSize(QWebEngineSettings::MinimumLogicalFontSize);
prefs->default_encoding = defaultTextEncoding().toStdString();
// Set the theme colors. Based on chrome_content_browser_client.cc:
@@ -410,10 +428,10 @@ void WebEngineSettings::applySettingsToWebPreferences(blink::web_pref::WebPrefer
if (webTheme) {
switch (webTheme->GetPreferredColorScheme()) {
case ui::NativeTheme::PreferredColorScheme::kDark:
- prefs->preferred_color_scheme = blink::PreferredColorScheme::kDark;
+ prefs->preferred_color_scheme = blink::mojom::PreferredColorScheme::kDark;
break;
case ui::NativeTheme::PreferredColorScheme::kLight:
- prefs->preferred_color_scheme = blink::PreferredColorScheme::kLight;
+ prefs->preferred_color_scheme = blink::mojom::PreferredColorScheme::kLight;
break;
}
}
@@ -442,14 +460,15 @@ void WebEngineSettings::applySettingsToWebPreferences(blink::web_pref::WebPrefer
}
}
-bool WebEngineSettings::applySettingsToRendererPreferences(blink::mojom::RendererPreferences *prefs)
+bool WebEngineSettings::applySettingsToRendererPreferences(blink::RendererPreferences *prefs)
{
bool changed = false;
#if QT_CONFIG(webengine_webrtc)
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kForceWebRtcIPHandlingPolicy)) {
- std::string webrtc_ip_handling_policy = testAttribute(WebEngineSettings::WebRTCPublicInterfacesOnly)
- ? blink::kWebRTCIPHandlingDefaultPublicInterfaceOnly
- : blink::kWebRTCIPHandlingDefault;
+ std::string webrtc_ip_handling_policy =
+ testAttribute(QWebEngineSettings::WebRTCPublicInterfacesOnly)
+ ? blink::kWebRTCIPHandlingDefaultPublicInterfaceOnly
+ : blink::kWebRTCIPHandlingDefault;
if (prefs->webrtc_ip_handling_policy != webrtc_ip_handling_policy) {
prefs->webrtc_ip_handling_policy = webrtc_ip_handling_policy;
changed = true;
@@ -469,7 +488,7 @@ void WebEngineSettings::scheduleApplyRecursively()
bool WebEngineSettings::getJavaScriptCanOpenWindowsAutomatically()
{
- return testAttribute(JavascriptCanOpenWindows);
+ return testAttribute(QWebEngineSettings::JavascriptCanOpenWindows);
}
void WebEngineSettings::setParentSettings(WebEngineSettings *_parentSettings)
@@ -479,6 +498,7 @@ void WebEngineSettings::setParentSettings(WebEngineSettings *_parentSettings)
parentSettings = _parentSettings;
if (parentSettings)
parentSettings->childSettings.insert(this);
+ scheduleApplyRecursively();
}
} // namespace QtWebEngineCore
diff --git a/src/core/web_engine_settings.h b/src/core/web_engine_settings.h
index d97ff5767..5d00a5d6f 100644
--- a/src/core/web_engine_settings.h
+++ b/src/core/web_engine_settings.h
@@ -52,7 +52,7 @@
#define WEB_ENGINE_SETTINGS_H
#include "qtwebenginecoreglobal_p.h"
-
+#include "qwebenginesettings.h"
#include <QScopedPointer>
#include <QHash>
#include <QUrl>
@@ -64,9 +64,7 @@ class WebContents;
}
namespace blink {
-namespace mojom {
-class RendererPreferences;
-}
+struct RendererPreferences;
namespace web_pref {
struct WebPreferences;
}
@@ -75,98 +73,36 @@ namespace QtWebEngineCore {
class WebContentsAdapter;
-class Q_WEBENGINECORE_PRIVATE_EXPORT WebEngineSettings {
+class WebEngineSettings {
public:
- // Attributes. Names match the ones from the public widgets API.
- enum Attribute {
- UnsupportedInCoreSettings = -1,
- AutoLoadImages,
- JavascriptEnabled,
- JavascriptCanOpenWindows,
- JavascriptCanAccessClipboard,
- LinksIncludedInFocusChain,
- LocalStorageEnabled,
- LocalContentCanAccessRemoteUrls,
- XSSAuditingEnabled,
- SpatialNavigationEnabled,
- LocalContentCanAccessFileUrls,
- HyperlinkAuditingEnabled,
- ScrollAnimatorEnabled,
- ErrorPageEnabled,
- PluginsEnabled,
- FullScreenSupportEnabled,
- ScreenCaptureEnabled,
- WebGLEnabled,
- Accelerated2dCanvasEnabled,
- AutoLoadIconsForPage,
- TouchIconsEnabled,
- FocusOnNavigationEnabled,
- PrintElementBackgrounds,
- AllowRunningInsecureContent,
- AllowGeolocationOnInsecureOrigins,
- AllowWindowActivationFromJavaScript,
- ShowScrollBars,
- PlaybackRequiresUserGesture,
- WebRTCPublicInterfacesOnly,
- JavascriptCanPaste,
- DnsPrefetchEnabled,
- PdfViewerEnabled,
- };
-
- // Must match the values from the public API in qwebenginesettings.h.
- enum FontFamily {
- StandardFont,
- FixedFont,
- SerifFont,
- SansSerifFont,
- CursiveFont,
- FantasyFont,
- PictographFont
- };
-
- // Must match the values from the public API in qwebenginesettings.h.
- enum FontSize {
- MinimumFontSize,
- MinimumLogicalFontSize,
- DefaultFontSize,
- DefaultFixedFontSize
- };
-
- // Must match the values from the public API in qwebenginesettings.h.
- enum UnknownUrlSchemePolicy {
- InheritedUnknownUrlSchemePolicy = 0,
- DisallowUnknownUrlSchemes = 1,
- AllowUnknownUrlSchemesFromUserInteraction,
- AllowAllUnknownUrlSchemes
- };
-
- explicit WebEngineSettings(WebEngineSettings *parentSettings = 0);
+ static WebEngineSettings* get(QWebEngineSettings *settings) { return settings->d_ptr.data(); }
+
+ explicit WebEngineSettings(WebEngineSettings *parentSettings = nullptr);
~WebEngineSettings();
void setParentSettings(WebEngineSettings *parentSettings);
void overrideWebPreferences(content::WebContents *webContents, blink::web_pref::WebPreferences *prefs);
- void setAttribute(Attribute, bool on);
- bool testAttribute(Attribute) const;
- void resetAttribute(Attribute);
- bool isAttributeExplicitlySet(Attribute) const;
+ void setAttribute(QWebEngineSettings::WebAttribute, bool on);
+ bool testAttribute(QWebEngineSettings::WebAttribute) const;
+ void resetAttribute(QWebEngineSettings::WebAttribute);
+ bool isAttributeExplicitlySet(QWebEngineSettings::WebAttribute) const;
- void setFontFamily(FontFamily, const QString &);
- QString fontFamily(FontFamily);
- void resetFontFamily(FontFamily);
+ void setFontFamily(QWebEngineSettings::FontFamily, const QString &);
+ QString fontFamily(QWebEngineSettings::FontFamily);
+ void resetFontFamily(QWebEngineSettings::FontFamily);
- void setFontSize(FontSize type, int size);
- int fontSize(FontSize type) const;
- void resetFontSize(FontSize type);
+ void setFontSize(QWebEngineSettings::FontSize type, int size);
+ int fontSize(QWebEngineSettings::FontSize type) const;
+ void resetFontSize(QWebEngineSettings::FontSize type);
void setDefaultTextEncoding(const QString &encoding);
QString defaultTextEncoding() const;
- void setUnknownUrlSchemePolicy(UnknownUrlSchemePolicy policy);
- UnknownUrlSchemePolicy unknownUrlSchemePolicy() const;
+ void setUnknownUrlSchemePolicy(QWebEngineSettings::UnknownUrlSchemePolicy policy);
+ QWebEngineSettings::UnknownUrlSchemePolicy unknownUrlSchemePolicy() const;
- void initDefaults();
void scheduleApply();
void scheduleApplyRecursively();
@@ -174,15 +110,16 @@ public:
bool getJavaScriptCanOpenWindowsAutomatically();
private:
+ void initDefaults();
void doApply();
void applySettingsToWebPreferences(blink::web_pref::WebPreferences *);
- bool applySettingsToRendererPreferences(blink::mojom::RendererPreferences *);
+ bool applySettingsToRendererPreferences(blink::RendererPreferences *);
void setWebContentsAdapter(WebContentsAdapter *adapter) { m_adapter = adapter; }
WebContentsAdapter* m_adapter;
- QHash<Attribute, bool> m_attributes;
- QHash<FontFamily, QString> m_fontFamilies;
- QHash<FontSize, int> m_fontSizes;
+ QHash<QWebEngineSettings::WebAttribute, bool> m_attributes;
+ QHash<QWebEngineSettings::FontFamily, QString> m_fontFamilies;
+ QHash<QWebEngineSettings::FontSize, int> m_fontSizes;
QString m_defaultEncoding;
QScopedPointer<blink::web_pref::WebPreferences> webPreferences;
QTimer m_batchTimer;
@@ -190,10 +127,10 @@ private:
WebEngineSettings *parentSettings;
QSet<WebEngineSettings *> childSettings;
- static QHash<Attribute, bool> s_defaultAttributes;
- static QHash<FontFamily, QString> s_defaultFontFamilies;
- static QHash<FontSize, int> s_defaultFontSizes;
- UnknownUrlSchemePolicy m_unknownUrlSchemePolicy;
+ static QHash<QWebEngineSettings::WebAttribute, bool> s_defaultAttributes;
+ static QHash<QWebEngineSettings::FontFamily, QString> s_defaultFontFamilies;
+ static QHash<QWebEngineSettings::FontSize, int> s_defaultFontSizes;
+ QWebEngineSettings::UnknownUrlSchemePolicy m_unknownUrlSchemePolicy;
friend class WebContentsAdapter;
};
diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp
index 3beb913a7..593acb5e5 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>
@@ -1443,12 +1443,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;
}
@@ -1458,8 +1460,8 @@ static WebPointerProperties::PointerType pointerTypeForTabletEvent(const QTablet
WebMouseEvent WebEventFactory::toWebMouseEvent(QMouseEvent *ev)
{
WebMouseEvent webKitEvent(webEventTypeForEvent(ev),
- gfx::PointF(ev->x(), ev->y()),
- gfx::PointF(ev->globalX(), ev->globalY()),
+ gfx::PointF(ev->position().x(), ev->position().y()),
+ gfx::PointF(ev->globalPosition().x(), ev->globalPosition().y()),
mouseButtonForEvent<QMouseEvent>(ev),
0,
modifiersForEvent(ev),
@@ -1477,9 +1479,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;
@@ -1489,8 +1491,8 @@ WebMouseEvent WebEventFactory::toWebMouseEvent(QHoverEvent *ev)
WebMouseEvent WebEventFactory::toWebMouseEvent(QTabletEvent *ev)
{
WebMouseEvent webKitEvent(webEventTypeForEvent(ev),
- gfx::PointF(ev->x(), ev->y()),
- gfx::PointF(ev->globalX(), ev->globalY()),
+ gfx::PointF(ev->position().x(), ev->position().y()),
+ gfx::PointF(ev->globalPosition().x(), ev->globalPosition().y()),
mouseButtonForEvent<QTabletEvent>(ev),
0,
modifiersForEvent(ev),
@@ -1523,9 +1525,11 @@ WebGestureEvent WebEventFactory::toWebGestureEvent(QNativeGestureEvent *ev)
webKitEvent.SetTimeStamp(base::TimeTicks::Now());
webKitEvent.SetModifiers(modifiersForEvent(ev));
- webKitEvent.SetPositionInWidget(gfx::PointF(ev->localPos().x(), ev->localPos().y()));
+ webKitEvent.SetPositionInWidget(gfx::PointF(ev->position().x(),
+ ev->position().y()));
- webKitEvent.SetPositionInScreen(gfx::PointF(ev->screenPos().x(), ev->screenPos().y()));
+ webKitEvent.SetPositionInScreen(gfx::PointF(ev->globalPosition().x(),
+ ev->globalPosition().y()));
webKitEvent.SetSourceDevice(blink::WebGestureDevice::kTouchpad);
diff --git a/src/pdf/api/qpdfdocument_p.h b/src/pdf/api/qpdfdocument_p.h
index 9a737766b..b6ee2dfd0 100644
--- a/src/pdf/api/qpdfdocument_p.h
+++ b/src/pdf/api/qpdfdocument_p.h
@@ -58,9 +58,11 @@
#include <QtCore/qpointer.h>
#include <QtNetwork/qnetworkreply.h>
+#include <mutex>
+
QT_BEGIN_NAMESPACE
-class QPdfMutexLocker : public QMutexLocker
+class QPdfMutexLocker : public std::unique_lock<QRecursiveMutex>
{
public:
QPdfMutexLocker();
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/qpdfpagenavigation.h b/src/pdf/api/qpdfpagenavigation.h
index 0f416bf77..dc412c33b 100644
--- a/src/pdf/api/qpdfpagenavigation.h
+++ b/src/pdf/api/qpdfpagenavigation.h
@@ -84,7 +84,7 @@ Q_SIGNALS:
void canGoToNextPageChanged(bool canGo);
private:
- Q_DECLARE_PRIVATE(QPdfPageNavigation)
+ QScopedPointer<QPdfPageNavigationPrivate> d_ptr;
};
QT_END_NAMESPACE
diff --git a/src/pdf/api/qpdfpagerenderer.h b/src/pdf/api/qpdfpagerenderer.h
index c7b8de0df..faeaef8af 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
@@ -84,7 +84,7 @@ Q_SIGNALS:
QPdfDocumentRenderOptions options, quint64 requestId);
private:
- Q_DECLARE_PRIVATE(QPdfPageRenderer)
+ QScopedPointer<QPdfPageRendererPrivate> d_ptr;
};
QT_END_NAMESPACE
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/config/common.pri b/src/pdf/config/common.pri
index f688caded..7e5459a2a 100644
--- a/src/pdf/config/common.pri
+++ b/src/pdf/config/common.pri
@@ -8,10 +8,10 @@ qtConfig(webengine-qt-png) {
gn_args += "pdfium_qt_libpng_includes=\"$$system_path($$QMAKE_INCDIR_LIBPNG)\""
}
-qtConfig(webengine-qt-jpeg) {
- gn_args += use_qt_libjpeg=true
- gn_args += "qt_libjpeg_includes=\"$$system_path($$QMAKE_INCDIR_LIBJPEG)\""
-}
+#qtConfig(webengine-qt-jpeg) {
+# gn_args += use_qt_libjpeg=true
+# gn_args += "qt_libjpeg_includes=\"$$system_path($$QMAKE_INCDIR_LIBJPEG)\""
+#}
qtConfig(webengine-qt-harfbuzz) {
gn_args += use_qt_harfbuzz=true
diff --git a/src/pdf/pdfcore.pro b/src/pdf/pdfcore.pro
index 23e0cec79..bb7146853 100644
--- a/src/pdf/pdfcore.pro
+++ b/src/pdf/pdfcore.pro
@@ -81,7 +81,7 @@ HEADERS += \
qtConfig(webengine-qt-freetype): QMAKE_USE += freetype
qtConfig(webengine-qt-png): QMAKE_USE += libpng
qtConfig(webengine-qt-harfbuzz): QMAKE_USE += harfbuzz
-qtConfig(webengine-qt-jpeg): QMAKE_USE += libjpeg
+#qtConfig(webengine-qt-jpeg): QMAKE_USE += libjpeg
qtConfig(webengine-qt-zlib){} #qtzlib is a part of QtCore
load(qt_module)
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..8fd55dd57 100644
--- a/src/pdf/qpdfdocument.cpp
+++ b/src/pdf/qpdfdocument.cpp
@@ -51,14 +51,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));
+Q_GLOBAL_STATIC(QRecursiveMutex, pdfMutex)
static int libraryRefCount;
static const double CharacterHitTolerance = 16.0;
Q_LOGGING_CATEGORY(qLcDoc, "qt.pdf.document")
QPdfMutexLocker::QPdfMutexLocker()
- : QMutexLocker(pdfMutex())
+ : std::unique_lock<QRecursiveMutex>(*pdfMutex())
{
}
@@ -395,11 +394,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)
@@ -424,6 +423,8 @@ QRectF QPdfDocumentPrivate::getCharBox(FPDF_TEXTPAGE textPage, double pageHeight
QPdfDocumentPrivate::TextPosition QPdfDocumentPrivate::hitTest(int page, QPointF position)
{
const QPdfMutexLocker lock;
+
+ TextPosition result;
FPDF_PAGE pdfPage = FPDF_LoadPage(doc, page);
double pageHeight = FPDF_GetPageHeight(pdfPage);
FPDF_TEXTPAGE textPage = FPDFText_LoadPage(pdfPage);
@@ -440,10 +441,14 @@ QPdfDocumentPrivate::TextPosition QPdfDocumentPrivate::hitTest(int page, QPointF
++hitIndex;
}
qCDebug(qLcDoc) << "on page" << page << "@" << position << "got char position" << charPos << "index" << hitIndex;
- return { charPos, charBox.height(), hitIndex };
+ result = { charPos, charBox.height(), hitIndex };
}
}
- return {};
+
+ FPDFText_ClosePage(textPage);
+ FPDF_ClosePage(pdfPage);
+
+ return result;
}
/*!
@@ -596,11 +601,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
@@ -789,6 +794,9 @@ QPdfSelection QPdfDocument::getSelection(int page, QPointF start, QPointF end)
CharacterHitTolerance, CharacterHitTolerance);
int endIndex = FPDFText_GetCharIndexAtPos(textPage, end.x(), pageHeight - end.y(),
CharacterHitTolerance, CharacterHitTolerance);
+
+ QPdfSelection result;
+
if (startIndex >= 0 && endIndex != startIndex) {
if (startIndex > endIndex)
qSwap(startIndex, endIndex);
@@ -801,7 +809,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) {
@@ -815,11 +823,15 @@ QPdfSelection QPdfDocument::getSelection(int page, QPointF start, QPointF end)
bounds << QPolygonF(rect);
}
qCDebug(qLcDoc) << page << start << "->" << end << "found" << startIndex << "->" << endIndex << text;
- return QPdfSelection(text, bounds, hull, startIndex, endIndex);
+ result = QPdfSelection(text, bounds, hull, startIndex, endIndex);
+ } else {
+ qCDebug(qLcDoc) << page << start << "->" << end << "nothing found";
}
- qCDebug(qLcDoc) << page << start << "->" << end << "nothing found";
- return QPdfSelection();
+ FPDFText_ClosePage(textPage);
+ FPDF_ClosePage(pdfPage);
+
+ return result;
}
/*!
@@ -838,7 +850,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;
@@ -860,6 +872,10 @@ QPdfSelection QPdfDocument::getSelectionAtIndex(int page, int startIndex, int ma
hull = QRectF(d->getCharPosition(textPage, pageHeight, startIndex), QSizeF());
qCDebug(qLcDoc) << "on page" << page << "at index" << startIndex << "maxLength" << maxLength
<< "got" << text.length() << "chars," << rectCount << "rects within" << hull;
+
+ FPDFText_ClosePage(textPage);
+ FPDF_ClosePage(pdfPage);
+
return QPdfSelection(text, bounds, hull, startIndex, startIndex + text.length());
}
@@ -876,7 +892,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) {
@@ -890,6 +906,10 @@ QPdfSelection QPdfDocument::getAllText(int page)
bounds << QPolygonF(rect);
}
qCDebug(qLcDoc) << "on page" << page << "got" << count << "chars," << rectCount << "rects within" << hull;
+
+ FPDFText_ClosePage(textPage);
+ FPDF_ClosePage(pdfPage);
+
return QPdfSelection(text, bounds, hull, 0, count);
}
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/qpdfpagenavigation.cpp b/src/pdf/qpdfpagenavigation.cpp
index 497c1c2eb..031b38962 100644
--- a/src/pdf/qpdfpagenavigation.cpp
+++ b/src/pdf/qpdfpagenavigation.cpp
@@ -44,36 +44,31 @@
QT_BEGIN_NAMESPACE
-class QPdfPageNavigationPrivate : public QObjectPrivate
+class QPdfPageNavigationPrivate
{
public:
- QPdfPageNavigationPrivate()
- : QObjectPrivate()
- {
- }
+ QPdfPageNavigationPrivate(QPdfPageNavigation *q) : q_ptr(q) { }
void update()
{
- Q_Q(QPdfPageNavigation);
-
const bool documentAvailable = m_document && m_document->status() == QPdfDocument::Ready;
if (documentAvailable) {
const int newPageCount = m_document->pageCount();
if (m_pageCount != newPageCount) {
m_pageCount = newPageCount;
- emit q->pageCountChanged(m_pageCount);
+ emit q_ptr->pageCountChanged(m_pageCount);
}
} else {
if (m_pageCount != 0) {
m_pageCount = 0;
- emit q->pageCountChanged(m_pageCount);
+ emit q_ptr->pageCountChanged(m_pageCount);
}
}
if (m_currentPage != 0) {
m_currentPage = 0;
- emit q->currentPageChanged(m_currentPage);
+ emit q_ptr->currentPageChanged(m_currentPage);
}
updatePrevNext();
@@ -81,19 +76,17 @@ public:
void updatePrevNext()
{
- Q_Q(QPdfPageNavigation);
-
const bool hasPreviousPage = m_currentPage > 0;
const bool hasNextPage = m_currentPage < (m_pageCount - 1);
if (m_canGoToPreviousPage != hasPreviousPage) {
m_canGoToPreviousPage = hasPreviousPage;
- emit q->canGoToPreviousPageChanged(m_canGoToPreviousPage);
+ emit q_ptr->canGoToPreviousPageChanged(m_canGoToPreviousPage);
}
if (m_canGoToNextPage != hasNextPage) {
m_canGoToNextPage = hasNextPage;
- emit q->canGoToNextPageChanged(m_canGoToNextPage);
+ emit q_ptr->canGoToNextPageChanged(m_canGoToNextPage);
}
}
@@ -102,8 +95,7 @@ public:
update();
}
- Q_DECLARE_PUBLIC(QPdfPageNavigation)
-
+ QPdfPageNavigation *q_ptr = nullptr;
QPointer<QPdfDocument> m_document = nullptr;
int m_currentPage = 0;
int m_pageCount = 0;
@@ -128,7 +120,7 @@ public:
Constructs a page navigation object with parent object \a parent.
*/
QPdfPageNavigation::QPdfPageNavigation(QObject *parent)
- : QObject(*new QPdfPageNavigationPrivate, parent)
+ : QObject(parent), d_ptr(new QPdfPageNavigationPrivate(this))
{
}
@@ -156,9 +148,7 @@ QPdfPageNavigation::~QPdfPageNavigation()
*/
QPdfDocument* QPdfPageNavigation::document() const
{
- Q_D(const QPdfPageNavigation);
-
- return d->m_document;
+ return d_ptr->m_document;
}
/*!
@@ -170,21 +160,21 @@ QPdfDocument* QPdfPageNavigation::document() const
*/
void QPdfPageNavigation::setDocument(QPdfDocument *document)
{
- Q_D(QPdfPageNavigation);
-
- if (d->m_document == document)
+ if (d_ptr->m_document == document)
return;
- if (d->m_document)
- disconnect(d->m_documentStatusChangedConnection);
+ if (d_ptr->m_document)
+ disconnect(d_ptr->m_documentStatusChangedConnection);
- d->m_document = document;
- emit documentChanged(d->m_document);
+ d_ptr->m_document = document;
+ emit documentChanged(d_ptr->m_document);
- if (d->m_document)
- d->m_documentStatusChangedConnection = connect(d->m_document.data(), &QPdfDocument::statusChanged, this, [d](){ d->documentStatusChanged(); });
+ if (d_ptr->m_document)
+ d_ptr->m_documentStatusChangedConnection =
+ connect(d_ptr->m_document.data(), &QPdfDocument::statusChanged, this,
+ [this]() { d_ptr->documentStatusChanged(); });
- d->update();
+ d_ptr->update();
}
/*!
@@ -201,9 +191,7 @@ void QPdfPageNavigation::setDocument(QPdfDocument *document)
*/
int QPdfPageNavigation::currentPage() const
{
- Q_D(const QPdfPageNavigation);
-
- return d->m_currentPage;
+ return d_ptr->m_currentPage;
}
/*!
@@ -213,18 +201,16 @@ int QPdfPageNavigation::currentPage() const
*/
void QPdfPageNavigation::setCurrentPage(int newPage)
{
- Q_D(QPdfPageNavigation);
-
- if (newPage < 0 || newPage >= d->m_pageCount)
+ if (newPage < 0 || newPage >= d_ptr->m_pageCount)
return;
- if (d->m_currentPage == newPage)
+ if (d_ptr->m_currentPage == newPage)
return;
- d->m_currentPage = newPage;
- emit currentPageChanged(d->m_currentPage);
+ d_ptr->m_currentPage = newPage;
+ emit currentPageChanged(d_ptr->m_currentPage);
- d->updatePrevNext();
+ d_ptr->updatePrevNext();
}
/*!
@@ -240,9 +226,7 @@ void QPdfPageNavigation::setCurrentPage(int newPage)
*/
int QPdfPageNavigation::pageCount() const
{
- Q_D(const QPdfPageNavigation);
-
- return d->m_pageCount;
+ return d_ptr->m_pageCount;
}
/*!
@@ -257,9 +241,7 @@ int QPdfPageNavigation::pageCount() const
*/
bool QPdfPageNavigation::canGoToPreviousPage() const
{
- Q_D(const QPdfPageNavigation);
-
- return d->m_canGoToPreviousPage;
+ return d_ptr->m_canGoToPreviousPage;
}
/*!
@@ -274,9 +256,7 @@ bool QPdfPageNavigation::canGoToPreviousPage() const
*/
bool QPdfPageNavigation::canGoToNextPage() const
{
- Q_D(const QPdfPageNavigation);
-
- return d->m_canGoToNextPage;
+ return d_ptr->m_canGoToNextPage;
}
/*!
@@ -288,10 +268,8 @@ bool QPdfPageNavigation::canGoToNextPage() const
*/
void QPdfPageNavigation::goToPreviousPage()
{
- Q_D(QPdfPageNavigation);
-
- if (d->m_currentPage > 0)
- setCurrentPage(d->m_currentPage - 1);
+ if (d_ptr->m_currentPage > 0)
+ setCurrentPage(d_ptr->m_currentPage - 1);
}
/*!
@@ -303,10 +281,8 @@ void QPdfPageNavigation::goToPreviousPage()
*/
void QPdfPageNavigation::goToNextPage()
{
- Q_D(QPdfPageNavigation);
-
- if (d->m_currentPage < d->m_pageCount - 1)
- setCurrentPage(d->m_currentPage + 1);
+ if (d_ptr->m_currentPage < d_ptr->m_pageCount - 1)
+ setCurrentPage(d_ptr->m_currentPage + 1);
}
QT_END_NAMESPACE
diff --git a/src/pdf/qpdfpagerenderer.cpp b/src/pdf/qpdfpagerenderer.cpp
index 31d9f4e1e..8be0cfa21 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>
@@ -67,10 +66,8 @@ private:
QMutex m_mutex;
};
-class QPdfPageRendererPrivate : public QObjectPrivate
+class QPdfPageRendererPrivate
{
- Q_DECLARE_PUBLIC(QPdfPageRenderer)
-
public:
QPdfPageRendererPrivate();
~QPdfPageRendererPrivate();
@@ -90,8 +87,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;
@@ -133,12 +130,7 @@ void RenderWorker::requestPage(quint64 requestId, int pageNumber, QSize imageSiz
emit pageRendered(pageNumber, imageSize, image, options, requestId);
}
-
-QPdfPageRendererPrivate::QPdfPageRendererPrivate()
- : QObjectPrivate()
- , m_renderWorker(new RenderWorker)
-{
-}
+QPdfPageRendererPrivate::QPdfPageRendererPrivate() : m_renderWorker(new RenderWorker) { }
QPdfPageRendererPrivate::~QPdfPageRendererPrivate()
{
@@ -194,18 +186,17 @@ void QPdfPageRendererPrivate::requestFinished(int page, QSize imageSize, const Q
Constructs a page renderer object with parent object \a parent.
*/
QPdfPageRenderer::QPdfPageRenderer(QObject *parent)
- : QObject(*new QPdfPageRendererPrivate(), parent)
+ : QObject(parent), d_ptr(new QPdfPageRendererPrivate)
{
- Q_D(QPdfPageRenderer);
-
qRegisterMetaType<QPdfDocumentRenderOptions>();
- connect(d->m_renderWorker.data(), &RenderWorker::pageRendered, this,
- [this,d](int page, QSize imageSize, const QImage &image, QPdfDocumentRenderOptions options, quint64 requestId) {
- d->requestFinished(page, imageSize, image, options, requestId);
+ connect(d_ptr->m_renderWorker.data(), &RenderWorker::pageRendered, this,
+ [this](int page, QSize imageSize, const QImage &image,
+ QPdfDocumentRenderOptions options, quint64 requestId) {
+ d_ptr->requestFinished(page, imageSize, image, options, requestId);
emit pageRendered(page, imageSize, image, options, requestId);
- d->handleNextRequest();
- });
+ d_ptr->handleNextRequest();
+ });
}
/*!
@@ -242,9 +233,7 @@ QPdfPageRenderer::~QPdfPageRenderer()
*/
QPdfPageRenderer::RenderMode QPdfPageRenderer::renderMode() const
{
- Q_D(const QPdfPageRenderer);
-
- return d->m_renderMode;
+ return d_ptr->m_renderMode;
}
/*!
@@ -254,26 +243,24 @@ QPdfPageRenderer::RenderMode QPdfPageRenderer::renderMode() const
*/
void QPdfPageRenderer::setRenderMode(RenderMode mode)
{
- Q_D(QPdfPageRenderer);
-
- if (d->m_renderMode == mode)
+ if (d_ptr->m_renderMode == mode)
return;
- d->m_renderMode = mode;
- emit renderModeChanged(d->m_renderMode);
+ d_ptr->m_renderMode = mode;
+ emit renderModeChanged(d_ptr->m_renderMode);
- if (d->m_renderMode == RenderMode::MultiThreaded) {
- d->m_renderThread = new QThread;
- d->m_renderWorker->moveToThread(d->m_renderThread);
- d->m_renderThread->start();
+ if (d_ptr->m_renderMode == RenderMode::MultiThreaded) {
+ d_ptr->m_renderThread = new QThread;
+ d_ptr->m_renderWorker->moveToThread(d_ptr->m_renderThread);
+ d_ptr->m_renderThread->start();
} else {
- d->m_renderThread->quit();
- d->m_renderThread->wait();
- delete d->m_renderThread;
- d->m_renderThread = nullptr;
+ d_ptr->m_renderThread->quit();
+ d_ptr->m_renderThread->wait();
+ delete d_ptr->m_renderThread;
+ d_ptr->m_renderThread = nullptr;
// pulling the object from another thread should be fine, once that thread is deleted
- d->m_renderWorker->moveToThread(this->thread());
+ d_ptr->m_renderWorker->moveToThread(this->thread());
}
}
@@ -294,9 +281,7 @@ void QPdfPageRenderer::setRenderMode(RenderMode mode)
*/
QPdfDocument* QPdfPageRenderer::document() const
{
- Q_D(const QPdfPageRenderer);
-
- return d->m_document;
+ return d_ptr->m_document;
}
/*!
@@ -306,15 +291,13 @@ QPdfDocument* QPdfPageRenderer::document() const
*/
void QPdfPageRenderer::setDocument(QPdfDocument *document)
{
- Q_D(QPdfPageRenderer);
-
- if (d->m_document == document)
+ if (d_ptr->m_document == document)
return;
- d->m_document = document;
- emit documentChanged(d->m_document);
+ d_ptr->m_document = document;
+ emit documentChanged(d_ptr->m_document);
- d->m_renderWorker->setDocument(d->m_document);
+ d_ptr->m_renderWorker->setDocument(d_ptr->m_document);
}
/*!
@@ -329,19 +312,17 @@ void QPdfPageRenderer::setDocument(QPdfDocument *document)
quint64 QPdfPageRenderer::requestPage(int pageNumber, QSize imageSize,
QPdfDocumentRenderOptions options)
{
- Q_D(QPdfPageRenderer);
-
- if (!d->m_document || d->m_document->status() != QPdfDocument::Ready)
+ if (!d_ptr->m_document || d_ptr->m_document->status() != QPdfDocument::Ready)
return 0;
- for (const auto &request : qAsConst(d->m_pendingRequests)) {
+ for (const auto &request : qAsConst(d_ptr->m_pendingRequests)) {
if (request.pageNumber == pageNumber
&& request.imageSize == imageSize
&& request.options == options)
return request.id;
}
- const auto id = d->m_requestIdCounter++;
+ const auto id = d_ptr->m_requestIdCounter++;
QPdfPageRendererPrivate::PageRequest request;
request.id = id;
@@ -349,9 +330,9 @@ quint64 QPdfPageRenderer::requestPage(int pageNumber, QSize imageSize,
request.imageSize = imageSize;
request.options = options;
- d->m_requests.append(request);
+ d_ptr->m_requests.append(request);
- d->handleNextRequest();
+ d_ptr->handleNextRequest();
return id;
}
diff --git a/src/pdf/qpdfsearchmodel.cpp b/src/pdf/qpdfsearchmodel.cpp
index 27b7833fc..4d4e86cee 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;
}
@@ -198,9 +198,6 @@ void QPdfSearchModelPrivate::clearResults()
if (document) {
searchResults.resize(document->pageCount());
pagesSearched.resize(document->pageCount());
- } else {
- searchResults.resize(0);
- pagesSearched.resize(0);
}
nextPageToUpdate = 0;
updateTimerId = q->startTimer(UpdateTimerInterval);
@@ -230,12 +227,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 +255,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 b40b9f924..d91ca69f8 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..d6b3f0345 100644
--- a/src/pdfwidgets/qpdfview_p.h
+++ b/src/pdfwidgets/qpdfview_p.h
@@ -50,19 +50,19 @@
#include "qpdfview.h"
+#include <QHash>
#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 +86,7 @@ public:
DocumentLayout calculateDocumentLayout() const;
void updateDocumentLayout();
+ QPdfView *q_ptr;
QPointer<QPdfDocument> m_document;
QPdfPageNavigation* m_pageNavigation;
QPdfPageRenderer *m_pageRenderer;
@@ -104,7 +105,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 149bce526..bd5752f7c 100644
--- a/src/process/process.pro
+++ b/src/process/process.pro
@@ -53,7 +53,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/A/Helpers
# Deploy the entitlements file so macdeployqt can use it.
entitlements.files = QtWebEngineProcess.entitlements
@@ -67,7 +67,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/A/Helpers
} else {
target.path = $$[QT_INSTALL_LIBEXECS]
}
diff --git a/src/src.pro b/src/src.pro
index 6f8bc2fe4..3edec57ca 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -2,7 +2,7 @@ load(functions)
include($$QTWEBENGINE_OUT_ROOT/src/buildtools/qtbuildtools-config.pri)
include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri)
-include($$QTWEBENGINE_OUT_ROOT/src/webengine/qtwebengine-config.pri)
+include($$QTWEBENGINE_OUT_ROOT/src/webenginequick/qtwebenginequick-config.pri)
include($$QTWEBENGINE_OUT_ROOT/src/webenginewidgets/qtwebenginewidgets-config.pri)
include($$QTWEBENGINE_OUT_ROOT/src/pdf/qtpdf-config.pri)
include($$QTWEBENGINE_OUT_ROOT/src/pdfwidgets/qtpdfwidgets-config.pri)
@@ -11,7 +11,9 @@ QT_FOR_CONFIG += \
buildtools-private \
webenginecore \
webenginecore-private \
- webengine-private \
+ webenginequick \
+ webenginequick-private \
+ webenginewidgets \
webenginewidgets-private \
pdf-private \
pdfwidgets-private
@@ -21,11 +23,11 @@ TEMPLATE = subdirs
qtConfig(build-qtwebengine-core):qtConfig(webengine-core-support) {
core.depends = buildtools
process.depends = core
- webengine.depends = core
- webenginewidgets.depends = core webengine
- webengine_plugin.subdir = webengine/plugin
- webengine_plugin.target = sub-webengine-plugin
- webengine_plugin.depends = webengine
+ webenginequick.depends = core
+ webenginewidgets.depends = core webenginequick
+ webenginequick_plugin.subdir = webenginequick/plugin
+ webenginequick_plugin.target = sub-webenginequick-plugin
+ webenginequick_plugin.depends = webenginequick
SUBDIRS += buildtools core process
@@ -35,8 +37,8 @@ qtConfig(build-qtwebengine-core):qtConfig(webengine-core-support) {
qwebengine_convert_dict.depends = core
}
- qtConfig(webengine-qml) {
- SUBDIRS += webengine
+ qtConfig(webengine-quick) {
+ SUBDIRS += webenginequick
}
qtConfig(webengine-widgets) {
@@ -61,4 +63,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 cfabbcdf7..d79132510 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
}
@@ -153,7 +153,7 @@ int main(int argc, char *argv[])
}
bool icuDataDirFound = false;
- QString icuDataDir = QLibraryInfo::location(QLibraryInfo::DataPath)
+ QString icuDataDir = QLibraryInfo::path(QLibraryInfo::DataPath)
% QLatin1String("/resources");
// Try to look up the path to the ICU data directory via an environment variable
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/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/qquickwebengineloadrequest.cpp b/src/webengine/api/qquickwebengineloadrequest.cpp
deleted file mode 100644
index db7399dc0..000000000
--- a/src/webengine/api/qquickwebengineloadrequest.cpp
+++ /dev/null
@@ -1,162 +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 <qquickwebengineloadrequest_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QQuickWebEngineLoadRequestPrivate {
-public:
- QQuickWebEngineLoadRequestPrivate(const QUrl& url, QQuickWebEngineView::LoadStatus status, const QString& errorString, int errorCode, QQuickWebEngineView::ErrorDomain errorDomain)
- : url(url)
- , status(status)
- , errorString(errorString)
- , errorCode(errorCode)
- , errorDomain(errorDomain)
- {
- }
-
- QUrl url;
- QQuickWebEngineView::LoadStatus status;
- QString errorString;
- int errorCode;
- QQuickWebEngineView::ErrorDomain errorDomain;
-};
-
-/*!
- \qmltype WebEngineLoadRequest
- \instantiates QQuickWebEngineLoadRequest
- \inqmlmodule QtWebEngine
- \since QtWebEngine 1.0
-
- \brief A utility type for the WebEngineView::loadingChanged signal.
-
- Contains information about a request for loading a web page, such as the URL and
- current loading status (started, succeeded, failed).
-
- \sa WebEngineView::loadingChanged
-*/
-QQuickWebEngineLoadRequest::QQuickWebEngineLoadRequest(const QUrl& url, QQuickWebEngineView::LoadStatus status, const QString& errorString, int errorCode, QQuickWebEngineView::ErrorDomain errorDomain, QObject* parent)
- : QObject(parent)
- , d_ptr(new QQuickWebEngineLoadRequestPrivate(url, status, errorString, errorCode, errorDomain))
-{
-}
-
-QQuickWebEngineLoadRequest::~QQuickWebEngineLoadRequest()
-{
-}
-
-/*!
- \qmlproperty url WebEngineLoadRequest::url
- \brief Holds the URL of the load request.
- */
-QUrl QQuickWebEngineLoadRequest::url() const
-{
- Q_D(const QQuickWebEngineLoadRequest);
- return d->url;
-}
-
-/*!
- \qmlproperty enumeration WebEngineLoadRequest::status
-
- This enumeration represents the load status of a web page load request:
-
- \value WebEngineView.LoadStartedStatus Page is currently loading.
- \value WebEngineView.LoadStoppedStatus
- Loading the page was stopped by the stop() method or by the loader
- code or network stack in Chromium.
- \value WebEngineView.LoadSucceededStatus
- Page has been loaded with success.
- \value WebEngineView.LoadFailedStatus Page could not be loaded.
-
- \sa WebEngineView::loadingChanged
-*/
-QQuickWebEngineView::LoadStatus QQuickWebEngineLoadRequest::status() const
-{
- Q_D(const QQuickWebEngineLoadRequest);
- return d->status;
-}
-
-/*!
- \qmlproperty string WebEngineLoadRequest::errorString
- \brief Holds the error message.
-*/
-QString QQuickWebEngineLoadRequest::errorString() const
-{
- Q_D(const QQuickWebEngineLoadRequest);
- return d->errorString;
-}
-
-/*!
- \qmlproperty enumeration WebEngineLoadRequest::errorDomain
- This enumeration holds the type of a load request error:
-
- \value WebEngineView.NoErrorDomain
- Error type is not known.
- \value WebEngineView.InternalErrorDomain
- Content cannot be interpreted by \QWE.
- \value WebEngineView.ConnectionErrorDomain
- Error results from a faulty network connection.
- \value WebEngineView.CertificateErrorDomain
- Error is related to the SSL/TLS certificate.
- \value WebEngineView.HttpErrorDomain
- Error is related to the HTTP connection.
- \value WebEngineView.FtpErrorDomain
- Error is related to the FTP connection.
- \value WebEngineView.DnsErrorDomain
- Error is related to the DNS connection.
-*/
-
-QQuickWebEngineView::ErrorDomain QQuickWebEngineLoadRequest::errorDomain() const
-{
- Q_D(const QQuickWebEngineLoadRequest);
- return d->errorDomain;
-}
-
-/*!
- \qmlproperty int WebEngineLoadRequest::errorCode
- \brief Holds the error code.
-*/
-int QQuickWebEngineLoadRequest::errorCode() const
-{
- Q_D(const QQuickWebEngineLoadRequest);
- return d->errorCode;
-}
-
-QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebenginescript.cpp b/src/webengine/api/qquickwebenginescript.cpp
deleted file mode 100644
index ab7aee4cb..000000000
--- a/src/webengine/api/qquickwebenginescript.cpp
+++ /dev/null
@@ -1,446 +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 "qquickwebenginescript.h"
-#include "qquickwebenginescript_p.h"
-
-#include <QQmlFile>
-#include <QtCore/QDebug>
-#include <QtCore/QFile>
-#include <QtCore/QTimerEvent>
-#include "renderer_host/user_resource_controller_host.h"
-
-using QtWebEngineCore::UserScript;
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QQuickWebEngineScript
- \brief Enables the injection of scripts in the JavaScript engine.
- \inmodule QtWebEngine
- \since 5.9
-
- The QQuickWebEngineScript type enables the programmatic injection of so called \e {user scripts} in
- the JavaScript engine at different points, determined by injectionPoint, during the loading of
- web content.
-
- Scripts can be executed either in the main JavaScript \e world, along with the rest of the
- JavaScript coming from the web contents, or in their own isolated world. While the DOM of the
- page can be accessed from any world, JavaScript variables of a function defined in one world are
- not accessible from a different one. The worldId property provides some predefined IDs for this
- purpose.
-*/
-
-/*!
- \enum QQuickWebEngineScript::InjectionPoint
-
- The point in the loading process at which the script will be executed.
-
- \value DocumentCreation
- The script will be executed as soon as the document is created. This is not suitable for
- any DOM operation.
- \value DocumentReady
- The script will run as soon as the DOM is ready. This is equivalent to the
- \c DOMContentLoaded event firing in JavaScript.
- \value Deferred
- The script will run when the page load finishes, or 500 ms after the document is ready,
- whichever comes first.
-*/
-
-/*!
- \enum QQuickWebEngineScript::ScriptWorldId
-
- The world ID defining which isolated world the script is executed in. Besides these predefined
- IDs custom IDs can be used, but must be integers between \c 0 and \c 256.
-
- \value MainWorld
- The world used by the page's web contents. It can be useful in order to expose custom
- functionality to web contents in certain scenarios.
- \value ApplicationWorld
- The default isolated world used for application level functionality implemented in
- JavaScript.
- \value UserWorld
- The first isolated world to be used by scripts set by users if the application is not
- making use of more worlds. As a rule of thumb, if that functionality is exposed to the
- application users, each individual script should probably get its own isolated world.
-*/
-
-/*!
- \qmltype WebEngineScript
- \instantiates QQuickWebEngineScript
- \inqmlmodule QtWebEngine
- \since QtWebEngine 1.1
- \brief Enables the programmatic injection of scripts in the JavaScript engine.
-
- The WebEngineScript type enables the programmatic injection of so called \e {user scripts} in
- the JavaScript engine at different points, determined by injectionPoint, during the loading of
- web content.
-
- Scripts can be executed either in the main JavaScript \e world, along with the rest of the
- JavaScript coming from the web contents, or in their own isolated world. While the DOM of the
- page can be accessed from any world, JavaScript variables of a function defined in one world are
- not accessible from a different one. The worldId property provides some predefined IDs for this
- purpose.
-
- The following \l Greasemonkey attributes are supported since Qt 5.8:
- \c @exclude, \c @include, \c @name, \c @match, and \c @run-at.
-
- Use \l{WebEngineView::userScripts}{WebEngineView.userScripts} to access a list of scripts
- attached to the web view.
-*/
-
-/*!
- Constructs a new QQuickWebEngineScript with the parent \a parent.
-*/
-QQuickWebEngineScript::QQuickWebEngineScript(QObject *parent)
- : QObject(parent)
- , d_ptr(new QQuickWebEngineScriptPrivate)
-{
- d_ptr->q_ptr = this;
-}
-
-/*!
- \internal
-*/
-QQuickWebEngineScript::~QQuickWebEngineScript()
-{
-}
-
-/*!
- Returns the script object as string.
-*/
-QString QQuickWebEngineScript::toString() const
-{
- Q_D(const QQuickWebEngineScript);
- if (d->coreScript.isNull())
- return QStringLiteral("QWebEngineScript()");
- QString ret = QStringLiteral("QWebEngineScript(") % d->coreScript.name() % QStringLiteral(", ");
- switch (d->coreScript.injectionPoint()) {
- case UserScript::DocumentElementCreation:
- ret.append(QStringLiteral("WebEngineScript::DocumentCreation, "));
- break;
- case UserScript::DocumentLoadFinished:
- ret.append(QStringLiteral("WebEngineScript::DocumentReady, "));
- break;
- case UserScript::AfterLoad:
- ret.append(QStringLiteral("WebEngineScript::Deferred, "));
- break;
- }
- ret.append(QString::number(d->coreScript.worldId()) % QStringLiteral(", ")
- % (d->coreScript.runsOnSubFrames() ? QStringLiteral("true") : QStringLiteral("false"))
- % QStringLiteral(", ") % d->coreScript.sourceCode() % QLatin1Char(')'));
- return ret;
-}
-
-/*!
- \property QQuickWebEngineScript::name
- \brief The name of the script.
-
- Can be useful to retrieve a particular script from
- QQuickWebEngineProfile::userScripts.
-*/
-
-/*!
- \qmlproperty string WebEngineScript::name
-
- The name of the script. Can be useful to retrieve a particular script from
- \l{WebEngineView::userScripts}{WebEngineView.userScripts}.
-*/
-QString QQuickWebEngineScript::name() const
-{
- Q_D(const QQuickWebEngineScript);
- return d->coreScript.name();
-}
-
-/*!
- \property QQuickWebEngineScript::sourceUrl
- \brief The remote source location of the user script (if any).
-
- Unlike \l sourceCode, this property allows referring to user scripts that
- are not already loaded in memory, for instance, when stored on disk.
-
- Setting this property will change the \l sourceCode of the script.
-
- \note At present, only file-based sources are supported.
-
- \sa QQuickWebEngineScript::sourceCode
-*/
-
-/*!
- \qmlproperty url WebEngineScript::sourceUrl
-
- This property holds the remote source location of the user script (if any).
-
- Unlike \l sourceCode, this property allows referring to user scripts that
- are not already loaded in memory, for instance, when stored on disk.
-
- Setting this property will change the \l sourceCode of the script.
-
- \note At present, only file-based sources are supported.
-
- \sa sourceCode
-*/
-QUrl QQuickWebEngineScript::sourceUrl() const
-{
- Q_D(const QQuickWebEngineScript);
- return d->m_sourceUrl;
-}
-
-/*!
- \property QQuickWebEngineScript::sourceCode
- \brief The JavaScript source code of the user script.
-
- \sa QQuickWebEngineScript::sourceUrl
-*/
-
-/*!
- \qmlproperty string WebEngineScript::sourceCode
-
- This property holds the JavaScript source code of the user script.
-
- \sa sourceUrl
-*/
-QString QQuickWebEngineScript::sourceCode() const
-{
- Q_D(const QQuickWebEngineScript);
- return d->coreScript.sourceCode();
-}
-
-ASSERT_ENUMS_MATCH(QQuickWebEngineScript::Deferred, UserScript::AfterLoad)
-ASSERT_ENUMS_MATCH(QQuickWebEngineScript::DocumentReady, UserScript::DocumentLoadFinished)
-ASSERT_ENUMS_MATCH(QQuickWebEngineScript::DocumentCreation, UserScript::DocumentElementCreation)
-
-/*!
- \property QQuickWebEngineScript::injectionPoint
- \brief The point in the loading process at which the script will be executed.
-
- The default value is \c Deferred.
-*/
-
-/*!
- \qmlproperty enumeration WebEngineScript::injectionPoint
-
- The point in the loading process at which the script will be executed.
- The default value is \c Deferred.
-
- \value WebEngineScript.DocumentCreation
- The script will be executed as soon as the document is created. This is not suitable for
- any DOM operation.
- \value WebEngineScript.DocumentReady
- The script will run as soon as the DOM is ready. This is equivalent to the
- \c DOMContentLoaded event firing in JavaScript.
- \value WebEngineScript.Deferred
- The script will run when the page load finishes, or 500 ms after the document is ready,
- whichever comes first.
-*/
-QQuickWebEngineScript::InjectionPoint QQuickWebEngineScript::injectionPoint() const
-{
- Q_D(const QQuickWebEngineScript);
- return static_cast<QQuickWebEngineScript::InjectionPoint>(d->coreScript.injectionPoint());
-}
-
-/*!
- \property QQuickWebEngineScript::worldId
- \brief The world ID defining which isolated world the script is executed in.
-*/
-
-/*!
- \qmlproperty enumeration WebEngineScript::worldId
-
- The world ID defining which isolated world the script is executed in.
-
- \value WebEngineScript.MainWorld
- The world used by the page's web contents. It can be useful in order to expose custom
- functionality to web contents in certain scenarios.
- \value WebEngineScript.ApplicationWorld
- The default isolated world used for application level functionality implemented in
- JavaScript.
- \value WebEngineScript.UserWorld
- The first isolated world to be used by scripts set by users if the application is not
- making use of more worlds. As a rule of thumb, if that functionality is exposed to the
- application users, each individual script should probably get its own isolated world.
-*/
-QQuickWebEngineScript::ScriptWorldId QQuickWebEngineScript::worldId() const
-{
- Q_D(const QQuickWebEngineScript);
- return static_cast<QQuickWebEngineScript::ScriptWorldId>(d->coreScript.worldId());
-}
-
-/*!
- \property QQuickWebEngineScript::runOnSubframes
- \brief Whether the script is executed on every frame or only on the main frame.
-
- Set this property to \c true if the script is executed on every frame in the page, or \c false
- if it is only run for the main frame.
- The default value is \c{false}.
-*/
-
-/*!
- \qmlproperty int WebEngineScript::runOnSubframes
-
- Set this property to \c true if the script is executed on every frame in the page, or \c false
- if it is only ran for the main frame.
- The default value is \c{false}.
- */
-bool QQuickWebEngineScript::runOnSubframes() const
-{
- Q_D(const QQuickWebEngineScript);
- return d->coreScript.runsOnSubFrames();
-}
-
-void QQuickWebEngineScript::setName(const QString &name)
-{
- Q_D(QQuickWebEngineScript);
- if (name == QQuickWebEngineScript::name())
- return;
- d->aboutToUpdateUnderlyingScript();
- d->coreScript.setName(name);
- Q_EMIT nameChanged(name);
-}
-
-void QQuickWebEngineScript::setSourceCode(const QString &code)
-{
- Q_D(QQuickWebEngineScript);
- if (code == sourceCode())
- return;
-
- // setting the source directly resets the sourceUrl
- if (d->m_sourceUrl != QUrl()) {
- d->m_sourceUrl = QUrl();
- Q_EMIT sourceUrlChanged(d->m_sourceUrl);
- }
-
- d->aboutToUpdateUnderlyingScript();
- d->coreScript.setSourceCode(code);
- Q_EMIT sourceCodeChanged(code);
-}
-
-void QQuickWebEngineScript::setSourceUrl(const QUrl &url)
-{
- Q_D(QQuickWebEngineScript);
- if (url == sourceUrl())
- return;
-
- d->m_sourceUrl = url;
- Q_EMIT sourceUrlChanged(d->m_sourceUrl);
-
- QFile f(QQmlFile::urlToLocalFileOrQrc(url));
- if (!f.open(QIODevice::ReadOnly)) {
- qWarning() << "Can't open user script " << url;
- return;
- }
-
- d->aboutToUpdateUnderlyingScript();
- QString source = QString::fromUtf8(f.readAll());
- d->coreScript.setSourceCode(source);
- Q_EMIT sourceCodeChanged(source);
-}
-
-void QQuickWebEngineScript::setInjectionPoint(QQuickWebEngineScript::InjectionPoint injectionPoint)
-{
- Q_D(QQuickWebEngineScript);
- if (injectionPoint == QQuickWebEngineScript::injectionPoint())
- return;
- d->aboutToUpdateUnderlyingScript();
- d->coreScript.setInjectionPoint(static_cast<UserScript::InjectionPoint>(injectionPoint));
- Q_EMIT injectionPointChanged(injectionPoint);
-}
-
-
-void QQuickWebEngineScript::setWorldId(QQuickWebEngineScript::ScriptWorldId scriptWorldId)
-{
- Q_D(QQuickWebEngineScript);
- if (scriptWorldId == worldId())
- return;
- d->aboutToUpdateUnderlyingScript();
- d->coreScript.setWorldId(scriptWorldId);
- Q_EMIT worldIdChanged(scriptWorldId);
-}
-
-
-void QQuickWebEngineScript::setRunOnSubframes(bool on)
-{
- Q_D(QQuickWebEngineScript);
- if (on == runOnSubframes())
- return;
- d->aboutToUpdateUnderlyingScript();
- d->coreScript.setRunsOnSubFrames(on);
- Q_EMIT runOnSubframesChanged(on);
-}
-
-/*!
- \internal
-*/
-void QQuickWebEngineScript::timerEvent(QTimerEvent *e)
-{
- Q_D(QQuickWebEngineScript);
- if (e->timerId() != d->m_basicTimer.timerId()) {
- QObject::timerEvent(e);
- return;
- }
- if (!d->m_controllerHost)
- return;
- d->m_basicTimer.stop();
- d->m_controllerHost->addUserScript(d->coreScript, d->m_adapter);
-}
-
-void QQuickWebEngineScriptPrivate::bind(QtWebEngineCore::UserResourceControllerHost *resourceController, QtWebEngineCore::WebContentsAdapter *adapter)
-{
- aboutToUpdateUnderlyingScript();
- m_adapter = adapter;
- m_controllerHost = resourceController;
-}
-
-QQuickWebEngineScriptPrivate::QQuickWebEngineScriptPrivate()
- :m_controllerHost(0)
- , m_adapter(0)
-
-{
-}
-
-void QQuickWebEngineScriptPrivate::aboutToUpdateUnderlyingScript()
-{
- Q_Q(QQuickWebEngineScript);
- if (m_controllerHost)
- m_controllerHost->removeUserScript(coreScript, m_adapter);
- // Defer updates to the next event loop
- m_basicTimer.start(0, q);
-}
-
-QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebenginescript.h b/src/webengine/api/qquickwebenginescript.h
deleted file mode 100644
index d5c4310db..000000000
--- a/src/webengine/api/qquickwebenginescript.h
+++ /dev/null
@@ -1,114 +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$
-**
-****************************************************************************/
-
-#ifndef QQUICKWEBENGINESCRIPT_H
-#define QQUICKWEBENGINESCRIPT_H
-
-#include <QtCore/qobject.h>
-#include <QtCore/qurl.h>
-#include <QtWebEngine/qtwebengineglobal.h>
-
-QT_BEGIN_NAMESPACE
-class QQuickWebEngineScriptPrivate;
-class QQuickWebEngineView;
-
-class Q_WEBENGINE_EXPORT QQuickWebEngineScript : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged FINAL)
- Q_PROPERTY(QUrl sourceUrl READ sourceUrl WRITE setSourceUrl NOTIFY sourceUrlChanged FINAL)
- Q_PROPERTY(QString sourceCode READ sourceCode WRITE setSourceCode NOTIFY sourceCodeChanged FINAL)
- Q_PROPERTY(InjectionPoint injectionPoint READ injectionPoint WRITE setInjectionPoint NOTIFY injectionPointChanged FINAL)
- Q_PROPERTY(ScriptWorldId worldId READ worldId WRITE setWorldId NOTIFY worldIdChanged FINAL)
- Q_PROPERTY(bool runOnSubframes READ runOnSubframes WRITE setRunOnSubframes NOTIFY runOnSubframesChanged FINAL)
-
-
-public:
- enum InjectionPoint {
- Deferred,
- DocumentReady,
- DocumentCreation
- };
- Q_ENUM(InjectionPoint)
-
- enum ScriptWorldId {
- MainWorld = 0,
- ApplicationWorld,
- UserWorld
- };
- Q_ENUM(ScriptWorldId)
-
- explicit QQuickWebEngineScript(QObject *parent = Q_NULLPTR);
- ~QQuickWebEngineScript();
- Q_INVOKABLE QString toString() const;
-
- QString name() const;
- QUrl sourceUrl() const;
- QString sourceCode() const;
- InjectionPoint injectionPoint() const;
- ScriptWorldId worldId() const;
- bool runOnSubframes() const;
-
- Q_INVOKABLE void setName(const QString &name);
- Q_INVOKABLE void setSourceUrl(const QUrl &url);
- Q_INVOKABLE void setSourceCode(const QString &code);
- Q_INVOKABLE void setInjectionPoint(InjectionPoint injectionPoint);
- Q_INVOKABLE void setWorldId(ScriptWorldId scriptWorldId);
- Q_INVOKABLE void setRunOnSubframes(bool on);
-
-Q_SIGNALS:
- void nameChanged(const QString &name);
- void sourceUrlChanged(const QUrl &url);
- void sourceCodeChanged(const QString &code);
- void injectionPointChanged(InjectionPoint injectionPoint);
- void worldIdChanged(ScriptWorldId scriptWorldId);
- void runOnSubframesChanged(bool on);
-
-protected:
- void timerEvent(QTimerEvent *e) override;
-
-private:
- friend class QQuickWebEngineProfilePrivate;
- friend class QQuickWebEngineViewPrivate;
- Q_DECLARE_PRIVATE(QQuickWebEngineScript)
- QScopedPointer<QQuickWebEngineScriptPrivate> d_ptr;
-};
-QT_END_NAMESPACE
-
-#endif // QQUICKWEBENGINESCRIPT_H
diff --git a/src/webengine/api/qquickwebengineaction.cpp b/src/webenginequick/api/qquickwebengineaction.cpp
index 77ac8d340..77ac8d340 100644
--- a/src/webengine/api/qquickwebengineaction.cpp
+++ b/src/webenginequick/api/qquickwebengineaction.cpp
diff --git a/src/webengine/api/qquickwebengineaction_p.h b/src/webenginequick/api/qquickwebengineaction_p.h
index 8f5f3386c..8f5f3386c 100644
--- a/src/webengine/api/qquickwebengineaction_p.h
+++ b/src/webenginequick/api/qquickwebengineaction_p.h
diff --git a/src/webengine/api/qquickwebengineaction_p_p.h b/src/webenginequick/api/qquickwebengineaction_p_p.h
index d2ead30e9..d2ead30e9 100644
--- a/src/webengine/api/qquickwebengineaction_p_p.h
+++ b/src/webenginequick/api/qquickwebengineaction_p_p.h
diff --git a/src/webengine/api/qquickwebengineclientcertificateselection.cpp b/src/webenginequick/api/qquickwebengineclientcertificateselection.cpp
index c48a59887..4d8b38427 100644
--- a/src/webengine/api/qquickwebengineclientcertificateselection.cpp
+++ b/src/webenginequick/api/qquickwebengineclientcertificateselection.cpp
@@ -132,11 +132,12 @@ 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(
+qsizetype QQuickWebEngineClientCertificateSelection::certificates_count(
QQmlListProperty<QQuickWebEngineClientCertificateOption> *p)
{
Q_ASSERT(p && p->object);
@@ -145,7 +146,7 @@ int QQuickWebEngineClientCertificateSelection::certificates_count(
}
QQuickWebEngineClientCertificateOption *QQuickWebEngineClientCertificateSelection::certificates_at(
- QQmlListProperty<QQuickWebEngineClientCertificateOption> *p, int idx)
+ QQmlListProperty<QQuickWebEngineClientCertificateOption> *p, qsizetype idx)
{
Q_ASSERT(p && p->object);
QQuickWebEngineClientCertificateSelection *d = static_cast<QQuickWebEngineClientCertificateSelection *>(p->object);
@@ -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/webenginequick/api/qquickwebengineclientcertificateselection_p.h
index adf8b5f7c..a62150404 100644
--- a/src/webengine/api/qquickwebengineclientcertificateselection_p.h
+++ b/src/webenginequick/api/qquickwebengineclientcertificateselection_p.h
@@ -51,20 +51,23 @@
// We mean it.
//
-#include <QtWebEngine/private/qtwebengineglobal_p.h>
+#include <QtWebEngineQuick/private/qtwebengineglobal_p.h>
#include <QtCore/QDateTime>
#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 {
@@ -111,13 +114,14 @@ private:
friend class QQuickWebEngineViewPrivate;
friend class QQuickWebEngineClientCertificateOption;
- static int certificates_count(QQmlListProperty<QQuickWebEngineClientCertificateOption> *p);
- static QQuickWebEngineClientCertificateOption *certificates_at(QQmlListProperty<QQuickWebEngineClientCertificateOption> *p, int idx);
+ static qsizetype certificates_count(QQmlListProperty<QQuickWebEngineClientCertificateOption> *p);
+ static QQuickWebEngineClientCertificateOption *certificates_at(QQmlListProperty<QQuickWebEngineClientCertificateOption> *p, qsizetype 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/qquickwebenginedialogrequests.cpp b/src/webenginequick/api/qquickwebenginedialogrequests.cpp
index da1aecaf6..da1aecaf6 100644
--- a/src/webengine/api/qquickwebenginedialogrequests.cpp
+++ b/src/webenginequick/api/qquickwebenginedialogrequests.cpp
diff --git a/src/webengine/api/qquickwebenginedialogrequests_p.h b/src/webenginequick/api/qquickwebenginedialogrequests_p.h
index 5e3f7c547..f3b5997d0 100644
--- a/src/webengine/api/qquickwebenginedialogrequests_p.h
+++ b/src/webenginequick/api/qquickwebenginedialogrequests_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtWebEngine/private/qtwebengineglobal_p.h>
+#include <QtWebEngineQuick/private/qtwebengineglobal_p.h>
#include <QtCore/QUrl>
#include <QtCore/QWeakPointer>
#include <QtCore/QRect>
diff --git a/src/webengine/api/qquickwebenginefaviconprovider.cpp b/src/webenginequick/api/qquickwebenginefaviconprovider.cpp
index f817e4016..f817e4016 100644
--- a/src/webengine/api/qquickwebenginefaviconprovider.cpp
+++ b/src/webenginequick/api/qquickwebenginefaviconprovider.cpp
diff --git a/src/webengine/api/qquickwebenginefaviconprovider_p_p.h b/src/webenginequick/api/qquickwebenginefaviconprovider_p_p.h
index 4ccc4ba10..80d2f65f2 100644
--- a/src/webengine/api/qquickwebenginefaviconprovider_p_p.h
+++ b/src/webenginequick/api/qquickwebenginefaviconprovider_p_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtWebEngine/private/qtwebengineglobal_p.h>
+#include <QtWebEngineQuick/private/qtwebengineglobal_p.h>
#include <QtQuick/QQuickImageProvider>
#include <QtCore/QMap>
diff --git a/src/webengine/api/qquickwebenginehistory.cpp b/src/webenginequick/api/qquickwebenginehistory.cpp
index e77974a0f..50feb067c 100644
--- a/src/webengine/api/qquickwebenginehistory.cpp
+++ b/src/webenginequick/api/qquickwebenginehistory.cpp
@@ -41,7 +41,6 @@
#include "qquickwebenginehistory_p_p.h"
#include "qquickwebenginefaviconprovider_p_p.h"
-#include "qquickwebengineloadrequest_p.h"
#include "qquickwebengineview_p_p.h"
#include "web_contents_adapter.h"
diff --git a/src/webengine/api/qquickwebenginehistory_p.h b/src/webenginequick/api/qquickwebenginehistory_p.h
index db0be3bad..828109230 100644
--- a/src/webengine/api/qquickwebenginehistory_p.h
+++ b/src/webenginequick/api/qquickwebenginehistory_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtWebEngine/qtwebengineglobal.h>
+#include <QtWebEngineQuick/qtwebengineglobal.h>
#include <QAbstractListModel>
#include <QtCore/qshareddata.h>
#include <QQuickItem>
@@ -63,7 +63,6 @@ QT_BEGIN_NAMESPACE
class QQuickWebEngineHistory;
class QQuickWebEngineHistoryPrivate;
class QQuickWebEngineHistoryListModelPrivate;
-class QQuickWebEngineLoadRequest;
class QQuickWebEngineViewPrivate;
class Q_WEBENGINE_EXPORT QQuickWebEngineHistoryListModel : public QAbstractListModel {
diff --git a/src/webengine/api/qquickwebenginehistory_p_p.h b/src/webenginequick/api/qquickwebenginehistory_p_p.h
index 019c6f0ad..019c6f0ad 100644
--- a/src/webengine/api/qquickwebenginehistory_p_p.h
+++ b/src/webenginequick/api/qquickwebenginehistory_p_p.h
diff --git a/src/webengine/api/qquickwebenginenavigationrequest.cpp b/src/webenginequick/api/qquickwebenginenavigationrequest.cpp
index 03c1d3d78..03c1d3d78 100644
--- a/src/webengine/api/qquickwebenginenavigationrequest.cpp
+++ b/src/webenginequick/api/qquickwebenginenavigationrequest.cpp
diff --git a/src/webengine/api/qquickwebenginenavigationrequest_p.h b/src/webenginequick/api/qquickwebenginenavigationrequest_p.h
index 55e3ca673..55e3ca673 100644
--- a/src/webengine/api/qquickwebenginenavigationrequest_p.h
+++ b/src/webenginequick/api/qquickwebenginenavigationrequest_p.h
diff --git a/src/webengine/api/qquickwebenginenewviewrequest.cpp b/src/webenginequick/api/qquickwebenginenewviewrequest.cpp
index 78ae1622a..78ae1622a 100644
--- a/src/webengine/api/qquickwebenginenewviewrequest.cpp
+++ b/src/webenginequick/api/qquickwebenginenewviewrequest.cpp
diff --git a/src/webengine/api/qquickwebenginenewviewrequest_p.h b/src/webenginequick/api/qquickwebenginenewviewrequest_p.h
index d4686b291..e1e0e5abd 100644
--- a/src/webengine/api/qquickwebenginenewviewrequest_p.h
+++ b/src/webenginequick/api/qquickwebenginenewviewrequest_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtWebEngine/private/qtwebengineglobal_p.h>
+#include <QtWebEngineQuick/private/qtwebengineglobal_p.h>
#include "qquickwebengineview_p.h"
namespace QtWebEngineCore {
diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webenginequick/api/qquickwebengineprofile.cpp
index a5a0b4ccb..98ce9904e 100644
--- a/src/webengine/api/qquickwebengineprofile.cpp
+++ b/src/webenginequick/api/qquickwebengineprofile.cpp
@@ -39,34 +39,29 @@
#include "qquickwebengineprofile.h"
-#include "qquickwebenginedownloaditem_p.h"
-#include "qquickwebenginedownloaditem_p_p.h"
#include "qquickwebengineprofile_p.h"
-#include "qquickwebenginescript_p.h"
#include "qquickwebenginesettings_p.h"
+#include "qwebenginescriptcollection.h"
+#include "qwebenginescriptcollection_p.h"
+#include "qquickwebenginescriptcollection.h"
#include "qquickwebengineview_p_p.h"
#include "qwebenginecookiestore.h"
#include "qwebenginenotification.h"
-
#include <QFileInfo>
#include <QDir>
#include <QQmlEngine>
+#include <QtQml/QQmlInfo>
#include "profile_adapter.h"
-#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 +128,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 +141,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).
@@ -164,14 +159,15 @@ ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::MimeHtmlSaveFormat, QtWebEngineC
*/
QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(ProfileAdapter *profileAdapter)
- : m_settings(new QQuickWebEngineSettings())
- , m_profileAdapter(profileAdapter)
+ : m_settings(new QQuickWebEngineSettings())
+ , m_profileAdapter(profileAdapter)
+ , m_scriptCollection(new QQuickWebEngineScriptCollection(new QWebEngineScriptCollection(
+ new QWebEngineScriptCollectionPrivate(profileAdapter->userResourceController()))))
{
profileAdapter->addClient(this);
- m_settings->d_ptr->initDefaults();
// Fullscreen API was implemented before the supported setting, so we must
// make it default true to avoid change in default API behavior.
- m_settings->d_ptr->setAttribute(QtWebEngineCore::WebEngineSettings::FullScreenSupportEnabled, true);
+ m_settings->d_ptr->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true);
}
QQuickWebEngineProfilePrivate::~QQuickWebEngineProfilePrivate()
@@ -242,38 +238,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->m_adapterClient = info.page;
else
- itemPrivate->view = nullptr;
+ itemPrivate->m_adapterClient = 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 +283,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);
@@ -315,38 +311,6 @@ void QQuickWebEngineProfilePrivate::showNotification(QSharedPointer<QtWebEngineC
Q_EMIT q->presentNotification(notification);
}
-void QQuickWebEngineProfilePrivate::userScripts_append(QQmlListProperty<QQuickWebEngineScript> *p, QQuickWebEngineScript *script)
-{
- Q_ASSERT(p && p->data);
- QQuickWebEngineProfilePrivate *d = static_cast<QQuickWebEngineProfilePrivate *>(p->data);
- QtWebEngineCore::UserResourceControllerHost *resourceController = d->profileAdapter()->userResourceController();
- d->m_userScripts.append(script);
- script->d_func()->bind(resourceController);
-}
-
-int QQuickWebEngineProfilePrivate::userScripts_count(QQmlListProperty<QQuickWebEngineScript> *p)
-{
- Q_ASSERT(p && p->data);
- QQuickWebEngineProfilePrivate *d = static_cast<QQuickWebEngineProfilePrivate *>(p->data);
- return d->m_userScripts.count();
-}
-
-QQuickWebEngineScript *QQuickWebEngineProfilePrivate::userScripts_at(QQmlListProperty<QQuickWebEngineScript> *p, int idx)
-{
- Q_ASSERT(p && p->data);
- QQuickWebEngineProfilePrivate *d = static_cast<QQuickWebEngineProfilePrivate *>(p->data);
- return d->m_userScripts.at(idx);
-}
-
-void QQuickWebEngineProfilePrivate::userScripts_clear(QQmlListProperty<QQuickWebEngineScript> *p)
-{
- Q_ASSERT(p && p->data);
- QQuickWebEngineProfilePrivate *d = static_cast<QQuickWebEngineProfilePrivate *>(p->data);
- QtWebEngineCore::UserResourceControllerHost *resourceController = d->profileAdapter()->userResourceController();
- resourceController->clearAllScripts(NULL);
- d->m_userScripts.clear();
-}
-
/*!
\qmltype WebEngineProfile
\instantiates QQuickWebEngineProfile
@@ -970,31 +934,6 @@ void QQuickWebEngineProfile::clearHttpCache()
d->profileAdapter()->clearHttpCache();
}
-#if QT_DEPRECATED_SINCE(5, 13)
-/*!
- Registers a request interceptor singleton \a interceptor to intercept URL requests.
-
- The profile does not take ownership of the pointer.
-
- \obsolete
-
- Interceptors installed with this method will call
- QWebEngineUrlRequestInterceptor::interceptRequest on the I/O thread. Therefore
- the user has to provide thread-safe interaction with the other user classes.
- Use setUrlRequestInterceptor instead.
-
- \sa QWebEngineUrlRequestInterceptor
-
-*/
-void QQuickWebEngineProfile::setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor)
-{
- Q_D(QQuickWebEngineProfile);
- interceptor->setProperty("deprecated", true);
- d->profileAdapter()->setRequestInterceptor(interceptor);
- qWarning("Use of deprecated not tread-safe setter, use setUrlRequestInterceptor instead.");
-}
-#endif
-
/*!
Registers a request interceptor singleton \a interceptor to intercept URL requests.
@@ -1077,23 +1016,10 @@ QQuickWebEngineSettings *QQuickWebEngineProfile::settings() const
\sa WebEngineScript
*/
-/*!
- \property QQuickWebEngineProfile::userScripts
- \since 5.9
-
- \brief The collection of scripts that are injected into all pages that share
- this profile.
-
- \sa QQuickWebEngineScript, QQmlListReference
-*/
-QQmlListProperty<QQuickWebEngineScript> QQuickWebEngineProfile::userScripts()
+QQuickWebEngineScriptCollection *QQuickWebEngineProfile::userScripts() const
{
- Q_D(QQuickWebEngineProfile);
- return QQmlListProperty<QQuickWebEngineScript>(this, d,
- d->userScripts_append,
- d->userScripts_count,
- d->userScripts_at,
- d->userScripts_clear);
+ const Q_D(QQuickWebEngineProfile);
+ return d->m_scriptCollection.data();
}
/*!
@@ -1112,3 +1038,5 @@ QWebEngineClientCertificateStore *QQuickWebEngineProfile::clientCertificateStore
}
QT_END_NAMESPACE
+
+#include "moc_qquickwebengineprofile.cpp"
diff --git a/src/webengine/api/qquickwebengineprofile.h b/src/webenginequick/api/qquickwebengineprofile.h
index e5f7ff713..c3f2f7958 100644
--- a/src/webengine/api/qquickwebengineprofile.h
+++ b/src/webenginequick/api/qquickwebengineprofile.h
@@ -40,25 +40,23 @@
#ifndef QQUICKWEBENGINEPROFILE_H
#define QQUICKWEBENGINEPROFILE_H
-
-#include <QtWebEngine/qtwebengineglobal.h>
-
+#include <QtWebEngineQuick/qtwebengineglobal.h>
#include <QtCore/QObject>
#include <QtCore/QScopedPointer>
#include <QtCore/QString>
-#include <QtQml/QQmlListProperty>
QT_BEGIN_NAMESPACE
-class QQuickWebEngineDownloadItem;
-class QQuickWebEngineProfilePrivate;
-class QQuickWebEngineScript;
+class QWebEngineDownloadRequest;
+class QWebEngineScript;
class QQuickWebEngineSettings;
class QWebEngineClientCertificateStore;
class QWebEngineCookieStore;
class QWebEngineNotification;
class QWebEngineUrlRequestInterceptor;
class QWebEngineUrlSchemeHandler;
+class QQuickWebEngineScriptCollection;
+class QQuickWebEngineProfilePrivate;
class Q_WEBENGINE_EXPORT QQuickWebEngineProfile : public QObject {
Q_OBJECT
@@ -73,7 +71,7 @@ class Q_WEBENGINE_EXPORT QQuickWebEngineProfile : public QObject {
Q_PROPERTY(int httpCacheMaximumSize READ httpCacheMaximumSize WRITE setHttpCacheMaximumSize NOTIFY httpCacheMaximumSizeChanged FINAL)
Q_PROPERTY(QStringList spellCheckLanguages READ spellCheckLanguages WRITE setSpellCheckLanguages NOTIFY spellCheckLanguagesChanged FINAL REVISION 3)
Q_PROPERTY(bool spellCheckEnabled READ isSpellCheckEnabled WRITE setSpellCheckEnabled NOTIFY spellCheckEnabledChanged FINAL REVISION 3)
- Q_PROPERTY(QQmlListProperty<QQuickWebEngineScript> userScripts READ userScripts FINAL REVISION 4)
+ Q_PROPERTY(QQuickWebEngineScriptCollection *userScripts READ userScripts)
Q_PROPERTY(bool useForGlobalCertificateVerification
READ isUsedForGlobalCertificateVerification
WRITE setUseForGlobalCertificateVerification
@@ -128,9 +126,6 @@ public:
QWebEngineCookieStore *cookieStore() const;
-#if QT_DEPRECATED_SINCE(5, 13)
- void setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor);
-#endif
void setUrlRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor);
const QWebEngineUrlSchemeHandler *urlSchemeHandler(const QByteArray &) const;
@@ -146,7 +141,7 @@ public:
void setSpellCheckEnabled(bool enabled);
bool isSpellCheckEnabled() const;
- QQmlListProperty<QQuickWebEngineScript> userScripts();
+ QQuickWebEngineScriptCollection *userScripts() const;
void setUseForGlobalCertificateVerification(bool b);
bool isUsedForGlobalCertificateVerification() const;
@@ -172,9 +167,8 @@ Q_SIGNALS:
Q_REVISION(3) void spellCheckEnabledChanged();
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 +180,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/webenginequick/api/qquickwebengineprofile_p.h
index c6d412ab3..b9b52a693 100644
--- a/src/webengine/api/qquickwebengineprofile_p.h
+++ b/src/webenginequick/api/qquickwebengineprofile_p.h
@@ -62,9 +62,10 @@
QT_BEGIN_NAMESPACE
-class QQuickWebEngineDownloadItem;
+class QWebEngineDownloadRequest;
class QQuickWebEngineSettings;
class QQuickWebEngineViewPrivate;
+class QQuickWebEngineScriptCollection;
class QQuickWebEngineProfilePrivate : public QtWebEngineCore::ProfileAdapterClient {
public:
@@ -89,19 +90,13 @@ public:
void showNotification(QSharedPointer<QtWebEngineCore::UserNotificationController> &controller) override;
- // QQmlListPropertyHelpers
- static void userScripts_append(QQmlListProperty<QQuickWebEngineScript> *p, QQuickWebEngineScript *script);
- static int userScripts_count(QQmlListProperty<QQuickWebEngineScript> *p);
- static QQuickWebEngineScript *userScripts_at(QQmlListProperty<QQuickWebEngineScript> *p, int idx);
- static void userScripts_clear(QQmlListProperty<QQuickWebEngineScript> *p);
-
private:
friend class QQuickWebEngineView;
QQuickWebEngineProfile *q_ptr;
QScopedPointer<QQuickWebEngineSettings> m_settings;
QPointer<QtWebEngineCore::ProfileAdapter> m_profileAdapter;
- QMap<quint32, QPointer<QQuickWebEngineDownloadItem> > m_ongoingDownloads;
- QList<QQuickWebEngineScript *> m_userScripts;
+ QMap<quint32, QPointer<QWebEngineDownloadRequest> > m_ongoingDownloads;
+ QScopedPointer<QQuickWebEngineScriptCollection> m_scriptCollection;
};
QT_END_NAMESPACE
diff --git a/src/webenginequick/api/qquickwebenginescriptcollection.cpp b/src/webenginequick/api/qquickwebenginescriptcollection.cpp
new file mode 100644
index 000000000..c0939d72f
--- /dev/null
+++ b/src/webenginequick/api/qquickwebenginescriptcollection.cpp
@@ -0,0 +1,157 @@
+/****************************************************************************
+**
+** 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 "qquickwebenginescriptcollection.h"
+#include "qwebenginescriptcollection.h"
+#include "qwebenginescriptcollection_p.h"
+#include <QtQml/QQmlInfo>
+#include <QtQml/private/qqmlengine_p.h>
+#include <QtQml/private/qv4scopedvalue_p.h>
+#include <QtQml/private/qv4arrayobject_p.h>
+
+QWebEngineScript parseScript(const QJSValue &value, bool *ok)
+{
+ QWebEngineScript s;
+ if (ok)
+ *ok = false;
+
+ if (value.isObject()) {
+
+ if (value.hasProperty(QStringLiteral("name")))
+ s.setName(value.property(QStringLiteral("name")).toString());
+
+ if (value.hasProperty(QStringLiteral("sourceUrl")))
+ s.setSourceUrl(value.property(QStringLiteral("sourceUrl")).toString());
+
+ if (value.hasProperty(QStringLiteral("injectionPoint")))
+ s.setInjectionPoint(QWebEngineScript::InjectionPoint(
+ value.property(QStringLiteral("injectionPoint")).toUInt()));
+
+ if (value.hasProperty(QStringLiteral("sourceCode")))
+ s.setSourceCode(value.property(QStringLiteral("sourceCode")).toString());
+
+ if (value.hasProperty(QStringLiteral("worldId")))
+ s.setWorldId(QWebEngineScript::ScriptWorldId(
+ value.property(QStringLiteral("worldId")).toUInt()));
+
+ if (value.hasProperty(QStringLiteral("runOnSubframes")))
+ s.setRunsOnSubFrames(value.property(QStringLiteral("runOnSubframes")).toBool());
+
+ if (ok)
+ *ok = true;
+ }
+ return s;
+}
+
+QQuickWebEngineScriptCollection::QQuickWebEngineScriptCollection(
+ QWebEngineScriptCollection *collection)
+ : d(collection)
+{
+}
+
+QQuickWebEngineScriptCollection::~QQuickWebEngineScriptCollection() { }
+
+bool QQuickWebEngineScriptCollection::contains(const QWebEngineScript &value) const
+{
+ return d->contains(value);
+}
+
+QList<QWebEngineScript> QQuickWebEngineScriptCollection::find(const QString &name) const
+{
+ return d->find(name);
+}
+
+void QQuickWebEngineScriptCollection::insert(const QWebEngineScript &s)
+{
+ d->insert(s);
+}
+
+void QQuickWebEngineScriptCollection::insert(const QList<QWebEngineScript> &list)
+{
+ d->insert(list);
+}
+
+bool QQuickWebEngineScriptCollection::remove(const QWebEngineScript &script)
+{
+ return d->remove(script);
+}
+
+void QQuickWebEngineScriptCollection::clear()
+{
+ d->clear();
+}
+
+QJSValue QQuickWebEngineScriptCollection::collection() const
+{
+ const QList<QWebEngineScript> &list = d->toList();
+ QQmlContext *context = QQmlEngine::contextForObject(this);
+ QQmlEngine *engine = context->engine();
+ QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(engine);
+ QV4::Scope scope(v4);
+ QV4::Scoped<QV4::ArrayObject> scriptArray(scope, v4->newArrayObject(list.length()));
+ int i = 0;
+ for (const auto &val : list) {
+ QV4::ScopedValue sv(scope, v4->fromVariant(QVariant::fromValue(val)));
+ scriptArray->put(i++, sv);
+ }
+ return QJSValuePrivate::fromReturnedValue(scriptArray.asReturnedValue());
+}
+
+void QQuickWebEngineScriptCollection::setCollection(const QJSValue &scripts)
+{
+ if (!scripts.isArray())
+ return;
+
+ QList<QWebEngineScript> scriptList;
+ quint32 length = scripts.property(QStringLiteral("length")).toUInt();
+ for (quint32 i = 0; i < length; ++i) {
+ bool ok;
+ QWebEngineScript s = parseScript(scripts.property(i), &ok);
+ if (!ok) {
+ qmlWarning(this) << "Unsupported script type";
+ return;
+ }
+ scriptList.append(s);
+ }
+ if (scriptList != d->toList()) {
+ clear();
+ insert(scriptList);
+ Q_EMIT collectionChanged();
+ }
+}
diff --git a/src/webenginequick/api/qquickwebenginescriptcollection.h b/src/webenginequick/api/qquickwebenginescriptcollection.h
new file mode 100644
index 000000000..e125fee96
--- /dev/null
+++ b/src/webenginequick/api/qquickwebenginescriptcollection.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#ifndef QQUICKWEBENGINESCRIPTCOLLECTION_H
+#define QQUICKWEBENGINESCRIPTCOLLECTION_H
+
+#include <QtWebEngineQuick/qtwebengineglobal.h>
+#include <QtWebEngineCore/qwebenginescript.h>
+#include <QtCore/qscopedpointer.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qset.h>
+#include <QtCore/QObject>
+#include <QtQml/QJSValue>
+
+QT_BEGIN_NAMESPACE
+class QWebEngineScriptCollection;
+
+class Q_WEBENGINE_EXPORT QQuickWebEngineScriptCollection : public QObject
+{
+ Q_OBJECT
+public:
+ Q_PROPERTY(QJSValue collection READ collection WRITE setCollection NOTIFY collectionChanged)
+ ~QQuickWebEngineScriptCollection();
+
+ Q_INVOKABLE bool contains(const QWebEngineScript &value) const;
+ Q_INVOKABLE QList<QWebEngineScript> find(const QString &name) const;
+ Q_INVOKABLE void insert(const QWebEngineScript &);
+ Q_INVOKABLE void insert(const QList<QWebEngineScript> &list);
+ Q_INVOKABLE bool remove(const QWebEngineScript &);
+ Q_INVOKABLE void clear();
+
+ QJSValue collection() const;
+ void setCollection(const QJSValue &scripts);
+
+Q_SIGNALS:
+ void collectionChanged();
+
+private:
+ Q_DISABLE_COPY(QQuickWebEngineScriptCollection)
+ QQuickWebEngineScriptCollection(QWebEngineScriptCollection *d);
+ QScopedPointer<QWebEngineScriptCollection> d;
+ friend class QQuickWebEngineProfilePrivate;
+ friend class QQuickWebEngineViewPrivate;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QQuickWebEngineScriptCollection *)
+
+#endif // QWEBENGINESCRIPTCOLLECTION_H
diff --git a/src/webengine/api/qquickwebenginesettings.cpp b/src/webenginequick/api/qquickwebenginesettings.cpp
index 78fbe16e8..f1fd00b8d 100644
--- a/src/webengine/api/qquickwebenginesettings.cpp
+++ b/src/webenginequick/api/qquickwebenginesettings.cpp
@@ -41,7 +41,7 @@
#include "web_engine_settings.h"
-#include <QtWebEngine/QQuickWebEngineProfile>
+#include <QtWebEngineQuick/QQuickWebEngineProfile>
#include <QtCore/QList>
QT_BEGIN_NAMESPACE
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
using QtWebEngineCore::WebEngineSettings;
QQuickWebEngineSettings::QQuickWebEngineSettings(QQuickWebEngineSettings *parentSettings)
- : d_ptr(new WebEngineSettings(parentSettings ? parentSettings->d_ptr.data() : 0))
+ : d_ptr(new QWebEngineSettings(parentSettings ? parentSettings->d_ptr.data() : nullptr))
{ }
/*!
@@ -97,7 +97,7 @@ QQuickWebEngineSettings::~QQuickWebEngineSettings()
*/
bool QQuickWebEngineSettings::autoLoadImages() const
{
- return d_ptr->testAttribute(WebEngineSettings::AutoLoadImages);
+ return d_ptr->testAttribute(QWebEngineSettings::AutoLoadImages);
}
/*!
@@ -109,7 +109,7 @@ bool QQuickWebEngineSettings::autoLoadImages() const
*/
bool QQuickWebEngineSettings::javascriptEnabled() const
{
- return d_ptr->testAttribute(WebEngineSettings::JavascriptEnabled);
+ return d_ptr->testAttribute(QWebEngineSettings::JavascriptEnabled);
}
/*!
@@ -121,7 +121,7 @@ bool QQuickWebEngineSettings::javascriptEnabled() const
*/
bool QQuickWebEngineSettings::javascriptCanOpenWindows() const
{
- return d_ptr->testAttribute(WebEngineSettings::JavascriptCanOpenWindows);
+ return d_ptr->testAttribute(QWebEngineSettings::JavascriptCanOpenWindows);
}
/*!
@@ -137,7 +137,7 @@ bool QQuickWebEngineSettings::javascriptCanOpenWindows() const
*/
bool QQuickWebEngineSettings::javascriptCanAccessClipboard() const
{
- return d_ptr->testAttribute(WebEngineSettings::JavascriptCanAccessClipboard);
+ return d_ptr->testAttribute(QWebEngineSettings::JavascriptCanAccessClipboard);
}
/*!
@@ -149,7 +149,7 @@ bool QQuickWebEngineSettings::javascriptCanAccessClipboard() const
*/
bool QQuickWebEngineSettings::linksIncludedInFocusChain() const
{
- return d_ptr->testAttribute(WebEngineSettings::LinksIncludedInFocusChain);
+ return d_ptr->testAttribute(QWebEngineSettings::LinksIncludedInFocusChain);
}
/*!
@@ -161,7 +161,7 @@ bool QQuickWebEngineSettings::linksIncludedInFocusChain() const
*/
bool QQuickWebEngineSettings::localStorageEnabled() const
{
- return d_ptr->testAttribute(WebEngineSettings::LocalStorageEnabled);
+ return d_ptr->testAttribute(QWebEngineSettings::LocalStorageEnabled);
}
/*!
@@ -173,7 +173,7 @@ bool QQuickWebEngineSettings::localStorageEnabled() const
*/
bool QQuickWebEngineSettings::localContentCanAccessRemoteUrls() const
{
- return d_ptr->testAttribute(WebEngineSettings::LocalContentCanAccessRemoteUrls);
+ return d_ptr->testAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls);
}
/*!
@@ -191,7 +191,7 @@ bool QQuickWebEngineSettings::localContentCanAccessRemoteUrls() const
*/
bool QQuickWebEngineSettings::spatialNavigationEnabled() const
{
- return d_ptr->testAttribute(WebEngineSettings::SpatialNavigationEnabled);
+ return d_ptr->testAttribute(QWebEngineSettings::SpatialNavigationEnabled);
}
/*!
@@ -203,7 +203,7 @@ bool QQuickWebEngineSettings::spatialNavigationEnabled() const
*/
bool QQuickWebEngineSettings::localContentCanAccessFileUrls() const
{
- return d_ptr->testAttribute(WebEngineSettings::LocalContentCanAccessFileUrls);
+ return d_ptr->testAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls);
}
/*!
@@ -215,7 +215,7 @@ bool QQuickWebEngineSettings::localContentCanAccessFileUrls() const
*/
bool QQuickWebEngineSettings::hyperlinkAuditingEnabled() const
{
- return d_ptr->testAttribute(WebEngineSettings::HyperlinkAuditingEnabled);
+ return d_ptr->testAttribute(QWebEngineSettings::HyperlinkAuditingEnabled);
}
/*!
@@ -227,7 +227,7 @@ bool QQuickWebEngineSettings::hyperlinkAuditingEnabled() const
*/
bool QQuickWebEngineSettings::errorPageEnabled() const
{
- return d_ptr->testAttribute(WebEngineSettings::ErrorPageEnabled);
+ return d_ptr->testAttribute(QWebEngineSettings::ErrorPageEnabled);
}
/*!
@@ -241,7 +241,7 @@ bool QQuickWebEngineSettings::errorPageEnabled() const
*/
bool QQuickWebEngineSettings::pluginsEnabled() const
{
- return d_ptr->testAttribute(WebEngineSettings::PluginsEnabled);
+ return d_ptr->testAttribute(QWebEngineSettings::PluginsEnabled);
}
/*!
@@ -254,7 +254,7 @@ bool QQuickWebEngineSettings::pluginsEnabled() const
*/
bool QQuickWebEngineSettings::fullScreenSupportEnabled() const
{
- return d_ptr->testAttribute(WebEngineSettings::FullScreenSupportEnabled);
+ return d_ptr->testAttribute(QWebEngineSettings::FullScreenSupportEnabled);
}
/*!
@@ -267,7 +267,7 @@ bool QQuickWebEngineSettings::fullScreenSupportEnabled() const
*/
bool QQuickWebEngineSettings::screenCaptureEnabled() const
{
- return d_ptr->testAttribute(WebEngineSettings::ScreenCaptureEnabled);
+ return d_ptr->testAttribute(QWebEngineSettings::ScreenCaptureEnabled);
}
/*!
@@ -280,7 +280,7 @@ bool QQuickWebEngineSettings::screenCaptureEnabled() const
*/
bool QQuickWebEngineSettings::webGLEnabled() const
{
- return d_ptr->testAttribute(WebEngineSettings::WebGLEnabled);
+ return d_ptr->testAttribute(QWebEngineSettings::WebGLEnabled);
}
/*!
@@ -294,7 +294,7 @@ bool QQuickWebEngineSettings::webGLEnabled() const
*/
bool QQuickWebEngineSettings::accelerated2dCanvasEnabled() const
{
- return d_ptr->testAttribute(WebEngineSettings::Accelerated2dCanvasEnabled);
+ return d_ptr->testAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled);
}
/*!
@@ -307,7 +307,7 @@ bool QQuickWebEngineSettings::accelerated2dCanvasEnabled() const
*/
bool QQuickWebEngineSettings::autoLoadIconsForPage() const
{
- return d_ptr->testAttribute(WebEngineSettings::AutoLoadIconsForPage);
+ return d_ptr->testAttribute(QWebEngineSettings::AutoLoadIconsForPage);
}
/*!
@@ -320,7 +320,7 @@ bool QQuickWebEngineSettings::autoLoadIconsForPage() const
*/
bool QQuickWebEngineSettings::touchIconsEnabled() const
{
- return d_ptr->testAttribute(WebEngineSettings::TouchIconsEnabled);
+ return d_ptr->testAttribute(QWebEngineSettings::TouchIconsEnabled);
}
/*!
@@ -334,7 +334,7 @@ bool QQuickWebEngineSettings::touchIconsEnabled() const
*/
bool QQuickWebEngineSettings::focusOnNavigationEnabled() const
{
- return d_ptr->testAttribute(WebEngineSettings::FocusOnNavigationEnabled);
+ return d_ptr->testAttribute(QWebEngineSettings::FocusOnNavigationEnabled);
}
/*!
@@ -347,7 +347,7 @@ bool QQuickWebEngineSettings::focusOnNavigationEnabled() const
*/
bool QQuickWebEngineSettings::printElementBackgrounds() const
{
- return d_ptr->testAttribute(WebEngineSettings::PrintElementBackgrounds);
+ return d_ptr->testAttribute(QWebEngineSettings::PrintElementBackgrounds);
}
/*!
@@ -362,7 +362,7 @@ bool QQuickWebEngineSettings::printElementBackgrounds() const
*/
bool QQuickWebEngineSettings::allowRunningInsecureContent() const
{
- return d_ptr->testAttribute(WebEngineSettings::AllowRunningInsecureContent);
+ return d_ptr->testAttribute(QWebEngineSettings::AllowRunningInsecureContent);
}
/*!
@@ -377,7 +377,7 @@ bool QQuickWebEngineSettings::allowRunningInsecureContent() const
*/
bool QQuickWebEngineSettings::allowGeolocationOnInsecureOrigins() const
{
- return d_ptr->testAttribute(WebEngineSettings::AllowGeolocationOnInsecureOrigins);
+ return d_ptr->testAttribute(QWebEngineSettings::AllowGeolocationOnInsecureOrigins);
}
/*!
@@ -387,7 +387,7 @@ bool QQuickWebEngineSettings::allowGeolocationOnInsecureOrigins() const
*/
bool QQuickWebEngineSettings::allowWindowActivationFromJavaScript() const
{
- return d_ptr->testAttribute(WebEngineSettings::AllowWindowActivationFromJavaScript);
+ return d_ptr->testAttribute(QWebEngineSettings::AllowWindowActivationFromJavaScript);
}
/*!
@@ -397,7 +397,7 @@ bool QQuickWebEngineSettings::allowWindowActivationFromJavaScript() const
*/
bool QQuickWebEngineSettings::showScrollBars() const
{
- return d_ptr->testAttribute(WebEngineSettings::ShowScrollBars);
+ return d_ptr->testAttribute(QWebEngineSettings::ShowScrollBars);
}
/*!
@@ -415,7 +415,7 @@ bool QQuickWebEngineSettings::showScrollBars() const
*/
bool QQuickWebEngineSettings::playbackRequiresUserGesture() const
{
- return d_ptr->testAttribute(WebEngineSettings::PlaybackRequiresUserGesture);
+ return d_ptr->testAttribute(QWebEngineSettings::PlaybackRequiresUserGesture);
}
/*!
@@ -429,7 +429,7 @@ bool QQuickWebEngineSettings::playbackRequiresUserGesture() const
*/
bool QQuickWebEngineSettings::webRTCPublicInterfacesOnly() const
{
- return d_ptr->testAttribute(WebEngineSettings::WebRTCPublicInterfacesOnly);
+ return d_ptr->testAttribute(QWebEngineSettings::WebRTCPublicInterfacesOnly);
}
/*!
@@ -443,7 +443,7 @@ bool QQuickWebEngineSettings::webRTCPublicInterfacesOnly() const
*/
bool QQuickWebEngineSettings::javascriptCanPaste() const
{
- return d_ptr->testAttribute(WebEngineSettings::JavascriptCanPaste);
+ return d_ptr->testAttribute(QWebEngineSettings::JavascriptCanPaste);
}
/*!
@@ -457,7 +457,7 @@ bool QQuickWebEngineSettings::javascriptCanPaste() const
*/
bool QQuickWebEngineSettings::dnsPrefetchEnabled() const
{
- return d_ptr->testAttribute(WebEngineSettings::DnsPrefetchEnabled);
+ return d_ptr->testAttribute(QWebEngineSettings::DnsPrefetchEnabled);
}
/*!
@@ -471,7 +471,7 @@ bool QQuickWebEngineSettings::dnsPrefetchEnabled() const
*/
bool QQuickWebEngineSettings::pdfViewerEnabled() const
{
- return d_ptr->testAttribute(WebEngineSettings::PdfViewerEnabled);
+ return d_ptr->testAttribute(QWebEngineSettings::PdfViewerEnabled);
}
/*!
@@ -488,12 +488,12 @@ QString QQuickWebEngineSettings::defaultTextEncoding() const
return d_ptr->defaultTextEncoding();
}
-ASSERT_ENUMS_MATCH(QQuickWebEngineSettings::DisallowUnknownUrlSchemes, WebEngineSettings::DisallowUnknownUrlSchemes)
-ASSERT_ENUMS_MATCH(QQuickWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction, WebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction)
-ASSERT_ENUMS_MATCH(QQuickWebEngineSettings::AllowAllUnknownUrlSchemes, WebEngineSettings::AllowAllUnknownUrlSchemes)
+ASSERT_ENUMS_MATCH(QQuickWebEngineSettings::DisallowUnknownUrlSchemes, QWebEngineSettings::DisallowUnknownUrlSchemes)
+ASSERT_ENUMS_MATCH(QQuickWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction, QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction)
+ASSERT_ENUMS_MATCH(QQuickWebEngineSettings::AllowAllUnknownUrlSchemes, QWebEngineSettings::AllowAllUnknownUrlSchemes)
/*!
- \qmlproperty WebEngineSettings::UnknownUrlSchemePolicy WebEngineSettings::unknownUrlSchemePolicy
+ \qmlproperty QWebEngineSettings::UnknownUrlSchemePolicy WebEngineSettings::unknownUrlSchemePolicy
\since QtWebEngine 1.7
Specifies how navigation requests to URLs with unknown schemes are handled.
@@ -506,58 +506,58 @@ QQuickWebEngineSettings::UnknownUrlSchemePolicy QQuickWebEngineSettings::unknown
void QQuickWebEngineSettings::setAutoLoadImages(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::AutoLoadImages);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::AutoLoadImages);
// Set unconditionally as it sets the override for the current settings while the current setting
// could be from the fallback and is prone to changing later on.
- d_ptr->setAttribute(WebEngineSettings::AutoLoadImages, on);
+ d_ptr->setAttribute(QWebEngineSettings::AutoLoadImages, on);
if (wasOn != on)
Q_EMIT autoLoadImagesChanged();
}
void QQuickWebEngineSettings::setJavascriptEnabled(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::JavascriptEnabled);
- d_ptr->setAttribute(WebEngineSettings::JavascriptEnabled, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::JavascriptEnabled);
+ d_ptr->setAttribute(QWebEngineSettings::JavascriptEnabled, on);
if (wasOn != on)
Q_EMIT javascriptEnabledChanged();
}
void QQuickWebEngineSettings::setJavascriptCanOpenWindows(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::JavascriptCanOpenWindows);
- d_ptr->setAttribute(WebEngineSettings::JavascriptCanOpenWindows, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::JavascriptCanOpenWindows);
+ d_ptr->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, on);
if (wasOn != on)
Q_EMIT javascriptCanOpenWindowsChanged();
}
void QQuickWebEngineSettings::setJavascriptCanAccessClipboard(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::JavascriptCanAccessClipboard);
- d_ptr->setAttribute(WebEngineSettings::JavascriptCanAccessClipboard, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::JavascriptCanAccessClipboard);
+ d_ptr->setAttribute(QWebEngineSettings::JavascriptCanAccessClipboard, on);
if (wasOn != on)
Q_EMIT javascriptCanAccessClipboardChanged();
}
void QQuickWebEngineSettings::setLinksIncludedInFocusChain(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::LinksIncludedInFocusChain);
- d_ptr->setAttribute(WebEngineSettings::LinksIncludedInFocusChain, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::LinksIncludedInFocusChain);
+ d_ptr->setAttribute(QWebEngineSettings::LinksIncludedInFocusChain, on);
if (wasOn != on)
Q_EMIT linksIncludedInFocusChainChanged();
}
void QQuickWebEngineSettings::setLocalStorageEnabled(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::LocalStorageEnabled);
- d_ptr->setAttribute(WebEngineSettings::LocalStorageEnabled, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::LocalStorageEnabled);
+ d_ptr->setAttribute(QWebEngineSettings::LocalStorageEnabled, on);
if (wasOn != on)
Q_EMIT localStorageEnabledChanged();
}
void QQuickWebEngineSettings::setLocalContentCanAccessRemoteUrls(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::LocalContentCanAccessRemoteUrls);
- d_ptr->setAttribute(WebEngineSettings::LocalContentCanAccessRemoteUrls, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls);
+ d_ptr->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, on);
if (wasOn != on)
Q_EMIT localContentCanAccessRemoteUrlsChanged();
}
@@ -565,96 +565,96 @@ void QQuickWebEngineSettings::setLocalContentCanAccessRemoteUrls(bool on)
void QQuickWebEngineSettings::setSpatialNavigationEnabled(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::SpatialNavigationEnabled);
- d_ptr->setAttribute(WebEngineSettings::SpatialNavigationEnabled, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::SpatialNavigationEnabled);
+ d_ptr->setAttribute(QWebEngineSettings::SpatialNavigationEnabled, on);
if (wasOn != on)
Q_EMIT spatialNavigationEnabledChanged();
}
void QQuickWebEngineSettings::setLocalContentCanAccessFileUrls(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::LocalContentCanAccessFileUrls);
- d_ptr->setAttribute(WebEngineSettings::LocalContentCanAccessFileUrls, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls);
+ d_ptr->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, on);
if (wasOn != on)
Q_EMIT localContentCanAccessFileUrlsChanged();
}
void QQuickWebEngineSettings::setHyperlinkAuditingEnabled(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::HyperlinkAuditingEnabled);
- d_ptr->setAttribute(WebEngineSettings::HyperlinkAuditingEnabled, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::HyperlinkAuditingEnabled);
+ d_ptr->setAttribute(QWebEngineSettings::HyperlinkAuditingEnabled, on);
if (wasOn != on)
Q_EMIT hyperlinkAuditingEnabledChanged();
}
void QQuickWebEngineSettings::setErrorPageEnabled(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::ErrorPageEnabled);
- d_ptr->setAttribute(WebEngineSettings::ErrorPageEnabled, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::ErrorPageEnabled);
+ d_ptr->setAttribute(QWebEngineSettings::ErrorPageEnabled, on);
if (wasOn != on)
Q_EMIT errorPageEnabledChanged();
}
void QQuickWebEngineSettings::setPluginsEnabled(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::PluginsEnabled);
- d_ptr->setAttribute(WebEngineSettings::PluginsEnabled, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::PluginsEnabled);
+ d_ptr->setAttribute(QWebEngineSettings::PluginsEnabled, on);
if (wasOn != on)
Q_EMIT pluginsEnabledChanged();
}
void QQuickWebEngineSettings::setFullScreenSupportEnabled(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::FullScreenSupportEnabled);
- d_ptr->setAttribute(WebEngineSettings::FullScreenSupportEnabled, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::FullScreenSupportEnabled);
+ d_ptr->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, on);
if (wasOn != on)
Q_EMIT fullScreenSupportEnabledChanged();
}
void QQuickWebEngineSettings::setScreenCaptureEnabled(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::ScreenCaptureEnabled);
- d_ptr->setAttribute(WebEngineSettings::ScreenCaptureEnabled, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::ScreenCaptureEnabled);
+ d_ptr->setAttribute(QWebEngineSettings::ScreenCaptureEnabled, on);
if (wasOn != on)
Q_EMIT screenCaptureEnabledChanged();
}
void QQuickWebEngineSettings::setWebGLEnabled(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::WebGLEnabled);
- d_ptr->setAttribute(WebEngineSettings::WebGLEnabled, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::WebGLEnabled);
+ d_ptr->setAttribute(QWebEngineSettings::WebGLEnabled, on);
if (wasOn != on)
Q_EMIT webGLEnabledChanged();
}
void QQuickWebEngineSettings::setAccelerated2dCanvasEnabled(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::Accelerated2dCanvasEnabled);
- d_ptr->setAttribute(WebEngineSettings::Accelerated2dCanvasEnabled, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled);
+ d_ptr->setAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled, on);
if (wasOn != on)
Q_EMIT accelerated2dCanvasEnabledChanged();
}
void QQuickWebEngineSettings::setAutoLoadIconsForPage(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::AutoLoadIconsForPage);
- d_ptr->setAttribute(WebEngineSettings::AutoLoadIconsForPage, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::AutoLoadIconsForPage);
+ d_ptr->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, on);
if (wasOn != on)
Q_EMIT autoLoadIconsForPageChanged();
}
void QQuickWebEngineSettings::setTouchIconsEnabled(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::TouchIconsEnabled);
- d_ptr->setAttribute(WebEngineSettings::TouchIconsEnabled, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::TouchIconsEnabled);
+ d_ptr->setAttribute(QWebEngineSettings::TouchIconsEnabled, on);
if (wasOn != on)
Q_EMIT touchIconsEnabledChanged();
}
void QQuickWebEngineSettings::setPrintElementBackgrounds(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::PrintElementBackgrounds);
- d_ptr->setAttribute(WebEngineSettings::PrintElementBackgrounds, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::PrintElementBackgrounds);
+ d_ptr->setAttribute(QWebEngineSettings::PrintElementBackgrounds, on);
if (wasOn != on)
Q_EMIT printElementBackgroundsChanged();
}
@@ -669,8 +669,8 @@ void QQuickWebEngineSettings::setDefaultTextEncoding(QString encoding)
void QQuickWebEngineSettings::setFocusOnNavigationEnabled(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::FocusOnNavigationEnabled);
- d_ptr->setAttribute(WebEngineSettings::FocusOnNavigationEnabled, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::FocusOnNavigationEnabled);
+ d_ptr->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, on);
if (wasOn != on)
Q_EMIT focusOnNavigationEnabledChanged();
}
@@ -678,72 +678,72 @@ void QQuickWebEngineSettings::setFocusOnNavigationEnabled(bool on)
void QQuickWebEngineSettings::setAllowRunningInsecureContent(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::AllowRunningInsecureContent);
- d_ptr->setAttribute(WebEngineSettings::AllowRunningInsecureContent, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::AllowRunningInsecureContent);
+ d_ptr->setAttribute(QWebEngineSettings::AllowRunningInsecureContent, on);
if (wasOn != on)
Q_EMIT allowRunningInsecureContentChanged();
}
void QQuickWebEngineSettings::setAllowGeolocationOnInsecureOrigins(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::AllowGeolocationOnInsecureOrigins);
- d_ptr->setAttribute(WebEngineSettings::AllowGeolocationOnInsecureOrigins, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::AllowGeolocationOnInsecureOrigins);
+ d_ptr->setAttribute(QWebEngineSettings::AllowGeolocationOnInsecureOrigins, on);
if (wasOn != on)
Q_EMIT allowGeolocationOnInsecureOriginsChanged();
}
void QQuickWebEngineSettings::setAllowWindowActivationFromJavaScript(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::AllowWindowActivationFromJavaScript);
- d_ptr->setAttribute(WebEngineSettings::AllowWindowActivationFromJavaScript, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::AllowWindowActivationFromJavaScript);
+ d_ptr->setAttribute(QWebEngineSettings::AllowWindowActivationFromJavaScript, on);
if (wasOn != on)
Q_EMIT allowWindowActivationFromJavaScriptChanged();
}
void QQuickWebEngineSettings::setShowScrollBars(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::ShowScrollBars);
- d_ptr->setAttribute(WebEngineSettings::ShowScrollBars, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::ShowScrollBars);
+ d_ptr->setAttribute(QWebEngineSettings::ShowScrollBars, on);
if (wasOn != on)
Q_EMIT showScrollBarsChanged();
}
void QQuickWebEngineSettings::setPlaybackRequiresUserGesture(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::PlaybackRequiresUserGesture);
- d_ptr->setAttribute(WebEngineSettings::PlaybackRequiresUserGesture, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::PlaybackRequiresUserGesture);
+ d_ptr->setAttribute(QWebEngineSettings::PlaybackRequiresUserGesture, on);
if (wasOn != on)
Q_EMIT playbackRequiresUserGestureChanged();
}
void QQuickWebEngineSettings::setJavascriptCanPaste(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::JavascriptCanPaste);
- d_ptr->setAttribute(WebEngineSettings::JavascriptCanPaste, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::JavascriptCanPaste);
+ d_ptr->setAttribute(QWebEngineSettings::JavascriptCanPaste, on);
if (wasOn != on)
Q_EMIT javascriptCanPasteChanged();
}
void QQuickWebEngineSettings::setDnsPrefetchEnabled(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::DnsPrefetchEnabled);
- d_ptr->setAttribute(WebEngineSettings::DnsPrefetchEnabled, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::DnsPrefetchEnabled);
+ d_ptr->setAttribute(QWebEngineSettings::DnsPrefetchEnabled, on);
if (wasOn != on)
Q_EMIT dnsPrefetchEnabledChanged();
}
void QQuickWebEngineSettings::setPdfViewerEnabled(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::PdfViewerEnabled);
- d_ptr->setAttribute(WebEngineSettings::PdfViewerEnabled, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::PdfViewerEnabled);
+ d_ptr->setAttribute(QWebEngineSettings::PdfViewerEnabled, on);
if (wasOn != on)
Q_EMIT pdfViewerEnabledChanged();
}
void QQuickWebEngineSettings::setUnknownUrlSchemePolicy(QQuickWebEngineSettings::UnknownUrlSchemePolicy policy)
{
- WebEngineSettings::UnknownUrlSchemePolicy oldPolicy = d_ptr->unknownUrlSchemePolicy();
- WebEngineSettings::UnknownUrlSchemePolicy newPolicy = static_cast<WebEngineSettings::UnknownUrlSchemePolicy>(policy);
+ QWebEngineSettings::UnknownUrlSchemePolicy oldPolicy = d_ptr->unknownUrlSchemePolicy();
+ QWebEngineSettings::UnknownUrlSchemePolicy newPolicy = static_cast<QWebEngineSettings::UnknownUrlSchemePolicy>(policy);
d_ptr->setUnknownUrlSchemePolicy(newPolicy);
if (oldPolicy != newPolicy)
Q_EMIT unknownUrlSchemePolicyChanged();
@@ -751,8 +751,8 @@ void QQuickWebEngineSettings::setUnknownUrlSchemePolicy(QQuickWebEngineSettings:
void QQuickWebEngineSettings::setWebRTCPublicInterfacesOnly(bool on)
{
- bool wasOn = d_ptr->testAttribute(WebEngineSettings::WebRTCPublicInterfacesOnly);
- d_ptr->setAttribute(WebEngineSettings::WebRTCPublicInterfacesOnly, on);
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::WebRTCPublicInterfacesOnly);
+ d_ptr->setAttribute(QWebEngineSettings::WebRTCPublicInterfacesOnly, on);
if (wasOn != on)
Q_EMIT webRTCPublicInterfacesOnlyChanged();
}
@@ -760,7 +760,6 @@ void QQuickWebEngineSettings::setWebRTCPublicInterfacesOnly(bool on)
void QQuickWebEngineSettings::setParentSettings(QQuickWebEngineSettings *parentSettings)
{
d_ptr->setParentSettings(parentSettings->d_ptr.data());
- d_ptr->scheduleApplyRecursively();
}
QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebenginesettings_p.h b/src/webenginequick/api/qquickwebenginesettings_p.h
index ce43e0e9c..8b275235a 100644
--- a/src/webengine/api/qquickwebenginesettings_p.h
+++ b/src/webenginequick/api/qquickwebenginesettings_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtWebEngine/private/qtwebengineglobal_p.h>
+#include <QtWebEngineQuick/private/qtwebengineglobal_p.h>
#include <QObject>
#include <QScopedPointer>
@@ -61,6 +61,7 @@ class WebEngineSettings;
QT_BEGIN_NAMESPACE
+class QWebEngineSettings;
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineSettings : public QObject {
Q_OBJECT
Q_PROPERTY(bool autoLoadImages READ autoLoadImages WRITE setAutoLoadImages NOTIFY autoLoadImagesChanged FINAL)
@@ -204,14 +205,14 @@ signals:
Q_REVISION(8) void pdfViewerEnabledChanged();
private:
- explicit QQuickWebEngineSettings(QQuickWebEngineSettings *parentSettings = 0);
+ explicit QQuickWebEngineSettings(QQuickWebEngineSettings *parentSettings = nullptr);
Q_DISABLE_COPY(QQuickWebEngineSettings)
friend class QQuickWebEngineProfilePrivate;
friend class QQuickWebEngineViewPrivate;
friend class QQuickWebEngineView;
void setParentSettings(QQuickWebEngineSettings *parentSettings);
- QScopedPointer<QtWebEngineCore::WebEngineSettings> d_ptr;
+ QScopedPointer<QWebEngineSettings> d_ptr;
};
QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebenginesingleton.cpp b/src/webenginequick/api/qquickwebenginesingleton.cpp
index 3e84f5cf0..05f38e34e 100644
--- a/src/webengine/api/qquickwebenginesingleton.cpp
+++ b/src/webenginequick/api/qquickwebenginesingleton.cpp
@@ -40,7 +40,7 @@
#include "qquickwebenginesingleton_p.h"
#include "qquickwebenginesettings_p.h"
-#include <QtWebEngine/QQuickWebEngineProfile>
+#include <QtWebEngineQuick/QQuickWebEngineProfile>
QT_BEGIN_NAMESPACE
@@ -71,6 +71,7 @@ QT_BEGIN_NAMESPACE
\sa WebEngineSettings
*/
+
QQuickWebEngineSettings *QQuickWebEngineSingleton::settings() const
{
return defaultProfile()->settings();
@@ -90,4 +91,11 @@ QQuickWebEngineProfile *QQuickWebEngineSingleton::defaultProfile() const
return QQuickWebEngineProfile::defaultProfile();
}
+QWebEngineScript QQuickWebEngineSingleton::script() const
+{
+ return QWebEngineScript();
+}
+
+#include "moc_qquickwebenginesingleton_p.cpp"
+
QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebenginesingleton_p.h b/src/webenginequick/api/qquickwebenginesingleton_p.h
index ba63382e5..cd7b5b2da 100644
--- a/src/webengine/api/qquickwebenginesingleton_p.h
+++ b/src/webenginequick/api/qquickwebenginesingleton_p.h
@@ -51,20 +51,23 @@
// We mean it.
//
-#include <QtWebEngine/private/qtwebengineglobal_p.h>
-#include <QObject>
+#include <QtWebEngineQuick/private/qtwebengineglobal_p.h>
+#include <QtWebEngineCore/qwebenginescript.h>
+#include <QtCore/qobject.h>
QT_BEGIN_NAMESPACE
-class QQuickWebEngineProfile;
+
class QQuickWebEngineSettings;
+class QQuickWebEngineProfile;
+
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineSingleton : public QObject {
Q_OBJECT
Q_PROPERTY(QQuickWebEngineSettings* settings READ settings CONSTANT FINAL)
Q_PROPERTY(QQuickWebEngineProfile* defaultProfile READ defaultProfile CONSTANT FINAL REVISION 1)
-
public:
QQuickWebEngineSettings *settings() const;
QQuickWebEngineProfile *defaultProfile() const;
+ Q_INVOKABLE QWebEngineScript script() const;
};
QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebenginetestsupport.cpp b/src/webenginequick/api/qquickwebenginetestsupport.cpp
index bef87160e..06798fe99 100644
--- a/src/webengine/api/qquickwebenginetestsupport.cpp
+++ b/src/webenginequick/api/qquickwebenginetestsupport.cpp
@@ -39,7 +39,9 @@
#include "qquickwebenginetestsupport_p.h"
-#include "qquickwebengineloadrequest_p.h"
+#include "qwebengineloadrequest.h"
+
+#include <QQuickItem>
#include <QQuickWindow>
#include <QtTest/qtest.h>
#include <QtCore/QTimer>
@@ -58,16 +60,14 @@ void QQuickWebEngineErrorPage::loadFinished(bool success, const QUrl &url)
{
Q_UNUSED(success);
QTimer::singleShot(0, this, [this, url]() {
- QQuickWebEngineLoadRequest loadRequest(url, QQuickWebEngineView::LoadSucceededStatus);
- emit loadingChanged(&loadRequest);
+ emit loadingChanged(QWebEngineLoadRequest(url, QWebEngineLoadRequest::LoadSucceededStatus));
});
}
void QQuickWebEngineErrorPage::loadStarted(const QUrl &provisionalUrl)
{
QTimer::singleShot(0, this, [this, provisionalUrl]() {
- QQuickWebEngineLoadRequest loadRequest(provisionalUrl, QQuickWebEngineView::LoadStartedStatus);
- emit loadingChanged(&loadRequest);
+ emit loadingChanged(QWebEngineLoadRequest(provisionalUrl, QWebEngineLoadRequest::LoadStartedStatus));
});
}
diff --git a/src/webengine/api/qquickwebenginetestsupport_p.h b/src/webenginequick/api/qquickwebenginetestsupport_p.h
index 89a997b29..189643a87 100644
--- a/src/webengine/api/qquickwebenginetestsupport_p.h
+++ b/src/webenginequick/api/qquickwebenginetestsupport_p.h
@@ -52,7 +52,7 @@
//
#include <QtGui/private/qinputmethod_p.h>
-#include <QtWebEngine/private/qtwebengineglobal_p.h>
+#include <QtWebEngineQuick/private/qtwebengineglobal_p.h>
#include <QEvent>
#include <QObject>
@@ -60,7 +60,7 @@
QT_BEGIN_NAMESPACE
-class QQuickWebEngineLoadRequest;
+class QWebEngineLoadRequest;
class QWindow;
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineErrorPage : public QObject {
@@ -73,7 +73,7 @@ public:
void loadStarted(const QUrl &provisionalUrl);
Q_SIGNALS:
- void loadingChanged(QQuickWebEngineLoadRequest *loadRequest);
+ void loadingChanged(const QWebEngineLoadRequest &loadRequest);
};
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineTestInputContext : public QPlatformInputContext {
@@ -104,7 +104,7 @@ public Q_SLOTS:
bool mouseMultiClick(QObject *item, qreal x, qreal y, int clickCount);
private:
- QWindow *eventWindow(QObject *item = 0);
+ QWindow *eventWindow(QObject *item = nullptr);
void mouseEvent(QEvent::Type type, QWindow *window, QObject *item, const QPointF &_pos);
};
diff --git a/src/webengine/api/qquickwebenginetouchhandleprovider.cpp b/src/webenginequick/api/qquickwebenginetouchhandleprovider.cpp
index d6d6116dd..d6d6116dd 100644
--- a/src/webengine/api/qquickwebenginetouchhandleprovider.cpp
+++ b/src/webenginequick/api/qquickwebenginetouchhandleprovider.cpp
diff --git a/src/webengine/api/qquickwebenginetouchhandleprovider_p_p.h b/src/webenginequick/api/qquickwebenginetouchhandleprovider_p_p.h
index 5379a5729..8f5f8cc94 100644
--- a/src/webengine/api/qquickwebenginetouchhandleprovider_p_p.h
+++ b/src/webenginequick/api/qquickwebenginetouchhandleprovider_p_p.h
@@ -52,7 +52,7 @@
//
#include <QtQuick/QQuickImageProvider>
-#include <QtWebEngine/private/qtwebengineglobal_p.h>
+#include <QtWebEngineQuick/private/qtwebengineglobal_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webenginequick/api/qquickwebengineview.cpp
index 1de7f1c7f..710e593c5 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webenginequick/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,29 +49,28 @@
#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"
#include "qquickwebenginenavigationrequest_p.h"
#include "qquickwebenginenewviewrequest_p.h"
#include "qquickwebengineprofile_p.h"
#include "qquickwebenginesettings_p.h"
-#include "qquickwebenginescript_p.h"
#include "qquickwebenginetouchhandleprovider_p_p.h"
+#include "qwebenginecertificateerror.h"
#include "qwebenginefindtextresult.h"
+#include "qwebenginefullscreenrequest.h"
+#include "qwebengineloadrequest.h"
#include "qwebenginequotarequest.h"
+#include "qwebenginescriptcollection.h"
+#include "qwebenginescriptcollection_p.h"
#include "qwebengineregisterprotocolhandlerrequest.h"
-
-#if QT_CONFIG(webengine_testsupport)
+#if QT_CONFIG(webenginequick_testsupport)
#include "qquickwebenginetestsupport_p.h"
#endif
#include "render_widget_host_view_qt_delegate_quick.h"
#include "render_widget_host_view_qt_delegate_quickwindow.h"
-#include "renderer_host/user_resource_controller_host.h"
#include "ui_delegates_manager.h"
#include "web_contents_adapter.h"
#include "web_engine_error.h"
@@ -98,10 +96,23 @@
#include <QTimer>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/qpa/qplatformintegration.h>
-
QT_BEGIN_NAMESPACE
using namespace QtWebEngineCore;
+using LoadStatus = QWebEngineLoadRequest::LoadStatus;
+using ErrorDomain = QWebEngineLoadRequest::ErrorDomain;
+Q_STATIC_ASSERT(static_cast<int>(QQuickWebEngineView::NoErrorDomain) == static_cast<int>(ErrorDomain::NoErrorDomain));
+Q_STATIC_ASSERT(static_cast<int>(QQuickWebEngineView::InternalErrorDomain) == static_cast<int>(ErrorDomain::InternalErrorDomain));
+Q_STATIC_ASSERT(static_cast<int>(QQuickWebEngineView::ConnectionErrorDomain) == static_cast<int>(ErrorDomain::ConnectionErrorDomain));
+Q_STATIC_ASSERT(static_cast<int>(QQuickWebEngineView::CertificateErrorDomain) == static_cast<int>(ErrorDomain::CertificateErrorDomain));
+Q_STATIC_ASSERT(static_cast<int>(QQuickWebEngineView::HttpErrorDomain) == static_cast<int>(ErrorDomain::HttpErrorDomain));
+Q_STATIC_ASSERT(static_cast<int>(QQuickWebEngineView::FtpErrorDomain) == static_cast<int>(ErrorDomain::FtpErrorDomain));
+Q_STATIC_ASSERT(static_cast<int>(QQuickWebEngineView::DnsErrorDomain) == static_cast<int>(ErrorDomain::DnsErrorDomain));
+Q_STATIC_ASSERT(static_cast<int>(QQuickWebEngineView::LoadStartedStatus) == static_cast<int>(LoadStatus::LoadStartedStatus));
+Q_STATIC_ASSERT(static_cast<int>(QQuickWebEngineView::LoadStoppedStatus) == static_cast<int>(LoadStatus::LoadStoppedStatus));
+Q_STATIC_ASSERT(static_cast<int>(QQuickWebEngineView::LoadFailedStatus) == static_cast<int>(LoadStatus::LoadFailedStatus));
+Q_STATIC_ASSERT(static_cast<int>(QQuickWebEngineView::LoadSucceededStatus) == static_cast<int>(LoadStatus::LoadSucceededStatus));
+
#ifndef QT_NO_ACCESSIBILITY
static QAccessibleInterface *webAccessibleFactory(const QString &, QObject *object)
{
@@ -117,7 +128,7 @@ QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate()
: m_profile(nullptr)
, adapter(QSharedPointer<WebContentsAdapter>::create())
, m_history(new QQuickWebEngineHistory(this))
-#if QT_CONFIG(webengine_testsupport)
+#if QT_CONFIG(webenginequick_testsupport)
, m_testSupport(0)
#endif
, contextMenuExtraItems(0)
@@ -135,6 +146,7 @@ QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate()
, m_zoomFactor(1.0)
, m_ui2Enabled(false)
, m_profileInitialized(false)
+ , m_contextMenuRequest(nullptr)
{
memset(actions, 0, sizeof(actions));
@@ -184,6 +196,9 @@ void QQuickWebEngineViewPrivate::initializeProfile()
m_profile->d_ptr->addWebContentsAdapterClient(this);
m_settings.reset(new QQuickWebEngineSettings(m_profile->settings()));
adapter->setClient(this);
+ m_scriptCollection.reset(new QQuickWebEngineScriptCollection(
+ new QWebEngineScriptCollection(new QWebEngineScriptCollectionPrivate(
+ profileAdapter()->userResourceController(), adapter))));
}
}
@@ -231,11 +246,11 @@ 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;
QQmlEngine *engine = qmlEngine(q);
@@ -244,20 +259,22 @@ void QQuickWebEngineViewPrivate::contextMenuRequested(const WebEngineContextMenu
return;
// mark the object for gc by creating temporary jsvalue
- QQuickWebEngineContextMenuRequest *request = new QQuickWebEngineContextMenuRequest(data);
- engine->newQObject(request);
- Q_EMIT q->contextMenuRequested(request);
+ // FIXME: we most likely do not need to make any copy here
+ auto *r = new QWebEngineContextMenuRequest(
+ new QWebEngineContextMenuRequestPrivate(*request->d.data()));
+ 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();
@@ -292,21 +309,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);
@@ -461,7 +471,7 @@ void QQuickWebEngineViewPrivate::loadStarted(const QUrl &provisionalUrl, bool is
{
Q_Q(QQuickWebEngineView);
if (isErrorPage) {
-#if QT_CONFIG(webengine_testsupport)
+#if QT_CONFIG(webenginequick_testsupport)
if (m_testSupport)
m_testSupport->errorPage()->loadStarted(provisionalUrl);
#endif
@@ -470,12 +480,9 @@ 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);
-
- emit q->loadingChanged(&loadRequest);
+ emit q->loadingChanged(QWebEngineLoadRequest(provisionalUrl, LoadStatus::LoadStartedStatus));
});
}
@@ -484,24 +491,38 @@ 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 QT_CONFIG(webenginequick_testsupport)
+ if (m_loadVisuallyCommittedState == NotCommitted) {
+ m_loadVisuallyCommittedState = DidFirstVisuallyNonEmptyPaint;
+ } else if (m_loadVisuallyCommittedState == DidFirstCompositorFrameSwap) {
+ if (m_testSupport)
+ Q_EMIT m_testSupport->loadVisuallyCommitted();
+ m_loadVisuallyCommittedState = NotCommitted;
+ }
#endif
}
-Q_STATIC_ASSERT(static_cast<int>(WebEngineError::NoErrorDomain) == static_cast<int>(QQuickWebEngineView::NoErrorDomain));
-Q_STATIC_ASSERT(static_cast<int>(WebEngineError::CertificateErrorDomain) == static_cast<int>(QQuickWebEngineView::CertificateErrorDomain));
-Q_STATIC_ASSERT(static_cast<int>(WebEngineError::DnsErrorDomain) == static_cast<int>(QQuickWebEngineView::DnsErrorDomain));
+void QQuickWebEngineViewPrivate::didCompositorFrameSwap()
+{
+#if QT_CONFIG(webenginequick_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
+}
void QQuickWebEngineViewPrivate::loadFinished(bool success, const QUrl &url, bool isErrorPage, int errorCode, const QString &errorDescription)
{
Q_Q(QQuickWebEngineView);
if (isErrorPage) {
-#if QT_CONFIG(webengine_testsupport)
+#if QT_CONFIG(webenginequick_testsupport)
if (m_testSupport)
m_testSupport->errorPage()->loadFinished(success, url);
#endif
@@ -512,24 +533,21 @@ void QQuickWebEngineViewPrivate::loadFinished(bool success, const QUrl &url, boo
m_history->reset();
if (errorCode == WebEngineError::UserAbortedError) {
QTimer::singleShot(0, q, [q, url]() {
- QQuickWebEngineLoadRequest loadRequest(url, QQuickWebEngineView::LoadStoppedStatus);
- emit q->loadingChanged(&loadRequest);
+ emit q->loadingChanged(QWebEngineLoadRequest(url, LoadStatus::LoadStoppedStatus));
});
return;
}
if (success) {
QTimer::singleShot(0, q, [q, url, errorDescription, errorCode]() {
- QQuickWebEngineLoadRequest loadRequest(url, QQuickWebEngineView::LoadSucceededStatus, errorDescription, errorCode);
- emit q->loadingChanged(&loadRequest);
+ emit q->loadingChanged(QWebEngineLoadRequest(url, LoadStatus::LoadSucceededStatus, errorDescription, errorCode));
});
return;
}
Q_ASSERT(errorCode);
- QQuickWebEngineView::ErrorDomain errorDomain = static_cast<QQuickWebEngineView::ErrorDomain>(WebEngineError::toQtErrorDomain(errorCode));
+ auto errorDomain = static_cast<ErrorDomain>(WebEngineError::toQtErrorDomain(errorCode));
QTimer::singleShot(0, q, [q, url, errorDescription, errorCode, errorDomain]() {
- QQuickWebEngineLoadRequest loadRequest(url, QQuickWebEngineView::LoadFailedStatus,errorDescription, errorCode, errorDomain);
- emit q->loadingChanged(&loadRequest);
+ emit q->loadingChanged(QWebEngineLoadRequest(url, LoadStatus::LoadFailedStatus, errorDescription, errorCode, errorDomain));
});
return;
}
@@ -600,7 +618,7 @@ void QQuickWebEngineViewPrivate::close()
void QQuickWebEngineViewPrivate::windowCloseRejected()
{
-#if QT_CONFIG(webengine_testsupport)
+#if QT_CONFIG(webenginequick_testsupport)
if (m_testSupport)
Q_EMIT m_testSupport->windowCloseRejected();
#endif
@@ -609,7 +627,7 @@ void QQuickWebEngineViewPrivate::windowCloseRejected()
void QQuickWebEngineViewPrivate::requestFullScreenMode(const QUrl &origin, bool fullscreen)
{
Q_Q(QQuickWebEngineView);
- QQuickWebEngineFullScreenRequest request(this, origin, fullscreen);
+ QWebEngineFullScreenRequest request(origin, fullscreen, [q = QPointer(q)] (bool toggleOn) { if (q) q->d_ptr->setFullScreenMode(toggleOn); });
Q_EMIT q->fullScreenRequested(request);
}
@@ -719,19 +737,13 @@ void QQuickWebEngineViewPrivate::printRequested()
});
}
-void QQuickWebEngineViewPrivate::widgetChanged(RenderWidgetHostViewQtDelegate *newWidgetBase)
-{
- Q_Q(QQuickWebEngineView);
- bindViewAndWidget(q, static_cast<RenderWidgetHostViewQtDelegateQuick *>(newWidgetBase));
-}
-
void QQuickWebEngineViewPrivate::findTextFinished(const QWebEngineFindTextResult &result)
{
Q_Q(QQuickWebEngineView);
Q_EMIT q->findTextFinished(result);
}
-WebEngineSettings *QQuickWebEngineViewPrivate::webEngineSettings() const
+QWebEngineSettings *QQuickWebEngineViewPrivate::webEngineSettings() const
{
return m_settings->d_ptr.data();
}
@@ -924,8 +936,7 @@ void QQuickWebEngineViewPrivate::initializationFinished()
if (devToolsView && devToolsView->d_ptr->adapter)
adapter->openDevToolsFrontend(devToolsView->d_ptr->adapter);
- for (QQuickWebEngineScript *script : qAsConst(m_userScripts))
- script->d_func()->bind(profileAdapter()->userResourceController(), adapter.data());
+ m_scriptCollection->d->d->initializationFinished(adapter);
if (q->window())
adapter->setVisible(q->isVisible());
@@ -937,8 +948,7 @@ void QQuickWebEngineViewPrivate::initializationFinished()
emit q->titleChanged();
emit q->urlChanged();
emit q->iconChanged();
- QQuickWebEngineLoadRequest loadRequest(m_url, QQuickWebEngineView::LoadSucceededStatus);
- emit q->loadingChanged(&loadRequest);
+ emit q->loadingChanged(QWebEngineLoadRequest(m_url, LoadStatus::LoadSucceededStatus));
emit q->loadProgressChanged();
m_isBeingAdopted = false;
@@ -1191,14 +1201,10 @@ QQuickWebEngineSettings *QQuickWebEngineView::settings()
return d->m_settings.data();
}
-QQmlListProperty<QQuickWebEngineScript> QQuickWebEngineView::userScripts()
+QQuickWebEngineScriptCollection *QQuickWebEngineView::userScripts()
{
Q_D(QQuickWebEngineView);
- return QQmlListProperty<QQuickWebEngineScript>(this, d,
- d->userScripts_append,
- d->userScripts_count,
- d->userScripts_at,
- d->userScripts_clear);
+ return d->m_scriptCollection.data();
}
void QQuickWebEngineViewPrivate::updateAdapter()
@@ -1217,7 +1223,7 @@ void QQuickWebEngineViewPrivate::updateAdapter()
}
}
-#if QT_CONFIG(webengine_testsupport)
+#if QT_CONFIG(webenginequick_testsupport)
QQuickWebEngineTestSupport *QQuickWebEngineView::testSupport() const
{
Q_D(const QQuickWebEngineView);
@@ -1288,25 +1294,16 @@ void QQuickWebEngineViewPrivate::requestGeometryChange(const QRect &geometry, co
Q_EMIT q->geometryChangeRequested(geometry, frameGeometry);
}
-void QQuickWebEngineViewPrivate::startDragging(const content::DropData &dropData,
- Qt::DropActions allowedActions,
- const QPixmap &pixmap, const QPoint &offset)
-{
-#if !QT_CONFIG(draganddrop)
- Q_UNUSED(dropData);
- Q_UNUSED(allowedActions);
- Q_UNUSED(pixmap);
- Q_UNUSED(offset);
-#else
- adapter->startDragging(q_ptr->window(), dropData, allowedActions, pixmap, offset);
-#endif // QT_CONFIG(draganddrop)
-}
-
-bool QQuickWebEngineViewPrivate::supportsDragging() const
+QObject *QQuickWebEngineViewPrivate::dragSource() const
{
// QTBUG-57516
// Fixme: This is just a band-aid workaround.
- return QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::MultipleWindows);
+#if !QT_CONFIG(draganddrop)
+ return QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::MultipleWindows) ?
+ q_ptr->window : nullptr;
+#else
+ return nullptr;
+#endif
}
bool QQuickWebEngineViewPrivate::isEnabled() const
@@ -1391,7 +1388,7 @@ bool QQuickWebEngineView::canGoForward() const
void QQuickWebEngineView::runJavaScript(const QString &script, const QJSValue &callback)
{
- runJavaScript(script, QQuickWebEngineScript::MainWorld, callback);
+ runJavaScript(script, QWebEngineScript::MainWorld, callback);
}
void QQuickWebEngineView::runJavaScript(const QString &script, quint32 worldId, const QJSValue &callback)
@@ -1561,7 +1558,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
}
@@ -1583,7 +1580,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
}
@@ -1707,9 +1704,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());
@@ -1727,16 +1724,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)
@@ -1749,7 +1746,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 {
@@ -1762,7 +1759,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)
@@ -1810,32 +1807,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();
@@ -1843,99 +1841,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();
@@ -1950,40 +1967,40 @@ void QQuickWebEngineView::triggerWebAction(WebAction action)
d->adapter->viewSource();
break;
case ToggleBold:
- runJavaScript(QStringLiteral("document.execCommand('bold');"), QQuickWebEngineScript::ApplicationWorld);
+ runJavaScript(QStringLiteral("document.execCommand('bold');"), QWebEngineScript::ApplicationWorld);
break;
case ToggleItalic:
- runJavaScript(QStringLiteral("document.execCommand('italic');"), QQuickWebEngineScript::ApplicationWorld);
+ runJavaScript(QStringLiteral("document.execCommand('italic');"), QWebEngineScript::ApplicationWorld);
break;
case ToggleUnderline:
- runJavaScript(QStringLiteral("document.execCommand('underline');"), QQuickWebEngineScript::ApplicationWorld);
+ runJavaScript(QStringLiteral("document.execCommand('underline');"), QWebEngineScript::ApplicationWorld);
break;
case ToggleStrikethrough:
- runJavaScript(QStringLiteral("document.execCommand('strikethrough');"), QQuickWebEngineScript::ApplicationWorld);
+ runJavaScript(QStringLiteral("document.execCommand('strikethrough');"), QWebEngineScript::ApplicationWorld);
break;
case AlignLeft:
- runJavaScript(QStringLiteral("document.execCommand('justifyLeft');"), QQuickWebEngineScript::ApplicationWorld);
+ runJavaScript(QStringLiteral("document.execCommand('justifyLeft');"), QWebEngineScript::ApplicationWorld);
break;
case AlignCenter:
- runJavaScript(QStringLiteral("document.execCommand('justifyCenter');"), QQuickWebEngineScript::ApplicationWorld);
+ runJavaScript(QStringLiteral("document.execCommand('justifyCenter');"), QWebEngineScript::ApplicationWorld);
break;
case AlignRight:
- runJavaScript(QStringLiteral("document.execCommand('justifyRight');"), QQuickWebEngineScript::ApplicationWorld);
+ runJavaScript(QStringLiteral("document.execCommand('justifyRight');"), QWebEngineScript::ApplicationWorld);
break;
case AlignJustified:
- runJavaScript(QStringLiteral("document.execCommand('justifyFull');"), QQuickWebEngineScript::ApplicationWorld);
+ runJavaScript(QStringLiteral("document.execCommand('justifyFull');"), QWebEngineScript::ApplicationWorld);
break;
case Indent:
- runJavaScript(QStringLiteral("document.execCommand('indent');"), QQuickWebEngineScript::ApplicationWorld);
+ runJavaScript(QStringLiteral("document.execCommand('indent');"), QWebEngineScript::ApplicationWorld);
break;
case Outdent:
- runJavaScript(QStringLiteral("document.execCommand('outdent');"), QQuickWebEngineScript::ApplicationWorld);
+ runJavaScript(QStringLiteral("document.execCommand('outdent');"), QWebEngineScript::ApplicationWorld);
break;
case InsertOrderedList:
- runJavaScript(QStringLiteral("document.execCommand('insertOrderedList');"), QQuickWebEngineScript::ApplicationWorld);
+ runJavaScript(QStringLiteral("document.execCommand('insertOrderedList');"), QWebEngineScript::ApplicationWorld);
break;
case InsertUnorderedList:
- runJavaScript(QStringLiteral("document.execCommand('insertUnorderedList');"), QQuickWebEngineScript::ApplicationWorld);
+ runJavaScript(QStringLiteral("document.execCommand('insertUnorderedList');"), QWebEngineScript::ApplicationWorld);
break;
default:
Q_UNREACHABLE();
@@ -2185,43 +2202,6 @@ QPointF QQuickWebEngineView::scrollPosition() const
return d->adapter->lastScrollOffset();
}
-void QQuickWebEngineViewPrivate::userScripts_append(QQmlListProperty<QQuickWebEngineScript> *p, QQuickWebEngineScript *script)
-{
- Q_ASSERT(p && p->data);
- QQuickWebEngineViewPrivate *d = static_cast<QQuickWebEngineViewPrivate*>(p->data);
- d->m_userScripts.append(script);
- // If the adapter hasn't been initialized, we'll bind the scripts in initializationFinished()
- if (!d->adapter->isInitialized())
- return;
- UserResourceControllerHost *resourceController = d->profileAdapter()->userResourceController();
- script->d_func()->bind(resourceController, d->adapter.data());
-}
-
-int QQuickWebEngineViewPrivate::userScripts_count(QQmlListProperty<QQuickWebEngineScript> *p)
-{
- Q_ASSERT(p && p->data);
- QQuickWebEngineViewPrivate *d = static_cast<QQuickWebEngineViewPrivate*>(p->data);
- return d->m_userScripts.count();
-}
-
-QQuickWebEngineScript *QQuickWebEngineViewPrivate::userScripts_at(QQmlListProperty<QQuickWebEngineScript> *p, int idx)
-{
- Q_ASSERT(p && p->data);
- QQuickWebEngineViewPrivate *d = static_cast<QQuickWebEngineViewPrivate*>(p->data);
- return d->m_userScripts.at(idx);
-}
-
-void QQuickWebEngineViewPrivate::userScripts_clear(QQmlListProperty<QQuickWebEngineScript> *p)
-{
- Q_ASSERT(p && p->data);
- QQuickWebEngineViewPrivate *d = static_cast<QQuickWebEngineViewPrivate*>(p->data);
- d->m_userScripts.clear();
- if (!d->adapter->isInitialized())
- return;
- UserResourceControllerHost *resourceController = d->profileAdapter()->userResourceController();
- resourceController->clearAllScripts(d->adapter.data());
-}
-
void QQuickWebEngineView::componentComplete()
{
QQuickItem::componentComplete();
@@ -2263,37 +2243,9 @@ QQuickWebEngineView::LifecycleState QQuickWebEngineView::recommendedState() cons
return static_cast<LifecycleState>(d->adapter->recommendedState());
}
-QQuickWebEngineFullScreenRequest::QQuickWebEngineFullScreenRequest()
- : m_viewPrivate(0)
- , m_toggleOn(false)
-{
-}
-
-QQuickWebEngineFullScreenRequest::QQuickWebEngineFullScreenRequest(QQuickWebEngineViewPrivate *viewPrivate, const QUrl &origin, bool toggleOn)
- : m_viewPrivate(viewPrivate)
- , m_origin(origin)
- , m_toggleOn(toggleOn)
-{
-}
-
-void QQuickWebEngineFullScreenRequest::accept()
-{
- if (m_viewPrivate)
- m_viewPrivate->setFullScreenMode(m_toggleOn);
-}
-
-void QQuickWebEngineFullScreenRequest::reject()
-{
- if (m_viewPrivate)
- 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)
{
}
@@ -2401,9 +2353,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);
}
@@ -2428,19 +2380,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:
@@ -2505,3 +2457,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/webenginequick/api/qquickwebengineview_p.h
index 3155bce37..df5880e73 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webenginequick/api/qquickwebengineview_p.h
@@ -51,11 +51,16 @@
// We mean it.
//
-#include <QtWebEngine/private/qtwebengineglobal_p.h>
+#include <QtWebEngineCore/qtwebenginecoreglobal.h>
+#include <QtWebEngineQuick/private/qtwebengineglobal_p.h>
#include <QQuickItem>
#include <QtGui/qcolor.h>
-#include "qquickwebenginescript.h"
+#include "qquickwebengineprofile.h"
+
+namespace QtWebEngineCore {
+class RenderWidgetHostViewQtDelegateQuick;
+}
QT_BEGIN_NAMESPACE
@@ -63,49 +68,31 @@ class QQmlWebChannel;
class QQuickContextMenuBuilder;
class QQuickWebEngineAction;
class QQuickWebEngineAuthenticationDialogRequest;
-class QQuickWebEngineCertificateError;
class QQuickWebEngineClientCertificateSelection;
class QQuickWebEngineColorDialogRequest;
-class QQuickWebEngineContextMenuRequest;
class QQuickWebEngineFaviconProvider;
class QQuickWebEngineFileDialogRequest;
class QQuickWebEngineHistory;
class QQuickWebEngineJavaScriptDialogRequest;
-class QQuickWebEngineLoadRequest;
+class QWebEngineLoadRequest;
class QQuickWebEngineNavigationRequest;
class QQuickWebEngineNewViewRequest;
-class QQuickWebEngineProfile;
class QQuickWebEngineSettings;
class QQuickWebEngineTooltipRequest;
class QQuickWebEngineFormValidationMessageRequest;
class QQuickWebEngineViewPrivate;
+class QWebEngineCertificateError;
class QWebEngineFindTextResult;
+class QWebEngineFullScreenRequest;
class QWebEngineQuotaRequest;
class QWebEngineRegisterProtocolHandlerRequest;
+class QWebEngineContextMenuRequest;
+class QQuickWebEngineScriptCollection;
-#if QT_CONFIG(webengine_testsupport)
+#if QT_CONFIG(webenginequick_testsupport)
class QQuickWebEngineTestSupport;
#endif
-class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineFullScreenRequest {
- Q_GADGET
- Q_PROPERTY(QUrl origin READ origin CONSTANT FINAL)
- Q_PROPERTY(bool toggleOn READ toggleOn CONSTANT FINAL)
-public:
- QQuickWebEngineFullScreenRequest();
- QQuickWebEngineFullScreenRequest(QQuickWebEngineViewPrivate *viewPrivate, const QUrl &origin, bool toggleOn);
-
- Q_INVOKABLE void accept();
- Q_INVOKABLE void reject();
- QUrl origin() const { return m_origin; }
- bool toggleOn() const { return m_toggleOn; }
-
-private:
- QQuickWebEngineViewPrivate *m_viewPrivate;
- const QUrl m_origin;
- const bool m_toggleOn;
-};
-
#define LATEST_WEBENGINEVIEW_REVISION 10
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
@@ -123,8 +110,10 @@ 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)
- Q_PROPERTY(QQmlListProperty<QQuickWebEngineScript> userScripts READ userScripts FINAL REVISION 1)
+#endif
+ Q_PROPERTY(QQuickWebEngineScriptCollection *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)
Q_PROPERTY(QSizeF contentsSize READ contentsSize NOTIFY contentsSizeChanged FINAL REVISION 3)
@@ -135,7 +124,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_PROPERTY(QQuickWebEngineView *inspectedView READ inspectedView WRITE setInspectedView NOTIFY inspectedViewChanged REVISION 7 FINAL)
Q_PROPERTY(QQuickWebEngineView *devToolsView READ devToolsView WRITE setDevToolsView NOTIFY devToolsViewChanged REVISION 7 FINAL)
-#if QT_CONFIG(webengine_testsupport)
+#if QT_CONFIG(webenginequick_testsupport)
Q_PROPERTY(QQuickWebEngineTestSupport *testSupport READ testSupport WRITE setTestSupport NOTIFY testSupportChanged FINAL)
#endif
@@ -145,7 +134,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_PROPERTY(qint64 renderProcessPid READ renderProcessPid NOTIFY renderProcessPidChanged FINAL REVISION 11)
public:
- QQuickWebEngineView(QQuickItem *parent = 0);
+ QQuickWebEngineView(QQuickItem *parent = nullptr);
~QQuickWebEngineView();
QUrl url() const;
@@ -481,7 +470,7 @@ public:
QQuickWebEngineProfile *profile();
void setProfile(QQuickWebEngineProfile *);
- QQmlListProperty<QQuickWebEngineScript> userScripts();
+ QQuickWebEngineScriptCollection *userScripts();
QQuickWebEngineSettings *settings();
QQmlWebChannel *webChannel();
@@ -497,7 +486,7 @@ public:
qint64 renderProcessPid() const;
-#if QT_CONFIG(webengine_testsupport)
+#if QT_CONFIG(webenginequick_testsupport)
QQuickWebEngineTestSupport *testSupport() const;
void setTestSupport(QQuickWebEngineTestSupport *testSupport);
#endif
@@ -540,13 +529,13 @@ Q_SIGNALS:
void titleChanged();
void urlChanged();
void iconChanged();
- void loadingChanged(QQuickWebEngineLoadRequest *loadRequest);
+ void loadingChanged(const QWebEngineLoadRequest &loadRequest);
void loadProgressChanged();
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 fullScreenRequested(const QQuickWebEngineFullScreenRequest &request);
+ Q_REVISION(1) void certificateError(const QWebEngineCertificateError &error);
+ Q_REVISION(1) void fullScreenRequested(const QWebEngineFullScreenRequest &request);
Q_REVISION(1) void isFullScreenChanged();
Q_REVISION(1) void featurePermissionRequested(const QUrl &securityOrigin, Feature feature);
Q_REVISION(1) void newViewRequested(QQuickWebEngineNewViewRequest *request);
@@ -562,7 +551,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);
@@ -584,12 +573,12 @@ Q_SIGNALS:
Q_REVISION(11) void canGoBackChanged();
Q_REVISION(11) void canGoForwardChanged();
-#if QT_CONFIG(webengine_testsupport)
+#if QT_CONFIG(webenginequick_testsupport)
void testSupportChanged();
#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;
@@ -602,6 +591,7 @@ private:
Q_DECLARE_PRIVATE(QQuickWebEngineView)
QScopedPointer<QQuickWebEngineViewPrivate> d_ptr;
+ friend class QtWebEngineCore::RenderWidgetHostViewQtDelegateQuick;
friend class QQuickContextMenuBuilder;
friend class QQuickWebEngineNewViewRequest;
friend class QQuickWebEngineFaviconProvider;
@@ -613,6 +603,5 @@ private:
QT_END_NAMESPACE
QML_DECLARE_TYPE(QQuickWebEngineView)
-Q_DECLARE_METATYPE(QQuickWebEngineFullScreenRequest)
#endif // QQUICKWEBENGINEVIEW_P_H
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webenginequick/api/qquickwebengineview_p_p.h
index ec535298b..115c13e06 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webenginequick/api/qquickwebengineview_p_p.h
@@ -52,6 +52,7 @@
//
#include "qquickwebengineview_p.h"
+#include "qquickwebenginescriptcollection.h"
#include "render_view_context_menu_qt.h"
#include "touch_handle_drawable_client.h"
#include "web_contents_adapter_client.h"
@@ -75,14 +76,14 @@ QT_BEGIN_NAMESPACE
class QQuickWebEngineView;
class QQmlComponent;
class QQmlContext;
-class QQuickWebEngineContextMenuRequest;
+class QWebEngineContextMenuRequest;
class QQuickWebEngineSettings;
class QQuickWebEngineFaviconProvider;
class QQuickWebEngineProfilePrivate;
class QQuickWebEngineTouchHandleProvider;
class QWebEngineFindTextResult;
-#if QT_CONFIG(webengine_testsupport)
+#if QT_CONFIG(webenginequick_testsupport)
class QQuickWebEngineTestSupport;
#endif
@@ -115,7 +116,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, int errorCode, const QString &errorDescription) override;
void focusContainer() override;
void unhandledKeyEvent(QKeyEvent *event) override;
@@ -128,7 +129,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;
@@ -146,9 +147,10 @@ public:
void runQuotaRequest(QWebEngineQuotaRequest) override;
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;
+ QWebEngineSettings *webEngineSettings() const 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;
@@ -156,9 +158,7 @@ public:
void updateContentsSize(const QSizeF &size) override;
void updateNavigationActions() override;
void updateEditActions() override;
- void startDragging(const content::DropData &dropData, Qt::DropActions allowedActions,
- const QPixmap &pixmap, const QPoint &offset) override;
- bool supportsDragging() const override;
+ QObject *dragSource() const override;
bool isEnabled() const override;
void setToolTip(const QString &toolTipText) override;
QtWebEngineCore::TouchHandleDrawableClient *createTouchHandle(const QMap<int, QImage> &images) override;
@@ -170,9 +170,10 @@ public:
QtWebEngineCore::ProfileAdapter *profileAdapter() override;
QtWebEngineCore::WebContentsAdapter *webContentsAdapter() override;
void printRequested() override;
- 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);
@@ -184,21 +185,14 @@ public:
void widgetChanged(QtWebEngineCore::RenderWidgetHostViewQtDelegateQuick *oldWidget,
QtWebEngineCore::RenderWidgetHostViewQtDelegateQuick *newWidget);
- // QQmlListPropertyHelpers
- static void userScripts_append(QQmlListProperty<QQuickWebEngineScript> *p, QQuickWebEngineScript *script);
- static int userScripts_count(QQmlListProperty<QQuickWebEngineScript> *p);
- static QQuickWebEngineScript *userScripts_at(QQmlListProperty<QQuickWebEngineScript> *p, int idx);
- static void userScripts_clear(QQmlListProperty<QQuickWebEngineScript> *p);
-
QQuickWebEngineProfile *m_profile;
QSharedPointer<QtWebEngineCore::WebContentsAdapter> adapter;
QScopedPointer<QQuickWebEngineHistory> m_history;
QScopedPointer<QQuickWebEngineSettings> m_settings;
-#if QT_CONFIG(webengine_testsupport)
+#if QT_CONFIG(webenginequick_testsupport)
QQuickWebEngineTestSupport *m_testSupport;
#endif
QQmlComponent *contextMenuExtraItems;
- QtWebEngineCore::WebEngineContextMenuData m_contextMenuData;
QUrl m_url;
QString m_html;
QUrl iconUrl;
@@ -210,7 +204,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 +216,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;
+ QScopedPointer<QQuickWebEngineScriptCollection> m_scriptCollection;
};
#ifndef QT_NO_ACCESSIBILITY
@@ -254,7 +255,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/webenginequick/api/qtwebengineglobal.cpp
index 47b729ebc..7d2b91e90 100644
--- a/src/webengine/api/qtwebengineglobal.cpp
+++ b/src/webenginequick/api/qtwebengineglobal.cpp
@@ -39,6 +39,7 @@
#include "qtwebengineglobal.h"
#include <QCoreApplication>
+#include <QQuickWindow>
namespace QtWebEngineCore
{
@@ -72,14 +73,15 @@ namespace QtWebEngine {
*/
void initialize()
{
- if (!QCoreApplication::startingUp()) {
+ if (!QCoreApplication::startingUp()) {
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/api/qtwebengineglobal.h b/src/webenginequick/api/qtwebengineglobal.h
index c2b33778a..50a91b745 100644
--- a/src/webengine/api/qtwebengineglobal.h
+++ b/src/webenginequick/api/qtwebengineglobal.h
@@ -41,7 +41,7 @@
#define QTWEBENGINEGLOBAL_H
#include <QtCore/qglobal.h>
-#include <QtWebEngine/qtwebengine-config.h>
+#include <QtWebEngineQuick/qtwebenginequick-config.h>
QT_BEGIN_NAMESPACE
diff --git a/src/webengine/api/qtwebengineglobal_p.h b/src/webenginequick/api/qtwebengineglobal_p.h
index 2d30f75b0..549de30d2 100644
--- a/src/webengine/api/qtwebengineglobal_p.h
+++ b/src/webenginequick/api/qtwebengineglobal_p.h
@@ -51,9 +51,9 @@
// We mean it.
//
-#include <QtWebEngine/qtwebengineglobal.h>
+#include <QtWebEngineQuick/qtwebengineglobal.h>
#include <QtCore/private/qglobal_p.h>
-#include <QtWebEngine/private/qtwebengine-config_p.h>
+#include <QtWebEngineQuick/private/qtwebenginequick-config_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/webengine/configure.json b/src/webenginequick/configure.json
index ebe1ddb2b..6297195e9 100644
--- a/src/webengine/configure.json
+++ b/src/webenginequick/configure.json
@@ -1,26 +1,26 @@
{
- "module": "webengine",
- "condition": "module.webenginecore && features.webengine-qml",
+ "module": "webenginequick",
+ "condition": "module.webenginecore && features.webengine-quick",
"depends": [
"webenginecore-private"
],
"commandline": {
"options": {
- "webengine-qml": "boolean"
+ "webengine-quick": "boolean"
}
},
"features": {
- "webengine-qml": {
- "label": "Support Qt WebEngine Qml",
- "purpose": "Provides WebEngine Qml support.",
+ "webengine-quick": {
+ "label": "Support Qt WebEngineQuick",
+ "purpose": "Provides WebEngineQuick support.",
"output": [ "privateFeature" ]
},
- "webengine-ui-delegates": {
+ "webenginequick-ui-delegates": {
"label": "UI Delegates",
"section": "WebEngine",
"output": [ "privateFeature" ]
},
- "webengine-testsupport": {
+ "webenginequick-testsupport": {
"label": "Test Support",
"autoDetect": "features.private_tests || call.isTestsInBuildParts",
"output": [ "privateFeature" ]
@@ -28,11 +28,11 @@
},
"summary": [
{
- "section": "Qt WebEngineQml",
+ "section": "Qt WebEngineQuick",
"entries": [
- "webengine-qml",
- "webengine-ui-delegates",
- "webengine-testsupport"
+ "webengine-quick",
+ "webenginequick-ui-delegates",
+ "webenginequick-testsupport"
]
}
]
diff --git a/src/webengine/doc/QtWebEngineDoc b/src/webenginequick/doc/QtWebEngineDoc
index 0737885f1..0737885f1 100644
--- a/src/webengine/doc/QtWebEngineDoc
+++ b/src/webenginequick/doc/QtWebEngineDoc
diff --git a/src/webengine/doc/images/qtwebengine-architecture.png b/src/webenginequick/doc/images/qtwebengine-architecture.png
index 979a0ad3f..979a0ad3f 100644
--- a/src/webengine/doc/images/qtwebengine-architecture.png
+++ b/src/webenginequick/doc/images/qtwebengine-architecture.png
Binary files differ
diff --git a/src/webengine/doc/images/qtwebengine-model.png b/src/webenginequick/doc/images/qtwebengine-model.png
index 0bbd556f1..0bbd556f1 100644
--- a/src/webengine/doc/images/qtwebengine-model.png
+++ b/src/webenginequick/doc/images/qtwebengine-model.png
Binary files differ
diff --git a/src/webengine/doc/images/qtwebengine-model.qmodel b/src/webenginequick/doc/images/qtwebengine-model.qmodel
index f3d5cb52b..f3d5cb52b 100644
--- a/src/webengine/doc/images/qtwebengine-model.qmodel
+++ b/src/webenginequick/doc/images/qtwebengine-model.qmodel
diff --git a/src/webengine/doc/images/qtwebengine-modules-model.qmodel b/src/webenginequick/doc/images/qtwebengine-modules-model.qmodel
index c1d64b617..c1d64b617 100644
--- a/src/webengine/doc/images/qtwebengine-modules-model.qmodel
+++ b/src/webenginequick/doc/images/qtwebengine-modules-model.qmodel
diff --git a/src/webengine/doc/images/qtwebenginewidgets-model.png b/src/webenginequick/doc/images/qtwebenginewidgets-model.png
index c334b84c9..c334b84c9 100644
--- a/src/webengine/doc/images/qtwebenginewidgets-model.png
+++ b/src/webenginequick/doc/images/qtwebenginewidgets-model.png
Binary files differ
diff --git a/src/webengine/doc/images/qtwebenginewidgets-model.qmodel b/src/webenginequick/doc/images/qtwebenginewidgets-model.qmodel
index aa59f7b8f..aa59f7b8f 100644
--- a/src/webengine/doc/images/qtwebenginewidgets-model.qmodel
+++ b/src/webenginequick/doc/images/qtwebenginewidgets-model.qmodel
diff --git a/src/webengine/doc/qtwebengine.qdocconf b/src/webenginequick/doc/qtwebengine.qdocconf
index be5db9c19..be5db9c19 100644
--- a/src/webengine/doc/qtwebengine.qdocconf
+++ b/src/webenginequick/doc/qtwebengine.qdocconf
diff --git a/src/webengine/doc/snippets/qtwebengine_build_snippet.qdoc b/src/webenginequick/doc/snippets/qtwebengine_build_snippet.qdoc
index 35bc480bb..35bc480bb 100644
--- a/src/webengine/doc/snippets/qtwebengine_build_snippet.qdoc
+++ b/src/webenginequick/doc/snippets/qtwebengine_build_snippet.qdoc
diff --git a/src/webengine/doc/snippets/qtwebengine_webengineview_newviewrequested.qml b/src/webenginequick/doc/snippets/qtwebengine_webengineview_newviewrequested.qml
index e7e6790f2..e7e6790f2 100644
--- a/src/webengine/doc/snippets/qtwebengine_webengineview_newviewrequested.qml
+++ b/src/webenginequick/doc/snippets/qtwebengine_webengineview_newviewrequested.qml
diff --git a/src/webenginequick/doc/src/context_menu_request.qdoc b/src/webenginequick/doc/src/context_menu_request.qdoc
new file mode 100644
index 000000000..cc812dcf2
--- /dev/null
+++ b/src/webenginequick/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/external-resources.qdoc b/src/webenginequick/doc/src/external-resources.qdoc
index 7878ed9f8..7878ed9f8 100644
--- a/src/webengine/doc/src/external-resources.qdoc
+++ b/src/webenginequick/doc/src/external-resources.qdoc
diff --git a/src/webenginequick/doc/src/fullscreen_request.qdoc b/src/webenginequick/doc/src/fullscreen_request.qdoc
new file mode 100644
index 000000000..ec7d93ba6
--- /dev/null
+++ b/src/webenginequick/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 QWebEngineFullScreenRequest
+ \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/webenginequick/doc/src/load_request.qdoc b/src/webenginequick/doc/src/load_request.qdoc
new file mode 100644
index 000000000..abe3a403f
--- /dev/null
+++ b/src/webenginequick/doc/src/load_request.qdoc
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 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 WebEngineLoadRequest
+ \instantiates QWebEngineLoadRequest
+ \inqmlmodule QtWebEngine
+ \since QtWebEngine 1.0
+
+ \brief A utility type for the WebEngineView::loadingChanged signal.
+
+ Contains information about a request for loading a web page, such as the URL and
+ current loading status (started, succeeded, failed).
+
+ \sa WebEngineView::loadingChanged
+*/
+/*!
+ \qmlproperty url WebEngineLoadRequest::url
+ \brief Holds the URL of the load request.
+ */
+/*!
+ \qmlproperty enumeration WebEngineLoadRequest::status
+
+ This enumeration represents the load status of a web page load request:
+
+ \value WebEngineView.LoadStartedStatus Page is currently loading.
+ \value WebEngineView.LoadStoppedStatus
+ Loading the page was stopped by the stop() method or by the loader
+ code or network stack in Chromium.
+ \value WebEngineView.LoadSucceededStatus
+ Page has been loaded with success.
+ \value WebEngineView.LoadFailedStatus Page could not be loaded.
+
+ \sa WebEngineView::loadingChanged
+*/
+/*!
+ \qmlproperty string WebEngineLoadRequest::errorString
+ \brief Holds the error message.
+*/
+/*!
+ \qmlproperty enumeration WebEngineLoadRequest::errorDomain
+ This enumeration holds the type of a load request error:
+
+ \value WebEngineLoadRequest.NoErrorDomain
+ Error type is not known.
+ \value WebEngineLoadRequest.InternalErrorDomain
+ Content cannot be interpreted by \QWE.
+ \value WebEngineLoadRequest.ConnectionErrorDomain
+ Error results from a faulty network connection.
+ \value WebEngineLoadRequest.CertificateErrorDomain
+ Error is related to the SSL/TLS certificate.
+ \value WebEngineLoadRequest.HttpErrorDomain
+ Error is related to the HTTP connection.
+ \value WebEngineLoadRequest.FtpErrorDomain
+ Error is related to the FTP connection.
+ \value WebEngineLoadRequest.DnsErrorDomain
+ Error is related to the DNS connection.
+*/
+/*!
+ \qmlproperty int WebEngineLoadRequest::errorCode
+ \brief Holds the error code.
+*/
diff --git a/src/webengine/doc/src/qtwebengine-debugging.qdoc b/src/webenginequick/doc/src/qtwebengine-debugging.qdoc
index 0db35c85c..0db35c85c 100644
--- a/src/webengine/doc/src/qtwebengine-debugging.qdoc
+++ b/src/webenginequick/doc/src/qtwebengine-debugging.qdoc
diff --git a/src/webengine/doc/src/qtwebengine-deploying.qdoc b/src/webenginequick/doc/src/qtwebengine-deploying.qdoc
index 7b9f3fd4a..7b9f3fd4a 100644
--- a/src/webengine/doc/src/qtwebengine-deploying.qdoc
+++ b/src/webenginequick/doc/src/qtwebengine-deploying.qdoc
diff --git a/src/webengine/doc/src/qtwebengine-examples.qdoc b/src/webenginequick/doc/src/qtwebengine-examples.qdoc
index d31895078..d31895078 100644
--- a/src/webengine/doc/src/qtwebengine-examples.qdoc
+++ b/src/webenginequick/doc/src/qtwebengine-examples.qdoc
diff --git a/src/webengine/doc/src/qtwebengine-features.qdoc b/src/webenginequick/doc/src/qtwebengine-features.qdoc
index 431367765..431367765 100644
--- a/src/webengine/doc/src/qtwebengine-features.qdoc
+++ b/src/webenginequick/doc/src/qtwebengine-features.qdoc
diff --git a/src/webengine/doc/src/qtwebengine-index.qdoc b/src/webenginequick/doc/src/qtwebengine-index.qdoc
index f668cf87b..f668cf87b 100644
--- a/src/webengine/doc/src/qtwebengine-index.qdoc
+++ b/src/webenginequick/doc/src/qtwebengine-index.qdoc
diff --git a/src/webengine/doc/src/qtwebengine-module.qdoc b/src/webenginequick/doc/src/qtwebengine-module.qdoc
index 5554bd519..5554bd519 100644
--- a/src/webengine/doc/src/qtwebengine-module.qdoc
+++ b/src/webenginequick/doc/src/qtwebengine-module.qdoc
diff --git a/src/webengine/doc/src/qtwebengine-modules.qdoc b/src/webenginequick/doc/src/qtwebengine-modules.qdoc
index 7b8ced728..7b8ced728 100644
--- a/src/webengine/doc/src/qtwebengine-modules.qdoc
+++ b/src/webenginequick/doc/src/qtwebengine-modules.qdoc
diff --git a/src/webengine/doc/src/qtwebengine-overview.qdoc b/src/webenginequick/doc/src/qtwebengine-overview.qdoc
index 9908d46a8..9908d46a8 100644
--- a/src/webengine/doc/src/qtwebengine-overview.qdoc
+++ b/src/webenginequick/doc/src/qtwebengine-overview.qdoc
diff --git a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc b/src/webenginequick/doc/src/qtwebengine-platform-notes.qdoc
index e32424eea..e32424eea 100644
--- a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc
+++ b/src/webenginequick/doc/src/qtwebengine-platform-notes.qdoc
diff --git a/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc b/src/webenginequick/doc/src/qtwebengine-qmlmodule.qdoc
index 4fd7e3a3b..4fd7e3a3b 100644
--- a/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc
+++ b/src/webenginequick/doc/src/qtwebengine-qmlmodule.qdoc
diff --git a/src/webenginequick/doc/src/quota_request.qdoc b/src/webenginequick/doc/src/quota_request.qdoc
new file mode 100644
index 000000000..ee64c0484
--- /dev/null
+++ b/src/webenginequick/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/qwebengine-licensing.qdoc b/src/webenginequick/doc/src/qwebengine-licensing.qdoc
index f6a0a6c32..f6a0a6c32 100644
--- a/src/webengine/doc/src/qwebengine-licensing.qdoc
+++ b/src/webenginequick/doc/src/qwebengine-licensing.qdoc
diff --git a/src/webenginequick/doc/src/register_protocol_handler_request.qdoc b/src/webenginequick/doc/src/register_protocol_handler_request.qdoc
new file mode 100644
index 000000000..b3ebcb31b
--- /dev/null
+++ b/src/webenginequick/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/webenginequick/doc/src/webengine_certificate_error.qdoc
index 6d50ea851..8c032dc8b 100644
--- a/src/webengine/api/qquickwebenginecertificateerror.cpp
+++ b/src/webenginequick/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,64 +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);
-
- if (d->answered)
- return;
-
- 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);
-
- if (d->answered)
- return;
-
- 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
@@ -211,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/webenginequick/doc/src/webengine_download_request.qdoc b/src/webenginequick/doc/src/webengine_download_request.qdoc
new file mode 100644
index 000000000..2b96ec45b
--- /dev/null
+++ b/src/webenginequick/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/webenginequick/doc/src/webengineview_lgpl.qdoc
index 0cd8441cf..2be475903 100644
--- a/src/webengine/doc/src/webengineview_lgpl.qdoc
+++ b/src/webenginequick/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/webenginequick/module.pro
index 49a1086b2..7b494bb5b 100644
--- a/src/webengine/module.pro
+++ b/src/webenginequick/module.pro
@@ -1,8 +1,8 @@
-include($$QTWEBENGINE_OUT_ROOT/src/webengine/qtwebengine-config.pri)
-QT_FOR_CONFIG += webengine-private
+include($$QTWEBENGINE_OUT_ROOT/src/webenginequick/qtwebenginequick-config.pri)
+QT_FOR_CONFIG += webenginequick-private webenginecore-private
-TARGET = QtWebEngine
-MODULE = webengine
+TARGET = QtWebEngineQuick
+MODULE = webenginequick
# For our export macros
DEFINES += QT_BUILD_WEBENGINE_LIB
@@ -16,23 +16,19 @@ 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 \
api/qquickwebenginenavigationrequest.cpp \
api/qquickwebenginenewviewrequest.cpp \
api/qquickwebengineprofile.cpp \
- api/qquickwebenginescript.cpp \
api/qquickwebenginesettings.cpp \
api/qquickwebenginesingleton.cpp \
api/qquickwebenginetouchhandleprovider.cpp \
api/qquickwebengineview.cpp \
api/qtwebengineglobal.cpp \
+ api/qquickwebenginescriptcollection.cpp \
render_widget_host_view_qt_delegate_quick.cpp \
render_widget_host_view_qt_delegate_quickwindow.cpp \
ui_delegates_manager.cpp
@@ -42,31 +38,25 @@ 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 \
api/qquickwebenginenavigationrequest_p.h \
api/qquickwebenginenewviewrequest_p.h \
api/qquickwebengineprofile.h \
api/qquickwebengineprofile_p.h \
- api/qquickwebenginescript.h \
- api/qquickwebenginescript_p.h \
api/qquickwebenginesettings_p.h \
api/qquickwebenginesingleton_p.h \
api/qquickwebenginetouchhandleprovider_p_p.h \
api/qquickwebengineview_p.h \
api/qquickwebengineview_p_p.h \
+ api/qquickwebenginescriptcollection.h \
render_widget_host_view_qt_delegate_quick.h \
render_widget_host_view_qt_delegate_quickwindow.h \
ui_delegates_manager.h
-qtConfig(webengine-testsupport) {
+qtConfig(webenginequick-testsupport) {
QT_PRIVATE += testlib
SOURCES += api/qquickwebenginetestsupport.cpp
HEADERS += api/qquickwebenginetestsupport_p.h
diff --git a/src/webengine/plugin/dependencies.json b/src/webenginequick/plugin/dependencies.json
index ef26b3617..ef26b3617 100644
--- a/src/webengine/plugin/dependencies.json
+++ b/src/webenginequick/plugin/dependencies.json
diff --git a/src/webengine/plugin/plugin.cpp b/src/webenginequick/plugin/plugin.cpp
index a74373b23..ead71694b 100644
--- a/src/webengine/plugin/plugin.cpp
+++ b/src/webenginequick/plugin/plugin.cpp
@@ -38,27 +38,29 @@
****************************************************************************/
#include <QtQml/qqmlextensionplugin.h>
-#include <QtWebEngine/QQuickWebEngineProfile>
+#include <QtWebEngineQuick/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>
-#include <QtWebEngine/private/qquickwebenginenavigationrequest_p.h>
-#include <QtWebEngine/private/qquickwebenginenewviewrequest_p.h>
-#include <QtWebEngine/private/qquickwebenginesettings_p.h>
-#include <QtWebEngine/private/qquickwebenginesingleton_p.h>
-#include <QtWebEngine/private/qquickwebenginetouchhandleprovider_p_p.h>
-#include <QtWebEngine/private/qquickwebengineview_p.h>
-#include <QtWebEngine/private/qquickwebengineaction_p.h>
+#include <QtWebEngineQuick/private/qquickwebengineclientcertificateselection_p.h>
+#include <QtWebEngineQuick/private/qquickwebenginedialogrequests_p.h>
+#include <QtWebEngineQuick/private/qquickwebenginehistory_p.h>
+#include <QtWebEngineQuick/private/qquickwebenginefaviconprovider_p_p.h>
+#include <QtWebEngineQuick/private/qquickwebenginenavigationrequest_p.h>
+#include <QtWebEngineQuick/private/qquickwebenginenewviewrequest_p.h>
+#include <QtWebEngineQuick/private/qquickwebenginesettings_p.h>
+#include <QtWebEngineQuick/private/qquickwebenginesingleton_p.h>
+#include <QtWebEngineQuick/private/qquickwebenginetouchhandleprovider_p_p.h>
+#include <QtWebEngineQuick/private/qquickwebengineview_p.h>
+#include <QtWebEngineQuick/private/qquickwebengineaction_p.h>
+#include <QtWebEngineCore/qwebenginecertificateerror.h>
#include <QtWebEngineCore/qwebenginefindtextresult.h>
+#include <QtWebEngineCore/qwebenginefullscreenrequest.h>
+#include <QtWebEngineCore/qwebengineloadrequest.h>
#include <QtWebEngineCore/qwebenginenotification.h>
#include <QtWebEngineCore/qwebenginequotarequest.h>
#include <QtWebEngineCore/qwebengineregisterprotocolhandlerrequest.h>
+#include <QtWebEngineCore/qwebenginecontextmenurequest.h>
+#include <QtWebEngineCore/qwebenginedownloadrequest.h>
+#include <QtWebEngineCore/qwebenginescript.h>
QT_BEGIN_NAMESPACE
@@ -84,7 +86,7 @@ public:
Q_ASSERT(QLatin1String(uri) == QLatin1String("QtWebEngine"));
qmlRegisterType<QQuickWebEngineView>(uri, 1, 0, "WebEngineView");
- qmlRegisterUncreatableType<QQuickWebEngineLoadRequest>(uri, 1, 0, "WebEngineLoadRequest", msgUncreatableType("WebEngineLoadRequest"));
+ qmlRegisterUncreatableType<QWebEngineLoadRequest>(uri, 1, 0, "WebEngineLoadRequest", msgUncreatableType("WebEngineLoadRequest"));
qmlRegisterUncreatableType<QQuickWebEngineNavigationRequest>(uri, 1, 0, "WebEngineNavigationRequest", msgUncreatableType("WebEngineNavigationRequest"));
qmlRegisterType<QQuickWebEngineView, 1>(uri, 1, 1, "WebEngineView");
@@ -104,26 +106,13 @@ public:
qmlRegisterType<QQuickWebEngineProfile, 3>(uri, 1, 4, "WebEngineProfile");
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<QWebEngineScript>();
+ qmlRegisterUncreatableType<QWebEngineScript>(
+ uri, 1, 1, "WebEngineScript", msgUncreatableType("WebEngineScript")); // for enums
+ 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"));
@@ -141,13 +130,11 @@ public:
qmlRegisterUncreatableType<QQuickWebEngineHistory, 1>(uri, 1, 11, "NavigationHistory", msgUncreatableType("NavigationHistory"));
qmlRegisterUncreatableType<QQuickWebEngineHistoryListModel>(uri, 1, 1, "NavigationHistoryListModel",
msgUncreatableType("NavigationHistory"));
- qmlRegisterUncreatableType<QQuickWebEngineFullScreenRequest>(uri, 1, 1, "FullScreenRequest",
+ qmlRegisterUncreatableType<QWebEngineFullScreenRequest>(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/plugin.pro b/src/webenginequick/plugin/plugin.pro
index 3b30bece2..236f199a2 100644
--- a/src/webengine/plugin/plugin.pro
+++ b/src/webenginequick/plugin/plugin.pro
@@ -4,7 +4,7 @@ TARGETPATH = QtWebEngine
IMPORT_VERSION = 1.10
QT += qml quick
-QT_PRIVATE += core-private webenginecore-private webengine-private
+QT_PRIVATE += core-private webenginecore-private webenginequick-private
SOURCES = plugin.cpp
diff --git a/src/webengine/plugin/plugins.qmltypes b/src/webenginequick/plugin/plugins.qmltypes
index 24b073290..6c96e2678 100644
--- a/src/webengine/plugin/plugins.qmltypes
+++ b/src/webenginequick/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]
@@ -703,7 +702,7 @@ Module {
Method { name: "dialogReject" }
}
Component {
- name: "QQuickWebEngineLoadRequest"
+ name: "QWebEngineLoadRequest"
prototype: "QObject"
exports: ["QtWebEngine/WebEngineLoadRequest 1.0"]
isCreatable: false
@@ -1351,7 +1350,7 @@ Module {
Property { name: "renderProcessId"; revision: 11; type: "qint64"; isReadonly: true }
Signal {
name: "loadingChanged"
- Parameter { name: "loadRequest"; type: "QQuickWebEngineLoadRequest"; isPointer: true }
+ Parameter { name: "loadRequest"; type: "QWebEngineLoadRequest" }
}
Signal {
name: "linkHovered"
@@ -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/plugin/qmldir b/src/webenginequick/plugin/qmldir
index 8970dc9c1..8970dc9c1 100644
--- a/src/webengine/plugin/qmldir
+++ b/src/webenginequick/plugin/qmldir
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp b/src/webenginequick/render_widget_host_view_qt_delegate_quick.cpp
index e729f7532..38d787bd4 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
+++ b/src/webenginequick/render_widget_host_view_qt_delegate_quick.cpp
@@ -39,11 +39,14 @@
#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 <QQuickWindow>
+#include <QSGImageNode>
#include <QVariant>
#include <QWindow>
@@ -65,29 +68,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);
}
@@ -165,19 +151,10 @@ QWindow* RenderWidgetHostViewQtDelegateQuick::window() const
return QQuickItem::window();
}
-QSGTexture *RenderWidgetHostViewQtDelegateQuick::createTextureFromImage(const QImage &image)
-{
- return QQuickItem::window()->createTextureFromImage(image, QQuickWindow::TextureCanUseAtlas);
-}
-
-QSGImageNode *RenderWidgetHostViewQtDelegateQuick::createImageNode()
-{
- return QQuickItem::window()->createImageNode();
-}
-
-void RenderWidgetHostViewQtDelegateQuick::update()
+void RenderWidgetHostViewQtDelegateQuick::readyToSwap()
{
- QQuickItem::update();
+ // Call update() on UI thread.
+ QMetaObject::invokeMethod(this, &QQuickItem::update, Qt::QueuedConnection);
}
void RenderWidgetHostViewQtDelegateQuick::updateCursor(const QCursor &cursor)
@@ -296,7 +273,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;
}
@@ -318,9 +296,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();
}
@@ -332,6 +310,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)
@@ -346,7 +326,54 @@ 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(QNativeInterface::QSGOpenGLTexture::fromNative(texId, win, texSize, texOpts));
+ node->setTextureCoordinatesTransform(QSGImageNode::MirrorVertically);
+ } else {
+ Q_UNREACHABLE();
+ }
+
+#if QT_CONFIG(webenginequick_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()
@@ -360,15 +387,10 @@ void RenderWidgetHostViewQtDelegateQuick::onHide()
m_client->forwardEvent(&event);
}
-bool RenderWidgetHostViewQtDelegateQuick::copySurface(const QRect &rect, const QSize &size, QImage &image)
+void RenderWidgetHostViewQtDelegateQuick::adapterClientChanged(WebContentsAdapterClient *client)
{
- 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;
+ QQuickWebEngineViewPrivate::bindViewAndWidget(
+ static_cast<QQuickWebEngineViewPrivate *>(client)->q_func(), this);
}
#if QT_CONFIG(accessibility)
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.h b/src/webenginequick/render_widget_host_view_qt_delegate_quick.h
index 86ee5fedd..015b9cdf4 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quick.h
+++ b/src/webenginequick/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,9 +76,6 @@ public:
void hide() override;
bool isVisible() const override;
QWindow* window() const override;
- QSGTexture *createTextureFromImage(const QImage &) override;
- QSGImageNode *createImageNode() override;
- void update() override;
void updateCursor(const QCursor &) override;
void resize(int width, int height) override;
void move(const QPoint&) override { }
@@ -81,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;
+ void adapterClientChanged(WebContentsAdapterClient *client) override;
protected:
bool event(QEvent *event) override;
@@ -98,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/webenginequick/render_widget_host_view_qt_delegate_quickwindow.cpp
index e16ebd9ab..c6d866033 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp
+++ b/src/webenginequick/render_widget_host_view_qt_delegate_quickwindow.cpp
@@ -113,22 +113,6 @@ QWindow *RenderWidgetHostViewQtDelegateQuickWindow::window() const
return const_cast<RenderWidgetHostViewQtDelegateQuickWindow*>(this);
}
-QSGTexture *RenderWidgetHostViewQtDelegateQuickWindow::createTextureFromImage(const QImage &image)
-{
- return m_realDelegate->createTextureFromImage(image);
-}
-
-QSGImageNode *RenderWidgetHostViewQtDelegateQuickWindow::createImageNode()
-{
- return m_realDelegate->createImageNode();
-}
-
-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/webenginequick/render_widget_host_view_qt_delegate_quickwindow.h
index 555e56484..632c59fa5 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h
+++ b/src/webenginequick/render_widget_host_view_qt_delegate_quickwindow.h
@@ -67,17 +67,13 @@ public:
void hide() override;
bool isVisible() const override;
QWindow* window() const override;
- QSGTexture *createTextureFromImage(const QImage &) override;
- QSGImageNode *createImageNode() 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 adapterClientChanged(WebContentsAdapterClient *) override { }
void setVirtualParent(QQuickItem *virtualParent);
private:
diff --git a/src/webengine/testsupport/plugin.cpp b/src/webenginequick/testsupport/plugin.cpp
index 828110207..087cd2919 100644
--- a/src/webengine/testsupport/plugin.cpp
+++ b/src/webenginequick/testsupport/plugin.cpp
@@ -39,7 +39,7 @@
#include <QtQml>
-#include <QtWebEngine/private/qquickwebenginetestsupport_p.h>
+#include <QtWebEngineQuick/private/qquickwebenginetestsupport_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/webengine/testsupport/plugins.qmltypes b/src/webenginequick/testsupport/plugins.qmltypes
index 12c763724..d371e1af6 100644
--- a/src/webengine/testsupport/plugins.qmltypes
+++ b/src/webenginequick/testsupport/plugins.qmltypes
@@ -17,7 +17,7 @@ Module {
exportMetaObjectRevisions: [0]
Signal {
name: "loadingChanged"
- Parameter { name: "loadRequest"; type: "QQuickWebEngineLoadRequest"; isPointer: true }
+ Parameter { name: "loadRequest"; type: "QWebEngineLoadRequest"; isPointer: true }
}
}
Component {
diff --git a/src/webengine/testsupport/qmldir b/src/webenginequick/testsupport/qmldir
index 7fff80251..7fff80251 100644
--- a/src/webengine/testsupport/qmldir
+++ b/src/webenginequick/testsupport/qmldir
diff --git a/src/webengine/testsupport/testsupport.pro b/src/webenginequick/testsupport/testsupport.pro
index a24796675..891bcb618 100644
--- a/src/webengine/testsupport/testsupport.pro
+++ b/src/webenginequick/testsupport/testsupport.pro
@@ -4,7 +4,7 @@ TARGETPATH = QtWebEngine/testsupport
IMPORT_VERSION = 1.0
QT += qml quick
-QT_PRIVATE += webengine-private gui-private
+QT_PRIVATE += webenginequick-private gui-private
SOURCES = plugin.cpp
diff --git a/src/webengine/ui/AlertDialog.qml b/src/webenginequick/ui/AlertDialog.qml
index 07f2d7df5..07f2d7df5 100644
--- a/src/webengine/ui/AlertDialog.qml
+++ b/src/webenginequick/ui/AlertDialog.qml
diff --git a/src/webengine/ui/AuthenticationDialog.qml b/src/webenginequick/ui/AuthenticationDialog.qml
index a7eedd14d..a7eedd14d 100644
--- a/src/webengine/ui/AuthenticationDialog.qml
+++ b/src/webenginequick/ui/AuthenticationDialog.qml
diff --git a/src/webengine/ui/ColorDialog.qml b/src/webenginequick/ui/ColorDialog.qml
index b74fd2cd7..b74fd2cd7 100644
--- a/src/webengine/ui/ColorDialog.qml
+++ b/src/webenginequick/ui/ColorDialog.qml
diff --git a/src/webengine/ui/ConfirmDialog.qml b/src/webenginequick/ui/ConfirmDialog.qml
index aab4db04a..aab4db04a 100644
--- a/src/webengine/ui/ConfirmDialog.qml
+++ b/src/webenginequick/ui/ConfirmDialog.qml
diff --git a/src/webengine/ui/FilePicker.qml b/src/webenginequick/ui/FilePicker.qml
index e6af977ba..e6af977ba 100644
--- a/src/webengine/ui/FilePicker.qml
+++ b/src/webenginequick/ui/FilePicker.qml
diff --git a/src/webengine/ui/Menu.qml b/src/webenginequick/ui/Menu.qml
index 36efa7680..36efa7680 100644
--- a/src/webengine/ui/Menu.qml
+++ b/src/webenginequick/ui/Menu.qml
diff --git a/src/webengine/ui/MenuItem.qml b/src/webenginequick/ui/MenuItem.qml
index e61f4c230..e61f4c230 100644
--- a/src/webengine/ui/MenuItem.qml
+++ b/src/webenginequick/ui/MenuItem.qml
diff --git a/src/webengine/ui/MenuSeparator.qml b/src/webenginequick/ui/MenuSeparator.qml
index 8427865cb..8427865cb 100644
--- a/src/webengine/ui/MenuSeparator.qml
+++ b/src/webenginequick/ui/MenuSeparator.qml
diff --git a/src/webengine/ui/PromptDialog.qml b/src/webenginequick/ui/PromptDialog.qml
index c4dcd6b98..c4dcd6b98 100644
--- a/src/webengine/ui/PromptDialog.qml
+++ b/src/webenginequick/ui/PromptDialog.qml
diff --git a/src/webengine/ui/ToolTip.qml b/src/webenginequick/ui/ToolTip.qml
index 2bfe9eaf5..2bfe9eaf5 100644
--- a/src/webengine/ui/ToolTip.qml
+++ b/src/webenginequick/ui/ToolTip.qml
diff --git a/src/webengine/ui/TouchHandle.qml b/src/webenginequick/ui/TouchHandle.qml
index 76a93829e..76a93829e 100644
--- a/src/webengine/ui/TouchHandle.qml
+++ b/src/webenginequick/ui/TouchHandle.qml
diff --git a/src/webengine/ui/TouchSelectionMenu.qml b/src/webenginequick/ui/TouchSelectionMenu.qml
index 7cf16b554..7cf16b554 100644
--- a/src/webengine/ui/TouchSelectionMenu.qml
+++ b/src/webenginequick/ui/TouchSelectionMenu.qml
diff --git a/src/webengine/ui/qmldir b/src/webenginequick/ui/qmldir
index e23b972be..e23b972be 100644
--- a/src/webengine/ui/qmldir
+++ b/src/webenginequick/ui/qmldir
diff --git a/src/webengine/ui/ui.pro b/src/webenginequick/ui/ui.pro
index 69f754e0c..69f754e0c 100644
--- a/src/webengine/ui/ui.pro
+++ b/src/webenginequick/ui/ui.pro
diff --git a/src/webengine/ui2/AlertDialog.qml b/src/webenginequick/ui2/AlertDialog.qml
index 4f63c5b70..4f63c5b70 100644
--- a/src/webengine/ui2/AlertDialog.qml
+++ b/src/webenginequick/ui2/AlertDialog.qml
diff --git a/src/webengine/ui2/AuthenticationDialog.qml b/src/webenginequick/ui2/AuthenticationDialog.qml
index 52fcce3f1..52fcce3f1 100644
--- a/src/webengine/ui2/AuthenticationDialog.qml
+++ b/src/webenginequick/ui2/AuthenticationDialog.qml
diff --git a/src/webengine/ui2/ConfirmDialog.qml b/src/webenginequick/ui2/ConfirmDialog.qml
index 0649d3654..0649d3654 100644
--- a/src/webengine/ui2/ConfirmDialog.qml
+++ b/src/webenginequick/ui2/ConfirmDialog.qml
diff --git a/src/webengine/ui2/Menu.qml b/src/webenginequick/ui2/Menu.qml
index 0e7b869f5..0e7b869f5 100644
--- a/src/webengine/ui2/Menu.qml
+++ b/src/webenginequick/ui2/Menu.qml
diff --git a/src/webengine/ui2/MenuItem.qml b/src/webenginequick/ui2/MenuItem.qml
index 9bf8aac5e..9bf8aac5e 100644
--- a/src/webengine/ui2/MenuItem.qml
+++ b/src/webenginequick/ui2/MenuItem.qml
diff --git a/src/webengine/ui2/MenuSeparator.qml b/src/webenginequick/ui2/MenuSeparator.qml
index 0c664084a..0c664084a 100644
--- a/src/webengine/ui2/MenuSeparator.qml
+++ b/src/webenginequick/ui2/MenuSeparator.qml
diff --git a/src/webengine/ui2/PromptDialog.qml b/src/webenginequick/ui2/PromptDialog.qml
index 880213e36..880213e36 100644
--- a/src/webengine/ui2/PromptDialog.qml
+++ b/src/webenginequick/ui2/PromptDialog.qml
diff --git a/src/webengine/ui2/ToolTip.qml b/src/webenginequick/ui2/ToolTip.qml
index 91645a0f4..91645a0f4 100644
--- a/src/webengine/ui2/ToolTip.qml
+++ b/src/webenginequick/ui2/ToolTip.qml
diff --git a/src/webengine/ui2/information.png b/src/webenginequick/ui2/information.png
index 0a2eb87d1..0a2eb87d1 100644
--- a/src/webengine/ui2/information.png
+++ b/src/webenginequick/ui2/information.png
Binary files differ
diff --git a/src/webengine/ui2/qmldir b/src/webenginequick/ui2/qmldir
index 8ab0d3671..8ab0d3671 100644
--- a/src/webengine/ui2/qmldir
+++ b/src/webenginequick/ui2/qmldir
diff --git a/src/webengine/ui2/question.png b/src/webenginequick/ui2/question.png
index 2dd92fd79..2dd92fd79 100644
--- a/src/webengine/ui2/question.png
+++ b/src/webenginequick/ui2/question.png
Binary files differ
diff --git a/src/webengine/ui2/ui2.pro b/src/webenginequick/ui2/ui2.pro
index 4628d40b5..4628d40b5 100644
--- a/src/webengine/ui2/ui2.pro
+++ b/src/webenginequick/ui2/ui2.pro
diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webenginequick/ui_delegates_manager.cpp
index 756b3429e..756b3429e 100644
--- a/src/webengine/ui_delegates_manager.cpp
+++ b/src/webenginequick/ui_delegates_manager.cpp
diff --git a/src/webengine/ui_delegates_manager.h b/src/webenginequick/ui_delegates_manager.h
index 4b6e291b2..4b6e291b2 100644
--- a/src/webengine/ui_delegates_manager.h
+++ b/src/webenginequick/ui_delegates_manager.h
diff --git a/src/webengine/webengine.pro b/src/webenginequick/webenginequick.pro
index 23668229e..fe27ee089 100644
--- a/src/webengine/webengine.pro
+++ b/src/webenginequick/webenginequick.pro
@@ -7,13 +7,13 @@ qml_plugin.depends = qml_module
SUBDIRS += qml_module qml_plugin
-qtConfig(webengine-testsupport) {
+qtConfig(webenginequick-testsupport) {
testsupport_plugin.file = testsupport/testsupport.pro
testsupport_plugin.depends = qml_module
SUBDIRS += testsupport_plugin
}
-qtConfig(webengine-ui-delegates) {
+qtConfig(webenginequick-ui-delegates) {
SUBDIRS += ui \
ui2
}
diff --git a/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp b/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp
deleted file mode 100644
index 5949f3d6e..000000000
--- a/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp
+++ /dev/null
@@ -1,75 +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 "qtwebenginewidgetsglobal.h"
-
-#include <QCoreApplication>
-#include <QOpenGLContext>
-
-namespace QtWebEngineCore
-{
- extern void initialize();
-}
-
-QT_BEGIN_NAMESPACE
-
-#if QT_CONFIG(opengl)
-Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();
-#endif
-
-static void initialize()
-{
-#if QT_CONFIG(opengl)
- if (QCoreApplication::instance()) {
- //On window/ANGLE, calling QtWebEngine::initialize from DllMain will result in a crash.
- if (!qt_gl_global_share_context()) {
- qWarning("Qt WebEngine seems to be initialized from a plugin. Please "
- "set Qt::AA_ShareOpenGLContexts using QCoreApplication::setAttribute "
- "before constructing QGuiApplication.");
- }
- return;
- }
- //QCoreApplication is not yet instantiated, ensuring the call will be deferred
- qAddPreRoutine(QtWebEngineCore::initialize);
-#endif // QT_CONFIG(opengl)
-}
-
-Q_CONSTRUCTOR_FUNCTION(initialize)
-
-QT_END_NAMESPACE
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/qwebenginesettings.cpp b/src/webenginewidgets/api/qwebenginesettings.cpp
deleted file mode 100644
index d9fb3b000..000000000
--- a/src/webenginewidgets/api/qwebenginesettings.cpp
+++ /dev/null
@@ -1,254 +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 "qwebenginesettings.h"
-
-#include "qwebengineprofile.h"
-#include "web_engine_settings.h"
-
-QT_BEGIN_NAMESPACE
-
-using QtWebEngineCore::WebEngineSettings;
-
-static WebEngineSettings::Attribute toWebEngineAttribute(QWebEngineSettings::WebAttribute attribute)
-{
- switch (attribute) {
- case QWebEngineSettings::AutoLoadImages:
- return WebEngineSettings::AutoLoadImages;
- case QWebEngineSettings::JavascriptEnabled:
- return WebEngineSettings::JavascriptEnabled;
- case QWebEngineSettings::JavascriptCanOpenWindows:
- return WebEngineSettings::JavascriptCanOpenWindows;
- case QWebEngineSettings::JavascriptCanAccessClipboard:
- return WebEngineSettings::JavascriptCanAccessClipboard;
- case QWebEngineSettings::LinksIncludedInFocusChain:
- return WebEngineSettings::LinksIncludedInFocusChain;
- case QWebEngineSettings::LocalStorageEnabled:
- return WebEngineSettings::LocalStorageEnabled;
- case QWebEngineSettings::LocalContentCanAccessRemoteUrls:
- return WebEngineSettings::LocalContentCanAccessRemoteUrls;
- case QWebEngineSettings::XSSAuditingEnabled:
- return WebEngineSettings::XSSAuditingEnabled;
- case QWebEngineSettings::SpatialNavigationEnabled:
- return WebEngineSettings::SpatialNavigationEnabled;
- case QWebEngineSettings::LocalContentCanAccessFileUrls:
- return WebEngineSettings::LocalContentCanAccessFileUrls;
- case QWebEngineSettings::HyperlinkAuditingEnabled:
- return WebEngineSettings::HyperlinkAuditingEnabled;
- case QWebEngineSettings::ScrollAnimatorEnabled:
- return WebEngineSettings::ScrollAnimatorEnabled;
- case QWebEngineSettings::ErrorPageEnabled:
- return WebEngineSettings::ErrorPageEnabled;
- case QWebEngineSettings::PluginsEnabled:
- return WebEngineSettings::PluginsEnabled;
- case QWebEngineSettings::FullScreenSupportEnabled:
- return WebEngineSettings::FullScreenSupportEnabled;
- case QWebEngineSettings::ScreenCaptureEnabled:
- return WebEngineSettings::ScreenCaptureEnabled;
- case QWebEngineSettings::WebGLEnabled:
- return WebEngineSettings::WebGLEnabled;
- case QWebEngineSettings::Accelerated2dCanvasEnabled:
- return WebEngineSettings::Accelerated2dCanvasEnabled;
- case QWebEngineSettings::AutoLoadIconsForPage:
- return WebEngineSettings::AutoLoadIconsForPage;
- case QWebEngineSettings::TouchIconsEnabled:
- return WebEngineSettings::TouchIconsEnabled;
- case QWebEngineSettings::FocusOnNavigationEnabled:
- return WebEngineSettings::FocusOnNavigationEnabled;
- case QWebEngineSettings::PrintElementBackgrounds:
- return WebEngineSettings::PrintElementBackgrounds;
- case QWebEngineSettings::AllowRunningInsecureContent:
- return WebEngineSettings::AllowRunningInsecureContent;
- case QWebEngineSettings::AllowGeolocationOnInsecureOrigins:
- return WebEngineSettings::AllowGeolocationOnInsecureOrigins;
- case QWebEngineSettings::AllowWindowActivationFromJavaScript:
- return WebEngineSettings::AllowWindowActivationFromJavaScript;
- case QWebEngineSettings::ShowScrollBars:
- return WebEngineSettings::ShowScrollBars;
- case QWebEngineSettings::PlaybackRequiresUserGesture:
- return WebEngineSettings::PlaybackRequiresUserGesture;
- case QWebEngineSettings::WebRTCPublicInterfacesOnly:
- return WebEngineSettings::WebRTCPublicInterfacesOnly;
- case QWebEngineSettings::JavascriptCanPaste:
- return WebEngineSettings::JavascriptCanPaste;
- case QWebEngineSettings::DnsPrefetchEnabled:
- return WebEngineSettings::DnsPrefetchEnabled;
- case QWebEngineSettings::PdfViewerEnabled:
- return WebEngineSettings::PdfViewerEnabled;
- default:
- return WebEngineSettings::UnsupportedInCoreSettings;
- }
-}
-
-QWebEngineSettings::QWebEngineSettings(QWebEngineSettings *parentSettings)
- : d_ptr(new WebEngineSettings(parentSettings ? parentSettings->d_func() : 0))
-{
- Q_D(QWebEngineSettings);
- d->scheduleApplyRecursively();
-}
-
-QWebEngineSettings::~QWebEngineSettings()
-{
-}
-
-#if QT_DEPRECATED_SINCE(5, 5)
-QWebEngineSettings *QWebEngineSettings::globalSettings()
-{
- return defaultSettings();
-}
-#endif
-
-/*!
- Returns the settings for a web engine page that belongs to the default
- profile. All web pages not specifically created with another profile belong
- to the default profile.
-*/
-QWebEngineSettings *QWebEngineSettings::defaultSettings()
-{
- return QWebEngineProfile::defaultProfile()->settings();
-}
-
-ASSERT_ENUMS_MATCH(WebEngineSettings::StandardFont, QWebEngineSettings::StandardFont)
-ASSERT_ENUMS_MATCH(WebEngineSettings::FixedFont, QWebEngineSettings::FixedFont)
-ASSERT_ENUMS_MATCH(WebEngineSettings::SerifFont, QWebEngineSettings::SerifFont)
-ASSERT_ENUMS_MATCH(WebEngineSettings::SansSerifFont, QWebEngineSettings::SansSerifFont)
-ASSERT_ENUMS_MATCH(WebEngineSettings::CursiveFont, QWebEngineSettings::CursiveFont)
-ASSERT_ENUMS_MATCH(WebEngineSettings::FantasyFont, QWebEngineSettings::FantasyFont)
-ASSERT_ENUMS_MATCH(WebEngineSettings::PictographFont, QWebEngineSettings::PictographFont)
-
-void QWebEngineSettings::setFontFamily(QWebEngineSettings::FontFamily which, const QString &family)
-{
- Q_D(QWebEngineSettings);
- d->setFontFamily(static_cast<WebEngineSettings::FontFamily>(which), family);
-}
-
-QString QWebEngineSettings::fontFamily(QWebEngineSettings::FontFamily which) const
-{
- return d_ptr->fontFamily(static_cast<WebEngineSettings::FontFamily>(which));
-}
-
-void QWebEngineSettings::resetFontFamily(QWebEngineSettings::FontFamily which)
-{
- d_ptr->resetFontFamily(static_cast<WebEngineSettings::FontFamily>(which));
-}
-
-ASSERT_ENUMS_MATCH(WebEngineSettings::DefaultFixedFontSize, QWebEngineSettings::DefaultFixedFontSize)
-ASSERT_ENUMS_MATCH(WebEngineSettings::DefaultFontSize, QWebEngineSettings::DefaultFontSize)
-ASSERT_ENUMS_MATCH(WebEngineSettings::MinimumFontSize, QWebEngineSettings::MinimumFontSize)
-ASSERT_ENUMS_MATCH(WebEngineSettings::MinimumLogicalFontSize, QWebEngineSettings::MinimumLogicalFontSize)
-
-void QWebEngineSettings::setFontSize(QWebEngineSettings::FontSize type, int size)
-{
- Q_D(QWebEngineSettings);
- d->setFontSize(static_cast<WebEngineSettings::FontSize>(type), size);
-}
-
-int QWebEngineSettings::fontSize(QWebEngineSettings::FontSize type) const
-{
- Q_D(const QWebEngineSettings);
- return d->fontSize(static_cast<WebEngineSettings::FontSize>(type));
-}
-
-void QWebEngineSettings::resetFontSize(QWebEngineSettings::FontSize type)
-{
- Q_D(QWebEngineSettings);
- d->resetFontSize(static_cast<WebEngineSettings::FontSize>(type));
-}
-
-void QWebEngineSettings::setDefaultTextEncoding(const QString &encoding)
-{
- Q_D(QWebEngineSettings);
- d->setDefaultTextEncoding(encoding);
-}
-
-QString QWebEngineSettings::defaultTextEncoding() const
-{
- Q_D(const QWebEngineSettings);
- return d->defaultTextEncoding();
-}
-
-ASSERT_ENUMS_MATCH(WebEngineSettings::DisallowUnknownUrlSchemes, QWebEngineSettings::DisallowUnknownUrlSchemes)
-ASSERT_ENUMS_MATCH(WebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction, QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction)
-ASSERT_ENUMS_MATCH(WebEngineSettings::AllowAllUnknownUrlSchemes, QWebEngineSettings::AllowAllUnknownUrlSchemes)
-
-QWebEngineSettings::UnknownUrlSchemePolicy QWebEngineSettings::unknownUrlSchemePolicy() const
-{
- Q_D(const QWebEngineSettings);
- WebEngineSettings::UnknownUrlSchemePolicy result = d->unknownUrlSchemePolicy();
- Q_ASSERT(result != WebEngineSettings::InheritedUnknownUrlSchemePolicy);
- return static_cast<QWebEngineSettings::UnknownUrlSchemePolicy>(result);
-}
-
-void QWebEngineSettings::setUnknownUrlSchemePolicy(QWebEngineSettings::UnknownUrlSchemePolicy policy)
-{
- Q_D(QWebEngineSettings);
- d->setUnknownUrlSchemePolicy(static_cast<WebEngineSettings::UnknownUrlSchemePolicy>(policy));
-}
-
-void QWebEngineSettings::resetUnknownUrlSchemePolicy()
-{
- Q_D(QWebEngineSettings);
- d->setUnknownUrlSchemePolicy(WebEngineSettings::InheritedUnknownUrlSchemePolicy);
-}
-
-void QWebEngineSettings::setAttribute(QWebEngineSettings::WebAttribute attr, bool on)
-{
- Q_D(QWebEngineSettings);
- WebEngineSettings::Attribute webEngineAttribute = toWebEngineAttribute(attr);
- Q_ASSERT(webEngineAttribute != WebEngineSettings::UnsupportedInCoreSettings);
- d->setAttribute(webEngineAttribute, on);
-}
-
-bool QWebEngineSettings::testAttribute(QWebEngineSettings::WebAttribute attr) const
-{
- Q_D(const QWebEngineSettings);
- WebEngineSettings::Attribute webEngineAttribute = toWebEngineAttribute(attr);
- Q_ASSERT(webEngineAttribute != WebEngineSettings::UnsupportedInCoreSettings);
- return d->testAttribute(webEngineAttribute);
-}
-
-void QWebEngineSettings::resetAttribute(QWebEngineSettings::WebAttribute attr)
-{
- Q_D(QWebEngineSettings);
- WebEngineSettings::Attribute webEngineAttribute = toWebEngineAttribute(attr);
- Q_ASSERT(webEngineAttribute != WebEngineSettings::UnsupportedInCoreSettings);
- d->resetAttribute(webEngineAttribute);
-}
-
-QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebengineview.cpp b/src/webenginewidgets/api/qwebengineview.cpp
index b1346f65e..f929a2691 100644
--- a/src/webenginewidgets/api/qwebengineview.cpp
+++ b/src/webenginewidgets/api/qwebengineview.cpp
@@ -41,9 +41,13 @@
#include "qwebengineview_p.h"
#include "qwebenginepage_p.h"
+#include "qwebengineprofile.h"
#include "render_widget_host_view_qt_delegate_widget.h"
#include "web_contents_adapter.h"
-
+#include "file_picker_controller.h"
+#include "qwebenginenotificationpresenter_p.h"
+#include "color_chooser_controller.h"
+#include <QStandardPaths>
#if QT_CONFIG(action)
#include <QAction>
#endif
@@ -53,6 +57,28 @@
#include <QContextMenuEvent>
#include <QToolTip>
#include <QVBoxLayout>
+#if QT_CONFIG(colordialog)
+# include <QColorDialog>
+#endif
+#include <QContextMenuEvent>
+#if QT_CONFIG(filedialog)
+# include <QFileDialog>
+#endif
+#include <QKeyEvent>
+#include <QIcon>
+#if QT_CONFIG(inputdialog)
+# include <QInputDialog>
+#endif
+#include <QLayout>
+#include <QLoggingCategory>
+#if QT_CONFIG(menu)
+# include <QMenu>
+#endif
+#if QT_CONFIG(messagebox)
+# include <QMessageBox>
+#endif
+#include <QStyle>
+#include <QGuiApplication>
QT_BEGIN_NAMESPACE
@@ -133,6 +159,182 @@ 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)
+}
+
+QStringList QWebEngineViewPrivate::chooseFiles(QWebEnginePage::FileSelectionMode mode,
+ const QStringList &oldFiles,
+ const QStringList &acceptedMimeTypes)
+{
+#if QT_CONFIG(filedialog)
+ Q_Q(QWebEngineView);
+ const QStringList &filter =
+ QtWebEngineCore::FilePickerController::nameFilters(acceptedMimeTypes);
+ QStringList ret;
+ QString str;
+ switch (static_cast<QtWebEngineCore::FilePickerController::FileChooserMode>(mode)) {
+ case QtWebEngineCore::FilePickerController::OpenMultiple:
+ ret = QFileDialog::getOpenFileNames(q, QString(), QString(),
+ filter.join(QStringLiteral(";;")), nullptr,
+ QFileDialog::HideNameFilterDetails);
+ break;
+ // Chromium extension, not exposed as part of the public API for now.
+ case QtWebEngineCore::FilePickerController::UploadFolder:
+ str = QFileDialog::getExistingDirectory(q, QObject::tr("Select folder to upload"));
+ if (!str.isNull())
+ ret << str;
+ break;
+ case QtWebEngineCore::FilePickerController::Save:
+ str = QFileDialog::getSaveFileName(
+ q, QString(),
+ (QStandardPaths::writableLocation(QStandardPaths::DownloadLocation)
+ + oldFiles.first()));
+ if (!str.isNull())
+ ret << str;
+ break;
+ case QtWebEngineCore::FilePickerController::Open:
+ str = QFileDialog::getOpenFileName(q, QString(), oldFiles.first(),
+ filter.join(QStringLiteral(";;")), nullptr,
+ QFileDialog::HideNameFilterDetails);
+ if (!str.isNull())
+ ret << str;
+ break;
+ }
+ return ret;
+#else
+ Q_UNUSED(mode);
+ Q_UNUSED(oldFiles);
+ Q_UNUSED(acceptedMimeTypes);
+
+ return QStringList();
+#endif // QT_CONFIG(filedialog)
+}
+
+void QWebEngineViewPrivate::showColorDialog(
+ QSharedPointer<QtWebEngineCore::ColorChooserController> controller)
+{
+#if QT_CONFIG(colordialog)
+ Q_Q(QWebEngineView);
+ QColorDialog *dialog = new QColorDialog(controller.data()->initialColor(), q);
+
+ QColorDialog::connect(dialog, SIGNAL(colorSelected(QColor)), controller.data(),
+ SLOT(accept(QColor)));
+ QColorDialog::connect(dialog, SIGNAL(rejected()), controller.data(), SLOT(reject()));
+
+ // Delete when done
+ QColorDialog::connect(dialog, SIGNAL(colorSelected(QColor)), dialog, SLOT(deleteLater()));
+ QColorDialog::connect(dialog, SIGNAL(rejected()), dialog, SLOT(deleteLater()));
+
+ dialog->open();
+#else
+ Q_UNUSED(controller);
+#endif
+}
+
+bool QWebEngineViewPrivate::showAuthorizationDialog(const QString &title, const QString &message)
+{
+#if QT_CONFIG(messagebox)
+ Q_Q(QWebEngineView);
+ return QMessageBox::question(q, title, message, QMessageBox::Yes, QMessageBox::No)
+ == QMessageBox::Yes;
+#else
+ return false;
+#endif // QT_CONFIG(messagebox)
+}
+
+void QWebEngineViewPrivate::javaScriptAlert(const QUrl &url, const QString &msg)
+{
+#if QT_CONFIG(messagebox)
+ Q_Q(QWebEngineView);
+ QMessageBox::information(q, QStringLiteral("Javascript Alert - %1").arg(url.toString()),
+ msg.toHtmlEscaped());
+#else
+ Q_UNUSED(msg);
+#endif // QT_CONFIG(messagebox)
+}
+
+bool QWebEngineViewPrivate::javaScriptConfirm(const QUrl &url, const QString &msg)
+{
+#if QT_CONFIG(messagebox)
+ Q_Q(QWebEngineView);
+ return (QMessageBox::information(q,
+ QStringLiteral("Javascript Confirm - %1").arg(url.toString()),
+ msg.toHtmlEscaped(), QMessageBox::Ok, QMessageBox::Cancel)
+ == QMessageBox::Ok);
+#else
+ Q_UNUSED(msg);
+ return false;
+#endif // QT_CONFIG(messagebox)
+}
+
+bool QWebEngineViewPrivate::javaScriptPrompt(const QUrl &url, const QString &msg,
+ const QString &defaultValue, QString *result)
+{
+#if QT_CONFIG(inputdialog)
+ Q_Q(QWebEngineView);
+ bool ret = false;
+ if (result)
+ *result = QInputDialog::getText(
+ q, QStringLiteral("Javascript Prompt - %1").arg(url.toString()),
+ msg.toHtmlEscaped(), QLineEdit::Normal, defaultValue.toHtmlEscaped(), &ret);
+ return ret;
+#else
+ Q_UNUSED(msg);
+ Q_UNUSED(defaultValue);
+ Q_UNUSED(result);
+ return false;
+#endif // QT_CONFIG(inputdialog)
+}
+
+void QWebEngineViewPrivate::focusContainer()
+{
+ Q_Q(QWebEngineView);
+ q->activateWindow();
+ q->setFocus();
+}
+
+void QWebEngineViewPrivate::unhandledKeyEvent(QKeyEvent *event)
+{
+ Q_Q(QWebEngineView);
+ if (q->parentWidget())
+ QGuiApplication::sendEvent(q->parentWidget(), event);
+}
+
+bool QWebEngineViewPrivate::passOnFocus(bool reverse)
+{
+ Q_Q(QWebEngineView);
+ return q->focusNextPrevChild(!reverse);
+}
+
#ifndef QT_NO_ACCESSIBILITY
static QAccessibleInterface *webAccessibleFactory(const QString &, QObject *object)
{
@@ -143,15 +345,179 @@ 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);
#endif // QT_NO_ACCESSIBILITY
}
+QWebEngineViewPrivate::~QWebEngineViewPrivate() = default;
+
+void QWebEngineViewPrivate::bindPageAndView(QWebEnginePage *page, QWebEngineView *view)
+{
+ QWebEngineViewPrivate *v =
+ page ? static_cast<QWebEngineViewPrivate *>(page->d_func()->view) : nullptr;
+ auto oldView = v ? v->q_func() : nullptr;
+ auto oldPage = view ? view->d_func()->page : nullptr;
+
+ bool ownNewPage = false;
+ bool deleteOldPage = false;
+
+ // Change pointers first.
+
+ if (page && oldView != view) {
+ if (oldView) {
+ ownNewPage = oldView->d_func()->m_ownsPage;
+ oldView->d_func()->page = nullptr;
+ oldView->d_func()->m_ownsPage = false;
+ }
+ page->d_func()->view = view ? view->d_func() : nullptr;
+ }
+
+ if (view && oldPage != page) {
+ if (oldPage) {
+ if (oldPage->d_func())
+ oldPage->d_func()->view = nullptr;
+ deleteOldPage = view->d_func()->m_ownsPage;
+ }
+ view->d_func()->m_ownsPage = ownNewPage;
+ view->d_func()->page = page;
+ }
+
+ // Then notify.
+
+ auto widget = page ? page->d_func()->widget : nullptr;
+ auto oldWidget = (oldPage && oldPage->d_func()) ? oldPage->d_func()->widget : nullptr;
+
+ if (page && oldView != view && oldView) {
+ oldView->d_func()->pageChanged(page, nullptr);
+ if (widget)
+ oldView->d_func()->widgetChanged(widget, nullptr);
+ }
+
+ if (view && oldPage != page) {
+ if (oldPage && oldPage->d_func())
+ view->d_func()->pageChanged(oldPage, page);
+ else
+ view->d_func()->pageChanged(nullptr, page);
+ if (oldWidget != widget)
+ view->d_func()->widgetChanged(oldWidget, widget);
+ }
+ if (deleteOldPage)
+ delete oldPage;
+}
+
+void QWebEngineViewPrivate::bindPageAndWidget(
+ QWebEnginePage *page, QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *widget)
+{
+ auto oldPage = widget ? widget->m_page : nullptr;
+ auto oldWidget = page ? page->d_func()->widget : nullptr;
+
+ // Change pointers first.
+
+ if (widget && oldPage != page) {
+ if (oldPage && oldPage->d_func())
+ oldPage->d_func()->widget = nullptr;
+ widget->m_page = page;
+ }
+
+ if (page && oldWidget != widget) {
+ if (oldWidget)
+ oldWidget->m_page = nullptr;
+ page->d_func()->widget = widget;
+ }
+
+ // Then notify.
+
+ if (widget && oldPage != page && oldPage && oldPage->d_func()) {
+ if (auto oldView = oldPage->d_func()->view)
+ static_cast<QWebEngineViewPrivate *>(oldView)->widgetChanged(widget, nullptr);
+ }
+
+ if (page && oldWidget != widget) {
+ if (auto view = page->d_func()->view)
+ static_cast<QWebEngineViewPrivate *>(view)->widgetChanged(oldWidget, widget);
+ }
+}
+
+QIcon QWebEngineViewPrivate::webActionIcon(QWebEnginePage::WebAction action)
+{
+ Q_Q(QWebEngineView);
+ QIcon icon;
+ QStyle *style = q->style();
+
+ switch (action) {
+ case QWebEnginePage::Back:
+ icon = style->standardIcon(QStyle::SP_ArrowBack);
+ break;
+ case QWebEnginePage::Forward:
+ icon = style->standardIcon(QStyle::SP_ArrowForward);
+ break;
+ case QWebEnginePage::Stop:
+ icon = style->standardIcon(QStyle::SP_BrowserStop);
+ break;
+ case QWebEnginePage::Reload:
+ icon = style->standardIcon(QStyle::SP_BrowserReload);
+ break;
+ case QWebEnginePage::ReloadAndBypassCache:
+ icon = style->standardIcon(QStyle::SP_BrowserReload);
+ break;
+ default:
+ break;
+ }
+ return icon;
+}
+
+QWebEnginePage *QWebEngineViewPrivate::createPageForWindow(QWebEnginePage::WebWindowType type)
+{
+ Q_Q(QWebEngineView);
+ QWebEngineView *newView = q->createWindow(type);
+ if (newView)
+ return newView->page();
+ return nullptr;
+}
+
+void QWebEngineViewPrivate::setToolTip(const QString &toolTipText)
+{
+ Q_Q(QWebEngineView);
+ q->setToolTip(toolTipText);
+}
+
+bool QWebEngineViewPrivate::isEnabled() const
+{
+ Q_Q(const QWebEngineView);
+ return q->isEnabled();
+}
+
+QObject *QWebEngineViewPrivate::accessibilityParentObject()
+{
+ Q_Q(QWebEngineView);
+ return q;
+}
+
+bool QWebEngineViewPrivate::isVisible() const
+{
+ Q_Q(const QWebEngineView);
+ return q->isVisible();
+}
+QRect QWebEngineViewPrivate::viewportRect() const
+{
+ Q_Q(const QWebEngineView);
+ return q->rect();
+}
+QtWebEngineCore::RenderWidgetHostViewQtDelegate *
+QWebEngineViewPrivate::CreateRenderWidgetHostViewQtDelegate(
+ QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client)
+{
+ Q_Q(QWebEngineView);
+ return new QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget(client, q);
+}
+
+QWebEngineContextMenuRequest *QWebEngineViewPrivate::lastContextMenuRequest() const
+{
+ return m_contextRequest;
+}
/*!
\fn QWebEngineView::renderProcessTerminated(QWebEnginePage::RenderProcessTerminationStatus terminationStatus, int exitCode)
\since 5.6
@@ -187,7 +553,7 @@ QWebEngineView::QWebEngineView(QWidget *parent)
QWebEngineView::~QWebEngineView()
{
blockSignals(true);
- QWebEnginePagePrivate::bindPageAndView(nullptr, this);
+ QWebEngineViewPrivate::bindPageAndView(nullptr, this);
}
QWebEnginePage* QWebEngineView::page() const
@@ -203,7 +569,12 @@ QWebEnginePage* QWebEngineView::page() const
void QWebEngineView::setPage(QWebEnginePage *newPage)
{
- QWebEnginePagePrivate::bindPageAndView(newPage, this);
+ QWebEngineViewPrivate::bindPageAndView(newPage, this);
+ connect(newPage, &QWebEnginePage::_q_aboutToDelete, this,
+ [newPage]() { QWebEngineViewPrivate::bindPageAndView(newPage, nullptr); });
+ auto profile = newPage->profile();
+ if (!profile->notificationPresenter())
+ profile->setNotificationPresenter(&defaultNotificationPresenter);
}
void QWebEngineView::load(const QUrl& url)
@@ -334,7 +705,7 @@ void QWebEngineView::reload()
QWebEngineView *QWebEngineView::createWindow(QWebEnginePage::WebWindowType type)
{
- Q_UNUSED(type)
+ Q_UNUSED(type);
return 0;
}
@@ -386,7 +757,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)
@@ -429,7 +800,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;
}
@@ -455,7 +826,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 {
@@ -473,11 +845,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
{
@@ -517,6 +918,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 = nullptr;
+
+ 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..d7f9d6a45 100644
--- a/src/webenginewidgets/api/qwebengineview.h
+++ b/src/webenginewidgets/api/qwebengineview.h
@@ -45,8 +45,9 @@
#include <QtWidgets/qwidget.h>
#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-#include <QtWebEngineWidgets/qwebenginepage.h>
+#include <QtWebEngineCore/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..47694ab24 100644
--- a/src/webenginewidgets/api/qwebengineview_p.h
+++ b/src/webenginewidgets/api/qwebengineview_p.h
@@ -52,18 +52,21 @@
//
#include <QtWebEngineWidgets/qwebengineview.h>
-
+#include "qwebenginecontextmenurequest.h"
+#include "render_view_context_menu_qt.h"
+#include "qwebenginepage_p.h"
#include <QtWidgets/qaccessiblewidget.h>
namespace QtWebEngineCore {
class RenderWidgetHostViewQtDelegateWidget;
+class RenderWidgetHostViewQtDelegate;
}
QT_BEGIN_NAMESPACE
class QWebEngineView;
-class QWebEngineViewPrivate
+class QWebEngineViewPrivate : public PageView
{
public:
Q_DECLARE_PUBLIC(QWebEngineView)
@@ -73,11 +76,38 @@ public:
void widgetChanged(QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *oldWidget,
QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *newWidget);
+ void contextMenuRequested(QWebEngineContextMenuRequest *request) override;
+ QStringList chooseFiles(QWebEnginePage::FileSelectionMode mode, const QStringList &oldFiles,
+ const QStringList &acceptedMimeTypes) override;
+ void
+ showColorDialog(QSharedPointer<QtWebEngineCore::ColorChooserController> controller) override;
+ bool showAuthorizationDialog(const QString &title, const QString &message) override;
+ void javaScriptAlert(const QUrl &url, const QString &msg) override;
+ bool javaScriptConfirm(const QUrl &url, const QString &msg) override;
+ bool javaScriptPrompt(const QUrl &url, const QString &msg, const QString &defaultValue,
+ QString *result) override;
+ void setToolTip(const QString &toolTipText) override;
+ QtWebEngineCore::RenderWidgetHostViewQtDelegate *CreateRenderWidgetHostViewQtDelegate(
+ QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) override;
+ QWebEngineContextMenuRequest *lastContextMenuRequest() const override;
+ QWebEnginePage *createPageForWindow(QWebEnginePage::WebWindowType type) override;
+ QObject *accessibilityParentObject() override;
QWebEngineViewPrivate();
-
+ virtual ~QWebEngineViewPrivate();
+ static void bindPageAndView(QWebEnginePage *page, QWebEngineView *view);
+ static void bindPageAndWidget(QWebEnginePage *page,
+ QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *widget);
+ QIcon webActionIcon(QWebEnginePage::WebAction action);
+ void unhandledKeyEvent(QKeyEvent *event) override;
+ void focusContainer() override;
+ bool passOnFocus(bool reverse) override;
+ bool isEnabled() const override;
+ bool isVisible() const override;
+ QRect viewportRect() const override;
QWebEnginePage *page;
bool m_dragEntered;
mutable bool m_ownsPage;
+ QWebEngineContextMenuRequest *m_contextRequest;
};
#ifndef QT_NO_ACCESSIBILITY
@@ -98,6 +128,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/snippets/simple/main.cpp b/src/webenginewidgets/doc/snippets/simple/main.cpp
index acaf073ba..39c07b84d 100644
--- a/src/webenginewidgets/doc/snippets/simple/main.cpp
+++ b/src/webenginewidgets/doc/snippets/simple/main.cpp
@@ -55,7 +55,7 @@
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- QWidget *parent = 0;
+ QWidget *parent = nullptr;
//! [Using QWebEngineView]
QWebEngineView *view = new QWebEngineView(parent);
view->load(QUrl("http://qt-project.org/"));
diff --git a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
index d88e8c48c..087c171cb 100644
--- a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
@@ -519,16 +519,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 5124eabed..5d8932fb7 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -39,28 +39,35 @@
#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"
+
#include <QGuiApplication>
#include <QLayout>
#include <QMouseEvent>
#include <QOpenGLContext>
#include <QResizeEvent>
-#include <QSGAbstractRenderer>
-#include <QSGNode>
+#include <QSGImageNode>
#include <QWindow>
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
{
@@ -81,17 +88,76 @@ 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(QNativeInterface::QSGOpenGLTexture::fromNative(texId, win, 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)
@@ -101,62 +167,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);
@@ -169,7 +179,7 @@ RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(Rende
RenderWidgetHostViewQtDelegateWidget::~RenderWidgetHostViewQtDelegateWidget()
{
- QWebEnginePagePrivate::bindPageAndWidget(nullptr, this);
+ QWebEngineViewPrivate::bindPageAndWidget(nullptr, this);
}
void RenderWidgetHostViewQtDelegateWidget::connectRemoveParentBeforeParentDelete()
@@ -290,21 +300,6 @@ QWindow* RenderWidgetHostViewQtDelegateWidget::window() const
return root ? root->windowHandle() : 0;
}
-QSGTexture *RenderWidgetHostViewQtDelegateWidget::createTextureFromImage(const QImage &image)
-{
- return quickWindow()->createTextureFromImage(image, QQuickWindow::TextureCanUseAtlas);
-}
-
-QSGImageNode *RenderWidgetHostViewQtDelegateWidget::createImageNode()
-{
- return quickWindow()->createImageNode();
-}
-
-void RenderWidgetHostViewQtDelegateWidget::update()
-{
- m_rootItem->update();
-}
-
void RenderWidgetHostViewQtDelegateWidget::updateCursor(const QCursor &cursor)
{
QQuickWidget::setCursor(cursor);
@@ -381,15 +376,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;
@@ -453,8 +439,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
@@ -477,6 +464,14 @@ void RenderWidgetHostViewQtDelegateWidget::onWindowPosChanged()
m_client->visualPropertiesChanged();
}
+void RenderWidgetHostViewQtDelegateWidget::adapterClientChanged(WebContentsAdapterClient *client)
+{
+ QWebEnginePage *page = static_cast<QWebEnginePagePrivate *>(client)->q_func();
+ QWebEngineViewPrivate::bindPageAndWidget(page, this);
+ connect(page, &QWebEnginePage::_q_aboutToDelete, this,
+ [this]() { QWebEngineViewPrivate::bindPageAndWidget(nullptr, this); });
+}
+
#if QT_CONFIG(accessibility)
RenderWidgetHostViewQtDelegateWidgetAccessible::RenderWidgetHostViewQtDelegateWidgetAccessible(RenderWidgetHostViewQtDelegateWidget *o, QWebEngineView *view)
: QAccessibleWidget(o)
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 fd8654d95..d106cf351 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
class QWebEnginePage;
class QWebEngineView;
class QWebEngineViewAccessible;
-class QWebEnginePagePrivate;
+class QWebEngineViewPrivate;
QT_END_NAMESPACE
namespace QtWebEngineCore {
@@ -65,7 +65,7 @@ namespace QtWebEngineCore {
class RenderWidgetHostViewQtDelegateWidget : public QQuickWidget, public RenderWidgetHostViewQtDelegate {
Q_OBJECT
public:
- RenderWidgetHostViewQtDelegateWidget(RenderWidgetHostViewQtDelegateClient *client, QWidget *parent = 0);
+ RenderWidgetHostViewQtDelegateWidget(RenderWidgetHostViewQtDelegateClient *client, QWidget *parent = nullptr);
~RenderWidgetHostViewQtDelegateWidget();
void initAsPopup(const QRect&) override;
@@ -79,16 +79,12 @@ public:
void hide() override;
bool isVisible() const override;
QWindow* window() const override;
- QSGTexture *createTextureFromImage(const QImage &) override;
- QSGImageNode *createImageNode() 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:
@@ -99,6 +95,7 @@ protected:
void closeEvent(QCloseEvent *event) override;
QVariant inputMethodQuery(Qt::InputMethodQuery query) const override;
+ void adapterClientChanged(WebContentsAdapterClient *client) override;
private slots:
void onWindowPosChanged();
@@ -106,7 +103,7 @@ private slots:
void removeParentBeforeParentDelete();
private:
- friend QWebEnginePagePrivate;
+ friend QWebEngineViewPrivate;
RenderWidgetHostViewQtDelegateClient *m_client;
QScopedPointer<QQuickItem> m_rootItem;
diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro
index d4fb40dc7..e726bdc8c 100644
--- a/src/webenginewidgets/webenginewidgets.pro
+++ b/src/webenginewidgets/webenginewidgets.pro
@@ -12,48 +12,15 @@ QT_PRIVATE += quick-private gui-private core-private widgets-private quickwidget
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 \
- api/qwebenginepage.cpp \
- api/qwebengineprofile.cpp \
- api/qwebenginescript.cpp \
- api/qwebenginescriptcollection.cpp \
- api/qwebenginesettings.cpp \
api/qwebengineview.cpp \
render_widget_host_view_qt_delegate_widget.cpp
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 \
- api/qwebenginepage.h \
- api/qwebenginepage_p.h \
- api/qwebengineprofile.h \
- api/qwebengineprofile_p.h \
- api/qwebenginescriptcollection.h \
- api/qwebenginescriptcollection_p.h \
- api/qwebenginesettings.h \
api/qwebengineview.h \
api/qwebengineview_p.h \
render_widget_host_view_qt_delegate_widget.h
-qtConfig(webengine-printing-and-pdf) {
- QT += printsupport
-
- SOURCES += printer_worker.cpp
- HEADERS += printer_worker.h
-}
-
load(qt_module)