mshtml: Associate PluginHost with containing element.

This commit is contained in:
Jacek Caban 2010-12-09 16:28:34 +01:00 committed by Alexandre Julliard
parent bfc49aa7f3
commit 483fe27730
4 changed files with 37 additions and 3 deletions

View File

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

View File

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

View File

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

View File

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