Commit db2d10b3 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

mshtml: Keep ref from the associated Style to the Element.

parent 9ea3493c
......@@ -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[] = {
......
......@@ -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);
}
......
......@@ -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[] = {
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment