Handle WebKitWebView create-web-view.

In some cases a new window is signalled using create-web-view rather than new-window-policy-decision-requested and so we need to handle it to emit the correct new window events.

Fixes #15447.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74804 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Steve Lamerton
2013-09-13 12:55:08 +00:00
parent 93c6dce5b0
commit fe7cefd493
2 changed files with 38 additions and 3 deletions

View File

@@ -130,6 +130,9 @@ public:
//We use this flag to stop recursion when we load a page from the navigation
//callback, mainly when loading a VFS page
bool m_guard;
//This flag is use to indicate when a navigation event is the result of a
//create-web-view signal and so we need to send a new window event
bool m_creating;
protected:
virtual void DoSetPage(const wxString& html, const wxString& baseUrl);

View File

@@ -86,6 +86,26 @@ wxgtk_webview_webkit_navigation(WebKitWebView *,
WebKitWebPolicyDecision *policy_decision,
wxWebViewWebKit *webKitCtrl)
{
const gchar* uri = webkit_network_request_get_uri(request);
wxString target = webkit_web_frame_get_name (frame);
//If m_creating is true then we are the result of a new window
//and so we need to send the event and veto the load
if(webKitCtrl->m_creating)
{
webKitCtrl->m_creating = false;
wxWebViewEvent event(wxEVT_WEBVIEW_NEWWINDOW,
webKitCtrl->GetId(),
wxString(uri, wxConvUTF8),
target);
if(webKitCtrl && webKitCtrl->GetEventHandler())
webKitCtrl->GetEventHandler()->ProcessEvent(event);
webkit_web_policy_decision_ignore(policy_decision);
return TRUE;
}
if(webKitCtrl->m_guard)
{
webKitCtrl->m_guard = false;
@@ -98,9 +118,6 @@ wxgtk_webview_webkit_navigation(WebKitWebView *,
webKitCtrl->m_busy = true;
const gchar* uri = webkit_network_request_get_uri(request);
wxString target = webkit_web_frame_get_name (frame);
wxWebViewEvent event(wxEVT_WEBVIEW_NAVIGATING,
webKitCtrl->GetId(),
wxString( uri, wxConvUTF8 ),
@@ -395,6 +412,17 @@ wxgtk_webview_webkit_context_menu(WebKitWebView *,
#endif
static WebKitWebView*
wxgtk_webview_webkit_create_webview(WebKitWebView *web_view,
WebKitWebFrame *frame,
wxWebViewWebKit *webKitCtrl)
{
//As we do not know the uri being loaded at this point allow the load to
//continue and catch it in navigation-policy-decision-requested
webKitCtrl->m_creating = true;
return web_view;
}
} // extern "C"
//-----------------------------------------------------------------------------
@@ -418,6 +446,7 @@ bool wxWebViewWebKit::Create(wxWindow *parent,
{
m_busy = false;
m_guard = false;
m_creating = false;
FindClear();
// We currently unconditionally impose scrolling in both directions as it's
@@ -456,6 +485,9 @@ bool wxWebViewWebKit::Create(wxWindow *parent,
G_CALLBACK(wxgtk_webview_webkit_context_menu), this);
#endif
g_signal_connect_after(m_web_view, "create-web-view",
G_CALLBACK(wxgtk_webview_webkit_create_webview), this);
m_parent->DoAddChild( this );
PostCreation(size);