From 00eb02711de63ef14040e4758856a6fea00cc785 Mon Sep 17 00:00:00 2001 From: Michael Stefaniuc Date: Fri, 31 Dec 2010 11:02:05 +0100 Subject: [PATCH] mshtml: COM cleanup for the IDispatchEx iface in HTMLDocument. --- dlls/mshtml/htmldoc.c | 54 +++++++++++++++++++----------------- dlls/mshtml/htmldoc3.c | 22 ++++++++------- dlls/mshtml/htmldoc5.c | 22 ++++++++------- dlls/mshtml/mshtml_private.h | 2 +- 4 files changed, 53 insertions(+), 47 deletions(-) diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index df449723c3b..3e0cc727082 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -69,7 +69,7 @@ static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT { HTMLDocument *This = impl_from_IHTMLDocument2(iface); - return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo); + return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo); } static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo, @@ -77,7 +77,7 @@ static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInf { HTMLDocument *This = impl_from_IHTMLDocument2(iface); - return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo); + return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo); } static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid, @@ -86,7 +86,8 @@ static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID r { HTMLDocument *This = impl_from_IHTMLDocument2(iface); - return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId); + return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, + rgDispId); } static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember, @@ -95,8 +96,8 @@ static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMe { HTMLDocument *This = impl_from_IHTMLDocument2(iface); - return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams, - pVarResult, pExcepInfo, puArgErr); + return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags, + pDispParams, pVarResult, pExcepInfo, puArgErr); } static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p) @@ -1547,32 +1548,35 @@ static const ISupportErrorInfoVtbl SupportErrorInfoVtbl = { SupportErrorInfo_InterfaceSupportsErrorInfo }; -#define DISPEX_THIS(iface) DEFINE_THIS(HTMLDocument, IDispatchEx, iface) +static inline HTMLDocument *impl_from_IDispatchEx(IDispatchEx *iface) +{ + return CONTAINING_RECORD(iface, HTMLDocument, IDispatchEx_iface); +} static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv) { - HTMLDocument *This = DISPEX_THIS(iface); + HTMLDocument *This = impl_from_IDispatchEx(iface); return htmldoc_query_interface(This, riid, ppv); } static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface) { - HTMLDocument *This = DISPEX_THIS(iface); + HTMLDocument *This = impl_from_IDispatchEx(iface); return htmldoc_addref(This); } static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface) { - HTMLDocument *This = DISPEX_THIS(iface); + HTMLDocument *This = impl_from_IDispatchEx(iface); return htmldoc_release(This); } static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo) { - HTMLDocument *This = DISPEX_THIS(iface); + HTMLDocument *This = impl_from_IDispatchEx(iface); return IDispatchEx_GetTypeInfoCount(This->dispex, pctinfo); } @@ -1580,7 +1584,7 @@ static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *p static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) { - HTMLDocument *This = DISPEX_THIS(iface); + HTMLDocument *This = impl_from_IDispatchEx(iface); return IDispatchEx_GetTypeInfo(This->dispex, iTInfo, lcid, ppTInfo); } @@ -1589,7 +1593,7 @@ static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID rii LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) { - HTMLDocument *This = DISPEX_THIS(iface); + HTMLDocument *This = impl_from_IDispatchEx(iface); return IDispatchEx_GetIDsOfNames(This->dispex, riid, rgszNames, cNames, lcid, rgDispId); } @@ -1598,7 +1602,7 @@ static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMemb REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { - HTMLDocument *This = DISPEX_THIS(iface); + HTMLDocument *This = impl_from_IDispatchEx(iface); TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid), lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); @@ -1621,7 +1625,7 @@ static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMemb static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid) { - HTMLDocument *This = DISPEX_THIS(iface); + HTMLDocument *This = impl_from_IDispatchEx(iface); return IDispatchEx_GetDispID(This->dispex, bstrName, grfdex, pid); } @@ -1629,7 +1633,7 @@ static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp, VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller) { - HTMLDocument *This = DISPEX_THIS(iface); + HTMLDocument *This = impl_from_IDispatchEx(iface); if(This->window && id == DISPID_IHTMLDOCUMENT2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT)) return IDispatchEx_InvokeEx(DISPATCHEX(This->window), DISPID_IHTMLWINDOW2_LOCATION, lcid, wFlags, @@ -1641,48 +1645,46 @@ static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex) { - HTMLDocument *This = DISPEX_THIS(iface); + HTMLDocument *This = impl_from_IDispatchEx(iface); return IDispatchEx_DeleteMemberByName(This->dispex, bstrName, grfdex); } static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id) { - HTMLDocument *This = DISPEX_THIS(iface); + HTMLDocument *This = impl_from_IDispatchEx(iface); return IDispatchEx_DeleteMemberByDispID(This->dispex, id); } static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex) { - HTMLDocument *This = DISPEX_THIS(iface); + HTMLDocument *This = impl_from_IDispatchEx(iface); return IDispatchEx_GetMemberProperties(This->dispex, id, grfdexFetch, pgrfdex); } static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName) { - HTMLDocument *This = DISPEX_THIS(iface); + HTMLDocument *This = impl_from_IDispatchEx(iface); return IDispatchEx_GetMemberName(This->dispex, id, pbstrName); } static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid) { - HTMLDocument *This = DISPEX_THIS(iface); + HTMLDocument *This = impl_from_IDispatchEx(iface); return IDispatchEx_GetNextDispID(This->dispex, grfdex, id, pid); } static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk) { - HTMLDocument *This = DISPEX_THIS(iface); + HTMLDocument *This = impl_from_IDispatchEx(iface); return IDispatchEx_GetNameSpaceParent(This->dispex, ppunk); } -#undef DISPEX_THIS - static const IDispatchExVtbl DocDispatchExVtbl = { DocDispatchEx_QueryInterface, DocDispatchEx_AddRef, @@ -1710,10 +1712,10 @@ static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv) *ppv = &This->IHTMLDocument2_iface; }else if(IsEqualGUID(&IID_IDispatch, riid)) { TRACE("(%p)->(IID_IDispatch, %p)\n", This, ppv); - *ppv = DISPATCHEX(This); + *ppv = &This->IDispatchEx_iface; }else if(IsEqualGUID(&IID_IDispatchEx, riid)) { TRACE("(%p)->(IID_IDispatchEx, %p)\n", This, ppv); - *ppv = DISPATCHEX(This); + *ppv = &This->IDispatchEx_iface; }else if(IsEqualGUID(&IID_IHTMLDocument, riid)) { TRACE("(%p)->(IID_IHTMLDocument, %p)\n", This, ppv); *ppv = &This->IHTMLDocument2_iface; @@ -1839,7 +1841,7 @@ static cp_static_data_t HTMLDocumentEvents_data = { HTMLDocumentEvents_tid, HTML static void init_doc(HTMLDocument *doc, IUnknown *unk_impl, IDispatchEx *dispex) { doc->IHTMLDocument2_iface.lpVtbl = &HTMLDocumentVtbl; - doc->lpIDispatchExVtbl = &DocDispatchExVtbl; + doc->IDispatchEx_iface.lpVtbl = &DocDispatchExVtbl; doc->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl; doc->unk_impl = unk_impl; diff --git a/dlls/mshtml/htmldoc3.c b/dlls/mshtml/htmldoc3.c index 53c47813139..fcc486ac9bb 100644 --- a/dlls/mshtml/htmldoc3.c +++ b/dlls/mshtml/htmldoc3.c @@ -62,14 +62,14 @@ static ULONG WINAPI HTMLDocument3_Release(IHTMLDocument3 *iface) static HRESULT WINAPI HTMLDocument3_GetTypeInfoCount(IHTMLDocument3 *iface, UINT *pctinfo) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); - return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo); + return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo); } static HRESULT WINAPI HTMLDocument3_GetTypeInfo(IHTMLDocument3 *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); - return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo); + return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo); } static HRESULT WINAPI HTMLDocument3_GetIDsOfNames(IHTMLDocument3 *iface, REFIID riid, @@ -77,7 +77,8 @@ static HRESULT WINAPI HTMLDocument3_GetIDsOfNames(IHTMLDocument3 *iface, REFIID LCID lcid, DISPID *rgDispId) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); - return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId); + return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, + rgDispId); } static HRESULT WINAPI HTMLDocument3_Invoke(IHTMLDocument3 *iface, DISPID dispIdMember, @@ -85,8 +86,8 @@ static HRESULT WINAPI HTMLDocument3_Invoke(IHTMLDocument3 *iface, DISPID dispIdM VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { HTMLDocument *This = impl_from_IHTMLDocument3(iface); - return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams, - pVarResult, pExcepInfo, puArgErr); + return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags, + pDispParams, pVarResult, pExcepInfo, puArgErr); } static HRESULT WINAPI HTMLDocument3_releaseCapture(IHTMLDocument3 *iface) @@ -664,14 +665,14 @@ static ULONG WINAPI HTMLDocument4_Release(IHTMLDocument4 *iface) static HRESULT WINAPI HTMLDocument4_GetTypeInfoCount(IHTMLDocument4 *iface, UINT *pctinfo) { HTMLDocument *This = impl_from_IHTMLDocument4(iface); - return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo); + return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo); } static HRESULT WINAPI HTMLDocument4_GetTypeInfo(IHTMLDocument4 *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) { HTMLDocument *This = impl_from_IHTMLDocument4(iface); - return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo); + return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo); } static HRESULT WINAPI HTMLDocument4_GetIDsOfNames(IHTMLDocument4 *iface, REFIID riid, @@ -679,7 +680,8 @@ static HRESULT WINAPI HTMLDocument4_GetIDsOfNames(IHTMLDocument4 *iface, REFIID LCID lcid, DISPID *rgDispId) { HTMLDocument *This = impl_from_IHTMLDocument4(iface); - return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId); + return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, + rgDispId); } static HRESULT WINAPI HTMLDocument4_Invoke(IHTMLDocument4 *iface, DISPID dispIdMember, @@ -687,8 +689,8 @@ static HRESULT WINAPI HTMLDocument4_Invoke(IHTMLDocument4 *iface, DISPID dispIdM VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { HTMLDocument *This = impl_from_IHTMLDocument4(iface); - return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams, - pVarResult, pExcepInfo, puArgErr); + return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags, + pDispParams, pVarResult, pExcepInfo, puArgErr); } static HRESULT WINAPI HTMLDocument4_focus(IHTMLDocument4 *iface) diff --git a/dlls/mshtml/htmldoc5.c b/dlls/mshtml/htmldoc5.c index c266e0247f5..bce41140556 100644 --- a/dlls/mshtml/htmldoc5.c +++ b/dlls/mshtml/htmldoc5.c @@ -61,21 +61,22 @@ static ULONG WINAPI HTMLDocument5_Release(IHTMLDocument5 *iface) static HRESULT WINAPI HTMLDocument5_GetTypeInfoCount(IHTMLDocument5 *iface, UINT *pctinfo) { HTMLDocument *This = impl_from_IHTMLDocument5(iface); - return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo); + return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo); } static HRESULT WINAPI HTMLDocument5_GetTypeInfo(IHTMLDocument5 *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) { HTMLDocument *This = impl_from_IHTMLDocument5(iface); - return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo); + return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo); } static HRESULT WINAPI HTMLDocument5_GetIDsOfNames(IHTMLDocument5 *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) { HTMLDocument *This = impl_from_IHTMLDocument5(iface); - return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId); + return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, + rgDispId); } static HRESULT WINAPI HTMLDocument5_Invoke(IHTMLDocument5 *iface, DISPID dispIdMember, @@ -83,8 +84,8 @@ static HRESULT WINAPI HTMLDocument5_Invoke(IHTMLDocument5 *iface, DISPID dispIdM VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { HTMLDocument *This = impl_from_IHTMLDocument5(iface); - return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams, - pVarResult, pExcepInfo, puArgErr); + return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags, + pDispParams, pVarResult, pExcepInfo, puArgErr); } static HRESULT WINAPI HTMLDocument5_put_onmousewheel(IHTMLDocument5 *iface, VARIANT v) @@ -330,21 +331,22 @@ static ULONG WINAPI HTMLDocument6_Release(IHTMLDocument6 *iface) static HRESULT WINAPI HTMLDocument6_GetTypeInfoCount(IHTMLDocument6 *iface, UINT *pctinfo) { HTMLDocument *This = impl_from_IHTMLDocument6(iface); - return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo); + return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo); } static HRESULT WINAPI HTMLDocument6_GetTypeInfo(IHTMLDocument6 *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) { HTMLDocument *This = impl_from_IHTMLDocument6(iface); - return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo); + return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo); } static HRESULT WINAPI HTMLDocument6_GetIDsOfNames(IHTMLDocument6 *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) { HTMLDocument *This = impl_from_IHTMLDocument6(iface); - return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId); + return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid, + rgDispId); } static HRESULT WINAPI HTMLDocument6_Invoke(IHTMLDocument6 *iface, DISPID dispIdMember, @@ -352,8 +354,8 @@ static HRESULT WINAPI HTMLDocument6_Invoke(IHTMLDocument6 *iface, DISPID dispIdM VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { HTMLDocument *This = impl_from_IHTMLDocument6(iface); - return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams, - pVarResult, pExcepInfo, puArgErr); + return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags, + pDispParams, pVarResult, pExcepInfo, puArgErr); } static HRESULT WINAPI HTMLDocument6_get_compatible(IHTMLDocument6 *iface, diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index f0fb3cf4443..6b12a442ca1 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -364,7 +364,7 @@ struct HTMLDocument { IOleControl IOleControl_iface; IHlinkTarget IHlinkTarget_iface; IPersistStreamInit IPersistStreamInit_iface; - const IDispatchExVtbl *lpIDispatchExVtbl; + IDispatchEx IDispatchEx_iface; ISupportErrorInfo ISupportErrorInfo_iface; IObjectWithSite IObjectWithSite_iface; IOleContainer IOleContainer_iface;