Use two step creation for WKWebView on macOS

This commit is contained in:
Tobias Taschner
2020-11-12 11:59:06 +01:00
parent bde4a45e9c
commit 4c35689b9d

View File

@@ -383,13 +383,21 @@ WebFrame::WebFrame(const wxString& url) :
wxLogMessage("Edge backend not available");
}
#endif
m_browser = wxWebView::New(this, wxID_ANY, url, wxDefaultPosition, wxDefaultSize, backend);
m_browser = wxWebView::New(backend);
#ifdef __WXMAC__
// With WKWebView handlers need to be registered before creation
m_browser->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new wxWebViewArchiveHandler("wxfs")));
m_browser->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new wxWebViewFSHandler("memory")));
#endif
m_browser->Create(this, wxID_ANY, url, wxDefaultPosition, wxDefaultSize);
topsizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1));
#ifndef __WXMAC__
//We register the wxfs:// protocol for testing purposes
m_browser->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new wxWebViewArchiveHandler("wxfs")));
//And the memory: file system
m_browser->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new wxWebViewFSHandler("memory")));
#endif
SetSizer(topsizer);