2 * Copyright 2008-2009 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
29 #include "mshtml_private.h"
30 #include "htmlevent.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
37 IDispatch
*handler_prop
;
39 IDispatch
*handlers
[0];
42 struct event_target_t
{
43 DWORD node_handlers_mask
;
44 handler_vector_t
*event_table
[EVENTID_LAST
];
47 static const WCHAR beforeunloadW
[] = {'b','e','f','o','r','e','u','n','l','o','a','d',0};
48 static const WCHAR onbeforeunloadW
[] = {'o','n','b','e','f','o','r','e','u','n','l','o','a','d',0};
50 static const WCHAR blurW
[] = {'b','l','u','r',0};
51 static const WCHAR onblurW
[] = {'o','n','b','l','u','r',0};
53 static const WCHAR changeW
[] = {'c','h','a','n','g','e',0};
54 static const WCHAR onchangeW
[] = {'o','n','c','h','a','n','g','e',0};
56 static const WCHAR clickW
[] = {'c','l','i','c','k',0};
57 static const WCHAR onclickW
[] = {'o','n','c','l','i','c','k',0};
59 static const WCHAR contextmenuW
[] = {'c','o','n','t','e','x','t','m','e','n','u',0};
60 static const WCHAR oncontextmenuW
[] = {'o','n','c','o','n','t','e','x','t','m','e','n','u',0};
62 static const WCHAR dblclickW
[] = {'d','b','l','c','l','i','c','k',0};
63 static const WCHAR ondblclickW
[] = {'o','n','d','b','l','c','l','i','c','k',0};
65 static const WCHAR dragW
[] = {'d','r','a','g',0};
66 static const WCHAR ondragW
[] = {'o','n','d','r','a','g',0};
68 static const WCHAR dragstartW
[] = {'d','r','a','g','s','t','a','r','t',0};
69 static const WCHAR ondragstartW
[] = {'o','n','d','r','a','g','s','t','a','r','t',0};
71 static const WCHAR focusW
[] = {'f','o','c','u','s',0};
72 static const WCHAR onfocusW
[] = {'o','n','f','o','c','u','s',0};
74 static const WCHAR keydownW
[] = {'k','e','y','d','o','w','n',0};
75 static const WCHAR onkeydownW
[] = {'o','n','k','e','y','d','o','w','n',0};
77 static const WCHAR keyupW
[] = {'k','e','y','u','p',0};
78 static const WCHAR onkeyupW
[] = {'o','n','k','e','y','u','p',0};
80 static const WCHAR loadW
[] = {'l','o','a','d',0};
81 static const WCHAR onloadW
[] = {'o','n','l','o','a','d',0};
83 static const WCHAR mousedownW
[] = {'m','o','u','s','e','d','o','w','n',0};
84 static const WCHAR onmousedownW
[] = {'o','n','m','o','u','s','e','d','o','w','n',0};
86 static const WCHAR mousemoveW
[] = {'m','o','u','s','e','m','o','v','e',0};
87 static const WCHAR onmousemoveW
[] = {'o','n','m','o','u','s','e','m','o','v','e',0};
89 static const WCHAR mouseoutW
[] = {'m','o','u','s','e','o','u','t',0};
90 static const WCHAR onmouseoutW
[] = {'o','n','m','o','u','s','e','o','u','t',0};
92 static const WCHAR mouseoverW
[] = {'m','o','u','s','e','o','v','e','r',0};
93 static const WCHAR onmouseoverW
[] = {'o','n','m','o','u','s','e','o','v','e','r',0};
95 static const WCHAR mouseupW
[] = {'m','o','u','s','e','u','p',0};
96 static const WCHAR onmouseupW
[] = {'o','n','m','o','u','s','e','u','p',0};
98 static const WCHAR pasteW
[] = {'p','a','s','t','e',0};
99 static const WCHAR onpasteW
[] = {'o','n','p','a','s','t','e',0};
101 static const WCHAR readystatechangeW
[] = {'r','e','a','d','y','s','t','a','t','e','c','h','a','n','g','e',0};
102 static const WCHAR onreadystatechangeW
[] = {'o','n','r','e','a','d','y','s','t','a','t','e','c','h','a','n','g','e',0};
104 static const WCHAR resizeW
[] = {'r','e','s','i','z','e',0};
105 static const WCHAR onresizeW
[] = {'o','n','r','e','s','i','z','e',0};
107 static const WCHAR selectstartW
[] = {'s','e','l','e','c','t','s','t','a','r','t',0};
108 static const WCHAR onselectstartW
[] = {'o','n','s','e','l','e','c','t','s','t','a','r','t',0};
110 static const WCHAR submitW
[] = {'s','u','b','m','i','t',0};
111 static const WCHAR onsubmitW
[] = {'o','n','s','u','b','m','i','t',0};
113 static const WCHAR HTMLEventsW
[] = {'H','T','M','L','E','v','e','n','t','s',0};
114 static const WCHAR KeyboardEventW
[] = {'K','e','y','b','o','a','r','d','E','v','e','n','t',0};
115 static const WCHAR MouseEventW
[] = {'M','o','u','s','e','E','v','e','n','t',0};
124 static const WCHAR
*event_types
[] = {
139 #define EVENT_DEFAULTLISTENER 0x0001
140 #define EVENT_BUBBLE 0x0002
141 #define EVENT_FORWARDBODY 0x0004
142 #define EVENT_NODEHANDLER 0x0008
143 #define EVENT_CANCELABLE 0x0010
145 static const event_info_t event_info
[] = {
146 {beforeunloadW
, onbeforeunloadW
, EVENTT_NONE
, DISPID_EVMETH_ONBEFOREUNLOAD
,
147 EVENT_DEFAULTLISTENER
|EVENT_FORWARDBODY
},
148 {blurW
, onblurW
, EVENTT_HTML
, DISPID_EVMETH_ONBLUR
,
149 EVENT_DEFAULTLISTENER
},
150 {changeW
, onchangeW
, EVENTT_HTML
, DISPID_EVMETH_ONCHANGE
,
151 EVENT_DEFAULTLISTENER
|EVENT_BUBBLE
},
152 {clickW
, onclickW
, EVENTT_MOUSE
, DISPID_EVMETH_ONCLICK
,
153 EVENT_DEFAULTLISTENER
|EVENT_BUBBLE
|EVENT_CANCELABLE
},
154 {contextmenuW
, oncontextmenuW
, EVENTT_MOUSE
, DISPID_EVMETH_ONCONTEXTMENU
,
155 EVENT_BUBBLE
|EVENT_CANCELABLE
},
156 {dblclickW
, ondblclickW
, EVENTT_MOUSE
, DISPID_EVMETH_ONDBLCLICK
,
157 EVENT_DEFAULTLISTENER
|EVENT_BUBBLE
|EVENT_CANCELABLE
},
158 {dragW
, ondragW
, EVENTT_MOUSE
, DISPID_EVMETH_ONDRAG
,
160 {dragstartW
, ondragstartW
, EVENTT_MOUSE
, DISPID_EVMETH_ONDRAGSTART
,
162 {focusW
, onfocusW
, EVENTT_HTML
, DISPID_EVMETH_ONFOCUS
,
163 EVENT_DEFAULTLISTENER
},
164 {keydownW
, onkeydownW
, EVENTT_KEY
, DISPID_EVMETH_ONKEYDOWN
,
165 EVENT_DEFAULTLISTENER
|EVENT_BUBBLE
},
166 {keyupW
, onkeyupW
, EVENTT_KEY
, DISPID_EVMETH_ONKEYUP
,
167 EVENT_DEFAULTLISTENER
|EVENT_BUBBLE
},
168 {loadW
, onloadW
, EVENTT_HTML
, DISPID_EVMETH_ONLOAD
,
170 {mousedownW
, onmousedownW
, EVENTT_MOUSE
, DISPID_EVMETH_ONMOUSEDOWN
,
171 EVENT_DEFAULTLISTENER
|EVENT_BUBBLE
},
172 {mousemoveW
, onmousemoveW
, EVENTT_MOUSE
, DISPID_EVMETH_ONMOUSEMOVE
,
173 EVENT_DEFAULTLISTENER
|EVENT_BUBBLE
},
174 {mouseoutW
, onmouseoutW
, EVENTT_MOUSE
, DISPID_EVMETH_ONMOUSEOUT
,
175 EVENT_DEFAULTLISTENER
|EVENT_BUBBLE
},
176 {mouseoverW
, onmouseoverW
, EVENTT_MOUSE
, DISPID_EVMETH_ONMOUSEOVER
,
177 EVENT_DEFAULTLISTENER
|EVENT_BUBBLE
},
178 {mouseupW
, onmouseupW
, EVENTT_MOUSE
, DISPID_EVMETH_ONMOUSEUP
,
179 EVENT_DEFAULTLISTENER
|EVENT_BUBBLE
},
180 {pasteW
, onpasteW
, EVENTT_NONE
, DISPID_EVMETH_ONPASTE
,
182 {readystatechangeW
, onreadystatechangeW
, EVENTT_NONE
, DISPID_EVMETH_ONREADYSTATECHANGE
,
184 {resizeW
, onresizeW
, EVENTT_NONE
, DISPID_EVMETH_ONRESIZE
,
185 EVENT_DEFAULTLISTENER
|EVENT_BUBBLE
},
186 {selectstartW
, onselectstartW
, EVENTT_MOUSE
, DISPID_EVMETH_ONSELECTSTART
,
188 {submitW
, onsubmitW
, EVENTT_HTML
, DISPID_EVMETH_ONSUBMIT
,
189 EVENT_DEFAULTLISTENER
|EVENT_BUBBLE
|EVENT_CANCELABLE
}
192 static const eventid_t node_handled_list
[] = { EVENTID_LOAD
};
194 eventid_t
str_to_eid(LPCWSTR str
)
198 for(i
=0; i
< sizeof(event_info
)/sizeof(event_info
[0]); i
++) {
199 if(!strcmpW(event_info
[i
].name
, str
))
203 ERR("unknown type %s\n", debugstr_w(str
));
207 static eventid_t
attr_to_eid(LPCWSTR str
)
211 for(i
=0; i
< sizeof(event_info
)/sizeof(event_info
[0]); i
++) {
212 if(!strcmpW(event_info
[i
].attr_name
, str
))
219 static DWORD
get_node_handler_mask(eventid_t eid
)
223 for(i
=0; i
<sizeof(node_handled_list
)/sizeof(*node_handled_list
); i
++) {
224 if(node_handled_list
[i
] == eid
)
228 ERR("Invalid eid %d\n", eid
);
234 IHTMLEventObj IHTMLEventObj_iface
;
239 const event_info_t
*type
;
240 nsIDOMEvent
*nsevent
;
241 BOOL prevent_default
;
244 static inline HTMLEventObj
*impl_from_IHTMLEventObj(IHTMLEventObj
*iface
)
246 return CONTAINING_RECORD(iface
, HTMLEventObj
, IHTMLEventObj_iface
);
249 static HRESULT WINAPI
HTMLEventObj_QueryInterface(IHTMLEventObj
*iface
, REFIID riid
, void **ppv
)
251 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
255 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
256 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
257 *ppv
= &This
->IHTMLEventObj_iface
;
258 }else if(IsEqualGUID(&IID_IHTMLEventObj
, riid
)) {
259 TRACE("(%p)->(IID_IHTMLEventObj %p)\n", This
, ppv
);
260 *ppv
= &This
->IHTMLEventObj_iface
;
261 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
262 return *ppv
? S_OK
: E_NOINTERFACE
;
266 IUnknown_AddRef((IUnknown
*)*ppv
);
270 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
271 return E_NOINTERFACE
;
274 static ULONG WINAPI
HTMLEventObj_AddRef(IHTMLEventObj
*iface
)
276 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
277 LONG ref
= InterlockedIncrement(&This
->ref
);
279 TRACE("(%p) ref=%d\n", This
, ref
);
284 static ULONG WINAPI
HTMLEventObj_Release(IHTMLEventObj
*iface
)
286 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
287 LONG ref
= InterlockedDecrement(&This
->ref
);
289 TRACE("(%p) ref=%d\n", This
, ref
);
293 IHTMLDOMNode_Release(&This
->target
->IHTMLDOMNode_iface
);
295 nsIDOMEvent_Release(This
->nsevent
);
296 release_dispex(&This
->dispex
);
303 static HRESULT WINAPI
HTMLEventObj_GetTypeInfoCount(IHTMLEventObj
*iface
, UINT
*pctinfo
)
305 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
306 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
309 static HRESULT WINAPI
HTMLEventObj_GetTypeInfo(IHTMLEventObj
*iface
, UINT iTInfo
,
310 LCID lcid
, ITypeInfo
**ppTInfo
)
312 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
313 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
316 static HRESULT WINAPI
HTMLEventObj_GetIDsOfNames(IHTMLEventObj
*iface
, REFIID riid
,
317 LPOLESTR
*rgszNames
, UINT cNames
,
318 LCID lcid
, DISPID
*rgDispId
)
320 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
321 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
325 static HRESULT WINAPI
HTMLEventObj_Invoke(IHTMLEventObj
*iface
, DISPID dispIdMember
,
326 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
327 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
329 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
330 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
331 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
334 static HRESULT WINAPI
HTMLEventObj_get_srcElement(IHTMLEventObj
*iface
, IHTMLElement
**p
)
336 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
338 TRACE("(%p)->(%p)\n", This
, p
);
340 return IHTMLDOMNode_QueryInterface(&This
->target
->IHTMLDOMNode_iface
, &IID_IHTMLElement
,
344 static HRESULT WINAPI
HTMLEventObj_get_altKey(IHTMLEventObj
*iface
, VARIANT_BOOL
*p
)
346 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
349 TRACE("(%p)->(%p)\n", This
, p
);
352 nsIDOMKeyEvent
*key_event
;
355 nsres
= nsIDOMEvent_QueryInterface(This
->nsevent
, &IID_nsIDOMKeyEvent
, (void**)&key_event
);
356 if(NS_SUCCEEDED(nsres
)) {
357 nsIDOMKeyEvent_GetAltKey(key_event
, &ret
);
358 nsIDOMKeyEvent_Release(key_event
);
360 nsIDOMMouseEvent
*mouse_event
;
362 nsres
= nsIDOMEvent_QueryInterface(This
->nsevent
, &IID_nsIDOMMouseEvent
, (void**)&mouse_event
);
363 if(NS_SUCCEEDED(nsres
)) {
364 nsIDOMMouseEvent_GetAltKey(mouse_event
, &ret
);
365 nsIDOMMouseEvent_Release(mouse_event
);
370 *p
= ret
? VARIANT_TRUE
: VARIANT_FALSE
;
374 static HRESULT WINAPI
HTMLEventObj_get_ctrlKey(IHTMLEventObj
*iface
, VARIANT_BOOL
*p
)
376 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
379 TRACE("(%p)->(%p)\n", This
, p
);
382 nsIDOMKeyEvent
*key_event
;
385 nsres
= nsIDOMEvent_QueryInterface(This
->nsevent
, &IID_nsIDOMKeyEvent
, (void**)&key_event
);
386 if(NS_SUCCEEDED(nsres
)) {
387 nsIDOMKeyEvent_GetCtrlKey(key_event
, &ret
);
388 nsIDOMKeyEvent_Release(key_event
);
390 nsIDOMMouseEvent
*mouse_event
;
392 nsres
= nsIDOMEvent_QueryInterface(This
->nsevent
, &IID_nsIDOMMouseEvent
, (void**)&mouse_event
);
393 if(NS_SUCCEEDED(nsres
)) {
394 nsIDOMMouseEvent_GetCtrlKey(mouse_event
, &ret
);
395 nsIDOMMouseEvent_Release(mouse_event
);
400 *p
= ret
? VARIANT_TRUE
: VARIANT_FALSE
;
404 static HRESULT WINAPI
HTMLEventObj_get_shiftKey(IHTMLEventObj
*iface
, VARIANT_BOOL
*p
)
406 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
409 TRACE("(%p)->(%p)\n", This
, p
);
412 nsIDOMKeyEvent
*key_event
;
415 nsres
= nsIDOMEvent_QueryInterface(This
->nsevent
, &IID_nsIDOMKeyEvent
, (void**)&key_event
);
416 if(NS_SUCCEEDED(nsres
)) {
417 nsIDOMKeyEvent_GetShiftKey(key_event
, &ret
);
418 nsIDOMKeyEvent_Release(key_event
);
420 nsIDOMMouseEvent
*mouse_event
;
422 nsres
= nsIDOMEvent_QueryInterface(This
->nsevent
, &IID_nsIDOMMouseEvent
, (void**)&mouse_event
);
423 if(NS_SUCCEEDED(nsres
)) {
424 nsIDOMMouseEvent_GetShiftKey(mouse_event
, &ret
);
425 nsIDOMMouseEvent_Release(mouse_event
);
430 *p
= ret
? VARIANT_TRUE
: VARIANT_FALSE
;
434 static HRESULT WINAPI
HTMLEventObj_put_returnValue(IHTMLEventObj
*iface
, VARIANT v
)
436 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
437 FIXME("(%p)->()\n", This
);
441 static HRESULT WINAPI
HTMLEventObj_get_returnValue(IHTMLEventObj
*iface
, VARIANT
*p
)
443 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
445 FIXME("(%p)->(%p)\n", This
, p
);
451 static HRESULT WINAPI
HTMLEventObj_put_cancelBubble(IHTMLEventObj
*iface
, VARIANT_BOOL v
)
453 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
454 FIXME("(%p)->(%x)\n", This
, v
);
458 static HRESULT WINAPI
HTMLEventObj_get_cancelBubble(IHTMLEventObj
*iface
, VARIANT_BOOL
*p
)
460 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
462 FIXME("(%p)->(%p)\n", This
, p
);
468 static HRESULT WINAPI
HTMLEventObj_get_fromElement(IHTMLEventObj
*iface
, IHTMLElement
**p
)
470 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
472 FIXME("(%p)->(%p)\n", This
, p
);
478 static HRESULT WINAPI
HTMLEventObj_get_toElement(IHTMLEventObj
*iface
, IHTMLElement
**p
)
480 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
482 FIXME("(%p)->(%p)\n", This
, p
);
488 static HRESULT WINAPI
HTMLEventObj_put_keyCode(IHTMLEventObj
*iface
, LONG v
)
490 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
491 FIXME("(%p)->(%d)\n", This
, v
);
495 static HRESULT WINAPI
HTMLEventObj_get_keyCode(IHTMLEventObj
*iface
, LONG
*p
)
497 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
498 PRUint32 key_code
= 0;
500 TRACE("(%p)->(%p)\n", This
, p
);
503 nsIDOMKeyEvent
*key_event
;
506 nsres
= nsIDOMEvent_QueryInterface(This
->nsevent
, &IID_nsIDOMKeyEvent
, (void**)&key_event
);
507 if(NS_SUCCEEDED(nsres
)) {
508 nsIDOMKeyEvent_GetKeyCode(key_event
, &key_code
);
509 nsIDOMKeyEvent_Release(key_event
);
517 static HRESULT WINAPI
HTMLEventObj_get_button(IHTMLEventObj
*iface
, LONG
*p
)
519 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
522 TRACE("(%p)->(%p)\n", This
, p
);
525 nsIDOMMouseEvent
*mouse_event
;
528 nsres
= nsIDOMEvent_QueryInterface(This
->nsevent
, &IID_nsIDOMMouseEvent
, (void**)&mouse_event
);
529 if(NS_SUCCEEDED(nsres
)) {
530 nsIDOMMouseEvent_GetButton(mouse_event
, &button
);
531 nsIDOMMouseEvent_Release(mouse_event
);
539 static HRESULT WINAPI
HTMLEventObj_get_type(IHTMLEventObj
*iface
, BSTR
*p
)
541 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
543 TRACE("(%p)->(%p)\n", This
, p
);
545 *p
= SysAllocString(This
->type
->name
);
546 return *p
? S_OK
: E_OUTOFMEMORY
;
549 static HRESULT WINAPI
HTMLEventObj_get_qualifier(IHTMLEventObj
*iface
, BSTR
*p
)
551 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
553 FIXME("(%p)->(%p)\n", This
, p
);
559 static HRESULT WINAPI
HTMLEventObj_get_reason(IHTMLEventObj
*iface
, LONG
*p
)
561 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
563 FIXME("(%p)->(%p)\n", This
, p
);
569 static HRESULT WINAPI
HTMLEventObj_get_x(IHTMLEventObj
*iface
, LONG
*p
)
571 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
573 FIXME("(%p)->(%p)\n", This
, p
);
579 static HRESULT WINAPI
HTMLEventObj_get_y(IHTMLEventObj
*iface
, LONG
*p
)
581 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
583 FIXME("(%p)->(%p)\n", This
, p
);
589 static HRESULT WINAPI
HTMLEventObj_get_clientX(IHTMLEventObj
*iface
, LONG
*p
)
591 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
594 TRACE("(%p)->(%p)\n", This
, p
);
597 nsIDOMMouseEvent
*mouse_event
;
600 nsres
= nsIDOMEvent_QueryInterface(This
->nsevent
, &IID_nsIDOMMouseEvent
, (void**)&mouse_event
);
601 if(NS_SUCCEEDED(nsres
)) {
602 nsIDOMMouseEvent_GetClientX(mouse_event
, &x
);
603 nsIDOMMouseEvent_Release(mouse_event
);
611 static HRESULT WINAPI
HTMLEventObj_get_clientY(IHTMLEventObj
*iface
, LONG
*p
)
613 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
616 TRACE("(%p)->(%p)\n", This
, p
);
619 nsIDOMMouseEvent
*mouse_event
;
622 nsres
= nsIDOMEvent_QueryInterface(This
->nsevent
, &IID_nsIDOMMouseEvent
, (void**)&mouse_event
);
623 if(NS_SUCCEEDED(nsres
)) {
624 nsIDOMMouseEvent_GetClientY(mouse_event
, &y
);
625 nsIDOMMouseEvent_Release(mouse_event
);
633 static HRESULT WINAPI
HTMLEventObj_get_offsetX(IHTMLEventObj
*iface
, LONG
*p
)
635 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
637 FIXME("(%p)->(%p)\n", This
, p
);
643 static HRESULT WINAPI
HTMLEventObj_get_offsetY(IHTMLEventObj
*iface
, LONG
*p
)
645 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
647 FIXME("(%p)->(%p)\n", This
, p
);
653 static HRESULT WINAPI
HTMLEventObj_get_screenX(IHTMLEventObj
*iface
, LONG
*p
)
655 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
658 TRACE("(%p)->(%p)\n", This
, p
);
661 nsIDOMMouseEvent
*mouse_event
;
664 nsres
= nsIDOMEvent_QueryInterface(This
->nsevent
, &IID_nsIDOMMouseEvent
, (void**)&mouse_event
);
665 if(NS_SUCCEEDED(nsres
)) {
666 nsIDOMMouseEvent_GetScreenX(mouse_event
, &x
);
667 nsIDOMMouseEvent_Release(mouse_event
);
675 static HRESULT WINAPI
HTMLEventObj_get_screenY(IHTMLEventObj
*iface
, LONG
*p
)
677 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
680 TRACE("(%p)->(%p)\n", This
, p
);
683 nsIDOMMouseEvent
*mouse_event
;
686 nsres
= nsIDOMEvent_QueryInterface(This
->nsevent
, &IID_nsIDOMMouseEvent
, (void**)&mouse_event
);
687 if(NS_SUCCEEDED(nsres
)) {
688 nsIDOMMouseEvent_GetScreenY(mouse_event
, &y
);
689 nsIDOMMouseEvent_Release(mouse_event
);
697 static HRESULT WINAPI
HTMLEventObj_get_srcFilter(IHTMLEventObj
*iface
, IDispatch
**p
)
699 HTMLEventObj
*This
= impl_from_IHTMLEventObj(iface
);
701 FIXME("(%p)->(%p)\n", This
, p
);
707 static const IHTMLEventObjVtbl HTMLEventObjVtbl
= {
708 HTMLEventObj_QueryInterface
,
710 HTMLEventObj_Release
,
711 HTMLEventObj_GetTypeInfoCount
,
712 HTMLEventObj_GetTypeInfo
,
713 HTMLEventObj_GetIDsOfNames
,
715 HTMLEventObj_get_srcElement
,
716 HTMLEventObj_get_altKey
,
717 HTMLEventObj_get_ctrlKey
,
718 HTMLEventObj_get_shiftKey
,
719 HTMLEventObj_put_returnValue
,
720 HTMLEventObj_get_returnValue
,
721 HTMLEventObj_put_cancelBubble
,
722 HTMLEventObj_get_cancelBubble
,
723 HTMLEventObj_get_fromElement
,
724 HTMLEventObj_get_toElement
,
725 HTMLEventObj_put_keyCode
,
726 HTMLEventObj_get_keyCode
,
727 HTMLEventObj_get_button
,
728 HTMLEventObj_get_type
,
729 HTMLEventObj_get_qualifier
,
730 HTMLEventObj_get_reason
,
733 HTMLEventObj_get_clientX
,
734 HTMLEventObj_get_clientY
,
735 HTMLEventObj_get_offsetX
,
736 HTMLEventObj_get_offsetY
,
737 HTMLEventObj_get_screenX
,
738 HTMLEventObj_get_screenY
,
739 HTMLEventObj_get_srcFilter
742 static const tid_t HTMLEventObj_iface_tids
[] = {
747 static dispex_static_data_t HTMLEventObj_dispex
= {
751 HTMLEventObj_iface_tids
754 static HTMLEventObj
*create_event(HTMLDOMNode
*target
, eventid_t eid
, nsIDOMEvent
*nsevent
)
758 ret
= heap_alloc_zero(sizeof(*ret
));
762 ret
->IHTMLEventObj_iface
.lpVtbl
= &HTMLEventObjVtbl
;
764 ret
->type
= event_info
+eid
;
766 ret
->nsevent
= nsevent
;
768 nsIDOMEvent_AddRef(nsevent
);
769 }else if(event_types
[event_info
[eid
].type
]) {
770 nsIDOMDocumentEvent
*doc_event
;
773 nsres
= nsIDOMHTMLDocument_QueryInterface(target
->doc
->nsdoc
, &IID_nsIDOMDocumentEvent
,
775 if(NS_SUCCEEDED(nsres
)) {
778 nsAString_InitDepend(&type_str
, event_types
[event_info
[eid
].type
]);
779 nsres
= nsIDOMDocumentEvent_CreateEvent(doc_event
, &type_str
, &ret
->nsevent
);
780 nsAString_Finish(&type_str
);
781 nsIDOMDocumentEvent_Release(doc_event
);
783 if(NS_FAILED(nsres
)) {
784 ERR("Could not create event: %08x\n", nsres
);
785 IHTMLEventObj_Release(&ret
->IHTMLEventObj_iface
);
790 ret
->target
= target
;
791 IHTMLDOMNode_AddRef(&target
->IHTMLDOMNode_iface
);
793 init_dispex(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLEventObj_iface
, &HTMLEventObj_dispex
);
798 static HRESULT
call_disp_func(IDispatch
*disp
, DISPPARAMS
*dp
, VARIANT
*retv
)
804 memset(&ei
, 0, sizeof(ei
));
806 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
807 if(SUCCEEDED(hres
)) {
808 hres
= IDispatchEx_InvokeEx(dispex
, 0, GetUserDefaultLCID(), DISPATCH_METHOD
, dp
, retv
, &ei
, NULL
);
809 IDispatchEx_Release(dispex
);
811 TRACE("Could not get IDispatchEx interface: %08x\n", hres
);
812 hres
= IDispatch_Invoke(disp
, 0, &IID_NULL
, GetUserDefaultLCID(), DISPATCH_METHOD
,
813 dp
, retv
, &ei
, NULL
);
819 static HRESULT
call_cp_func(IDispatch
*disp
, DISPID dispid
, VARIANT
*retv
)
821 DISPPARAMS dp
= {NULL
,NULL
,0,0};
825 memset(&ei
, 0, sizeof(ei
));
826 return IDispatch_Invoke(disp
, dispid
, &IID_NULL
, 0, DISPATCH_METHOD
, &dp
, retv
, &ei
, &argerr
);
829 static BOOL
is_cp_event(cp_static_data_t
*data
, DISPID dispid
)
838 hres
= get_dispids(data
->tid
, &data
->id_cnt
, &data
->ids
);
844 max
= data
->id_cnt
-1;
847 if(data
->ids
[i
] == dispid
)
850 if(data
->ids
[i
] < dispid
)
859 static void call_event_handlers(HTMLDocumentNode
*doc
, HTMLEventObj
*event_obj
, event_target_t
*event_target
,
860 ConnectionPointContainer
*cp_container
, eventid_t eid
, IDispatch
*this_obj
)
862 const BOOL cancelable
= event_info
[eid
].flags
& EVENT_CANCELABLE
;
863 handler_vector_t
*handler_vector
= NULL
;
869 handler_vector
= event_target
->event_table
[eid
];
871 if(handler_vector
&& handler_vector
->handler_prop
) {
872 DISPID named_arg
= DISPID_THIS
;
874 DISPPARAMS dp
= {&arg
, &named_arg
, 1, 1};
876 V_VT(&arg
) = VT_DISPATCH
;
877 V_DISPATCH(&arg
) = this_obj
;
880 TRACE("%s >>>\n", debugstr_w(event_info
[eid
].name
));
881 hres
= call_disp_func(handler_vector
->handler_prop
, &dp
, &v
);
883 TRACE("%s <<< %s\n", debugstr_w(event_info
[eid
].name
), debugstr_variant(&v
));
886 if(V_VT(&v
) == VT_BOOL
) {
888 event_obj
->prevent_default
= TRUE
;
889 }else if(V_VT(&v
) != VT_EMPTY
) {
890 FIXME("unhandled result %s\n", debugstr_variant(&v
));
895 WARN("%s <<< %08x\n", debugstr_w(event_info
[eid
].name
), hres
);
899 if(handler_vector
&& handler_vector
->handler_cnt
) {
901 DISPPARAMS dp
= {&arg
, NULL
, 1, 0};
903 V_VT(&arg
) = VT_DISPATCH
;
904 V_DISPATCH(&arg
) = (IDispatch
*)event_obj
;
906 i
= handler_vector
->handler_cnt
;
908 if(handler_vector
->handlers
[i
]) {
911 TRACE("%s [%d] >>>\n", debugstr_w(event_info
[eid
].name
), i
);
912 hres
= call_disp_func(handler_vector
->handlers
[i
], &dp
, &v
);
914 TRACE("%s [%d] <<<\n", debugstr_w(event_info
[eid
].name
), i
);
917 if(V_VT(&v
) == VT_BOOL
) {
919 event_obj
->prevent_default
= TRUE
;
920 }else if(V_VT(&v
) != VT_EMPTY
) {
921 FIXME("unhandled result %s\n", debugstr_variant(&v
));
926 WARN("%s [%d] <<< %08x\n", debugstr_w(event_info
[eid
].name
), i
, hres
);
935 if(cp_container
->forward_container
)
936 cp_container
= cp_container
->forward_container
;
938 for(cp
= cp_container
->cp_list
; cp
; cp
= cp
->next
) {
939 if(cp
->sinks_size
&& is_cp_event(cp
->data
, event_info
[eid
].dispid
)) {
940 for(i
=0; i
< cp
->sinks_size
; i
++) {
941 if(!cp
->sinks
[i
].disp
)
946 TRACE("cp %s [%d] >>>\n", debugstr_w(event_info
[eid
].name
), i
);
947 hres
= call_cp_func(cp
->sinks
[i
].disp
, event_info
[eid
].dispid
, &v
);
949 TRACE("cp %s [%d] <<<\n", debugstr_w(event_info
[eid
].name
), i
);
952 if(V_VT(&v
) == VT_BOOL
) {
954 event_obj
->prevent_default
= TRUE
;
955 }else if(V_VT(&v
) != VT_EMPTY
) {
956 FIXME("unhandled result %s\n", debugstr_variant(&v
));
961 WARN("cp %s [%d] <<< %08x\n", debugstr_w(event_info
[eid
].name
), i
, hres
);
969 void fire_event(HTMLDocumentNode
*doc
, eventid_t eid
, BOOL set_event
, nsIDOMNode
*target
, nsIDOMEvent
*nsevent
)
971 HTMLEventObj
*event_obj
= NULL
;
972 IHTMLEventObj
*prev_event
;
973 nsIDOMNode
*parent
, *nsnode
;
978 TRACE("(%p) %s\n", doc
, debugstr_w(event_info
[eid
].name
));
980 prev_event
= doc
->basedoc
.window
->event
;
982 hres
= get_node(doc
, target
, TRUE
, &node
);
986 event_obj
= create_event(node
, eid
, nsevent
);
987 doc
->basedoc
.window
->event
= &event_obj
->IHTMLEventObj_iface
;
989 doc
->basedoc
.window
->event
= NULL
;
992 nsIDOMNode_GetNodeType(target
, &node_type
);
994 nsIDOMNode_AddRef(nsnode
);
999 hres
= get_node(doc
, nsnode
, FALSE
, &node
);
1000 if(SUCCEEDED(hres
) && node
)
1001 call_event_handlers(doc
, event_obj
, *get_node_event_target(node
),
1002 node
->cp_container
, eid
, (IDispatch
*)&node
->IHTMLDOMNode_iface
);
1004 if(!(event_info
[eid
].flags
& EVENT_BUBBLE
))
1007 nsIDOMNode_GetParentNode(nsnode
, &parent
);
1008 nsIDOMNode_Release(nsnode
);
1013 nsIDOMNode_GetNodeType(nsnode
, &node_type
);
1014 }while(node_type
== ELEMENT_NODE
);
1016 if(!(event_info
[eid
].flags
& EVENT_BUBBLE
))
1020 if(event_info
[eid
].flags
& EVENT_FORWARDBODY
) {
1021 nsIDOMHTMLElement
*nsbody
;
1024 nsres
= nsIDOMHTMLDocument_GetBody(doc
->nsdoc
, &nsbody
);
1025 if(NS_SUCCEEDED(nsres
) && nsbody
) {
1026 hres
= get_node(doc
, (nsIDOMNode
*)nsbody
, FALSE
, &node
);
1027 if(SUCCEEDED(hres
) && node
)
1028 call_event_handlers(doc
, event_obj
, *get_node_event_target(node
),
1029 node
->cp_container
, eid
, (IDispatch
*)&node
->IHTMLDOMNode_iface
);
1030 nsIDOMHTMLElement_Release(nsbody
);
1032 ERR("Could not get body: %08x\n", nsres
);
1036 call_event_handlers(doc
, event_obj
, doc
->node
.event_target
, &doc
->basedoc
.cp_container
, eid
,
1037 (IDispatch
*)&doc
->basedoc
.IHTMLDocument2_iface
);
1041 FIXME("unimplemented node type %d\n", node_type
);
1045 nsIDOMNode_Release(nsnode
);
1047 doc
->basedoc
.window
->event
= prev_event
;
1050 if(event_obj
->prevent_default
&& nsevent
) {
1051 TRACE("calling PreventDefault\n");
1052 nsIDOMEvent_PreventDefault(nsevent
);
1054 IHTMLEventObj_Release(&event_obj
->IHTMLEventObj_iface
);
1058 HRESULT
dispatch_event(HTMLDOMNode
*node
, const WCHAR
*event_name
, VARIANT
*event_obj
, VARIANT_BOOL
*cancelled
)
1062 eid
= attr_to_eid(event_name
);
1063 if(eid
== EVENTID_LAST
) {
1064 WARN("unknown event %s\n", debugstr_w(event_name
));
1065 return E_INVALIDARG
;
1068 if(event_obj
&& V_VT(event_obj
) != VT_EMPTY
&& V_VT(event_obj
) != VT_ERROR
)
1069 FIXME("event_obj not implemented\n");
1071 if(!(event_info
[eid
].flags
& EVENT_DEFAULTLISTENER
)) {
1072 FIXME("not EVENT_DEFAULTEVENTHANDLER\n");
1076 fire_event(node
->doc
, eid
, TRUE
, node
->nsnode
, NULL
);
1078 *cancelled
= VARIANT_TRUE
; /* FIXME */
1082 HRESULT
call_event(HTMLDOMNode
*node
, eventid_t eid
)
1086 if(node
->vtbl
->call_event
) {
1087 BOOL handled
= FALSE
;
1089 hres
= node
->vtbl
->call_event(node
, eid
, &handled
);
1094 fire_event(node
->doc
, eid
, TRUE
, node
->nsnode
, NULL
);
1098 static inline event_target_t
*get_event_target(event_target_t
**event_target_ptr
)
1100 if(!*event_target_ptr
)
1101 *event_target_ptr
= heap_alloc_zero(sizeof(event_target_t
));
1102 return *event_target_ptr
;
1105 static BOOL
alloc_handler_vector(event_target_t
*event_target
, eventid_t eid
, int cnt
)
1107 handler_vector_t
*new_vector
, *handler_vector
= event_target
->event_table
[eid
];
1109 if(handler_vector
) {
1110 if(cnt
<= handler_vector
->handler_cnt
)
1113 new_vector
= heap_realloc_zero(handler_vector
, sizeof(handler_vector_t
) + sizeof(IDispatch
*)*cnt
);
1115 new_vector
= heap_alloc_zero(sizeof(handler_vector_t
) + sizeof(IDispatch
*)*cnt
);
1121 new_vector
->handler_cnt
= cnt
;
1122 event_target
->event_table
[eid
] = new_vector
;
1126 static HRESULT
ensure_nsevent_handler(HTMLDocumentNode
*doc
, event_target_t
*event_target
, nsIDOMNode
*nsnode
, eventid_t eid
)
1131 if(event_info
[eid
].flags
& EVENT_NODEHANDLER
) {
1134 mask
= get_node_handler_mask(eid
);
1135 if(event_target
->node_handlers_mask
& mask
)
1138 add_nsevent_listener(doc
, nsnode
, event_info
[eid
].name
);
1139 event_target
->node_handlers_mask
|= mask
;
1143 if(!(event_info
[eid
].flags
& EVENT_DEFAULTLISTENER
))
1146 if(!doc
->event_vector
) {
1147 doc
->event_vector
= heap_alloc_zero(EVENTID_LAST
*sizeof(BOOL
));
1148 if(!doc
->event_vector
)
1149 return E_OUTOFMEMORY
;
1152 if(!doc
->event_vector
[eid
]) {
1153 doc
->event_vector
[eid
] = TRUE
;
1154 add_nsevent_listener(doc
, NULL
, event_info
[eid
].name
);
1160 static HRESULT
remove_event_handler(event_target_t
**event_target
, eventid_t eid
)
1162 if(*event_target
&& (*event_target
)->event_table
[eid
] && (*event_target
)->event_table
[eid
]->handler_prop
) {
1163 IDispatch_Release((*event_target
)->event_table
[eid
]->handler_prop
);
1164 (*event_target
)->event_table
[eid
]->handler_prop
= NULL
;
1170 static HRESULT
set_event_handler_disp(event_target_t
**event_target_ptr
, nsIDOMNode
*nsnode
, HTMLDocumentNode
*doc
,
1171 eventid_t eid
, IDispatch
*disp
)
1173 event_target_t
*event_target
;
1176 return remove_event_handler(event_target_ptr
, eid
);
1178 event_target
= get_event_target(event_target_ptr
);
1180 return E_OUTOFMEMORY
;
1182 if(!alloc_handler_vector(event_target
, eid
, 0))
1183 return E_OUTOFMEMORY
;
1185 if(event_target
->event_table
[eid
]->handler_prop
)
1186 IDispatch_Release(event_target
->event_table
[eid
]->handler_prop
);
1188 event_target
->event_table
[eid
]->handler_prop
= disp
;
1189 IDispatch_AddRef(disp
);
1191 return ensure_nsevent_handler(doc
, event_target
, nsnode
, eid
);
1194 HRESULT
set_event_handler(event_target_t
**event_target
, nsIDOMNode
*nsnode
, HTMLDocumentNode
*doc
, eventid_t eid
, VARIANT
*var
)
1198 return remove_event_handler(event_target
, eid
);
1201 return set_event_handler_disp(event_target
, nsnode
, doc
, eid
, V_DISPATCH(var
));
1204 FIXME("not supported vt=%d\n", V_VT(var
));
1212 HRESULT
get_event_handler(event_target_t
**event_target
, eventid_t eid
, VARIANT
*var
)
1214 if(*event_target
&& (*event_target
)->event_table
[eid
] && (*event_target
)->event_table
[eid
]->handler_prop
) {
1215 V_VT(var
) = VT_DISPATCH
;
1216 V_DISPATCH(var
) = (*event_target
)->event_table
[eid
]->handler_prop
;
1217 IDispatch_AddRef(V_DISPATCH(var
));
1219 V_VT(var
) = VT_NULL
;
1225 HRESULT
attach_event(event_target_t
**event_target_ptr
, nsIDOMNode
*nsnode
, HTMLDocument
*doc
, BSTR name
,
1226 IDispatch
*disp
, VARIANT_BOOL
*res
)
1228 event_target_t
*event_target
;
1232 eid
= attr_to_eid(name
);
1233 if(eid
== EVENTID_LAST
) {
1234 WARN("Unknown event\n");
1235 *res
= VARIANT_TRUE
;
1239 event_target
= get_event_target(event_target_ptr
);
1241 return E_OUTOFMEMORY
;
1243 if(event_target
->event_table
[eid
]) {
1244 while(i
< event_target
->event_table
[eid
]->handler_cnt
&& event_target
->event_table
[eid
]->handlers
[i
])
1246 if(i
== event_target
->event_table
[eid
]->handler_cnt
&& !alloc_handler_vector(event_target
, eid
, i
+1))
1247 return E_OUTOFMEMORY
;
1248 }else if(!alloc_handler_vector(event_target
, eid
, i
+1)) {
1249 return E_OUTOFMEMORY
;
1252 IDispatch_AddRef(disp
);
1253 event_target
->event_table
[eid
]->handlers
[i
] = disp
;
1255 *res
= VARIANT_TRUE
;
1256 return ensure_nsevent_handler(doc
->doc_node
, event_target
, nsnode
, eid
);
1259 HRESULT
detach_event(event_target_t
*event_target
, HTMLDocument
*doc
, BSTR name
, IDispatch
*disp
)
1267 eid
= attr_to_eid(name
);
1268 if(eid
== EVENTID_LAST
) {
1269 WARN("Unknown event\n");
1273 if(!event_target
->event_table
[eid
])
1276 while(i
< event_target
->event_table
[eid
]->handler_cnt
) {
1277 if(event_target
->event_table
[eid
]->handlers
[i
] == disp
) {
1278 IDispatch_Release(event_target
->event_table
[eid
]->handlers
[i
]);
1279 event_target
->event_table
[eid
]->handlers
[i
] = NULL
;
1287 void update_cp_events(HTMLWindow
*window
, event_target_t
**event_target_ptr
, cp_static_data_t
*cp
, nsIDOMNode
*nsnode
)
1289 event_target_t
*event_target
;
1292 event_target
= get_event_target(event_target_ptr
);
1296 for(i
=0; i
< EVENTID_LAST
; i
++) {
1297 if((event_info
[i
].flags
& EVENT_DEFAULTLISTENER
) && is_cp_event(cp
, event_info
[i
].dispid
))
1298 ensure_nsevent_handler(window
->doc
, event_target
, nsnode
, i
);
1302 void check_event_attr(HTMLDocumentNode
*doc
, nsIDOMElement
*nselem
)
1304 const PRUnichar
*attr_value
;
1305 nsAString attr_name_str
, attr_value_str
;
1312 nsAString_Init(&attr_value_str
, NULL
);
1313 nsAString_Init(&attr_name_str
, NULL
);
1315 for(i
=0; i
< EVENTID_LAST
; i
++) {
1316 nsAString_SetData(&attr_name_str
, event_info
[i
].attr_name
);
1317 nsres
= nsIDOMElement_GetAttribute(nselem
, &attr_name_str
, &attr_value_str
);
1318 if(NS_SUCCEEDED(nsres
)) {
1319 nsAString_GetData(&attr_value_str
, &attr_value
);
1323 TRACE("%p.%s = %s\n", nselem
, debugstr_w(event_info
[i
].attr_name
), debugstr_w(attr_value
));
1325 disp
= script_parse_event(doc
->basedoc
.window
, attr_value
);
1327 hres
= get_node(doc
, (nsIDOMNode
*)nselem
, TRUE
, &node
);
1329 set_event_handler_disp(get_node_event_target(node
), node
->nsnode
, node
->doc
, i
, disp
);
1330 IDispatch_Release(disp
);
1335 nsAString_Finish(&attr_value_str
);
1336 nsAString_Finish(&attr_name_str
);
1339 void release_event_target(event_target_t
*event_target
)
1343 for(i
=0; i
< EVENTID_LAST
; i
++) {
1344 if(event_target
->event_table
[i
]) {
1345 if(event_target
->event_table
[i
]->handler_prop
)
1346 IDispatch_Release(event_target
->event_table
[i
]->handler_prop
);
1347 for(j
=0; j
< event_target
->event_table
[i
]->handler_cnt
; j
++)
1348 if(event_target
->event_table
[i
]->handlers
[j
])
1349 IDispatch_Release(event_target
->event_table
[i
]->handlers
[j
]);
1353 heap_free(event_target
);