From 2610ef9c9ce9e25b8a4ea6c8b3e707c34379808f Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 2 Aug 2011 11:08:32 +0200 Subject: [PATCH] mshtml: Always alloc event_vector for documents. --- dlls/mshtml/htmldoc.c | 3 +-- dlls/mshtml/htmlevent.c | 16 ++++++++++------ dlls/mshtml/htmlevent.h | 1 + 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 38d4bf3c998..f625602adb2 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -2164,8 +2164,6 @@ static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLWindow *wi &doc->node.dispex.IDispatchEx_iface); HTMLDocumentNode_SecMgr_Init(doc); - init_nsevents(doc); - list_init(&doc->bindings); list_init(&doc->selection_list); list_init(&doc->range_list); @@ -2188,6 +2186,7 @@ HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_ob nsIDOMHTMLDocument_AddRef(nsdoc); doc->nsdoc = nsdoc; init_document_mutation(doc); + doc_init_events(doc); HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc); doc->node.vtbl = &HTMLDocumentNodeImplVtbl; diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c index 85e2b4b2fdd..c0a998b55e4 100644 --- a/dlls/mshtml/htmlevent.c +++ b/dlls/mshtml/htmlevent.c @@ -1182,12 +1182,6 @@ static HRESULT ensure_nsevent_handler(HTMLDocumentNode *doc, event_target_t *eve if(!(event_info[eid].flags & EVENT_DEFAULTLISTENER)) return S_OK; - if(!doc->event_vector) { - doc->event_vector = heap_alloc_zero(EVENTID_LAST*sizeof(BOOL)); - if(!doc->event_vector) - return E_OUTOFMEMORY; - } - if(!doc->event_vector[eid]) { doc->event_vector[eid] = TRUE; add_nsevent_listener(doc, NULL, event_info[eid].name); @@ -1375,6 +1369,16 @@ void check_event_attr(HTMLDocumentNode *doc, nsIDOMElement *nselem) nsAString_Finish(&attr_name_str); } +HRESULT doc_init_events(HTMLDocumentNode *doc) +{ + doc->event_vector = heap_alloc_zero(EVENTID_LAST*sizeof(BOOL)); + if(!doc->event_vector) + return E_OUTOFMEMORY; + + init_nsevents(doc); + return S_OK; +} + void release_event_target(event_target_t *event_target) { int i, j; diff --git a/dlls/mshtml/htmlevent.h b/dlls/mshtml/htmlevent.h index 5615bbdf2f8..90724827391 100644 --- a/dlls/mshtml/htmlevent.h +++ b/dlls/mshtml/htmlevent.h @@ -53,6 +53,7 @@ HRESULT detach_event(event_target_t*,HTMLDocument*,BSTR,IDispatch*) DECLSPEC_HID HRESULT dispatch_event(HTMLDOMNode*,const WCHAR*,VARIANT*,VARIANT_BOOL*) DECLSPEC_HIDDEN; HRESULT call_fire_event(HTMLDOMNode*,eventid_t) DECLSPEC_HIDDEN; void update_cp_events(HTMLWindow*,event_target_t**,cp_static_data_t*,nsIDOMNode*) DECLSPEC_HIDDEN; +HRESULT doc_init_events(HTMLDocumentNode*) DECLSPEC_HIDDEN; void init_nsevents(HTMLDocumentNode*) DECLSPEC_HIDDEN; void release_nsevents(HTMLDocumentNode*) DECLSPEC_HIDDEN;