mshtml: Store connection point as a list.

This commit is contained in:
Jacek Caban 2007-06-29 02:48:50 +02:00 committed by Alexandre Julliard
parent fb16633d6f
commit fc4fd71e01
3 changed files with 27 additions and 18 deletions

View File

@ -184,13 +184,17 @@ static const IConnectionPointVtbl ConnectionPointVtbl =
ConnectionPoint_EnumConnections ConnectionPoint_EnumConnections
}; };
static void ConnectionPoint_Init(HTMLDocument *doc, REFIID riid, ConnectionPoint *cp) void ConnectionPoint_Init(ConnectionPoint *cp, HTMLDocument *doc, REFIID riid, ConnectionPoint *prev)
{ {
cp->lpConnectionPointVtbl = &ConnectionPointVtbl; cp->lpConnectionPointVtbl = &ConnectionPointVtbl;
cp->doc = doc; cp->doc = doc;
cp->sinks = NULL; cp->sinks = NULL;
cp->sinks_size = 0; cp->sinks_size = 0;
cp->iid = *riid; cp->iid = *riid;
cp->next = NULL;
if(prev)
prev->next = cp;
} }
static void ConnectionPoint_Destroy(ConnectionPoint *This) static void ConnectionPoint_Destroy(ConnectionPoint *This)
@ -238,18 +242,15 @@ static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPo
REFIID riid, IConnectionPoint **ppCP) REFIID riid, IConnectionPoint **ppCP)
{ {
HTMLDocument *This = CONPTCONT_THIS(iface); HTMLDocument *This = CONPTCONT_THIS(iface);
ConnectionPoint *iter;
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppCP);
*ppCP = NULL; *ppCP = NULL;
if(IsEqualGUID(&DIID_HTMLDocumentEvents, riid)) { for(iter = &This->cp_propnotif; iter; iter = iter->next) {
TRACE("(%p)->(DIID_HTMLDocumentEvents %p)\n", This, ppCP); if(IsEqualGUID(&iter->iid, riid))
*ppCP = CONPOINT(&This->cp_htmldocevents); *ppCP = CONPOINT(iter);
}else if(IsEqualGUID(&DIID_HTMLDocumentEvents2, riid)) {
TRACE("(%p)->(DIID_HTMLDocumentEvents2 %p)\n", This, ppCP);
*ppCP = CONPOINT(&This->cp_htmldocevents2);
}else if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
TRACE("(%p)->(IID_IPropertyNotifySink %p)\n", This, ppCP);
*ppCP = CONPOINT(&This->cp_propnotif);
} }
if(*ppCP) { if(*ppCP) {
@ -257,7 +258,7 @@ static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPo
return S_OK; return S_OK;
} }
FIXME("(%p)->(%s %p) unsupported riid\n", This, debugstr_guid(riid), ppCP); FIXME("unsupported riid %s\n", debugstr_guid(riid));
return CONNECT_E_NOCONNECTION; return CONNECT_E_NOCONNECTION;
} }
@ -274,15 +275,14 @@ static const IConnectionPointContainerVtbl ConnectionPointContainerVtbl = {
void HTMLDocument_ConnectionPoints_Init(HTMLDocument *This) void HTMLDocument_ConnectionPoints_Init(HTMLDocument *This)
{ {
This->lpConnectionPointContainerVtbl = &ConnectionPointContainerVtbl; This->lpConnectionPointContainerVtbl = &ConnectionPointContainerVtbl;
ConnectionPoint_Init(This, &IID_IPropertyNotifySink, &This->cp_propnotif);
ConnectionPoint_Init(This, &DIID_HTMLDocumentEvents, &This->cp_htmldocevents);
ConnectionPoint_Init(This, &DIID_HTMLDocumentEvents2, &This->cp_htmldocevents2);
} }
void HTMLDocument_ConnectionPoints_Destroy(HTMLDocument *This) void HTMLDocument_ConnectionPoints_Destroy(HTMLDocument *This)
{ {
ConnectionPoint_Destroy(&This->cp_propnotif); ConnectionPoint *iter = &This->cp_propnotif;
ConnectionPoint_Destroy(&This->cp_htmldocevents);
ConnectionPoint_Destroy(&This->cp_htmldocevents2); while(iter) {
ConnectionPoint_Destroy(iter);
iter = iter->next;
}
} }

View File

@ -1143,6 +1143,11 @@ HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
HTMLDocument_Hlink_Init(ret); HTMLDocument_Hlink_Init(ret);
HTMLDocument_ConnectionPoints_Init(ret); HTMLDocument_ConnectionPoints_Init(ret);
ConnectionPoint_Init(&ret->cp_propnotif, ret, &IID_IPropertyNotifySink, NULL);
ConnectionPoint_Init(&ret->cp_htmldocevents, ret, &DIID_HTMLDocumentEvents, &ret->cp_propnotif);
ConnectionPoint_Init(&ret->cp_htmldocevents2, ret, &DIID_HTMLDocumentEvents2,
&ret->cp_htmldocevents);
ret->nscontainer = NSContainer_Create(ret, NULL); ret->nscontainer = NSContainer_Create(ret, NULL);
ret->window = HTMLWindow_Create(ret); ret->window = HTMLWindow_Create(ret);

View File

@ -84,6 +84,8 @@ struct ConnectionPoint {
DWORD sinks_size; DWORD sinks_size;
IID iid; IID iid;
ConnectionPoint *next;
}; };
struct HTMLDocument { struct HTMLDocument {
@ -340,6 +342,8 @@ void HTMLDocument_ConnectionPoints_Init(HTMLDocument*);
void HTMLDocument_ConnectionPoints_Destroy(HTMLDocument*); void HTMLDocument_ConnectionPoints_Destroy(HTMLDocument*);
void ConnectionPoint_Init(ConnectionPoint*,HTMLDocument*,REFIID,ConnectionPoint*);
NSContainer *NSContainer_Create(HTMLDocument*,NSContainer*); NSContainer *NSContainer_Create(HTMLDocument*,NSContainer*);
void NSContainer_Release(NSContainer*); void NSContainer_Release(NSContainer*);