From ca353c9b7ead5ae1ad4630c9fb962e284639d55f Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Sat, 13 Nov 2010 17:47:58 +0100 Subject: [PATCH] shdocvw: Get rid of CLIENTSITE_THIS. --- dlls/shdocvw/client.c | 79 ++++++++++++++++++----------------------- dlls/shdocvw/dochost.c | 22 ++++++------ dlls/shdocvw/frame.c | 4 +-- dlls/shdocvw/navigate.c | 8 ++--- dlls/shdocvw/shdocvw.h | 3 +- 5 files changed, 52 insertions(+), 64 deletions(-) diff --git a/dlls/shdocvw/client.c b/dlls/shdocvw/client.c index 17fa35f96d1..d32e6493943 100644 --- a/dlls/shdocvw/client.c +++ b/dlls/shdocvw/client.c @@ -25,20 +25,21 @@ WINE_DEFAULT_DEBUG_CHANNEL(shdocvw); -#define CLIENTSITE_THIS(iface) DEFINE_THIS(DocHost, OleClientSite, iface) +static inline DocHost *impl_from_IOleClientSite(IOleClientSite *iface) +{ + return (DocHost*)((char*)iface - FIELD_OFFSET(DocHost, IOleClientSite_iface)); +} static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv) { - DocHost *This = CLIENTSITE_THIS(iface); - - *ppv = NULL; + DocHost *This = impl_from_IOleClientSite(iface); if(IsEqualGUID(&IID_IUnknown, riid)) { TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); - *ppv = CLIENTSITE(This); + *ppv = &This->IOleClientSite_iface; }else if(IsEqualGUID(&IID_IOleClientSite, riid)) { TRACE("(%p)->(IID_IOleClientSite %p)\n", This, ppv); - *ppv = CLIENTSITE(This); + *ppv = &This->IOleClientSite_iface; }else if(IsEqualGUID(&IID_IOleWindow, riid)) { TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv); *ppv = INPLACESITE(This); @@ -66,33 +67,31 @@ static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID ri }else if(IsEqualGUID(&IID_IServiceProvider, riid)) { TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv); *ppv = SERVPROV(This); + }else { + *ppv = NULL; + WARN("Unsupported interface %s\n", debugstr_guid(riid)); + return E_NOINTERFACE; } - if(*ppv) { - IOleClientSite_AddRef(CLIENTSITE(This)); - return S_OK; - } - - WARN("Unsupported interface %s\n", debugstr_guid(riid)); - - return E_NOINTERFACE; + IOleClientSite_AddRef((IUnknown*)*ppv); + return S_OK; } static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface) { - DocHost *This = CLIENTSITE_THIS(iface); + DocHost *This = impl_from_IOleClientSite(iface); return IDispatch_AddRef(This->disp); } static ULONG WINAPI ClientSite_Release(IOleClientSite *iface) { - DocHost *This = CLIENTSITE_THIS(iface); + DocHost *This = impl_from_IOleClientSite(iface); return IDispatch_Release(This->disp); } static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface) { - DocHost *This = CLIENTSITE_THIS(iface); + DocHost *This = impl_from_IOleClientSite(iface); FIXME("(%p)\n", This); return E_NOTIMPL; } @@ -100,41 +99,39 @@ static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface) static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk) { - DocHost *This = CLIENTSITE_THIS(iface); + DocHost *This = impl_from_IOleClientSite(iface); FIXME("(%p)->(%d %d %p)\n", This, dwAssign, dwWhichMoniker, ppmk); return E_NOTIMPL; } static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer) { - DocHost *This = CLIENTSITE_THIS(iface); + DocHost *This = impl_from_IOleClientSite(iface); FIXME("(%p)->(%p)\n", This, ppContainer); return E_NOTIMPL; } static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface) { - DocHost *This = CLIENTSITE_THIS(iface); + DocHost *This = impl_from_IOleClientSite(iface); FIXME("(%p)\n", This); return E_NOTIMPL; } static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow) { - DocHost *This = CLIENTSITE_THIS(iface); + DocHost *This = impl_from_IOleClientSite(iface); FIXME("(%p)->(%x)\n", This, fShow); return E_NOTIMPL; } static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface) { - DocHost *This = CLIENTSITE_THIS(iface); + DocHost *This = impl_from_IOleClientSite(iface); FIXME("(%p)\n", This); return E_NOTIMPL; } -#undef CLIENTSITE_THIS - static const IOleClientSiteVtbl OleClientSiteVtbl = { ClientSite_QueryInterface, ClientSite_AddRef, @@ -152,19 +149,19 @@ static const IOleClientSiteVtbl OleClientSiteVtbl = { static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppv) { DocHost *This = INPLACESITE_THIS(iface); - return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv); + return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv); } static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSite *iface) { DocHost *This = INPLACESITE_THIS(iface); - return IOleClientSite_AddRef(CLIENTSITE(This)); + return IOleClientSite_AddRef(&This->IOleClientSite_iface); } static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSite *iface) { DocHost *This = INPLACESITE_THIS(iface); - return IOleClientSite_Release(CLIENTSITE(This)); + return IOleClientSite_Release(&This->IOleClientSite_iface); } static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSite *iface, HWND *phwnd) @@ -282,8 +279,6 @@ static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSite *iface, return E_NOTIMPL; } -#undef INPLACESITE_THIS - static const IOleInPlaceSiteVtbl OleInPlaceSiteVtbl = { InPlaceSite_QueryInterface, InPlaceSite_AddRef, @@ -308,19 +303,19 @@ static HRESULT WINAPI OleDocumentSite_QueryInterface(IOleDocumentSite *iface, REFIID riid, void **ppv) { DocHost *This = DOCSITE_THIS(iface); - return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv); + return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv); } static ULONG WINAPI OleDocumentSite_AddRef(IOleDocumentSite *iface) { DocHost *This = DOCSITE_THIS(iface); - return IOleClientSite_AddRef(CLIENTSITE(This)); + return IOleClientSite_AddRef(&This->IOleClientSite_iface); } static ULONG WINAPI OleDocumentSite_Release(IOleDocumentSite *iface) { DocHost *This = DOCSITE_THIS(iface); - return IOleClientSite_Release(CLIENTSITE(This)); + return IOleClientSite_Release(&This->IOleClientSite_iface); } static HRESULT WINAPI OleDocumentSite_ActivateMe(IOleDocumentSite *iface, @@ -348,8 +343,6 @@ static HRESULT WINAPI OleDocumentSite_ActivateMe(IOleDocumentSite *iface, return hres; } -#undef DOCSITE_THIS - static const IOleDocumentSiteVtbl OleDocumentSiteVtbl = { OleDocumentSite_QueryInterface, OleDocumentSite_AddRef, @@ -362,19 +355,19 @@ static const IOleDocumentSiteVtbl OleDocumentSiteVtbl = { static HRESULT WINAPI ClDispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv) { DocHost *This = DISP_THIS(iface); - return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv); + return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv); } static ULONG WINAPI ClDispatch_AddRef(IDispatch *iface) { DocHost *This = DISP_THIS(iface); - return IOleClientSite_AddRef(CLIENTSITE(This)); + return IOleClientSite_AddRef(&This->IOleClientSite_iface); } static ULONG WINAPI ClDispatch_Release(IDispatch *iface) { DocHost *This = DISP_THIS(iface); - return IOleClientSite_Release(CLIENTSITE(This)); + return IOleClientSite_Release(&This->IOleClientSite_iface); } static HRESULT WINAPI ClDispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo) @@ -458,8 +451,6 @@ static HRESULT WINAPI ClDispatch_Invoke(IDispatch *iface, DISPID dispIdMember, R return E_NOTIMPL; } -#undef DISP_THIS - static const IDispatchVtbl DispatchVtbl = { ClDispatch_QueryInterface, ClDispatch_AddRef, @@ -476,19 +467,19 @@ static HRESULT WINAPI ClServiceProvider_QueryInterface(IServiceProvider *iface, void **ppv) { DocHost *This = SERVPROV_THIS(iface); - return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv); + return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv); } static ULONG WINAPI ClServiceProvider_AddRef(IServiceProvider *iface) { DocHost *This = SERVPROV_THIS(iface); - return IOleClientSite_AddRef(CLIENTSITE(This)); + return IOleClientSite_AddRef(&This->IOleClientSite_iface); } static ULONG WINAPI ClServiceProvider_Release(IServiceProvider *iface) { DocHost *This = SERVPROV_THIS(iface); - return IOleClientSite_Release(CLIENTSITE(This)); + return IOleClientSite_Release(&This->IOleClientSite_iface); } static HRESULT WINAPI ClServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService, @@ -506,8 +497,6 @@ static HRESULT WINAPI ClServiceProvider_QueryService(IServiceProvider *iface, RE return E_NOINTERFACE; } -#undef SERVPROV_THIS - static const IServiceProviderVtbl ServiceProviderVtbl = { ClServiceProvider_QueryInterface, ClServiceProvider_AddRef, @@ -517,7 +506,7 @@ static const IServiceProviderVtbl ServiceProviderVtbl = { void DocHost_ClientSite_Init(DocHost *This) { - This->lpOleClientSiteVtbl = &OleClientSiteVtbl; + This->IOleClientSite_iface.lpVtbl = &OleClientSiteVtbl; This->lpOleInPlaceSiteVtbl = &OleInPlaceSiteVtbl; This->lpOleDocumentSiteVtbl = &OleDocumentSiteVtbl; This->lpDispatchVtbl = &DispatchVtbl; diff --git a/dlls/shdocvw/dochost.c b/dlls/shdocvw/dochost.c index f74d06413ac..5c3d088ff3e 100644 --- a/dlls/shdocvw/dochost.c +++ b/dlls/shdocvw/dochost.c @@ -230,7 +230,7 @@ HRESULT dochost_object_available(DocHost *This, IUnknown *doc) TRACE("Got clsid %s\n", IsEqualGUID(&clsid, &CLSID_HTMLDocument) ? "CLSID_HTMLDocument" : debugstr_guid(&clsid)); - hres = IOleObject_SetClientSite(oleobj, CLIENTSITE(This)); + hres = IOleObject_SetClientSite(oleobj, &This->IOleClientSite_iface); if(FAILED(hres)) FIXME("SetClientSite failed: %08x\n", hres); @@ -367,7 +367,7 @@ void deactivate_document(DocHost *This) IOleObject_GetClientSite(oleobj, &client_site); if(client_site) { - if(client_site == CLIENTSITE(This)) + if(client_site == &This->IOleClientSite_iface) IOleObject_SetClientSite(oleobj, NULL); IOleClientSite_Release(client_site); } @@ -408,19 +408,19 @@ static HRESULT WINAPI ClOleCommandTarget_QueryInterface(IOleCommandTarget *iface REFIID riid, void **ppv) { DocHost *This = OLECMD_THIS(iface); - return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv); + return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv); } static ULONG WINAPI ClOleCommandTarget_AddRef(IOleCommandTarget *iface) { DocHost *This = OLECMD_THIS(iface); - return IOleClientSite_AddRef(CLIENTSITE(This)); + return IOleClientSite_AddRef(&This->IOleClientSite_iface); } static ULONG WINAPI ClOleCommandTarget_Release(IOleCommandTarget *iface) { DocHost *This = OLECMD_THIS(iface); - return IOleClientSite_Release(CLIENTSITE(This)); + return IOleClientSite_Release(&This->IOleClientSite_iface); } static HRESULT WINAPI ClOleCommandTarget_QueryStatus(IOleCommandTarget *iface, @@ -495,19 +495,19 @@ static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv) { DocHost *This = DOCHOSTUI_THIS(iface); - return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv); + return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv); } static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface) { DocHost *This = DOCHOSTUI_THIS(iface); - return IOleClientSite_AddRef(CLIENTSITE(This)); + return IOleClientSite_AddRef(&This->IOleClientSite_iface); } static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface) { DocHost *This = DOCHOSTUI_THIS(iface); - return IOleClientSite_Release(CLIENTSITE(This)); + return IOleClientSite_Release(&This->IOleClientSite_iface); } static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, @@ -728,19 +728,19 @@ static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *ifa REFIID riid, void **ppv) { DocHost *This = PROPNOTIF_THIS(iface); - return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv); + return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv); } static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface) { DocHost *This = PROPNOTIF_THIS(iface); - return IOleClientSite_AddRef(CLIENTSITE(This)); + return IOleClientSite_AddRef(&This->IOleClientSite_iface); } static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface) { DocHost *This = PROPNOTIF_THIS(iface); - return IOleClientSite_Release(CLIENTSITE(This)); + return IOleClientSite_Release(&This->IOleClientSite_iface); } static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID) diff --git a/dlls/shdocvw/frame.c b/dlls/shdocvw/frame.c index 2f089c12595..f0bd0c25833 100644 --- a/dlls/shdocvw/frame.c +++ b/dlls/shdocvw/frame.c @@ -56,13 +56,13 @@ static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface) { DocHost *This = INPLACEFRAME_THIS(iface); - return IOleClientSite_AddRef(CLIENTSITE(This)); + return IOleClientSite_AddRef(&This->IOleClientSite_iface); } static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface) { DocHost *This = INPLACEFRAME_THIS(iface); - return IOleClientSite_Release(CLIENTSITE(This)); + return IOleClientSite_Release(&This->IOleClientSite_iface); } static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd) diff --git a/dlls/shdocvw/navigate.c b/dlls/shdocvw/navigate.c index a160ee2b52e..8d3b539a2d4 100644 --- a/dlls/shdocvw/navigate.c +++ b/dlls/shdocvw/navigate.c @@ -178,7 +178,7 @@ static ULONG WINAPI BindStatusCallback_Release(IBindStatusCallback *iface) if(!ref) { if(This->doc_host) - IOleClientSite_Release(CLIENTSITE(This->doc_host)); + IOleClientSite_Release(&This->doc_host->IOleClientSite_iface); if(This->post_data) GlobalFree(This->post_data); SysFreeString(This->headers); @@ -254,7 +254,7 @@ static HRESULT WINAPI BindStatusCallback_OnStopBinding(IBindStatusCallback *ifac set_status_text(This, emptyW); if(This->doc_host) { - IOleClientSite_Release(CLIENTSITE(This->doc_host)); + IOleClientSite_Release(&This->doc_host->IOleClientSite_iface); This->doc_host = NULL; } @@ -390,7 +390,7 @@ static BindStatusCallback *create_callback(DocHost *doc_host, LPCWSTR url, PBYTE ret->headers = headers ? SysAllocString(headers) : NULL; ret->doc_host = doc_host; - IOleClientSite_AddRef(CLIENTSITE(doc_host)); + IOleClientSite_AddRef(&doc_host->IOleClientSite_iface); if(post_data) { ret->post_data = GlobalAlloc(0, post_data_len); @@ -546,7 +546,7 @@ static HRESULT bind_to_object(DocHost *This, IMoniker *mon, LPCWSTR url, IBindCt return hres; IBindCtx_RegisterObjectParam(bindctx, (LPOLESTR)SZ_HTML_CLIENTSITE_OBJECTPARAM, - (IUnknown*)CLIENTSITE(This)); + (IUnknown*)&This->IOleClientSite_iface); hres = IMoniker_BindToObject(mon, bindctx, NULL, &IID_IUnknown, (void**)&unk); if(SUCCEEDED(hres)) { diff --git a/dlls/shdocvw/shdocvw.h b/dlls/shdocvw/shdocvw.h index 34749188d25..0f647773ef3 100644 --- a/dlls/shdocvw/shdocvw.h +++ b/dlls/shdocvw/shdocvw.h @@ -93,7 +93,7 @@ typedef struct _IDocHostContainerVtbl } IDocHostContainerVtbl; struct DocHost { - const IOleClientSiteVtbl *lpOleClientSiteVtbl; + IOleClientSite IOleClientSite_iface; const IOleInPlaceSiteVtbl *lpOleInPlaceSiteVtbl; const IDocHostUIHandler2Vtbl *lpDocHostUIHandlerVtbl; const IOleDocumentSiteVtbl *lpOleDocumentSiteVtbl; @@ -197,7 +197,6 @@ struct InternetExplorer { #define CONPTCONT(x) ((IConnectionPointContainer*) &(x)->lpConnectionPointContainerVtbl) #define OLECMD(x) ((IOleCommandTarget*) &(x)->lpOleCommandTargetVtbl) -#define CLIENTSITE(x) ((IOleClientSite*) &(x)->lpOleClientSiteVtbl) #define INPLACESITE(x) ((IOleInPlaceSite*) &(x)->lpOleInPlaceSiteVtbl) #define DOCHOSTUI(x) ((IDocHostUIHandler*) &(x)->lpDocHostUIHandlerVtbl) #define DOCHOSTUI2(x) ((IDocHostUIHandler2*) &(x)->lpDocHostUIHandlerVtbl)