Module: wine Branch: master Commit: db2d10b3a3225d576aef4351252a8e48e1a9228a URL: https://gitlab.winehq.org/wine/wine/-/commit/db2d10b3a3225d576aef4351252a8e4...
Author: Gabriel Ivăncescu gabrielopcode@gmail.com Date: Thu Nov 2 16:11:19 2023 +0200
mshtml: Keep ref from the associated Style to the Element.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com
---
dlls/mshtml/htmlcurstyle.c | 4 +++- dlls/mshtml/htmlelem.c | 24 ++++++++++++++---------- dlls/mshtml/htmlstyle.c | 41 ++++++++++++++++++++++++++++++++++++----- dlls/mshtml/htmlstyle.h | 2 -- 4 files changed, 53 insertions(+), 18 deletions(-)
diff --git a/dlls/mshtml/htmlcurstyle.c b/dlls/mshtml/htmlcurstyle.c index 27ad42410c1..07f67d5cbf6 100644 --- a/dlls/mshtml/htmlcurstyle.c +++ b/dlls/mshtml/htmlcurstyle.c @@ -1295,7 +1295,9 @@ static void *HTMLCurrentStyle_query_interface(DispatchEx *dispex, REFIID riid)
static const dispex_static_data_vtbl_t HTMLCurrentStyle_dispex_vtbl = { CSSSTYLE_DISPEX_VTBL_ENTRIES, - .query_interface = HTMLCurrentStyle_query_interface + .query_interface = HTMLCurrentStyle_query_interface, + .traverse = CSSStyle_traverse, + .unlink = CSSStyle_unlink };
static const tid_t HTMLCurrentStyle_iface_tids[] = { diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index e3010d3f059..cfc84523436 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -6863,6 +6863,10 @@ void HTMLElement_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback HTMLElement *This = impl_from_DispatchEx(dispex); HTMLDOMNode_traverse(&This->node.event_target.dispex, cb);
+ if(This->style) + note_cc_edge((nsISupports*)&This->style->IHTMLStyle_iface, "style", cb); + if(This->runtime_style) + note_cc_edge((nsISupports*)&This->runtime_style->IHTMLStyle_iface, "runtime_style", cb); if(This->attrs) note_cc_edge((nsISupports*)&This->attrs->IHTMLAttributeCollection_iface, "attrs", cb); } @@ -6872,6 +6876,16 @@ void HTMLElement_unlink(DispatchEx *dispex) HTMLElement *This = impl_from_DispatchEx(dispex); HTMLDOMNode_unlink(&This->node.event_target.dispex);
+ if(This->style) { + HTMLStyle *style = This->style; + This->style = NULL; + IHTMLStyle_Release(&style->IHTMLStyle_iface); + } + if(This->runtime_style) { + HTMLStyle *runtime_style = This->runtime_style; + This->runtime_style = NULL; + IHTMLStyle_Release(&runtime_style->IHTMLStyle_iface); + } if(This->attrs) { HTMLAttributeCollection *attrs = This->attrs; This->attrs = NULL; @@ -6884,16 +6898,6 @@ void HTMLElement_destructor(DispatchEx *dispex) HTMLElement *This = impl_from_DispatchEx(dispex);
ConnectionPointContainer_Destroy(&This->cp_container); - - if(This->style) { - This->style->elem = NULL; - IHTMLStyle_Release(&This->style->IHTMLStyle_iface); - } - if(This->runtime_style) { - This->runtime_style->elem = NULL; - IHTMLStyle_Release(&This->runtime_style->IHTMLStyle_iface); - } - free(This->filter); HTMLDOMNode_destructor(&This->node.event_target.dispex); } diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c index 8c4af46836f..6dfa9744df3 100644 --- a/dlls/mshtml/htmlstyle.c +++ b/dlls/mshtml/htmlstyle.c @@ -9967,9 +9967,14 @@ HRESULT CSSStyle_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID * return DISP_E_UNKNOWNNAME; }
+static inline HTMLStyle *HTMLStyle_from_DispatchEx(DispatchEx *dispex) +{ + return CONTAINING_RECORD(dispex, HTMLStyle, css_style.dispex); +} + static void *HTMLStyle_query_interface(DispatchEx *dispex, REFIID riid) { - HTMLStyle *This = CONTAINING_RECORD(dispex, HTMLStyle, css_style.dispex); + HTMLStyle *This = HTMLStyle_from_DispatchEx(dispex);
if(IsEqualGUID(&IID_IHTMLStyle, riid)) return &This->IHTMLStyle_iface; @@ -9986,6 +9991,27 @@ static void *HTMLStyle_query_interface(DispatchEx *dispex, REFIID riid) return CSSStyle_query_interface(&This->css_style.dispex, riid); }
+static void HTMLStyle_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb) +{ + HTMLStyle *This = HTMLStyle_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 HTMLStyle_unlink(DispatchEx *dispex) +{ + HTMLStyle *This = HTMLStyle_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); + } +} + void CSSStyle_init_dispex_info(dispex_data_t *info, compat_mode_t mode) { if(mode >= COMPAT_MODE_IE9) @@ -9994,9 +10020,11 @@ void CSSStyle_init_dispex_info(dispex_data_t *info, compat_mode_t mode) dispex_info_add_interface(info, IHTMLCSSStyleDeclaration2_tid, NULL); }
-static const dispex_static_data_vtbl_t CSSStyle_dispex_vtbl = { +static const dispex_static_data_vtbl_t HTMLStyle_dispex_vtbl = { CSSSTYLE_DISPEX_VTBL_ENTRIES, - .query_interface = HTMLStyle_query_interface + .query_interface = HTMLStyle_query_interface, + .traverse = HTMLStyle_traverse, + .unlink = HTMLStyle_unlink };
static const tid_t HTMLStyle_iface_tids[] = { @@ -10010,7 +10038,7 @@ static const tid_t HTMLStyle_iface_tids[] = { }; static dispex_static_data_t HTMLStyle_dispex = { "MSStyleCSSProperties", - &CSSStyle_dispex_vtbl, + &HTMLStyle_dispex_vtbl, DispHTMLStyle_tid, HTMLStyle_iface_tids, CSSStyle_init_dispex_info @@ -10088,6 +10116,7 @@ HRESULT HTMLStyle_Create(HTMLElement *elem, HTMLStyle **ret) style->IHTMLStyle6_iface.lpVtbl = &HTMLStyle6Vtbl;
style->elem = elem; + IHTMLDOMNode_AddRef(&elem->node.IHTMLDOMNode_iface);
init_css_style(&style->css_style, nsstyle, &HTMLStyle_dispex, dispex_compat_mode(&elem->node.event_target.dispex)); nsIDOMCSSStyleDeclaration_Release(nsstyle); @@ -10098,7 +10127,9 @@ HRESULT HTMLStyle_Create(HTMLElement *elem, HTMLStyle **ret)
static const dispex_static_data_vtbl_t HTMLW3CComputedStyle_dispex_vtbl = { CSSSTYLE_DISPEX_VTBL_ENTRIES, - .query_interface = CSSStyle_query_interface + .query_interface = CSSStyle_query_interface, + .traverse = CSSStyle_traverse, + .unlink = CSSStyle_unlink };
static const tid_t HTMLW3CComputedStyle_iface_tids[] = { diff --git a/dlls/mshtml/htmlstyle.h b/dlls/mshtml/htmlstyle.h index 5246e799ce5..f6d5ea7c5bb 100644 --- a/dlls/mshtml/htmlstyle.h +++ b/dlls/mshtml/htmlstyle.h @@ -166,6 +166,4 @@ HRESULT set_elem_style(HTMLElement*,styleid_t,const WCHAR*);
#define CSSSTYLE_DISPEX_VTBL_ENTRIES \ .destructor = CSSStyle_destructor, \ - .traverse = CSSStyle_traverse, \ - .unlink = CSSStyle_unlink, \ .get_dispid = CSSStyle_get_dispid