mshtml: Moved event_vector to HTMLWindow.

This commit is contained in:
Jacek Caban 2009-09-16 22:07:17 +02:00 committed by Alexandre Julliard
parent ff0d147b22
commit 4956e3edb5
5 changed files with 13 additions and 22 deletions

View File

@ -856,16 +856,16 @@ static HRESULT set_event_handler_disp(event_target_t **event_target_ptr, HTMLDoc
return S_OK; return S_OK;
IDispatch_AddRef(disp); IDispatch_AddRef(disp);
if(doc->nscontainer && (event_info[eid].flags & EVENT_DEFAULTLISTENER)) { if(doc->window->nswindow && (event_info[eid].flags & EVENT_DEFAULTLISTENER)) {
if(!doc->nscontainer->event_vector) { if(!doc->window->event_vector) {
doc->nscontainer->event_vector = heap_alloc_zero(EVENTID_LAST*sizeof(BOOL)); doc->window->event_vector = heap_alloc_zero(EVENTID_LAST*sizeof(BOOL));
if(!doc->nscontainer->event_vector) if(!doc->window->event_vector)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
if(!doc->nscontainer->event_vector[eid]) { if(!doc->window->event_vector[eid]) {
doc->nscontainer->event_vector[eid] = TRUE; doc->window->event_vector[eid] = TRUE;
add_nsevent_listener(doc->nscontainer, event_info[eid].name); add_nsevent_listener(doc->window, event_info[eid].name);
} }
} }

View File

@ -110,6 +110,7 @@ static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
for(i=0; i < This->global_prop_cnt; i++) for(i=0; i < This->global_prop_cnt; i++)
heap_free(This->global_props[i].name); heap_free(This->global_props[i].name);
heap_free(This->global_props); heap_free(This->global_props);
heap_free(This->event_vector);
release_script_hosts(This); release_script_hosts(This);
list_remove(&This->entry); list_remove(&This->entry);
release_dispex(&This->dispex); release_dispex(&This->dispex);

View File

@ -198,6 +198,7 @@ struct HTMLWindow {
event_target_t *event_target; event_target_t *event_target;
IHTMLEventObj *event; IHTMLEventObj *event;
BOOL *event_vector;
SCRIPTMODE scriptmode; SCRIPTMODE scriptmode;
struct list script_hosts; struct list script_hosts;
@ -401,8 +402,6 @@ struct NSContainer {
nsChannelBSC *bscallback; /* hack */ nsChannelBSC *bscallback; /* hack */
HWND reset_focus; /* hack */ HWND reset_focus; /* hack */
BOOL *event_vector;
}; };
typedef struct { typedef struct {
@ -613,7 +612,7 @@ nsICommandParams *create_nscommand_params(void);
HRESULT nsnode_to_nsstring(nsIDOMNode*,nsAString*); HRESULT nsnode_to_nsstring(nsIDOMNode*,nsAString*);
void get_editor_controller(NSContainer*); void get_editor_controller(NSContainer*);
void init_nsevents(NSContainer*); void init_nsevents(NSContainer*);
void add_nsevent_listener(NSContainer*,LPCWSTR); void add_nsevent_listener(HTMLWindow*,LPCWSTR);
nsresult get_nsinterface(nsISupports*,REFIID,void**); nsresult get_nsinterface(nsISupports*,REFIID,void**);
void update_nsdocument(HTMLDocument*); void update_nsdocument(HTMLDocument*);

View File

@ -932,7 +932,6 @@ static nsrefcnt NSAPI nsWebBrowserChrome_Release(nsIWebBrowserChrome *iface)
TRACE("(%p) ref=%d\n", This, ref); TRACE("(%p) ref=%d\n", This, ref);
if(!ref) { if(!ref) {
heap_free(This->event_vector);
if(This->parent) if(This->parent)
nsIWebBrowserChrome_Release(NSWBCHROME(This->parent)); nsIWebBrowserChrome_Release(NSWBCHROME(This->parent));
heap_free(This); heap_free(This);

View File

@ -235,26 +235,18 @@ static void init_listener(nsEventListener *This, NSContainer *container,
This->This = 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; nsIDOMEventTarget *target;
nsresult nsres; nsresult nsres;
nsres = nsIWebBrowser_GetContentDOMWindow(container->webbrowser, &dom_window); nsres = nsIDOMWindow_QueryInterface(window->nswindow, &IID_nsIDOMEventTarget, (void**)&target);
if(NS_FAILED(nsres)) {
ERR("GetContentDOMWindow failed: %08x\n", nsres);
return;
}
nsres = nsIDOMWindow_QueryInterface(dom_window, &IID_nsIDOMEventTarget, (void**)&target);
nsIDOMWindow_Release(dom_window);
if(NS_FAILED(nsres)) { if(NS_FAILED(nsres)) {
ERR("Could not get nsIDOMEventTarget interface: %08x\n", nsres); ERR("Could not get nsIDOMEventTarget interface: %08x\n", nsres);
return; return;
} }
init_event(target, type, NSEVENTLIST(&container->htmlevent_listener), TRUE); init_event(target, type, NSEVENTLIST(&window->doc->nscontainer->htmlevent_listener), TRUE);
nsIDOMEventTarget_Release(target); nsIDOMEventTarget_Release(target);
} }