Merge branch 'webview_misc' of https://github.com/TcT2k/wxWidgets
More wxWebView miscellaneous improvements. See https://github.com/wxWidgets/wxWidgets/pull/2221
This commit is contained in:
@@ -105,7 +105,7 @@ private:
|
|||||||
|
|
||||||
void OnSize(wxSizeEvent& event);
|
void OnSize(wxSizeEvent& event);
|
||||||
|
|
||||||
void OnShow(wxShowEvent& event);
|
void OnTopLevelParentIconized(wxIconizeEvent& event);
|
||||||
|
|
||||||
bool RunScriptSync(const wxString& javascript, wxString* output = NULL) const;
|
bool RunScriptSync(const wxString& javascript, wxString* output = NULL) const;
|
||||||
|
|
||||||
|
@@ -113,15 +113,16 @@ private:
|
|||||||
class WXDLLIMPEXP_WEBVIEW wxWebViewFactoryWebKit : public wxWebViewFactory
|
class WXDLLIMPEXP_WEBVIEW wxWebViewFactoryWebKit : public wxWebViewFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual wxWebView* Create() { return new wxWebViewWebKit; }
|
virtual wxWebView* Create() wxOVERRIDE { return new wxWebViewWebKit; }
|
||||||
virtual wxWebView* Create(wxWindow* parent,
|
virtual wxWebView* Create(wxWindow* parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxString& url = wxWebViewDefaultURLStr,
|
const wxString& url = wxWebViewDefaultURLStr,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
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); }
|
{ return new wxWebViewWebKit(parent, id, url, pos, size, style, name); }
|
||||||
|
virtual wxVersionInfo GetVersionInfo() wxOVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT
|
#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT
|
||||||
|
@@ -56,8 +56,8 @@ bool DecodeString(const wxString& in, wxString* out)
|
|||||||
out->append('\\');
|
out->append('\\');
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
#if SIZEOF_WCHAR_T == 2
|
#if SIZEOF_WCHAR_T == 2
|
||||||
// In this case, we handle surrogates without doing anything special was wchar_t strings use UTF-17 encoding.
|
// 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]) &&
|
if (wxIsxdigit(ch[1]) && wxIsxdigit(ch[2]) &&
|
||||||
wxIsxdigit(ch[3]) && wxIsxdigit(ch[4]))
|
wxIsxdigit(ch[3]) && wxIsxdigit(ch[4]))
|
||||||
{
|
{
|
||||||
|
@@ -296,6 +296,7 @@ HRESULT wxWebViewEdgeImpl::OnWebViewCreated(HRESULT result, ICoreWebView2Control
|
|||||||
|
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
UpdateBounds();
|
UpdateBounds();
|
||||||
|
m_webViewController->put_IsVisible(true);
|
||||||
|
|
||||||
// Connect and handle the various WebView events
|
// Connect and handle the various WebView events
|
||||||
m_webView->add_NavigationStarting(
|
m_webView->add_NavigationStarting(
|
||||||
@@ -362,7 +363,9 @@ ICoreWebView2Settings* wxWebViewEdgeImpl::GetSettings()
|
|||||||
|
|
||||||
wxWebViewEdge::~wxWebViewEdge()
|
wxWebViewEdge::~wxWebViewEdge()
|
||||||
{
|
{
|
||||||
Unbind(wxEVT_SHOW, &wxWebViewEdge::OnShow, this);
|
wxWindow* topLevelParent = wxGetTopLevelParent(this);
|
||||||
|
if (topLevelParent)
|
||||||
|
topLevelParent->Unbind(wxEVT_ICONIZE, &wxWebViewEdge::OnTopLevelParentIconized, this);
|
||||||
delete m_impl;
|
delete m_impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,7 +390,9 @@ bool wxWebViewEdge::Create(wxWindow* parent,
|
|||||||
if (!m_impl->Create())
|
if (!m_impl->Create())
|
||||||
return false;
|
return false;
|
||||||
Bind(wxEVT_SIZE, &wxWebViewEdge::OnSize, this);
|
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);
|
LoadURL(url);
|
||||||
return true;
|
return true;
|
||||||
@@ -399,10 +404,10 @@ void wxWebViewEdge::OnSize(wxSizeEvent& event)
|
|||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWebViewEdge::OnShow(wxShowEvent& event)
|
void wxWebViewEdge::OnTopLevelParentIconized(wxIconizeEvent& event)
|
||||||
{
|
{
|
||||||
if (m_impl->m_webView)
|
if (m_impl && m_impl->m_webViewController)
|
||||||
m_impl->m_webViewController->put_IsVisible(event.IsShown());
|
m_impl->m_webViewController->put_IsVisible(!event.IsIconized());
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -741,15 +746,15 @@ bool wxWebViewFactoryEdge::IsAvailable()
|
|||||||
wxVersionInfo wxWebViewFactoryEdge::GetVersionInfo()
|
wxVersionInfo wxWebViewFactoryEdge::GetVersionInfo()
|
||||||
{
|
{
|
||||||
IsAvailable(); // Make sure ms_version string is initialized (if available)
|
IsAvailable(); // Make sure ms_version string is initialized (if available)
|
||||||
long major = 0,
|
long major = 0,
|
||||||
minor = 0,
|
minor = 0,
|
||||||
micro = 0;
|
micro = 0;
|
||||||
wxStringTokenizer tk(wxWebViewEdgeImpl::ms_version, ". ");
|
wxStringTokenizer tk(wxWebViewEdgeImpl::ms_version, ". ");
|
||||||
// Ignore the return value because if the version component is missing
|
// 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
|
// or invalid (i.e. non-numeric), the only thing we can do is to ignore
|
||||||
// it anyhow.
|
// it anyhow.
|
||||||
tk.GetNextToken().ToLong(&major);
|
tk.GetNextToken().ToLong(&major);
|
||||||
tk.GetNextToken().ToLong(&minor);
|
tk.GetNextToken().ToLong(&minor);
|
||||||
tk.GetNextToken().ToLong(µ);
|
tk.GetNextToken().ToLong(µ);
|
||||||
|
|
||||||
return wxVersionInfo("Microsoft Edge WebView2", major, minor, micro);
|
return wxVersionInfo("Microsoft Edge WebView2", major, minor, micro);
|
||||||
|
@@ -58,16 +58,16 @@ wxVersionInfo wxWebViewFactoryIE::GetVersionInfo()
|
|||||||
wxRegKey key(wxRegKey::HKLM, "Software\\Microsoft\\Internet Explorer");
|
wxRegKey key(wxRegKey::HKLM, "Software\\Microsoft\\Internet Explorer");
|
||||||
wxString value;
|
wxString value;
|
||||||
key.QueryValue("Version", value);
|
key.QueryValue("Version", value);
|
||||||
long major = 0,
|
long major = 0,
|
||||||
minor = 0,
|
minor = 0,
|
||||||
micro = 0;
|
micro = 0;
|
||||||
wxStringTokenizer tk(value, ". ");
|
wxStringTokenizer tk(value, ". ");
|
||||||
// Ignore the return value because if the version component is missing
|
// 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
|
// or invalid (i.e. non-numeric), the only thing we can do is to ignore
|
||||||
// it anyhow.
|
// it anyhow.
|
||||||
tk.GetNextToken().ToLong(&major);
|
tk.GetNextToken().ToLong(&major);
|
||||||
tk.GetNextToken().ToLong(&minor);
|
tk.GetNextToken().ToLong(&minor);
|
||||||
tk.GetNextToken().ToLong(µ);
|
tk.GetNextToken().ToLong(µ);
|
||||||
return wxVersionInfo("Internet Explorer", major, minor, micro);
|
return wxVersionInfo("Internet Explorer", major, minor, micro);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -87,6 +87,17 @@ wxEND_EVENT_TABLE()
|
|||||||
@end
|
@end
|
||||||
#endif // macOS 10.13+
|
#endif // macOS 10.13+
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxWebViewFactoryWebKit
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxVersionInfo wxWebViewFactoryWebKit::GetVersionInfo()
|
||||||
|
{
|
||||||
|
int verMaj, verMin, verMicro;
|
||||||
|
wxGetOsVersion(&verMaj, &verMin, &verMicro);
|
||||||
|
return wxVersionInfo("WKWebView", verMaj, verMin, verMicro);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// creation/destruction
|
// creation/destruction
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user