ReactOS 0.4.15-dev-5672-gf73ac17
htmlevent.c File Reference
#include "mshtml_private.h"
Include dependency graph for htmlevent.c:

Go to the source code of this file.

Classes

struct  handler_vector_t
 
struct  event_target_t
 
struct  event_info_t
 
struct  HTMLEventObj
 

Macros

#define EVENT_DEFAULTLISTENER   0x0001
 
#define EVENT_BUBBLE   0x0002
 
#define EVENT_FORWARDBODY   0x0004
 
#define EVENT_BIND_TO_BODY   0x0008
 
#define EVENT_CANCELABLE   0x0010
 
#define EVENT_HASDEFAULTHANDLERS   0x0020
 

Enumerations

enum  { EVENTT_NONE , EVENTT_HTML , EVENTT_KEY , EVENTT_MOUSE }
 

Functions

eventid_t str_to_eid (LPCWSTR str)
 
static eventid_t attr_to_eid (LPCWSTR str)
 
static HTMLEventObjimpl_from_IHTMLEventObj (IHTMLEventObj *iface)
 
static HRESULT WINAPI HTMLEventObj_QueryInterface (IHTMLEventObj *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI HTMLEventObj_AddRef (IHTMLEventObj *iface)
 
static ULONG WINAPI HTMLEventObj_Release (IHTMLEventObj *iface)
 
static HRESULT WINAPI HTMLEventObj_GetTypeInfoCount (IHTMLEventObj *iface, UINT *pctinfo)
 
static HRESULT WINAPI HTMLEventObj_GetTypeInfo (IHTMLEventObj *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
 
static HRESULT WINAPI HTMLEventObj_GetIDsOfNames (IHTMLEventObj *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
 
static HRESULT WINAPI HTMLEventObj_Invoke (IHTMLEventObj *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
 
static HRESULT WINAPI HTMLEventObj_get_srcElement (IHTMLEventObj *iface, IHTMLElement **p)
 
static HRESULT WINAPI HTMLEventObj_get_altKey (IHTMLEventObj *iface, VARIANT_BOOL *p)
 
static HRESULT WINAPI HTMLEventObj_get_ctrlKey (IHTMLEventObj *iface, VARIANT_BOOL *p)
 
static HRESULT WINAPI HTMLEventObj_get_shiftKey (IHTMLEventObj *iface, VARIANT_BOOL *p)
 
static HRESULT WINAPI HTMLEventObj_put_returnValue (IHTMLEventObj *iface, VARIANT v)
 
static HRESULT WINAPI HTMLEventObj_get_returnValue (IHTMLEventObj *iface, VARIANT *p)
 
static HRESULT WINAPI HTMLEventObj_put_cancelBubble (IHTMLEventObj *iface, VARIANT_BOOL v)
 
static HRESULT WINAPI HTMLEventObj_get_cancelBubble (IHTMLEventObj *iface, VARIANT_BOOL *p)
 
static HRESULT WINAPI HTMLEventObj_get_fromElement (IHTMLEventObj *iface, IHTMLElement **p)
 
static HRESULT WINAPI HTMLEventObj_get_toElement (IHTMLEventObj *iface, IHTMLElement **p)
 
static HRESULT WINAPI HTMLEventObj_put_keyCode (IHTMLEventObj *iface, LONG v)
 
static HRESULT WINAPI HTMLEventObj_get_keyCode (IHTMLEventObj *iface, LONG *p)
 
static HRESULT WINAPI HTMLEventObj_get_button (IHTMLEventObj *iface, LONG *p)
 
static HRESULT WINAPI HTMLEventObj_get_type (IHTMLEventObj *iface, BSTR *p)
 
static HRESULT WINAPI HTMLEventObj_get_qualifier (IHTMLEventObj *iface, BSTR *p)
 
static HRESULT WINAPI HTMLEventObj_get_reason (IHTMLEventObj *iface, LONG *p)
 
static HRESULT WINAPI HTMLEventObj_get_x (IHTMLEventObj *iface, LONG *p)
 
static HRESULT WINAPI HTMLEventObj_get_y (IHTMLEventObj *iface, LONG *p)
 
static HRESULT WINAPI HTMLEventObj_get_clientX (IHTMLEventObj *iface, LONG *p)
 
static HRESULT WINAPI HTMLEventObj_get_clientY (IHTMLEventObj *iface, LONG *p)
 
static HRESULT WINAPI HTMLEventObj_get_offsetX (IHTMLEventObj *iface, LONG *p)
 
static HRESULT WINAPI HTMLEventObj_get_offsetY (IHTMLEventObj *iface, LONG *p)
 
static HRESULT WINAPI HTMLEventObj_get_screenX (IHTMLEventObj *iface, LONG *p)
 
static HRESULT WINAPI HTMLEventObj_get_screenY (IHTMLEventObj *iface, LONG *p)
 
static HRESULT WINAPI HTMLEventObj_get_srcFilter (IHTMLEventObj *iface, IDispatch **p)
 
static HTMLEventObjunsafe_impl_from_IHTMLEventObj (IHTMLEventObj *iface)
 
static HTMLEventObjcreate_event (void)
 
static HRESULT set_event_info (HTMLEventObj *event, HTMLDOMNode *target, eventid_t eid, nsIDOMEvent *nsevent)
 
HRESULT create_event_obj (IHTMLEventObj **ret)
 
static event_target_tget_event_target_data (EventTarget *event_target, BOOL alloc)
 
static HRESULT call_disp_func (IDispatch *disp, DISPPARAMS *dp, VARIANT *retv)
 
static HRESULT call_cp_func (IDispatch *disp, DISPID dispid, HTMLEventObj *event_obj, VARIANT *retv)
 
static BOOL is_cp_event (cp_static_data_t *data, DISPID dispid)
 
void call_event_handlers (HTMLDocumentNode *doc, HTMLEventObj *event_obj, EventTarget *event_target, ConnectionPointContainer *cp_container, eventid_t eid, IDispatch *this_obj)
 
static void fire_event_obj (HTMLDocumentNode *doc, eventid_t eid, HTMLEventObj *event_obj, nsIDOMNode *target, IDispatch *script_this)
 
void fire_event (HTMLDocumentNode *doc, eventid_t eid, BOOL set_event, nsIDOMNode *target, nsIDOMEvent *nsevent, IDispatch *script_this)
 
HRESULT dispatch_event (HTMLDOMNode *node, const WCHAR *event_name, VARIANT *event_var, VARIANT_BOOL *cancelled)
 
HRESULT call_fire_event (HTMLDOMNode *node, eventid_t eid)
 
static BOOL alloc_handler_vector (event_target_t *event_target, eventid_t eid, int cnt)
 
HRESULT ensure_doc_nsevent_handler (HTMLDocumentNode *doc, eventid_t eid)
 
void detach_events (HTMLDocumentNode *doc)
 
static void bind_event (EventTarget *event_target, eventid_t eid)
 
static void remove_event_handler (EventTarget *event_target, eventid_t eid)
 
static HRESULT set_event_handler_disp (EventTarget *event_target, eventid_t eid, IDispatch *disp)
 
HRESULT set_event_handler (EventTarget *event_target, eventid_t eid, VARIANT *var)
 
HRESULT get_event_handler (EventTarget *event_target, eventid_t eid, VARIANT *var)
 
HRESULT attach_event (EventTarget *event_target, BSTR name, IDispatch *disp, VARIANT_BOOL *res)
 
HRESULT detach_event (EventTarget *event_target, BSTR name, IDispatch *disp)
 
void bind_target_event (HTMLDocumentNode *doc, EventTarget *event_target, const WCHAR *event, IDispatch *disp)
 
void update_doc_cp_events (HTMLDocumentNode *doc, cp_static_data_t *cp)
 
void check_event_attr (HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
 
HRESULT doc_init_events (HTMLDocumentNode *doc)
 
void release_event_target (event_target_t *event_target)
 

Variables

static const WCHAR abortW [] = {'a','b','o','r','t',0}
 
static const WCHAR onabortW [] = {'o','n','a','b','o','r','t',0}
 
static const WCHAR beforeunloadW [] = {'b','e','f','o','r','e','u','n','l','o','a','d',0}
 
static const WCHAR onbeforeunloadW [] = {'o','n','b','e','f','o','r','e','u','n','l','o','a','d',0}
 
static const WCHAR blurW [] = {'b','l','u','r',0}
 
static const WCHAR onblurW [] = {'o','n','b','l','u','r',0}
 
static const WCHAR changeW [] = {'c','h','a','n','g','e',0}
 
static const WCHAR onchangeW [] = {'o','n','c','h','a','n','g','e',0}
 
static const WCHAR clickW [] = {'c','l','i','c','k',0}
 
static const WCHAR onclickW [] = {'o','n','c','l','i','c','k',0}
 
static const WCHAR contextmenuW [] = {'c','o','n','t','e','x','t','m','e','n','u',0}
 
static const WCHAR oncontextmenuW [] = {'o','n','c','o','n','t','e','x','t','m','e','n','u',0}
 
static const WCHAR dataavailableW [] = {'d','a','t','a','a','v','a','i','l','a','b','l','e',0}
 
static const WCHAR ondataavailableW [] = {'o','n','d','a','t','a','a','v','a','i','l','a','b','l','e',0}
 
static const WCHAR dblclickW [] = {'d','b','l','c','l','i','c','k',0}
 
static const WCHAR ondblclickW [] = {'o','n','d','b','l','c','l','i','c','k',0}
 
static const WCHAR dragW [] = {'d','r','a','g',0}
 
static const WCHAR ondragW [] = {'o','n','d','r','a','g',0}
 
static const WCHAR dragstartW [] = {'d','r','a','g','s','t','a','r','t',0}
 
static const WCHAR ondragstartW [] = {'o','n','d','r','a','g','s','t','a','r','t',0}
 
static const WCHAR errorW [] = {'e','r','r','o','r',0}
 
static const WCHAR onerrorW [] = {'o','n','e','r','r','o','r',0}
 
static const WCHAR focusW [] = {'f','o','c','u','s',0}
 
static const WCHAR onfocusW [] = {'o','n','f','o','c','u','s',0}
 
static const WCHAR focusinW [] = {'f','o','c','u','s','i','n',0}
 
static const WCHAR onfocusinW [] = {'o','n','f','o','c','u','s','i','n',0}
 
static const WCHAR helpW [] = {'h','e','l','p',0}
 
static const WCHAR onhelpW [] = {'o','n','h','e','l','p',0}
 
static const WCHAR keydownW [] = {'k','e','y','d','o','w','n',0}
 
static const WCHAR onkeydownW [] = {'o','n','k','e','y','d','o','w','n',0}
 
static const WCHAR keypressW [] = {'k','e','y','p','r','e','s','s',0}
 
static const WCHAR onkeypressW [] = {'o','n','k','e','y','p','r','e','s','s',0}
 
static const WCHAR keyupW [] = {'k','e','y','u','p',0}
 
static const WCHAR onkeyupW [] = {'o','n','k','e','y','u','p',0}
 
static const WCHAR loadW [] = {'l','o','a','d',0}
 
static const WCHAR onloadW [] = {'o','n','l','o','a','d',0}
 
static const WCHAR mousedownW [] = {'m','o','u','s','e','d','o','w','n',0}
 
static const WCHAR onmousedownW [] = {'o','n','m','o','u','s','e','d','o','w','n',0}
 
static const WCHAR mousemoveW [] = {'m','o','u','s','e','m','o','v','e',0}
 
static const WCHAR onmousemoveW [] = {'o','n','m','o','u','s','e','m','o','v','e',0}
 
static const WCHAR mouseoutW [] = {'m','o','u','s','e','o','u','t',0}
 
static const WCHAR onmouseoutW [] = {'o','n','m','o','u','s','e','o','u','t',0}
 
static const WCHAR mouseoverW [] = {'m','o','u','s','e','o','v','e','r',0}
 
static const WCHAR onmouseoverW [] = {'o','n','m','o','u','s','e','o','v','e','r',0}
 
static const WCHAR mouseupW [] = {'m','o','u','s','e','u','p',0}
 
static const WCHAR onmouseupW [] = {'o','n','m','o','u','s','e','u','p',0}
 
static const WCHAR mousewheelW [] = {'m','o','u','s','e','w','h','e','e','l',0}
 
static const WCHAR onmousewheelW [] = {'o','n','m','o','u','s','e','w','h','e','e','l',0}
 
static const WCHAR pasteW [] = {'p','a','s','t','e',0}
 
static const WCHAR onpasteW [] = {'o','n','p','a','s','t','e',0}
 
static const WCHAR readystatechangeW [] = {'r','e','a','d','y','s','t','a','t','e','c','h','a','n','g','e',0}
 
static const WCHAR onreadystatechangeW [] = {'o','n','r','e','a','d','y','s','t','a','t','e','c','h','a','n','g','e',0}
 
static const WCHAR resizeW [] = {'r','e','s','i','z','e',0}
 
static const WCHAR onresizeW [] = {'o','n','r','e','s','i','z','e',0}
 
static const WCHAR scrollW [] = {'s','c','r','o','l','l',0}
 
static const WCHAR onscrollW [] = {'o','n','s','c','r','o','l','l',0}
 
static const WCHAR selectstartW [] = {'s','e','l','e','c','t','s','t','a','r','t',0}
 
static const WCHAR onselectstartW [] = {'o','n','s','e','l','e','c','t','s','t','a','r','t',0}
 
static const WCHAR submitW [] = {'s','u','b','m','i','t',0}
 
static const WCHAR onsubmitW [] = {'o','n','s','u','b','m','i','t',0}
 
static const WCHAR HTMLEventsW [] = {'H','T','M','L','E','v','e','n','t','s',0}
 
static const WCHAR KeyboardEventW [] = {'K','e','y','b','o','a','r','d','E','v','e','n','t',0}
 
static const WCHAR MouseEventW [] = {'M','o','u','s','e','E','v','e','n','t',0}
 
static const WCHARevent_types []
 
static const event_info_t event_info []
 
static const IHTMLEventObjVtbl HTMLEventObjVtbl
 
static const tid_t HTMLEventObj_iface_tids []
 
static dispex_static_data_t HTMLEventObj_dispex
 

Macro Definition Documentation

◆ EVENT_BIND_TO_BODY

#define EVENT_BIND_TO_BODY   0x0008

Definition at line 150 of file htmlevent.c.

◆ EVENT_BUBBLE

#define EVENT_BUBBLE   0x0002

Definition at line 148 of file htmlevent.c.

◆ EVENT_CANCELABLE

#define EVENT_CANCELABLE   0x0010

Definition at line 151 of file htmlevent.c.

◆ EVENT_DEFAULTLISTENER

#define EVENT_DEFAULTLISTENER   0x0001

Definition at line 147 of file htmlevent.c.

◆ EVENT_FORWARDBODY

#define EVENT_FORWARDBODY   0x0004

Definition at line 149 of file htmlevent.c.

◆ EVENT_HASDEFAULTHANDLERS

#define EVENT_HASDEFAULTHANDLERS   0x0020

Definition at line 152 of file htmlevent.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
EVENTT_NONE 
EVENTT_HTML 
EVENTT_KEY 
EVENTT_MOUSE 

Definition at line 125 of file htmlevent.c.

125 {
130};
@ EVENTT_MOUSE
Definition: htmlevent.c:129
@ EVENTT_HTML
Definition: htmlevent.c:127
@ EVENTT_KEY
Definition: htmlevent.c:128
@ EVENTT_NONE
Definition: htmlevent.c:126

Function Documentation

◆ alloc_handler_vector()

static BOOL alloc_handler_vector ( event_target_t event_target,
eventid_t  eid,
int  cnt 
)
static

Definition at line 1298 of file htmlevent.c.

1299{
1300 handler_vector_t *new_vector, *handler_vector = event_target->event_table[eid];
1301
1302 if(handler_vector) {
1303 if(cnt <= handler_vector->handler_cnt)
1304 return TRUE;
1305
1306 new_vector = heap_realloc_zero(handler_vector, sizeof(handler_vector_t) + sizeof(IDispatch*)*cnt);
1307 }else {
1308 new_vector = heap_alloc_zero(sizeof(handler_vector_t) + sizeof(IDispatch*)*cnt);
1309 }
1310
1311 if(!new_vector)
1312 return FALSE;
1313
1314 new_vector->handler_cnt = cnt;
1315 event_target->event_table[eid] = new_vector;
1316 return TRUE;
1317}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
handler_vector_t * event_table[EVENTID_LAST]
Definition: htmlevent.c:28
DWORD handler_cnt
Definition: htmlevent.c:23

Referenced by attach_event(), and set_event_handler_disp().

◆ attach_event()

HRESULT attach_event ( EventTarget event_target,
BSTR  name,
IDispatch disp,
VARIANT_BOOL res 
)

Definition at line 1469 of file htmlevent.c.

1470{
1472 eventid_t eid;
1473 DWORD i = 0;
1474
1475 eid = attr_to_eid(name);
1476 if(eid == EVENTID_LAST) {
1477 WARN("Unknown event\n");
1478 *res = VARIANT_TRUE;
1479 return S_OK;
1480 }
1481
1482 data = get_event_target_data(event_target, TRUE);
1483 if(!data)
1484 return E_OUTOFMEMORY;
1485
1486 if(data->event_table[eid]) {
1487 while(i < data->event_table[eid]->handler_cnt && data->event_table[eid]->handlers[i])
1488 i++;
1489 if(i == data->event_table[eid]->handler_cnt && !alloc_handler_vector(data, eid, i+1))
1490 return E_OUTOFMEMORY;
1491 }else if(!alloc_handler_vector(data, eid, i+1)) {
1492 return E_OUTOFMEMORY;
1493 }
1494
1495 IDispatch_AddRef(disp);
1496 data->event_table[eid]->handlers[i] = disp;
1497
1498 bind_event(event_target, eid);
1499
1500 *res = VARIANT_TRUE;
1501 return S_OK;
1502}
#define WARN(fmt,...)
Definition: debug.h:112
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint res
Definition: glext.h:9613
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static BOOL alloc_handler_vector(event_target_t *event_target, eventid_t eid, int cnt)
Definition: htmlevent.c:1298
static event_target_t * get_event_target_data(EventTarget *event_target, BOOL alloc)
Definition: htmlevent.c:870
static void bind_event(EventTarget *event_target, eventid_t eid)
Definition: htmlevent.c:1357
static eventid_t attr_to_eid(LPCWSTR str)
Definition: htmlevent.c:230
eventid_t
Definition: htmlevent.h:21
@ EVENTID_LAST
Definition: htmlevent.h:52
#define S_OK
Definition: intsafe.h:52
Definition: name.c:39

Referenced by HTMLDocument3_attachEvent(), HTMLElement2_attachEvent(), and HTMLWindow3_attachEvent().

◆ attr_to_eid()

static eventid_t attr_to_eid ( LPCWSTR  str)
static

Definition at line 230 of file htmlevent.c.

231{
232 int i;
233
234 for(i=0; i < sizeof(event_info)/sizeof(event_info[0]); i++) {
235 if(!strcmpW(event_info[i].attr_name, str))
236 return i;
237 }
238
239 return EVENTID_LAST;
240}
static const event_info_t event_info[]
Definition: htmlevent.c:154
#define strcmpW(s1, s2)
Definition: unicode.h:38
const WCHAR * str

Referenced by attach_event(), bind_target_event(), detach_event(), and dispatch_event().

◆ bind_event()

static void bind_event ( EventTarget event_target,
eventid_t  eid 
)
static

Definition at line 1357 of file htmlevent.c.

1358{
1359 if(event_target->dispex.data->vtbl->bind_event)
1360 event_target->dispex.data->vtbl->bind_event(&event_target->dispex, eid);
1361 else
1362 FIXME("Unsupported event binding on target %p\n", event_target);
1363}
#define FIXME(fmt,...)
Definition: debug.h:111
dispex_static_data_t * data
DispatchEx dispex
const dispex_static_data_vtbl_t * vtbl
void(* bind_event)(DispatchEx *, int)

Referenced by attach_event(), and set_event_handler_disp().

◆ bind_target_event()

void bind_target_event ( HTMLDocumentNode doc,
EventTarget event_target,
const WCHAR event,
IDispatch disp 
)

Definition at line 1534 of file htmlevent.c.

1535{
1536 eventid_t eid;
1537
1538 TRACE("(%p %p %s %p)\n", doc, event_target, debugstr_w(event), disp);
1539
1540 eid = attr_to_eid(event);
1541 if(eid == EVENTID_LAST) {
1542 WARN("Unsupported event %s\n", debugstr_w(event));
1543 return;
1544 }
1545
1546 set_event_handler_disp(event_target, eid, disp);
1547}
struct _cl_event * event
Definition: glext.h:7739
static HRESULT set_event_handler_disp(EventTarget *event_target, eventid_t eid, IDispatch *disp)
Definition: htmlevent.c:1382
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by bind_event_scripts().

◆ call_cp_func()

static HRESULT call_cp_func ( IDispatch disp,
DISPID  dispid,
HTMLEventObj event_obj,
VARIANT retv 
)
static

Definition at line 904 of file htmlevent.c.

905{
906 DISPPARAMS dp = {NULL,NULL,0,0};
907 VARIANT event_arg;
908 ULONG argerr;
909 EXCEPINFO ei;
910
911 if(event_obj) {
912 V_VT(&event_arg) = VT_DISPATCH;
913 V_DISPATCH(&event_arg) = (IDispatch*)&event_obj->IHTMLEventObj_iface;
914 dp.rgvarg = &event_arg;
915 dp.cArgs = 1;
916 }
917
918 memset(&ei, 0, sizeof(ei));
919 return IDispatch_Invoke(disp, dispid, &IID_NULL, 0, DISPATCH_METHOD, &dp, retv, &ei, &argerr);
920}
#define NULL
Definition: types.h:112
@ VT_DISPATCH
Definition: compat.h:2304
struct stdole::DISPPARAMS DISPPARAMS
struct stdole::EXCEPINFO EXCEPINFO
#define DISPATCH_METHOD
Definition: oleauto.h:1006
#define V_VT(A)
Definition: oleauto.h:211
#define V_DISPATCH(A)
Definition: oleauto.h:239
#define IID_NULL
Definition: guiddef.h:98
#define memset(x, y, z)
Definition: compat.h:39
IHTMLEventObj IHTMLEventObj_iface
Definition: htmlevent.c:244
uint32_t ULONG
Definition: typedefs.h:59

Referenced by call_event_handlers().

◆ call_disp_func()

static HRESULT call_disp_func ( IDispatch disp,
DISPPARAMS *  dp,
VARIANT retv 
)
static

Definition at line 883 of file htmlevent.c.

884{
885 IDispatchEx *dispex;
886 EXCEPINFO ei;
888
889 memset(&ei, 0, sizeof(ei));
890
891 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
892 if(SUCCEEDED(hres)) {
893 hres = IDispatchEx_InvokeEx(dispex, 0, GetUserDefaultLCID(), DISPATCH_METHOD, dp, retv, &ei, NULL);
894 IDispatchEx_Release(dispex);
895 }else {
896 TRACE("Could not get IDispatchEx interface: %08x\n", hres);
897 hres = IDispatch_Invoke(disp, 0, &IID_NULL, GetUserDefaultLCID(), DISPATCH_METHOD,
898 dp, retv, &ei, NULL);
899 }
900
901 return hres;
902}
#define SUCCEEDED(hr)
Definition: intsafe.h:50
LCID WINAPI GetUserDefaultLCID(void)
Definition: lang.c:772
HRESULT hres
Definition: protocol.c:465

Referenced by call_event_handlers().

◆ call_event_handlers()

void call_event_handlers ( HTMLDocumentNode doc,
HTMLEventObj event_obj,
EventTarget event_target,
ConnectionPointContainer cp_container,
eventid_t  eid,
IDispatch this_obj 
)

Definition at line 952 of file htmlevent.c.

954{
956 const BOOL cancelable = event_info[eid].flags & EVENT_CANCELABLE;
957 VARIANT v;
959
960 if(data && data->event_table[eid] && data->event_table[eid]->handler_prop) {
961 DISPID named_arg = DISPID_THIS;
963 DISPPARAMS dp = {&arg, &named_arg, 1, 1};
964
965 V_VT(&arg) = VT_DISPATCH;
966 V_DISPATCH(&arg) = this_obj;
967 V_VT(&v) = VT_EMPTY;
968
969 TRACE("%s >>>\n", debugstr_w(event_info[eid].name));
970 hres = call_disp_func(data->event_table[eid]->handler_prop, &dp, &v);
971 if(hres == S_OK) {
972 TRACE("%s <<< %s\n", debugstr_w(event_info[eid].name), debugstr_variant(&v));
973
974 if(cancelable) {
975 if(V_VT(&v) == VT_BOOL) {
976 if(!V_BOOL(&v))
977 event_obj->prevent_default = TRUE;
978 }else if(V_VT(&v) != VT_EMPTY) {
979 FIXME("unhandled result %s\n", debugstr_variant(&v));
980 }
981 }
982 VariantClear(&v);
983 }else {
984 WARN("%s <<< %08x\n", debugstr_w(event_info[eid].name), hres);
985 }
986 }
987
988 if(data && data->event_table[eid] && data->event_table[eid]->handler_cnt) {
990 DISPPARAMS dp = {&arg, NULL, 1, 0};
991 int i;
992
993 V_VT(&arg) = VT_DISPATCH;
994 V_DISPATCH(&arg) = (IDispatch*)event_obj;
995
996 i = data->event_table[eid]->handler_cnt;
997 while(i--) {
998 if(data->event_table[eid]->handlers[i]) {
999 V_VT(&v) = VT_EMPTY;
1000
1001 TRACE("%s [%d] >>>\n", debugstr_w(event_info[eid].name), i);
1002 hres = call_disp_func(data->event_table[eid]->handlers[i], &dp, &v);
1003 if(hres == S_OK) {
1004 TRACE("%s [%d] <<<\n", debugstr_w(event_info[eid].name), i);
1005
1006 if(cancelable) {
1007 if(V_VT(&v) == VT_BOOL) {
1008 if(!V_BOOL(&v))
1009 event_obj->prevent_default = TRUE;
1010 }else if(V_VT(&v) != VT_EMPTY) {
1011 FIXME("unhandled result %s\n", debugstr_variant(&v));
1012 }
1013 }
1014 VariantClear(&v);
1015 }else {
1016 WARN("%s [%d] <<< %08x\n", debugstr_w(event_info[eid].name), i, hres);
1017 }
1018 }
1019 }
1020 }
1021
1022 /*
1023 * NOTE: CP events may require doc_obj reference, which we don't own. We make sure that
1024 * it's safe to call event handler by checking nsevent_listener, which is NULL for
1025 * detached documents.
1026 */
1027 if(cp_container && cp_container->forward_container)
1028 cp_container = cp_container->forward_container;
1029 if(cp_container && cp_container->cps && doc->nsevent_listener) {
1031 unsigned i, j;
1032
1033 for(j=0; cp_container->cp_entries[j].riid; j++) {
1034 cp = cp_container->cps + j;
1035 if(!cp->sinks_size || !is_cp_event(cp->data, event_info[eid].dispid))
1036 continue;
1037
1038 for(i=0; doc->nsevent_listener && i < cp->sinks_size; i++) {
1039 if(!cp->sinks[i].disp)
1040 continue;
1041
1042 V_VT(&v) = VT_EMPTY;
1043
1044 TRACE("cp %s [%u] >>>\n", debugstr_w(event_info[eid].name), i);
1045 hres = call_cp_func(cp->sinks[i].disp, event_info[eid].dispid,
1046 cp->data->pass_event_arg ? event_obj : NULL, &v);
1047 if(hres == S_OK) {
1048 TRACE("cp %s [%u] <<<\n", debugstr_w(event_info[eid].name), i);
1049
1050 if(cancelable) {
1051 if(V_VT(&v) == VT_BOOL) {
1052 if(!V_BOOL(&v))
1053 event_obj->prevent_default = TRUE;
1054 }else if(V_VT(&v) != VT_EMPTY) {
1055 FIXME("unhandled result %s\n", debugstr_variant(&v));
1056 }
1057 }
1058 VariantClear(&v);
1059 }else {
1060 WARN("cp %s [%u] <<< %08x\n", debugstr_w(event_info[eid].name), i, hres);
1061 }
1062 }
1063
1064 if(!doc->nsevent_listener)
1065 break;
1066 }
1067 }
1068}
@ VT_BOOL
Definition: compat.h:2306
@ VT_EMPTY
Definition: compat.h:2295
unsigned int BOOL
Definition: ntddk_ex.h:94
const GLdouble * v
Definition: gl.h:2040
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
static HRESULT call_disp_func(IDispatch *disp, DISPPARAMS *dp, VARIANT *retv)
Definition: htmlevent.c:883
#define EVENT_CANCELABLE
Definition: htmlevent.c:151
static BOOL is_cp_event(cp_static_data_t *data, DISPID dispid)
Definition: htmlevent.c:922
static HRESULT call_cp_func(IDispatch *disp, DISPID dispid, HTMLEventObj *event_obj, VARIANT *retv)
Definition: htmlevent.c:904
POINT cp
Definition: magnifier.c:59
static const char * debugstr_variant(const VARIANT *var)
Definition: container.c:46
static VARIANTARG static DISPID
Definition: ordinal.c:49
#define V_BOOL(A)
Definition: oleauto.h:224
#define DISPID_THIS
Definition: olectl.h:395
ConnectionPoint * cps
struct ConnectionPointContainer * forward_container
const cpc_entry_t * cp_entries
nsDocumentEventListener * nsevent_listener
BOOL prevent_default
Definition: htmlevent.c:252
const IID * riid
DWORD flags
Definition: htmlevent.c:144
DISPID dispid
Definition: htmlevent.c:143
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
void * arg
Definition: msvc.h:10

Referenced by fire_event_obj(), and XMLHttpReqEventListener_HandleEvent().

◆ call_fire_event()

HRESULT call_fire_event ( HTMLDOMNode node,
eventid_t  eid 
)

Definition at line 1282 of file htmlevent.c.

1283{
1284 HRESULT hres;
1285
1286 if(node->vtbl->fire_event) {
1287 BOOL handled = FALSE;
1288
1289 hres = node->vtbl->fire_event(node, eid, &handled);
1290 if(handled)
1291 return hres;
1292 }
1293
1294 fire_event(node->doc, eid, TRUE, node->nsnode, NULL, NULL);
1295 return S_OK;
1296}
void fire_event(HTMLDocumentNode *doc, eventid_t eid, BOOL set_event, nsIDOMNode *target, nsIDOMEvent *nsevent, IDispatch *script_this)
Definition: htmlevent.c:1195
Definition: dlist.c:348

Referenced by HTMLElement_click().

◆ check_event_attr()

void check_event_attr ( HTMLDocumentNode doc,
nsIDOMHTMLElement nselem 
)

Definition at line 1559 of file htmlevent.c.

1560{
1561 const PRUnichar *attr_value;
1562 nsAString attr_value_str;
1563 IDispatch *disp;
1565 int i;
1566 nsresult nsres;
1567 HRESULT hres;
1568
1569 for(i=0; i < EVENTID_LAST; i++) {
1570 nsres = get_elem_attr_value(nselem, event_info[i].attr_name, &attr_value_str, &attr_value);
1571 if(NS_SUCCEEDED(nsres)) {
1572 if(!*attr_value)
1573 continue;
1574
1575 TRACE("%p.%s = %s\n", nselem, debugstr_w(event_info[i].attr_name), debugstr_w(attr_value));
1576
1577 disp = script_parse_event(doc->window, attr_value);
1578 if(disp) {
1579 hres = get_node(doc, (nsIDOMNode*)nselem, TRUE, &node);
1580 if(SUCCEEDED(hres)) {
1581 set_event_handler_disp(&node->event_target, i, disp);
1583 }
1584 IDispatch_Release(disp);
1585 }
1586 nsAString_Finish(&attr_value_str);
1587 }
1588 }
1589}
nsresult get_elem_attr_value(nsIDOMHTMLElement *nselem, const WCHAR *name, nsAString *val_str, const PRUnichar **val)
Definition: htmlelem.c:143
HRESULT get_node(HTMLDocumentNode *This, nsIDOMNode *nsnode, BOOL create, HTMLDOMNode **ret)
Definition: htmlnode.c:1339
IDispatch * script_parse_event(HTMLInnerWindow *, LPCWSTR) DECLSPEC_HIDDEN
Definition: script.c:1184
void nsAString_Finish(nsAString *) DECLSPEC_HIDDEN
Definition: nsembed.c:836
static void node_release(HTMLDOMNode *node)
#define NS_SUCCEEDED(res)
WCHAR PRUnichar
Definition: nsiface.idl:48
HTMLInnerWindow * window

Referenced by nsDocumentObserver_BindToDocument().

◆ create_event()

static HTMLEventObj * create_event ( void  )
static

Definition at line 816 of file htmlevent.c.

817{
819
820 ret = heap_alloc_zero(sizeof(*ret));
821 if(!ret)
822 return NULL;
823
824 ret->IHTMLEventObj_iface.lpVtbl = &HTMLEventObjVtbl;
825 ret->ref = 1;
826
827 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLEventObj_iface, &HTMLEventObj_dispex);
828
829 return ret;
830}
static dispex_static_data_t HTMLEventObj_dispex
Definition: htmlevent.c:809
static const IHTMLEventObjVtbl HTMLEventObjVtbl
Definition: htmlevent.c:764
HRESULT init_dispex(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *prototype)
Definition: dispex.c:919
int ret

Referenced by create_event_obj(), and fire_event().

◆ create_event_obj()

HRESULT create_event_obj ( IHTMLEventObj **  ret)

Definition at line 858 of file htmlevent.c.

859{
861
862 event = create_event();
863 if(!event)
864 return E_OUTOFMEMORY;
865
866 *ret = &event->IHTMLEventObj_iface;
867 return S_OK;
868}
static HTMLEventObj * create_event(void)
Definition: htmlevent.c:816

Referenced by HTMLDocument4_createEventObject().

◆ detach_event()

HRESULT detach_event ( EventTarget event_target,
BSTR  name,
IDispatch disp 
)

Definition at line 1504 of file htmlevent.c.

1505{
1507 eventid_t eid;
1508 DWORD i = 0;
1509
1510 eid = attr_to_eid(name);
1511 if(eid == EVENTID_LAST) {
1512 WARN("Unknown event\n");
1513 return S_OK;
1514 }
1515
1516 data = get_event_target_data(event_target, FALSE);
1517 if(!data)
1518 return S_OK;
1519
1520 if(!data->event_table[eid])
1521 return S_OK;
1522
1523 while(i < data->event_table[eid]->handler_cnt) {
1524 if(data->event_table[eid]->handlers[i] == disp) {
1525 IDispatch_Release(data->event_table[eid]->handlers[i]);
1526 data->event_table[eid]->handlers[i] = NULL;
1527 }
1528 i++;
1529 }
1530
1531 return S_OK;
1532}

Referenced by HTMLDocument3_detachEvent(), HTMLElement2_detachEvent(), and HTMLWindow3_detachEvent().

◆ detach_events()

void detach_events ( HTMLDocumentNode doc)

Definition at line 1341 of file htmlevent.c.

1342{
1343 if(doc->event_vector) {
1344 int i;
1345
1346 for(i=0; i < EVENTID_LAST; i++) {
1347 if(doc->event_vector[i]) {
1349 doc->event_vector[i] = FALSE;
1350 }
1351 }
1352 }
1353
1354 release_nsevents(doc);
1355}
void release_nsevents(HTMLDocumentNode *) DECLSPEC_HIDDEN
Definition: nsevents.c:394
void detach_nsevent(HTMLDocumentNode *, const WCHAR *) DECLSPEC_HIDDEN
Definition: nsevents.c:389

Referenced by detach_inner_window(), and HTMLDocumentNode_destructor().

◆ dispatch_event()

HRESULT dispatch_event ( HTMLDOMNode node,
const WCHAR event_name,
VARIANT event_var,
VARIANT_BOOL cancelled 
)

Definition at line 1225 of file htmlevent.c.

1226{
1227 HTMLEventObj *event_obj = NULL;
1228 eventid_t eid;
1229 HRESULT hres;
1230
1231 eid = attr_to_eid(event_name);
1232 if(eid == EVENTID_LAST) {
1233 WARN("unknown event %s\n", debugstr_w(event_name));
1234 return E_INVALIDARG;
1235 }
1236
1237 if(event_var && V_VT(event_var) != VT_EMPTY && V_VT(event_var) != VT_ERROR) {
1238 if(V_VT(event_var) != VT_DISPATCH) {
1239 FIXME("event_var %s not supported\n", debugstr_variant(event_var));
1240 return E_NOTIMPL;
1241 }
1242
1243 if(V_DISPATCH(event_var)) {
1244 IHTMLEventObj *event_iface;
1245
1246 hres = IDispatch_QueryInterface(V_DISPATCH(event_var), &IID_IHTMLEventObj, (void**)&event_iface);
1247 if(FAILED(hres)) {
1248 FIXME("No IHTMLEventObj iface\n");
1249 return hres;
1250 }
1251
1252 event_obj = unsafe_impl_from_IHTMLEventObj(event_iface);
1253 if(!event_obj) {
1254 ERR("Not our IHTMLEventObj?\n");
1255 IHTMLEventObj_Release(event_iface);
1256 return E_FAIL;
1257 }
1258 }
1259 }
1260
1261 if(event_obj) {
1262 hres = set_event_info(event_obj, node, eid, NULL);
1263 if(SUCCEEDED(hres))
1264 fire_event_obj(node->doc, eid, event_obj, node->nsnode, NULL);
1265
1266 IHTMLEventObj_Release(&event_obj->IHTMLEventObj_iface);
1267 if(FAILED(hres))
1268 return hres;
1269 }else {
1270 if(!(event_info[eid].flags & EVENT_DEFAULTLISTENER)) {
1271 FIXME("not EVENT_DEFAULTEVENTHANDLER\n");
1272 return E_NOTIMPL;
1273 }
1274
1275 fire_event(node->doc, eid, TRUE, node->nsnode, NULL, NULL);
1276 }
1277
1278 *cancelled = VARIANT_TRUE; /* FIXME */
1279 return S_OK;
1280}
#define ERR(fmt,...)
Definition: debug.h:110
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
@ VT_ERROR
Definition: compat.h:2305
GLbitfield flags
Definition: glext.h:7161
#define EVENT_DEFAULTLISTENER
Definition: htmlevent.c:147
static void fire_event_obj(HTMLDocumentNode *doc, eventid_t eid, HTMLEventObj *event_obj, nsIDOMNode *target, IDispatch *script_this)
Definition: htmlevent.c:1070
static HRESULT set_event_info(HTMLEventObj *event, HTMLDOMNode *target, eventid_t eid, nsIDOMEvent *nsevent)
Definition: htmlevent.c:832
static HTMLEventObj * unsafe_impl_from_IHTMLEventObj(IHTMLEventObj *iface)
Definition: htmlevent.c:799
#define FAILED(hr)
Definition: intsafe.h:51

Referenced by HTMLDocument4_fireEvent(), and HTMLElement3_fireEvent().

◆ doc_init_events()

HRESULT doc_init_events ( HTMLDocumentNode doc)

Definition at line 1591 of file htmlevent.c.

1592{
1593 unsigned i;
1594 HRESULT hres;
1595
1596 doc->event_vector = heap_alloc_zero(EVENTID_LAST*sizeof(BOOL));
1597 if(!doc->event_vector)
1598 return E_OUTOFMEMORY;
1599
1600 init_nsevents(doc);
1601
1602 for(i=0; i < EVENTID_LAST; i++) {
1605 if(FAILED(hres))
1606 return hres;
1607 }
1608 }
1609
1610 return S_OK;
1611}
#define EVENT_HASDEFAULTHANDLERS
Definition: htmlevent.c:152
HRESULT ensure_doc_nsevent_handler(HTMLDocumentNode *doc, eventid_t eid)
Definition: htmlevent.c:1319
void init_nsevents(HTMLDocumentNode *) DECLSPEC_HIDDEN
Definition: nsevents.c:413

Referenced by create_doc_from_nsdoc().

◆ ensure_doc_nsevent_handler()

HRESULT ensure_doc_nsevent_handler ( HTMLDocumentNode doc,
eventid_t  eid 
)

Definition at line 1319 of file htmlevent.c.

1320{
1321 nsIDOMNode *nsnode = NULL;
1322
1323 TRACE("%s\n", debugstr_w(event_info[eid].name));
1324
1325 if(!doc->nsdoc || doc->event_vector[eid] || !(event_info[eid].flags & (EVENT_DEFAULTLISTENER|EVENT_BIND_TO_BODY)))
1326 return S_OK;
1327
1329 nsnode = doc->node.nsnode;
1330 nsIDOMNode_AddRef(nsnode);
1331 }
1332
1333 doc->event_vector[eid] = TRUE;
1334 add_nsevent_listener(doc, nsnode, event_info[eid].name);
1335
1336 if(nsnode)
1337 nsIDOMNode_Release(nsnode);
1338 return S_OK;
1339}
#define EVENT_BIND_TO_BODY
Definition: htmlevent.c:150
void add_nsevent_listener(HTMLDocumentNode *, nsIDOMNode *, LPCWSTR) DECLSPEC_HIDDEN
Definition: nsevents.c:346
nsIDOMNode * nsnode
HTMLDOMNode node
nsIDOMHTMLDocument * nsdoc

Referenced by doc_init_events(), HTMLDocumentNode_bind_event(), and update_doc_cp_events().

◆ fire_event()

void fire_event ( HTMLDocumentNode doc,
eventid_t  eid,
BOOL  set_event,
nsIDOMNode target,
nsIDOMEvent nsevent,
IDispatch script_this 
)

Definition at line 1195 of file htmlevent.c.

1197{
1198 HTMLEventObj *event_obj = NULL;
1200 HRESULT hres;
1201
1202 if(set_event) {
1203 hres = get_node(doc, target, TRUE, &node);
1204 if(FAILED(hres))
1205 return;
1206
1207 event_obj = create_event();
1209 if(!event_obj)
1210 return;
1211
1212 hres = set_event_info(event_obj, node, eid, nsevent);
1213 if(FAILED(hres)) {
1214 IHTMLEventObj_Release(&event_obj->IHTMLEventObj_iface);
1215 return;
1216 }
1217 }
1218
1219 fire_event_obj(doc, eid, event_obj, target, script_this);
1220
1221 if(event_obj)
1222 IHTMLEventObj_Release(&event_obj->IHTMLEventObj_iface);
1223}
GLenum target
Definition: glext.h:7315

Referenced by call_fire_event(), dispatch_event(), fire_readystatechange_proc(), handle_htmlevent(), handle_load(), HTMLElement_handle_event(), notif_readystate(), nsContextMenuListener_OnShowContextMenu(), and set_script_elem_readystate().

◆ fire_event_obj()

static void fire_event_obj ( HTMLDocumentNode doc,
eventid_t  eid,
HTMLEventObj event_obj,
nsIDOMNode target,
IDispatch script_this 
)
static

Definition at line 1070 of file htmlevent.c.

1072{
1073 IHTMLEventObj *prev_event;
1074 nsIDOMNode *parent, *nsnode;
1075 BOOL prevent_default = FALSE;
1078 UINT16 node_type;
1079 nsresult nsres;
1080 HRESULT hres;
1081
1082 TRACE("(%p) %s\n", doc, debugstr_w(event_info[eid].name));
1083
1084 window = doc->window;
1085 if(!window) {
1086 WARN("NULL window\n");
1087 return;
1088 }
1089
1090 htmldoc_addref(&doc->basedoc);
1091
1092 prev_event = window->event;
1093 window->event = event_obj ? &event_obj->IHTMLEventObj_iface : NULL;
1094
1095 nsIDOMNode_GetNodeType(target, &node_type);
1096 nsnode = target;
1097 nsIDOMNode_AddRef(nsnode);
1098
1099 switch(node_type) {
1100 case ELEMENT_NODE:
1101 do {
1102 hres = get_node(doc, nsnode, FALSE, &node);
1103 if(SUCCEEDED(hres) && node) {
1104 call_event_handlers(doc, event_obj, &node->event_target, node->cp_container, eid,
1105 script_this ? script_this : (IDispatch*)&node->IHTMLDOMNode_iface);
1107 }
1108
1109 if(!(event_info[eid].flags & EVENT_BUBBLE) || (event_obj && event_obj->cancel_bubble))
1110 break;
1111
1112 nsIDOMNode_GetParentNode(nsnode, &parent);
1113 nsIDOMNode_Release(nsnode);
1114 nsnode = parent;
1115 if(!nsnode)
1116 break;
1117
1118 nsIDOMNode_GetNodeType(nsnode, &node_type);
1119 }while(node_type == ELEMENT_NODE);
1120
1121 if(!(event_info[eid].flags & EVENT_BUBBLE) || (event_obj && event_obj->cancel_bubble))
1122 break;
1123
1124 case DOCUMENT_NODE:
1126 nsIDOMHTMLElement *nsbody;
1127 nsresult nsres;
1128
1129 nsres = nsIDOMHTMLDocument_GetBody(doc->nsdoc, &nsbody);
1130 if(NS_SUCCEEDED(nsres) && nsbody) {
1131 hres = get_node(doc, (nsIDOMNode*)nsbody, FALSE, &node);
1132 if(SUCCEEDED(hres) && node) {
1133 call_event_handlers(doc, event_obj, &node->event_target, node->cp_container, eid,
1134 script_this ? script_this : (IDispatch*)&node->IHTMLDOMNode_iface);
1136 }
1137 nsIDOMHTMLElement_Release(nsbody);
1138 }else {
1139 ERR("Could not get body: %08x\n", nsres);
1140 }
1141 }
1142
1143 call_event_handlers(doc, event_obj, &doc->node.event_target, &doc->basedoc.cp_container, eid,
1144 script_this ? script_this : (IDispatch*)&doc->basedoc.IHTMLDocument2_iface);
1145 break;
1146
1147 default:
1148 FIXME("unimplemented node type %d\n", node_type);
1149 }
1150
1151 if(nsnode)
1152 nsIDOMNode_Release(nsnode);
1153
1154 if(event_obj && event_obj->prevent_default)
1155 prevent_default = TRUE;
1156 window->event = prev_event;
1157
1158 if(!prevent_default && (event_info[eid].flags & EVENT_HASDEFAULTHANDLERS)) {
1159 nsIDOMNode_AddRef(target);
1160 nsnode = target;
1161
1162 do {
1163 hres = get_node(doc, nsnode, TRUE, &node);
1164 if(FAILED(hres))
1165 break;
1166
1167 if(node) {
1168 if(node->vtbl->handle_event)
1169 hres = node->vtbl->handle_event(node, eid, event_obj ? event_obj->nsevent : NULL, &prevent_default);
1171 if(FAILED(hres) || prevent_default || (event_obj && event_obj->cancel_bubble))
1172 break;
1173 }
1174
1175 nsres = nsIDOMNode_GetParentNode(nsnode, &parent);
1176 if(NS_FAILED(nsres))
1177 break;
1178
1179 nsIDOMNode_Release(nsnode);
1180 nsnode = parent;
1181 } while(nsnode);
1182
1183 if(nsnode)
1184 nsIDOMNode_Release(nsnode);
1185 }
1186
1187 if(prevent_default && event_obj && event_obj->nsevent) {
1188 TRACE("calling PreventDefault\n");
1189 nsIDOMEvent_PreventDefault(event_obj->nsevent);
1190 }
1191
1192 htmldoc_release(&doc->basedoc);
1193}
unsigned short UINT16
r parent
Definition: btrfs.c:3010
#define EVENT_FORWARDBODY
Definition: htmlevent.c:149
void call_event_handlers(HTMLDocumentNode *doc, HTMLEventObj *event_obj, EventTarget *event_target, ConnectionPointContainer *cp_container, eventid_t eid, IDispatch *this_obj)
Definition: htmlevent.c:952
#define EVENT_BUBBLE
Definition: htmlevent.c:148
static IHTMLWindow2 * window
Definition: events.c:77
static ULONG htmldoc_addref(HTMLDocument *This)
static ULONG htmldoc_release(HTMLDocument *This)
#define NS_FAILED(res)
EventTarget event_target
HTMLDocument basedoc
IHTMLDocument2 IHTMLDocument2_iface
ConnectionPointContainer cp_container
nsIDOMEvent * nsevent
Definition: htmlevent.c:250
BOOL cancel_bubble
Definition: htmlevent.c:253

Referenced by dispatch_event(), and fire_event().

◆ get_event_handler()

HRESULT get_event_handler ( EventTarget event_target,
eventid_t  eid,
VARIANT var 
)

Definition at line 1447 of file htmlevent.c.

1448{
1450 VARIANT *v;
1451 HRESULT hres;
1452
1453 hres = dispex_get_dprop_ref(&event_target->dispex, event_info[eid].attr_name, FALSE, &v);
1454 if(SUCCEEDED(hres) && V_VT(v) != VT_EMPTY)
1455 return VariantCopy(var, v);
1456
1457 data = get_event_target_data(event_target, FALSE);
1458 if(data && data->event_table[eid] && data->event_table[eid]->handler_prop) {
1459 V_VT(var) = VT_DISPATCH;
1460 V_DISPATCH(var) = data->event_table[eid]->handler_prop;
1461 IDispatch_AddRef(V_DISPATCH(var));
1462 }else {
1463 V_VT(var) = VT_NULL;
1464 }
1465
1466 return S_OK;
1467}
@ VT_NULL
Definition: compat.h:2296
const char * var
Definition: shader.c:5666
HRESULT dispex_get_dprop_ref(DispatchEx *This, const WCHAR *name, BOOL alloc, VARIANT **ret)
Definition: dispex.c:555
LPCWSTR attr_name
Definition: htmlevent.c:141
HRESULT WINAPI VariantCopy(VARIANTARG *pvargDest, VARIANTARG *pvargSrc)
Definition: variant.c:748

Referenced by get_node_event(), get_window_event(), and HTMLXMLHttpRequest_get_onreadystatechange().

◆ get_event_target_data()

static event_target_t * get_event_target_data ( EventTarget event_target,
BOOL  alloc 
)
inlinestatic

Definition at line 870 of file htmlevent.c.

871{
873
874 ptr = event_target->dispex.data->vtbl && event_target->dispex.data->vtbl->get_event_target_ptr
875 ? event_target->dispex.data->vtbl->get_event_target_ptr(&event_target->dispex)
876 : &event_target->ptr;
877 if(*ptr || !alloc)
878 return *ptr;
879
880 return *ptr = heap_alloc_zero(sizeof(event_target_t));
881}
static PVOID ptr
Definition: dispmode.c:27
#define alloc
Definition: rosglue.h:13
event_target_t * ptr
event_target_t **(* get_event_target_ptr)(DispatchEx *)

Referenced by attach_event(), call_event_handlers(), detach_event(), get_event_handler(), remove_event_handler(), and set_event_handler_disp().

◆ HTMLEventObj_AddRef()

static ULONG WINAPI HTMLEventObj_AddRef ( IHTMLEventObj *  iface)
static

Definition at line 283 of file htmlevent.c.

284{
287
288 TRACE("(%p) ref=%d\n", This, ref);
289
290 return ref;
291}
#define InterlockedIncrement
Definition: armddk.h:53
static HTMLEventObj * impl_from_IHTMLEventObj(IHTMLEventObj *iface)
Definition: htmlevent.c:256
long LONG
Definition: pedump.c:60
Definition: send.c:48

◆ HTMLEventObj_get_altKey()

static HRESULT WINAPI HTMLEventObj_get_altKey ( IHTMLEventObj *  iface,
VARIANT_BOOL p 
)
static

Definition at line 355 of file htmlevent.c.

356{
359
360 TRACE("(%p)->(%p)\n", This, p);
361
362 if(This->nsevent) {
364 nsresult nsres;
365
366 nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMKeyEvent, (void**)&key_event);
367 if(NS_SUCCEEDED(nsres)) {
368 nsIDOMKeyEvent_GetAltKey(key_event, &ret);
369 nsIDOMKeyEvent_Release(key_event);
370 }else {
372
373 nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMMouseEvent, (void**)&mouse_event);
374 if(NS_SUCCEEDED(nsres)) {
375 nsIDOMMouseEvent_GetAltKey(mouse_event, &ret);
376 nsIDOMMouseEvent_Release(mouse_event);
377 }
378 }
379 }
380
381 *p = ret ? VARIANT_TRUE : VARIANT_FALSE;
382 return S_OK;
383}
unsigned char cpp_bool
Definition: atl.c:38
GLfloat GLfloat p
Definition: glext.h:8902
void key_event(int scancode, int pressed)
Definition: svgawin.c:773
void WINAPI mouse_event(_In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ ULONG_PTR)

◆ HTMLEventObj_get_button()

static HRESULT WINAPI HTMLEventObj_get_button ( IHTMLEventObj *  iface,
LONG p 
)
static

Definition at line 541 of file htmlevent.c.

542{
544 INT16 button = 0;
545
546 TRACE("(%p)->(%p)\n", This, p);
547
548 if(This->nsevent) {
550 nsresult nsres;
551
552 nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMMouseEvent, (void**)&mouse_event);
553 if(NS_SUCCEEDED(nsres)) {
554 nsIDOMMouseEvent_GetButton(mouse_event, &button);
555 nsIDOMMouseEvent_Release(mouse_event);
556 }
557 }
558
559 *p = button;
560 return S_OK;
561}
signed short INT16
DWORD button
Definition: button.c:166

◆ HTMLEventObj_get_cancelBubble()

static HRESULT WINAPI HTMLEventObj_get_cancelBubble ( IHTMLEventObj *  iface,
VARIANT_BOOL p 
)
static

Definition at line 482 of file htmlevent.c.

483{
485
486 TRACE("(%p)->(%p)\n", This, p);
487
488 *p = This->cancel_bubble ? VARIANT_TRUE : VARIANT_FALSE;
489 return S_OK;
490}

◆ HTMLEventObj_get_clientX()

static HRESULT WINAPI HTMLEventObj_get_clientX ( IHTMLEventObj *  iface,
LONG p 
)
static

Definition at line 646 of file htmlevent.c.

647{
649 LONG x = 0;
650
651 TRACE("(%p)->(%p)\n", This, p);
652
653 if(This->nsevent) {
655 nsresult nsres;
656
657 nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMMouseEvent, (void**)&mouse_event);
658 if(NS_SUCCEEDED(nsres)) {
659 nsIDOMMouseEvent_GetClientX(mouse_event, &x);
660 nsIDOMMouseEvent_Release(mouse_event);
661 }
662 }
663
664 *p = x;
665 return S_OK;
666}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548

◆ HTMLEventObj_get_clientY()

static HRESULT WINAPI HTMLEventObj_get_clientY ( IHTMLEventObj *  iface,
LONG p 
)
static

Definition at line 668 of file htmlevent.c.

669{
671 LONG y = 0;
672
673 TRACE("(%p)->(%p)\n", This, p);
674
675 if(This->nsevent) {
677 nsresult nsres;
678
679 nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMMouseEvent, (void**)&mouse_event);
680 if(NS_SUCCEEDED(nsres)) {
681 nsIDOMMouseEvent_GetClientY(mouse_event, &y);
682 nsIDOMMouseEvent_Release(mouse_event);
683 }
684 }
685
686 *p = y;
687 return S_OK;
688}
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

◆ HTMLEventObj_get_ctrlKey()

static HRESULT WINAPI HTMLEventObj_get_ctrlKey ( IHTMLEventObj *  iface,
VARIANT_BOOL p 
)
static

Definition at line 385 of file htmlevent.c.

386{
389
390 TRACE("(%p)->(%p)\n", This, p);
391
392 if(This->nsevent) {
394 nsresult nsres;
395
396 nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMKeyEvent, (void**)&key_event);
397 if(NS_SUCCEEDED(nsres)) {
398 nsIDOMKeyEvent_GetCtrlKey(key_event, &ret);
399 nsIDOMKeyEvent_Release(key_event);
400 }else {
402
403 nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMMouseEvent, (void**)&mouse_event);
404 if(NS_SUCCEEDED(nsres)) {
405 nsIDOMMouseEvent_GetCtrlKey(mouse_event, &ret);
406 nsIDOMMouseEvent_Release(mouse_event);
407 }
408 }
409 }
410
411 *p = ret ? VARIANT_TRUE : VARIANT_FALSE;
412 return S_OK;
413}

◆ HTMLEventObj_get_fromElement()

static HRESULT WINAPI HTMLEventObj_get_fromElement ( IHTMLEventObj *  iface,
IHTMLElement **  p 
)
static

Definition at line 492 of file htmlevent.c.

493{
495
496 FIXME("(%p)->(%p)\n", This, p);
497
498 *p = NULL;
499 return S_OK;
500}

◆ HTMLEventObj_get_keyCode()

static HRESULT WINAPI HTMLEventObj_get_keyCode ( IHTMLEventObj *  iface,
LONG p 
)
static

Definition at line 519 of file htmlevent.c.

520{
522 UINT32 key_code = 0;
523
524 TRACE("(%p)->(%p)\n", This, p);
525
526 if(This->nsevent) {
528 nsresult nsres;
529
530 nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMKeyEvent, (void**)&key_event);
531 if(NS_SUCCEEDED(nsres)) {
532 nsIDOMKeyEvent_GetKeyCode(key_event, &key_code);
533 nsIDOMKeyEvent_Release(key_event);
534 }
535 }
536
537 *p = key_code;
538 return S_OK;
539}
unsigned int UINT32

◆ HTMLEventObj_get_offsetX()

static HRESULT WINAPI HTMLEventObj_get_offsetX ( IHTMLEventObj *  iface,
LONG p 
)
static

Definition at line 690 of file htmlevent.c.

691{
693
694 FIXME("(%p)->(%p)\n", This, p);
695
696 *p = 0;
697 return S_OK;
698}

◆ HTMLEventObj_get_offsetY()

static HRESULT WINAPI HTMLEventObj_get_offsetY ( IHTMLEventObj *  iface,
LONG p 
)
static

Definition at line 700 of file htmlevent.c.

701{
703
704 FIXME("(%p)->(%p)\n", This, p);
705
706 *p = 0;
707 return S_OK;
708}

◆ HTMLEventObj_get_qualifier()

static HRESULT WINAPI HTMLEventObj_get_qualifier ( IHTMLEventObj *  iface,
BSTR p 
)
static

Definition at line 578 of file htmlevent.c.

579{
581
582 FIXME("(%p)->(%p)\n", This, p);
583
584 *p = NULL;
585 return S_OK;
586}

◆ HTMLEventObj_get_reason()

static HRESULT WINAPI HTMLEventObj_get_reason ( IHTMLEventObj *  iface,
LONG p 
)
static

Definition at line 588 of file htmlevent.c.

589{
591
592 FIXME("(%p)->(%p)\n", This, p);
593
594 *p = 0;
595 return S_OK;
596}

◆ HTMLEventObj_get_returnValue()

static HRESULT WINAPI HTMLEventObj_get_returnValue ( IHTMLEventObj *  iface,
VARIANT p 
)
static

Definition at line 462 of file htmlevent.c.

463{
465
466 TRACE("(%p)->(%p)\n", This, p);
467
468 V_VT(p) = VT_EMPTY;
469 return VariantCopy(p, &This->return_value);
470}

◆ HTMLEventObj_get_screenX()

static HRESULT WINAPI HTMLEventObj_get_screenX ( IHTMLEventObj *  iface,
LONG p 
)
static

Definition at line 710 of file htmlevent.c.

711{
713 LONG x = 0;
714
715 TRACE("(%p)->(%p)\n", This, p);
716
717 if(This->nsevent) {
719 nsresult nsres;
720
721 nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMMouseEvent, (void**)&mouse_event);
722 if(NS_SUCCEEDED(nsres)) {
723 nsIDOMMouseEvent_GetScreenX(mouse_event, &x);
724 nsIDOMMouseEvent_Release(mouse_event);
725 }
726 }
727
728 *p = x;
729 return S_OK;
730}

◆ HTMLEventObj_get_screenY()

static HRESULT WINAPI HTMLEventObj_get_screenY ( IHTMLEventObj *  iface,
LONG p 
)
static

Definition at line 732 of file htmlevent.c.

733{
735 LONG y = 0;
736
737 TRACE("(%p)->(%p)\n", This, p);
738
739 if(This->nsevent) {
741 nsresult nsres;
742
743 nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMMouseEvent, (void**)&mouse_event);
744 if(NS_SUCCEEDED(nsres)) {
745 nsIDOMMouseEvent_GetScreenY(mouse_event, &y);
746 nsIDOMMouseEvent_Release(mouse_event);
747 }
748 }
749
750 *p = y;
751 return S_OK;
752}

◆ HTMLEventObj_get_shiftKey()

static HRESULT WINAPI HTMLEventObj_get_shiftKey ( IHTMLEventObj *  iface,
VARIANT_BOOL p 
)
static

Definition at line 415 of file htmlevent.c.

416{
419
420 TRACE("(%p)->(%p)\n", This, p);
421
422 if(This->nsevent) {
424 nsresult nsres;
425
426 nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMKeyEvent, (void**)&key_event);
427 if(NS_SUCCEEDED(nsres)) {
428 nsIDOMKeyEvent_GetShiftKey(key_event, &ret);
429 nsIDOMKeyEvent_Release(key_event);
430 }else {
432
433 nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMMouseEvent, (void**)&mouse_event);
434 if(NS_SUCCEEDED(nsres)) {
435 nsIDOMMouseEvent_GetShiftKey(mouse_event, &ret);
436 nsIDOMMouseEvent_Release(mouse_event);
437 }
438 }
439 }
440
441 *p = ret ? VARIANT_TRUE : VARIANT_FALSE;
442 return S_OK;
443}

◆ HTMLEventObj_get_srcElement()

static HRESULT WINAPI HTMLEventObj_get_srcElement ( IHTMLEventObj *  iface,
IHTMLElement **  p 
)
static

Definition at line 343 of file htmlevent.c.

344{
346
347 TRACE("(%p)->(%p)\n", This, p);
348
349 *p = NULL;
350 if(This->target)
351 IHTMLDOMNode_QueryInterface(&This->target->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
352 return S_OK;
353}

◆ HTMLEventObj_get_srcFilter()

static HRESULT WINAPI HTMLEventObj_get_srcFilter ( IHTMLEventObj *  iface,
IDispatch **  p 
)
static

Definition at line 754 of file htmlevent.c.

755{
757
758 FIXME("(%p)->(%p)\n", This, p);
759
760 *p = NULL;
761 return S_OK;
762}

◆ HTMLEventObj_get_toElement()

static HRESULT WINAPI HTMLEventObj_get_toElement ( IHTMLEventObj *  iface,
IHTMLElement **  p 
)
static

Definition at line 502 of file htmlevent.c.

503{
505
506 FIXME("(%p)->(%p)\n", This, p);
507
508 *p = NULL;
509 return S_OK;
510}

◆ HTMLEventObj_get_type()

static HRESULT WINAPI HTMLEventObj_get_type ( IHTMLEventObj *  iface,
BSTR p 
)
static

Definition at line 563 of file htmlevent.c.

564{
566
567 TRACE("(%p)->(%p)\n", This, p);
568
569 if(!This->type) {
570 *p = NULL;
571 return S_OK;
572 }
573
574 *p = SysAllocString(This->type->name);
575 return *p ? S_OK : E_OUTOFMEMORY;
576}
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238

◆ HTMLEventObj_get_x()

static HRESULT WINAPI HTMLEventObj_get_x ( IHTMLEventObj *  iface,
LONG p 
)
static

Definition at line 598 of file htmlevent.c.

599{
601 LONG x = 0;
602
603 TRACE("(%p)->(%p)\n", This, p);
604
605 if(This->nsevent) {
606 nsIDOMUIEvent *ui_event;
607 nsresult nsres;
608
609 nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMUIEvent, (void**)&ui_event);
610 if(NS_SUCCEEDED(nsres)) {
611 /* NOTE: pageX is not exactly right here. */
612 nsres = nsIDOMUIEvent_GetPageX(ui_event, &x);
613 assert(nsres == NS_OK);
614 nsIDOMUIEvent_Release(ui_event);
615 }
616 }
617
618 *p = x;
619 return S_OK;
620}
#define assert(x)
Definition: debug.h:53
#define NS_OK

◆ HTMLEventObj_get_y()

static HRESULT WINAPI HTMLEventObj_get_y ( IHTMLEventObj *  iface,
LONG p 
)
static

Definition at line 622 of file htmlevent.c.

623{
625 LONG y = 0;
626
627 TRACE("(%p)->(%p)\n", This, p);
628
629 if(This->nsevent) {
630 nsIDOMUIEvent *ui_event;
631 nsresult nsres;
632
633 nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMUIEvent, (void**)&ui_event);
634 if(NS_SUCCEEDED(nsres)) {
635 /* NOTE: pageY is not exactly right here. */
636 nsres = nsIDOMUIEvent_GetPageY(ui_event, &y);
637 assert(nsres == NS_OK);
638 nsIDOMUIEvent_Release(ui_event);
639 }
640 }
641
642 *p = y;
643 return S_OK;
644}

◆ HTMLEventObj_GetIDsOfNames()

static HRESULT WINAPI HTMLEventObj_GetIDsOfNames ( IHTMLEventObj *  iface,
REFIID  riid,
LPOLESTR rgszNames,
UINT  cNames,
LCID  lcid,
DISPID rgDispId 
)
static

Definition at line 325 of file htmlevent.c.

328{
330 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
331 lcid, rgDispId);
332}
REFIID riid
Definition: atlbase.h:39

◆ HTMLEventObj_GetTypeInfo()

static HRESULT WINAPI HTMLEventObj_GetTypeInfo ( IHTMLEventObj *  iface,
UINT  iTInfo,
LCID  lcid,
ITypeInfo **  ppTInfo 
)
static

Definition at line 318 of file htmlevent.c.

320{
322 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
323}

◆ HTMLEventObj_GetTypeInfoCount()

static HRESULT WINAPI HTMLEventObj_GetTypeInfoCount ( IHTMLEventObj *  iface,
UINT pctinfo 
)
static

Definition at line 312 of file htmlevent.c.

313{
315 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
316}

◆ HTMLEventObj_Invoke()

static HRESULT WINAPI HTMLEventObj_Invoke ( IHTMLEventObj *  iface,
DISPID  dispIdMember,
REFIID  riid,
LCID  lcid,
WORD  wFlags,
DISPPARAMS *  pDispParams,
VARIANT pVarResult,
EXCEPINFO *  pExcepInfo,
UINT puArgErr 
)
static

Definition at line 334 of file htmlevent.c.

337{
339 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
340 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
341}
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:531

◆ HTMLEventObj_put_cancelBubble()

static HRESULT WINAPI HTMLEventObj_put_cancelBubble ( IHTMLEventObj *  iface,
VARIANT_BOOL  v 
)
static

Definition at line 472 of file htmlevent.c.

473{
475
476 TRACE("(%p)->(%x)\n", This, v);
477
478 This->cancel_bubble = !!v;
479 return S_OK;
480}

◆ HTMLEventObj_put_keyCode()

static HRESULT WINAPI HTMLEventObj_put_keyCode ( IHTMLEventObj *  iface,
LONG  v 
)
static

Definition at line 512 of file htmlevent.c.

513{
515 FIXME("(%p)->(%d)\n", This, v);
516 return E_NOTIMPL;
517}

◆ HTMLEventObj_put_returnValue()

static HRESULT WINAPI HTMLEventObj_put_returnValue ( IHTMLEventObj *  iface,
VARIANT  v 
)
static

Definition at line 445 of file htmlevent.c.

446{
448
449 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
450
451 if(V_VT(&v) != VT_BOOL) {
452 FIXME("unsupported value %s\n", debugstr_variant(&v));
453 return DISP_E_BADVARTYPE;
454 }
455
456 This->return_value = v;
457 if(!V_BOOL(&v))
458 This->prevent_default = TRUE;
459 return S_OK;
460}
#define DISP_E_BADVARTYPE
Definition: winerror.h:2517

◆ HTMLEventObj_QueryInterface()

static HRESULT WINAPI HTMLEventObj_QueryInterface ( IHTMLEventObj *  iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 261 of file htmlevent.c.

262{
264
265 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
266
268 *ppv = &This->IHTMLEventObj_iface;
269 }else if(IsEqualGUID(&IID_IHTMLEventObj, riid)) {
270 *ppv = &This->IHTMLEventObj_iface;
271 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
272 return *ppv ? S_OK : E_NOINTERFACE;
273 }else {
274 *ppv = NULL;
275 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
276 return E_NOINTERFACE;
277 }
278
279 IUnknown_AddRef((IUnknown*)*ppv);
280 return S_OK;
281}
const GUID IID_IUnknown
const char * debugstr_mshtml_guid(const GUID *iid)
Definition: main.c:542
REFIID LPVOID * ppv
Definition: atlbase.h:39
BOOL dispex_query_interface(DispatchEx *This, REFIID riid, void **ppv)
Definition: dispex.c:1656
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ HTMLEventObj_Release()

static ULONG WINAPI HTMLEventObj_Release ( IHTMLEventObj *  iface)
static

Definition at line 293 of file htmlevent.c.

294{
297
298 TRACE("(%p) ref=%d\n", This, ref);
299
300 if(!ref) {
301 if(This->target)
302 IHTMLDOMNode_Release(&This->target->IHTMLDOMNode_iface);
303 if(This->nsevent)
304 nsIDOMEvent_Release(This->nsevent);
305 release_dispex(&This->dispex);
307 }
308
309 return ref;
310}
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
#define InterlockedDecrement
Definition: armddk.h:52
void release_dispex(DispatchEx *This)
Definition: dispex.c:1706

◆ impl_from_IHTMLEventObj()

◆ is_cp_event()

static BOOL is_cp_event ( cp_static_data_t data,
DISPID  dispid 
)
static

Definition at line 922 of file htmlevent.c.

923{
924 int min, max, i;
926
927 if(!data)
928 return FALSE;
929
930 if(!data->ids) {
931 hres = get_dispids(data->tid, &data->id_cnt, &data->ids);
932 if(FAILED(hres))
933 return FALSE;
934 }
935
936 min = 0;
937 max = data->id_cnt-1;
938 while(min <= max) {
939 i = (min+max)/2;
940 if(data->ids[i] == dispid)
941 return TRUE;
942
943 if(data->ids[i] < dispid)
944 min = i+1;
945 else
946 max = i-1;
947 }
948
949 return FALSE;
950}
#define min(a, b)
Definition: monoChain.cc:55
HRESULT get_dispids(tid_t tid, DWORD *ret_size, DISPID **ret)
Definition: dispex.c:389
#define max(a, b)
Definition: svc.c:63

Referenced by call_event_handlers(), and update_doc_cp_events().

◆ release_event_target()

void release_event_target ( event_target_t event_target)

Definition at line 1613 of file htmlevent.c.

1614{
1615 int i;
1616 unsigned int j;
1617
1618 for(i=0; i < EVENTID_LAST; i++) {
1619 if(event_target->event_table[i]) {
1620 if(event_target->event_table[i]->handler_prop)
1621 IDispatch_Release(event_target->event_table[i]->handler_prop);
1622 for(j=0; j < event_target->event_table[i]->handler_cnt; j++)
1623 if(event_target->event_table[i]->handlers[j])
1624 IDispatch_Release(event_target->event_table[i]->handlers[j]);
1625 }
1626 }
1627
1628 heap_free(event_target);
1629}
IDispatch * handlers[0]
Definition: htmlevent.c:24
IDispatch * handler_prop
Definition: htmlevent.c:22

Referenced by HTMLDocumentNode_destructor(), and HTMLDOMNode_destructor().

◆ remove_event_handler()

static void remove_event_handler ( EventTarget event_target,
eventid_t  eid 
)
static

Definition at line 1365 of file htmlevent.c.

1366{
1368 VARIANT *store;
1369 HRESULT hres;
1370
1371 hres = dispex_get_dprop_ref(&event_target->dispex, event_info[eid].attr_name, FALSE, &store);
1372 if(SUCCEEDED(hres))
1373 VariantClear(store);
1374
1375 data = get_event_target_data(event_target, FALSE);
1376 if(data && data->event_table[eid] && data->event_table[eid]->handler_prop) {
1377 IDispatch_Release(data->event_table[eid]->handler_prop);
1378 data->event_table[eid]->handler_prop = NULL;
1379 }
1380}

Referenced by set_event_handler(), and set_event_handler_disp().

◆ set_event_handler()

HRESULT set_event_handler ( EventTarget event_target,
eventid_t  eid,
VARIANT var 
)

Definition at line 1404 of file htmlevent.c.

1405{
1406 switch(V_VT(var)) {
1407 case VT_NULL:
1408 remove_event_handler(event_target, eid);
1409 return S_OK;
1410
1411 case VT_DISPATCH:
1412 return set_event_handler_disp(event_target, eid, V_DISPATCH(var));
1413
1414 case VT_BSTR: {
1415 VARIANT *v;
1416 HRESULT hres;
1417
1418 /*
1419 * Setting event handler to string is a rare case and we don't want to
1420 * complicate nor increase memory of event_target_t for that. Instead,
1421 * we store the value in DispatchEx, which can already handle custom
1422 * properties.
1423 */
1424 remove_event_handler(event_target, eid);
1425
1426 hres = dispex_get_dprop_ref(&event_target->dispex, event_info[eid].attr_name, TRUE, &v);
1427 if(FAILED(hres))
1428 return hres;
1429
1431 if(!V_BSTR(v))
1432 return E_OUTOFMEMORY;
1433 V_VT(v) = VT_BSTR;
1434 return S_OK;
1435 }
1436
1437 default:
1438 FIXME("not handler %s\n", debugstr_variant(var));
1439 /* fall through */
1440 case VT_EMPTY:
1441 return E_NOTIMPL;
1442 }
1443
1444 return S_OK;
1445}
@ VT_BSTR
Definition: compat.h:2303
static void remove_event_handler(EventTarget *event_target, eventid_t eid)
Definition: htmlevent.c:1365
#define V_BSTR(A)
Definition: oleauto.h:226

Referenced by HTMLXMLHttpRequest_put_onreadystatechange(), set_node_event(), and set_window_event().

◆ set_event_handler_disp()

static HRESULT set_event_handler_disp ( EventTarget event_target,
eventid_t  eid,
IDispatch disp 
)
static

Definition at line 1382 of file htmlevent.c.

1383{
1385
1386 remove_event_handler(event_target, eid);
1387 if(!disp)
1388 return S_OK;
1389
1390 data = get_event_target_data(event_target, TRUE);
1391 if(!data)
1392 return E_OUTOFMEMORY;
1393
1394 if(!alloc_handler_vector(data, eid, 0))
1395 return E_OUTOFMEMORY;
1396
1397 data->event_table[eid]->handler_prop = disp;
1398 IDispatch_AddRef(disp);
1399
1400 bind_event(event_target, eid);
1401 return S_OK;
1402}

Referenced by bind_target_event(), check_event_attr(), and set_event_handler().

◆ set_event_info()

static HRESULT set_event_info ( HTMLEventObj event,
HTMLDOMNode target,
eventid_t  eid,
nsIDOMEvent nsevent 
)
static

Definition at line 832 of file htmlevent.c.

833{
834 event->type = event_info+eid;
835 event->nsevent = nsevent;
836
837 if(nsevent) {
838 nsIDOMEvent_AddRef(nsevent);
839 }else if(event_types[event_info[eid].type]) {
840 nsAString type_str;
841 nsresult nsres;
842
844 nsres = nsIDOMHTMLDocument_CreateEvent(target->doc->nsdoc, &type_str, &event->nsevent);
845 nsAString_Finish(&type_str);
846 if(NS_FAILED(nsres)) {
847 ERR("Could not create event: %08x\n", nsres);
848 return E_FAIL;
849 }
850 }
851
852 event->target = target;
853 if(target)
854 IHTMLDOMNode_AddRef(&target->IHTMLDOMNode_iface);
855 return S_OK;
856}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static const WCHAR * event_types[]
Definition: htmlevent.c:132
void nsAString_InitDepend(nsAString *, const PRUnichar *) DECLSPEC_HIDDEN
Definition: nsembed.c:826

Referenced by dispatch_event(), and fire_event().

◆ str_to_eid()

eventid_t str_to_eid ( LPCWSTR  str)

Definition at line 217 of file htmlevent.c.

218{
219 int i;
220
221 for(i=0; i < sizeof(event_info)/sizeof(event_info[0]); i++) {
222 if(!strcmpW(event_info[i].name, str))
223 return i;
224 }
225
226 ERR("unknown type %s\n", debugstr_w(str));
227 return EVENTID_LAST;
228}

Referenced by handle_htmlevent().

◆ unsafe_impl_from_IHTMLEventObj()

static HTMLEventObj * unsafe_impl_from_IHTMLEventObj ( IHTMLEventObj *  iface)
inlinestatic

Definition at line 799 of file htmlevent.c.

800{
801 return iface->lpVtbl == &HTMLEventObjVtbl ? impl_from_IHTMLEventObj(iface) : NULL;
802}

Referenced by dispatch_event().

◆ update_doc_cp_events()

void update_doc_cp_events ( HTMLDocumentNode doc,
cp_static_data_t cp 
)

Definition at line 1549 of file htmlevent.c.

1550{
1551 int i;
1552
1553 for(i=0; i < EVENTID_LAST; i++) {
1556 }
1557}

Referenced by HTMLDocument_on_advise().

Variable Documentation

◆ abortW

const WCHAR abortW[] = {'a','b','o','r','t',0}
static

Definition at line 31 of file htmlevent.c.

◆ beforeunloadW

const WCHAR beforeunloadW[] = {'b','e','f','o','r','e','u','n','l','o','a','d',0}
static

Definition at line 34 of file htmlevent.c.

◆ blurW

const WCHAR blurW[] = {'b','l','u','r',0}
static

Definition at line 37 of file htmlevent.c.

◆ changeW

const WCHAR changeW[] = {'c','h','a','n','g','e',0}
static

Definition at line 40 of file htmlevent.c.

◆ clickW

const WCHAR clickW[] = {'c','l','i','c','k',0}
static

Definition at line 43 of file htmlevent.c.

◆ contextmenuW

const WCHAR contextmenuW[] = {'c','o','n','t','e','x','t','m','e','n','u',0}
static

Definition at line 46 of file htmlevent.c.

◆ dataavailableW

const WCHAR dataavailableW[] = {'d','a','t','a','a','v','a','i','l','a','b','l','e',0}
static

Definition at line 49 of file htmlevent.c.

◆ dblclickW

const WCHAR dblclickW[] = {'d','b','l','c','l','i','c','k',0}
static

Definition at line 52 of file htmlevent.c.

◆ dragstartW

const WCHAR dragstartW[] = {'d','r','a','g','s','t','a','r','t',0}
static

Definition at line 58 of file htmlevent.c.

◆ dragW

const WCHAR dragW[] = {'d','r','a','g',0}
static

Definition at line 55 of file htmlevent.c.

◆ errorW

const WCHAR errorW[] = {'e','r','r','o','r',0}
static

Definition at line 61 of file htmlevent.c.

Referenced by AMGetErrorTextA(), ldap_parse_resultA(), and Object_toString().

◆ event_info

◆ event_types

const WCHAR* event_types[]
static
Initial value:
= {
}
static const WCHAR HTMLEventsW[]
Definition: htmlevent.c:121
static const WCHAR MouseEventW[]
Definition: htmlevent.c:123
static const WCHAR KeyboardEventW[]
Definition: htmlevent.c:122

Definition at line 132 of file htmlevent.c.

Referenced by set_event_info().

◆ focusinW

const WCHAR focusinW[] = {'f','o','c','u','s','i','n',0}
static

Definition at line 67 of file htmlevent.c.

◆ focusW

const WCHAR focusW[] = {'f','o','c','u','s',0}
static

Definition at line 64 of file htmlevent.c.

◆ helpW

const WCHAR helpW[] = {'h','e','l','p',0}
static

Definition at line 70 of file htmlevent.c.

Referenced by MsiGetFeatureInfoA(), resolve_filename(), and test_typelib_section().

◆ HTMLEventObj_dispex

dispex_static_data_t HTMLEventObj_dispex
static
Initial value:
= {
DispCEventObj_tid,
}
static const tid_t HTMLEventObj_iface_tids[]
Definition: htmlevent.c:804

Definition at line 809 of file htmlevent.c.

Referenced by create_event().

◆ HTMLEventObj_iface_tids

const tid_t HTMLEventObj_iface_tids[]
static
Initial value:
= {
IHTMLEventObj_tid,
0
}

Definition at line 804 of file htmlevent.c.

◆ HTMLEventObjVtbl

const IHTMLEventObjVtbl HTMLEventObjVtbl
static

Definition at line 764 of file htmlevent.c.

Referenced by create_event(), and unsafe_impl_from_IHTMLEventObj().

◆ HTMLEventsW

const WCHAR HTMLEventsW[] = {'H','T','M','L','E','v','e','n','t','s',0}
static

Definition at line 121 of file htmlevent.c.

◆ KeyboardEventW

const WCHAR KeyboardEventW[] = {'K','e','y','b','o','a','r','d','E','v','e','n','t',0}
static

Definition at line 122 of file htmlevent.c.

◆ keydownW

const WCHAR keydownW[] = {'k','e','y','d','o','w','n',0}
static

Definition at line 73 of file htmlevent.c.

◆ keypressW

const WCHAR keypressW[] = {'k','e','y','p','r','e','s','s',0}
static

Definition at line 76 of file htmlevent.c.

◆ keyupW

const WCHAR keyupW[] = {'k','e','y','u','p',0}
static

Definition at line 79 of file htmlevent.c.

◆ loadW

const WCHAR loadW[] = {'l','o','a','d',0}
static

Definition at line 82 of file htmlevent.c.

◆ mousedownW

const WCHAR mousedownW[] = {'m','o','u','s','e','d','o','w','n',0}
static

Definition at line 85 of file htmlevent.c.

◆ MouseEventW

const WCHAR MouseEventW[] = {'M','o','u','s','e','E','v','e','n','t',0}
static

Definition at line 123 of file htmlevent.c.

◆ mousemoveW

const WCHAR mousemoveW[] = {'m','o','u','s','e','m','o','v','e',0}
static

Definition at line 88 of file htmlevent.c.

◆ mouseoutW

const WCHAR mouseoutW[] = {'m','o','u','s','e','o','u','t',0}
static

Definition at line 91 of file htmlevent.c.

◆ mouseoverW

const WCHAR mouseoverW[] = {'m','o','u','s','e','o','v','e','r',0}
static

Definition at line 94 of file htmlevent.c.

◆ mouseupW

const WCHAR mouseupW[] = {'m','o','u','s','e','u','p',0}
static

Definition at line 97 of file htmlevent.c.

◆ mousewheelW

const WCHAR mousewheelW[] = {'m','o','u','s','e','w','h','e','e','l',0}
static

Definition at line 100 of file htmlevent.c.

◆ onabortW

const WCHAR onabortW[] = {'o','n','a','b','o','r','t',0}
static

Definition at line 32 of file htmlevent.c.

◆ onbeforeunloadW

const WCHAR onbeforeunloadW[] = {'o','n','b','e','f','o','r','e','u','n','l','o','a','d',0}
static

Definition at line 35 of file htmlevent.c.

◆ onblurW

const WCHAR onblurW[] = {'o','n','b','l','u','r',0}
static

Definition at line 38 of file htmlevent.c.

◆ onchangeW

const WCHAR onchangeW[] = {'o','n','c','h','a','n','g','e',0}
static

Definition at line 41 of file htmlevent.c.

◆ onclickW

const WCHAR onclickW[] = {'o','n','c','l','i','c','k',0}
static

Definition at line 44 of file htmlevent.c.

◆ oncontextmenuW

const WCHAR oncontextmenuW[] = {'o','n','c','o','n','t','e','x','t','m','e','n','u',0}
static

Definition at line 47 of file htmlevent.c.

◆ ondataavailableW

const WCHAR ondataavailableW[] = {'o','n','d','a','t','a','a','v','a','i','l','a','b','l','e',0}
static

Definition at line 50 of file htmlevent.c.

◆ ondblclickW

const WCHAR ondblclickW[] = {'o','n','d','b','l','c','l','i','c','k',0}
static

Definition at line 53 of file htmlevent.c.

◆ ondragstartW

const WCHAR ondragstartW[] = {'o','n','d','r','a','g','s','t','a','r','t',0}
static

Definition at line 59 of file htmlevent.c.

◆ ondragW

const WCHAR ondragW[] = {'o','n','d','r','a','g',0}
static

Definition at line 56 of file htmlevent.c.

◆ onerrorW

const WCHAR onerrorW[] = {'o','n','e','r','r','o','r',0}
static

Definition at line 62 of file htmlevent.c.

◆ onfocusinW

const WCHAR onfocusinW[] = {'o','n','f','o','c','u','s','i','n',0}
static

Definition at line 68 of file htmlevent.c.

◆ onfocusW

const WCHAR onfocusW[] = {'o','n','f','o','c','u','s',0}
static

Definition at line 65 of file htmlevent.c.

◆ onhelpW

const WCHAR onhelpW[] = {'o','n','h','e','l','p',0}
static

Definition at line 71 of file htmlevent.c.

◆ onkeydownW

const WCHAR onkeydownW[] = {'o','n','k','e','y','d','o','w','n',0}
static

Definition at line 74 of file htmlevent.c.

◆ onkeypressW

const WCHAR onkeypressW[] = {'o','n','k','e','y','p','r','e','s','s',0}
static

Definition at line 77 of file htmlevent.c.

◆ onkeyupW

const WCHAR onkeyupW[] = {'o','n','k','e','y','u','p',0}
static

Definition at line 80 of file htmlevent.c.

◆ onloadW

const WCHAR onloadW[] = {'o','n','l','o','a','d',0}
static

Definition at line 83 of file htmlevent.c.

◆ onmousedownW

const WCHAR onmousedownW[] = {'o','n','m','o','u','s','e','d','o','w','n',0}
static

Definition at line 86 of file htmlevent.c.

◆ onmousemoveW

const WCHAR onmousemoveW[] = {'o','n','m','o','u','s','e','m','o','v','e',0}
static

Definition at line 89 of file htmlevent.c.

◆ onmouseoutW

const WCHAR onmouseoutW[] = {'o','n','m','o','u','s','e','o','u','t',0}
static

Definition at line 92 of file htmlevent.c.

◆ onmouseoverW

const WCHAR onmouseoverW[] = {'o','n','m','o','u','s','e','o','v','e','r',0}
static

Definition at line 95 of file htmlevent.c.

◆ onmouseupW

const WCHAR onmouseupW[] = {'o','n','m','o','u','s','e','u','p',0}
static

Definition at line 98 of file htmlevent.c.

◆ onmousewheelW

const WCHAR onmousewheelW[] = {'o','n','m','o','u','s','e','w','h','e','e','l',0}
static

Definition at line 101 of file htmlevent.c.

◆ onpasteW

const WCHAR onpasteW[] = {'o','n','p','a','s','t','e',0}
static

Definition at line 104 of file htmlevent.c.

◆ onreadystatechangeW

const WCHAR onreadystatechangeW[] = {'o','n','r','e','a','d','y','s','t','a','t','e','c','h','a','n','g','e',0}
static

Definition at line 107 of file htmlevent.c.

◆ onresizeW

const WCHAR onresizeW[] = {'o','n','r','e','s','i','z','e',0}
static

Definition at line 110 of file htmlevent.c.

◆ onscrollW

const WCHAR onscrollW[] = {'o','n','s','c','r','o','l','l',0}
static

Definition at line 113 of file htmlevent.c.

◆ onselectstartW

const WCHAR onselectstartW[] = {'o','n','s','e','l','e','c','t','s','t','a','r','t',0}
static

Definition at line 116 of file htmlevent.c.

◆ onsubmitW

const WCHAR onsubmitW[] = {'o','n','s','u','b','m','i','t',0}
static

Definition at line 119 of file htmlevent.c.

◆ pasteW

const WCHAR pasteW[] = {'p','a','s','t','e',0}
static

Definition at line 103 of file htmlevent.c.

◆ readystatechangeW

const WCHAR readystatechangeW[] = {'r','e','a','d','y','s','t','a','t','e','c','h','a','n','g','e',0}
static

Definition at line 106 of file htmlevent.c.

Referenced by detach_xhr_event_listener(), and HTMLXMLHttpRequest_bind_event().

◆ resizeW

const WCHAR resizeW[] = {'r','e','s','i','z','e',0}
static

Definition at line 109 of file htmlevent.c.

◆ scrollW

const WCHAR scrollW[] = {'s','c','r','o','l','l',0}
static

Definition at line 112 of file htmlevent.c.

◆ selectstartW

const WCHAR selectstartW[] = {'s','e','l','e','c','t','s','t','a','r','t',0}
static

Definition at line 115 of file htmlevent.c.

◆ submitW

const WCHAR submitW[] = {'s','u','b','m','i','t',0}
static

Definition at line 118 of file htmlevent.c.

Referenced by HTMLInputElement_is_text_edit().