Module: wine Branch: master Commit: 684aa5bbfb8d229f4b418495f2ed4e9adbf6fbe9 URL: https://gitlab.winehq.org/wine/wine/-/commit/684aa5bbfb8d229f4b418495f2ed4e9...
Author: Gabriel Ivăncescu gabrielopcode@gmail.com Date: Tue Aug 22 16:21:48 2023 +0300
mshtml: Implement Cycle Collection for HTMLDOMRange.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com
---
dlls/mshtml/range.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/dlls/mshtml/range.c b/dlls/mshtml/range.c index 4d732fb891b..71e225a587e 100644 --- a/dlls/mshtml/range.c +++ b/dlls/mshtml/range.c @@ -47,8 +47,6 @@ typedef struct { DispatchEx dispex; IHTMLDOMRange IHTMLDOMRange_iface;
- LONG ref; - nsIDOMRange *nsrange; } HTMLDOMRange;
@@ -1792,7 +1790,7 @@ static HRESULT WINAPI HTMLDOMRange_QueryInterface(IHTMLDOMRange *iface, REFIID r *ppv = &This->IHTMLDOMRange_iface; }else if(IsEqualGUID(&IID_IHTMLDOMRange, riid)) { *ppv = &This->IHTMLDOMRange_iface; - }else if(dispex_query_interface_no_cc(&This->dispex, riid, ppv)) { + }else if(dispex_query_interface(&This->dispex, riid, ppv)) { return *ppv ? S_OK : E_NOINTERFACE; }else { *ppv = NULL; @@ -1807,7 +1805,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_ref_incr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
@@ -1817,13 +1815,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_ref_decr(&This->dispex);
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) - release_dispex(&This->dispex); - return ref; }
@@ -2086,6 +2081,13 @@ static inline HTMLDOMRange *HTMLDOMRange_from_DispatchEx(DispatchEx *iface) return CONTAINING_RECORD(iface, HTMLDOMRange, dispex); }
+static void HTMLDOMRange_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb) +{ + HTMLDOMRange *This = HTMLDOMRange_from_DispatchEx(dispex); + if(This->nsrange) + note_cc_edge((nsISupports*)This->nsrange, "nsrange", cb); +} + static void HTMLDOMRange_unlink(DispatchEx *dispex) { HTMLDOMRange *This = HTMLDOMRange_from_DispatchEx(dispex); @@ -2100,6 +2102,7 @@ static void HTMLDOMRange_destructor(DispatchEx *dispex)
static const dispex_static_data_vtbl_t HTMLDOMRange_dispex_vtbl = { .destructor = HTMLDOMRange_destructor, + .traverse = HTMLDOMRange_traverse, .unlink = HTMLDOMRange_unlink };
@@ -2126,7 +2129,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);