Jacek Caban : mshtml: Pass HTMLPluginContainer to create_plugin_host.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Dec 11 15:22:15 CST 2014


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Dec 11 16:25:49 2014 +0100

mshtml: Pass HTMLPluginContainer to create_plugin_host.

---

 dlls/mshtml/npplugin.c   | 27 ++++++++++++++++++++-------
 dlls/mshtml/pluginhost.c | 37 +++++--------------------------------
 dlls/mshtml/pluginhost.h |  2 +-
 3 files changed, 26 insertions(+), 40 deletions(-)

diff --git a/dlls/mshtml/npplugin.c b/dlls/mshtml/npplugin.c
index ca0d9fd..7c31a24 100644
--- a/dlls/mshtml/npplugin.c
+++ b/dlls/mshtml/npplugin.c
@@ -639,11 +639,14 @@ static IUnknown *create_activex_object(HTMLInnerWindow *window, nsIDOMHTMLElemen
 static NPError CDECL NPP_New(NPMIMEType pluginType, NPP instance, UINT16 mode, INT16 argc, char **argn,
         char **argv, NPSavedData *saved)
 {
+    HTMLPluginContainer *container;
     nsIDOMHTMLElement *nselem;
     HTMLInnerWindow *window;
+    HTMLDOMNode *node;
     IUnknown *obj;
     CLSID clsid;
     NPError err = NPERR_NO_ERROR;
+    HRESULT hres;
 
     TRACE("(%s %p %x %d %p %p %p)\n", debugstr_a(pluginType), instance, mode, argc, argn, argv, saved);
 
@@ -660,22 +663,32 @@ static NPError CDECL NPP_New(NPMIMEType pluginType, NPP instance, UINT16 mode, I
         return NPERR_GENERIC_ERROR;
     }
 
-    obj = create_activex_object(window, nselem, &clsid);
-    if(obj) {
-        PluginHost *host;
-        HRESULT hres;
+    hres = get_node(window->doc, (nsIDOMNode*)nselem, TRUE, &node);
+    nsIDOMHTMLElement_Release(nselem);
+    if(FAILED(hres))
+        return NPERR_GENERIC_ERROR;
 
-        hres = create_plugin_host(window->doc, (nsIDOMElement*)nselem, obj, &clsid, &host);
+    hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_HTMLPluginContainer,
+            (void**)&container);
+    node_release(node);
+    if(FAILED(hres)) {
+        ERR("Not an object element\n");
+        return NPERR_GENERIC_ERROR;
+    }
+
+    obj = create_activex_object(window, container->element.nselem, &clsid);
+    if(obj) {
+        hres = create_plugin_host(window->doc, container, obj, &clsid);
         IUnknown_Release(obj);
         if(SUCCEEDED(hres))
-            instance->pdata = host;
+            instance->pdata = container->plugin_host;
         else
             err = NPERR_GENERIC_ERROR;
     }else {
         err = NPERR_GENERIC_ERROR;
     }
 
-    nsIDOMHTMLElement_Release(nselem);
+    node_release(&container->element.node);
     return err;
 }
 
diff --git a/dlls/mshtml/pluginhost.c b/dlls/mshtml/pluginhost.c
index 7c1b760..2d71264 100644
--- a/dlls/mshtml/pluginhost.c
+++ b/dlls/mshtml/pluginhost.c
@@ -1634,29 +1634,6 @@ 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(&node->IHTMLDOMNode_iface, &IID_HTMLPluginContainer,
-            (void**)&container_elem);
-    node_release(node);
-    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_host(PluginHost *host)
 {
     HRESULT hres;
@@ -1717,10 +1694,11 @@ void detach_plugin_host(PluginHost *host)
     host->doc = NULL;
 }
 
-HRESULT create_plugin_host(HTMLDocumentNode *doc, nsIDOMElement *nselem, IUnknown *unk, const CLSID *clsid, PluginHost **ret)
+HRESULT create_plugin_host(HTMLDocumentNode *doc, HTMLPluginContainer *container, IUnknown *unk, const CLSID *clsid)
 {
     PluginHost *host;
-    HRESULT hres;
+
+    assert(!container->plugin_host);
 
     host = heap_alloc_zero(sizeof(*host));
     if(!host)
@@ -1737,12 +1715,6 @@ HRESULT create_plugin_host(HTMLDocumentNode *doc, nsIDOMElement *nselem, IUnknow
 
     host->ref = 1;
 
-    hres = assoc_element(host, doc, nselem);
-    if(FAILED(hres)) {
-        heap_free(host);
-        return hres;
-    }
-
     IUnknown_AddRef(unk);
     host->plugin_unk = unk;
     host->clsid = *clsid;
@@ -1750,6 +1722,7 @@ HRESULT create_plugin_host(HTMLDocumentNode *doc, nsIDOMElement *nselem, IUnknow
     host->doc = doc;
     list_add_tail(&doc->plugin_hosts, &host->entry);
 
-    *ret = host;
+    container->plugin_host = host;
+    host->element = container;
     return S_OK;
 }
diff --git a/dlls/mshtml/pluginhost.h b/dlls/mshtml/pluginhost.h
index 5cc5ad0..f1c0a74 100644
--- a/dlls/mshtml/pluginhost.h
+++ b/dlls/mshtml/pluginhost.h
@@ -60,7 +60,7 @@ struct HTMLPluginContainer {
 
 extern const IID IID_HTMLPluginContainer DECLSPEC_HIDDEN;
 
-HRESULT create_plugin_host(HTMLDocumentNode*,nsIDOMElement*,IUnknown*,const CLSID*,PluginHost**) DECLSPEC_HIDDEN;
+HRESULT create_plugin_host(HTMLDocumentNode*,HTMLPluginContainer*,IUnknown*,const CLSID*) DECLSPEC_HIDDEN;
 void update_plugin_window(PluginHost*,HWND,const RECT*) DECLSPEC_HIDDEN;
 void detach_plugin_host(PluginHost*) DECLSPEC_HIDDEN;
 




More information about the wine-cvs mailing list