Module: wine Branch: master Commit: 213786efe2f745dfc79b97177da66a3194ddc1bb URL: https://gitlab.winehq.org/wine/wine/-/commit/213786efe2f745dfc79b97177da66a3...
Author: Gabriel Ivăncescu gabrielopcode@gmail.com Date: Thu Nov 2 16:11:20 2023 +0200
mshtml: Traverse and unlink the Element referenced from the CurrentStyle.
This was actually leaking even before the Cycle Collection was implemented.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com
---
dlls/mshtml/htmlcurstyle.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-)
diff --git a/dlls/mshtml/htmlcurstyle.c b/dlls/mshtml/htmlcurstyle.c index 07f67d5cbf6..29543eb4a18 100644 --- a/dlls/mshtml/htmlcurstyle.c +++ b/dlls/mshtml/htmlcurstyle.c @@ -1278,9 +1278,14 @@ static const IHTMLCurrentStyle4Vtbl HTMLCurrentStyle4Vtbl = { HTMLCurrentStyle4_get_maxWidth };
+static inline HTMLCurrentStyle *impl_from_DispatchEx(DispatchEx *dispex) +{ + return CONTAINING_RECORD(dispex, HTMLCurrentStyle, css_style.dispex); +} + static void *HTMLCurrentStyle_query_interface(DispatchEx *dispex, REFIID riid) { - HTMLCurrentStyle *This = CONTAINING_RECORD(dispex, HTMLCurrentStyle, css_style.dispex); + HTMLCurrentStyle *This = impl_from_DispatchEx(dispex);
if(IsEqualGUID(&IID_IHTMLCurrentStyle, riid)) return &This->IHTMLCurrentStyle_iface; @@ -1293,11 +1298,32 @@ static void *HTMLCurrentStyle_query_interface(DispatchEx *dispex, REFIID riid) return CSSStyle_query_interface(&This->css_style.dispex, riid); }
+static void HTMLCurrentStyle_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb) +{ + HTMLCurrentStyle *This = impl_from_DispatchEx(dispex); + CSSStyle_traverse(&This->css_style.dispex, cb); + + if(This->elem) + note_cc_edge((nsISupports*)&This->elem->node.IHTMLDOMNode_iface, "elem", cb); +} + +static void HTMLCurrentStyle_unlink(DispatchEx *dispex) +{ + HTMLCurrentStyle *This = impl_from_DispatchEx(dispex); + CSSStyle_unlink(&This->css_style.dispex); + + if(This->elem) { + HTMLElement *elem = This->elem; + This->elem = NULL; + IHTMLDOMNode_Release(&elem->node.IHTMLDOMNode_iface); + } +} + static const dispex_static_data_vtbl_t HTMLCurrentStyle_dispex_vtbl = { CSSSTYLE_DISPEX_VTBL_ENTRIES, .query_interface = HTMLCurrentStyle_query_interface, - .traverse = CSSStyle_traverse, - .unlink = CSSStyle_unlink + .traverse = HTMLCurrentStyle_traverse, + .unlink = HTMLCurrentStyle_unlink };
static const tid_t HTMLCurrentStyle_iface_tids[] = {