mshtml: Introduce unlink_ref helper.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
This commit is contained in:
Gabriel Ivăncescu 2023-08-01 19:45:24 +03:00 committed by Alexandre Julliard
parent 7b30e3d34e
commit 3c92edfdf2
26 changed files with 70 additions and 312 deletions

View file

@ -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 = {

View file

@ -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 = {

View file

@ -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)

View file

@ -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;

View file

@ -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 = {

View file

@ -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 = {

View file

@ -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 = {

View file

@ -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 = {

View file

@ -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,

View file

@ -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;

View file

@ -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 = {

View file

@ -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 = {

View file

@ -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 = {

View file

@ -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)

View file

@ -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[] = {

View file

@ -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 = {

View file

@ -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

View file

@ -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)

View file

@ -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);

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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;
}

View file

@ -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);

View file

@ -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;