2008-10-09 20:36:01 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2008 Jacek Caban for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef enum {
|
2022-12-01 14:57:17 +00:00
|
|
|
EVENTID_INVALID_ID = -1,
|
2022-05-25 16:13:14 +00:00
|
|
|
EVENTID_DOMCONTENTLOADED,
|
2012-10-17 10:18:30 +00:00
|
|
|
EVENTID_ABORT,
|
2022-11-25 17:10:03 +00:00
|
|
|
EVENTID_AFTERPRINT,
|
2021-03-10 13:59:20 +00:00
|
|
|
EVENTID_ANIMATIONEND,
|
|
|
|
EVENTID_ANIMATIONSTART,
|
2017-02-15 15:28:37 +00:00
|
|
|
EVENTID_BEFOREACTIVATE,
|
2022-11-25 17:10:03 +00:00
|
|
|
EVENTID_BEFOREPRINT,
|
2009-09-08 20:30:14 +00:00
|
|
|
EVENTID_BEFOREUNLOAD,
|
2008-10-10 20:49:09 +00:00
|
|
|
EVENTID_BLUR,
|
2008-10-09 20:36:01 +00:00
|
|
|
EVENTID_CHANGE,
|
|
|
|
EVENTID_CLICK,
|
2010-05-07 13:20:33 +00:00
|
|
|
EVENTID_CONTEXTMENU,
|
2012-09-13 10:27:43 +00:00
|
|
|
EVENTID_DATAAVAILABLE,
|
2009-09-08 20:32:47 +00:00
|
|
|
EVENTID_DBLCLICK,
|
2008-10-10 20:49:09 +00:00
|
|
|
EVENTID_DRAG,
|
2008-10-10 20:49:25 +00:00
|
|
|
EVENTID_DRAGSTART,
|
2012-04-04 13:08:38 +00:00
|
|
|
EVENTID_ERROR,
|
2008-10-10 20:49:09 +00:00
|
|
|
EVENTID_FOCUS,
|
2014-12-16 12:10:29 +00:00
|
|
|
EVENTID_FOCUSIN,
|
2016-04-04 11:22:20 +00:00
|
|
|
EVENTID_FOCUSOUT,
|
2012-09-04 11:58:58 +00:00
|
|
|
EVENTID_HELP,
|
2018-06-12 12:21:42 +00:00
|
|
|
EVENTID_INPUT,
|
2008-10-10 20:49:16 +00:00
|
|
|
EVENTID_KEYDOWN,
|
2012-04-10 10:53:12 +00:00
|
|
|
EVENTID_KEYPRESS,
|
2008-10-09 20:36:01 +00:00
|
|
|
EVENTID_KEYUP,
|
|
|
|
EVENTID_LOAD,
|
2022-06-06 12:24:13 +00:00
|
|
|
EVENTID_LOADEND,
|
2022-06-06 12:24:12 +00:00
|
|
|
EVENTID_LOADSTART,
|
2016-04-04 16:01:46 +00:00
|
|
|
EVENTID_MESSAGE,
|
2008-10-10 20:49:16 +00:00
|
|
|
EVENTID_MOUSEDOWN,
|
2011-02-21 09:23:48 +00:00
|
|
|
EVENTID_MOUSEMOVE,
|
2008-10-10 20:49:33 +00:00
|
|
|
EVENTID_MOUSEOUT,
|
2008-10-10 20:46:08 +00:00
|
|
|
EVENTID_MOUSEOVER,
|
2008-10-10 20:49:16 +00:00
|
|
|
EVENTID_MOUSEUP,
|
2014-09-11 09:03:24 +00:00
|
|
|
EVENTID_MOUSEWHEEL,
|
2019-06-18 06:09:36 +00:00
|
|
|
EVENTID_MSTHUMBNAILCLICK,
|
2022-11-18 15:20:28 +00:00
|
|
|
EVENTID_PAGEHIDE,
|
2022-11-18 15:20:27 +00:00
|
|
|
EVENTID_PAGESHOW,
|
2008-10-10 20:49:09 +00:00
|
|
|
EVENTID_PASTE,
|
2022-06-06 12:24:11 +00:00
|
|
|
EVENTID_PROGRESS,
|
2009-09-13 22:35:40 +00:00
|
|
|
EVENTID_READYSTATECHANGE,
|
2009-12-07 22:28:10 +00:00
|
|
|
EVENTID_RESIZE,
|
2012-09-10 12:41:28 +00:00
|
|
|
EVENTID_SCROLL,
|
2017-02-16 15:35:37 +00:00
|
|
|
EVENTID_SELECTIONCHANGE,
|
2008-10-10 20:49:25 +00:00
|
|
|
EVENTID_SELECTSTART,
|
2022-09-13 16:57:37 +00:00
|
|
|
EVENTID_STORAGE,
|
|
|
|
EVENTID_STORAGECOMMIT,
|
2011-02-28 12:13:49 +00:00
|
|
|
EVENTID_SUBMIT,
|
2022-05-25 16:13:16 +00:00
|
|
|
EVENTID_TIMEOUT,
|
2016-05-26 14:16:09 +00:00
|
|
|
EVENTID_UNLOAD,
|
2022-11-18 15:20:27 +00:00
|
|
|
EVENTID_VISIBILITYCHANGE,
|
2008-10-09 20:36:01 +00:00
|
|
|
EVENTID_LAST
|
|
|
|
} eventid_t;
|
|
|
|
|
2019-01-24 12:49:51 +00:00
|
|
|
typedef struct DOMEvent {
|
2017-10-19 15:02:21 +00:00
|
|
|
DispatchEx dispex;
|
|
|
|
IDOMEvent IDOMEvent_iface;
|
|
|
|
|
|
|
|
LONG ref;
|
2019-01-24 12:49:51 +00:00
|
|
|
void *(*query_interface)(struct DOMEvent*,REFIID);
|
2017-10-19 15:02:21 +00:00
|
|
|
|
|
|
|
nsIDOMEvent *nsevent;
|
2018-02-05 16:29:36 +00:00
|
|
|
|
2017-10-19 15:02:30 +00:00
|
|
|
eventid_t event_id;
|
2017-12-01 16:01:59 +00:00
|
|
|
WCHAR *type;
|
2017-10-19 15:02:54 +00:00
|
|
|
EventTarget *target;
|
2017-12-01 16:02:59 +00:00
|
|
|
EventTarget *current_target;
|
2017-12-05 17:24:46 +00:00
|
|
|
ULONGLONG time_stamp;
|
2017-12-01 16:02:22 +00:00
|
|
|
BOOL bubbles;
|
2017-12-01 16:02:31 +00:00
|
|
|
BOOL cancelable;
|
2017-10-20 13:08:59 +00:00
|
|
|
BOOL prevent_default;
|
2017-10-20 13:09:05 +00:00
|
|
|
BOOL stop_propagation;
|
2018-02-15 16:04:51 +00:00
|
|
|
BOOL stop_immediate_propagation;
|
2021-04-21 23:48:56 +00:00
|
|
|
BOOL trusted;
|
2017-10-25 16:13:26 +00:00
|
|
|
DOM_EVENT_PHASE phase;
|
2017-10-20 13:09:15 +00:00
|
|
|
|
|
|
|
IHTMLEventObj *event_obj;
|
|
|
|
BOOL no_event_obj;
|
2017-10-19 15:02:21 +00:00
|
|
|
} DOMEvent;
|
|
|
|
|
2023-07-03 14:55:44 +00:00
|
|
|
const WCHAR *get_event_name(eventid_t);
|
|
|
|
void check_event_attr(HTMLDocumentNode*,nsIDOMElement*);
|
|
|
|
void release_event_target(EventTarget*);
|
|
|
|
HRESULT set_event_handler(EventTarget*,eventid_t,VARIANT*);
|
|
|
|
HRESULT get_event_handler(EventTarget*,eventid_t,VARIANT*);
|
|
|
|
HRESULT attach_event(EventTarget*,BSTR,IDispatch*,VARIANT_BOOL*);
|
|
|
|
HRESULT detach_event(EventTarget*,BSTR,IDispatch*);
|
|
|
|
HRESULT fire_event(HTMLDOMNode*,const WCHAR*,VARIANT*,VARIANT_BOOL*);
|
|
|
|
void update_doc_cp_events(HTMLDocumentNode*,cp_static_data_t*);
|
|
|
|
HRESULT doc_init_events(HTMLDocumentNode*);
|
|
|
|
void detach_events(HTMLDocumentNode *doc);
|
|
|
|
HRESULT create_event_obj(compat_mode_t,IHTMLEventObj**);
|
|
|
|
void bind_target_event(HTMLDocumentNode*,EventTarget*,const WCHAR*,IDispatch*);
|
|
|
|
HRESULT ensure_doc_nsevent_handler(HTMLDocumentNode*,nsIDOMNode*,eventid_t);
|
|
|
|
|
|
|
|
void dispatch_event(EventTarget*,DOMEvent*);
|
|
|
|
|
|
|
|
HRESULT create_document_event(HTMLDocumentNode*,eventid_t,DOMEvent**);
|
|
|
|
HRESULT create_document_event_str(HTMLDocumentNode*,const WCHAR*,IDOMEvent**);
|
|
|
|
HRESULT create_event_from_nsevent(nsIDOMEvent*,compat_mode_t,DOMEvent**);
|
|
|
|
HRESULT create_message_event(HTMLDocumentNode*,VARIANT*,DOMEvent**);
|
|
|
|
HRESULT create_storage_event(HTMLDocumentNode*,BSTR,BSTR,BSTR,const WCHAR*,BOOL,DOMEvent**);
|
|
|
|
|
|
|
|
void init_nsevents(HTMLDocumentNode*);
|
|
|
|
void release_nsevents(HTMLDocumentNode*);
|
|
|
|
void add_nsevent_listener(HTMLDocumentNode*,nsIDOMNode*,LPCWSTR);
|
|
|
|
void detach_nsevent(HTMLDocumentNode*,const WCHAR*);
|
2011-08-02 09:08:12 +00:00
|
|
|
|
2017-10-18 14:38:51 +00:00
|
|
|
/* We extend dispex vtbl for EventTarget functions to avoid separated vtbl. */
|
|
|
|
typedef struct {
|
|
|
|
dispex_static_data_vtbl_t dispex_vtbl;
|
2018-02-20 12:48:44 +00:00
|
|
|
nsISupports *(*get_gecko_target)(DispatchEx*);
|
2017-10-18 14:38:51 +00:00
|
|
|
void (*bind_event)(DispatchEx*,eventid_t);
|
2017-10-19 15:01:33 +00:00
|
|
|
EventTarget *(*get_parent_event_target)(DispatchEx*);
|
2017-10-18 14:40:02 +00:00
|
|
|
HRESULT (*handle_event_default)(DispatchEx*,eventid_t,nsIDOMEvent*,BOOL*);
|
2017-10-18 14:39:22 +00:00
|
|
|
ConnectionPointContainer *(*get_cp_container)(DispatchEx*);
|
2017-10-19 15:01:43 +00:00
|
|
|
IHTMLEventObj *(*set_current_event)(DispatchEx*,IHTMLEventObj*);
|
2017-10-18 14:38:51 +00:00
|
|
|
} event_target_vtbl_t;
|
|
|
|
|
2023-08-01 16:45:24 +00:00
|
|
|
extern const event_target_vtbl_t HTMLElement_event_target_vtbl;
|
2023-07-03 14:55:44 +00:00
|
|
|
IHTMLEventObj *default_set_current_event(HTMLInnerWindow*,IHTMLEventObj*);
|
2017-10-19 15:01:43 +00:00
|
|
|
|
2017-10-16 20:31:42 +00:00
|
|
|
static inline EventTarget *get_node_event_prop_target(HTMLDOMNode *node, eventid_t eid)
|
|
|
|
{
|
|
|
|
return node->vtbl->get_event_prop_target ? node->vtbl->get_event_prop_target(node, eid) : &node->event_target;
|
|
|
|
}
|
|
|
|
|
2008-10-10 20:46:20 +00:00
|
|
|
static inline HRESULT set_node_event(HTMLDOMNode *node, eventid_t eid, VARIANT *var)
|
|
|
|
{
|
2017-10-16 20:31:42 +00:00
|
|
|
return set_event_handler(get_node_event_prop_target(node, eid), eid, var);
|
2008-10-10 20:46:20 +00:00
|
|
|
}
|
|
|
|
|
2008-10-10 20:46:32 +00:00
|
|
|
static inline HRESULT get_node_event(HTMLDOMNode *node, eventid_t eid, VARIANT *var)
|
|
|
|
{
|
2017-10-16 20:31:42 +00:00
|
|
|
return get_event_handler(get_node_event_prop_target(node, eid), eid, var);
|
2008-10-10 20:46:32 +00:00
|
|
|
}
|
|
|
|
|
2022-10-24 12:58:01 +00:00
|
|
|
static inline HRESULT set_doc_event(HTMLDocumentNode *doc, eventid_t eid, VARIANT *var)
|
2008-10-10 20:46:20 +00:00
|
|
|
{
|
2022-10-24 12:58:01 +00:00
|
|
|
return set_event_handler(&doc->node.event_target, eid, var);
|
2008-10-10 20:46:20 +00:00
|
|
|
}
|
2008-10-10 20:46:32 +00:00
|
|
|
|
2022-10-24 12:58:01 +00:00
|
|
|
static inline HRESULT get_doc_event(HTMLDocumentNode *doc, eventid_t eid, VARIANT *var)
|
2008-10-10 20:46:32 +00:00
|
|
|
{
|
2022-10-24 12:58:01 +00:00
|
|
|
return get_event_handler(&doc->node.event_target, eid, var);
|
2008-10-10 20:46:32 +00:00
|
|
|
}
|