crypt32: Implement CryptFormatObject for szOID_CRL_DIST_POINTS.
[wine/multimedia.git] / dlls / mshtml / htmlevent.c
blobe7f581a2759e3ee02475741f4ab2b522fa2b5053
1 /*
2 * Copyright 2008 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
28 #include "mshtml_private.h"
29 #include "htmlevent.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
35 struct event_target_t {
36 IDispatch *event_table[EVENTID_LAST];
39 static const WCHAR blurW[] = {'b','l','u','r',0};
40 static const WCHAR onblurW[] = {'o','n','b','l','u','r',0};
42 static const WCHAR changeW[] = {'c','h','a','n','g','e',0};
43 static const WCHAR onchangeW[] = {'o','n','c','h','a','n','g','e',0};
45 static const WCHAR clickW[] = {'c','l','i','c','k',0};
46 static const WCHAR onclickW[] = {'o','n','c','l','i','c','k',0};
48 static const WCHAR dragW[] = {'d','r','a','g',0};
49 static const WCHAR ondragW[] = {'o','n','d','r','a','g',0};
51 static const WCHAR dragstartW[] = {'d','r','a','g','s','t','a','r','t',0};
52 static const WCHAR ondragstartW[] = {'o','n','d','r','a','g','s','t','a','r','t',0};
54 static const WCHAR focusW[] = {'f','o','c','u','s',0};
55 static const WCHAR onfocusW[] = {'o','n','f','o','c','u','s',0};
57 static const WCHAR keydownW[] = {'k','e','y','d','o','w','n',0};
58 static const WCHAR onkeydownW[] = {'o','n','k','e','y','d','o','w','n',0};
60 static const WCHAR keyupW[] = {'k','e','y','u','p',0};
61 static const WCHAR onkeyupW[] = {'o','n','k','e','y','u','p',0};
63 static const WCHAR loadW[] = {'l','o','a','d',0};
64 static const WCHAR onloadW[] = {'o','n','l','o','a','d',0};
66 static const WCHAR mousedownW[] = {'m','o','u','s','e','d','o','w','n',0};
67 static const WCHAR onmousedownW[] = {'o','n','m','o','u','s','e','d','o','w','n',0};
69 static const WCHAR mouseoutW[] = {'m','o','u','s','e','o','u','t',0};
70 static const WCHAR onmouseoutW[] = {'o','n','m','o','u','s','e','o','u','t',0};
72 static const WCHAR mouseoverW[] = {'m','o','u','s','e','o','v','e','r',0};
73 static const WCHAR onmouseoverW[] = {'o','n','m','o','u','s','e','o','v','e','r',0};
75 static const WCHAR mouseupW[] = {'m','o','u','s','e','u','p',0};
76 static const WCHAR onmouseupW[] = {'o','n','m','o','u','s','e','u','p',0};
78 static const WCHAR pasteW[] = {'p','a','s','t','e',0};
79 static const WCHAR onpasteW[] = {'o','n','p','a','s','t','e',0};
81 static const WCHAR selectstartW[] = {'s','e','l','e','c','t','s','t','a','r','t',0};
82 static const WCHAR onselectstartW[] = {'o','n','s','e','l','e','c','t','s','t','a','r','t',0};
84 typedef struct {
85 LPCWSTR name;
86 LPCWSTR attr_name;
87 DWORD flags;
88 } event_info_t;
90 #define EVENT_DEFAULTLISTENER 0x0001
91 #define EVENT_BUBBLE 0x0002
93 static const event_info_t event_info[] = {
94 {blurW, onblurW, EVENT_DEFAULTLISTENER},
95 {changeW, onchangeW, EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
96 {clickW, onclickW, EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
97 {dragW, ondragW, 0},
98 {dragstartW, ondragstartW, 0},
99 {focusW, onfocusW, EVENT_DEFAULTLISTENER},
100 {keydownW, onkeydownW, EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
101 {keyupW, onkeyupW, EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
102 {loadW, onloadW, 0},
103 {mousedownW, onmousedownW, EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
104 {mouseoutW, onmouseoutW, EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
105 {mouseoverW, onmouseoverW, EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
106 {mouseupW, onmouseupW, EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
107 {pasteW, onpasteW, 0},
108 {selectstartW, onselectstartW, 0}
111 eventid_t str_to_eid(LPCWSTR str)
113 int i;
115 for(i=0; i < sizeof(event_info)/sizeof(event_info[0]); i++) {
116 if(!strcmpW(event_info[i].name, str))
117 return i;
120 ERR("unknown type %s\n", debugstr_w(str));
121 return EVENTID_LAST;
124 typedef struct {
125 DispatchEx dispex;
126 const IHTMLEventObjVtbl *lpIHTMLEventObjVtbl;
128 LONG ref;
130 HTMLDOMNode *target;
131 } HTMLEventObj;
133 #define HTMLEVENTOBJ(x) ((IHTMLEventObj*) &(x)->lpIHTMLEventObjVtbl)
135 #define HTMLEVENTOBJ_THIS(iface) DEFINE_THIS(HTMLEventObj, IHTMLEventObj, iface)
137 static HRESULT WINAPI HTMLEventObj_QueryInterface(IHTMLEventObj *iface, REFIID riid, void **ppv)
139 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
141 *ppv = NULL;
143 if(IsEqualGUID(&IID_IUnknown, riid)) {
144 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
145 *ppv = HTMLEVENTOBJ(This);
146 }else if(IsEqualGUID(&IID_IHTMLEventObj, riid)) {
147 TRACE("(%p)->(IID_IHTMLEventObj %p)\n", This, ppv);
148 *ppv = HTMLEVENTOBJ(This);
149 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
150 return *ppv ? S_OK : E_NOINTERFACE;
153 if(*ppv) {
154 IUnknown_AddRef((IUnknown*)*ppv);
155 return S_OK;
158 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
159 return E_NOINTERFACE;
162 static ULONG WINAPI HTMLEventObj_AddRef(IHTMLEventObj *iface)
164 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
165 LONG ref = InterlockedIncrement(&This->ref);
167 TRACE("(%p) ref=%d\n", This, ref);
169 return ref;
172 static ULONG WINAPI HTMLEventObj_Release(IHTMLEventObj *iface)
174 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
175 LONG ref = InterlockedDecrement(&This->ref);
177 TRACE("(%p) ref=%d\n", This, ref);
179 if(!ref)
180 heap_free(This);
182 return ref;
185 static HRESULT WINAPI HTMLEventObj_GetTypeInfoCount(IHTMLEventObj *iface, UINT *pctinfo)
187 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
188 FIXME("(%p)->(%p)\n", This, pctinfo);
189 return E_NOTIMPL;
192 static HRESULT WINAPI HTMLEventObj_GetTypeInfo(IHTMLEventObj *iface, UINT iTInfo,
193 LCID lcid, ITypeInfo **ppTInfo)
195 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
196 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
197 return E_NOTIMPL;
200 static HRESULT WINAPI HTMLEventObj_GetIDsOfNames(IHTMLEventObj *iface, REFIID riid,
201 LPOLESTR *rgszNames, UINT cNames,
202 LCID lcid, DISPID *rgDispId)
204 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
205 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
206 lcid, rgDispId);
207 return E_NOTIMPL;
210 static HRESULT WINAPI HTMLEventObj_Invoke(IHTMLEventObj *iface, DISPID dispIdMember,
211 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
212 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
214 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
215 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
216 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
217 return E_NOTIMPL;
220 static HRESULT WINAPI HTMLEventObj_get_srcElement(IHTMLEventObj *iface, IHTMLElement **p)
222 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
224 TRACE("(%p)->(%p)\n", This, p);
226 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(This->target), &IID_IHTMLElement, (void**)p);
229 static HRESULT WINAPI HTMLEventObj_get_altKey(IHTMLEventObj *iface, VARIANT_BOOL *p)
231 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
232 FIXME("(%p)->(%p)\n", This, p);
233 return E_NOTIMPL;
236 static HRESULT WINAPI HTMLEventObj_get_ctrlKey(IHTMLEventObj *iface, VARIANT_BOOL *p)
238 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
239 FIXME("(%p)->(%p)\n", This, p);
240 return E_NOTIMPL;
243 static HRESULT WINAPI HTMLEventObj_get_shiftKey(IHTMLEventObj *iface, VARIANT_BOOL *p)
245 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
246 FIXME("(%p)->(%p)\n", This, p);
247 return E_NOTIMPL;
250 static HRESULT WINAPI HTMLEventObj_put_returnValue(IHTMLEventObj *iface, VARIANT v)
252 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
253 FIXME("(%p)->()\n", This);
254 return E_NOTIMPL;
257 static HRESULT WINAPI HTMLEventObj_get_returnValue(IHTMLEventObj *iface, VARIANT *p)
259 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
260 FIXME("(%p)->(%p)\n", This, p);
261 return E_NOTIMPL;
264 static HRESULT WINAPI HTMLEventObj_put_cancelBubble(IHTMLEventObj *iface, VARIANT_BOOL v)
266 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
267 FIXME("(%p)->(%x)\n", This, v);
268 return E_NOTIMPL;
271 static HRESULT WINAPI HTMLEventObj_get_cancelBubble(IHTMLEventObj *iface, VARIANT_BOOL *p)
273 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
274 FIXME("(%p)->(%p)\n", This, p);
275 return E_NOTIMPL;
278 static HRESULT WINAPI HTMLEventObj_get_fromElement(IHTMLEventObj *iface, IHTMLElement **p)
280 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
281 FIXME("(%p)->(%p)\n", This, p);
282 return E_NOTIMPL;
285 static HRESULT WINAPI HTMLEventObj_get_toElement(IHTMLEventObj *iface, IHTMLElement **p)
287 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
288 FIXME("(%p)->(%p)\n", This, p);
289 return E_NOTIMPL;
292 static HRESULT WINAPI HTMLEventObj_put_keyCode(IHTMLEventObj *iface, long v)
294 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
295 FIXME("(%p)->(%ld)\n", This, v);
296 return E_NOTIMPL;
299 static HRESULT WINAPI HTMLEventObj_get_keyCode(IHTMLEventObj *iface, long *p)
301 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
302 FIXME("(%p)->(%p)\n", This, p);
303 return E_NOTIMPL;
306 static HRESULT WINAPI HTMLEventObj_get_button(IHTMLEventObj *iface, long *p)
308 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
309 FIXME("(%p)->(%p)\n", This, p);
310 return E_NOTIMPL;
313 static HRESULT WINAPI HTMLEventObj_get_type(IHTMLEventObj *iface, BSTR *p)
315 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
316 FIXME("(%p)->(%p)\n", This, p);
317 return E_NOTIMPL;
320 static HRESULT WINAPI HTMLEventObj_get_qualifier(IHTMLEventObj *iface, BSTR *p)
322 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
323 FIXME("(%p)->(%p)\n", This, p);
324 return E_NOTIMPL;
327 static HRESULT WINAPI HTMLEventObj_get_reason(IHTMLEventObj *iface, long *p)
329 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
330 FIXME("(%p)->(%p)\n", This, p);
331 return E_NOTIMPL;
334 static HRESULT WINAPI HTMLEventObj_get_x(IHTMLEventObj *iface, long *p)
336 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
337 FIXME("(%p)->(%p)\n", This, p);
338 return E_NOTIMPL;
341 static HRESULT WINAPI HTMLEventObj_get_y(IHTMLEventObj *iface, long *p)
343 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
344 FIXME("(%p)->(%p)\n", This, p);
345 return E_NOTIMPL;
348 static HRESULT WINAPI HTMLEventObj_get_clientX(IHTMLEventObj *iface, long *p)
350 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
351 FIXME("(%p)->(%p)\n", This, p);
352 return E_NOTIMPL;
355 static HRESULT WINAPI HTMLEventObj_get_clientY(IHTMLEventObj *iface, long *p)
357 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
358 FIXME("(%p)->(%p)\n", This, p);
359 return E_NOTIMPL;
362 static HRESULT WINAPI HTMLEventObj_get_offsetX(IHTMLEventObj *iface, long *p)
364 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
365 FIXME("(%p)->(%p)\n", This, p);
366 return E_NOTIMPL;
369 static HRESULT WINAPI HTMLEventObj_get_offsetY(IHTMLEventObj *iface, long *p)
371 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
372 FIXME("(%p)->(%p)\n", This, p);
373 return E_NOTIMPL;
376 static HRESULT WINAPI HTMLEventObj_get_screenX(IHTMLEventObj *iface, long *p)
378 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
379 FIXME("(%p)->(%p)\n", This, p);
380 return E_NOTIMPL;
383 static HRESULT WINAPI HTMLEventObj_get_screenY(IHTMLEventObj *iface, long *p)
385 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
386 FIXME("(%p)->(%p)\n", This, p);
387 return E_NOTIMPL;
390 static HRESULT WINAPI HTMLEventObj_get_srcFilter(IHTMLEventObj *iface, IDispatch **p)
392 HTMLEventObj *This = HTMLEVENTOBJ_THIS(iface);
393 FIXME("(%p)->(%p)\n", This, p);
394 return E_NOTIMPL;
397 #undef HTMLEVENTOBJ_THIS
399 static const IHTMLEventObjVtbl HTMLEventObjVtbl = {
400 HTMLEventObj_QueryInterface,
401 HTMLEventObj_AddRef,
402 HTMLEventObj_Release,
403 HTMLEventObj_GetTypeInfoCount,
404 HTMLEventObj_GetTypeInfo,
405 HTMLEventObj_GetIDsOfNames,
406 HTMLEventObj_Invoke,
407 HTMLEventObj_get_srcElement,
408 HTMLEventObj_get_altKey,
409 HTMLEventObj_get_ctrlKey,
410 HTMLEventObj_get_shiftKey,
411 HTMLEventObj_put_returnValue,
412 HTMLEventObj_get_returnValue,
413 HTMLEventObj_put_cancelBubble,
414 HTMLEventObj_get_cancelBubble,
415 HTMLEventObj_get_fromElement,
416 HTMLEventObj_get_toElement,
417 HTMLEventObj_put_keyCode,
418 HTMLEventObj_get_keyCode,
419 HTMLEventObj_get_button,
420 HTMLEventObj_get_type,
421 HTMLEventObj_get_qualifier,
422 HTMLEventObj_get_reason,
423 HTMLEventObj_get_x,
424 HTMLEventObj_get_y,
425 HTMLEventObj_get_clientX,
426 HTMLEventObj_get_clientY,
427 HTMLEventObj_get_offsetX,
428 HTMLEventObj_get_offsetY,
429 HTMLEventObj_get_screenX,
430 HTMLEventObj_get_screenY,
431 HTMLEventObj_get_srcFilter
434 static const tid_t HTMLEventObj_iface_tids[] = {
435 IHTMLEventObj_tid,
439 static dispex_static_data_t HTMLEventObj_dispex = {
440 NULL,
441 DispCEventObj_tid,
442 NULL,
443 HTMLEventObj_iface_tids
446 static IHTMLEventObj *create_event(HTMLDOMNode *target)
448 HTMLEventObj *ret;
450 ret = heap_alloc(sizeof(*ret));
451 ret->lpIHTMLEventObjVtbl = &HTMLEventObjVtbl;
452 ret->ref = 1;
453 ret->target = target;
454 IHTMLDOMNode_AddRef(HTMLDOMNODE(target));
456 init_dispex(&ret->dispex, (IUnknown*)HTMLEVENTOBJ(ret), &HTMLEventObj_dispex);
458 return HTMLEVENTOBJ(ret);
461 void fire_event(HTMLDocument *doc, eventid_t eid, nsIDOMNode *target)
463 IHTMLEventObj *prev_event, *event_obj = NULL;
464 nsIDOMNode *parent, *nsnode;
465 HTMLDOMNode *node;
466 PRUint16 node_type;
468 nsIDOMNode_GetNodeType(target, &node_type);
469 if(node_type != ELEMENT_NODE) {
470 FIXME("node type %d node supported\n", node_type);
471 return;
474 prev_event = doc->window->event;
475 nsnode = target;
476 nsIDOMNode_AddRef(nsnode);
478 while(1) {
479 node = get_node(doc, nsnode, FALSE);
481 if(node && node->event_target && node->event_target->event_table[eid]) {
482 if(!event_obj)
483 event_obj = doc->window->event = create_event(get_node(doc, target, TRUE));
485 TRACE("%s >>>\n", debugstr_w(event_info[eid].name));
486 call_disp_func(doc, node->event_target->event_table[eid], (IDispatch*)HTMLDOMNODE(node));
487 TRACE("%s <<<\n", debugstr_w(event_info[eid].name));
490 if(!(event_info[eid].flags & EVENT_BUBBLE))
491 break;
493 nsIDOMNode_GetParentNode(nsnode, &parent);
494 nsIDOMNode_Release(nsnode);
495 nsnode = parent;
496 if(!nsnode)
497 break;
499 nsIDOMNode_GetNodeType(nsnode, &node_type);
500 if(node_type != ELEMENT_NODE)
501 break;
504 if(nsnode)
505 nsIDOMNode_Release(nsnode);
507 if((event_info[eid].flags & EVENT_BUBBLE) && doc->event_target && doc->event_target->event_table[eid]) {
508 if(!event_obj)
509 event_obj = doc->window->event = create_event(get_node(doc, target, TRUE));
511 TRACE("doc %s >>>\n", debugstr_w(event_info[eid].name));
512 call_disp_func(doc, doc->event_target->event_table[eid], (IDispatch*)HTMLDOC(doc));
513 TRACE("doc %s <<<\n", debugstr_w(event_info[eid].name));
516 if(event_obj) {
517 IHTMLEventObj_Release(event_obj);
518 doc->window->event = prev_event;
522 static HRESULT set_event_handler_disp(event_target_t **event_target, HTMLDocument *doc, eventid_t eid, IDispatch *disp)
524 if(!*event_target)
525 *event_target = heap_alloc_zero(sizeof(event_target_t));
526 else if((*event_target)->event_table[eid])
527 IDispatch_Release((*event_target)->event_table[eid]);
529 (*event_target)->event_table[eid] = disp;
530 if(!disp)
531 return S_OK;
532 IDispatch_AddRef(disp);
534 if(doc->nscontainer && (event_info[eid].flags & EVENT_DEFAULTLISTENER)) {
535 if(!doc->nscontainer->event_vector) {
536 doc->nscontainer->event_vector = heap_alloc_zero(EVENTID_LAST*sizeof(BOOL));
537 if(!doc->nscontainer->event_vector)
538 return E_OUTOFMEMORY;
541 if(!doc->nscontainer->event_vector[eid]) {
542 doc->nscontainer->event_vector[eid] = TRUE;
543 add_nsevent_listener(doc->nscontainer, event_info[eid].name);
547 return S_OK;
550 HRESULT set_event_handler(event_target_t **event_target, HTMLDocument *doc, eventid_t eid, VARIANT *var)
552 switch(V_VT(var)) {
553 case VT_NULL:
554 if(*event_target && (*event_target)->event_table[eid]) {
555 IDispatch_Release((*event_target)->event_table[eid]);
556 (*event_target)->event_table[eid] = NULL;
558 break;
560 case VT_DISPATCH:
561 return set_event_handler_disp(event_target, doc, eid, V_DISPATCH(var));
563 default:
564 FIXME("not supported vt=%d\n", V_VT(var));
565 return E_NOTIMPL;
568 return S_OK;
571 HRESULT get_event_handler(event_target_t **event_target, eventid_t eid, VARIANT *var)
573 if(*event_target && (*event_target)->event_table[eid]) {
574 V_VT(var) = VT_DISPATCH;
575 V_DISPATCH(var) = (*event_target)->event_table[eid];
576 IDispatch_AddRef(V_DISPATCH(var));
577 }else {
578 V_VT(var) = VT_NULL;
581 return S_OK;
584 void check_event_attr(HTMLDocument *doc, nsIDOMElement *nselem)
586 const PRUnichar *attr_value;
587 nsAString attr_name_str, attr_value_str;
588 IDispatch *disp;
589 HTMLDOMNode *node;
590 int i;
591 nsresult nsres;
593 nsAString_Init(&attr_value_str, NULL);
594 nsAString_Init(&attr_name_str, NULL);
596 for(i=0; i < EVENTID_LAST; i++) {
597 nsAString_SetData(&attr_name_str, event_info[i].attr_name);
598 nsres = nsIDOMElement_GetAttribute(nselem, &attr_name_str, &attr_value_str);
599 if(NS_SUCCEEDED(nsres)) {
600 nsAString_GetData(&attr_value_str, &attr_value);
601 if(!*attr_value)
602 continue;
604 TRACE("%p.%s = %s\n", nselem, debugstr_w(event_info[i].attr_name), debugstr_w(attr_value));
606 disp = script_parse_event(doc, attr_value);
607 if(disp) {
608 node = get_node(doc, (nsIDOMNode*)nselem, TRUE);
609 set_event_handler_disp(&node->event_target, node->doc, i, disp);
610 IDispatch_Release(disp);
615 nsAString_Finish(&attr_value_str);
616 nsAString_Finish(&attr_name_str);
619 void release_event_target(event_target_t *event_target)
621 int i;
623 for(i=0; i < EVENTID_LAST; i++) {
624 if(event_target->event_table[i])
625 IDispatch_Release(event_target->event_table[i]);
628 heap_free(event_target);