mshtml: Added IHTMLEventObj::get_altKey implementation.

This commit is contained in:
Jacek Caban 2009-09-06 18:55:25 +02:00 committed by Alexandre Julliard
parent 145d53e2ac
commit 461b3768d2
3 changed files with 38 additions and 8 deletions

View File

@ -129,6 +129,7 @@ typedef struct {
HTMLDOMNode *target; HTMLDOMNode *target;
const event_info_t *type; const event_info_t *type;
nsIDOMEvent *nsevent;
} HTMLEventObj; } HTMLEventObj;
#define HTMLEVENTOBJ(x) ((IHTMLEventObj*) &(x)->lpIHTMLEventObjVtbl) #define HTMLEVENTOBJ(x) ((IHTMLEventObj*) &(x)->lpIHTMLEventObjVtbl)
@ -178,6 +179,8 @@ static ULONG WINAPI HTMLEventObj_Release(IHTMLEventObj *iface)
TRACE("(%p) ref=%d\n", This, ref); TRACE("(%p) ref=%d\n", This, ref);
if(!ref) { if(!ref) {
if(This->nsevent)
nsIDOMEvent_Release(This->nsevent);
release_dispex(&This->dispex); release_dispex(&This->dispex);
heap_free(This); heap_free(This);
} }
@ -232,8 +235,31 @@ static HRESULT WINAPI HTMLEventObj_get_srcElement(IHTMLEventObj *iface, IHTMLEle
static HRESULT WINAPI HTMLEventObj_get_altKey(IHTMLEventObj *iface, VARIANT_BOOL *p) static HRESULT WINAPI HTMLEventObj_get_altKey(IHTMLEventObj *iface, VARIANT_BOOL *p)
{ {
HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface); HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
FIXME("(%p)->(%p)\n", This, p); PRBool ret = FALSE;
return E_NOTIMPL;
TRACE("(%p)->(%p)\n", This, p);
if(This->nsevent) {
nsIDOMKeyEvent *key_event;
nsresult nsres;
nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMKeyEvent, (void**)&key_event);
if(NS_SUCCEEDED(nsres)) {
nsIDOMKeyEvent_GetAltKey(key_event, &ret);
nsIDOMKeyEvent_Release(key_event);
}else {
nsIDOMMouseEvent *mouse_event;
nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMMouseEvent, (void**)&mouse_event);
if(NS_SUCCEEDED(nsres)) {
nsIDOMMouseEvent_GetAltKey(mouse_event, &ret);
nsIDOMMouseEvent_Release(mouse_event);
}
}
}
*p = ret ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
} }
static HRESULT WINAPI HTMLEventObj_get_ctrlKey(IHTMLEventObj *iface, VARIANT_BOOL *p) static HRESULT WINAPI HTMLEventObj_get_ctrlKey(IHTMLEventObj *iface, VARIANT_BOOL *p)
@ -449,7 +475,7 @@ static dispex_static_data_t HTMLEventObj_dispex = {
HTMLEventObj_iface_tids HTMLEventObj_iface_tids
}; };
static IHTMLEventObj *create_event(HTMLDOMNode *target, eventid_t eid) static IHTMLEventObj *create_event(HTMLDOMNode *target, eventid_t eid, nsIDOMEvent *nsevent)
{ {
HTMLEventObj *ret; HTMLEventObj *ret;
@ -460,6 +486,10 @@ static IHTMLEventObj *create_event(HTMLDOMNode *target, eventid_t eid)
ret->target = target; ret->target = target;
IHTMLDOMNode_AddRef(HTMLDOMNODE(target)); IHTMLDOMNode_AddRef(HTMLDOMNODE(target));
ret->nsevent = nsevent;
if(nsevent)
nsIDOMEvent_AddRef(nsevent);
init_dispex(&ret->dispex, (IUnknown*)HTMLEVENTOBJ(ret), &HTMLEventObj_dispex); init_dispex(&ret->dispex, (IUnknown*)HTMLEVENTOBJ(ret), &HTMLEventObj_dispex);
return HTMLEVENTOBJ(ret); return HTMLEVENTOBJ(ret);
@ -490,7 +520,7 @@ static void call_event_handlers(HTMLDocument *doc, event_target_t *event_target,
} }
} }
void fire_event(HTMLDocument *doc, eventid_t eid, nsIDOMNode *target) void fire_event(HTMLDocument *doc, eventid_t eid, nsIDOMNode *target, nsIDOMEvent *nsevent)
{ {
IHTMLEventObj *prev_event, *event_obj = NULL; IHTMLEventObj *prev_event, *event_obj = NULL;
nsIDOMNode *parent, *nsnode; nsIDOMNode *parent, *nsnode;
@ -504,7 +534,7 @@ void fire_event(HTMLDocument *doc, eventid_t eid, nsIDOMNode *target)
} }
prev_event = doc->window->event; prev_event = doc->window->event;
event_obj = doc->window->event = create_event(get_node(doc, target, TRUE), eid); event_obj = doc->window->event = create_event(get_node(doc, target, TRUE), eid, nsevent);
nsnode = target; nsnode = target;
nsIDOMNode_AddRef(nsnode); nsIDOMNode_AddRef(nsnode);

View File

@ -38,7 +38,7 @@ typedef enum {
eventid_t str_to_eid(LPCWSTR); eventid_t str_to_eid(LPCWSTR);
void check_event_attr(HTMLDocument*,nsIDOMElement*); void check_event_attr(HTMLDocument*,nsIDOMElement*);
void release_event_target(event_target_t*); void release_event_target(event_target_t*);
void fire_event(HTMLDocument*,eventid_t,nsIDOMNode*); void fire_event(HTMLDocument*,eventid_t,nsIDOMNode*,nsIDOMEvent*);
HRESULT set_event_handler(event_target_t**,HTMLDocument*,eventid_t,VARIANT*); HRESULT set_event_handler(event_target_t**,HTMLDocument*,eventid_t,VARIANT*);
HRESULT get_event_handler(event_target_t**,eventid_t,VARIANT*); HRESULT get_event_handler(event_target_t**,eventid_t,VARIANT*);

View File

@ -155,7 +155,7 @@ static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event
nsIDOMHTMLDocument_GetBody(This->doc->nsdoc, &nsbody); nsIDOMHTMLDocument_GetBody(This->doc->nsdoc, &nsbody);
if(nsbody) { if(nsbody) {
fire_event(This->doc, EVENTID_LOAD, (nsIDOMNode*)nsbody); fire_event(This->doc, EVENTID_LOAD, (nsIDOMNode*)nsbody, event);
nsIDOMHTMLElement_Release(nsbody); nsIDOMHTMLElement_Release(nsbody);
} }
@ -191,7 +191,7 @@ static nsresult NSAPI handle_htmlevent(nsIDOMEventListener *iface, nsIDOMEvent *
return NS_OK; return NS_OK;
} }
fire_event(This->doc, eid, nsnode); fire_event(This->doc, eid, nsnode, event);
nsIDOMNode_Release(nsnode); nsIDOMNode_Release(nsnode);