Commit 361f9a30 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Moved event_vector to HTMLDocumentNode.

parent d52f41ba
......@@ -1777,6 +1777,7 @@ static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
nsIDOMHTMLDocument_Release(This->nsdoc);
}
heap_free(This->event_vector);
destroy_htmldoc(&This->basedoc);
}
......
......@@ -921,7 +921,8 @@ static BOOL alloc_handler_vector(event_target_t *event_target, eventid_t eid, in
return TRUE;
}
static HRESULT set_event_handler_disp(event_target_t **event_target_ptr, HTMLWindow *window, eventid_t eid, IDispatch *disp)
static HRESULT set_event_handler_disp(event_target_t **event_target_ptr, HTMLDocumentNode *doc,
eventid_t eid, IDispatch *disp)
{
event_target_t *event_target;
......@@ -940,23 +941,23 @@ static HRESULT set_event_handler_disp(event_target_t **event_target_ptr, HTMLWin
return S_OK;
IDispatch_AddRef(disp);
if(window->nswindow && (event_info[eid].flags & EVENT_DEFAULTLISTENER)) {
if(!window->event_vector) {
window->event_vector = heap_alloc_zero(EVENTID_LAST*sizeof(BOOL));
if(!window->event_vector)
if(doc->nsdoc && (event_info[eid].flags & EVENT_DEFAULTLISTENER)) {
if(!doc->event_vector) {
doc->event_vector = heap_alloc_zero(EVENTID_LAST*sizeof(BOOL));
if(!doc->event_vector)
return E_OUTOFMEMORY;
}
if(!window->event_vector[eid]) {
window->event_vector[eid] = TRUE;
add_nsevent_listener(window, event_info[eid].name);
if(!doc->event_vector[eid]) {
doc->event_vector[eid] = TRUE;
add_nsevent_listener(doc, event_info[eid].name);
}
}
return S_OK;
}
HRESULT set_event_handler(event_target_t **event_target, HTMLDocument *doc, eventid_t eid, VARIANT *var)
HRESULT set_event_handler(event_target_t **event_target, HTMLDocumentNode *doc, eventid_t eid, VARIANT *var)
{
switch(V_VT(var)) {
case VT_NULL:
......@@ -967,7 +968,7 @@ HRESULT set_event_handler(event_target_t **event_target, HTMLDocument *doc, even
break;
case VT_DISPATCH:
return set_event_handler_disp(event_target, doc->window, eid, V_DISPATCH(var));
return set_event_handler_disp(event_target, doc, eid, V_DISPATCH(var));
default:
FIXME("not supported vt=%d\n", V_VT(var));
......@@ -1048,7 +1049,7 @@ void check_event_attr(HTMLDocumentNode *doc, nsIDOMElement *nselem)
disp = script_parse_event(doc->basedoc.window, attr_value);
if(disp) {
node = get_node(doc, (nsIDOMNode*)nselem, TRUE);
set_event_handler_disp(get_node_event_target(node), node->doc->basedoc.window, i, disp);
set_event_handler_disp(get_node_event_target(node), node->doc, i, disp);
IDispatch_Release(disp);
}
}
......
......@@ -42,7 +42,7 @@ eventid_t str_to_eid(LPCWSTR);
void check_event_attr(HTMLDocumentNode*,nsIDOMElement*);
void release_event_target(event_target_t*);
void fire_event(HTMLDocumentNode*,eventid_t,nsIDOMNode*,nsIDOMEvent*);
HRESULT set_event_handler(event_target_t**,HTMLDocument*,eventid_t,VARIANT*);
HRESULT set_event_handler(event_target_t**,HTMLDocumentNode*,eventid_t,VARIANT*);
HRESULT get_event_handler(event_target_t**,eventid_t,VARIANT*);
HRESULT attach_event(event_target_t**,HTMLDocument*,BSTR,IDispatch*,VARIANT_BOOL*);
HRESULT dispatch_event(HTMLDOMNode*,const WCHAR*,VARIANT*,VARIANT_BOOL*);
......@@ -55,7 +55,7 @@ static inline event_target_t **get_node_event_target(HTMLDOMNode *node)
static inline HRESULT set_node_event(HTMLDOMNode *node, eventid_t eid, VARIANT *var)
{
return set_event_handler(get_node_event_target(node), &node->doc->basedoc, eid, var);
return set_event_handler(get_node_event_target(node), node->doc, eid, var);
}
static inline HRESULT get_node_event(HTMLDOMNode *node, eventid_t eid, VARIANT *var)
......@@ -75,7 +75,7 @@ static inline HRESULT get_doc_event(HTMLDocument *doc, eventid_t eid, VARIANT *v
static inline HRESULT set_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
{
return set_event_handler(&window->event_target, &window->doc_obj->basedoc, eid, var);
return set_event_handler(&window->event_target, window->doc, eid, var);
}
static inline HRESULT get_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
......
......@@ -189,7 +189,6 @@ static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
windowref_release(This->window_ref);
heap_free(This->global_props);
heap_free(This->event_vector);
release_script_hosts(This);
list_remove(&This->entry);
release_dispex(&This->dispex);
......
......@@ -226,7 +226,6 @@ struct HTMLWindow {
event_target_t *event_target;
IHTMLEventObj *event;
BOOL *event_vector;
SCRIPTMODE scriptmode;
struct list script_hosts;
......@@ -487,6 +486,7 @@ struct HTMLDocumentNode {
IInternetSecurityManager *secmgr;
nsDocumentEventListener *nsevent_listener;
BOOL *event_vector;
mutation_queue_t *mutation_queue;
mutation_queue_t *mutation_queue_tail;
......@@ -652,7 +652,7 @@ nsresult get_nsinterface(nsISupports*,REFIID,void**);
void init_nsevents(HTMLDocumentNode*);
void release_nsevents(HTMLDocumentNode*);
void add_nsevent_listener(HTMLWindow*,LPCWSTR);
void add_nsevent_listener(HTMLDocumentNode*,LPCWSTR);
void set_window_bscallback(HTMLWindow*,nsChannelBSC*);
void set_current_mon(HTMLWindow*,IMoniker*);
......
......@@ -282,18 +282,18 @@ static void init_listener(nsEventListener *This, nsDocumentEventListener *listen
This->This = listener;
}
void add_nsevent_listener(HTMLWindow *window, LPCWSTR type)
void add_nsevent_listener(HTMLDocumentNode *doc, LPCWSTR type)
{
nsIDOMEventTarget *target;
nsresult nsres;
nsres = nsIDOMWindow_QueryInterface(window->nswindow, &IID_nsIDOMEventTarget, (void**)&target);
nsres = nsIDOMWindow_QueryInterface(doc->basedoc.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(&window->doc->nsevent_listener->htmlevent_listener), TRUE);
init_event(target, type, NSEVENTLIST(&doc->nsevent_listener->htmlevent_listener), TRUE);
nsIDOMEventTarget_Release(target);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment