shdocvw: Move IOleClientSite to new DocHost object to allow sharing

code between WebBrowser and InternetExplorer.
This commit is contained in:
Jacek Caban 2006-04-18 00:24:59 +02:00 committed by Alexandre Julliard
parent 02a9bc0094
commit 2dab3d4c1b
5 changed files with 59 additions and 44 deletions

View File

@ -21,11 +21,11 @@
WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
#define CLIENTSITE_THIS(iface) DEFINE_THIS(WebBrowser, OleClientSite, iface)
#define CLIENTSITE_THIS(iface) DEFINE_THIS(DocHost, OleClientSite, iface)
static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
{
WebBrowser *This = CLIENTSITE_THIS(iface);
DocHost *This = CLIENTSITE_THIS(iface);
*ppv = NULL;
@ -37,32 +37,32 @@ static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID ri
*ppv = CLIENTSITE(This);
}else if(IsEqualGUID(&IID_IOleWindow, riid)) {
TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
*ppv = INPLACESITE(This);
*ppv = INPLACESITE(This->wb);
}else if(IsEqualGUID(&IID_IOleInPlaceSite, riid)) {
TRACE("(%p)->(IID_IOleInPlaceSite %p)\n", This, ppv);
*ppv = INPLACESITE(This);
*ppv = INPLACESITE(This->wb);
}else if(IsEqualGUID(&IID_IDocHostUIHandler, riid)) {
TRACE("(%p)->(IID_IDocHostUIHandler %p)\n", This, ppv);
*ppv = DOCHOSTUI(This);
*ppv = DOCHOSTUI(This->wb);
}else if(IsEqualGUID(&IID_IDocHostUIHandler2, riid)) {
TRACE("(%p)->(IID_IDocHostUIHandler2 %p)\n", This, ppv);
*ppv = DOCHOSTUI2(This);
*ppv = DOCHOSTUI2(This->wb);
}else if(IsEqualGUID(&IID_IOleDocumentSite, riid)) {
TRACE("(%p)->(IID_IOleDocumentSite %p)\n", This, ppv);
*ppv = DOCSITE(This);
}else if(IsEqualGUID(&IID_IOleClientSite, riid)) {
TRACE("(%p)->(IID_IOleClientSite %p)\n", This, ppv);
*ppv = CLOLECMD(This);
*ppv = DOCSITE(This->wb);
}else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
TRACE("(%p)->(IID_IOleCommandTarget %p)\n", This, ppv);
*ppv = CLOLECMD(This->wb);
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
*ppv = CLDISP(This);
*ppv = CLDISP(This->wb);
}else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
*ppv = CLSERVPROV(This);
*ppv = CLSERVPROV(This->wb);
}
if(*ppv) {
IWebBrowser2_AddRef(WEBBROWSER(This));
IOleClientSite_AddRef(CLIENTSITE(This));
return S_OK;
}
@ -73,19 +73,19 @@ static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID ri
static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
{
WebBrowser *This = CLIENTSITE_THIS(iface);
return IWebBrowser2_AddRef(WEBBROWSER(This));
DocHost *This = CLIENTSITE_THIS(iface);
return IDispatch_AddRef(This->disp);
}
static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
{
WebBrowser *This = CLIENTSITE_THIS(iface);
return IWebBrowser2_Release(WEBBROWSER(This));
DocHost *This = CLIENTSITE_THIS(iface);
return IDispatch_Release(This->disp);
}
static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
{
WebBrowser *This = CLIENTSITE_THIS(iface);
DocHost *This = CLIENTSITE_THIS(iface);
FIXME("(%p)\n", This);
return E_NOTIMPL;
}
@ -93,35 +93,35 @@ static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign,
DWORD dwWhichMoniker, IMoniker **ppmk)
{
WebBrowser *This = CLIENTSITE_THIS(iface);
DocHost *This = CLIENTSITE_THIS(iface);
FIXME("(%p)->(%ld %ld %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
return E_NOTIMPL;
}
static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
{
WebBrowser *This = CLIENTSITE_THIS(iface);
DocHost *This = CLIENTSITE_THIS(iface);
FIXME("(%p)->(%p)\n", This, ppContainer);
return E_NOTIMPL;
}
static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
{
WebBrowser *This = CLIENTSITE_THIS(iface);
DocHost *This = CLIENTSITE_THIS(iface);
FIXME("(%p)\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
{
WebBrowser *This = CLIENTSITE_THIS(iface);
DocHost *This = CLIENTSITE_THIS(iface);
FIXME("(%p)->(%x)\n", This, fShow);
return E_NOTIMPL;
}
static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
{
WebBrowser *This = CLIENTSITE_THIS(iface);
DocHost *This = CLIENTSITE_THIS(iface);
FIXME("(%p)\n", This);
return E_NOTIMPL;
}
@ -145,19 +145,19 @@ static const IOleClientSiteVtbl OleClientSiteVtbl = {
static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppv)
{
WebBrowser *This = INPLACESITE_THIS(iface);
return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
return IOleClientSite_QueryInterface(CLIENTSITE(&This->doc_host), riid, ppv);
}
static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSite *iface)
{
WebBrowser *This = INPLACESITE_THIS(iface);
return IOleClientSite_AddRef(CLIENTSITE(This));
return IOleClientSite_AddRef(CLIENTSITE(&This->doc_host));
}
static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSite *iface)
{
WebBrowser *This = INPLACESITE_THIS(iface);
return IOleClientSite_Release(CLIENTSITE(This));
return IOleClientSite_Release(CLIENTSITE(&This->doc_host));
}
static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSite *iface, HWND *phwnd)
@ -298,19 +298,19 @@ static HRESULT WINAPI OleDocumentSite_QueryInterface(IOleDocumentSite *iface,
REFIID riid, void **ppv)
{
WebBrowser *This = DOCSITE_THIS(iface);
return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
return IOleClientSite_QueryInterface(CLIENTSITE(&This->doc_host), riid, ppv);
}
static ULONG WINAPI OleDocumentSite_AddRef(IOleDocumentSite *iface)
{
WebBrowser *This = DOCSITE_THIS(iface);
return IOleClientSite_AddRef(CLIENTSITE(This));
return IOleClientSite_AddRef(CLIENTSITE(&This->doc_host));
}
static ULONG WINAPI OleDocumentSite_Release(IOleDocumentSite *iface)
{
WebBrowser *This = DOCSITE_THIS(iface);
return IOleClientSite_Release(CLIENTSITE(This));
return IOleClientSite_Release(CLIENTSITE(&This->doc_host));
}
static HRESULT WINAPI OleDocumentSite_ActivateMe(IOleDocumentSite *iface,
@ -352,19 +352,19 @@ static const IOleDocumentSiteVtbl OleDocumentSiteVtbl = {
static HRESULT WINAPI ClDispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
{
WebBrowser *This = DISP_THIS(iface);
return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
return IOleClientSite_QueryInterface(CLIENTSITE(&This->doc_host), riid, ppv);
}
static ULONG WINAPI ClDispatch_AddRef(IDispatch *iface)
{
WebBrowser *This = DISP_THIS(iface);
return IWebBrowser2_AddRef(WEBBROWSER(This));
return IOleClientSite_AddRef(CLIENTSITE(&This->doc_host));
}
static ULONG WINAPI ClDispatch_Release(IDispatch *iface)
{
WebBrowser *This = DISP_THIS(iface);
return IWebBrowser2_Release(WEBBROWSER(This));
return IOleClientSite_Release(CLIENTSITE(&This->doc_host));
}
static HRESULT WINAPI ClDispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
@ -425,19 +425,19 @@ static HRESULT WINAPI ClServiceProvider_QueryInterface(IServiceProvider *iface,
void **ppv)
{
WebBrowser *This = SERVPROV_THIS(iface);
return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
return IOleClientSite_QueryInterface(CLIENTSITE(&This->doc_host), riid, ppv);
}
static ULONG WINAPI ClServiceProvider_AddRef(IServiceProvider *iface)
{
WebBrowser *This = SERVPROV_THIS(iface);
return IWebBrowser2_AddRef(WEBBROWSER2(This));
return IOleClientSite_AddRef(CLIENTSITE(&This->doc_host));
}
static ULONG WINAPI ClServiceProvider_Release(IServiceProvider *iface)
{
WebBrowser *This = SERVPROV_THIS(iface);
return IWebBrowser2_Release(WEBBROWSER2(This));
return IOleClientSite_Release(CLIENTSITE(&This->doc_host));
}
static HRESULT WINAPI ClServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
@ -466,13 +466,15 @@ static const IServiceProviderVtbl ServiceProviderVtbl = {
void WebBrowser_ClientSite_Init(WebBrowser *This)
{
This->lpOleClientSiteVtbl = &OleClientSiteVtbl;
This->doc_host.lpOleClientSiteVtbl = &OleClientSiteVtbl;
This->lpOleInPlaceSiteVtbl = &OleInPlaceSiteVtbl;
This->lpOleDocumentSiteVtbl = &OleDocumentSiteVtbl;
This->lpDispatchVtbl = &DispatchVtbl;
This->lpClServiceProviderVtbl = &ServiceProviderVtbl;
This->view = NULL;
This->doc_host.wb = This;
}
void WebBrowser_ClientSite_Destroy(WebBrowser *This)

View File

@ -194,7 +194,7 @@ void deactivate_document(WebBrowser *This)
IOleObject_GetClientSite(oleobj, &client_site);
if(client_site) {
if(client_site == CLIENTSITE(This))
if(client_site == CLIENTSITE(&This->doc_host))
IOleObject_SetClientSite(oleobj, NULL);
IOleClientSite_Release(client_site);
}
@ -212,7 +212,7 @@ static HRESULT WINAPI ClOleCommandTarget_QueryInterface(IOleCommandTarget *iface
REFIID riid, void **ppv)
{
WebBrowser *This = OLECMD_THIS(iface);
return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
return IOleClientSite_QueryInterface(CLIENTSITE(&This->doc_host), riid, ppv);
}
static ULONG WINAPI ClOleCommandTarget_AddRef(IOleCommandTarget *iface)
@ -262,19 +262,19 @@ static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface,
REFIID riid, void **ppv)
{
WebBrowser *This = DOCHOSTUI_THIS(iface);
return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
return IOleClientSite_QueryInterface(CLIENTSITE(&This->doc_host), riid, ppv);
}
static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
{
WebBrowser *This = DOCHOSTUI_THIS(iface);
return IOleClientSite_AddRef(CLIENTSITE(This));
return IOleClientSite_AddRef(CLIENTSITE(&This->doc_host));
}
static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
{
WebBrowser *This = DOCHOSTUI_THIS(iface);
return IOleClientSite_Release(CLIENTSITE(This));
return IOleClientSite_Release(CLIENTSITE(&This->doc_host));
}
static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface,

View File

@ -392,7 +392,7 @@ static HRESULT navigate(WebBrowser *This, IMoniker *mon, IBindCtx *bindctx,
}
IBindCtx_RegisterObjectParam(bindctx, (LPOLESTR)SZ_HTML_CLIENTSITE_OBJECTPARAM,
(IUnknown*)CLIENTSITE(This));
(IUnknown*)CLIENTSITE(&This->doc_host));
/*
* FIXME:
@ -432,7 +432,7 @@ static HRESULT navigate(WebBrowser *This, IMoniker *mon, IBindCtx *bindctx,
if(FAILED(hres))
return hres;
hres = IOleObject_SetClientSite(oleobj, CLIENTSITE(This));
hres = IOleObject_SetClientSite(oleobj, CLIENTSITE(&This->doc_host));
IOleObject_Release(oleobj);
PostMessageW(This->doc_view_hwnd, WB_WM_NAVIGATE2, 0, 0);

View File

@ -51,7 +51,17 @@ extern HRESULT SHDOCVW_GetShellInstanceObjectClassObject(REFCLSID rclsid,
typedef struct ConnectionPoint ConnectionPoint;
struct WebBrowser;
typedef struct {
const IOleClientSiteVtbl *lpOleClientSiteVtbl;
IDispatch *disp;
struct WebBrowser *wb; /* FIXME */
} DocHost;
typedef struct WebBrowser {
/* Interfaces available via WebBrowser object */
const IWebBrowser2Vtbl *lpWebBrowser2Vtbl;
@ -69,7 +79,6 @@ typedef struct {
/* Interfaces available for embeded document */
const IOleClientSiteVtbl *lpOleClientSiteVtbl;
const IOleInPlaceSiteVtbl *lpOleInPlaceSiteVtbl;
const IDocHostUIHandler2Vtbl *lpDocHostUIHandlerVtbl;
const IOleDocumentSiteVtbl *lpOleDocumentSiteVtbl;
@ -111,6 +120,8 @@ typedef struct {
ConnectionPoint *cp_wbe2;
ConnectionPoint *cp_wbe;
ConnectionPoint *cp_pns;
DocHost doc_host;
} WebBrowser;
#define WEBBROWSER(x) ((IWebBrowser*) &(x)->lpWebBrowser2Vtbl)

View File

@ -847,6 +847,8 @@ HRESULT WebBrowser_Create(IUnknown *pOuter, REFIID riid, void **ppv)
ret->document = NULL;
ret->url = NULL;
ret->doc_host.disp = (IDispatch*)WEBBROWSER2(ret);
WebBrowser_OleObject_Init(ret);
WebBrowser_ViewObject_Init(ret);
WebBrowser_Persist_Init(ret);