From 416e241e6a368c11433b2f34931dd3c1899a896d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 5 Jan 2024 02:55:09 +0100 Subject: [PATCH] Add wxWebViewConfigurationImplChromium scaffolding It is perfectly useless for now, but provides place to add more things in the upcoming commits. --- include/wx/webview_chromium.h | 2 ++ src/common/webview_chromium.cpp | 39 +++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/include/wx/webview_chromium.h b/include/wx/webview_chromium.h index 7ef6f4de39..4552ca82e0 100644 --- a/include/wx/webview_chromium.h +++ b/include/wx/webview_chromium.h @@ -30,6 +30,8 @@ class WXDLLIMPEXP_WEBVIEW wxWebViewChromium : public wxWebView public: wxWebViewChromium() { Init(); } + explicit wxWebViewChromium(const wxWebViewConfiguration& config); + wxWebViewChromium(wxWindow* parent, wxWindowID id, const wxString& url = wxWebViewDefaultURLStr, diff --git a/src/common/webview_chromium.cpp b/src/common/webview_chromium.cpp index 98ea625c94..d6c5c2bfee 100644 --- a/src/common/webview_chromium.cpp +++ b/src/common/webview_chromium.cpp @@ -23,6 +23,7 @@ #ifdef __WXMSW__ #include "wx/msw/private.h" #endif +#include "wx/private/webview.h" #ifdef __WXGTK__ #include @@ -248,12 +249,34 @@ void AppImplData::DoMessageLoopWork() CefDoMessageLoopWork(); } +// ---------------------------------------------------------------------------- +// Chromium-specific configuration data +// ---------------------------------------------------------------------------- + +class wxWebViewConfigurationImplChromium : public wxWebViewConfigurationImpl +{ +public: + static wxWebViewConfiguration MakeConfig() + { + return wxWebViewConfiguration(wxWebViewBackendChromium, + new wxWebViewConfigurationImplChromium); + } +}; + // ---------------------------------------------------------------------------- // ImplData contains data for a single wxWebViewChromium instance // ---------------------------------------------------------------------------- struct ImplData { + explicit ImplData(const wxWebViewConfiguration& config = + wxWebViewConfigurationImplChromium::MakeConfig()) + : m_config{config} + { + } + + wxWebViewConfiguration m_config; + #ifdef __WXGTK__ // Due to delayed creation of the browser in wxGTK we need to remember the // URL passed to Create() as we can't use it there directly. @@ -606,6 +629,11 @@ void wxWebViewChromium::Init() m_implData = new ImplData{}; } +wxWebViewChromium::wxWebViewChromium(const wxWebViewConfiguration& config) +{ + m_implData = new ImplData{config}; +} + bool wxWebViewChromium::Create(wxWindow* parent, wxWindowID id, const wxString& url, @@ -1822,6 +1850,12 @@ class WXDLLIMPEXP_WEBVIEW wxWebViewFactoryChromium : public wxWebViewFactory { public: virtual wxWebView* Create() override { return new wxWebViewChromium; } + + virtual wxWebView* CreateWithConfig(const wxWebViewConfiguration& config) override + { + return new wxWebViewChromium(config); + } + virtual wxWebView* Create(wxWindow* parent, wxWindowID id, const wxString& url = wxWebViewDefaultURLStr, @@ -1853,6 +1887,11 @@ public: CEF_VERSION }; } + + virtual wxWebViewConfiguration CreateConfiguration() override + { + return wxWebViewConfigurationImplChromium::MakeConfig(); + } }; class wxWebViewChromiumModule : public wxModule