Commit 61560b87 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

shdocvw: Move connection points to DocHost object.

parent 22b6d548
...@@ -475,8 +475,8 @@ void DocHost_ClientSite_Init(DocHost *This) ...@@ -475,8 +475,8 @@ void DocHost_ClientSite_Init(DocHost *This)
This->view = NULL; This->view = NULL;
} }
void WebBrowser_ClientSite_Destroy(WebBrowser *This) void DocHost_ClientSite_Release(DocHost *This)
{ {
if(This->doc_host.view) if(This->view)
IOleDocumentView_Release(This->doc_host.view); IOleDocumentView_Release(This->view);
} }
...@@ -51,8 +51,8 @@ static void navigate_complete(WebBrowser *This) ...@@ -51,8 +51,8 @@ static void navigate_complete(WebBrowser *This)
V_VT(&url) = VT_BSTR; V_VT(&url) = VT_BSTR;
V_BSTR(&url) = This->url; V_BSTR(&url) = This->url;
call_sink(This->cp_wbe2, DISPID_NAVIGATECOMPLETE2, &dispparams); call_sink(This->doc_host.cp_wbe2, DISPID_NAVIGATECOMPLETE2, &dispparams);
call_sink(This->cp_wbe2, DISPID_DOCUMENTCOMPLETE, &dispparams); call_sink(This->doc_host.cp_wbe2, DISPID_DOCUMENTCOMPLETE, &dispparams);
if(disp) if(disp)
IDispatch_Release(disp); IDispatch_Release(disp);
...@@ -491,4 +491,11 @@ void DocHost_Init(DocHost *This) ...@@ -491,4 +491,11 @@ void DocHost_Init(DocHost *This)
DocHost_ClientSite_Init(This); DocHost_ClientSite_Init(This);
DocHost_Frame_Init(This); DocHost_Frame_Init(This);
DocHost_Events_Init(This);
}
void DocHost_Release(DocHost *This)
{
DocHost_ClientSite_Release(This);
DocHost_Events_Release(This);
} }
...@@ -30,7 +30,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(shdocvw); ...@@ -30,7 +30,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
struct ConnectionPoint { struct ConnectionPoint {
const IConnectionPointVtbl *lpConnectionPointVtbl; const IConnectionPointVtbl *lpConnectionPointVtbl;
WebBrowser *webbrowser; DocHost *doc_host;
IConnectionPointContainer *container;
IDispatch **sinks; IDispatch **sinks;
DWORD sinks_size; DWORD sinks_size;
...@@ -87,13 +88,13 @@ static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPo ...@@ -87,13 +88,13 @@ static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPo
if(IsEqualGUID(&DIID_DWebBrowserEvents2, riid)) { if(IsEqualGUID(&DIID_DWebBrowserEvents2, riid)) {
TRACE("(%p)->(DIID_DWebBrowserEvents2 %p)\n", This, ppCP); TRACE("(%p)->(DIID_DWebBrowserEvents2 %p)\n", This, ppCP);
*ppCP = CONPOINT(This->cp_wbe2); *ppCP = CONPOINT(This->doc_host.cp_wbe2);
}else if(IsEqualGUID(&DIID_DWebBrowserEvents, riid)) { }else if(IsEqualGUID(&DIID_DWebBrowserEvents, riid)) {
TRACE("(%p)->(DIID_DWebBrowserEvents %p)\n", This, ppCP); TRACE("(%p)->(DIID_DWebBrowserEvents %p)\n", This, ppCP);
*ppCP = CONPOINT(This->cp_wbe); *ppCP = CONPOINT(This->doc_host.cp_wbe);
}else if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) { }else if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
TRACE("(%p)->(IID_IPropertyNotifySink %p)\n", This, ppCP); TRACE("(%p)->(IID_IPropertyNotifySink %p)\n", This, ppCP);
*ppCP = CONPOINT(This->cp_pns); *ppCP = CONPOINT(This->doc_host.cp_pns);
} }
if(*ppCP) { if(*ppCP) {
...@@ -139,7 +140,7 @@ static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface, ...@@ -139,7 +140,7 @@ static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface,
} }
if(*ppv) { if(*ppv) {
IWebBrowser2_AddRef(WEBBROWSER(This->webbrowser)); IOleClientSite_AddRef(CLIENTSITE(This->doc_host));
return S_OK; return S_OK;
} }
...@@ -150,13 +151,13 @@ static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface, ...@@ -150,13 +151,13 @@ static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface,
static ULONG WINAPI ConnectionPoint_AddRef(IConnectionPoint *iface) static ULONG WINAPI ConnectionPoint_AddRef(IConnectionPoint *iface)
{ {
ConnectionPoint *This = CONPOINT_THIS(iface); ConnectionPoint *This = CONPOINT_THIS(iface);
return IWebBrowser2_AddRef(WEBBROWSER(This->webbrowser)); return IOleClientSite_AddRef(CLIENTSITE(This->doc_host));
} }
static ULONG WINAPI ConnectionPoint_Release(IConnectionPoint *iface) static ULONG WINAPI ConnectionPoint_Release(IConnectionPoint *iface)
{ {
ConnectionPoint *This = CONPOINT_THIS(iface); ConnectionPoint *This = CONPOINT_THIS(iface);
return IWebBrowser2_Release(WEBBROWSER(This->webbrowser)); return IOleClientSite_Release(CLIENTSITE(This->doc_host));
} }
static HRESULT WINAPI ConnectionPoint_GetConnectionInterface(IConnectionPoint *iface, IID *pIID) static HRESULT WINAPI ConnectionPoint_GetConnectionInterface(IConnectionPoint *iface, IID *pIID)
...@@ -176,8 +177,8 @@ static HRESULT WINAPI ConnectionPoint_GetConnectionPointContainer(IConnectionPoi ...@@ -176,8 +177,8 @@ static HRESULT WINAPI ConnectionPoint_GetConnectionPointContainer(IConnectionPoi
TRACE("(%p)->(%p)\n", This, ppCPC); TRACE("(%p)->(%p)\n", This, ppCPC);
*ppCPC = CONPTCONT(This->webbrowser); *ppCPC = This->container;
IConnectionPointContainer_AddRef(CONPTCONT(This->webbrowser)); IConnectionPointContainer_AddRef(This->container);
return S_OK; return S_OK;
} }
...@@ -267,15 +268,16 @@ void call_sink(ConnectionPoint *This, DISPID dispid, DISPPARAMS *dispparams) ...@@ -267,15 +268,16 @@ void call_sink(ConnectionPoint *This, DISPID dispid, DISPPARAMS *dispparams)
} }
} }
static void ConnectionPoint_Create(WebBrowser *wb, REFIID riid, ConnectionPoint **cp) static void ConnectionPoint_Create(DocHost *doc_host, REFIID riid, ConnectionPoint **cp)
{ {
ConnectionPoint *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(ConnectionPoint)); ConnectionPoint *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(ConnectionPoint));
ret->lpConnectionPointVtbl = &ConnectionPointVtbl; ret->lpConnectionPointVtbl = &ConnectionPointVtbl;
ret->webbrowser = wb;
ret->doc_host = doc_host;
ret->sinks = NULL; ret->sinks = NULL;
ret->sinks_size = 0; ret->sinks_size = 0;
ret->container = NULL;
memcpy(&ret->iid, riid, sizeof(IID)); memcpy(&ret->iid, riid, sizeof(IID));
...@@ -295,18 +297,25 @@ static void ConnectionPoint_Destroy(ConnectionPoint *This) ...@@ -295,18 +297,25 @@ static void ConnectionPoint_Destroy(ConnectionPoint *This)
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
void WebBrowser_Events_Init(WebBrowser *This) void DocHost_Events_Init(DocHost *This)
{ {
This->lpConnectionPointContainerVtbl = &ConnectionPointContainerVtbl;
ConnectionPoint_Create(This, &DIID_DWebBrowserEvents2, &This->cp_wbe2); ConnectionPoint_Create(This, &DIID_DWebBrowserEvents2, &This->cp_wbe2);
ConnectionPoint_Create(This, &DIID_DWebBrowserEvents, &This->cp_wbe); ConnectionPoint_Create(This, &DIID_DWebBrowserEvents, &This->cp_wbe);
ConnectionPoint_Create(This, &IID_IPropertyNotifySink, &This->cp_pns); ConnectionPoint_Create(This, &IID_IPropertyNotifySink, &This->cp_pns);
} }
void WebBrowser_Events_Destroy(WebBrowser *This) void DocHost_Events_Release(DocHost *This)
{ {
ConnectionPoint_Destroy(This->cp_wbe2); ConnectionPoint_Destroy(This->cp_wbe2);
ConnectionPoint_Destroy(This->cp_wbe); ConnectionPoint_Destroy(This->cp_wbe);
ConnectionPoint_Destroy(This->cp_pns); ConnectionPoint_Destroy(This->cp_pns);
} }
void WebBrowser_Events_Init(WebBrowser *This)
{
This->lpConnectionPointContainerVtbl = &ConnectionPointContainerVtbl;
This->doc_host.cp_wbe2->container = CONPTCONT(This);
This->doc_host.cp_wbe->container = CONPTCONT(This);
This->doc_host.cp_pns->container = CONPTCONT(This);
}
...@@ -371,7 +371,7 @@ static void on_before_navigate2(WebBrowser *This, LPWSTR url, PBYTE post_data, U ...@@ -371,7 +371,7 @@ static void on_before_navigate2(WebBrowser *This, LPWSTR url, PBYTE post_data, U
V_VT(params+6) = (VT_DISPATCH); V_VT(params+6) = (VT_DISPATCH);
V_DISPATCH(params+6) = (IDispatch*)WEBBROWSER2(This); V_DISPATCH(params+6) = (IDispatch*)WEBBROWSER2(This);
call_sink(This->cp_wbe2, DISPID_BEFORENAVIGATE2, &dispparams); call_sink(This->doc_host.cp_wbe2, DISPID_BEFORENAVIGATE2, &dispparams);
SysFreeString(V_BSTR(&var_url)); SysFreeString(V_BSTR(&var_url));
if(post_data_len) if(post_data_len)
......
...@@ -73,6 +73,12 @@ typedef struct { ...@@ -73,6 +73,12 @@ typedef struct {
HWND hwnd; HWND hwnd;
HWND frame_hwnd; HWND frame_hwnd;
/* Connection points */
ConnectionPoint *cp_wbe2;
ConnectionPoint *cp_wbe;
ConnectionPoint *cp_pns;
} DocHost; } DocHost;
typedef struct WebBrowser { typedef struct WebBrowser {
...@@ -111,12 +117,6 @@ typedef struct WebBrowser { ...@@ -111,12 +117,6 @@ typedef struct WebBrowser {
HWND shell_embedding_hwnd; HWND shell_embedding_hwnd;
/* Connection points */
ConnectionPoint *cp_wbe2;
ConnectionPoint *cp_wbe;
ConnectionPoint *cp_pns;
DocHost doc_host; DocHost doc_host;
} WebBrowser; } WebBrowser;
...@@ -153,14 +153,16 @@ void WebBrowser_ClassInfo_Init(WebBrowser*); ...@@ -153,14 +153,16 @@ void WebBrowser_ClassInfo_Init(WebBrowser*);
void WebBrowser_Events_Init(WebBrowser*); void WebBrowser_Events_Init(WebBrowser*);
void WebBrowser_HlinkFrame_Init(WebBrowser*); void WebBrowser_HlinkFrame_Init(WebBrowser*);
void WebBrowser_OleObject_Destroy(WebBrowser*);
void DocHost_Init(DocHost*); void DocHost_Init(DocHost*);
void DocHost_ClientSite_Init(DocHost*); void DocHost_ClientSite_Init(DocHost*);
void DocHost_Events_Init(DocHost*);
void DocHost_Frame_Init(DocHost*); void DocHost_Frame_Init(DocHost*);
void WebBrowser_OleObject_Destroy(WebBrowser*); void DocHost_Release(DocHost*);
void WebBrowser_Events_Destroy(WebBrowser*); void DocHost_ClientSite_Release(DocHost*);
void WebBrowser_ClientSite_Destroy(WebBrowser*); void DocHost_Events_Release(DocHost*);
HRESULT WebBrowser_Create(IUnknown*,REFIID,void**); HRESULT WebBrowser_Create(IUnknown*,REFIID,void**);
......
...@@ -128,9 +128,9 @@ static ULONG WINAPI WebBrowser_Release(IWebBrowser2 *iface) ...@@ -128,9 +128,9 @@ static ULONG WINAPI WebBrowser_Release(IWebBrowser2 *iface)
if(This->doc_host.document) if(This->doc_host.document)
IUnknown_Release(This->doc_host.document); IUnknown_Release(This->doc_host.document);
DocHost_Release(&This->doc_host);
WebBrowser_OleObject_Destroy(This); WebBrowser_OleObject_Destroy(This);
WebBrowser_Events_Destroy(This);
WebBrowser_ClientSite_Destroy(This);
SysFreeString(This->url); SysFreeString(This->url);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment