diff --git a/include/wx/msw/webview_edge.h b/include/wx/msw/webview_edge.h index be7eeeac2a..ffd54f2077 100644 --- a/include/wx/msw/webview_edge.h +++ b/include/wx/msw/webview_edge.h @@ -105,7 +105,7 @@ private: void OnSize(wxSizeEvent& event); - void OnShow(wxShowEvent& event); + void OnTopLevelParentIconized(wxIconizeEvent& event); bool RunScriptSync(const wxString& javascript, wxString* output = NULL) const; diff --git a/include/wx/osx/webview_webkit.h b/include/wx/osx/webview_webkit.h index 1c92faac73..6bd6da02f3 100644 --- a/include/wx/osx/webview_webkit.h +++ b/include/wx/osx/webview_webkit.h @@ -113,15 +113,16 @@ private: class WXDLLIMPEXP_WEBVIEW wxWebViewFactoryWebKit : public wxWebViewFactory { public: - virtual wxWebView* Create() { return new wxWebViewWebKit; } + virtual wxWebView* Create() wxOVERRIDE { return new wxWebViewWebKit; } virtual wxWebView* Create(wxWindow* parent, wxWindowID id, const wxString& url = wxWebViewDefaultURLStr, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, - const wxString& name = wxASCII_STR(wxWebViewNameStr)) + const wxString& name = wxASCII_STR(wxWebViewNameStr)) wxOVERRIDE { return new wxWebViewWebKit(parent, id, url, pos, size, style, name); } + virtual wxVersionInfo GetVersionInfo() wxOVERRIDE; }; #endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT diff --git a/include/wx/private/json.h b/include/wx/private/json.h index 12d78e4a2e..8e93b7d9c8 100644 --- a/include/wx/private/json.h +++ b/include/wx/private/json.h @@ -56,8 +56,8 @@ bool DecodeString(const wxString& in, wxString* out) out->append('\\'); break; case 'u': -#if SIZEOF_WCHAR_T == 2 - // In this case, we handle surrogates without doing anything special was wchar_t strings use UTF-17 encoding. +#if SIZEOF_WCHAR_T == 2 + // In this case, we handle surrogates without doing anything special was wchar_t strings use UTF-17 encoding. if (wxIsxdigit(ch[1]) && wxIsxdigit(ch[2]) && wxIsxdigit(ch[3]) && wxIsxdigit(ch[4])) { diff --git a/src/msw/webview_edge.cpp b/src/msw/webview_edge.cpp index 06b1f1126a..bdf8ce5b76 100644 --- a/src/msw/webview_edge.cpp +++ b/src/msw/webview_edge.cpp @@ -296,6 +296,7 @@ HRESULT wxWebViewEdgeImpl::OnWebViewCreated(HRESULT result, ICoreWebView2Control m_initialized = true; UpdateBounds(); + m_webViewController->put_IsVisible(true); // Connect and handle the various WebView events m_webView->add_NavigationStarting( @@ -362,7 +363,9 @@ ICoreWebView2Settings* wxWebViewEdgeImpl::GetSettings() wxWebViewEdge::~wxWebViewEdge() { - Unbind(wxEVT_SHOW, &wxWebViewEdge::OnShow, this); + wxWindow* topLevelParent = wxGetTopLevelParent(this); + if (topLevelParent) + topLevelParent->Unbind(wxEVT_ICONIZE, &wxWebViewEdge::OnTopLevelParentIconized, this); delete m_impl; } @@ -387,7 +390,9 @@ bool wxWebViewEdge::Create(wxWindow* parent, if (!m_impl->Create()) return false; Bind(wxEVT_SIZE, &wxWebViewEdge::OnSize, this); - Bind(wxEVT_SHOW, &wxWebViewEdge::OnShow, this); + wxWindow* topLevelParent = wxGetTopLevelParent(this); + if (topLevelParent) + topLevelParent->Bind(wxEVT_ICONIZE, &wxWebViewEdge::OnTopLevelParentIconized, this); LoadURL(url); return true; @@ -399,10 +404,10 @@ void wxWebViewEdge::OnSize(wxSizeEvent& event) event.Skip(); } -void wxWebViewEdge::OnShow(wxShowEvent& event) +void wxWebViewEdge::OnTopLevelParentIconized(wxIconizeEvent& event) { - if (m_impl->m_webView) - m_impl->m_webViewController->put_IsVisible(event.IsShown()); + if (m_impl && m_impl->m_webViewController) + m_impl->m_webViewController->put_IsVisible(!event.IsIconized()); event.Skip(); } @@ -741,15 +746,15 @@ bool wxWebViewFactoryEdge::IsAvailable() wxVersionInfo wxWebViewFactoryEdge::GetVersionInfo() { IsAvailable(); // Make sure ms_version string is initialized (if available) - long major = 0, - minor = 0, - micro = 0; - wxStringTokenizer tk(wxWebViewEdgeImpl::ms_version, ". "); - // Ignore the return value because if the version component is missing - // or invalid (i.e. non-numeric), the only thing we can do is to ignore - // it anyhow. - tk.GetNextToken().ToLong(&major); - tk.GetNextToken().ToLong(&minor); + long major = 0, + minor = 0, + micro = 0; + wxStringTokenizer tk(wxWebViewEdgeImpl::ms_version, ". "); + // Ignore the return value because if the version component is missing + // or invalid (i.e. non-numeric), the only thing we can do is to ignore + // it anyhow. + tk.GetNextToken().ToLong(&major); + tk.GetNextToken().ToLong(&minor); tk.GetNextToken().ToLong(µ); return wxVersionInfo("Microsoft Edge WebView2", major, minor, micro); diff --git a/src/msw/webview_ie.cpp b/src/msw/webview_ie.cpp index a008166b6a..6b0f194dc7 100644 --- a/src/msw/webview_ie.cpp +++ b/src/msw/webview_ie.cpp @@ -58,16 +58,16 @@ wxVersionInfo wxWebViewFactoryIE::GetVersionInfo() wxRegKey key(wxRegKey::HKLM, "Software\\Microsoft\\Internet Explorer"); wxString value; key.QueryValue("Version", value); - long major = 0, - minor = 0, - micro = 0; - wxStringTokenizer tk(value, ". "); - // Ignore the return value because if the version component is missing - // or invalid (i.e. non-numeric), the only thing we can do is to ignore - // it anyhow. - tk.GetNextToken().ToLong(&major); - tk.GetNextToken().ToLong(&minor); - tk.GetNextToken().ToLong(µ); + long major = 0, + minor = 0, + micro = 0; + wxStringTokenizer tk(value, ". "); + // Ignore the return value because if the version component is missing + // or invalid (i.e. non-numeric), the only thing we can do is to ignore + // it anyhow. + tk.GetNextToken().ToLong(&major); + tk.GetNextToken().ToLong(&minor); + tk.GetNextToken().ToLong(µ); return wxVersionInfo("Internet Explorer", major, minor, micro); } diff --git a/src/osx/webview_webkit.mm b/src/osx/webview_webkit.mm index 5350081e78..a788f8c4a3 100644 --- a/src/osx/webview_webkit.mm +++ b/src/osx/webview_webkit.mm @@ -87,6 +87,17 @@ wxEND_EVENT_TABLE() @end #endif // macOS 10.13+ +//----------------------------------------------------------------------------- +// wxWebViewFactoryWebKit +//----------------------------------------------------------------------------- + +wxVersionInfo wxWebViewFactoryWebKit::GetVersionInfo() +{ + int verMaj, verMin, verMicro; + wxGetOsVersion(&verMaj, &verMin, &verMicro); + return wxVersionInfo("WKWebView", verMaj, verMin, verMicro); +} + // ---------------------------------------------------------------------------- // creation/destruction // ----------------------------------------------------------------------------