Jacek Caban : mshtml: Associate PluginHost with containing element.

Alexandre Julliard julliard at winehq.org
Thu Dec 9 12:26:32 CST 2010


Module: wine
Branch: master
Commit: 483fe27730f8b5c06e1718b25a3c27483622f398
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=483fe27730f8b5c06e1718b25a3c27483622f398

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Dec  9 16:28:34 2010 +0100

mshtml: Associate PluginHost with containing element.

---

 dlls/mshtml/htmlobject.c |    2 ++
 dlls/mshtml/npplugin.c   |    2 +-
 dlls/mshtml/pluginhost.c |   32 +++++++++++++++++++++++++++++++-
 dlls/mshtml/pluginhost.h |    4 +++-
 4 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/dlls/mshtml/htmlobject.c b/dlls/mshtml/htmlobject.c
index a2f5322..c911dd8 100644
--- a/dlls/mshtml/htmlobject.c
+++ b/dlls/mshtml/htmlobject.c
@@ -422,6 +422,8 @@ static void HTMLObjectElement_destructor(HTMLDOMNode *iface)
 {
     HTMLObjectElement *This = HTMLOBJECT_NODE_THIS(iface);
 
+    if(This->plugin_container.plugin_host)
+        This->plugin_container.plugin_host->element = NULL;
     if(This->nsobject)
         nsIDOMHTMLObjectElement_Release(This->nsobject);
 
diff --git a/dlls/mshtml/npplugin.c b/dlls/mshtml/npplugin.c
index a1c1c47..93e22da 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(window->doc, obj, &host);
+        hres = create_plugin_host(window->doc, nselem, obj, &host);
         nsIDOMElement_Release(nselem);
         IUnknown_Release(obj);
         if(SUCCEEDED(hres))
diff --git a/dlls/mshtml/pluginhost.c b/dlls/mshtml/pluginhost.c
index 2af929c..785abdd 100644
--- a/dlls/mshtml/pluginhost.c
+++ b/dlls/mshtml/pluginhost.c
@@ -164,6 +164,8 @@ static ULONG WINAPI PHClientSite_Release(IOleClientSite *iface)
 
     if(!ref) {
         list_remove(&This->entry);
+        if(This->element)
+            This->element->plugin_host = NULL;
         if(This->plugin_unk)
             IUnknown_Release(This->plugin_unk);
         heap_free(This);
@@ -735,6 +737,27 @@ static const IServiceProviderVtbl ServiceProviderVtbl = {
     PHServiceProvider_QueryService
 };
 
+static HRESULT assoc_element(PluginHost *host, HTMLDocumentNode *doc, nsIDOMElement *nselem)
+{
+    HTMLPluginContainer *container_elem;
+    HTMLDOMNode *node;
+    HRESULT hres;
+
+    hres = get_node(doc, (nsIDOMNode*)nselem, TRUE, &node);
+    if(FAILED(hres))
+        return hres;
+
+    hres = IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_HTMLPluginContainer, (void**)&container_elem);
+    if(FAILED(hres)) {
+        ERR("Not an object element\n");
+        return hres;
+    }
+
+    container_elem->plugin_host = host;
+    host->element = container_elem;
+    return S_OK;
+}
+
 void detach_plugin_hosts(HTMLDocumentNode *doc)
 {
     PluginHost *iter;
@@ -746,9 +769,10 @@ void detach_plugin_hosts(HTMLDocumentNode *doc)
     }
 }
 
-HRESULT create_plugin_host(HTMLDocumentNode *doc, IUnknown *unk, PluginHost **ret)
+HRESULT create_plugin_host(HTMLDocumentNode *doc, nsIDOMElement *nselem, IUnknown *unk, PluginHost **ret)
 {
     PluginHost *host;
+    HRESULT hres;
 
     host = heap_alloc_zero(sizeof(*host));
     if(!host)
@@ -765,6 +789,12 @@ HRESULT create_plugin_host(HTMLDocumentNode *doc, IUnknown *unk, PluginHost **re
 
     host->ref = 1;
 
+    hres = assoc_element(host, doc, nselem);
+    if(FAILED(hres)) {
+        heap_free(host);
+        return hres;
+    }
+
     IUnknown_AddRef(unk);
     host->plugin_unk = unk;
 
diff --git a/dlls/mshtml/pluginhost.h b/dlls/mshtml/pluginhost.h
index 1c80a9c..d030a3e 100644
--- a/dlls/mshtml/pluginhost.h
+++ b/dlls/mshtml/pluginhost.h
@@ -35,6 +35,8 @@ typedef struct {
 
     HTMLDocumentNode *doc;
     struct list entry;
+
+    HTMLPluginContainer *element;
 } PluginHost;
 
 struct HTMLPluginContainer {
@@ -45,6 +47,6 @@ struct HTMLPluginContainer {
 
 extern const IID IID_HTMLPluginContainer;
 
-HRESULT create_plugin_host(HTMLDocumentNode*,IUnknown*,PluginHost**);
+HRESULT create_plugin_host(HTMLDocumentNode*,nsIDOMElement*,IUnknown*,PluginHost**);
 void update_plugin_window(PluginHost*,HWND,const RECT*);
 void detach_plugin_hosts(HTMLDocumentNode*);




More information about the wine-cvs mailing list