From 6d63a630fe27097cb4ee9072b63f67681ffbea85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Iv=C4=83ncescu?= Date: Tue, 1 Aug 2023 19:45:25 +0300 Subject: [PATCH] mshtml: Use unlink and destructor in the vtbl for HTMLStyleSheetRule. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gabriel Ivăncescu --- dlls/mshtml/htmlstylesheet.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/dlls/mshtml/htmlstylesheet.c b/dlls/mshtml/htmlstylesheet.c index 73d94d1f2c0..79c59bf3058 100644 --- a/dlls/mshtml/htmlstylesheet.c +++ b/dlls/mshtml/htmlstylesheet.c @@ -123,12 +123,8 @@ static ULONG WINAPI HTMLStyleSheetRule_Release(IHTMLStyleSheetRule *iface) TRACE("(%p) ref=%ld\n", This, ref); - if(!ref) { + if(!ref) release_dispex(&This->dispex); - if(This->nsstylesheetrule) - nsIDOMCSSRule_Release(This->nsstylesheetrule); - free(This); - } return ref; } @@ -206,13 +202,35 @@ static const IHTMLStyleSheetRuleVtbl HTMLStyleSheetRuleVtbl = { HTMLStyleSheetRule_get_readOnly }; +static inline HTMLStyleSheetRule *HTMLStyleSheetRule_from_DispatchEx(DispatchEx *iface) +{ + return CONTAINING_RECORD(iface, HTMLStyleSheetRule, dispex); +} + +static void HTMLStyleSheetRule_unlink(DispatchEx *dispex) +{ + HTMLStyleSheetRule *This = HTMLStyleSheetRule_from_DispatchEx(dispex); + unlink_ref(&This->nsstylesheetrule); +} + +static void HTMLStyleSheetRule_destructor(DispatchEx *dispex) +{ + HTMLStyleSheetRule *This = HTMLStyleSheetRule_from_DispatchEx(dispex); + free(This); +} + +static const dispex_static_data_vtbl_t HTMLStyleSheetRule_dispex_vtbl = { + HTMLStyleSheetRule_destructor, + HTMLStyleSheetRule_unlink +}; + static const tid_t HTMLStyleSheetRule_iface_tids[] = { IHTMLStyleSheetRule_tid, 0 }; static dispex_static_data_t HTMLStyleSheetRule_dispex = { L"CSSStyleRule", - NULL, + &HTMLStyleSheetRule_dispex_vtbl, DispHTMLStyleSheetRule_tid, HTMLStyleSheetRule_iface_tids };