From b962fff243906ba56295aeeacf66142f0388638b Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 9 Dec 2010 16:27:51 +0100 Subject: [PATCH] mshtml: Associate PluginHost with containing HTMLDocumentDode. --- dlls/mshtml/htmldoc.c | 3 +++ dlls/mshtml/mshtml_private.h | 1 + dlls/mshtml/npplugin.c | 2 +- dlls/mshtml/pluginhost.c | 17 ++++++++++++++++- dlls/mshtml/pluginhost.h | 6 +++++- 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index e9a0cd6b8b0..a4c1451f0bc 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -35,6 +35,7 @@ #include "mshtml_private.h" #include "htmlevent.h" +#include "pluginhost.h" WINE_DEFAULT_DEBUG_CHANNEL(mshtml); @@ -1897,6 +1898,7 @@ static void HTMLDocumentNode_destructor(HTMLDOMNode *iface) detach_selection(This); detach_ranges(This); + detach_plugin_hosts(This); release_nodes(This); if(This->nsdoc) { @@ -1982,6 +1984,7 @@ static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLWindow *wi list_init(&doc->bindings); list_init(&doc->selection_list); list_init(&doc->range_list); + list_init(&doc->plugin_hosts); return doc; } diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index c27a06875df..269962f1d02 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -618,6 +618,7 @@ struct HTMLDocumentNode { struct list bindings; struct list selection_list; struct list range_list; + struct list plugin_hosts; }; #define HTMLWINDOW2(x) ((IHTMLWindow2*) &(x)->lpHTMLWindow2Vtbl) diff --git a/dlls/mshtml/npplugin.c b/dlls/mshtml/npplugin.c index 60f2125144e..a1c1c47b73c 100644 --- a/dlls/mshtml/npplugin.c +++ b/dlls/mshtml/npplugin.c @@ -272,7 +272,7 @@ static NPError CDECL NPP_New(NPMIMEType pluginType, NPP instance, UINT16 mode, I PluginHost *host; HRESULT hres; - hres = create_plugin_host(obj, &host); + hres = create_plugin_host(window->doc, obj, &host); nsIDOMElement_Release(nselem); IUnknown_Release(obj); if(SUCCEEDED(hres)) diff --git a/dlls/mshtml/pluginhost.c b/dlls/mshtml/pluginhost.c index e7f39d81163..27404f601fb 100644 --- a/dlls/mshtml/pluginhost.c +++ b/dlls/mshtml/pluginhost.c @@ -160,6 +160,7 @@ static ULONG WINAPI PHClientSite_Release(IOleClientSite *iface) TRACE("(%p) ref=%d\n", This, ref); if(!ref) { + list_remove(&This->entry); if(This->plugin_unk) IUnknown_Release(This->plugin_unk); heap_free(This); @@ -731,7 +732,18 @@ static const IServiceProviderVtbl ServiceProviderVtbl = { PHServiceProvider_QueryService }; -HRESULT create_plugin_host(IUnknown *unk, PluginHost **ret) +void detach_plugin_hosts(HTMLDocumentNode *doc) +{ + PluginHost *iter; + + while(!list_empty(&doc->plugin_hosts)) { + iter = LIST_ENTRY(list_head(&doc->plugin_hosts), PluginHost, entry); + list_remove(&iter->entry); + iter->doc = NULL; + } +} + +HRESULT create_plugin_host(HTMLDocumentNode *doc, IUnknown *unk, PluginHost **ret) { PluginHost *host; @@ -753,6 +765,9 @@ HRESULT create_plugin_host(IUnknown *unk, PluginHost **ret) IUnknown_AddRef(unk); host->plugin_unk = unk; + host->doc = doc; + list_add_tail(&doc->plugin_hosts, &host->entry); + *ret = host; return S_OK; } diff --git a/dlls/mshtml/pluginhost.h b/dlls/mshtml/pluginhost.h index 2b666965404..ab61523e56d 100644 --- a/dlls/mshtml/pluginhost.h +++ b/dlls/mshtml/pluginhost.h @@ -32,7 +32,11 @@ typedef struct { IUnknown *plugin_unk; HWND hwnd; + + HTMLDocumentNode *doc; + struct list entry; } PluginHost; -HRESULT create_plugin_host(IUnknown*,PluginHost**); +HRESULT create_plugin_host(HTMLDocumentNode*,IUnknown*,PluginHost**); void update_plugin_window(PluginHost*,HWND,const RECT*); +void detach_plugin_hosts(HTMLDocumentNode*);