]> git.saurik.com Git - wxWidgets.git/commitdiff
Send correct navigation events when using SetPage on the IE backend, they now mimic...
authorSteve Lamerton <steve.lamerton@gmail.com>
Fri, 15 Jul 2011 15:22:08 +0000 (15:22 +0000)
committerSteve Lamerton <steve.lamerton@gmail.com>
Fri, 15 Jul 2011 15:22:08 +0000 (15:22 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68276 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/webview_ie.cpp

index dbb35fdc3a205c475fb542d7ac2fd1b404570196..0c8c88609f23761347a5744550e0247737129111 100644 (file)
@@ -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*)&param);
         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
     {