mshtml: COM cleanup for the IHTMLDOMChildrenCollection iface.

This commit is contained in:
Michael Stefaniuc 2010-12-30 01:41:56 +01:00 committed by Alexandre Julliard
parent e068287c21
commit 6c075b6d42
1 changed files with 23 additions and 22 deletions

View File

@ -37,7 +37,7 @@ static HRESULT create_node(HTMLDocumentNode*,nsIDOMNode*,HTMLDOMNode**);
typedef struct { typedef struct {
DispatchEx dispex; DispatchEx dispex;
const IHTMLDOMChildrenCollectionVtbl *lpIHTMLDOMChildrenCollectionVtbl; IHTMLDOMChildrenCollection IHTMLDOMChildrenCollection_iface;
LONG ref; LONG ref;
@ -47,22 +47,23 @@ typedef struct {
nsIDOMNodeList *nslist; nsIDOMNodeList *nslist;
} HTMLDOMChildrenCollection; } HTMLDOMChildrenCollection;
#define HTMLCHILDCOL(x) ((IHTMLDOMChildrenCollection*) &(x)->lpIHTMLDOMChildrenCollectionVtbl) static inline HTMLDOMChildrenCollection *impl_from_IHTMLDOMChildrenCollection(IHTMLDOMChildrenCollection *iface)
{
#define HTMLCHILDCOL_THIS(iface) DEFINE_THIS(HTMLDOMChildrenCollection, IHTMLDOMChildrenCollection, iface) return CONTAINING_RECORD(iface, HTMLDOMChildrenCollection, IHTMLDOMChildrenCollection_iface);
}
static HRESULT WINAPI HTMLDOMChildrenCollection_QueryInterface(IHTMLDOMChildrenCollection *iface, REFIID riid, void **ppv) static HRESULT WINAPI HTMLDOMChildrenCollection_QueryInterface(IHTMLDOMChildrenCollection *iface, REFIID riid, void **ppv)
{ {
HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface); HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface);
*ppv = NULL; *ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) { if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = HTMLCHILDCOL(This); *ppv = &This->IHTMLDOMChildrenCollection_iface;
}else if(IsEqualGUID(&IID_IHTMLDOMChildrenCollection, riid)) { }else if(IsEqualGUID(&IID_IHTMLDOMChildrenCollection, riid)) {
TRACE("(%p)->(IID_IHTMLDOMChildrenCollection %p)\n", This, ppv); TRACE("(%p)->(IID_IHTMLDOMChildrenCollection %p)\n", This, ppv);
*ppv = HTMLCHILDCOL(This); *ppv = &This->IHTMLDOMChildrenCollection_iface;
}else if(dispex_query_interface(&This->dispex, riid, ppv)) { }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
return *ppv ? S_OK : E_NOINTERFACE; return *ppv ? S_OK : E_NOINTERFACE;
} }
@ -78,7 +79,7 @@ static HRESULT WINAPI HTMLDOMChildrenCollection_QueryInterface(IHTMLDOMChildrenC
static ULONG WINAPI HTMLDOMChildrenCollection_AddRef(IHTMLDOMChildrenCollection *iface) static ULONG WINAPI HTMLDOMChildrenCollection_AddRef(IHTMLDOMChildrenCollection *iface)
{ {
HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface); HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface);
LONG ref = InterlockedIncrement(&This->ref); LONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref); TRACE("(%p) ref=%d\n", This, ref);
@ -88,7 +89,7 @@ static ULONG WINAPI HTMLDOMChildrenCollection_AddRef(IHTMLDOMChildrenCollection
static ULONG WINAPI HTMLDOMChildrenCollection_Release(IHTMLDOMChildrenCollection *iface) static ULONG WINAPI HTMLDOMChildrenCollection_Release(IHTMLDOMChildrenCollection *iface)
{ {
HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface); HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface);
LONG ref = InterlockedDecrement(&This->ref); LONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref); TRACE("(%p) ref=%d\n", This, ref);
@ -103,21 +104,21 @@ static ULONG WINAPI HTMLDOMChildrenCollection_Release(IHTMLDOMChildrenCollection
static HRESULT WINAPI HTMLDOMChildrenCollection_GetTypeInfoCount(IHTMLDOMChildrenCollection *iface, UINT *pctinfo) static HRESULT WINAPI HTMLDOMChildrenCollection_GetTypeInfoCount(IHTMLDOMChildrenCollection *iface, UINT *pctinfo)
{ {
HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface); HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface);
return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo); return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo);
} }
static HRESULT WINAPI HTMLDOMChildrenCollection_GetTypeInfo(IHTMLDOMChildrenCollection *iface, UINT iTInfo, static HRESULT WINAPI HTMLDOMChildrenCollection_GetTypeInfo(IHTMLDOMChildrenCollection *iface, UINT iTInfo,
LCID lcid, ITypeInfo **ppTInfo) LCID lcid, ITypeInfo **ppTInfo)
{ {
HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface); HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface);
return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo); return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
} }
static HRESULT WINAPI HTMLDOMChildrenCollection_GetIDsOfNames(IHTMLDOMChildrenCollection *iface, REFIID riid, static HRESULT WINAPI HTMLDOMChildrenCollection_GetIDsOfNames(IHTMLDOMChildrenCollection *iface, REFIID riid,
LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
{ {
HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface); HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface);
return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId); return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
} }
@ -125,14 +126,14 @@ static HRESULT WINAPI HTMLDOMChildrenCollection_Invoke(IHTMLDOMChildrenCollectio
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{ {
HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface); HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface);
return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid, return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid,
wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
} }
static HRESULT WINAPI HTMLDOMChildrenCollection_get_length(IHTMLDOMChildrenCollection *iface, LONG *p) static HRESULT WINAPI HTMLDOMChildrenCollection_get_length(IHTMLDOMChildrenCollection *iface, LONG *p)
{ {
HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface); HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface);
PRUint32 length=0; PRUint32 length=0;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
@ -144,14 +145,14 @@ static HRESULT WINAPI HTMLDOMChildrenCollection_get_length(IHTMLDOMChildrenColle
static HRESULT WINAPI HTMLDOMChildrenCollection__newEnum(IHTMLDOMChildrenCollection *iface, IUnknown **p) static HRESULT WINAPI HTMLDOMChildrenCollection__newEnum(IHTMLDOMChildrenCollection *iface, IUnknown **p)
{ {
HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface); HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface);
FIXME("(%p)->(%p)\n", This, p); FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT WINAPI HTMLDOMChildrenCollection_item(IHTMLDOMChildrenCollection *iface, LONG index, IDispatch **ppItem) static HRESULT WINAPI HTMLDOMChildrenCollection_item(IHTMLDOMChildrenCollection *iface, LONG index, IDispatch **ppItem)
{ {
HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface); HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface);
nsIDOMNode *nsnode = NULL; nsIDOMNode *nsnode = NULL;
HTMLDOMNode *node; HTMLDOMNode *node;
PRUint32 length=0; PRUint32 length=0;
@ -184,8 +185,6 @@ static HRESULT WINAPI HTMLDOMChildrenCollection_item(IHTMLDOMChildrenCollection
return S_OK; return S_OK;
} }
#undef HTMLCHILDCOL_THIS
static const IHTMLDOMChildrenCollectionVtbl HTMLDOMChildrenCollectionVtbl = { static const IHTMLDOMChildrenCollectionVtbl HTMLDOMChildrenCollectionVtbl = {
HTMLDOMChildrenCollection_QueryInterface, HTMLDOMChildrenCollection_QueryInterface,
HTMLDOMChildrenCollection_AddRef, HTMLDOMChildrenCollection_AddRef,
@ -239,7 +238,8 @@ static HRESULT HTMLDOMChildrenCollection_invoke(DispatchEx *dispex, DISPID id, L
IDispatch *disp = NULL; IDispatch *disp = NULL;
HRESULT hres; HRESULT hres;
hres = IHTMLDOMChildrenCollection_item(HTMLCHILDCOL(This), id - DISPID_CHILDCOL_0, &disp); hres = IHTMLDOMChildrenCollection_item(&This->IHTMLDOMChildrenCollection_iface,
id - DISPID_CHILDCOL_0, &disp);
if(0&&FAILED(hres)) if(0&&FAILED(hres))
return hres; return hres;
@ -279,16 +279,17 @@ static IHTMLDOMChildrenCollection *create_child_collection(HTMLDocumentNode *doc
HTMLDOMChildrenCollection *ret; HTMLDOMChildrenCollection *ret;
ret = heap_alloc_zero(sizeof(*ret)); ret = heap_alloc_zero(sizeof(*ret));
ret->lpIHTMLDOMChildrenCollectionVtbl = &HTMLDOMChildrenCollectionVtbl; ret->IHTMLDOMChildrenCollection_iface.lpVtbl = &HTMLDOMChildrenCollectionVtbl;
ret->ref = 1; ret->ref = 1;
nsIDOMNodeList_AddRef(nslist); nsIDOMNodeList_AddRef(nslist);
ret->nslist = nslist; ret->nslist = nslist;
ret->doc = doc; ret->doc = doc;
init_dispex(&ret->dispex, (IUnknown*)HTMLCHILDCOL(ret), &HTMLDOMChildrenCollection_dispex); init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLDOMChildrenCollection_iface,
&HTMLDOMChildrenCollection_dispex);
return HTMLCHILDCOL(ret); return &ret->IHTMLDOMChildrenCollection_iface;
} }
static inline HTMLDOMNode *impl_from_IHTMLDOMNode(IHTMLDOMNode *iface) static inline HTMLDOMNode *impl_from_IHTMLDOMNode(IHTMLDOMNode *iface)