From 442262d47ae64e33697ee344eedbaba144de91a0 Mon Sep 17 00:00:00 2001 From: Steve Lamerton Date: Fri, 15 Jul 2011 15:22:08 +0000 Subject: [PATCH] Send correct navigation events when using SetPage on the IE backend, they now mimic Webkit. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68276 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/webview_ie.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/msw/webview_ie.cpp b/src/msw/webview_ie.cpp index dbb35fdc3a..0c8c88609f 100644 --- a/src/msw/webview_ie.cpp +++ b/src/msw/webview_ie.cpp @@ -127,17 +127,8 @@ void wxWebViewIE::LoadUrl(const wxString& url) m_ie.CallMethod("Navigate", (BSTR) url.wc_str(), NULL, NULL, NULL, NULL); } -void wxWebViewIE::SetPage(const wxString& html, const wxString&) +void wxWebViewIE::SetPage(const wxString& html, const wxString& baseUrl) { - LoadUrl("about:blank"); - - // Let the wx events generated for navigation events be processed, so - // that the underlying IE component completes its Document object. - // FIXME: calling wxYield is not elegant nor very reliable probably - wxYield(); - - // TODO: consider the "baseUrl" parameter if possible - // TODO: consider encoding BSTR bstr = SysAllocString(html.wc_str()); // Creates a new one-dimensional array @@ -145,16 +136,30 @@ void wxWebViewIE::SetPage(const wxString& html, const wxString&) if (psaStrings != NULL) { VARIANT *param; + HRESULT hr = SafeArrayAccessData(psaStrings, (LPVOID*)¶m); param->vt = VT_BSTR; param->bstrVal = bstr; - hr = SafeArrayUnaccessData(psaStrings); + IHTMLDocument2* document = GetDocument(); document->write(psaStrings); + document->Release(); // SafeArrayDestroy calls SysFreeString for each BSTR SafeArrayDestroy(psaStrings); + + //We send the events when we are done to mimic webkit + //Navigated event + wxWebNavigationEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATED, + GetId(), baseUrl, "", false); + event.SetEventObject(this); + HandleWindowEvent(event); + + //Document complete event + event.SetEventType(wxEVT_COMMAND_WEB_VIEW_LOADED); + event.SetEventObject(this); + HandleWindowEvent(event); } else { -- 2.47.2