mshtml: Use node's IDispatchEx implementation in HTMLDocumentNode.

This commit is contained in:
Jacek Caban 2009-09-16 22:14:38 +02:00 committed by Alexandre Julliard
parent f750bc4059
commit 7eca0bcae4
3 changed files with 58 additions and 37 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2005 Jacek Caban * Copyright 2005-2009 Jacek Caban for CodeWeavers
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -1475,7 +1475,7 @@ static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *p
{ {
HTMLDocument *This = DISPEX_THIS(iface); HTMLDocument *This = DISPEX_THIS(iface);
return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo); return IDispatchEx_GetTypeInfoCount(This->dispex, pctinfo);
} }
static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo, static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
@ -1483,7 +1483,7 @@ static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
{ {
HTMLDocument *This = DISPEX_THIS(iface); HTMLDocument *This = DISPEX_THIS(iface);
return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo); return IDispatchEx_GetTypeInfo(This->dispex, iTInfo, lcid, ppTInfo);
} }
static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid, static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
@ -1492,7 +1492,7 @@ static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID rii
{ {
HTMLDocument *This = DISPEX_THIS(iface); HTMLDocument *This = DISPEX_THIS(iface);
return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId); return IDispatchEx_GetIDsOfNames(This->dispex, riid, rgszNames, cNames, lcid, rgDispId);
} }
static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember, static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
@ -1516,7 +1516,7 @@ static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMemb
return S_OK; return S_OK;
} }
return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid, wFlags, pDispParams, return IDispatchEx_Invoke(This->dispex, dispIdMember, riid, lcid, wFlags, pDispParams,
pVarResult, pExcepInfo, puArgErr); pVarResult, pExcepInfo, puArgErr);
} }
@ -1524,7 +1524,7 @@ static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName,
{ {
HTMLDocument *This = DISPEX_THIS(iface); HTMLDocument *This = DISPEX_THIS(iface);
return IDispatchEx_GetDispID(DISPATCHEX(&This->dispex), bstrName, grfdex, pid); return IDispatchEx_GetDispID(This->dispex, bstrName, grfdex, pid);
} }
static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp, static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
@ -1532,49 +1532,49 @@ static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID
{ {
HTMLDocument *This = DISPEX_THIS(iface); HTMLDocument *This = DISPEX_THIS(iface);
return IDispatchEx_InvokeEx(DISPATCHEX(&This->dispex), id, lcid, wFlags, pdp, pvarRes, pei, pspCaller); return IDispatchEx_InvokeEx(This->dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
} }
static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex) static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
{ {
HTMLDocument *This = DISPEX_THIS(iface); HTMLDocument *This = DISPEX_THIS(iface);
return IDispatchEx_DeleteMemberByName(DISPATCHEX(&This->dispex), bstrName, grfdex); return IDispatchEx_DeleteMemberByName(This->dispex, bstrName, grfdex);
} }
static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id) static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
{ {
HTMLDocument *This = DISPEX_THIS(iface); HTMLDocument *This = DISPEX_THIS(iface);
return IDispatchEx_DeleteMemberByDispID(DISPATCHEX(&This->dispex), id); return IDispatchEx_DeleteMemberByDispID(This->dispex, id);
} }
static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex) static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
{ {
HTMLDocument *This = DISPEX_THIS(iface); HTMLDocument *This = DISPEX_THIS(iface);
return IDispatchEx_GetMemberProperties(DISPATCHEX(&This->dispex), id, grfdexFetch, pgrfdex); return IDispatchEx_GetMemberProperties(This->dispex, id, grfdexFetch, pgrfdex);
} }
static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName) static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
{ {
HTMLDocument *This = DISPEX_THIS(iface); HTMLDocument *This = DISPEX_THIS(iface);
return IDispatchEx_GetMemberName(DISPATCHEX(&This->dispex), id, pbstrName); return IDispatchEx_GetMemberName(This->dispex, id, pbstrName);
} }
static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid) static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
{ {
HTMLDocument *This = DISPEX_THIS(iface); HTMLDocument *This = DISPEX_THIS(iface);
return IDispatchEx_GetNextDispID(DISPATCHEX(&This->dispex), grfdex, id, pid); return IDispatchEx_GetNextDispID(This->dispex, grfdex, id, pid);
} }
static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk) static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
{ {
HTMLDocument *This = DISPEX_THIS(iface); HTMLDocument *This = DISPEX_THIS(iface);
return IDispatchEx_GetNameSpaceParent(DISPATCHEX(&This->dispex), ppunk); return IDispatchEx_GetNameSpaceParent(This->dispex, ppunk);
} }
#undef DISPEX_THIS #undef DISPEX_THIS
@ -1703,8 +1703,6 @@ static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
}else if(IsEqualGUID(&IID_IMarshal, riid)) { }else if(IsEqualGUID(&IID_IMarshal, riid)) {
TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv); TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv);
*ppv = NULL; *ppv = NULL;
}else if(dispex_query_interface(&This->dispex, riid, ppv)) {
return TRUE;
}else { }else {
return FALSE; return FALSE;
} }
@ -1714,27 +1712,14 @@ static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
return TRUE; return TRUE;
} }
static const tid_t HTMLDocument_iface_tids[] = { static void init_doc(HTMLDocument *doc, IUnknown *unk_impl, IDispatchEx *dispex)
IHTMLDocument2_tid,
IHTMLDocument3_tid,
IHTMLDocument4_tid,
IHTMLDocument5_tid,
0
};
static dispex_static_data_t HTMLDocument_dispex = {
NULL,
DispHTMLDocument_tid,
NULL,
HTMLDocument_iface_tids
};
static void init_doc(HTMLDocument *doc, IUnknown *unk_impl)
{ {
doc->lpHTMLDocument2Vtbl = &HTMLDocumentVtbl; doc->lpHTMLDocument2Vtbl = &HTMLDocumentVtbl;
doc->lpIDispatchExVtbl = &DocDispatchExVtbl; doc->lpIDispatchExVtbl = &DocDispatchExVtbl;
doc->lpSupportErrorInfoVtbl = &SupportErrorInfoVtbl; doc->lpSupportErrorInfoVtbl = &SupportErrorInfoVtbl;
doc->unk_impl = unk_impl; doc->unk_impl = unk_impl;
doc->dispex = dispex;
HTMLDocument_HTMLDocument3_Init(doc); HTMLDocument_HTMLDocument3_Init(doc);
HTMLDocument_HTMLDocument5_Init(doc); HTMLDocument_HTMLDocument5_Init(doc);
@ -1750,8 +1735,6 @@ static void init_doc(HTMLDocument *doc, IUnknown *unk_impl)
ConnectionPoint_Init(&doc->cp_propnotif, &doc->cp_container, &IID_IPropertyNotifySink); ConnectionPoint_Init(&doc->cp_propnotif, &doc->cp_container, &IID_IPropertyNotifySink);
ConnectionPoint_Init(&doc->cp_htmldocevents, &doc->cp_container, &DIID_HTMLDocumentEvents); ConnectionPoint_Init(&doc->cp_htmldocevents, &doc->cp_container, &DIID_HTMLDocumentEvents);
ConnectionPoint_Init(&doc->cp_htmldocevents2, &doc->cp_container, &DIID_HTMLDocumentEvents2); ConnectionPoint_Init(&doc->cp_htmldocevents2, &doc->cp_container, &DIID_HTMLDocumentEvents2);
init_dispex(&doc->dispex, (IUnknown*)HTMLDOC(doc), &HTMLDocument_dispex);
} }
static void destroy_htmldoc(HTMLDocument *This) static void destroy_htmldoc(HTMLDocument *This)
@ -1761,8 +1744,6 @@ static void destroy_htmldoc(HTMLDocument *This)
if(This->event_target) if(This->event_target)
release_event_target(This->event_target); release_event_target(This->event_target);
release_dispex(&This->dispex);
ConnectionPointContainer_Destroy(&This->cp_container); ConnectionPointContainer_Destroy(&This->cp_container);
if(This->nsdoc) if(This->nsdoc)
@ -1798,6 +1779,23 @@ static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
HTMLDocumentNode_destructor HTMLDocumentNode_destructor
}; };
static const tid_t HTMLDocumentNode_iface_tids[] = {
IHTMLDOMNode_tid,
IHTMLDOMNode2_tid,
IHTMLDocument2_tid,
IHTMLDocument3_tid,
IHTMLDocument4_tid,
IHTMLDocument5_tid,
0
};
static dispex_static_data_t HTMLDocumentNode_dispex = {
NULL,
DispHTMLDocument_tid,
NULL,
HTMLDocumentNode_iface_tids
};
HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_obj, HTMLWindow *window, HTMLDocumentNode **ret) HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_obj, HTMLWindow *window, HTMLDocumentNode **ret)
{ {
HTMLDocumentNode *doc; HTMLDocumentNode *doc;
@ -1809,7 +1807,8 @@ HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_ob
doc->basedoc.doc_node = doc; doc->basedoc.doc_node = doc;
doc->basedoc.doc_obj = doc_obj; doc->basedoc.doc_obj = doc_obj;
init_doc(&doc->basedoc, (IUnknown*)HTMLDOMNODE(&doc->node)); init_dispex(&doc->node.dispex, (IUnknown*)HTMLDOMNODE(&doc->node), &HTMLDocumentNode_dispex);
init_doc(&doc->basedoc, (IUnknown*)HTMLDOMNODE(&doc->node), DISPATCHEX(&doc->node.dispex));
doc->ref = 1; doc->ref = 1;
nsIDOMHTMLDocument_AddRef(nsdoc); nsIDOMHTMLDocument_AddRef(nsdoc);
@ -1843,6 +1842,8 @@ static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, v
if(IsEqualGUID(&IID_ICustomDoc, riid)) { if(IsEqualGUID(&IID_ICustomDoc, riid)) {
TRACE("(%p)->(IID_ICustomDoc %p)\n", This, ppv); TRACE("(%p)->(IID_ICustomDoc %p)\n", This, ppv);
*ppv = CUSTOMDOC(This); *ppv = CUSTOMDOC(This);
}else if(dispex_query_interface(&This->dispex, riid, ppv)) {
return *ppv ? S_OK : E_NOINTERFACE;
}else { }else {
FIXME("Unimplemented interface %s\n", debugstr_guid(riid)); FIXME("Unimplemented interface %s\n", debugstr_guid(riid));
*ppv = NULL; *ppv = NULL;
@ -1898,6 +1899,7 @@ static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
heap_free(This->mime); heap_free(This->mime);
destroy_htmldoc(&This->basedoc); destroy_htmldoc(&This->basedoc);
release_dispex(&This->dispex);
if(This->basedoc.nsdoc) if(This->basedoc.nsdoc)
remove_mutation_observer(This->nscontainer, This->basedoc.nsdoc); remove_mutation_observer(This->nscontainer, This->basedoc.nsdoc);
@ -1925,6 +1927,20 @@ static const ICustomDocVtbl CustomDocVtbl = {
CustomDoc_SetUIHandler CustomDoc_SetUIHandler
}; };
static const tid_t HTMLDocumentObj_iface_tids[] = {
IHTMLDocument2_tid,
IHTMLDocument3_tid,
IHTMLDocument4_tid,
IHTMLDocument5_tid,
0
};
static dispex_static_data_t HTMLDocumentObj_dispex = {
NULL,
DispHTMLDocument_tid,
NULL,
HTMLDocumentObj_iface_tids
};
HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject) HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
{ {
HTMLDocumentObj *doc; HTMLDocumentObj *doc;
@ -1937,7 +1953,8 @@ HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
if(!doc) if(!doc)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
init_doc(&doc->basedoc, (IUnknown*)CUSTOMDOC(doc)); init_dispex(&doc->dispex, (IUnknown*)CUSTOMDOC(doc), &HTMLDocumentObj_dispex);
init_doc(&doc->basedoc, (IUnknown*)CUSTOMDOC(doc), DISPATCHEX(&doc->dispex));
doc->lpCustomDocVtbl = &CustomDocVtbl; doc->lpCustomDocVtbl = &CustomDocVtbl;
doc->ref = 1; doc->ref = 1;

View File

@ -247,7 +247,6 @@ struct ConnectionPoint {
}; };
struct HTMLDocument { struct HTMLDocument {
DispatchEx dispex;
const IHTMLDocument2Vtbl *lpHTMLDocument2Vtbl; const IHTMLDocument2Vtbl *lpHTMLDocument2Vtbl;
const IHTMLDocument3Vtbl *lpHTMLDocument3Vtbl; const IHTMLDocument3Vtbl *lpHTMLDocument3Vtbl;
const IHTMLDocument4Vtbl *lpHTMLDocument4Vtbl; const IHTMLDocument4Vtbl *lpHTMLDocument4Vtbl;
@ -271,6 +270,7 @@ struct HTMLDocument {
const ISupportErrorInfoVtbl *lpSupportErrorInfoVtbl; const ISupportErrorInfoVtbl *lpSupportErrorInfoVtbl;
IUnknown *unk_impl; IUnknown *unk_impl;
IDispatchEx *dispex;
HTMLDocumentObj *doc_obj; HTMLDocumentObj *doc_obj;
HTMLDocumentNode *doc_node; HTMLDocumentNode *doc_node;
@ -302,6 +302,7 @@ static inline ULONG htmldoc_release(HTMLDocument *This)
struct HTMLDocumentObj { struct HTMLDocumentObj {
HTMLDocument basedoc; HTMLDocument basedoc;
DispatchEx dispex;
const ICustomDocVtbl *lpCustomDocVtbl; const ICustomDocVtbl *lpCustomDocVtbl;
LONG ref; LONG ref;

View File

@ -4109,7 +4109,10 @@ static void test_window(IHTMLDocument2 *doc)
ok(doc2 != NULL, "doc2 == NULL\n"); ok(doc2 != NULL, "doc2 == NULL\n");
test_ifaces((IUnknown*)doc2, doc_node_iids); test_ifaces((IUnknown*)doc2, doc_node_iids);
test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
test_ifaces((IUnknown*)doc, doc_obj_iids); test_ifaces((IUnknown*)doc, doc_obj_iids);
test_disp((IUnknown*)doc2, &DIID_DispHTMLDocument, "[object]");
unk = (void*)0xdeadbeef; unk = (void*)0xdeadbeef;
hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk); hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);