diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index ebb6538fd14..9ac6f2ed22a 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -204,6 +204,8 @@ static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface) ConnectionPointContainer_Destroy(&This->cp_container); + if(This->nsdoc) + nsIDOMHTMLDocument_Release(This->nsdoc); if(This->nscontainer) NSContainer_Release(This->nscontainer); @@ -1636,6 +1638,8 @@ HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject) init_dispex(&ret->dispex, (IUnknown*)HTMLDOC(ret), &HTMLDocument_dispex); ret->nscontainer = NSContainer_Create(ret, NULL); + update_nsdocument(ret); + ret->window = HTMLWindow_Create(ret); get_thread_hwnd(); diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index b90d07af1bb..cac111711e4 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -246,6 +246,7 @@ struct HTMLDocument { NSContainer *nscontainer; HTMLWindow *window; + nsIDOMHTMLDocument *nsdoc; IOleClientSite *client; IDocHostUIHandler *hostui; @@ -530,6 +531,7 @@ void get_editor_controller(NSContainer*); void init_nsevents(NSContainer*); void add_nsevent_listener(NSContainer*,LPCWSTR); nsresult get_nsinterface(nsISupports*,REFIID,void**); +void update_nsdocument(HTMLDocument*); void check_event_attr(HTMLDocument*,nsIDOMElement*); void release_event_target(event_target_t*); diff --git a/dlls/mshtml/navigate.c b/dlls/mshtml/navigate.c index d019e292754..0a543a789ea 100644 --- a/dlls/mshtml/navigate.c +++ b/dlls/mshtml/navigate.c @@ -883,8 +883,10 @@ static HRESULT read_stream_data(nsChannelBSC *This, IStream *stream) FIXME("OnStartRequest failed: %08x\n", nsres); /* events are reset when a new document URI is loaded, so re-initialise them here */ - if(This->bsc.doc && This->bsc.doc->bscallback == This && This->bsc.doc->nscontainer) + if(This->bsc.doc && This->bsc.doc->bscallback == This && This->bsc.doc->nscontainer) { + update_nsdocument(This->bsc.doc); init_nsevents(This->bsc.doc->nscontainer); + } } This->bsc.readed += This->nsstream->buf_size; diff --git a/dlls/mshtml/nsembed.c b/dlls/mshtml/nsembed.c index 78563d3994d..94707c2649d 100644 --- a/dlls/mshtml/nsembed.c +++ b/dlls/mshtml/nsembed.c @@ -866,6 +866,39 @@ void set_ns_editmode(NSContainer *This) nsIWebBrowser_SetParentURIContentListener(This->webbrowser, NSURICL(This)); } +void update_nsdocument(HTMLDocument *doc) +{ + nsIDOMHTMLDocument *nsdoc; + nsIDOMDocument *nsdomdoc; + nsresult nsres; + + if(!doc->nscontainer || !doc->nscontainer->navigation) + return; + + nsres = nsIWebNavigation_GetDocument(doc->nscontainer->navigation, &nsdomdoc); + if(NS_FAILED(nsres) || !nsdomdoc) { + ERR("GetDocument failed: %08x\n", nsres); + return; + } + + nsres = nsIDOMDocument_QueryInterface(nsdomdoc, &IID_nsIDOMHTMLDocument, (void**)&nsdoc); + nsIDOMDocument_Release(nsdomdoc); + if(NS_FAILED(nsres)) { + ERR("Could not get nsIDOMHTMLDocument iface: %08x\n", nsres); + return; + } + + if(nsdoc == doc->nsdoc) { + nsIDOMHTMLDocument_Release(nsdoc); + return; + } + + if(doc->nsdoc) + nsIDOMHTMLDocument_Release(doc->nsdoc); + + doc->nsdoc = nsdoc; +} + void close_gecko(void) { TRACE("()\n"); @@ -963,8 +996,14 @@ static nsresult NSAPI nsWebBrowserChrome_SetStatus(nsIWebBrowserChrome *iface, PRUint32 statusType, const PRUnichar *status) { NSContainer *This = NSWBCHROME_THIS(iface); + TRACE("(%p)->(%d %s)\n", This, statusType, debugstr_w(status)); - return NS_ERROR_NOT_IMPLEMENTED; + + /* FIXME: This hack should be removed when we'll load all pages by URLMoniker */ + if(This->doc) + update_nsdocument(This->doc); + + return NS_OK; } static nsresult NSAPI nsWebBrowserChrome_GetWebBrowser(nsIWebBrowserChrome *iface, diff --git a/dlls/mshtml/nsevents.c b/dlls/mshtml/nsevents.c index d0f5079a666..e79ec4e1c7d 100644 --- a/dlls/mshtml/nsevents.c +++ b/dlls/mshtml/nsevents.c @@ -139,6 +139,7 @@ static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event if(!This->doc) return NS_OK; + update_nsdocument(This->doc); connect_scripts(This->doc); setup_nswindow(This->doc->window);