diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c
index db9691c5d9..be42a916c0 100644
--- a/dlls/mshtml/htmlevent.c
+++ b/dlls/mshtml/htmlevent.c
@@ -856,16 +856,16 @@ static HRESULT set_event_handler_disp(event_target_t **event_target_ptr, HTMLDoc
return S_OK;
IDispatch_AddRef(disp);
- if(doc->nscontainer && (event_info[eid].flags & EVENT_DEFAULTLISTENER)) {
- if(!doc->nscontainer->event_vector) {
- doc->nscontainer->event_vector = heap_alloc_zero(EVENTID_LAST*sizeof(BOOL));
- if(!doc->nscontainer->event_vector)
+ if(doc->window->nswindow && (event_info[eid].flags & EVENT_DEFAULTLISTENER)) {
+ if(!doc->window->event_vector) {
+ doc->window->event_vector = heap_alloc_zero(EVENTID_LAST*sizeof(BOOL));
+ if(!doc->window->event_vector)
return E_OUTOFMEMORY;
}
- if(!doc->nscontainer->event_vector[eid]) {
- doc->nscontainer->event_vector[eid] = TRUE;
- add_nsevent_listener(doc->nscontainer, event_info[eid].name);
+ if(!doc->window->event_vector[eid]) {
+ doc->window->event_vector[eid] = TRUE;
+ add_nsevent_listener(doc->window, event_info[eid].name);
}
}
diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c
index c08929bed6..8fae282e64 100644
--- a/dlls/mshtml/htmlwindow.c
+++ b/dlls/mshtml/htmlwindow.c
@@ -110,6 +110,7 @@ static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
for(i=0; i < This->global_prop_cnt; i++)
heap_free(This->global_props[i].name);
heap_free(This->global_props);
+ heap_free(This->event_vector);
release_script_hosts(This);
list_remove(&This->entry);
release_dispex(&This->dispex);
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 91fca71c10..6f65787f3b 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -198,6 +198,7 @@ struct HTMLWindow {
event_target_t *event_target;
IHTMLEventObj *event;
+ BOOL *event_vector;
SCRIPTMODE scriptmode;
struct list script_hosts;
@@ -401,8 +402,6 @@ struct NSContainer {
nsChannelBSC *bscallback; /* hack */
HWND reset_focus; /* hack */
-
- BOOL *event_vector;
};
typedef struct {
@@ -613,7 +612,7 @@ nsICommandParams *create_nscommand_params(void);
HRESULT nsnode_to_nsstring(nsIDOMNode*,nsAString*);
void get_editor_controller(NSContainer*);
void init_nsevents(NSContainer*);
-void add_nsevent_listener(NSContainer*,LPCWSTR);
+void add_nsevent_listener(HTMLWindow*,LPCWSTR);
nsresult get_nsinterface(nsISupports*,REFIID,void**);
void update_nsdocument(HTMLDocument*);
diff --git a/dlls/mshtml/nsembed.c b/dlls/mshtml/nsembed.c
index 50001aa72b..0abb2b4224 100644
--- a/dlls/mshtml/nsembed.c
+++ b/dlls/mshtml/nsembed.c
@@ -932,7 +932,6 @@ static nsrefcnt NSAPI nsWebBrowserChrome_Release(nsIWebBrowserChrome *iface)
TRACE("(%p) ref=%d\n", This, ref);
if(!ref) {
- heap_free(This->event_vector);
if(This->parent)
nsIWebBrowserChrome_Release(NSWBCHROME(This->parent));
heap_free(This);
diff --git a/dlls/mshtml/nsevents.c b/dlls/mshtml/nsevents.c
index 40900a75af..d131e8d03c 100644
--- a/dlls/mshtml/nsevents.c
+++ b/dlls/mshtml/nsevents.c
@@ -235,26 +235,18 @@ static void init_listener(nsEventListener *This, NSContainer *container,
This->This = container;
}
-void add_nsevent_listener(NSContainer *container, LPCWSTR type)
+void add_nsevent_listener(HTMLWindow *window, LPCWSTR type)
{
- nsIDOMWindow *dom_window;
nsIDOMEventTarget *target;
nsresult nsres;
- nsres = nsIWebBrowser_GetContentDOMWindow(container->webbrowser, &dom_window);
- if(NS_FAILED(nsres)) {
- ERR("GetContentDOMWindow failed: %08x\n", nsres);
- return;
- }
-
- nsres = nsIDOMWindow_QueryInterface(dom_window, &IID_nsIDOMEventTarget, (void**)&target);
- nsIDOMWindow_Release(dom_window);
+ nsres = nsIDOMWindow_QueryInterface(window->nswindow, &IID_nsIDOMEventTarget, (void**)&target);
if(NS_FAILED(nsres)) {
ERR("Could not get nsIDOMEventTarget interface: %08x\n", nsres);
return;
}
- init_event(target, type, NSEVENTLIST(&container->htmlevent_listener), TRUE);
+ init_event(target, type, NSEVENTLIST(&window->doc->nscontainer->htmlevent_listener), TRUE);
nsIDOMEventTarget_Release(target);
}