mshtml: Pass HTMLPluginContainer to create_plugin_host.

This commit is contained in:
Jacek Caban 2014-12-11 16:25:49 +01:00 committed by Alexandre Julliard
parent 44bb2ba295
commit a545fe08ad
3 changed files with 26 additions and 40 deletions

View File

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

View File

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

View File

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