From: Gabriel Ivăncescu gabrielopcode@gmail.com
DOM Nodes don't make use of the destructor yet, so they are special case no-ops as temporary exceptions, because they still use their own mechanism which will change in the future.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/dispex.c | 64 ++++++++++++++------ dlls/mshtml/htmlattr.c | 8 +-- dlls/mshtml/htmldoc.c | 12 +++- dlls/mshtml/htmlelem.c | 55 +++++------------ dlls/mshtml/htmlelemcol.c | 10 +-- dlls/mshtml/htmlevent.c | 21 ++----- dlls/mshtml/htmlevent.h | 2 - dlls/mshtml/htmlimg.c | 8 +-- dlls/mshtml/htmllocation.c | 8 +-- dlls/mshtml/htmlnode.c | 25 ++++---- dlls/mshtml/htmlselect.c | 8 +-- dlls/mshtml/htmlstorage.c | 9 +-- dlls/mshtml/htmlstyle.c | 8 +-- dlls/mshtml/htmlstyle.h | 2 - dlls/mshtml/htmlstylesheet.c | 40 +++--------- dlls/mshtml/htmltextnode.c | 10 ++- dlls/mshtml/htmlwindow.c | 18 +++--- dlls/mshtml/mshtml_private.h | 53 ++++++++-------- dlls/mshtml/mutation.c | 19 ++---- dlls/mshtml/nsembed.c | 1 + dlls/mshtml/omnavigator.c | 114 ++++++++--------------------------- dlls/mshtml/range.c | 20 ++---- dlls/mshtml/selection.c | 10 +-- dlls/mshtml/xmlhttprequest.c | 18 +++--- 24 files changed, 196 insertions(+), 347 deletions(-)
diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index 5f1fb98ddab..53aeba303a2 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -33,6 +33,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
#define MAX_ARGS 16
+ExternalCycleCollectionParticipant dispex_ccp; + static CRITICAL_SECTION cs_dispex_static_data; static CRITICAL_SECTION_DEBUG cs_dispex_static_data_dbg = { @@ -88,7 +90,6 @@ typedef struct { typedef struct { DispatchEx dispex; IUnknown IUnknown_iface; - LONG ref; DispatchEx *obj; func_info_t *info; } func_disp_t; @@ -812,7 +813,7 @@ static HRESULT WINAPI Function_QueryInterface(IUnknown *iface, REFIID riid, void static ULONG WINAPI Function_AddRef(IUnknown *iface) { func_disp_t *This = impl_from_IUnknown(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -822,13 +823,10 @@ static ULONG WINAPI Function_AddRef(IUnknown *iface) static ULONG WINAPI Function_Release(IUnknown *iface) { func_disp_t *This = impl_from_IUnknown(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -933,7 +931,6 @@ static func_disp_t *create_func_disp(DispatchEx *obj, func_info_t *info)
ret->IUnknown_iface.lpVtbl = &FunctionUnkVtbl; init_dispatch(&ret->dispex, &ret->IUnknown_iface, &function_dispex, dispex_compat_mode(obj)); - ret->ref = 1; ret->obj = obj; ret->info = info;
@@ -1979,7 +1976,13 @@ BOOL dispex_query_interface(DispatchEx *This, REFIID riid, void **ppv) *ppv = &This->IDispatchEx_iface; else if(IsEqualGUID(&IID_IDispatchEx, riid)) *ppv = &This->IDispatchEx_iface; - else if(IsEqualGUID(&IID_IDispatchJS, riid)) + else if(IsEqualGUID(&IID_nsXPCOMCycleCollectionParticipant, riid)) { + *ppv = &dispex_ccp; + return TRUE; + }else if(IsEqualGUID(&IID_nsCycleCollectionISupports, riid)) { + *ppv = &This->IDispatchEx_iface; + return TRUE; + }else if(IsEqualGUID(&IID_IDispatchJS, riid)) *ppv = NULL; else if(IsEqualGUID(&IID_UndocumentedScriptIface, riid)) *ppv = NULL; @@ -1995,12 +1998,15 @@ BOOL dispex_query_interface(DispatchEx *This, REFIID riid, void **ppv) return TRUE; }
-void dispex_traverse(DispatchEx *This, nsCycleCollectionTraversalCallback *cb) +static nsresult NSAPI dispex_traverse(void *ccp, void *p, nsCycleCollectionTraversalCallback *cb) { + DispatchEx *This = impl_from_IDispatchEx(p); dynamic_prop_t *prop;
+ describe_cc_node(&This->ccref, This->info->desc->name, cb); + if(!This->dynamic_data) - return; + return NS_OK;
for(prop = This->dynamic_data->props; prop < This->dynamic_data->props + This->dynamic_data->prop_cnt; prop++) { if(V_VT(&prop->var) == VT_DISPATCH) @@ -2018,9 +2024,11 @@ void dispex_traverse(DispatchEx *This, nsCycleCollectionTraversalCallback *cb) note_cc_edge((nsISupports*)V_DISPATCH(&iter->val), "func_val", cb); } } + + return NS_OK; }
-void dispex_unlink(DispatchEx *This) +void dispex_props_unlink(DispatchEx *This) { dynamic_prop_t *prop;
@@ -2048,16 +2056,23 @@ void dispex_unlink(DispatchEx *This) } }
-const void *dispex_get_vtbl(DispatchEx *dispex) +nsresult NSAPI dispex_unlink(void *p) { - return dispex->info->desc->vtbl; + DispatchEx *This = impl_from_IDispatchEx(p); + + if(This->info->desc->vtbl->unlink) + This->info->desc->vtbl->unlink(This); + + dispex_props_unlink(This); + return NS_OK; }
-void release_dispex(DispatchEx *This) +void NSAPI dispex_delete_cycle_collectable(void *p) { + DispatchEx *This = impl_from_IDispatchEx(p); dynamic_prop_t *prop;
- if(This->info->desc->vtbl && This->info->desc->vtbl->unlink) + if(This->info->desc->vtbl->unlink) This->info->desc->vtbl->unlink(This);
if(!This->dynamic_data) @@ -2087,8 +2102,22 @@ void release_dispex(DispatchEx *This) free(This->dynamic_data);
destructor: - if(This->info->desc->vtbl && This->info->desc->vtbl->destructor) - This->info->desc->vtbl->destructor(This); + This->info->desc->vtbl->destructor(This); +} + +void init_dispex_cc(void) +{ + static const CCObjCallback dispex_ccp_callback = { + dispex_traverse, + dispex_unlink, + dispex_delete_cycle_collectable + }; + ccp_init(&dispex_ccp, &dispex_ccp_callback); +} + +const void *dispex_get_vtbl(DispatchEx *dispex) +{ + return dispex->info->desc->vtbl; }
void init_dispatch(DispatchEx *dispex, IUnknown *outer, dispex_static_data_t *data, compat_mode_t compat_mode) @@ -2098,6 +2127,7 @@ void init_dispatch(DispatchEx *dispex, IUnknown *outer, dispex_static_data_t *da dispex->IDispatchEx_iface.lpVtbl = &DispatchExVtbl; dispex->outer = outer; dispex->dynamic_data = NULL; + ccref_init(&dispex->ccref, 1);
if(data->vtbl && data->vtbl->get_compat_mode) { /* delayed init */ diff --git a/dlls/mshtml/htmlattr.c b/dlls/mshtml/htmlattr.c index 112c03cb0b5..bb8a0b1e3f3 100644 --- a/dlls/mshtml/htmlattr.c +++ b/dlls/mshtml/htmlattr.c @@ -65,7 +65,7 @@ static HRESULT WINAPI HTMLDOMAttribute_QueryInterface(IHTMLDOMAttribute *iface, static ULONG WINAPI HTMLDOMAttribute_AddRef(IHTMLDOMAttribute *iface) { HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -75,13 +75,10 @@ static ULONG WINAPI HTMLDOMAttribute_AddRef(IHTMLDOMAttribute *iface) static ULONG WINAPI HTMLDOMAttribute_Release(IHTMLDOMAttribute *iface) { HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -529,7 +526,6 @@ HRESULT HTMLDOMAttribute_Create(const WCHAR *name, HTMLElement *elem, DISPID dis
ret->IHTMLDOMAttribute_iface.lpVtbl = &HTMLDOMAttributeVtbl; ret->IHTMLDOMAttribute2_iface.lpVtbl = &HTMLDOMAttribute2Vtbl; - ret->ref = 1; ret->dispid = dispid; ret->elem = elem;
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index d4761db77aa..e48b80efa79 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -295,6 +295,10 @@ static inline DocumentType *DocumentType_from_DispatchEx(DispatchEx *iface) return CONTAINING_RECORD(iface, DocumentType, node.event_target.dispex); }
+static void DocumentType_dispex_destructor(DispatchEx *dispex) +{ +} + static HRESULT DocumentType_QI(HTMLDOMNode *iface, REFIID riid, void **ppv) { DocumentType *This = DocumentType_from_HTMLDOMNode(iface); @@ -367,6 +371,7 @@ static IHTMLEventObj *DocumentType_set_current_event(DispatchEx *dispex, IHTMLEv
static event_target_vtbl_t DocumentType_event_target_vtbl = { { + DocumentType_dispex_destructor, NULL, }, DocumentType_get_gecko_target, @@ -5915,6 +5920,10 @@ static inline HTMLDocumentNode *impl_from_DispatchEx(DispatchEx *iface) return CONTAINING_RECORD(iface, HTMLDocumentNode, node.event_target.dispex); }
+static void HTMLDocumentNode_dispex_destructor(DispatchEx *dispex) +{ +} + static HRESULT HTMLDocumentNode_get_name(DispatchEx *dispex, DISPID id, BSTR *name) { HTMLDocumentNode *This = impl_from_DispatchEx(dispex); @@ -6086,7 +6095,7 @@ static HRESULT HTMLDocumentNode_location_hook(DispatchEx *dispex, WORD flags, DI
static const event_target_vtbl_t HTMLDocumentNode_event_target_vtbl = { { - NULL, + HTMLDocumentNode_dispex_destructor, NULL, NULL, NULL, @@ -6195,7 +6204,6 @@ static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindo if(!doc) return NULL;
- doc->ref = 1; doc->IDispatchEx_iface.lpVtbl = &DocDispatchExVtbl; doc->IHTMLDocument2_iface.lpVtbl = &HTMLDocumentVtbl; doc->IHTMLDocument3_iface.lpVtbl = &HTMLDocument3Vtbl; diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index 838f4a2ae66..902e4c9f3e7 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -339,8 +339,6 @@ typedef struct { DispatchEx dispex; IHTMLFiltersCollection IHTMLFiltersCollection_iface; - - LONG ref; } HTMLFiltersCollection;
static inline HTMLFiltersCollection *impl_from_IHTMLFiltersCollection(IHTMLFiltersCollection *iface) @@ -531,8 +529,6 @@ typedef struct { IHTMLRect IHTMLRect_iface; IHTMLRect2 IHTMLRect2_iface;
- LONG ref; - nsIDOMClientRect *nsrect; } HTMLRect;
@@ -568,7 +564,7 @@ static HRESULT WINAPI HTMLRect_QueryInterface(IHTMLRect *iface, REFIID riid, voi static ULONG WINAPI HTMLRect_AddRef(IHTMLRect *iface) { HTMLRect *This = impl_from_IHTMLRect(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -578,13 +574,10 @@ static ULONG WINAPI HTMLRect_AddRef(IHTMLRect *iface) static ULONG WINAPI HTMLRect_Release(IHTMLRect *iface) { HTMLRect *This = impl_from_IHTMLRect(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -887,7 +880,6 @@ static HRESULT create_html_rect(nsIDOMClientRect *nsrect, compat_mode_t compat_m
rect->IHTMLRect_iface.lpVtbl = &HTMLRectVtbl; rect->IHTMLRect2_iface.lpVtbl = &HTMLRect2Vtbl; - rect->ref = 1;
init_dispatch(&rect->dispex, (IUnknown*)&rect->IHTMLRect_iface, &HTMLRect_dispex, compat_mode);
@@ -902,8 +894,6 @@ typedef struct { DispatchEx dispex; IHTMLRectCollection IHTMLRectCollection_iface;
- LONG ref; - nsIDOMClientRectList *rect_list; } HTMLRectCollection;
@@ -1070,7 +1060,7 @@ static HRESULT WINAPI HTMLRectCollection_QueryInterface(IHTMLRectCollection *ifa static ULONG WINAPI HTMLRectCollection_AddRef(IHTMLRectCollection *iface) { HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -1080,13 +1070,10 @@ static ULONG WINAPI HTMLRectCollection_AddRef(IHTMLRectCollection *iface) static ULONG WINAPI HTMLRectCollection_Release(IHTMLRectCollection *iface) { HTMLRectCollection *This = impl_from_IHTMLRectCollection(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -3327,7 +3314,6 @@ static HRESULT WINAPI HTMLElement2_getClientRects(IHTMLElement2 *iface, IHTMLRec }
rects->IHTMLRectCollection_iface.lpVtbl = &HTMLRectCollectionVtbl; - rects->ref = 1; rects->rect_list = rect_list; init_dispatch(&rects->dispex, (IUnknown*)&rects->IHTMLRectCollection_iface, &HTMLRectCollection_dispex, dispex_compat_mode(&This->node.event_target.dispex)); @@ -6961,6 +6947,10 @@ static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface) return CONTAINING_RECORD(iface, HTMLElement, node.event_target.dispex); }
+static void HTMLElement_dispex_destructor(DispatchEx *dispex) +{ +} + static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name, DWORD grfdex, DISPID *pid) { @@ -7356,7 +7346,7 @@ static const tid_t HTMLElement_iface_tids[] = {
const event_target_vtbl_t HTMLElement_event_target_vtbl = { { - NULL, + HTMLElement_dispex_destructor, NULL, NULL, HTMLElement_get_dispid, @@ -7379,8 +7369,6 @@ struct token_list { DispatchEx dispex; IWineDOMTokenList IWineDOMTokenList_iface; IHTMLElement *element; - - LONG ref; };
static inline struct token_list *impl_from_IWineDOMTokenList(IWineDOMTokenList *iface) @@ -7413,7 +7401,7 @@ static HRESULT WINAPI token_list_QueryInterface(IWineDOMTokenList *iface, REFIID static ULONG WINAPI token_list_AddRef(IWineDOMTokenList *iface) { struct token_list *token_list = impl_from_IWineDOMTokenList(iface); - LONG ref = InterlockedIncrement(&token_list->ref); + LONG ref = dispex_ccref_incr(&token_list->dispex);
TRACE("(%p) ref=%ld\n", token_list, ref);
@@ -7423,13 +7411,10 @@ static ULONG WINAPI token_list_AddRef(IWineDOMTokenList *iface) static ULONG WINAPI token_list_Release(IWineDOMTokenList *iface) { struct token_list *token_list = impl_from_IWineDOMTokenList(iface); - LONG ref = InterlockedDecrement(&token_list->ref); + LONG ref = dispex_ccref_decr(&token_list->dispex);
TRACE("(%p) ref=%ld\n", token_list, ref);
- if(!ref) - release_dispex(&token_list->dispex); - return ref; }
@@ -7865,7 +7850,6 @@ static HRESULT create_token_list(compat_mode_t compat_mode, IHTMLElement *elemen }
obj->IWineDOMTokenList_iface.lpVtbl = &WineDOMTokenListVtbl; - obj->ref = 1; init_dispatch(&obj->dispex, (IUnknown*)&obj->IWineDOMTokenList_iface, &token_list_dispex, compat_mode); IHTMLElement_AddRef(element); obj->element = element; @@ -8120,7 +8104,7 @@ static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollectio static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface) { HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -8130,13 +8114,10 @@ static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface) static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface) { HTMLFiltersCollection *This = impl_from_IHTMLFiltersCollection(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -8289,7 +8270,6 @@ static HRESULT create_filters_collection(compat_mode_t compat_mode, IHTMLFilters return E_OUTOFMEMORY;
collection->IHTMLFiltersCollection_iface.lpVtbl = &HTMLFiltersCollectionVtbl; - collection->ref = 1;
init_dispatch(&collection->dispex, (IUnknown*)&collection->IHTMLFiltersCollection_iface, &HTMLFiltersCollection_dispex, min(compat_mode, COMPAT_MODE_IE8)); @@ -8580,7 +8560,7 @@ static HRESULT WINAPI HTMLAttributeCollection_QueryInterface(IHTMLAttributeColle static ULONG WINAPI HTMLAttributeCollection_AddRef(IHTMLAttributeCollection *iface) { HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -8590,13 +8570,10 @@ static ULONG WINAPI HTMLAttributeCollection_AddRef(IHTMLAttributeCollection *ifa static ULONG WINAPI HTMLAttributeCollection_Release(IHTMLAttributeCollection *iface) { HTMLAttributeCollection *This = impl_from_IHTMLAttributeCollection(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -9068,7 +9045,6 @@ HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **a This->attrs->IHTMLAttributeCollection_iface.lpVtbl = &HTMLAttributeCollectionVtbl; This->attrs->IHTMLAttributeCollection2_iface.lpVtbl = &HTMLAttributeCollection2Vtbl; This->attrs->IHTMLAttributeCollection3_iface.lpVtbl = &HTMLAttributeCollection3Vtbl; - This->attrs->ref = 2;
This->attrs->elem = This; list_init(&This->attrs->attrs); @@ -9076,5 +9052,6 @@ HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **a &HTMLAttributeCollection_dispex, dispex_compat_mode(&iface->event_target.dispex));
*ac = This->attrs; + IHTMLAttributeCollection_AddRef(&This->attrs->IHTMLAttributeCollection_iface); return S_OK; } diff --git a/dlls/mshtml/htmlelemcol.c b/dlls/mshtml/htmlelemcol.c index 79dd59fca91..c9448adbe09 100644 --- a/dlls/mshtml/htmlelemcol.c +++ b/dlls/mshtml/htmlelemcol.c @@ -37,8 +37,6 @@ typedef struct {
HTMLElement **elems; DWORD len; - - LONG ref; } HTMLElementCollection;
typedef struct { @@ -238,7 +236,7 @@ static HRESULT WINAPI HTMLElementCollection_QueryInterface(IHTMLElementCollectio static ULONG WINAPI HTMLElementCollection_AddRef(IHTMLElementCollection *iface) { HTMLElementCollection *This = impl_from_IHTMLElementCollection(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -248,13 +246,10 @@ static ULONG WINAPI HTMLElementCollection_AddRef(IHTMLElementCollection *iface) static ULONG WINAPI HTMLElementCollection_Release(IHTMLElementCollection *iface) { HTMLElementCollection *This = impl_from_IHTMLElementCollection(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -866,7 +861,6 @@ static IHTMLElementCollection *HTMLElementCollection_Create(HTMLElement **elems, return NULL;
ret->IHTMLElementCollection_iface.lpVtbl = &HTMLElementCollectionVtbl; - ret->ref = 1; ret->elems = elems; ret->len = len;
diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c index 41c8b36e941..79dc58bb57d 100644 --- a/dlls/mshtml/htmlevent.c +++ b/dlls/mshtml/htmlevent.c @@ -335,8 +335,6 @@ typedef struct { DispatchEx dispex; IHTMLEventObj IHTMLEventObj_iface;
- LONG ref; - DOMEvent *event; VARIANT return_value; } HTMLEventObj; @@ -371,7 +369,7 @@ static HRESULT WINAPI HTMLEventObj_QueryInterface(IHTMLEventObj *iface, REFIID r static ULONG WINAPI HTMLEventObj_AddRef(IHTMLEventObj *iface) { HTMLEventObj *This = impl_from_IHTMLEventObj(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -381,13 +379,10 @@ static ULONG WINAPI HTMLEventObj_AddRef(IHTMLEventObj *iface) static ULONG WINAPI HTMLEventObj_Release(IHTMLEventObj *iface) { HTMLEventObj *This = impl_from_IHTMLEventObj(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -915,7 +910,6 @@ static HTMLEventObj *alloc_event_obj(DOMEvent *event, compat_mode_t compat_mode) return NULL;
event_obj->IHTMLEventObj_iface.lpVtbl = &HTMLEventObjVtbl; - event_obj->ref = 1; event_obj->event = event; if(event) IDOMEvent_AddRef(&event->IDOMEvent_iface); @@ -973,7 +967,7 @@ static HRESULT WINAPI DOMEvent_QueryInterface(IDOMEvent *iface, REFIID riid, voi static ULONG WINAPI DOMEvent_AddRef(IDOMEvent *iface) { DOMEvent *This = impl_from_IDOMEvent(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%lu\n", This, ref);
@@ -983,13 +977,10 @@ static ULONG WINAPI DOMEvent_AddRef(IDOMEvent *iface) static ULONG WINAPI DOMEvent_Release(IDOMEvent *iface) { DOMEvent *This = impl_from_IDOMEvent(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%lu\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -3132,7 +3123,6 @@ static void *event_ctor(unsigned size, dispex_static_data_t *dispex_data, void * return NULL; event->IDOMEvent_iface.lpVtbl = &DOMEventVtbl; event->query_interface = query_interface; - event->ref = 1; event->event_id = event_id; if(event_id != EVENTID_LAST) { event->type = wcsdup(event_info[event_id].name); @@ -4531,11 +4521,12 @@ void release_event_target(EventTarget *event_target) WINE_RB_FOR_EACH_ENTRY_DESTRUCTOR(iter, iter2, &event_target->handler_map, listener_container_t, entry) { while(!list_empty(&iter->listeners)) { event_listener_t *listener = LIST_ENTRY(list_head(&iter->listeners), event_listener_t, entry); + list_remove(&listener->entry); if(listener->function) IDispatch_Release(listener->function); - list_remove(&listener->entry); free(listener); } free(iter); } + rb_destroy(&event_target->handler_map, NULL, NULL); } diff --git a/dlls/mshtml/htmlevent.h b/dlls/mshtml/htmlevent.h index f6c7cbc381b..782ac5dd902 100644 --- a/dlls/mshtml/htmlevent.h +++ b/dlls/mshtml/htmlevent.h @@ -75,8 +75,6 @@ typedef enum { typedef struct DOMEvent { DispatchEx dispex; IDOMEvent IDOMEvent_iface; - - LONG ref; void *(*query_interface)(struct DOMEvent*,REFIID);
nsIDOMEvent *nsevent; diff --git a/dlls/mshtml/htmlimg.c b/dlls/mshtml/htmlimg.c index aad4d1f6dfa..fac0a56ab74 100644 --- a/dlls/mshtml/htmlimg.c +++ b/dlls/mshtml/htmlimg.c @@ -794,7 +794,7 @@ static HRESULT WINAPI HTMLImageElementFactory_QueryInterface(IHTMLImageElementFa static ULONG WINAPI HTMLImageElementFactory_AddRef(IHTMLImageElementFactory *iface) { HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -804,13 +804,10 @@ static ULONG WINAPI HTMLImageElementFactory_AddRef(IHTMLImageElementFactory *ifa static ULONG WINAPI HTMLImageElementFactory_Release(IHTMLImageElementFactory *iface) { HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -1003,7 +1000,6 @@ HRESULT HTMLImageElementFactory_Create(HTMLInnerWindow *window, HTMLImageElement return E_OUTOFMEMORY;
ret->IHTMLImageElementFactory_iface.lpVtbl = &HTMLImageElementFactoryVtbl; - ret->ref = 1; ret->window = window;
init_dispatch(&ret->dispex, (IUnknown*)&ret->IHTMLImageElementFactory_iface, diff --git a/dlls/mshtml/htmllocation.c b/dlls/mshtml/htmllocation.c index 418c59ca308..216ebf44d9a 100644 --- a/dlls/mshtml/htmllocation.c +++ b/dlls/mshtml/htmllocation.c @@ -88,7 +88,7 @@ static HRESULT WINAPI HTMLLocation_QueryInterface(IHTMLLocation *iface, REFIID r static ULONG WINAPI HTMLLocation_AddRef(IHTMLLocation *iface) { HTMLLocation *This = impl_from_IHTMLLocation(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -98,13 +98,10 @@ static ULONG WINAPI HTMLLocation_AddRef(IHTMLLocation *iface) static ULONG WINAPI HTMLLocation_Release(IHTMLLocation *iface) { HTMLLocation *This = impl_from_IHTMLLocation(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -658,7 +655,6 @@ HRESULT create_location(HTMLOuterWindow *window, HTMLLocation **ret) return E_OUTOFMEMORY;
location->IHTMLLocation_iface.lpVtbl = &HTMLLocationVtbl; - location->ref = 1; location->window = window; IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
diff --git a/dlls/mshtml/htmlnode.c b/dlls/mshtml/htmlnode.c index 337dc282fe6..ad292fbae90 100644 --- a/dlls/mshtml/htmlnode.c +++ b/dlls/mshtml/htmlnode.c @@ -41,8 +41,6 @@ typedef struct { DispatchEx dispex; IHTMLDOMChildrenCollection IHTMLDOMChildrenCollection_iface;
- LONG ref; - nsIDOMNodeList *nslist; } HTMLDOMChildrenCollection;
@@ -225,7 +223,7 @@ static HRESULT WINAPI HTMLDOMChildrenCollection_QueryInterface(IHTMLDOMChildrenC static ULONG WINAPI HTMLDOMChildrenCollection_AddRef(IHTMLDOMChildrenCollection *iface) { HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -235,13 +233,10 @@ static ULONG WINAPI HTMLDOMChildrenCollection_AddRef(IHTMLDOMChildrenCollection static ULONG WINAPI HTMLDOMChildrenCollection_Release(IHTMLDOMChildrenCollection *iface) { HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -473,7 +468,6 @@ HRESULT create_child_collection(nsIDOMNodeList *nslist, compat_mode_t compat_mod return E_OUTOFMEMORY;
collection->IHTMLDOMChildrenCollection_iface.lpVtbl = &HTMLDOMChildrenCollectionVtbl; - collection->ref = 1;
nsIDOMNodeList_AddRef(nslist); collection->nslist = nslist; @@ -1425,6 +1419,10 @@ static const IHTMLDOMNode3Vtbl HTMLDOMNode3Vtbl = { HTMLDOMNode3_isSupported };
+static void HTMLDOMNode_dispex_destructor(DispatchEx *dispex) +{ +} + HRESULT HTMLDOMNode_QI(HTMLDOMNode *This, REFIID riid, void **ppv) { TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv); @@ -1507,13 +1505,17 @@ void HTMLDOMNode_Init(HTMLDocumentNode *doc, HTMLDOMNode *node, nsIDOMNode *nsno assert(nsres == NS_OK); }
+static const dispex_static_data_vtbl_t HTMLDOMNode_dispex_vtbl = { + HTMLDOMNode_dispex_destructor, +}; + static const tid_t HTMLDOMNode_iface_tids[] = { IHTMLDOMNode_tid, 0 }; static dispex_static_data_t HTMLDOMNode_dispex = { "Node", - NULL, + &HTMLDOMNode_dispex_vtbl, IHTMLDOMNode_tid, HTMLDOMNode_iface_tids, HTMLDOMNode_init_dispex_info @@ -1591,7 +1593,6 @@ static nsresult NSAPI HTMLDOMNode_traverse(void *ccp, void *p, nsCycleCollection note_cc_edge((nsISupports*)This->nsnode, "This->nsnode", cb); if(This->doc && &This->doc->node != This) note_cc_edge((nsISupports*)&This->doc->node.IHTMLDOMNode_iface, "This->doc", cb); - dispex_traverse(&This->event_target.dispex, cb);
if(This->vtbl->traverse) This->vtbl->traverse(This, cb); @@ -1608,7 +1609,7 @@ static nsresult NSAPI HTMLDOMNode_unlink(void *p) if(This->vtbl->unlink) This->vtbl->unlink(This);
- dispex_unlink(&This->event_target.dispex); + dispex_unlink(&This->event_target.dispex.IDispatchEx_iface); unlink_ref(&This->nsnode);
if(This->doc && &This->doc->node != This) { @@ -1631,7 +1632,7 @@ static void NSAPI HTMLDOMNode_delete_cycle_collectable(void *p) if(This->vtbl->unlink) This->vtbl->unlink(This); This->vtbl->destructor(This); - release_dispex(&This->event_target.dispex); + dispex_delete_cycle_collectable(&This->event_target.dispex.IDispatchEx_iface); free(This); }
diff --git a/dlls/mshtml/htmlselect.c b/dlls/mshtml/htmlselect.c index 0a5905e6f1f..ac9c4ea8f5b 100644 --- a/dlls/mshtml/htmlselect.c +++ b/dlls/mshtml/htmlselect.c @@ -473,7 +473,7 @@ static HRESULT WINAPI HTMLOptionElementFactory_QueryInterface(IHTMLOptionElement static ULONG WINAPI HTMLOptionElementFactory_AddRef(IHTMLOptionElementFactory *iface) { HTMLOptionElementFactory *This = impl_from_IHTMLOptionElementFactory(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -483,13 +483,10 @@ static ULONG WINAPI HTMLOptionElementFactory_AddRef(IHTMLOptionElementFactory *i static ULONG WINAPI HTMLOptionElementFactory_Release(IHTMLOptionElementFactory *iface) { HTMLOptionElementFactory *This = impl_from_IHTMLOptionElementFactory(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -657,7 +654,6 @@ HRESULT HTMLOptionElementFactory_Create(HTMLInnerWindow *window, HTMLOptionEleme return E_OUTOFMEMORY;
ret->IHTMLOptionElementFactory_iface.lpVtbl = &HTMLOptionElementFactoryVtbl; - ret->ref = 1; ret->window = window;
init_dispatch(&ret->dispex, (IUnknown*)&ret->IHTMLOptionElementFactory_iface, diff --git a/dlls/mshtml/htmlstorage.c b/dlls/mshtml/htmlstorage.c index 77c8383680e..3c3259c3804 100644 --- a/dlls/mshtml/htmlstorage.c +++ b/dlls/mshtml/htmlstorage.c @@ -39,7 +39,6 @@ enum { MAX_QUOTA = 5000000 }; typedef struct { DispatchEx dispex; IHTMLStorage IHTMLStorage_iface; - LONG ref; unsigned num_props; BSTR *props; HTMLInnerWindow *window; @@ -383,7 +382,7 @@ static HRESULT WINAPI HTMLStorage_QueryInterface(IHTMLStorage *iface, REFIID rii static ULONG WINAPI HTMLStorage_AddRef(IHTMLStorage *iface) { HTMLStorage *This = impl_from_IHTMLStorage(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -393,13 +392,10 @@ static ULONG WINAPI HTMLStorage_AddRef(IHTMLStorage *iface) static ULONG WINAPI HTMLStorage_Release(IHTMLStorage *iface) { HTMLStorage *This = impl_from_IHTMLStorage(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -1481,7 +1477,6 @@ HRESULT create_html_storage(HTMLInnerWindow *window, BOOL local, IHTMLStorage ** }
storage->IHTMLStorage_iface.lpVtbl = &HTMLStorageVtbl; - storage->ref = 1; storage->window = window;
init_dispatch(&storage->dispex, (IUnknown*)&storage->IHTMLStorage_iface, &HTMLStorage_dispex, diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c index 16a1140f97d..f302de0cf8c 100644 --- a/dlls/mshtml/htmlstyle.c +++ b/dlls/mshtml/htmlstyle.c @@ -4758,7 +4758,7 @@ static HRESULT WINAPI HTMLCSSStyleDeclaration_QueryInterface(IHTMLCSSStyleDeclar static ULONG WINAPI HTMLCSSStyleDeclaration_AddRef(IHTMLCSSStyleDeclaration *iface) { CSSStyle *This = impl_from_IHTMLCSSStyleDeclaration(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -4768,13 +4768,10 @@ static ULONG WINAPI HTMLCSSStyleDeclaration_AddRef(IHTMLCSSStyleDeclaration *ifa static ULONG WINAPI HTMLCSSStyleDeclaration_Release(IHTMLCSSStyleDeclaration *iface) { CSSStyle *This = impl_from_IHTMLCSSStyleDeclaration(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -10073,7 +10070,6 @@ void init_css_style(CSSStyle *style, nsIDOMCSSStyleDeclaration *nsstyle, style_q { style->IHTMLCSSStyleDeclaration_iface.lpVtbl = &HTMLCSSStyleDeclarationVtbl; style->IHTMLCSSStyleDeclaration2_iface.lpVtbl = &HTMLCSSStyleDeclaration2Vtbl; - style->ref = 1; style->qi = qi; style->nsstyle = nsstyle; nsIDOMCSSStyleDeclaration_AddRef(nsstyle); diff --git a/dlls/mshtml/htmlstyle.h b/dlls/mshtml/htmlstyle.h index 73d54128120..caae7d6ffa0 100644 --- a/dlls/mshtml/htmlstyle.h +++ b/dlls/mshtml/htmlstyle.h @@ -23,8 +23,6 @@ struct CSSStyle { DispatchEx dispex; IHTMLCSSStyleDeclaration IHTMLCSSStyleDeclaration_iface; IHTMLCSSStyleDeclaration2 IHTMLCSSStyleDeclaration2_iface; - - LONG ref; style_qi_t qi;
nsIDOMCSSStyleDeclaration *nsstyle; diff --git a/dlls/mshtml/htmlstylesheet.c b/dlls/mshtml/htmlstylesheet.c index 8ce0f85b76e..fd43e68949e 100644 --- a/dlls/mshtml/htmlstylesheet.c +++ b/dlls/mshtml/htmlstylesheet.c @@ -36,8 +36,6 @@ struct HTMLStyleSheet { IHTMLStyleSheet IHTMLStyleSheet_iface; IHTMLStyleSheet4 IHTMLStyleSheet4_iface;
- LONG ref; - nsIDOMCSSStyleSheet *nsstylesheet; };
@@ -45,8 +43,6 @@ struct HTMLStyleSheetsCollection { DispatchEx dispex; IHTMLStyleSheetsCollection IHTMLStyleSheetsCollection_iface;
- LONG ref; - nsIDOMStyleSheetList *nslist; };
@@ -63,8 +59,6 @@ struct HTMLStyleSheetRulesCollection { DispatchEx dispex; IHTMLStyleSheetRulesCollection IHTMLStyleSheetRulesCollection_iface;
- LONG ref; - nsIDOMCSSRuleList *nslist; };
@@ -72,8 +66,6 @@ struct HTMLStyleSheetRule { DispatchEx dispex; IHTMLStyleSheetRule IHTMLStyleSheetRule_iface;
- LONG ref; - nsIDOMCSSRule *nsstylesheetrule; };
@@ -109,7 +101,7 @@ static HRESULT WINAPI HTMLStyleSheetRule_QueryInterface(IHTMLStyleSheetRule *ifa static ULONG WINAPI HTMLStyleSheetRule_AddRef(IHTMLStyleSheetRule *iface) { HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -119,13 +111,10 @@ static ULONG WINAPI HTMLStyleSheetRule_AddRef(IHTMLStyleSheetRule *iface) static ULONG WINAPI HTMLStyleSheetRule_Release(IHTMLStyleSheetRule *iface) { HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -245,7 +234,6 @@ static HRESULT create_style_sheet_rule(nsIDOMCSSRule *nsstylesheetrule, compat_m return E_OUTOFMEMORY;
rule->IHTMLStyleSheetRule_iface.lpVtbl = &HTMLStyleSheetRuleVtbl; - rule->ref = 1; rule->nsstylesheetrule = NULL;
init_dispatch(&rule->dispex, (IUnknown *)&rule->IHTMLStyleSheetRule_iface, &HTMLStyleSheetRule_dispex, @@ -294,7 +282,7 @@ static HRESULT WINAPI HTMLStyleSheetRulesCollection_QueryInterface(IHTMLStyleShe static ULONG WINAPI HTMLStyleSheetRulesCollection_AddRef(IHTMLStyleSheetRulesCollection *iface) { HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -304,13 +292,10 @@ static ULONG WINAPI HTMLStyleSheetRulesCollection_AddRef(IHTMLStyleSheetRulesCol static ULONG WINAPI HTMLStyleSheetRulesCollection_Release(IHTMLStyleSheetRulesCollection *iface) { HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -519,7 +504,6 @@ static HRESULT create_style_sheet_rules_collection(nsIDOMCSSRuleList *nslist, co return E_OUTOFMEMORY;
collection->IHTMLStyleSheetRulesCollection_iface.lpVtbl = &HTMLStyleSheetRulesCollectionVtbl; - collection->ref = 1; collection->nslist = nslist;
init_dispatch(&collection->dispex, (IUnknown*)&collection->IHTMLStyleSheetRulesCollection_iface, @@ -689,7 +673,7 @@ static HRESULT WINAPI HTMLStyleSheetsCollection_QueryInterface(IHTMLStyleSheetsC static ULONG WINAPI HTMLStyleSheetsCollection_AddRef(IHTMLStyleSheetsCollection *iface) { HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -699,13 +683,10 @@ static ULONG WINAPI HTMLStyleSheetsCollection_AddRef(IHTMLStyleSheetsCollection static ULONG WINAPI HTMLStyleSheetsCollection_Release(IHTMLStyleSheetsCollection *iface) { HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -956,7 +937,6 @@ HRESULT create_style_sheet_collection(nsIDOMStyleSheetList *nslist, compat_mode_ return E_OUTOFMEMORY;
collection->IHTMLStyleSheetsCollection_iface.lpVtbl = &HTMLStyleSheetsCollectionVtbl; - collection->ref = 1;
if(nslist) nsIDOMStyleSheetList_AddRef(nslist); @@ -1003,7 +983,7 @@ static HRESULT WINAPI HTMLStyleSheet_QueryInterface(IHTMLStyleSheet *iface, REFI static ULONG WINAPI HTMLStyleSheet_AddRef(IHTMLStyleSheet *iface) { HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -1013,13 +993,10 @@ static ULONG WINAPI HTMLStyleSheet_AddRef(IHTMLStyleSheet *iface) static ULONG WINAPI HTMLStyleSheet_Release(IHTMLStyleSheet *iface) { HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -1546,7 +1523,6 @@ HRESULT create_style_sheet(nsIDOMStyleSheet *nsstylesheet, compat_mode_t compat_
style_sheet->IHTMLStyleSheet_iface.lpVtbl = &HTMLStyleSheetVtbl; style_sheet->IHTMLStyleSheet4_iface.lpVtbl = &HTMLStyleSheet4Vtbl; - style_sheet->ref = 1; style_sheet->nsstylesheet = NULL;
init_dispatch(&style_sheet->dispex, (IUnknown*)&style_sheet->IHTMLStyleSheet_iface, diff --git a/dlls/mshtml/htmltextnode.c b/dlls/mshtml/htmltextnode.c index af3f57044b8..1bae5994c14 100644 --- a/dlls/mshtml/htmltextnode.c +++ b/dlls/mshtml/htmltextnode.c @@ -319,6 +319,10 @@ static const IHTMLDOMTextNode2Vtbl HTMLDOMTextNode2Vtbl = { HTMLDOMTextNode2_replaceData };
+static void HTMLDOMTextNode_destructor(DispatchEx *dispex) +{ +} + static inline HTMLDOMTextNode *impl_from_HTMLDOMNode(HTMLDOMNode *iface) { return CONTAINING_RECORD(iface, HTMLDOMTextNode, node); @@ -358,6 +362,10 @@ static const NodeImplVtbl HTMLDOMTextNodeImplVtbl = { HTMLDOMTextNode_clone };
+static const dispex_static_data_vtbl_t HTMLDOMTextNode_dispex_vtbl = { + HTMLDOMTextNode_destructor, +}; + static const tid_t HTMLDOMTextNode_iface_tids[] = { IHTMLDOMNode_tid, IHTMLDOMNode2_tid, @@ -367,7 +375,7 @@ static const tid_t HTMLDOMTextNode_iface_tids[] = { }; static dispex_static_data_t HTMLDOMTextNode_dispex = { "Text", - NULL, + &HTMLDOMTextNode_dispex_vtbl, DispHTMLDOMTextNode_tid, HTMLDOMTextNode_iface_tids, HTMLDOMNode_init_dispex_info diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index 8a5ca5b441c..68777c18c7f 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -134,7 +134,7 @@ static void detach_inner_window(HTMLInnerWindow *window) detach_document_node(doc);
if(outer_window && outer_window->location) - dispex_unlink(&outer_window->location->dispex); + dispex_props_unlink(&outer_window->location->dispex);
abort_window_bindings(window); remove_target_tasks(window->task_magic); @@ -200,11 +200,11 @@ static HRESULT WINAPI HTMLWindow2_QueryInterface(IHTMLWindow2 *iface, REFIID rii *ppv = NULL; FIXME("(%p)->(IID_IMarshal %p)\n", This, ppv); return E_NOINTERFACE; - }else if(IsEqualGUID(&IID_nsXPCOMCycleCollectionParticipant, riid) && is_outer_window(This)) { - *ppv = &outer_window_ccp; + }else if(IsEqualGUID(&IID_nsXPCOMCycleCollectionParticipant, riid)) { + *ppv = is_outer_window(This) ? &outer_window_ccp : &dispex_ccp; return S_OK; - }else if(IsEqualGUID(&IID_nsCycleCollectionISupports, riid) && is_outer_window(This)) { - *ppv = &This->IHTMLWindow2_iface; + }else if(IsEqualGUID(&IID_nsCycleCollectionISupports, riid)) { + *ppv = is_outer_window(This) ? (nsISupports*)&This->IHTMLWindow2_iface : (nsISupports*)&This->inner_window->event_target.dispex.IDispatchEx_iface; return S_OK; }else { return EventTarget_QI(&This->inner_window->event_target, riid, ppv); @@ -217,7 +217,7 @@ static HRESULT WINAPI HTMLWindow2_QueryInterface(IHTMLWindow2 *iface, REFIID rii static ULONG WINAPI HTMLWindow2_AddRef(IHTMLWindow2 *iface) { HTMLWindow *This = impl_from_IHTMLWindow2(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->inner_window->event_target.dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -227,13 +227,10 @@ static ULONG WINAPI HTMLWindow2_AddRef(IHTMLWindow2 *iface) static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface) { HTMLWindow *This = impl_from_IHTMLWindow2(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->inner_window->event_target.dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->inner_window->event_target.dispex); - return ref; }
@@ -4265,7 +4262,6 @@ static HRESULT create_inner_window(HTMLOuterWindow *outer_window, IMoniker *mon, window->base.outer_window = outer_window; window->base.inner_window = window;
- window->base.ref = 1; EventTarget_Init(&window->event_target, (IUnknown*)&window->base.IHTMLWindow2_iface, &HTMLWindow_dispex, COMPAT_MODE_NONE);
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 47d6f4421e2..7f39b4293fd 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -337,6 +337,11 @@ typedef struct dispex_dynamic_data_t dispex_dynamic_data_t; #define MSHTML_CUSTOM_DISPID_CNT (MSHTML_DISPID_CUSTOM_MAX-MSHTML_DISPID_CUSTOM_MIN)
typedef struct DispatchEx DispatchEx; +typedef struct nsCycleCollectionTraversalCallback nsCycleCollectionTraversalCallback; + +typedef struct { + UINT_PTR x; +} nsCycleCollectingAutoRefCnt;
/* dispex is our base IDispatchEx implementation for all mshtml objects, and the vtbl allows @@ -347,7 +352,8 @@ typedef struct DispatchEx DispatchEx; - dynamic props: These props are generally allocated by external code (e.g. 'document.wine = 42' creates 'wine' dynamic prop on document) */ typedef struct { - /* Unlike delete_cycle_collectable, unlink is called before the destructor (if available). */ + /* Used to implement Cycle Collection callbacks; note that the destructor is not optional! + Unlike delete_cycle_collectable, unlink is called before the destructor (if available). */ void (*destructor)(DispatchEx*); void (*unlink)(DispatchEx*);
@@ -393,23 +399,18 @@ struct DispatchEx { IDispatchEx IDispatchEx_iface;
IUnknown *outer; + nsCycleCollectingAutoRefCnt ccref;
dispex_data_t *info; dispex_dynamic_data_t *dynamic_data; };
-typedef struct { - UINT_PTR x; -} nsCycleCollectingAutoRefCnt; - typedef struct { void *vtbl; int ref_flags; void *callbacks; } ExternalCycleCollectionParticipant;
-typedef struct nsCycleCollectionTraversalCallback nsCycleCollectionTraversalCallback; - typedef struct { nsresult (NSAPI *traverse)(void*,void*,nsCycleCollectionTraversalCallback*); nsresult (NSAPI *unlink)(void*); @@ -425,16 +426,28 @@ extern void (__cdecl *ccp_init)(ExternalCycleCollectionParticipant*,const CCObjC extern void (__cdecl *describe_cc_node)(nsCycleCollectingAutoRefCnt*,const char*,nsCycleCollectionTraversalCallback*); extern void (__cdecl *note_cc_edge)(nsISupports*,const char*,nsCycleCollectionTraversalCallback*);
+extern ExternalCycleCollectionParticipant dispex_ccp; + +static inline LONG dispex_ccref_incr(DispatchEx *dispex) +{ + return ccref_incr(&dispex->ccref, (nsISupports*)&dispex->IDispatchEx_iface); +} + +static inline LONG dispex_ccref_decr(DispatchEx *dispex) +{ + return ccref_decr(&dispex->ccref, (nsISupports*)&dispex->IDispatchEx_iface, &dispex_ccp); +} + void init_dispatch(DispatchEx*,IUnknown*,dispex_static_data_t*,compat_mode_t); -void release_dispex(DispatchEx*); BOOL dispex_query_interface(DispatchEx*,REFIID,void**); +void dispex_props_unlink(DispatchEx*); +nsresult NSAPI dispex_unlink(void*); +void NSAPI dispex_delete_cycle_collectable(void*); HRESULT change_type(VARIANT*,VARIANT*,VARTYPE,IServiceProvider*); HRESULT dispex_get_dprop_ref(DispatchEx*,const WCHAR*,BOOL,VARIANT**); HRESULT get_dispids(tid_t,DWORD*,DISPID**); HRESULT remove_attribute(DispatchEx*,DISPID,VARIANT_BOOL*); HRESULT dispex_get_dynid(DispatchEx*,const WCHAR*,BOOL,DISPID*); -void dispex_traverse(DispatchEx*,nsCycleCollectionTraversalCallback*); -void dispex_unlink(DispatchEx*); void release_typelib(void); HRESULT get_class_typeinfo(const CLSID*,ITypeInfo**); const void *dispex_get_vtbl(DispatchEx*); @@ -487,8 +500,6 @@ typedef struct { DispatchEx dispex; IHTMLOptionElementFactory IHTMLOptionElementFactory_iface;
- LONG ref; - HTMLInnerWindow *window; } HTMLOptionElementFactory;
@@ -496,8 +507,6 @@ typedef struct { DispatchEx dispex; IHTMLImageElementFactory IHTMLImageElementFactory_iface;
- LONG ref; - HTMLInnerWindow *window; } HTMLImageElementFactory;
@@ -505,8 +514,6 @@ typedef struct { DispatchEx dispex; IHTMLXMLHttpRequestFactory IHTMLXMLHttpRequestFactory_iface;
- LONG ref; - HTMLInnerWindow *window; } HTMLXMLHttpRequestFactory;
@@ -514,8 +521,6 @@ struct HTMLLocation { DispatchEx dispex; IHTMLLocation IHTMLLocation_iface;
- LONG ref; - HTMLOuterWindow *window; };
@@ -523,8 +528,6 @@ typedef struct { DispatchEx dispex; IOmHistory IOmHistory_iface;
- LONG ref; - HTMLInnerWindow *window; } OmHistory;
@@ -548,8 +551,6 @@ struct HTMLWindow {
IWineMSHTMLConsole *console;
- LONG ref; - HTMLInnerWindow *inner_window; HTMLOuterWindow *outer_window; }; @@ -955,9 +956,6 @@ struct HTMLDocumentNode { IInternetHostSecurityManager IInternetHostSecurityManager_iface;
nsIDocumentObserver nsIDocumentObserver_iface; - - LONG ref; - ConnectionPointContainer cp_container; HTMLOuterWindow *outer_window; HTMLInnerWindow *window; @@ -1071,6 +1069,7 @@ BOOL is_gecko_path(const char*); void set_viewer_zoom(GeckoBrowser*,float); float get_viewer_zoom(GeckoBrowser*);
+void init_dispex_cc(void); void init_window_cc(void); void init_node_cc(void);
@@ -1157,8 +1156,6 @@ struct HTMLAttributeCollection { IHTMLAttributeCollection2 IHTMLAttributeCollection2_iface; IHTMLAttributeCollection3 IHTMLAttributeCollection3_iface;
- LONG ref; - HTMLElement *elem; struct list attrs; }; @@ -1168,8 +1165,6 @@ typedef struct { IHTMLDOMAttribute IHTMLDOMAttribute_iface; IHTMLDOMAttribute2 IHTMLDOMAttribute2_iface;
- LONG ref; - /* value is valid only for detached attributes (when elem == NULL). */ VARIANT value; /* name must be valid for detached attributes */ diff --git a/dlls/mshtml/mutation.c b/dlls/mshtml/mutation.c index 8df0211621e..4d1078cce81 100644 --- a/dlls/mshtml/mutation.c +++ b/dlls/mshtml/mutation.c @@ -1080,7 +1080,6 @@ void init_mutation(nsIComponentManager *component_manager) struct mutation_observer { IWineMSHTMLMutationObserver IWineMSHTMLMutationObserver_iface;
- LONG ref; DispatchEx dispex; IDispatch *callback; }; @@ -1113,7 +1112,7 @@ static HRESULT WINAPI MutationObserver_QueryInterface(IWineMSHTMLMutationObserve static ULONG WINAPI MutationObserver_AddRef(IWineMSHTMLMutationObserver *iface) { struct mutation_observer *This = impl_from_IWineMSHTMLMutationObserver(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -1123,13 +1122,10 @@ static ULONG WINAPI MutationObserver_AddRef(IWineMSHTMLMutationObserver *iface) static ULONG WINAPI MutationObserver_Release(IWineMSHTMLMutationObserver *iface) { struct mutation_observer *This = impl_from_IWineMSHTMLMutationObserver(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -1258,7 +1254,6 @@ static HRESULT create_mutation_observer(compat_mode_t compat_mode, IDispatch *ca }
obj->IWineMSHTMLMutationObserver_iface.lpVtbl = &WineMSHTMLMutationObserverVtbl; - obj->ref = 1; init_dispatch(&obj->dispex, (IUnknown*)&obj->IWineMSHTMLMutationObserver_iface, &mutation_observer_dispex, compat_mode);
@@ -1271,8 +1266,6 @@ static HRESULT create_mutation_observer(compat_mode_t compat_mode, IDispatch *ca struct mutation_observer_ctor { IUnknown IUnknown_iface; DispatchEx dispex; - - LONG ref; };
static inline struct mutation_observer_ctor *mutation_observer_ctor_from_IUnknown(IUnknown *iface) @@ -1308,7 +1301,7 @@ static HRESULT WINAPI mutation_observer_ctor_QueryInterface(IUnknown *iface, REF static ULONG WINAPI mutation_observer_ctor_AddRef(IUnknown *iface) { struct mutation_observer_ctor *This = mutation_observer_ctor_from_IUnknown(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -1318,13 +1311,10 @@ static ULONG WINAPI mutation_observer_ctor_AddRef(IUnknown *iface) static ULONG WINAPI mutation_observer_ctor_Release(IUnknown *iface) { struct mutation_observer_ctor *This = mutation_observer_ctor_from_IUnknown(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -1418,7 +1408,6 @@ HRESULT create_mutation_observer_ctor(compat_mode_t compat_mode, IDispatch **ret }
obj->IUnknown_iface.lpVtbl = &mutation_observer_ctor_vtbl; - obj->ref = 1; init_dispatch(&obj->dispex, (IUnknown*)&obj->IUnknown_iface, &mutation_observer_ctor_dispex, compat_mode);
diff --git a/dlls/mshtml/nsembed.c b/dlls/mshtml/nsembed.c index 61d4ec335b4..00295242f4a 100644 --- a/dlls/mshtml/nsembed.c +++ b/dlls/mshtml/nsembed.c @@ -596,6 +596,7 @@ static BOOL init_xpcom(const PRUnichar *gre_path) ERR("NS_GetComponentRegistrar failed: %08lx\n", nsres); }
+ init_dispex_cc(); init_window_cc(); init_node_cc();
diff --git a/dlls/mshtml/omnavigator.c b/dlls/mshtml/omnavigator.c index ce96ab7f84e..4ba7991ab05 100644 --- a/dlls/mshtml/omnavigator.c +++ b/dlls/mshtml/omnavigator.c @@ -38,8 +38,6 @@ typedef struct { DispatchEx dispex; IOmNavigator IOmNavigator_iface;
- LONG ref; - HTMLPluginsCollection *plugins; HTMLMimeTypesCollection *mime_types; } OmNavigator; @@ -49,8 +47,6 @@ typedef struct { IHTMLDOMImplementation IHTMLDOMImplementation_iface; IHTMLDOMImplementation2 IHTMLDOMImplementation2_iface;
- LONG ref; - nsIDOMDOMImplementation *implementation; GeckoBrowser *browser; } HTMLDOMImplementation; @@ -85,7 +81,7 @@ static HRESULT WINAPI HTMLDOMImplementation_QueryInterface(IHTMLDOMImplementatio static ULONG WINAPI HTMLDOMImplementation_AddRef(IHTMLDOMImplementation *iface) { HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -95,13 +91,10 @@ static ULONG WINAPI HTMLDOMImplementation_AddRef(IHTMLDOMImplementation *iface) static ULONG WINAPI HTMLDOMImplementation_Release(IHTMLDOMImplementation *iface) { HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -344,7 +337,6 @@ HRESULT create_dom_implementation(HTMLDocumentNode *doc_node, IHTMLDOMImplementa
dom_implementation->IHTMLDOMImplementation_iface.lpVtbl = &HTMLDOMImplementationVtbl; dom_implementation->IHTMLDOMImplementation2_iface.lpVtbl = &HTMLDOMImplementation2Vtbl; - dom_implementation->ref = 1; dom_implementation->browser = doc_node->browser;
init_dispatch(&dom_implementation->dispex, (IUnknown*)&dom_implementation->IHTMLDOMImplementation_iface, @@ -370,8 +362,6 @@ void detach_dom_implementation(IHTMLDOMImplementation *iface) typedef struct { DispatchEx dispex; IHTMLScreen IHTMLScreen_iface; - - LONG ref; } HTMLScreen;
static inline HTMLScreen *impl_from_IHTMLScreen(IHTMLScreen *iface) @@ -404,7 +394,7 @@ static HRESULT WINAPI HTMLScreen_QueryInterface(IHTMLScreen *iface, REFIID riid, static ULONG WINAPI HTMLScreen_AddRef(IHTMLScreen *iface) { HTMLScreen *This = impl_from_IHTMLScreen(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -414,13 +404,10 @@ static ULONG WINAPI HTMLScreen_AddRef(IHTMLScreen *iface) static ULONG WINAPI HTMLScreen_Release(IHTMLScreen *iface) { HTMLScreen *This = impl_from_IHTMLScreen(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -604,7 +591,6 @@ HRESULT create_html_screen(compat_mode_t compat_mode, IHTMLScreen **ret) return E_OUTOFMEMORY;
screen->IHTMLScreen_iface.lpVtbl = &HTMLSreenVtbl; - screen->ref = 1;
init_dispatch(&screen->dispex, (IUnknown*)&screen->IHTMLScreen_iface, &HTMLScreen_dispex, compat_mode);
@@ -642,7 +628,7 @@ static HRESULT WINAPI OmHistory_QueryInterface(IOmHistory *iface, REFIID riid, v static ULONG WINAPI OmHistory_AddRef(IOmHistory *iface) { OmHistory *This = impl_from_IOmHistory(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -652,13 +638,10 @@ static ULONG WINAPI OmHistory_AddRef(IOmHistory *iface) static ULONG WINAPI OmHistory_Release(IOmHistory *iface) { OmHistory *This = impl_from_IOmHistory(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -784,7 +767,6 @@ HRESULT create_history(HTMLInnerWindow *window, OmHistory **ret) init_dispatch(&history->dispex, (IUnknown*)&history->IOmHistory_iface, &OmHistory_dispex, dispex_compat_mode(&window->event_target.dispex)); history->IOmHistory_iface.lpVtbl = &OmHistoryVtbl; - history->ref = 1;
history->window = window;
@@ -796,8 +778,6 @@ struct HTMLPluginsCollection { DispatchEx dispex; IHTMLPluginsCollection IHTMLPluginsCollection_iface;
- LONG ref; - OmNavigator *navigator; };
@@ -831,7 +811,7 @@ static HRESULT WINAPI HTMLPluginsCollection_QueryInterface(IHTMLPluginsCollectio static ULONG WINAPI HTMLPluginsCollection_AddRef(IHTMLPluginsCollection *iface) { HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -841,13 +821,10 @@ static ULONG WINAPI HTMLPluginsCollection_AddRef(IHTMLPluginsCollection *iface) static ULONG WINAPI HTMLPluginsCollection_Release(IHTMLPluginsCollection *iface) { HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -959,7 +936,6 @@ static HRESULT create_plugins_collection(OmNavigator *navigator, HTMLPluginsColl return E_OUTOFMEMORY;
col->IHTMLPluginsCollection_iface.lpVtbl = &HTMLPluginsCollectionVtbl; - col->ref = 1; col->navigator = navigator;
init_dispatch(&col->dispex, (IUnknown*)&col->IHTMLPluginsCollection_iface, @@ -973,8 +949,6 @@ struct HTMLMimeTypesCollection { DispatchEx dispex; IHTMLMimeTypesCollection IHTMLMimeTypesCollection_iface;
- LONG ref; - OmNavigator *navigator; };
@@ -1008,7 +982,7 @@ static HRESULT WINAPI HTMLMimeTypesCollection_QueryInterface(IHTMLMimeTypesColle static ULONG WINAPI HTMLMimeTypesCollection_AddRef(IHTMLMimeTypesCollection *iface) { HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -1018,13 +992,10 @@ static ULONG WINAPI HTMLMimeTypesCollection_AddRef(IHTMLMimeTypesCollection *ifa static ULONG WINAPI HTMLMimeTypesCollection_Release(IHTMLMimeTypesCollection *iface) { HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -1125,7 +1096,6 @@ static HRESULT create_mime_types_collection(OmNavigator *navigator, HTMLMimeType return E_OUTOFMEMORY;
col->IHTMLMimeTypesCollection_iface.lpVtbl = &HTMLMimeTypesCollectionVtbl; - col->ref = 1; col->navigator = navigator;
init_dispatch(&col->dispex, (IUnknown*)&col->IHTMLMimeTypesCollection_iface, @@ -1165,7 +1135,7 @@ static HRESULT WINAPI OmNavigator_QueryInterface(IOmNavigator *iface, REFIID rii static ULONG WINAPI OmNavigator_AddRef(IOmNavigator *iface) { OmNavigator *This = impl_from_IOmNavigator(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -1175,13 +1145,10 @@ static ULONG WINAPI OmNavigator_AddRef(IOmNavigator *iface) static ULONG WINAPI OmNavigator_Release(IOmNavigator *iface) { OmNavigator *This = impl_from_IOmNavigator(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -1576,7 +1543,6 @@ HRESULT create_navigator(compat_mode_t compat_mode, IOmNavigator **navigator) return E_OUTOFMEMORY;
ret->IOmNavigator_iface.lpVtbl = &OmNavigatorVtbl; - ret->ref = 1;
init_dispatch(&ret->dispex, (IUnknown*)&ret->IOmNavigator_iface, &OmNavigator_dispex, compat_mode);
@@ -1588,7 +1554,6 @@ typedef struct { DispatchEx dispex; IHTMLPerformanceTiming IHTMLPerformanceTiming_iface;
- LONG ref; HTMLInnerWindow *window; } HTMLPerformanceTiming;
@@ -1622,7 +1587,7 @@ static HRESULT WINAPI HTMLPerformanceTiming_QueryInterface(IHTMLPerformanceTimin static ULONG WINAPI HTMLPerformanceTiming_AddRef(IHTMLPerformanceTiming *iface) { HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -1632,13 +1597,10 @@ static ULONG WINAPI HTMLPerformanceTiming_AddRef(IHTMLPerformanceTiming *iface) static ULONG WINAPI HTMLPerformanceTiming_Release(IHTMLPerformanceTiming *iface) { HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -2004,7 +1966,6 @@ typedef struct { DispatchEx dispex; IHTMLPerformanceNavigation IHTMLPerformanceNavigation_iface;
- LONG ref; HTMLInnerWindow *window; } HTMLPerformanceNavigation;
@@ -2038,7 +1999,7 @@ static HRESULT WINAPI HTMLPerformanceNavigation_QueryInterface(IHTMLPerformanceN static ULONG WINAPI HTMLPerformanceNavigation_AddRef(IHTMLPerformanceNavigation *iface) { HTMLPerformanceNavigation *This = impl_from_IHTMLPerformanceNavigation(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -2048,13 +2009,10 @@ static ULONG WINAPI HTMLPerformanceNavigation_AddRef(IHTMLPerformanceNavigation static ULONG WINAPI HTMLPerformanceNavigation_Release(IHTMLPerformanceNavigation *iface) { HTMLPerformanceNavigation *This = impl_from_IHTMLPerformanceNavigation(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -2184,8 +2142,6 @@ typedef struct { DispatchEx dispex; IHTMLPerformance IHTMLPerformance_iface;
- LONG ref; - HTMLInnerWindow *window; IHTMLPerformanceNavigation *navigation; IHTMLPerformanceTiming *timing; @@ -2221,7 +2177,7 @@ static HRESULT WINAPI HTMLPerformance_QueryInterface(IHTMLPerformance *iface, RE static ULONG WINAPI HTMLPerformance_AddRef(IHTMLPerformance *iface) { HTMLPerformance *This = impl_from_IHTMLPerformance(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -2231,13 +2187,10 @@ static ULONG WINAPI HTMLPerformance_AddRef(IHTMLPerformance *iface) static ULONG WINAPI HTMLPerformance_Release(IHTMLPerformance *iface) { HTMLPerformance *This = impl_from_IHTMLPerformance(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -2291,7 +2244,6 @@ static HRESULT WINAPI HTMLPerformance_get_navigation(IHTMLPerformance *iface, return E_OUTOFMEMORY;
navigation->IHTMLPerformanceNavigation_iface.lpVtbl = &HTMLPerformanceNavigationVtbl; - navigation->ref = 1; navigation->window = This->window; IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
@@ -2319,7 +2271,6 @@ static HRESULT WINAPI HTMLPerformance_get_timing(IHTMLPerformance *iface, IHTMLP return E_OUTOFMEMORY;
timing->IHTMLPerformanceTiming_iface.lpVtbl = &HTMLPerformanceTimingVtbl; - timing->ref = 1; timing->window = This->window; IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
@@ -2412,7 +2363,6 @@ HRESULT create_performance(HTMLInnerWindow *window, IHTMLPerformance **ret) return E_OUTOFMEMORY;
performance->IHTMLPerformance_iface.lpVtbl = &HTMLPerformanceVtbl; - performance->ref = 1; performance->window = window; IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
@@ -2426,8 +2376,6 @@ HRESULT create_performance(HTMLInnerWindow *window, IHTMLPerformance **ret) typedef struct { DispatchEx dispex; IHTMLNamespaceCollection IHTMLNamespaceCollection_iface; - - LONG ref; } HTMLNamespaceCollection;
static inline HTMLNamespaceCollection *impl_from_IHTMLNamespaceCollection(IHTMLNamespaceCollection *iface) @@ -2460,7 +2408,7 @@ static HRESULT WINAPI HTMLNamespaceCollection_QueryInterface(IHTMLNamespaceColle static ULONG WINAPI HTMLNamespaceCollection_AddRef(IHTMLNamespaceCollection *iface) { HTMLNamespaceCollection *This = impl_from_IHTMLNamespaceCollection(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -2470,13 +2418,10 @@ static ULONG WINAPI HTMLNamespaceCollection_AddRef(IHTMLNamespaceCollection *ifa static ULONG WINAPI HTMLNamespaceCollection_Release(IHTMLNamespaceCollection *iface) { HTMLNamespaceCollection *This = impl_from_IHTMLNamespaceCollection(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -2585,7 +2530,6 @@ HRESULT create_namespace_collection(compat_mode_t compat_mode, IHTMLNamespaceCol return E_OUTOFMEMORY;
namespaces->IHTMLNamespaceCollection_iface.lpVtbl = &HTMLNamespaceCollectionVtbl; - namespaces->ref = 1; init_dispatch(&namespaces->dispex, (IUnknown*)&namespaces->IHTMLNamespaceCollection_iface, &HTMLNamespaceCollection_dispex, compat_mode); *ret = &namespaces->IHTMLNamespaceCollection_iface; @@ -2595,7 +2539,6 @@ HRESULT create_namespace_collection(compat_mode_t compat_mode, IHTMLNamespaceCol struct console { DispatchEx dispex; IWineMSHTMLConsole IWineMSHTMLConsole_iface; - LONG ref; };
static inline struct console *impl_from_IWineMSHTMLConsole(IWineMSHTMLConsole *iface) @@ -2628,7 +2571,7 @@ static HRESULT WINAPI console_QueryInterface(IWineMSHTMLConsole *iface, REFIID r static ULONG WINAPI console_AddRef(IWineMSHTMLConsole *iface) { struct console *console = impl_from_IWineMSHTMLConsole(iface); - LONG ref = InterlockedIncrement(&console->ref); + LONG ref = dispex_ccref_incr(&console->dispex);
TRACE("(%p) ref=%ld\n", console, ref);
@@ -2638,13 +2581,10 @@ static ULONG WINAPI console_AddRef(IWineMSHTMLConsole *iface) static ULONG WINAPI console_Release(IWineMSHTMLConsole *iface) { struct console *console = impl_from_IWineMSHTMLConsole(iface); - LONG ref = InterlockedDecrement(&console->ref); + LONG ref = dispex_ccref_decr(&console->dispex);
TRACE("(%p) ref=%ld\n", console, ref);
- if(!ref) - release_dispex(&console->dispex); - return ref; }
@@ -2858,7 +2798,6 @@ void create_console(compat_mode_t compat_mode, IWineMSHTMLConsole **ret) }
obj->IWineMSHTMLConsole_iface.lpVtbl = &WineMSHTMLConsoleVtbl; - obj->ref = 1; init_dispatch(&obj->dispex, (IUnknown*)&obj->IWineMSHTMLConsole_iface, &console_dispex, compat_mode);
*ret = &obj->IWineMSHTMLConsole_iface; @@ -2873,7 +2812,6 @@ struct media_query_list_callback; struct media_query_list { DispatchEx dispex; IWineMSHTMLMediaQueryList IWineMSHTMLMediaQueryList_iface; - LONG ref; nsIDOMMediaQueryList *nsquerylist; struct media_query_list_callback *callback; struct list listeners; @@ -2912,7 +2850,7 @@ static HRESULT WINAPI media_query_list_QueryInterface(IWineMSHTMLMediaQueryList static ULONG WINAPI media_query_list_AddRef(IWineMSHTMLMediaQueryList *iface) { struct media_query_list *media_query_list = impl_from_IWineMSHTMLMediaQueryList(iface); - LONG ref = InterlockedIncrement(&media_query_list->ref); + LONG ref = dispex_ccref_incr(&media_query_list->dispex);
TRACE("(%p) ref=%ld\n", media_query_list, ref);
@@ -2922,13 +2860,10 @@ static ULONG WINAPI media_query_list_AddRef(IWineMSHTMLMediaQueryList *iface) static ULONG WINAPI media_query_list_Release(IWineMSHTMLMediaQueryList *iface) { struct media_query_list *media_query_list = impl_from_IWineMSHTMLMediaQueryList(iface); - LONG ref = InterlockedDecrement(&media_query_list->ref); + LONG ref = dispex_ccref_decr(&media_query_list->dispex);
TRACE("(%p) ref=%ld\n", media_query_list, ref);
- if(!ref) - release_dispex(&media_query_list->dispex); - return ref; }
@@ -3227,7 +3162,6 @@ HRESULT create_media_query_list(HTMLWindow *window, BSTR media_query, IDispatch assert(NS_SUCCEEDED(nsres));
media_query_list->IWineMSHTMLMediaQueryList_iface.lpVtbl = &media_query_list_vtbl; - media_query_list->ref = 1; list_init(&media_query_list->listeners); init_dispatch(&media_query_list->dispex, (IUnknown*)&media_query_list->IWineMSHTMLMediaQueryList_iface, &media_query_list_dispex, dispex_compat_mode(&window->inner_window->event_target.dispex)); diff --git a/dlls/mshtml/range.c b/dlls/mshtml/range.c index e7234994933..4c7bd710265 100644 --- a/dlls/mshtml/range.c +++ b/dlls/mshtml/range.c @@ -37,8 +37,6 @@ typedef struct { IHTMLTxtRange IHTMLTxtRange_iface; IOleCommandTarget IOleCommandTarget_iface;
- LONG ref; - nsIDOMRange *nsrange; HTMLDocumentNode *doc;
@@ -49,8 +47,6 @@ typedef struct { DispatchEx dispex; IHTMLDOMRange IHTMLDOMRange_iface;
- LONG ref; - nsIDOMRange *nsrange; } HTMLDOMRange;
@@ -841,7 +837,7 @@ static HRESULT WINAPI HTMLTxtRange_QueryInterface(IHTMLTxtRange *iface, REFIID r static ULONG WINAPI HTMLTxtRange_AddRef(IHTMLTxtRange *iface) { HTMLTxtRange *This = impl_from_IHTMLTxtRange(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -851,13 +847,10 @@ static ULONG WINAPI HTMLTxtRange_AddRef(IHTMLTxtRange *iface) static ULONG WINAPI HTMLTxtRange_Release(IHTMLTxtRange *iface) { HTMLTxtRange *This = impl_from_IHTMLTxtRange(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -1762,7 +1755,6 @@ HRESULT HTMLTxtRange_Create(HTMLDocumentNode *doc, nsIDOMRange *nsrange, IHTMLTx
ret->IHTMLTxtRange_iface.lpVtbl = &HTMLTxtRangeVtbl; ret->IOleCommandTarget_iface.lpVtbl = &OleCommandTargetVtbl; - ret->ref = 1;
if(nsrange) nsIDOMRange_AddRef(nsrange); @@ -1805,7 +1797,7 @@ static HRESULT WINAPI HTMLDOMRange_QueryInterface(IHTMLDOMRange *iface, REFIID r static ULONG WINAPI HTMLDOMRange_AddRef(IHTMLDOMRange *iface) { HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -1815,13 +1807,10 @@ static ULONG WINAPI HTMLDOMRange_AddRef(IHTMLDOMRange *iface) static ULONG WINAPI HTMLDOMRange_Release(IHTMLDOMRange *iface) { HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -2124,7 +2113,6 @@ HRESULT create_dom_range(nsIDOMRange *nsrange, compat_mode_t compat_mode, IHTMLD init_dispatch(&ret->dispex, (IUnknown*)&ret->IHTMLDOMRange_iface, &HTMLDOMRange_dispex, compat_mode);
ret->IHTMLDOMRange_iface.lpVtbl = &HTMLDOMRangeVtbl; - ret->ref = 1;
if(nsrange) nsIDOMRange_AddRef(nsrange); diff --git a/dlls/mshtml/selection.c b/dlls/mshtml/selection.c index 3067b1a43b1..3b840d526d2 100644 --- a/dlls/mshtml/selection.c +++ b/dlls/mshtml/selection.c @@ -36,8 +36,6 @@ typedef struct { IHTMLSelectionObject IHTMLSelectionObject_iface; IHTMLSelectionObject2 IHTMLSelectionObject2_iface;
- LONG ref; - nsISelection *nsselection; HTMLDocumentNode *doc;
@@ -79,7 +77,7 @@ static HRESULT WINAPI HTMLSelectionObject_QueryInterface(IHTMLSelectionObject *i static ULONG WINAPI HTMLSelectionObject_AddRef(IHTMLSelectionObject *iface) { HTMLSelectionObject *This = impl_from_IHTMLSelectionObject(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -89,13 +87,10 @@ static ULONG WINAPI HTMLSelectionObject_AddRef(IHTMLSelectionObject *iface) static ULONG WINAPI HTMLSelectionObject_Release(IHTMLSelectionObject *iface) { HTMLSelectionObject *This = impl_from_IHTMLSelectionObject(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -374,7 +369,6 @@ HRESULT HTMLSelectionObject_Create(HTMLDocumentNode *doc, nsISelection *nsselect
selection->IHTMLSelectionObject_iface.lpVtbl = &HTMLSelectionObjectVtbl; selection->IHTMLSelectionObject2_iface.lpVtbl = &HTMLSelectionObject2Vtbl; - selection->ref = 1; selection->nsselection = nsselection; /* We shouldn't call AddRef here */
selection->doc = doc; diff --git a/dlls/mshtml/xmlhttprequest.c b/dlls/mshtml/xmlhttprequest.c index 417923cf444..ba18bd419fa 100644 --- a/dlls/mshtml/xmlhttprequest.c +++ b/dlls/mshtml/xmlhttprequest.c @@ -136,7 +136,6 @@ struct HTMLXMLHttpRequest { IHTMLXMLHttpRequest2 IHTMLXMLHttpRequest2_iface; IWineXMLHttpRequestPrivate IWineXMLHttpRequestPrivate_iface; IProvideClassInfo2 IProvideClassInfo2_iface; - LONG ref; LONG task_magic; LONG ready_state; response_type_t response_type; @@ -536,7 +535,7 @@ static HRESULT WINAPI HTMLXMLHttpRequest_QueryInterface(IHTMLXMLHttpRequest *ifa static ULONG WINAPI HTMLXMLHttpRequest_AddRef(IHTMLXMLHttpRequest *iface) { HTMLXMLHttpRequest *This = impl_from_IHTMLXMLHttpRequest(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->event_target.dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -546,12 +545,14 @@ static ULONG WINAPI HTMLXMLHttpRequest_AddRef(IHTMLXMLHttpRequest *iface) static ULONG WINAPI HTMLXMLHttpRequest_Release(IHTMLXMLHttpRequest *iface) { HTMLXMLHttpRequest *This = impl_from_IHTMLXMLHttpRequest(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->event_target.dispex);
TRACE("(%p) ref=%ld\n", This, ref);
+ /* The Cycle Collector might delay the unlink or destruction after ref reaches 0, + but we don't want a task to possibly grab ref to us and send events anymore. */ if(!ref) - release_dispex(&This->event_target.dispex); + This->magic++;
return ref; } @@ -1647,7 +1648,7 @@ static HRESULT WINAPI HTMLXMLHttpRequestFactory_QueryInterface(IHTMLXMLHttpReque static ULONG WINAPI HTMLXMLHttpRequestFactory_AddRef(IHTMLXMLHttpRequestFactory *iface) { HTMLXMLHttpRequestFactory *This = impl_from_IHTMLXMLHttpRequestFactory(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = dispex_ccref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -1657,13 +1658,10 @@ static ULONG WINAPI HTMLXMLHttpRequestFactory_AddRef(IHTMLXMLHttpRequestFactory static ULONG WINAPI HTMLXMLHttpRequestFactory_Release(IHTMLXMLHttpRequestFactory *iface) { HTMLXMLHttpRequestFactory *This = impl_from_IHTMLXMLHttpRequestFactory(iface); - LONG ref = InterlockedDecrement(&This->ref); + LONG ref = dispex_ccref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -1739,7 +1737,6 @@ static HRESULT WINAPI HTMLXMLHttpRequestFactory_create(IHTMLXMLHttpRequestFactor ret->IProvideClassInfo2_iface.lpVtbl = &ProvideClassInfo2Vtbl; EventTarget_Init(&ret->event_target, (IUnknown*)&ret->IHTMLXMLHttpRequest_iface, &HTMLXMLHttpRequest_dispex, This->window->doc->document_mode); - ret->ref = 1;
/* Always register the handlers because we need them to track state */ event_listener->nsIDOMEventListener_iface.lpVtbl = &XMLHttpReqEventListenerVtbl; @@ -1840,7 +1837,6 @@ HRESULT HTMLXMLHttpRequestFactory_Create(HTMLInnerWindow* window, HTMLXMLHttpReq return E_OUTOFMEMORY;
ret->IHTMLXMLHttpRequestFactory_iface.lpVtbl = &HTMLXMLHttpRequestFactoryVtbl; - ret->ref = 1; ret->window = window;
init_dispatch(&ret->dispex, (IUnknown*)&ret->IHTMLXMLHttpRequestFactory_iface,