This is first part in a series that implements Cycle Collection for every mshtml object (dispex) and cleans up rest of the code based on it, which is obviously needed due to dynamic props and other extra object-specific refs.
In an effort to split it up as much as possible, since it already has quite a lot of restructuring and changes, some of the earlier patches will introduce temporary leaks or cyclic refs, but that's because we'll later handle them properly with the dispex CC. These shouldn't affect behavior, though, so it shouldn't pose problems for functionality.
Nodes are, initially, not changed much (other than to make it compatible with the dispex) to keep changes as small as possible. They still use their own CC mechanism and refcounting, which is hackish but that is solved in a follow-up MR, so it's temporary only.
Eventually, every object (including nodes) will use the dispex's vtbl to do its Cycle Collection, except for stuff like outer window (which is a special case).
In this first part, the objects that are using the node CC will have no-op dispex CC methods since they are using the node's, but this is temporary only.
v2: Now the entire first part will be split up into several MRs. This only moves destruction/unlinking of dispex into separate vtbl methods, without actually using any of the CC yet. `release_dispex` will now call the unlink and destructor, if available (it won't be optional later, but for now it is), so only those converted objects make use of it.
Most of the patches are small and typically convert one object at a time, except the first 4. More will follow up in subsequent MRs.
-- v3: mshtml: Use unlink and destructor in the vtbl for the MutationObserver mshtml: Use unlink and destructor in the vtbl for HTMLXMLHttpRequestFactory. mshtml: Use unlink and destructor in the vtbl for HTMLOptionElementFactory. mshtml: Use unlink and destructor in the vtbl for HTMLImageElementFactory. mshtml: Use unlink and destructor in the vtbl for HTMLStyleSheet. mshtml: Use unlink and destructor in the vtbl for HTMLStyleSheetsCollection. mshtml: Use unlink and destructor in the vtbl for mshtml: Use unlink and destructor in the vtbl for HTMLStyleSheetRule. mshtml: Use unlink and destructor in the vtbl for CSSStyle. mshtml: Use unlink and destructor in the vtbl for inner windows. mshtml: Use unlink and destructor in the vtbl for HTMLEventObj. mshtml: Use separate dispex destructors for different event types. mshtml: Use unlink and destructor in the vtbl for function disps. mshtml: Introduce unlink_ref helper. mshtml: Use the common HTMLElement dispex vtbl in the dispex definitions.
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Rather than filling it during initialization, which was a bit confusing, even more later on when dispex will handle Cycle Collection.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmlanchor.c | 2 +- dlls/mshtml/htmlarea.c | 2 +- dlls/mshtml/htmlbody.c | 2 +- dlls/mshtml/htmlcomment.c | 3 ++- dlls/mshtml/htmlelem.c | 5 +---- dlls/mshtml/htmlevent.h | 1 + dlls/mshtml/htmlform.c | 2 +- dlls/mshtml/htmlframe.c | 4 ++-- dlls/mshtml/htmlgeneric.c | 3 ++- dlls/mshtml/htmlhead.c | 9 +++++---- dlls/mshtml/htmlimg.c | 2 +- dlls/mshtml/htmlinput.c | 6 +++--- dlls/mshtml/htmllink.c | 2 +- dlls/mshtml/htmlobject.c | 5 +++-- dlls/mshtml/htmlscript.c | 2 +- dlls/mshtml/htmlselect.c | 4 ++-- dlls/mshtml/htmlstyleelem.c | 3 ++- dlls/mshtml/htmltable.c | 7 ++++--- dlls/mshtml/htmltextarea.c | 3 ++- 19 files changed, 36 insertions(+), 31 deletions(-)
diff --git a/dlls/mshtml/htmlanchor.c b/dlls/mshtml/htmlanchor.c index 1e783ce007e..7620bc45d81 100644 --- a/dlls/mshtml/htmlanchor.c +++ b/dlls/mshtml/htmlanchor.c @@ -902,7 +902,7 @@ static const tid_t HTMLAnchorElement_iface_tids[] = {
static dispex_static_data_t HTMLAnchorElement_dispex = { L"HTMLAnchorElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLAnchorElement_tid, HTMLAnchorElement_iface_tids, HTMLElement_init_dispex_info diff --git a/dlls/mshtml/htmlarea.c b/dlls/mshtml/htmlarea.c index c518432519d..b6dbd0b28d5 100644 --- a/dlls/mshtml/htmlarea.c +++ b/dlls/mshtml/htmlarea.c @@ -509,7 +509,7 @@ static const tid_t HTMLAreaElement_iface_tids[] = { }; static dispex_static_data_t HTMLAreaElement_dispex = { L"HTMLAreaElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLAreaElement_tid, HTMLAreaElement_iface_tids, HTMLElement_init_dispex_info diff --git a/dlls/mshtml/htmlbody.c b/dlls/mshtml/htmlbody.c index 6338e7e907b..5ee2555e421 100644 --- a/dlls/mshtml/htmlbody.c +++ b/dlls/mshtml/htmlbody.c @@ -1010,7 +1010,7 @@ static const tid_t HTMLBodyElement_iface_tids[] = {
static dispex_static_data_t HTMLBodyElement_dispex = { L"HTMLBodyElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLBody_tid, HTMLBodyElement_iface_tids, HTMLElement_init_dispex_info diff --git a/dlls/mshtml/htmlcomment.c b/dlls/mshtml/htmlcomment.c index cc3bec32959..705d84f4367 100644 --- a/dlls/mshtml/htmlcomment.c +++ b/dlls/mshtml/htmlcomment.c @@ -27,6 +27,7 @@ #include "ole2.h"
#include "mshtml_private.h" +#include "htmlevent.h"
#include "wine/debug.h"
@@ -200,7 +201,7 @@ static const tid_t HTMLCommentElement_iface_tids[] = { }; static dispex_static_data_t HTMLCommentElement_dispex = { L"Comment", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLCommentElement_tid, HTMLCommentElement_iface_tids, HTMLElement_init_dispex_info diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index ad5bda63665..53c418ab333 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -7326,7 +7326,7 @@ static const tid_t HTMLElement_iface_tids[] = { 0 };
-static event_target_vtbl_t HTMLElement_event_target_vtbl = { +const event_target_vtbl_t HTMLElement_event_target_vtbl = { { NULL, HTMLElement_get_dispid, @@ -7946,9 +7946,6 @@ void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMElement *n This->IProvideMultipleClassInfo_iface.lpVtbl = &ProvideMultipleClassInfoVtbl; This->IWineHTMLElementPrivate_iface.lpVtbl = &WineHTMLElementPrivateVtbl;
- if(dispex_data && !dispex_data->vtbl) - dispex_data->vtbl = &HTMLElement_event_target_vtbl.dispex_vtbl; - if(nselem) { nsIDOMHTMLElement *html_element; nsresult nsres; diff --git a/dlls/mshtml/htmlevent.h b/dlls/mshtml/htmlevent.h index 5a46b855a30..5e2c7a0a054 100644 --- a/dlls/mshtml/htmlevent.h +++ b/dlls/mshtml/htmlevent.h @@ -138,6 +138,7 @@ typedef struct { IHTMLEventObj *(*set_current_event)(DispatchEx*,IHTMLEventObj*); } event_target_vtbl_t;
+extern const event_target_vtbl_t HTMLElement_event_target_vtbl; IHTMLEventObj *default_set_current_event(HTMLInnerWindow*,IHTMLEventObj*);
static inline EventTarget *get_node_event_prop_target(HTMLDOMNode *node, eventid_t eid) diff --git a/dlls/mshtml/htmlform.c b/dlls/mshtml/htmlform.c index 3e7ca112311..385cc6f9834 100644 --- a/dlls/mshtml/htmlform.c +++ b/dlls/mshtml/htmlform.c @@ -1007,7 +1007,7 @@ static const tid_t HTMLFormElement_iface_tids[] = {
static dispex_static_data_t HTMLFormElement_dispex = { L"HTMLFormElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLFormElement_tid, HTMLFormElement_iface_tids, HTMLElement_init_dispex_info diff --git a/dlls/mshtml/htmlframe.c b/dlls/mshtml/htmlframe.c index 9be69c29f9a..acc5dbad8ca 100644 --- a/dlls/mshtml/htmlframe.c +++ b/dlls/mshtml/htmlframe.c @@ -1043,7 +1043,7 @@ static const tid_t HTMLFrameElement_iface_tids[] = {
static dispex_static_data_t HTMLFrameElement_dispex = { L"HTMLFrameElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLFrameElement_tid, HTMLFrameElement_iface_tids, HTMLElement_init_dispex_info @@ -1638,7 +1638,7 @@ static const tid_t HTMLIFrame_iface_tids[] = {
static dispex_static_data_t HTMLIFrame_dispex = { L"HTMLIFrameElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLIFrame_tid, HTMLIFrame_iface_tids, HTMLElement_init_dispex_info diff --git a/dlls/mshtml/htmlgeneric.c b/dlls/mshtml/htmlgeneric.c index 9244ba017fb..4666348fddb 100644 --- a/dlls/mshtml/htmlgeneric.c +++ b/dlls/mshtml/htmlgeneric.c @@ -29,6 +29,7 @@ #include "wine/debug.h"
#include "mshtml_private.h" +#include "htmlevent.h"
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
@@ -169,7 +170,7 @@ static const tid_t HTMLGenericElement_iface_tids[] = {
static dispex_static_data_t HTMLGenericElement_dispex = { L"HTMLUnknownElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLGenericElement_tid, HTMLGenericElement_iface_tids, HTMLElement_init_dispex_info diff --git a/dlls/mshtml/htmlhead.c b/dlls/mshtml/htmlhead.c index 072efd967b9..1ef183338c7 100644 --- a/dlls/mshtml/htmlhead.c +++ b/dlls/mshtml/htmlhead.c @@ -29,6 +29,7 @@ #include "wine/debug.h"
#include "mshtml_private.h" +#include "htmlevent.h"
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
@@ -184,7 +185,7 @@ static const tid_t HTMLTitleElement_iface_tids[] = { }; static dispex_static_data_t HTMLTitleElement_dispex = { L"HTMLTitleElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLTitleElement_tid, HTMLTitleElement_iface_tids, HTMLElement_init_dispex_info @@ -369,7 +370,7 @@ static const tid_t HTMLHtmlElement_iface_tids[] = { }; static dispex_static_data_t HTMLHtmlElement_dispex = { L"HTMLHtmlElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLHtmlElement_tid, HTMLHtmlElement_iface_tids, HTMLElement_init_dispex_info @@ -606,7 +607,7 @@ static const tid_t HTMLMetaElement_iface_tids[] = {
static dispex_static_data_t HTMLMetaElement_dispex = { L"HTMLMetaElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLMetaElement_tid, HTMLMetaElement_iface_tids, HTMLElement_init_dispex_info @@ -770,7 +771,7 @@ static const tid_t HTMLHeadElement_iface_tids[] = { }; static dispex_static_data_t HTMLHeadElement_dispex = { L"HTMLHeadElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLHeadElement_tid, HTMLHeadElement_iface_tids, HTMLElement_init_dispex_info diff --git a/dlls/mshtml/htmlimg.c b/dlls/mshtml/htmlimg.c index 50fa3531464..47fc2be8d5d 100644 --- a/dlls/mshtml/htmlimg.c +++ b/dlls/mshtml/htmlimg.c @@ -742,7 +742,7 @@ static void HTMLImgElement_init_dispex_info(dispex_data_t *info, compat_mode_t m
static dispex_static_data_t HTMLImgElement_dispex = { L"HTMLImageElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLImg_tid, HTMLImgElement_iface_tids, HTMLImgElement_init_dispex_info diff --git a/dlls/mshtml/htmlinput.c b/dlls/mshtml/htmlinput.c index c220a2495c7..4d59cf4f158 100644 --- a/dlls/mshtml/htmlinput.c +++ b/dlls/mshtml/htmlinput.c @@ -1456,7 +1456,7 @@ static const tid_t HTMLInputElement_iface_tids[] = { }; static dispex_static_data_t HTMLInputElement_dispex = { L"HTMLInputElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLInputElement_tid, HTMLInputElement_iface_tids, HTMLElement_init_dispex_info @@ -1653,7 +1653,7 @@ static const tid_t HTMLLabelElement_iface_tids[] = {
static dispex_static_data_t HTMLLabelElement_dispex = { L"HTMLLabelElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLLabelElement_tid, HTMLLabelElement_iface_tids, HTMLElement_init_dispex_info @@ -2001,7 +2001,7 @@ static const tid_t HTMLButtonElement_iface_tids[] = {
static dispex_static_data_t HTMLButtonElement_dispex = { L"HTMLButtonElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLButtonElement_tid, HTMLButtonElement_iface_tids, HTMLElement_init_dispex_info diff --git a/dlls/mshtml/htmllink.c b/dlls/mshtml/htmllink.c index 124507a2fc9..d5ae5932e0e 100644 --- a/dlls/mshtml/htmllink.c +++ b/dlls/mshtml/htmllink.c @@ -448,7 +448,7 @@ static const tid_t HTMLLinkElement_iface_tids[] = { }; static dispex_static_data_t HTMLLinkElement_dispex = { L"HTMLLinkElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLLinkElement_tid, HTMLLinkElement_iface_tids, HTMLElement_init_dispex_info diff --git a/dlls/mshtml/htmlobject.c b/dlls/mshtml/htmlobject.c index 9e30b5426fb..6e29ccd640c 100644 --- a/dlls/mshtml/htmlobject.c +++ b/dlls/mshtml/htmlobject.c @@ -29,6 +29,7 @@ #include "wine/debug.h"
#include "mshtml_private.h" +#include "htmlevent.h" #include "pluginhost.h"
WINE_DEFAULT_DEBUG_CHANNEL(mshtml); @@ -777,7 +778,7 @@ static const tid_t HTMLObjectElement_iface_tids[] = { }; static dispex_static_data_t HTMLObjectElement_dispex = { L"HTMLObjectElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLObjectElement_tid, HTMLObjectElement_iface_tids, HTMLElement_init_dispex_info @@ -1040,7 +1041,7 @@ static const tid_t HTMLEmbedElement_iface_tids[] = { }; static dispex_static_data_t HTMLEmbedElement_dispex = { L"HTMLEmbedElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLEmbed_tid, HTMLEmbedElement_iface_tids, HTMLElement_init_dispex_info diff --git a/dlls/mshtml/htmlscript.c b/dlls/mshtml/htmlscript.c index 2ef21fbfb0a..42cf63c47bd 100644 --- a/dlls/mshtml/htmlscript.c +++ b/dlls/mshtml/htmlscript.c @@ -481,7 +481,7 @@ static const tid_t HTMLScriptElement_iface_tids[] = {
static dispex_static_data_t HTMLScriptElement_dispex = { L"HTMLScriptElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLScriptElement_tid, HTMLScriptElement_iface_tids, HTMLElement_init_dispex_info diff --git a/dlls/mshtml/htmlselect.c b/dlls/mshtml/htmlselect.c index bbe6fadebba..dd1c784c28d 100644 --- a/dlls/mshtml/htmlselect.c +++ b/dlls/mshtml/htmlselect.c @@ -419,7 +419,7 @@ static const tid_t HTMLOptionElement_iface_tids[] = { }; static dispex_static_data_t HTMLOptionElement_dispex = { L"HTMLOptionElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLOptionElement_tid, HTMLOptionElement_iface_tids, HTMLElement_init_dispex_info @@ -1496,7 +1496,7 @@ static const tid_t HTMLSelectElement_tids[] = {
static dispex_static_data_t HTMLSelectElement_dispex = { L"HTMLSelectElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLSelectElement_tid, HTMLSelectElement_tids, HTMLElement_init_dispex_info diff --git a/dlls/mshtml/htmlstyleelem.c b/dlls/mshtml/htmlstyleelem.c index abd720cc18f..434afcd46e3 100644 --- a/dlls/mshtml/htmlstyleelem.c +++ b/dlls/mshtml/htmlstyleelem.c @@ -29,6 +29,7 @@ #include "wine/debug.h"
#include "mshtml_private.h" +#include "htmlevent.h" #include "mshtmdid.h"
WINE_DEFAULT_DEBUG_CHANNEL(mshtml); @@ -464,7 +465,7 @@ static const tid_t HTMLStyleElement_iface_tids[] = { }; static dispex_static_data_t HTMLStyleElement_dispex = { L"HTMLStyleElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLStyleElement_tid, HTMLStyleElement_iface_tids, HTMLStyleElement_init_dispex_info diff --git a/dlls/mshtml/htmltable.c b/dlls/mshtml/htmltable.c index 1afb32ea6ec..3cadc75b90d 100644 --- a/dlls/mshtml/htmltable.c +++ b/dlls/mshtml/htmltable.c @@ -28,6 +28,7 @@ #include "wine/debug.h"
#include "mshtml_private.h" +#include "htmlevent.h"
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
@@ -522,7 +523,7 @@ static const tid_t HTMLTableCell_iface_tids[] = {
static dispex_static_data_t HTMLTableCell_dispex = { L"HTMLTableDataCellElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLTableCell_tid, HTMLTableCell_iface_tids, HTMLElement_init_dispex_info @@ -968,7 +969,7 @@ static const tid_t HTMLTableRow_iface_tids[] = {
static dispex_static_data_t HTMLTableRow_dispex = { L"HTMLTableRowElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLTableRow_tid, HTMLTableRow_iface_tids, HTMLElement_init_dispex_info @@ -2002,7 +2003,7 @@ static const tid_t HTMLTable_iface_tids[] = {
static dispex_static_data_t HTMLTable_dispex = { L"HTMLTableElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLTable_tid, HTMLTable_iface_tids, HTMLElement_init_dispex_info diff --git a/dlls/mshtml/htmltextarea.c b/dlls/mshtml/htmltextarea.c index 5820c0c7291..98468685eab 100644 --- a/dlls/mshtml/htmltextarea.c +++ b/dlls/mshtml/htmltextarea.c @@ -28,6 +28,7 @@ #include "wine/debug.h"
#include "mshtml_private.h" +#include "htmlevent.h"
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
@@ -481,7 +482,7 @@ static const tid_t HTMLTextAreaElement_iface_tids[] = {
static dispex_static_data_t HTMLTextAreaElement_dispex = { L"HTMLTextAreaElement", - NULL, + &HTMLElement_event_target_vtbl.dispex_vtbl, DispHTMLTextAreaElement_tid, HTMLTextAreaElement_iface_tids, HTMLElement_init_dispex_info
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmlanchor.c | 8 +---- dlls/mshtml/htmlarea.c | 8 +---- dlls/mshtml/htmlbody.c | 7 +--- dlls/mshtml/htmldoc.c | 18 +++------- dlls/mshtml/htmlform.c | 8 +---- dlls/mshtml/htmlframe.c | 16 ++------- dlls/mshtml/htmlimg.c | 8 +---- dlls/mshtml/htmlinput.c | 16 ++------- dlls/mshtml/htmllink.c | 8 +---- dlls/mshtml/htmlnode.c | 7 +--- dlls/mshtml/htmlobject.c | 8 +---- dlls/mshtml/htmlscript.c | 8 +---- dlls/mshtml/htmlselect.c | 16 ++------- dlls/mshtml/htmlstyleelem.c | 14 ++------ dlls/mshtml/htmltable.c | 24 ++----------- dlls/mshtml/htmltextarea.c | 8 +---- dlls/mshtml/mshtml_private.h | 10 ++++++ dlls/mshtml/navigate.c | 16 ++------- dlls/mshtml/nsembed.c | 11 ++---- dlls/mshtml/nsevents.c | 5 +-- dlls/mshtml/nsio.c | 65 ++++++------------------------------ dlls/mshtml/oleobj.c | 48 ++++++-------------------- dlls/mshtml/persist.c | 12 ++----- dlls/mshtml/pluginhost.c | 17 ++-------- dlls/mshtml/script.c | 11 ++---- dlls/mshtml/view.c | 5 +-- 26 files changed, 70 insertions(+), 312 deletions(-)
diff --git a/dlls/mshtml/htmlanchor.c b/dlls/mshtml/htmlanchor.c index 7620bc45d81..988daa5d255 100644 --- a/dlls/mshtml/htmlanchor.c +++ b/dlls/mshtml/htmlanchor.c @@ -864,13 +864,7 @@ static void HTMLAnchorElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTrav static void HTMLAnchorElement_unlink(HTMLDOMNode *iface) { HTMLAnchorElement *This = impl_from_HTMLDOMNode(iface); - - if(This->nsanchor) { - nsIDOMHTMLAnchorElement *nsanchor = This->nsanchor; - - This->nsanchor = NULL; - nsIDOMHTMLAnchorElement_Release(nsanchor); - } + unlink_ref(&This->nsanchor); }
static const NodeImplVtbl HTMLAnchorElementImplVtbl = { diff --git a/dlls/mshtml/htmlarea.c b/dlls/mshtml/htmlarea.c index b6dbd0b28d5..2e4c92f8d4c 100644 --- a/dlls/mshtml/htmlarea.c +++ b/dlls/mshtml/htmlarea.c @@ -472,13 +472,7 @@ static void HTMLAreaElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraver static void HTMLAreaElement_unlink(HTMLDOMNode *iface) { HTMLAreaElement *This = impl_from_HTMLDOMNode(iface); - - if(This->nsarea) { - nsIDOMHTMLAreaElement *nsarea = This->nsarea; - - This->nsarea = NULL; - nsIDOMHTMLAreaElement_Release(nsarea); - } + unlink_ref(&This->nsarea); }
static const NodeImplVtbl HTMLAreaElementImplVtbl = { diff --git a/dlls/mshtml/htmlbody.c b/dlls/mshtml/htmlbody.c index 5ee2555e421..867aec39fc2 100644 --- a/dlls/mshtml/htmlbody.c +++ b/dlls/mshtml/htmlbody.c @@ -929,12 +929,7 @@ static void HTMLBodyElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraver static void HTMLBodyElement_unlink(HTMLDOMNode *iface) { HTMLBodyElement *This = impl_from_HTMLDOMNode(iface); - - if(This->nsbody) { - nsIDOMHTMLBodyElement *nsbody = This->nsbody; - This->nsbody = NULL; - nsIDOMHTMLBodyElement_Release(nsbody); - } + unlink_ref(&This->nsbody); }
static EventTarget *HTMLBodyElement_get_event_prop_target(HTMLDOMNode *iface, int event_id) diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 049b5c3559e..6777debecd0 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -5810,17 +5810,11 @@ void detach_document_node(HTMLDocumentNode *doc) while(!list_empty(&doc->plugin_hosts)) detach_plugin_host(LIST_ENTRY(list_head(&doc->plugin_hosts), PluginHost, entry));
- if(doc->dom_implementation) { + if(doc->dom_implementation) detach_dom_implementation(doc->dom_implementation); - IHTMLDOMImplementation_Release(doc->dom_implementation); - doc->dom_implementation = NULL; - } - - if(doc->namespaces) { - IHTMLNamespaceCollection_Release(doc->namespaces); - doc->namespaces = NULL; - }
+ unlink_ref(&doc->dom_implementation); + unlink_ref(&doc->namespaces); detach_events(doc); detach_selection(doc); detach_ranges(doc); @@ -5831,11 +5825,7 @@ void detach_document_node(HTMLDocumentNode *doc) doc->elem_vars_cnt = doc->elem_vars_size = 0; doc->elem_vars = NULL;
- if(doc->catmgr) { - ICatInformation_Release(doc->catmgr); - doc->catmgr = NULL; - } - + unlink_ref(&doc->catmgr); if(doc->browser) { list_remove(&doc->browser_entry); doc->browser = NULL; diff --git a/dlls/mshtml/htmlform.c b/dlls/mshtml/htmlform.c index 385cc6f9834..78b06391a8f 100644 --- a/dlls/mshtml/htmlform.c +++ b/dlls/mshtml/htmlform.c @@ -969,13 +969,7 @@ static void HTMLFormElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraver static void HTMLFormElement_unlink(HTMLDOMNode *iface) { HTMLFormElement *This = impl_from_HTMLDOMNode(iface); - - if(This->nsform) { - nsIDOMHTMLFormElement *nsform = This->nsform; - - This->nsform = NULL; - nsIDOMHTMLFormElement_Release(nsform); - } + unlink_ref(&This->nsform); }
static const NodeImplVtbl HTMLFormElementImplVtbl = { diff --git a/dlls/mshtml/htmlframe.c b/dlls/mshtml/htmlframe.c index acc5dbad8ca..126edc56181 100644 --- a/dlls/mshtml/htmlframe.c +++ b/dlls/mshtml/htmlframe.c @@ -1003,13 +1003,7 @@ static void HTMLFrameElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTrave static void HTMLFrameElement_unlink(HTMLDOMNode *iface) { HTMLFrameElement *This = frame_from_HTMLDOMNode(iface); - - if(This->framebase.nsframe) { - nsIDOMHTMLFrameElement *nsframe = This->framebase.nsframe; - - This->framebase.nsframe = NULL; - nsIDOMHTMLFrameElement_Release(nsframe); - } + unlink_ref(&This->framebase.nsframe); }
static const NodeImplVtbl HTMLFrameElementImplVtbl = { @@ -1596,13 +1590,7 @@ static void HTMLIFrame_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCa static void HTMLIFrame_unlink(HTMLDOMNode *iface) { HTMLIFrame *This = iframe_from_HTMLDOMNode(iface); - - if(This->framebase.nsiframe) { - nsIDOMHTMLIFrameElement *nsiframe = This->framebase.nsiframe; - - This->framebase.nsiframe = NULL; - nsIDOMHTMLIFrameElement_Release(nsiframe); - } + unlink_ref(&This->framebase.nsiframe); }
static const NodeImplVtbl HTMLIFrameImplVtbl = { diff --git a/dlls/mshtml/htmlimg.c b/dlls/mshtml/htmlimg.c index 47fc2be8d5d..d624c0e9df6 100644 --- a/dlls/mshtml/htmlimg.c +++ b/dlls/mshtml/htmlimg.c @@ -693,13 +693,7 @@ static void HTMLImgElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTravers static void HTMLImgElement_unlink(HTMLDOMNode *iface) { HTMLImg *This = impl_from_HTMLDOMNode(iface); - - if(This->nsimg) { - nsIDOMHTMLImageElement *nsimg = This->nsimg; - - This->nsimg = NULL; - nsIDOMHTMLImageElement_Release(nsimg); - } + unlink_ref(&This->nsimg); }
static const NodeImplVtbl HTMLImgElementImplVtbl = { diff --git a/dlls/mshtml/htmlinput.c b/dlls/mshtml/htmlinput.c index 4d59cf4f158..415b1aa7c59 100644 --- a/dlls/mshtml/htmlinput.c +++ b/dlls/mshtml/htmlinput.c @@ -1417,13 +1417,7 @@ static void HTMLInputElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTrave static void HTMLInputElement_unlink(HTMLDOMNode *iface) { HTMLInputElement *This = impl_from_HTMLDOMNode(iface); - - if(This->nsinput) { - nsIDOMHTMLInputElement *nsinput = This->nsinput; - - This->nsinput = NULL; - nsIDOMHTMLInputElement_Release(nsinput); - } + unlink_ref(&This->nsinput); }
static const NodeImplVtbl HTMLInputElementImplVtbl = { @@ -1962,13 +1956,7 @@ static void HTMLButtonElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTrav static void HTMLButtonElement_unlink(HTMLDOMNode *iface) { HTMLButtonElement *This = button_from_HTMLDOMNode(iface); - - if(This->nsbutton) { - nsIDOMHTMLButtonElement *nsbutton = This->nsbutton; - - This->nsbutton = NULL; - nsIDOMHTMLButtonElement_Release(nsbutton); - } + unlink_ref(&This->nsbutton); }
static const NodeImplVtbl HTMLButtonElementImplVtbl = { diff --git a/dlls/mshtml/htmllink.c b/dlls/mshtml/htmllink.c index d5ae5932e0e..82dc9b6dbe1 100644 --- a/dlls/mshtml/htmllink.c +++ b/dlls/mshtml/htmllink.c @@ -412,13 +412,7 @@ static void HTMLLinkElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraver static void HTMLLinkElement_unlink(HTMLDOMNode *iface) { HTMLLinkElement *This = impl_from_HTMLDOMNode(iface); - - if(This->nslink) { - nsIDOMHTMLLinkElement *nslink = This->nslink; - - This->nslink = NULL; - nsIDOMHTMLLinkElement_Release(nslink); - } + unlink_ref(&This->nslink); } static const NodeImplVtbl HTMLLinkElementImplVtbl = { &CLSID_HTMLLinkElement, diff --git a/dlls/mshtml/htmlnode.c b/dlls/mshtml/htmlnode.c index b29383ad9ff..b20c1decddb 100644 --- a/dlls/mshtml/htmlnode.c +++ b/dlls/mshtml/htmlnode.c @@ -1597,12 +1597,7 @@ static nsresult NSAPI HTMLDOMNode_unlink(void *p) This->vtbl->unlink(This);
dispex_unlink(&This->event_target.dispex); - - if(This->nsnode) { - nsIDOMNode *nsnode = This->nsnode; - This->nsnode = NULL; - nsIDOMNode_Release(nsnode); - } + unlink_ref(&This->nsnode);
if(This->doc && &This->doc->node != This) { HTMLDocumentNode *doc = This->doc; diff --git a/dlls/mshtml/htmlobject.c b/dlls/mshtml/htmlobject.c index 6e29ccd640c..f70da7bb8df 100644 --- a/dlls/mshtml/htmlobject.c +++ b/dlls/mshtml/htmlobject.c @@ -740,13 +740,7 @@ static void HTMLObjectElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTrav static void HTMLObjectElement_unlink(HTMLDOMNode *iface) { HTMLObjectElement *This = impl_from_HTMLDOMNode(iface); - - if(This->nsobject) { - nsIDOMHTMLObjectElement *nsobject = This->nsobject; - - This->nsobject = NULL; - nsIDOMHTMLObjectElement_Release(nsobject); - } + unlink_ref(&This->nsobject); }
static const NodeImplVtbl HTMLObjectElementImplVtbl = { diff --git a/dlls/mshtml/htmlscript.c b/dlls/mshtml/htmlscript.c index 42cf63c47bd..b440224309f 100644 --- a/dlls/mshtml/htmlscript.c +++ b/dlls/mshtml/htmlscript.c @@ -423,13 +423,7 @@ static void HTMLScriptElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTrav static void HTMLScriptElement_unlink(HTMLDOMNode *iface) { HTMLScriptElement *This = impl_from_HTMLDOMNode(iface); - - if(This->nsscript) { - nsIDOMHTMLScriptElement *nsscript = This->nsscript; - - This->nsscript = NULL; - nsIDOMHTMLScriptElement_Release(nsscript); - } + unlink_ref(&This->nsscript); }
static const NodeImplVtbl HTMLScriptElementImplVtbl = { diff --git a/dlls/mshtml/htmlselect.c b/dlls/mshtml/htmlselect.c index dd1c784c28d..31410e9f0f0 100644 --- a/dlls/mshtml/htmlselect.c +++ b/dlls/mshtml/htmlselect.c @@ -382,13 +382,7 @@ static void HTMLOptionElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTrav static void HTMLOptionElement_unlink(HTMLDOMNode *iface) { HTMLOptionElement *This = HTMLOptionElement_from_HTMLDOMNode(iface); - - if(This->nsoption) { - nsIDOMHTMLOptionElement *nsoption = This->nsoption; - - This->nsoption = NULL; - nsIDOMHTMLOptionElement_Release(nsoption); - } + unlink_ref(&This->nsoption); }
static const NodeImplVtbl HTMLOptionElementImplVtbl = { @@ -1458,13 +1452,7 @@ static void HTMLSelectElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTrav static void HTMLSelectElement_unlink(HTMLDOMNode *iface) { HTMLSelectElement *This = impl_from_HTMLDOMNode(iface); - - if(This->nsselect) { - nsIDOMHTMLSelectElement *nsselect = This->nsselect; - - This->nsselect = NULL; - nsIDOMHTMLSelectElement_Release(nsselect); - } + unlink_ref(&This->nsselect); }
static const NodeImplVtbl HTMLSelectElementImplVtbl = { diff --git a/dlls/mshtml/htmlstyleelem.c b/dlls/mshtml/htmlstyleelem.c index 434afcd46e3..4409f982343 100644 --- a/dlls/mshtml/htmlstyleelem.c +++ b/dlls/mshtml/htmlstyleelem.c @@ -393,11 +393,7 @@ static void HTMLStyleElement_destructor(HTMLDOMNode *iface) { HTMLStyleElement *This = impl_from_HTMLDOMNode(iface);
- if(This->style_sheet) { - IHTMLStyleSheet_Release(This->style_sheet); - This->style_sheet = NULL; - } - + unlink_ref(&This->style_sheet); HTMLElement_destructor(iface); }
@@ -412,13 +408,7 @@ static void HTMLStyleElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTrave static void HTMLStyleElement_unlink(HTMLDOMNode *iface) { HTMLStyleElement *This = impl_from_HTMLDOMNode(iface); - - if(This->nsstyle) { - nsIDOMHTMLStyleElement *nsstyle = This->nsstyle; - - This->nsstyle = NULL; - nsIDOMHTMLStyleElement_Release(nsstyle); - } + unlink_ref(&This->nsstyle); }
static void HTMLStyleElement_init_dispex_info(dispex_data_t *info, compat_mode_t mode) diff --git a/dlls/mshtml/htmltable.c b/dlls/mshtml/htmltable.c index 3cadc75b90d..cde97e5144c 100644 --- a/dlls/mshtml/htmltable.c +++ b/dlls/mshtml/htmltable.c @@ -485,13 +485,7 @@ static void HTMLTableCell_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversa static void HTMLTableCell_unlink(HTMLDOMNode *iface) { HTMLTableCell *This = HTMLTableCell_from_HTMLDOMNode(iface); - - if(This->nscell) { - nsIDOMHTMLTableCellElement *nscell = This->nscell; - - This->nscell = NULL; - nsIDOMHTMLTableCellElement_Release(nscell); - } + unlink_ref(&This->nscell); }
static const NodeImplVtbl HTMLTableCellImplVtbl = { @@ -931,13 +925,7 @@ static void HTMLTableRow_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversal static void HTMLTableRow_unlink(HTMLDOMNode *iface) { HTMLTableRow *This = HTMLTableRow_from_HTMLDOMNode(iface); - - if(This->nsrow) { - nsIDOMHTMLTableRowElement *nsrow = This->nsrow; - - This->nsrow = NULL; - nsIDOMHTMLTableRowElement_Release(nsrow); - } + unlink_ref(&This->nsrow); }
static const NodeImplVtbl HTMLTableRowImplVtbl = { @@ -1957,13 +1945,7 @@ static void HTMLTable_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCal static void HTMLTable_unlink(HTMLDOMNode *iface) { HTMLTable *This = impl_from_HTMLDOMNode(iface); - - if(This->nstable) { - nsIDOMHTMLTableElement *nstable = This->nstable; - - This->nstable = NULL; - nsIDOMHTMLTableElement_Release(nstable); - } + unlink_ref(&This->nstable); }
static const cpc_entry_t HTMLTable_cpc[] = { diff --git a/dlls/mshtml/htmltextarea.c b/dlls/mshtml/htmltextarea.c index 98468685eab..6b40b630112 100644 --- a/dlls/mshtml/htmltextarea.c +++ b/dlls/mshtml/htmltextarea.c @@ -443,13 +443,7 @@ static void HTMLTextAreaElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTr static void HTMLTextAreaElement_unlink(HTMLDOMNode *iface) { HTMLTextAreaElement *This = impl_from_HTMLDOMNode(iface); - - if(This->nstextarea) { - nsIDOMHTMLTextAreaElement *nstextarea = This->nstextarea; - - This->nstextarea = NULL; - nsIDOMHTMLTextAreaElement_Release(nstextarea); - } + unlink_ref(&This->nstextarea); }
static const NodeImplVtbl HTMLTextAreaElementImplVtbl = { diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 803e1e38b4d..c0274bd8aac 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -1483,6 +1483,16 @@ static inline BOOL is_power_of_2(unsigned x) return !(x & (x - 1)); }
+static inline void unlink_ref(void *p) +{ + IUnknown **ref = p; + if(*ref) { + IUnknown *unk = *ref; + *ref = NULL; + IUnknown_Release(unk); + } +} + #ifdef __i386__ extern void *call_thiscall_func; #endif diff --git a/dlls/mshtml/navigate.c b/dlls/mshtml/navigate.c index 112b63ba4b1..3583fb91069 100644 --- a/dlls/mshtml/navigate.c +++ b/dlls/mshtml/navigate.c @@ -335,15 +335,8 @@ static HRESULT WINAPI BindStatusCallback_OnStopBinding(IBindStatusCallback *ifac
hres = This->vtbl->stop_binding(This, hresult);
- if(This->binding) { - IBinding_Release(This->binding); - This->binding = NULL; - } - - if(This->mon) { - IMoniker_Release(This->mon); - This->mon = NULL; - } + unlink_ref(&This->binding); + unlink_ref(&This->mon);
list_remove(&This->entry); list_init(&This->entry); @@ -2016,10 +2009,7 @@ void abort_window_bindings(HTMLInnerWindow *window) window->bscallback = NULL; }
- if(window->mon) { - IMoniker_Release(window->mon); - window->mon = NULL; - } + unlink_ref(&window->mon); }
HRESULT channelbsc_load_stream(HTMLInnerWindow *pending_window, IMoniker *mon, IStream *stream) diff --git a/dlls/mshtml/nsembed.c b/dlls/mshtml/nsembed.c index 95c07c90390..21ddb3cb38f 100644 --- a/dlls/mshtml/nsembed.c +++ b/dlls/mshtml/nsembed.c @@ -1217,15 +1217,8 @@ void setup_editor_controller(GeckoBrowser *This) nsIControllerContext *ctrlctx; nsresult nsres;
- if(This->editor) { - nsIEditor_Release(This->editor); - This->editor = NULL; - } - - if(This->editor_controller) { - nsIController_Release(This->editor_controller); - This->editor_controller = NULL; - } + unlink_ref(&This->editor); + unlink_ref(&This->editor_controller);
nsres = get_nsinterface((nsISupports*)This->webbrowser, &IID_nsIEditingSession, (void**)&editing_session); diff --git a/dlls/mshtml/nsevents.c b/dlls/mshtml/nsevents.c index 90d4bc9e9bd..76a3f4ab4c6 100644 --- a/dlls/mshtml/nsevents.c +++ b/dlls/mshtml/nsevents.c @@ -293,10 +293,7 @@ static void handle_docobj_load(HTMLDocumentObj *doc) IOleCommandTarget *olecmd = NULL; HRESULT hres;
- if(doc->nscontainer->editor_controller) { - nsIController_Release(doc->nscontainer->editor_controller); - doc->nscontainer->editor_controller = NULL; - } + unlink_ref(&doc->nscontainer->editor_controller);
if(doc->nscontainer->usermode == EDITMODE) setup_editor_controller(doc->nscontainer); diff --git a/dlls/mshtml/nsio.c b/dlls/mshtml/nsio.c index 6bd9a408037..c0e0e2e9f5d 100644 --- a/dlls/mshtml/nsio.c +++ b/dlls/mshtml/nsio.c @@ -1246,10 +1246,7 @@ static nsresult NSAPI nsChannel_SetReferrerWithPolicy(nsIHttpChannel *iface, nsI if(aReferrerPolicy) FIXME("refferer policy %d not implemented\n", aReferrerPolicy);
- if(This->referrer) { - nsIURI_Release(This->referrer); - This->referrer = NULL; - } + unlink_ref(&This->referrer); if(!aReferrer) return NS_OK;
@@ -2283,42 +2280,13 @@ static nsresult NSAPI nsChannel_unlink(void *p)
TRACE("%p\n", This);
- if(This->owner) { - nsISupports *owner = This->owner; - This->owner = NULL; - nsISupports_Release(owner); - } - if(This->post_data_stream) { - nsIInputStream *post_data_stream = This->post_data_stream; - This->post_data_stream = NULL; - nsIInputStream_Release(post_data_stream); - } - if(This->load_info) { - nsISupports *load_info = This->load_info; - This->load_info = NULL; - nsISupports_Release(load_info); - } - if(This->load_group) { - nsILoadGroup *load_group = This->load_group; - This->load_group = NULL; - nsILoadGroup_Release(load_group); - } - if(This->notif_callback) { - nsIInterfaceRequestor *notif_callback = This->notif_callback; - This->notif_callback = NULL; - nsIInterfaceRequestor_Release(notif_callback); - } - if(This->original_uri) { - nsIURI *original_uri = This->original_uri; - This->original_uri = NULL; - nsIURI_Release(original_uri); - } - if(This->referrer) { - nsIURI *referrer = This->referrer; - This->referrer = NULL; - nsIURI_Release(referrer); - } - + unlink_ref(&This->owner); + unlink_ref(&This->post_data_stream); + unlink_ref(&This->load_info); + unlink_ref(&This->load_group); + unlink_ref(&This->notif_callback); + unlink_ref(&This->original_uri); + unlink_ref(&This->referrer); return NS_OK; }
@@ -2338,14 +2306,6 @@ static void NSAPI nsChannel_delete_cycle_collectable(void *p) free(This); }
-static void invalidate_uri(nsWineURI *This) -{ - if(This->uri) { - IUri_Release(This->uri); - This->uri = NULL; - } -} - static BOOL ensure_uri_builder(nsWineURI *This) { if(!This->is_mutable) { @@ -2366,7 +2326,7 @@ static BOOL ensure_uri_builder(nsWineURI *This) } }
- invalidate_uri(This); + unlink_ref(&This->uri); return TRUE; }
@@ -2501,11 +2461,8 @@ static nsresult NSAPI nsURI_SetSpec(nsIFileURL *iface, const nsACString *aSpec) return NS_ERROR_FAILURE; }
- invalidate_uri(This); - if(This->uri_builder) { - IUriBuilder_Release(This->uri_builder); - This->uri_builder = NULL; - } + unlink_ref(&This->uri); + unlink_ref(&This->uri_builder);
This->uri = uri; return NS_OK; diff --git a/dlls/mshtml/oleobj.c b/dlls/mshtml/oleobj.c index c01c18b5fa8..870500ff0ab 100644 --- a/dlls/mshtml/oleobj.c +++ b/dlls/mshtml/oleobj.c @@ -448,41 +448,17 @@ static HRESULT WINAPI DocObjOleObject_SetClientSite(IOleObject *iface, IOleClien if(pClientSite == This->client) return S_OK;
- if(This->client) { - IOleClientSite_Release(This->client); - This->client = NULL; + if(This->client) This->nscontainer->usermode = UNKNOWN_USERMODE; - } - - if(This->client_cmdtrg) { - IOleCommandTarget_Release(This->client_cmdtrg); - This->client_cmdtrg = NULL; - } - - if(This->hostui && !This->custom_hostui) { - IDocHostUIHandler_Release(This->hostui); - This->hostui = NULL; - } - - if(This->doc_object_service) { - IDocObjectService_Release(This->doc_object_service); - This->doc_object_service = NULL; - } - - if(This->webbrowser) { - IUnknown_Release(This->webbrowser); - This->webbrowser = NULL; - } - - if(This->browser_service) { - IUnknown_Release(This->browser_service); - This->browser_service = NULL; - }
- if(This->travel_log) { - ITravelLog_Release(This->travel_log); - This->travel_log = NULL; - } + unlink_ref(&This->client); + unlink_ref(&This->client_cmdtrg); + if(!This->custom_hostui) + unlink_ref(&This->hostui); + unlink_ref(&This->doc_object_service); + unlink_ref(&This->webbrowser); + unlink_ref(&This->browser_service); + unlink_ref(&This->travel_log);
memset(&This->hostinfo, 0, sizeof(DOCHOSTUIINFO));
@@ -1617,11 +1593,7 @@ static HRESULT WINAPI DocObjOleInPlaceObjectWindowless_InPlaceDeactivate(IOleInP if(!This->in_place_active) return S_OK;
- if(This->frame) { - IOleInPlaceFrame_Release(This->frame); - This->frame = NULL; - } - + unlink_ref(&This->frame); if(This->hwnd) { ShowWindow(This->hwnd, SW_HIDE); SetWindowPos(This->hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); diff --git a/dlls/mshtml/persist.c b/dlls/mshtml/persist.c index b1ec172f912..bea2ab65750 100644 --- a/dlls/mshtml/persist.c +++ b/dlls/mshtml/persist.c @@ -75,16 +75,8 @@ static void notify_travellog_update(HTMLDocumentObj *doc)
void set_current_uri(HTMLOuterWindow *window, IUri *uri) { - if(window->uri) { - IUri_Release(window->uri); - window->uri = NULL; - } - - if(window->uri_nofrag) { - IUri_Release(window->uri_nofrag); - window->uri_nofrag = NULL; - } - + unlink_ref(&window->uri); + unlink_ref(&window->uri_nofrag); SysFreeString(window->url); window->url = NULL;
diff --git a/dlls/mshtml/pluginhost.c b/dlls/mshtml/pluginhost.c index c81c17690ac..f910600de18 100644 --- a/dlls/mshtml/pluginhost.c +++ b/dlls/mshtml/pluginhost.c @@ -1515,15 +1515,8 @@ static ULONG WINAPI PHClientSite_AddRef(IOleClientSite *iface)
static void release_plugin_ifaces(PluginHost *This) { - if(This->disp) { - IDispatch_Release(This->disp); - This->disp = NULL; - } - - if(This->ip_object) { - IOleInPlaceObject_Release(This->ip_object); - This->ip_object = NULL; - } + unlink_ref(&This->disp); + unlink_ref(&This->ip_object);
if(This->plugin_unk) { IUnknown *unk = This->plugin_unk; @@ -1970,11 +1963,7 @@ static HRESULT WINAPI PHInPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx *iface
TRACE("(%p)\n", This);
- if(This->ip_object) { - IOleInPlaceObject_Release(This->ip_object); - This->ip_object = NULL; - } - + unlink_ref(&This->ip_object); return S_OK; }
diff --git a/dlls/mshtml/script.c b/dlls/mshtml/script.c index 0cd79b45405..ad44a1ace41 100644 --- a/dlls/mshtml/script.c +++ b/dlls/mshtml/script.c @@ -257,15 +257,8 @@ static void release_script_engine(ScriptHost *This) IActiveScript_Close(This->script);
default: - if(This->parse_proc) { - IActiveScriptParseProcedure2_Release(This->parse_proc); - This->parse_proc = NULL; - } - - if(This->parse) { - IActiveScriptParse_Release(This->parse); - This->parse = NULL; - } + unlink_ref(&This->parse_proc); + unlink_ref(&This->parse); }
IActiveScript_Release(This->script); diff --git a/dlls/mshtml/view.c b/dlls/mshtml/view.c index 3f31e609e39..43ebc5284f5 100644 --- a/dlls/mshtml/view.c +++ b/dlls/mshtml/view.c @@ -619,10 +619,7 @@ static HRESULT WINAPI OleDocumentView_Show(IOleDocumentView *iface, BOOL fShow) if(This->in_place_active) IOleInPlaceObjectWindowless_InPlaceDeactivate(&This->IOleInPlaceObjectWindowless_iface);
- if(This->ip_window) { - IOleInPlaceUIWindow_Release(This->ip_window); - This->ip_window = NULL; - } + unlink_ref(&This->ip_window); }
return S_OK;
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/dispex.c | 23 ++++++++++++++++++----- dlls/mshtml/htmldoc.c | 2 ++ dlls/mshtml/htmlelem.c | 10 ++++++++++ dlls/mshtml/htmlelemcol.c | 2 ++ dlls/mshtml/htmlimg.c | 2 ++ dlls/mshtml/htmlnode.c | 2 ++ dlls/mshtml/htmlselect.c | 2 ++ dlls/mshtml/htmlstorage.c | 2 ++ dlls/mshtml/htmlstyle.c | 2 ++ dlls/mshtml/htmlstylesheet.c | 4 ++++ dlls/mshtml/htmlwindow.c | 2 ++ dlls/mshtml/mshtml_private.h | 4 ++++ dlls/mshtml/xmlhttprequest.c | 2 ++ 13 files changed, 54 insertions(+), 5 deletions(-)
diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index fecc7f6690c..09782fb83c9 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -826,11 +826,8 @@ static ULONG WINAPI Function_Release(IUnknown *iface)
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) { - assert(!This->obj); + if(!ref) release_dispex(&This->dispex); - free(This); - }
return ref; } @@ -846,6 +843,13 @@ static inline func_disp_t *impl_from_DispatchEx(DispatchEx *iface) return CONTAINING_RECORD(iface, func_disp_t, dispex); }
+static void function_destructor(DispatchEx *dispex) +{ + func_disp_t *This = impl_from_DispatchEx(dispex); + assert(!This->obj); + free(This); +} + static HRESULT function_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { @@ -902,6 +906,8 @@ static HRESULT function_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPAR }
static const dispex_static_data_vtbl_t function_dispex_vtbl = { + function_destructor, + NULL, function_value, NULL, NULL, @@ -2053,8 +2059,11 @@ void release_dispex(DispatchEx *This) { dynamic_prop_t *prop;
+ if(This->info->desc->vtbl && This->info->desc->vtbl->unlink) + This->info->desc->vtbl->unlink(This); + if(!This->dynamic_data) - return; + goto destructor;
for(prop = This->dynamic_data->props; prop < This->dynamic_data->props + This->dynamic_data->prop_cnt; prop++) { VariantClear(&prop->var); @@ -2078,6 +2087,10 @@ void release_dispex(DispatchEx *This) }
free(This->dynamic_data); + +destructor: + if(This->info->desc->vtbl && This->info->desc->vtbl->destructor) + This->info->desc->vtbl->destructor(This); }
void init_dispatch(DispatchEx *dispex, IUnknown *outer, dispex_static_data_t *data, compat_mode_t compat_mode) diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 6777debecd0..23b0064c9a6 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -6086,6 +6086,8 @@ static HRESULT HTMLDocumentNode_location_hook(DispatchEx *dispex, WORD flags, DI
static const event_target_vtbl_t HTMLDocumentNode_event_target_vtbl = { { + NULL, + NULL, NULL, NULL, HTMLDocumentNode_get_name, diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index 53c418ab333..f9ab44ce5fc 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -1269,6 +1269,8 @@ static HRESULT HTMLRectCollection_invoke(DispatchEx *dispex, DISPID id, LCID lci }
static const dispex_static_data_vtbl_t HTMLRectCollection_dispex_vtbl = { + NULL, + NULL, NULL, HTMLRectCollection_get_dispid, HTMLRectCollection_get_name, @@ -7328,6 +7330,8 @@ static const tid_t HTMLElement_iface_tids[] = {
const event_target_vtbl_t HTMLElement_event_target_vtbl = { { + NULL, + NULL, NULL, HTMLElement_get_dispid, HTMLElement_get_name, @@ -7795,6 +7799,8 @@ static HRESULT token_list_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD }
static const dispex_static_data_vtbl_t token_list_dispex_vtbl = { + NULL, + NULL, token_list_value, token_list_get_dispid, token_list_get_name, @@ -8211,6 +8217,8 @@ static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID }
static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = { + NULL, + NULL, NULL, HTMLFiltersCollection_get_dispid, HTMLFiltersCollection_get_name, @@ -8967,6 +8975,8 @@ static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCI }
static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl = { + NULL, + NULL, NULL, HTMLAttributeCollection_get_dispid, HTMLAttributeCollection_get_name, diff --git a/dlls/mshtml/htmlelemcol.c b/dlls/mshtml/htmlelemcol.c index 75ee079e3c7..afd7104c476 100644 --- a/dlls/mshtml/htmlelemcol.c +++ b/dlls/mshtml/htmlelemcol.c @@ -622,6 +622,8 @@ static HRESULT HTMLElementCollection_invoke(DispatchEx *dispex, DISPID id, LCID }
static const dispex_static_data_vtbl_t HTMLElementColection_dispex_vtbl = { + NULL, + NULL, NULL, HTMLElementCollection_get_dispid, HTMLElementCollection_get_name, diff --git a/dlls/mshtml/htmlimg.c b/dlls/mshtml/htmlimg.c index d624c0e9df6..e0ade235c01 100644 --- a/dlls/mshtml/htmlimg.c +++ b/dlls/mshtml/htmlimg.c @@ -975,6 +975,8 @@ static const tid_t HTMLImageElementFactory_iface_tids[] = { };
static const dispex_static_data_vtbl_t HTMLImageElementFactory_dispex_vtbl = { + NULL, + NULL, HTMLImageElementFactory_value, NULL, NULL, diff --git a/dlls/mshtml/htmlnode.c b/dlls/mshtml/htmlnode.c index b20c1decddb..0b509eca79a 100644 --- a/dlls/mshtml/htmlnode.c +++ b/dlls/mshtml/htmlnode.c @@ -433,6 +433,8 @@ static HRESULT HTMLDOMChildrenCollection_invoke(DispatchEx *dispex, DISPID id, L }
static const dispex_static_data_vtbl_t HTMLDOMChildrenCollection_dispex_vtbl = { + NULL, + NULL, NULL, HTMLDOMChildrenCollection_get_dispid, HTMLDOMChildrenCollection_get_name, diff --git a/dlls/mshtml/htmlselect.c b/dlls/mshtml/htmlselect.c index 31410e9f0f0..cbbd9ebcc69 100644 --- a/dlls/mshtml/htmlselect.c +++ b/dlls/mshtml/htmlselect.c @@ -629,6 +629,8 @@ static const tid_t HTMLOptionElementFactory_iface_tids[] = { };
static const dispex_static_data_vtbl_t HTMLOptionElementFactory_dispex_vtbl = { + NULL, + NULL, HTMLOptionElementFactory_value, NULL, NULL, diff --git a/dlls/mshtml/htmlstorage.c b/dlls/mshtml/htmlstorage.c index 24eec4ba078..da97809177b 100644 --- a/dlls/mshtml/htmlstorage.c +++ b/dlls/mshtml/htmlstorage.c @@ -1308,6 +1308,8 @@ static HRESULT HTMLStorage_next_dispid(DispatchEx *dispex, DISPID id, DISPID *pi }
static const dispex_static_data_vtbl_t HTMLStorage_dispex_vtbl = { + NULL, + NULL, NULL, HTMLStorage_get_dispid, HTMLStorage_get_name, diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c index c8dc69bb2af..766a9306b05 100644 --- a/dlls/mshtml/htmlstyle.c +++ b/dlls/mshtml/htmlstyle.c @@ -9997,6 +9997,8 @@ void CSSStyle_init_dispex_info(dispex_data_t *info, compat_mode_t mode) }
const dispex_static_data_vtbl_t CSSStyle_dispex_vtbl = { + NULL, + NULL, NULL, CSSStyle_get_dispid, NULL, diff --git a/dlls/mshtml/htmlstylesheet.c b/dlls/mshtml/htmlstylesheet.c index 59680d720e2..73d94d1f2c0 100644 --- a/dlls/mshtml/htmlstylesheet.c +++ b/dlls/mshtml/htmlstylesheet.c @@ -466,6 +466,8 @@ static HRESULT HTMLStyleSheetRulesCollection_invoke(DispatchEx *dispex, DISPID i }
static const dispex_static_data_vtbl_t HTMLStyleSheetRulesCollection_dispex_vtbl = { + NULL, + NULL, NULL, HTMLStyleSheetRulesCollection_get_dispid, HTMLStyleSheetRulesCollection_get_name, @@ -893,6 +895,8 @@ static HRESULT HTMLStyleSheetsCollection_invoke(DispatchEx *dispex, DISPID id, L }
static const dispex_static_data_vtbl_t HTMLStyleSheetsCollection_dispex_vtbl = { + NULL, + NULL, NULL, HTMLStyleSheetsCollection_get_dispid, HTMLStyleSheetsCollection_get_name, diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index 5abe13c96e6..f603a33016c 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -4028,6 +4028,8 @@ static IHTMLEventObj *HTMLWindow_set_current_event(DispatchEx *dispex, IHTMLEven
static const event_target_vtbl_t HTMLWindow_event_target_vtbl = { { + NULL, + NULL, NULL, NULL, HTMLWindow_get_name, diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index c0274bd8aac..ff6294749cd 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -347,6 +347,10 @@ typedef struct DispatchEx DispatchEx; - dynamic props: These props are generally allocated by external code (e.g. 'document.wine = 42' creates 'wine' dynamic prop on document) */ typedef struct { + /* Unlike delete_cycle_collectable, unlink is called before the destructor (if available). */ + void (*destructor)(DispatchEx*); + void (*unlink)(DispatchEx*); + /* Called when the object wants to handle DISPID_VALUE invocations */ HRESULT (*value)(DispatchEx*,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
diff --git a/dlls/mshtml/xmlhttprequest.c b/dlls/mshtml/xmlhttprequest.c index 17f29396b8f..4803b5c55a1 100644 --- a/dlls/mshtml/xmlhttprequest.c +++ b/dlls/mshtml/xmlhttprequest.c @@ -1790,6 +1790,8 @@ static HRESULT HTMLXMLHttpRequestFactory_value(DispatchEx *iface, LCID lcid, WOR }
static const dispex_static_data_vtbl_t HTMLXMLHttpRequestFactory_dispex_vtbl = { + NULL, + NULL, HTMLXMLHttpRequestFactory_value };
From: Gabriel Ivăncescu gabrielopcode@gmail.com
And get rid of the destroy method. This especially simplifies it when traversal and unlinking is implemented.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmlevent.c | 165 +++++++++++++++++++++++++++------------- dlls/mshtml/htmlevent.h | 1 - 2 files changed, 112 insertions(+), 54 deletions(-)
diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c index ccea4e16567..ea1b11fbd38 100644 --- a/dlls/mshtml/htmlevent.c +++ b/dlls/mshtml/htmlevent.c @@ -965,16 +965,8 @@ static ULONG WINAPI DOMEvent_Release(IDOMEvent *iface)
TRACE("(%p) ref=%lu\n", This, ref);
- if(!ref) { - if(This->destroy) - This->destroy(This); - if(This->target) - IEventTarget_Release(&This->target->IEventTarget_iface); - nsIDOMEvent_Release(This->nsevent); + if(!ref) release_dispex(&This->dispex); - free(This->type); - free(This); - }
return ref; } @@ -1234,6 +1226,29 @@ static const IDOMEventVtbl DOMEventVtbl = { DOMEvent_get_srcElement };
+static inline DOMEvent *DOMEvent_from_DispatchEx(DispatchEx *iface) +{ + return CONTAINING_RECORD(iface, DOMEvent, dispex); +} + +static void DOMEvent_unlink(DispatchEx *dispex) +{ + DOMEvent *This = DOMEvent_from_DispatchEx(dispex); + if(This->target) { + EventTarget *target = This->target; + This->target = NULL; + IEventTarget_Release(&target->IEventTarget_iface); + } + unlink_ref(&This->nsevent); +} + +static void DOMEvent_destructor(DispatchEx *dispex) +{ + DOMEvent *This = DOMEvent_from_DispatchEx(dispex); + free(This->type); + free(This); +} + static inline DOMUIEvent *impl_from_IDOMUIEvent(IDOMUIEvent *iface) { return CONTAINING_RECORD(iface, DOMUIEvent, IDOMUIEvent_iface); @@ -1382,10 +1397,11 @@ static void *DOMUIEvent_query_interface(DOMEvent *event, REFIID riid) return NULL; }
-static void DOMUIEvent_destroy(DOMEvent *event) +static void DOMUIEvent_unlink(DispatchEx *dispex) { - DOMUIEvent *This = DOMUIEvent_from_DOMEvent(event); - nsIDOMUIEvent_Release(This->nsevent); + DOMUIEvent *This = DOMUIEvent_from_DOMEvent(DOMEvent_from_DispatchEx(dispex)); + DOMEvent_unlink(&This->event.dispex); + unlink_ref(&This->nsevent); }
typedef struct { @@ -1913,11 +1929,11 @@ static void *DOMMouseEvent_query_interface(DOMEvent *event, REFIID riid) return NULL; }
-static void DOMMouseEvent_destroy(DOMEvent *event) +static void DOMMouseEvent_unlink(DispatchEx *dispex) { - DOMMouseEvent *This = DOMMouseEvent_from_DOMEvent(event); - DOMUIEvent_destroy(&This->ui_event.event); - nsIDOMMouseEvent_Release(This->nsevent); + DOMMouseEvent *This = DOMMouseEvent_from_DOMEvent(DOMEvent_from_DispatchEx(dispex)); + DOMUIEvent_unlink(&This->ui_event.event.dispex); + unlink_ref(&This->nsevent); }
typedef struct { @@ -2212,11 +2228,11 @@ static void *DOMKeyboardEvent_query_interface(DOMEvent *event, REFIID riid) return NULL; }
-static void DOMKeyboardEvent_destroy(DOMEvent *event) +static void DOMKeyboardEvent_unlink(DispatchEx *dispex) { - DOMKeyboardEvent *This = DOMKeyboardEvent_from_DOMEvent(event); - DOMUIEvent_destroy(&This->ui_event.event); - nsIDOMKeyEvent_Release(This->nsevent); + DOMKeyboardEvent *This = DOMKeyboardEvent_from_DOMEvent(DOMEvent_from_DispatchEx(dispex)); + DOMUIEvent_unlink(&This->ui_event.event.dispex); + unlink_ref(&This->nsevent); }
typedef struct { @@ -2420,9 +2436,10 @@ static void *DOMCustomEvent_query_interface(DOMEvent *event, REFIID riid) return NULL; }
-static void DOMCustomEvent_destroy(DOMEvent *event) +static void DOMCustomEvent_unlink(DispatchEx *dispex) { - DOMCustomEvent *custom_event = DOMCustomEvent_from_DOMEvent(event); + DOMCustomEvent *custom_event = DOMCustomEvent_from_DOMEvent(DOMEvent_from_DispatchEx(dispex)); + DOMEvent_unlink(&custom_event->event.dispex); VariantClear(&custom_event->detail); }
@@ -2564,9 +2581,10 @@ static void *DOMMessageEvent_query_interface(DOMEvent *event, REFIID riid) return NULL; }
-static void DOMMessageEvent_destroy(DOMEvent *event) +static void DOMMessageEvent_unlink(DispatchEx *dispex) { - DOMMessageEvent *message_event = DOMMessageEvent_from_DOMEvent(event); + DOMMessageEvent *message_event = DOMMessageEvent_from_DOMEvent(DOMEvent_from_DispatchEx(dispex)); + DOMEvent_unlink(&message_event->event.dispex); VariantClear(&message_event->data); }
@@ -2737,10 +2755,11 @@ static void *DOMProgressEvent_query_interface(DOMEvent *event, REFIID riid) return NULL; }
-static void DOMProgressEvent_destroy(DOMEvent *event) +static void DOMProgressEvent_unlink(DispatchEx *dispex) { - DOMProgressEvent *This = DOMProgressEvent_from_DOMEvent(event); - nsIDOMProgressEvent_Release(This->nsevent); + DOMProgressEvent *This = DOMProgressEvent_from_DOMEvent(DOMEvent_from_DispatchEx(dispex)); + DOMEvent_unlink(&This->event.dispex); + unlink_ref(&This->nsevent); }
typedef struct { @@ -2899,15 +2918,21 @@ static void *DOMStorageEvent_query_interface(DOMEvent *event, REFIID riid) return NULL; }
-static void DOMStorageEvent_destroy(DOMEvent *event) +static void DOMStorageEvent_destructor(DispatchEx *dispex) { - DOMStorageEvent *storage_event = DOMStorageEvent_from_DOMEvent(event); + DOMStorageEvent *storage_event = DOMStorageEvent_from_DOMEvent(DOMEvent_from_DispatchEx(dispex)); SysFreeString(storage_event->key); SysFreeString(storage_event->old_value); SysFreeString(storage_event->new_value); SysFreeString(storage_event->url); + DOMEvent_destructor(dispex); }
+static const dispex_static_data_vtbl_t DOMEvent_dispex_vtbl = { + DOMEvent_destructor, + DOMEvent_unlink +}; + static const tid_t DOMEvent_iface_tids[] = { IDOMEvent_tid, 0 @@ -2915,11 +2940,16 @@ static const tid_t DOMEvent_iface_tids[] = {
static dispex_static_data_t DOMEvent_dispex = { L"Event", - NULL, + &DOMEvent_dispex_vtbl, DispDOMEvent_tid, DOMEvent_iface_tids };
+static const dispex_static_data_vtbl_t DOMUIEvent_dispex_vtbl = { + DOMEvent_destructor, + DOMUIEvent_unlink +}; + static const tid_t DOMUIEvent_iface_tids[] = { IDOMEvent_tid, IDOMUIEvent_tid, @@ -2928,11 +2958,16 @@ static const tid_t DOMUIEvent_iface_tids[] = {
static dispex_static_data_t DOMUIEvent_dispex = { L"UIEvent", - NULL, + &DOMUIEvent_dispex_vtbl, DispDOMUIEvent_tid, DOMUIEvent_iface_tids };
+static const dispex_static_data_vtbl_t DOMMouseEvent_dispex_vtbl = { + DOMEvent_destructor, + DOMMouseEvent_unlink +}; + static const tid_t DOMMouseEvent_iface_tids[] = { IDOMEvent_tid, IDOMUIEvent_tid, @@ -2942,11 +2977,16 @@ static const tid_t DOMMouseEvent_iface_tids[] = {
static dispex_static_data_t DOMMouseEvent_dispex = { L"MouseEvent", - NULL, + &DOMMouseEvent_dispex_vtbl, DispDOMMouseEvent_tid, DOMMouseEvent_iface_tids };
+static const dispex_static_data_vtbl_t DOMKeyboardEvent_dispex_vtbl = { + DOMEvent_destructor, + DOMKeyboardEvent_unlink +}; + static const tid_t DOMKeyboardEvent_iface_tids[] = { IDOMEvent_tid, IDOMUIEvent_tid, @@ -2956,7 +2996,7 @@ static const tid_t DOMKeyboardEvent_iface_tids[] = {
static dispex_static_data_t DOMKeyboardEvent_dispex = { L"KeyboardEvent", - NULL, + &DOMKeyboardEvent_dispex_vtbl, DispDOMKeyboardEvent_tid, DOMKeyboardEvent_iface_tids }; @@ -2967,14 +3007,19 @@ static void DOMPageTransitionEvent_init_dispex_info(dispex_data_t *info, compat_ dispex_info_add_interface(info, IWinePageTransitionEvent_tid, NULL); }
-dispex_static_data_t DOMPageTransitionEvent_dispex = { +static dispex_static_data_t DOMPageTransitionEvent_dispex = { L"PageTransitionEvent", - NULL, + &DOMEvent_dispex_vtbl, DispDOMEvent_tid, DOMEvent_iface_tids, DOMPageTransitionEvent_init_dispex_info };
+static const dispex_static_data_vtbl_t DOMCustomEvent_dispex_vtbl = { + DOMEvent_destructor, + DOMCustomEvent_unlink +}; + static const tid_t DOMCustomEvent_iface_tids[] = { IDOMEvent_tid, IDOMCustomEvent_tid, @@ -2983,52 +3028,67 @@ static const tid_t DOMCustomEvent_iface_tids[] = {
static dispex_static_data_t DOMCustomEvent_dispex = { L"CustomEvent", - NULL, + &DOMCustomEvent_dispex_vtbl, DispDOMCustomEvent_tid, DOMCustomEvent_iface_tids };
+static const dispex_static_data_vtbl_t DOMMessageEvent_dispex_vtbl = { + DOMEvent_destructor, + DOMMessageEvent_unlink +}; + static const tid_t DOMMessageEvent_iface_tids[] = { IDOMEvent_tid, 0 };
-dispex_static_data_t DOMMessageEvent_dispex = { +static dispex_static_data_t DOMMessageEvent_dispex = { L"MessageEvent", - NULL, + &DOMMessageEvent_dispex_vtbl, DispDOMMessageEvent_tid, DOMMessageEvent_iface_tids, DOMMessageEvent_init_dispex_info };
+static const dispex_static_data_vtbl_t DOMProgressEvent_dispex_vtbl = { + DOMEvent_destructor, + DOMProgressEvent_unlink +}; + static const tid_t DOMProgressEvent_iface_tids[] = { IDOMEvent_tid, IDOMProgressEvent_tid, 0 };
-dispex_static_data_t DOMProgressEvent_dispex = { +static dispex_static_data_t DOMProgressEvent_dispex = { L"ProgressEvent", - NULL, + &DOMProgressEvent_dispex_vtbl, DispDOMProgressEvent_tid, DOMProgressEvent_iface_tids };
+static const dispex_static_data_vtbl_t DOMStorageEvent_dispex_vtbl = { + DOMStorageEvent_destructor, + DOMEvent_unlink +}; + static const tid_t DOMStorageEvent_iface_tids[] = { IDOMEvent_tid, IDOMStorageEvent_tid, 0 };
-dispex_static_data_t DOMStorageEvent_dispex = { +static dispex_static_data_t DOMStorageEvent_dispex = { L"StorageEvent", - NULL, + &DOMStorageEvent_dispex_vtbl, DispDOMStorageEvent_tid, DOMStorageEvent_iface_tids };
static void *event_ctor(unsigned size, dispex_static_data_t *dispex_data, void *(*query_interface)(DOMEvent*,REFIID), - void (*destroy)(DOMEvent*), nsIDOMEvent *nsevent, eventid_t event_id, compat_mode_t compat_mode) + nsIDOMEvent *nsevent, eventid_t event_id, compat_mode_t compat_mode) { DOMEvent *event = calloc(1, size);
@@ -3036,7 +3096,6 @@ static void *event_ctor(unsigned size, dispex_static_data_t *dispex_data, void * return NULL; event->IDOMEvent_iface.lpVtbl = &DOMEventVtbl; event->query_interface = query_interface; - event->destroy = destroy; event->ref = 1; event->event_id = event_id; if(event_id != EVENTID_LAST) { @@ -3064,13 +3123,13 @@ static void fill_parent_ui_event(nsIDOMEvent *nsevent, DOMUIEvent *ui_event)
static DOMEvent *generic_event_ctor(void *iface, nsIDOMEvent *nsevent, eventid_t event_id, compat_mode_t compat_mode) { - return event_ctor(sizeof(DOMEvent), &DOMEvent_dispex, NULL, NULL, nsevent, event_id, compat_mode); + return event_ctor(sizeof(DOMEvent), &DOMEvent_dispex, NULL, nsevent, event_id, compat_mode); }
static DOMEvent *ui_event_ctor(void *iface, nsIDOMEvent *nsevent, eventid_t event_id, compat_mode_t compat_mode) { DOMUIEvent *ui_event = event_ctor(sizeof(DOMUIEvent), &DOMUIEvent_dispex, - DOMUIEvent_query_interface, DOMUIEvent_destroy, nsevent, event_id, compat_mode); + DOMUIEvent_query_interface, nsevent, event_id, compat_mode); if(!ui_event) return NULL; ui_event->IDOMUIEvent_iface.lpVtbl = &DOMUIEventVtbl; ui_event->nsevent = iface; @@ -3080,7 +3139,7 @@ static DOMEvent *ui_event_ctor(void *iface, nsIDOMEvent *nsevent, eventid_t even static DOMEvent *mouse_event_ctor(void *iface, nsIDOMEvent *nsevent, eventid_t event_id, compat_mode_t compat_mode) { DOMMouseEvent *mouse_event = event_ctor(sizeof(DOMMouseEvent), &DOMMouseEvent_dispex, - DOMMouseEvent_query_interface, DOMMouseEvent_destroy, nsevent, event_id, compat_mode); + DOMMouseEvent_query_interface, nsevent, event_id, compat_mode); if(!mouse_event) return NULL; mouse_event->IDOMMouseEvent_iface.lpVtbl = &DOMMouseEventVtbl; mouse_event->nsevent = iface; @@ -3091,7 +3150,7 @@ static DOMEvent *mouse_event_ctor(void *iface, nsIDOMEvent *nsevent, eventid_t e static DOMEvent *keyboard_event_ctor(void *iface, nsIDOMEvent *nsevent, eventid_t event_id, compat_mode_t compat_mode) { DOMKeyboardEvent *keyboard_event = event_ctor(sizeof(DOMKeyboardEvent), &DOMKeyboardEvent_dispex, - DOMKeyboardEvent_query_interface, DOMKeyboardEvent_destroy, nsevent, event_id, compat_mode); + DOMKeyboardEvent_query_interface, nsevent, event_id, compat_mode); if(!keyboard_event) return NULL; keyboard_event->IDOMKeyboardEvent_iface.lpVtbl = &DOMKeyboardEventVtbl; keyboard_event->nsevent = iface; @@ -3102,7 +3161,7 @@ static DOMEvent *keyboard_event_ctor(void *iface, nsIDOMEvent *nsevent, eventid_ static DOMEvent *page_transition_event_ctor(void *iface, nsIDOMEvent *nsevent, eventid_t event_id, compat_mode_t compat_mode) { DOMPageTransitionEvent *page_transition_event = event_ctor(sizeof(DOMCustomEvent), &DOMPageTransitionEvent_dispex, - DOMPageTransitionEvent_query_interface, NULL, nsevent, event_id, compat_mode); + DOMPageTransitionEvent_query_interface, nsevent, event_id, compat_mode); if(!page_transition_event) return NULL; page_transition_event->IWinePageTransitionEvent_iface.lpVtbl = &DOMPageTransitionEventVtbl; return &page_transition_event->event; @@ -3111,7 +3170,7 @@ static DOMEvent *page_transition_event_ctor(void *iface, nsIDOMEvent *nsevent, e static DOMEvent *custom_event_ctor(void *iface, nsIDOMEvent *nsevent, eventid_t event_id, compat_mode_t compat_mode) { DOMCustomEvent *custom_event = event_ctor(sizeof(DOMCustomEvent), &DOMCustomEvent_dispex, - DOMCustomEvent_query_interface, DOMCustomEvent_destroy, nsevent, event_id, compat_mode); + DOMCustomEvent_query_interface, nsevent, event_id, compat_mode); if(!custom_event) return NULL; custom_event->IDOMCustomEvent_iface.lpVtbl = &DOMCustomEventVtbl; nsIDOMCustomEvent_Release(iface); @@ -3123,7 +3182,7 @@ static DOMEvent *progress_event_ctor(void *iface, nsIDOMEvent *nsevent, eventid_ DOMProgressEvent *progress_event;
if(!(progress_event = event_ctor(sizeof(DOMProgressEvent), &DOMProgressEvent_dispex, - DOMProgressEvent_query_interface, DOMProgressEvent_destroy, nsevent, event_id, compat_mode))) + DOMProgressEvent_query_interface, nsevent, event_id, compat_mode))) return NULL; progress_event->IDOMProgressEvent_iface.lpVtbl = &DOMProgressEventVtbl; progress_event->nsevent = iface; @@ -3133,7 +3192,7 @@ static DOMEvent *progress_event_ctor(void *iface, nsIDOMEvent *nsevent, eventid_ static DOMEvent *message_event_ctor(void *iface, nsIDOMEvent *nsevent, eventid_t event_id, compat_mode_t compat_mode) { DOMMessageEvent *message_event = event_ctor(sizeof(DOMMessageEvent), &DOMMessageEvent_dispex, - DOMMessageEvent_query_interface, DOMMessageEvent_destroy, nsevent, event_id, compat_mode); + DOMMessageEvent_query_interface, nsevent, event_id, compat_mode); if(!message_event) return NULL; message_event->IDOMMessageEvent_iface.lpVtbl = &DOMMessageEventVtbl; return &message_event->event; @@ -3142,7 +3201,7 @@ static DOMEvent *message_event_ctor(void *iface, nsIDOMEvent *nsevent, eventid_t static DOMEvent *storage_event_ctor(void *iface, nsIDOMEvent *nsevent, eventid_t event_id, compat_mode_t compat_mode) { DOMStorageEvent *storage_event = event_ctor(sizeof(DOMStorageEvent), &DOMStorageEvent_dispex, - DOMStorageEvent_query_interface, DOMStorageEvent_destroy, nsevent, event_id, compat_mode); + DOMStorageEvent_query_interface, nsevent, event_id, compat_mode); if(!storage_event) return NULL; storage_event->IDOMStorageEvent_iface.lpVtbl = &DOMStorageEventVtbl; return &storage_event->event; diff --git a/dlls/mshtml/htmlevent.h b/dlls/mshtml/htmlevent.h index 5e2c7a0a054..f6c7cbc381b 100644 --- a/dlls/mshtml/htmlevent.h +++ b/dlls/mshtml/htmlevent.h @@ -78,7 +78,6 @@ typedef struct DOMEvent {
LONG ref; void *(*query_interface)(struct DOMEvent*,REFIID); - void (*destroy)(struct DOMEvent*);
nsIDOMEvent *nsevent;
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmlevent.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)
diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c index ea1b11fbd38..2c518464246 100644 --- a/dlls/mshtml/htmlevent.c +++ b/dlls/mshtml/htmlevent.c @@ -385,12 +385,8 @@ static ULONG WINAPI HTMLEventObj_Release(IHTMLEventObj *iface)
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) { - if(This->event) - IDOMEvent_Release(&This->event->IDOMEvent_iface); + if(!ref) release_dispex(&This->dispex); - free(This); - }
return ref; } @@ -872,6 +868,32 @@ static inline HTMLEventObj *unsafe_impl_from_IHTMLEventObj(IHTMLEventObj *iface) return iface->lpVtbl == &HTMLEventObjVtbl ? impl_from_IHTMLEventObj(iface) : NULL; }
+static inline HTMLEventObj *HTMLEventObj_from_DispatchEx(DispatchEx *iface) +{ + return CONTAINING_RECORD(iface, HTMLEventObj, dispex); +} + +static void HTMLEventObj_unlink(DispatchEx *dispex) +{ + HTMLEventObj *This = HTMLEventObj_from_DispatchEx(dispex); + if(This->event) { + DOMEvent *event = This->event; + This->event = NULL; + IDOMEvent_Release(&event->IDOMEvent_iface); + } +} + +static void HTMLEventObj_destructor(DispatchEx *dispex) +{ + HTMLEventObj *This = HTMLEventObj_from_DispatchEx(dispex); + free(This); +} + +static const dispex_static_data_vtbl_t HTMLEventObj_dispex_vtbl = { + HTMLEventObj_destructor, + HTMLEventObj_unlink +}; + static const tid_t HTMLEventObj_iface_tids[] = { IHTMLEventObj_tid, 0 @@ -879,7 +901,7 @@ static const tid_t HTMLEventObj_iface_tids[] = {
static dispex_static_data_t HTMLEventObj_dispex = { L"MSEventObj", - NULL, + &HTMLEventObj_dispex_vtbl, DispCEventObj_tid, HTMLEventObj_iface_tids };
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmlwindow.c | 148 +++++++++++++++++++++------------------ 1 file changed, 79 insertions(+), 69 deletions(-)
diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index f603a33016c..9ebea7f8b57 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -249,72 +249,6 @@ static void release_outer_window(HTMLOuterWindow *This) free(This); }
-static void release_inner_window(HTMLInnerWindow *This) -{ - unsigned i; - - TRACE("%p\n", This); - - detach_inner_window(This); - - if(This->doc) { - This->doc->window = NULL; - IHTMLDOMNode_Release(&This->doc->node.IHTMLDOMNode_iface); - } - - release_event_target(&This->event_target); - release_dispex(&This->event_target.dispex); - - for(i=0; i < This->global_prop_cnt; i++) - free(This->global_props[i].name); - free(This->global_props); - - if(This->image_factory) { - This->image_factory->window = NULL; - IHTMLImageElementFactory_Release(&This->image_factory->IHTMLImageElementFactory_iface); - } - - if(This->option_factory) { - This->option_factory->window = NULL; - IHTMLOptionElementFactory_Release(&This->option_factory->IHTMLOptionElementFactory_iface); - } - - if(This->xhr_factory) { - This->xhr_factory->window = NULL; - IHTMLXMLHttpRequestFactory_Release(&This->xhr_factory->IHTMLXMLHttpRequestFactory_iface); - } - - if(This->screen) - IHTMLScreen_Release(This->screen); - - if(This->history) { - This->history->window = NULL; - IOmHistory_Release(&This->history->IOmHistory_iface); - } - - if(This->navigator) - IOmNavigator_Release(This->navigator); - if(This->session_storage) { - detach_html_storage(This->session_storage); - IHTMLStorage_Release(This->session_storage); - } - if(This->local_storage) { - detach_html_storage(This->local_storage); - IHTMLStorage_Release(This->local_storage); - } - - IHTMLPerformanceTiming_Release(&This->performance_timing->IHTMLPerformanceTiming_iface); - VariantClear(&This->performance); - - if(This->mon) - IMoniker_Release(This->mon); - - if(This->mutation_observer_ctor) - IDispatch_Release(This->mutation_observer_ctor); - - free(This); -} - static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface) { HTMLWindow *This = impl_from_IHTMLWindow2(iface); @@ -329,7 +263,7 @@ static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface) if(is_outer_window(This)) release_outer_window(This->outer_window); else - release_inner_window(This->inner_window); + release_dispex(&This->inner_window->event_target.dispex); }
return ref; @@ -3785,6 +3719,82 @@ static inline HTMLInnerWindow *impl_from_DispatchEx(DispatchEx *iface) return CONTAINING_RECORD(iface, HTMLInnerWindow, event_target.dispex); }
+static void HTMLWindow_unlink(DispatchEx *dispex) +{ + HTMLInnerWindow *This = impl_from_DispatchEx(dispex); + + TRACE("%p\n", This); + + unlink_ref(&This->base.console); + detach_inner_window(This); + + if(This->doc) { + HTMLDocumentNode *doc = This->doc; + This->doc->window = NULL; + This->doc = NULL; + IHTMLDOMNode_Release(&doc->node.IHTMLDOMNode_iface); + } + + release_event_target(&This->event_target); + + if(This->image_factory) { + HTMLImageElementFactory *image_factory = This->image_factory; + This->image_factory->window = NULL; + This->image_factory = NULL; + IHTMLImageElementFactory_Release(&image_factory->IHTMLImageElementFactory_iface); + } + if(This->option_factory) { + HTMLOptionElementFactory *option_factory = This->option_factory; + This->option_factory->window = NULL; + This->option_factory = NULL; + IHTMLOptionElementFactory_Release(&option_factory->IHTMLOptionElementFactory_iface); + } + if(This->xhr_factory) { + HTMLXMLHttpRequestFactory *xhr_factory = This->xhr_factory; + This->xhr_factory->window = NULL; + This->xhr_factory = NULL; + IHTMLXMLHttpRequestFactory_Release(&xhr_factory->IHTMLXMLHttpRequestFactory_iface); + } + unlink_ref(&This->mutation_observer_ctor); + unlink_ref(&This->screen); + if(This->history) { + OmHistory *history = This->history; + This->history->window = NULL; + This->history = NULL; + IOmHistory_Release(&history->IOmHistory_iface); + } + unlink_ref(&This->navigator); + if(This->session_storage) { + IHTMLStorage *session_storage = This->session_storage; + detach_html_storage(session_storage); + This->session_storage = NULL; + IHTMLStorage_Release(session_storage); + } + if(This->local_storage) { + IHTMLStorage *local_storage = This->local_storage; + detach_html_storage(local_storage); + This->local_storage = NULL; + IHTMLStorage_Release(local_storage); + } + IHTMLPerformanceTiming_Release(&This->performance_timing->IHTMLPerformanceTiming_iface); + VariantClear(&This->performance); +} + +static void HTMLWindow_destructor(DispatchEx *dispex) +{ + HTMLInnerWindow *This = impl_from_DispatchEx(dispex); + unsigned i; + + for(i = 0; i < This->global_prop_cnt; i++) + free(This->global_props[i].name); + free(This->global_props); + + if(This->mon) + IMoniker_Release(This->mon); + + free(This); +} + static HRESULT HTMLWindow_get_name(DispatchEx *dispex, DISPID id, BSTR *name) { HTMLInnerWindow *This = impl_from_DispatchEx(dispex); @@ -4028,8 +4038,8 @@ static IHTMLEventObj *HTMLWindow_set_current_event(DispatchEx *dispex, IHTMLEven
static const event_target_vtbl_t HTMLWindow_event_target_vtbl = { { - NULL, - NULL, + HTMLWindow_destructor, + HTMLWindow_unlink, NULL, NULL, HTMLWindow_get_name,
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmlstyle.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c index 766a9306b05..b696a155fc2 100644 --- a/dlls/mshtml/htmlstyle.c +++ b/dlls/mshtml/htmlstyle.c @@ -4772,12 +4772,8 @@ static ULONG WINAPI HTMLCSSStyleDeclaration_Release(IHTMLCSSStyleDeclaration *if
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) { - if(This->nsstyle) - nsIDOMCSSStyleDeclaration_Release(This->nsstyle); + if(!ref) release_dispex(&This->dispex); - free(This); - }
return ref; } @@ -9969,6 +9965,18 @@ static inline CSSStyle *impl_from_DispatchEx(DispatchEx *dispex) return CONTAINING_RECORD(dispex, CSSStyle, dispex); }
+static void CSSStyle_unlink(DispatchEx *dispex) +{ + CSSStyle *This = impl_from_DispatchEx(dispex); + unlink_ref(&This->nsstyle); +} + +static void CSSStyle_destructor(DispatchEx *dispex) +{ + CSSStyle *This = impl_from_DispatchEx(dispex); + free(This); +} + static HRESULT CSSStyle_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid) { CSSStyle *This = impl_from_DispatchEx(dispex); @@ -9997,8 +10005,8 @@ void CSSStyle_init_dispex_info(dispex_data_t *info, compat_mode_t mode) }
const dispex_static_data_vtbl_t CSSStyle_dispex_vtbl = { - NULL, - NULL, + CSSStyle_destructor, + CSSStyle_unlink, NULL, CSSStyle_get_dispid, NULL,
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- 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 };
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmlstylesheet.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/dlls/mshtml/htmlstylesheet.c b/dlls/mshtml/htmlstylesheet.c index 79c59bf3058..336f4d41edf 100644 --- a/dlls/mshtml/htmlstylesheet.c +++ b/dlls/mshtml/htmlstylesheet.c @@ -308,12 +308,8 @@ static ULONG WINAPI HTMLStyleSheetRulesCollection_Release(IHTMLStyleSheetRulesCo
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) { + if(!ref) release_dispex(&This->dispex); - if(This->nslist) - nsIDOMCSSRuleList_Release(This->nslist); - free(This); - }
return ref; } @@ -407,6 +403,18 @@ static inline HTMLStyleSheetRulesCollection *HTMLStyleSheetRulesCollection_from_ return CONTAINING_RECORD(iface, HTMLStyleSheetRulesCollection, dispex); }
+static void HTMLStyleSheetRulesCollection_unlink(DispatchEx *dispex) +{ + HTMLStyleSheetRulesCollection *This = HTMLStyleSheetRulesCollection_from_DispatchEx(dispex); + unlink_ref(&This->nslist); +} + +static void HTMLStyleSheetRulesCollection_destructor(DispatchEx *dispex) +{ + HTMLStyleSheetRulesCollection *This = HTMLStyleSheetRulesCollection_from_DispatchEx(dispex); + free(This); +} + static HRESULT HTMLStyleSheetRulesCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid) { HTMLStyleSheetRulesCollection *This = HTMLStyleSheetRulesCollection_from_DispatchEx(dispex); @@ -484,8 +492,8 @@ static HRESULT HTMLStyleSheetRulesCollection_invoke(DispatchEx *dispex, DISPID i }
static const dispex_static_data_vtbl_t HTMLStyleSheetRulesCollection_dispex_vtbl = { - NULL, - NULL, + HTMLStyleSheetRulesCollection_destructor, + HTMLStyleSheetRulesCollection_unlink, NULL, HTMLStyleSheetRulesCollection_get_dispid, HTMLStyleSheetRulesCollection_get_name,
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmlstylesheet.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/dlls/mshtml/htmlstylesheet.c b/dlls/mshtml/htmlstylesheet.c index 336f4d41edf..02c46195314 100644 --- a/dlls/mshtml/htmlstylesheet.c +++ b/dlls/mshtml/htmlstylesheet.c @@ -703,12 +703,8 @@ static ULONG WINAPI HTMLStyleSheetsCollection_Release(IHTMLStyleSheetsCollection
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) { + if(!ref) release_dispex(&This->dispex); - if(This->nslist) - nsIDOMStyleSheetList_Release(This->nslist); - free(This); - }
return ref; } @@ -844,6 +840,18 @@ static inline HTMLStyleSheetsCollection *HTMLStyleSheetsCollection_from_Dispatch return CONTAINING_RECORD(iface, HTMLStyleSheetsCollection, dispex); }
+static void HTMLStyleSheetsCollection_unlink(DispatchEx *dispex) +{ + HTMLStyleSheetsCollection *This = HTMLStyleSheetsCollection_from_DispatchEx(dispex); + unlink_ref(&This->nslist); +} + +static void HTMLStyleSheetsCollection_destructor(DispatchEx *dispex) +{ + HTMLStyleSheetsCollection *This = HTMLStyleSheetsCollection_from_DispatchEx(dispex); + free(This); +} + static HRESULT HTMLStyleSheetsCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid) { HTMLStyleSheetsCollection *This = HTMLStyleSheetsCollection_from_DispatchEx(dispex); @@ -921,8 +929,8 @@ static HRESULT HTMLStyleSheetsCollection_invoke(DispatchEx *dispex, DISPID id, L }
static const dispex_static_data_vtbl_t HTMLStyleSheetsCollection_dispex_vtbl = { - NULL, - NULL, + HTMLStyleSheetsCollection_destructor, + HTMLStyleSheetsCollection_unlink, NULL, HTMLStyleSheetsCollection_get_dispid, HTMLStyleSheetsCollection_get_name,
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- 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 02c46195314..010f3ef3f8c 100644 --- a/dlls/mshtml/htmlstylesheet.c +++ b/dlls/mshtml/htmlstylesheet.c @@ -1017,12 +1017,8 @@ static ULONG WINAPI HTMLStyleSheet_Release(IHTMLStyleSheet *iface)
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) { + if(!ref) release_dispex(&This->dispex); - if(This->nsstylesheet) - nsIDOMCSSStyleSheet_Release(This->nsstylesheet); - free(This); - }
return ref; } @@ -1500,19 +1496,41 @@ static const IHTMLStyleSheet4Vtbl HTMLStyleSheet4Vtbl = { HTMLStyleSheet4_deleteRule, };
+static inline HTMLStyleSheet *HTMLStyleSheet_from_DispatchEx(DispatchEx *iface) +{ + return CONTAINING_RECORD(iface, HTMLStyleSheet, dispex); +} + +static void HTMLStyleSheet_unlink(DispatchEx *dispex) +{ + HTMLStyleSheet *This = HTMLStyleSheet_from_DispatchEx(dispex); + unlink_ref(&This->nsstylesheet); +} + +static void HTMLStyleSheet_destructor(DispatchEx *dispex) +{ + HTMLStyleSheet *This = HTMLStyleSheet_from_DispatchEx(dispex); + free(This); +} + static void HTMLStyleSheet_init_dispex_info(dispex_data_t *info, compat_mode_t mode) { if(mode >= COMPAT_MODE_IE9) dispex_info_add_interface(info, IHTMLStyleSheet4_tid, NULL); }
+static const dispex_static_data_vtbl_t HTMLStyleSheet_dispex_vtbl = { + HTMLStyleSheet_destructor, + HTMLStyleSheet_unlink +}; + static const tid_t HTMLStyleSheet_iface_tids[] = { IHTMLStyleSheet_tid, 0 }; static dispex_static_data_t HTMLStyleSheet_dispex = { L"CSSStyleSheet", - NULL, + &HTMLStyleSheet_dispex_vtbl, DispHTMLStyleSheet_tid, HTMLStyleSheet_iface_tids, HTMLStyleSheet_init_dispex_info
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmlimg.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/dlls/mshtml/htmlimg.c b/dlls/mshtml/htmlimg.c index e0ade235c01..cc091429500 100644 --- a/dlls/mshtml/htmlimg.c +++ b/dlls/mshtml/htmlimg.c @@ -808,10 +808,8 @@ static ULONG WINAPI HTMLImageElementFactory_Release(IHTMLImageElementFactory *if
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) { + if(!ref) release_dispex(&This->dispex); - free(This); - }
return ref; } @@ -941,6 +939,12 @@ static inline HTMLImageElementFactory *impl_from_DispatchEx(DispatchEx *iface) return CONTAINING_RECORD(iface, HTMLImageElementFactory, dispex); }
+static void HTMLImageElementFactory_destructor(DispatchEx *dispex) +{ + HTMLImageElementFactory *This = impl_from_DispatchEx(dispex); + free(This); +} + static HRESULT HTMLImageElementFactory_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) @@ -975,7 +979,7 @@ static const tid_t HTMLImageElementFactory_iface_tids[] = { };
static const dispex_static_data_vtbl_t HTMLImageElementFactory_dispex_vtbl = { - NULL, + HTMLImageElementFactory_destructor, NULL, HTMLImageElementFactory_value, NULL,
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmlselect.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/dlls/mshtml/htmlselect.c b/dlls/mshtml/htmlselect.c index cbbd9ebcc69..b48805de64d 100644 --- a/dlls/mshtml/htmlselect.c +++ b/dlls/mshtml/htmlselect.c @@ -487,10 +487,8 @@ static ULONG WINAPI HTMLOptionElementFactory_Release(IHTMLOptionElementFactory *
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) { + if(!ref) release_dispex(&This->dispex); - free(This); - }
return ref; } @@ -591,6 +589,12 @@ static inline HTMLOptionElementFactory *HTMLOptionElementFactory_from_DispatchEx return CONTAINING_RECORD(iface, HTMLOptionElementFactory, dispex); }
+static void HTMLOptionElementFactory_destructor(DispatchEx *dispex) +{ + HTMLOptionElementFactory *This = HTMLOptionElementFactory_from_DispatchEx(dispex); + free(This); +} + static HRESULT HTMLOptionElementFactory_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) @@ -629,7 +633,7 @@ static const tid_t HTMLOptionElementFactory_iface_tids[] = { };
static const dispex_static_data_vtbl_t HTMLOptionElementFactory_dispex_vtbl = { - NULL, + HTMLOptionElementFactory_destructor, NULL, HTMLOptionElementFactory_value, NULL,
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/xmlhttprequest.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/dlls/mshtml/xmlhttprequest.c b/dlls/mshtml/xmlhttprequest.c index 4803b5c55a1..73eea9d7f6d 100644 --- a/dlls/mshtml/xmlhttprequest.c +++ b/dlls/mshtml/xmlhttprequest.c @@ -1640,10 +1640,8 @@ static ULONG WINAPI HTMLXMLHttpRequestFactory_Release(IHTMLXMLHttpRequestFactory
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) { + if(!ref) release_dispex(&This->dispex); - free(This); - }
return ref; } @@ -1766,6 +1764,12 @@ static inline HTMLXMLHttpRequestFactory *factory_from_DispatchEx(DispatchEx *ifa return CONTAINING_RECORD(iface, HTMLXMLHttpRequestFactory, dispex); }
+static void HTMLXMLHttpRequestFactory_destructor(DispatchEx *dispex) +{ + HTMLXMLHttpRequestFactory *This = factory_from_DispatchEx(dispex); + free(This); +} + static HRESULT HTMLXMLHttpRequestFactory_value(DispatchEx *iface, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { @@ -1790,7 +1794,7 @@ static HRESULT HTMLXMLHttpRequestFactory_value(DispatchEx *iface, LCID lcid, WOR }
static const dispex_static_data_vtbl_t HTMLXMLHttpRequestFactory_dispex_vtbl = { - NULL, + HTMLXMLHttpRequestFactory_destructor, NULL, HTMLXMLHttpRequestFactory_value };
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/mutation.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/dlls/mshtml/mutation.c b/dlls/mshtml/mutation.c index e6d080cff16..3f544e0a90f 100644 --- a/dlls/mshtml/mutation.c +++ b/dlls/mshtml/mutation.c @@ -1303,10 +1303,8 @@ static ULONG WINAPI mutation_observer_ctor_Release(IUnknown *iface)
TRACE("(%p) ref=%ld\n", This, ref);
- if(!ref) { + if(!ref) release_dispex(&This->dispex); - free(This); - }
return ref; } @@ -1317,6 +1315,12 @@ static const IUnknownVtbl mutation_observer_ctor_vtbl = { mutation_observer_ctor_Release, };
+static void mutation_observer_ctor_destructor(DispatchEx *dispex) +{ + struct mutation_observer_ctor *This = mutation_observer_ctor_from_DispatchEx(dispex); + free(This); +} + static HRESULT mutation_observer_ctor_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) @@ -1365,7 +1369,9 @@ static HRESULT mutation_observer_ctor_value(DispatchEx *dispex, LCID lcid, }
static dispex_static_data_vtbl_t mutation_observer_ctor_dispex_vtbl = { - .value = mutation_observer_ctor_value + mutation_observer_ctor_destructor, + NULL, + mutation_observer_ctor_value };
static const tid_t mutation_observer_ctor_iface_tids[] = {
This merge request was approved by Jacek Caban.