shdocvw: Move IOleDocumentSite to DocHost object.
This commit is contained in:
parent
ff7a8abb85
commit
72c5329336
|
@ -49,7 +49,7 @@ static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID ri
|
|||
*ppv = DOCHOSTUI2(This);
|
||||
}else if(IsEqualGUID(&IID_IOleDocumentSite, riid)) {
|
||||
TRACE("(%p)->(IID_IOleDocumentSite %p)\n", This, ppv);
|
||||
*ppv = DOCSITE(This->wb);
|
||||
*ppv = DOCSITE(This);
|
||||
}else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
|
||||
TRACE("(%p)->(IID_IOleCommandTarget %p)\n", This, ppv);
|
||||
*ppv = CLOLECMD(This->wb);
|
||||
|
@ -292,31 +292,31 @@ static const IOleInPlaceSiteVtbl OleInPlaceSiteVtbl = {
|
|||
InPlaceSite_OnPosRectChange
|
||||
};
|
||||
|
||||
#define DOCSITE_THIS(iface) DEFINE_THIS(WebBrowser, OleDocumentSite, iface)
|
||||
#define DOCSITE_THIS(iface) DEFINE_THIS(DocHost, OleDocumentSite, iface)
|
||||
|
||||
static HRESULT WINAPI OleDocumentSite_QueryInterface(IOleDocumentSite *iface,
|
||||
REFIID riid, void **ppv)
|
||||
{
|
||||
WebBrowser *This = DOCSITE_THIS(iface);
|
||||
return IOleClientSite_QueryInterface(CLIENTSITE(&This->doc_host), riid, ppv);
|
||||
DocHost *This = DOCSITE_THIS(iface);
|
||||
return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
|
||||
}
|
||||
|
||||
static ULONG WINAPI OleDocumentSite_AddRef(IOleDocumentSite *iface)
|
||||
{
|
||||
WebBrowser *This = DOCSITE_THIS(iface);
|
||||
return IOleClientSite_AddRef(CLIENTSITE(&This->doc_host));
|
||||
DocHost *This = DOCSITE_THIS(iface);
|
||||
return IOleClientSite_AddRef(CLIENTSITE(This));
|
||||
}
|
||||
|
||||
static ULONG WINAPI OleDocumentSite_Release(IOleDocumentSite *iface)
|
||||
{
|
||||
WebBrowser *This = DOCSITE_THIS(iface);
|
||||
return IOleClientSite_Release(CLIENTSITE(&This->doc_host));
|
||||
DocHost *This = DOCSITE_THIS(iface);
|
||||
return IOleClientSite_Release(CLIENTSITE(This));
|
||||
}
|
||||
|
||||
static HRESULT WINAPI OleDocumentSite_ActivateMe(IOleDocumentSite *iface,
|
||||
IOleDocumentView *pViewToActivate)
|
||||
{
|
||||
WebBrowser *This = DOCSITE_THIS(iface);
|
||||
DocHost *This = DOCSITE_THIS(iface);
|
||||
IOleDocument *oledoc;
|
||||
RECT rect;
|
||||
HRESULT hres;
|
||||
|
@ -327,10 +327,10 @@ static HRESULT WINAPI OleDocumentSite_ActivateMe(IOleDocumentSite *iface,
|
|||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
IOleDocument_CreateView(oledoc, INPLACESITE(&This->doc_host), NULL, 0, &This->view);
|
||||
IOleDocument_CreateView(oledoc, INPLACESITE(This), NULL, 0, &This->view);
|
||||
IOleDocument_Release(oledoc);
|
||||
|
||||
GetClientRect(This->doc_host.hwnd, &rect);
|
||||
GetClientRect(This->hwnd, &rect);
|
||||
IOleDocumentView_SetRect(This->view, &rect);
|
||||
|
||||
hres = IOleDocumentView_Show(This->view, TRUE);
|
||||
|
@ -468,17 +468,17 @@ void WebBrowser_ClientSite_Init(WebBrowser *This)
|
|||
{
|
||||
This->doc_host.lpOleClientSiteVtbl = &OleClientSiteVtbl;
|
||||
This->doc_host.lpOleInPlaceSiteVtbl = &OleInPlaceSiteVtbl;
|
||||
This->lpOleDocumentSiteVtbl = &OleDocumentSiteVtbl;
|
||||
This->doc_host.lpOleDocumentSiteVtbl = &OleDocumentSiteVtbl;
|
||||
This->lpDispatchVtbl = &DispatchVtbl;
|
||||
This->lpClServiceProviderVtbl = &ServiceProviderVtbl;
|
||||
|
||||
This->view = NULL;
|
||||
This->doc_host.view = NULL;
|
||||
|
||||
This->doc_host.wb = This;
|
||||
}
|
||||
|
||||
void WebBrowser_ClientSite_Destroy(WebBrowser *This)
|
||||
{
|
||||
if(This->view)
|
||||
IOleDocumentView_Release(This->view);
|
||||
if(This->doc_host.view)
|
||||
IOleDocumentView_Release(This->doc_host.view);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ static void navigate_complete(WebBrowser *This)
|
|||
VARIANT url;
|
||||
HRESULT hres;
|
||||
|
||||
hres = IUnknown_QueryInterface(This->document, &IID_IDispatch, (void**)&disp);
|
||||
hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IDispatch, (void**)&disp);
|
||||
if(FAILED(hres))
|
||||
FIXME("Could not get IDispatch interface\n");
|
||||
|
||||
|
@ -65,12 +65,12 @@ static LRESULT navigate2(WebBrowser *This)
|
|||
|
||||
TRACE("(%p)\n", This);
|
||||
|
||||
if(!This->document) {
|
||||
if(!This->doc_host.document) {
|
||||
WARN("document == NULL\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
hres = IUnknown_QueryInterface(This->document, &IID_IHlinkTarget, (void**)&hlink);
|
||||
hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IHlinkTarget, (void**)&hlink);
|
||||
if(FAILED(hres)) {
|
||||
FIXME("Could not get IHlinkTarget interface\n");
|
||||
return 0;
|
||||
|
@ -94,8 +94,8 @@ static LRESULT resize_document(WebBrowser *This, LONG width, LONG height)
|
|||
|
||||
TRACE("(%p)->(%ld %ld)\n", This, width, height);
|
||||
|
||||
if(This->view)
|
||||
IOleDocumentView_SetRect(This->view, &rect);
|
||||
if(This->doc_host.view)
|
||||
IOleDocumentView_SetRect(This->doc_host.view, &rect);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -161,29 +161,29 @@ void deactivate_document(WebBrowser *This)
|
|||
IHlinkTarget *hlink = NULL;
|
||||
HRESULT hres;
|
||||
|
||||
if(This->view)
|
||||
IOleDocumentView_UIActivate(This->view, FALSE);
|
||||
if(This->doc_host.view)
|
||||
IOleDocumentView_UIActivate(This->doc_host.view, FALSE);
|
||||
|
||||
hres = IUnknown_QueryInterface(This->document, &IID_IOleInPlaceObjectWindowless,
|
||||
hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IOleInPlaceObjectWindowless,
|
||||
(void**)&winobj);
|
||||
if(SUCCEEDED(hres)) {
|
||||
IOleInPlaceObjectWindowless_InPlaceDeactivate(winobj);
|
||||
IOleInPlaceObjectWindowless_Release(winobj);
|
||||
}
|
||||
|
||||
if(This->view) {
|
||||
IOleDocumentView_Show(This->view, FALSE);
|
||||
IOleDocumentView_CloseView(This->view, 0);
|
||||
IOleDocumentView_SetInPlaceSite(This->view, NULL);
|
||||
IOleDocumentView_Release(This->view);
|
||||
This->view = NULL;
|
||||
if(This->doc_host.view) {
|
||||
IOleDocumentView_Show(This->doc_host.view, FALSE);
|
||||
IOleDocumentView_CloseView(This->doc_host.view, 0);
|
||||
IOleDocumentView_SetInPlaceSite(This->doc_host.view, NULL);
|
||||
IOleDocumentView_Release(This->doc_host.view);
|
||||
This->doc_host.view = NULL;
|
||||
}
|
||||
|
||||
hres = IUnknown_QueryInterface(This->document, &IID_IOleObject, (void**)&oleobj);
|
||||
hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IOleObject, (void**)&oleobj);
|
||||
if(SUCCEEDED(hres))
|
||||
IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
|
||||
|
||||
hres = IUnknown_QueryInterface(This->document, &IID_IHlinkTarget, (void**)&hlink);
|
||||
hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IHlinkTarget, (void**)&hlink);
|
||||
if(SUCCEEDED(hres)) {
|
||||
IHlinkTarget_SetBrowseContext(hlink, NULL);
|
||||
IHlinkTarget_Release(hlink);
|
||||
|
@ -202,8 +202,8 @@ void deactivate_document(WebBrowser *This)
|
|||
IOleObject_Release(oleobj);
|
||||
}
|
||||
|
||||
IUnknown_Release(This->document);
|
||||
This->document = NULL;
|
||||
IUnknown_Release(This->doc_host.document);
|
||||
This->doc_host.document = NULL;
|
||||
}
|
||||
|
||||
#define OLECMD_THIS(iface) DEFINE_THIS(WebBrowser, ClOleCommandTarget, iface)
|
||||
|
@ -483,6 +483,7 @@ void WebBrowser_DocHost_Init(WebBrowser *This)
|
|||
This->doc_host.lpDocHostUIHandlerVtbl = &DocHostUIHandler2Vtbl;
|
||||
This->lpClOleCommandTargetVtbl = &OleCommandTargetVtbl;
|
||||
|
||||
This->doc_host.document = NULL;
|
||||
This->doc_host.hostui = NULL;
|
||||
|
||||
This->doc_host.hwnd = NULL;
|
||||
|
|
|
@ -400,19 +400,19 @@ static HRESULT navigate(WebBrowser *This, IMoniker *mon, IBindCtx *bindctx,
|
|||
* This should be fixed when mshtml.dll and urlmon.dll will be good enough.
|
||||
*/
|
||||
|
||||
if(This->document)
|
||||
if(This->doc_host.document)
|
||||
deactivate_document(This);
|
||||
|
||||
hres = CoCreateInstance(&CLSID_HTMLDocument, NULL,
|
||||
CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
|
||||
&IID_IUnknown, (void**)&This->document);
|
||||
&IID_IUnknown, (void**)&This->doc_host.document);
|
||||
|
||||
if(FAILED(hres)) {
|
||||
ERR("Could not create HTMLDocument: %08lx\n", hres);
|
||||
return hres;
|
||||
}
|
||||
|
||||
hres = IUnknown_QueryInterface(This->document, &IID_IPersistMoniker, (void**)&persist);
|
||||
hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IPersistMoniker, (void**)&persist);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
|
@ -428,7 +428,7 @@ static HRESULT navigate(WebBrowser *This, IMoniker *mon, IBindCtx *bindctx,
|
|||
return hres;
|
||||
}
|
||||
|
||||
hres = IUnknown_QueryInterface(This->document, &IID_IOleObject, (void**)&oleobj);
|
||||
hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IOleObject, (void**)&oleobj);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE
|
|||
IOleClientSite_Release(This->client);
|
||||
|
||||
if(!pClientSite) {
|
||||
if(This->document)
|
||||
if(This->doc_host.document)
|
||||
deactivate_document(This);
|
||||
This->client = NULL;
|
||||
return S_OK;
|
||||
|
|
|
@ -57,9 +57,12 @@ typedef struct {
|
|||
const IOleClientSiteVtbl *lpOleClientSiteVtbl;
|
||||
const IOleInPlaceSiteVtbl *lpOleInPlaceSiteVtbl;
|
||||
const IDocHostUIHandler2Vtbl *lpDocHostUIHandlerVtbl;
|
||||
const IOleDocumentSiteVtbl *lpOleDocumentSiteVtbl;
|
||||
|
||||
IDispatch *disp;
|
||||
|
||||
IUnknown *document;
|
||||
IOleDocumentView *view;
|
||||
IDocHostUIHandler *hostui;
|
||||
|
||||
HWND hwnd;
|
||||
|
@ -86,7 +89,6 @@ typedef struct WebBrowser {
|
|||
|
||||
/* Interfaces available for embeded document */
|
||||
|
||||
const IOleDocumentSiteVtbl *lpOleDocumentSiteVtbl;
|
||||
const IOleCommandTargetVtbl *lpClOleCommandTargetVtbl;
|
||||
const IDispatchVtbl *lpDispatchVtbl;
|
||||
const IServiceProviderVtbl *lpClServiceProviderVtbl;
|
||||
|
@ -97,11 +99,8 @@ typedef struct WebBrowser {
|
|||
|
||||
LONG ref;
|
||||
|
||||
IUnknown *document;
|
||||
|
||||
IOleClientSite *client;
|
||||
IOleContainer *container;
|
||||
IOleDocumentView *view;
|
||||
IOleInPlaceSite *inplace;
|
||||
|
||||
LPOLESTR url;
|
||||
|
|
|
@ -125,8 +125,8 @@ static ULONG WINAPI WebBrowser_Release(IWebBrowser2 *iface)
|
|||
TRACE("(%p) ref=%ld\n", This, ref);
|
||||
|
||||
if(!ref) {
|
||||
if(This->document)
|
||||
IUnknown_Release(This->document);
|
||||
if(This->doc_host.document)
|
||||
IUnknown_Release(This->doc_host.document);
|
||||
|
||||
WebBrowser_OleObject_Destroy(This);
|
||||
WebBrowser_Events_Destroy(This);
|
||||
|
@ -274,8 +274,8 @@ static HRESULT WINAPI WebBrowser_get_Document(IWebBrowser2 *iface, IDispatch **p
|
|||
TRACE("(%p)->(%p)\n", This, ppDisp);
|
||||
|
||||
*ppDisp = NULL;
|
||||
if(This->document)
|
||||
IUnknown_QueryInterface(This->document, &IID_IDispatch, (void**)ppDisp);
|
||||
if(This->doc_host.document)
|
||||
IUnknown_QueryInterface(This->doc_host.document, &IID_IDispatch, (void**)ppDisp);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -844,7 +844,6 @@ HRESULT WebBrowser_Create(IUnknown *pOuter, REFIID riid, void **ppv)
|
|||
ret->lpWebBrowser2Vtbl = &WebBrowser2Vtbl;
|
||||
ret->ref = 0;
|
||||
|
||||
ret->document = NULL;
|
||||
ret->url = NULL;
|
||||
|
||||
ret->doc_host.disp = (IDispatch*)WEBBROWSER2(ret);
|
||||
|
|
Loading…
Reference in New Issue