2008-10-09 22:36:01 +02: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 {
|
2012-10-17 12:18:30 +02:00
|
|
|
EVENTID_ABORT,
|
2017-02-15 16:28:37 +01:00
|
|
|
EVENTID_BEFOREACTIVATE,
|
2009-09-08 22:30:14 +02:00
|
|
|
EVENTID_BEFOREUNLOAD,
|
2008-10-10 22:49:09 +02:00
|
|
|
EVENTID_BLUR,
|
2008-10-09 22:36:01 +02:00
|
|
|
EVENTID_CHANGE,
|
|
|
|
EVENTID_CLICK,
|
2010-05-07 15:20:33 +02:00
|
|
|
EVENTID_CONTEXTMENU,
|
2012-09-13 12:27:43 +02:00
|
|
|
EVENTID_DATAAVAILABLE,
|
2009-09-08 22:32:47 +02:00
|
|
|
EVENTID_DBLCLICK,
|
2008-10-10 22:49:09 +02:00
|
|
|
EVENTID_DRAG,
|
2008-10-10 22:49:25 +02:00
|
|
|
EVENTID_DRAGSTART,
|
2012-04-04 15:08:38 +02:00
|
|
|
EVENTID_ERROR,
|
2008-10-10 22:49:09 +02:00
|
|
|
EVENTID_FOCUS,
|
2014-12-16 13:10:29 +01:00
|
|
|
EVENTID_FOCUSIN,
|
2016-04-04 13:22:20 +02:00
|
|
|
EVENTID_FOCUSOUT,
|
2012-09-04 13:58:58 +02:00
|
|
|
EVENTID_HELP,
|
2008-10-10 22:49:16 +02:00
|
|
|
EVENTID_KEYDOWN,
|
2012-04-10 12:53:12 +02:00
|
|
|
EVENTID_KEYPRESS,
|
2008-10-09 22:36:01 +02:00
|
|
|
EVENTID_KEYUP,
|
|
|
|
EVENTID_LOAD,
|
2016-04-04 18:01:46 +02:00
|
|
|
EVENTID_MESSAGE,
|
2008-10-10 22:49:16 +02:00
|
|
|
EVENTID_MOUSEDOWN,
|
2011-02-21 10:23:48 +01:00
|
|
|
EVENTID_MOUSEMOVE,
|
2008-10-10 22:49:33 +02:00
|
|
|
EVENTID_MOUSEOUT,
|
2008-10-10 22:46:08 +02:00
|
|
|
EVENTID_MOUSEOVER,
|
2008-10-10 22:49:16 +02:00
|
|
|
EVENTID_MOUSEUP,
|
2014-09-11 11:03:24 +02:00
|
|
|
EVENTID_MOUSEWHEEL,
|
2008-10-10 22:49:09 +02:00
|
|
|
EVENTID_PASTE,
|
2009-09-14 00:35:40 +02:00
|
|
|
EVENTID_READYSTATECHANGE,
|
2009-12-07 23:28:10 +01:00
|
|
|
EVENTID_RESIZE,
|
2012-09-10 14:41:28 +02:00
|
|
|
EVENTID_SCROLL,
|
2017-02-16 16:35:37 +01:00
|
|
|
EVENTID_SELECTIONCHANGE,
|
2008-10-10 22:49:25 +02:00
|
|
|
EVENTID_SELECTSTART,
|
2011-02-28 13:13:49 +01:00
|
|
|
EVENTID_SUBMIT,
|
2016-05-26 16:16:09 +02:00
|
|
|
EVENTID_UNLOAD,
|
2008-10-09 22:36:01 +02:00
|
|
|
EVENTID_LAST
|
|
|
|
} eventid_t;
|
|
|
|
|
2017-10-19 17:02:21 +02:00
|
|
|
typedef struct {
|
|
|
|
DispatchEx dispex;
|
|
|
|
IDOMEvent IDOMEvent_iface;
|
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
nsIDOMEvent *nsevent;
|
2017-10-19 17:02:30 +02:00
|
|
|
eventid_t event_id;
|
2017-10-19 17:02:54 +02:00
|
|
|
EventTarget *target;
|
2017-10-20 15:08:59 +02:00
|
|
|
BOOL prevent_default;
|
2017-10-20 15:09:05 +02:00
|
|
|
BOOL stop_propagation;
|
2017-10-20 15:09:15 +02:00
|
|
|
|
|
|
|
IHTMLEventObj *event_obj;
|
|
|
|
BOOL no_event_obj;
|
2017-10-19 17:02:21 +02:00
|
|
|
} DOMEvent;
|
|
|
|
|
2011-05-01 20:27:06 +02:00
|
|
|
eventid_t str_to_eid(LPCWSTR) DECLSPEC_HIDDEN;
|
2014-05-27 11:29:37 +02:00
|
|
|
void check_event_attr(HTMLDocumentNode*,nsIDOMHTMLElement*) DECLSPEC_HIDDEN;
|
2017-02-13 21:11:50 +01:00
|
|
|
void release_event_target(EventTarget*) DECLSPEC_HIDDEN;
|
2017-10-19 17:01:33 +02:00
|
|
|
void fire_event(HTMLDocumentNode*,eventid_t,BOOL,EventTarget*,nsIDOMEvent*) DECLSPEC_HIDDEN;
|
2015-05-20 19:47:11 +02:00
|
|
|
HRESULT set_event_handler(EventTarget*,eventid_t,VARIANT*) DECLSPEC_HIDDEN;
|
2015-05-14 13:25:34 +02:00
|
|
|
HRESULT get_event_handler(EventTarget*,eventid_t,VARIANT*) DECLSPEC_HIDDEN;
|
2015-05-20 19:46:53 +02:00
|
|
|
HRESULT attach_event(EventTarget*,BSTR,IDispatch*,VARIANT_BOOL*) DECLSPEC_HIDDEN;
|
2015-05-20 19:47:00 +02:00
|
|
|
HRESULT detach_event(EventTarget*,BSTR,IDispatch*) DECLSPEC_HIDDEN;
|
2011-05-01 20:27:06 +02:00
|
|
|
HRESULT dispatch_event(HTMLDOMNode*,const WCHAR*,VARIANT*,VARIANT_BOOL*) DECLSPEC_HIDDEN;
|
2015-05-15 17:59:35 +02:00
|
|
|
void update_doc_cp_events(HTMLDocumentNode*,cp_static_data_t*) DECLSPEC_HIDDEN;
|
2011-08-02 11:08:32 +02:00
|
|
|
HRESULT doc_init_events(HTMLDocumentNode*) DECLSPEC_HIDDEN;
|
2011-11-24 12:48:31 +01:00
|
|
|
void detach_events(HTMLDocumentNode *doc) DECLSPEC_HIDDEN;
|
2012-09-13 12:27:56 +02:00
|
|
|
HRESULT create_event_obj(IHTMLEventObj**) DECLSPEC_HIDDEN;
|
2015-05-14 13:25:09 +02:00
|
|
|
void bind_target_event(HTMLDocumentNode*,EventTarget*,const WCHAR*,IDispatch*) DECLSPEC_HIDDEN;
|
2015-05-20 19:46:53 +02:00
|
|
|
HRESULT ensure_doc_nsevent_handler(HTMLDocumentNode*,eventid_t) DECLSPEC_HIDDEN;
|
2008-10-10 22:46:20 +02:00
|
|
|
|
2017-10-20 15:09:15 +02:00
|
|
|
void call_event_handlers(EventTarget*,DOMEvent*);
|
2015-07-01 17:38:17 +02:00
|
|
|
|
2017-10-19 17:02:08 +02:00
|
|
|
HRESULT create_document_event_str(HTMLDocumentNode*,const WCHAR*,IDOMEvent**) DECLSPEC_HIDDEN;
|
2017-10-19 17:03:26 +02:00
|
|
|
HRESULT create_event_from_nsevent(nsIDOMEvent*,DOMEvent**) DECLSPEC_HIDDEN;
|
2017-10-19 17:02:08 +02:00
|
|
|
|
2011-08-02 11:08:12 +02:00
|
|
|
void init_nsevents(HTMLDocumentNode*) DECLSPEC_HIDDEN;
|
|
|
|
void release_nsevents(HTMLDocumentNode*) DECLSPEC_HIDDEN;
|
|
|
|
void add_nsevent_listener(HTMLDocumentNode*,nsIDOMNode*,LPCWSTR) DECLSPEC_HIDDEN;
|
2011-11-24 12:48:31 +01:00
|
|
|
void detach_nsevent(HTMLDocumentNode*,const WCHAR*) DECLSPEC_HIDDEN;
|
2011-08-02 11:08:12 +02:00
|
|
|
|
2017-10-18 16:38:51 +02:00
|
|
|
/* We extend dispex vtbl for EventTarget functions to avoid separated vtbl. */
|
|
|
|
typedef struct {
|
|
|
|
dispex_static_data_vtbl_t dispex_vtbl;
|
|
|
|
void (*bind_event)(DispatchEx*,eventid_t);
|
2017-10-19 17:01:33 +02:00
|
|
|
EventTarget *(*get_parent_event_target)(DispatchEx*);
|
2017-10-18 16:40:02 +02:00
|
|
|
HRESULT (*handle_event_default)(DispatchEx*,eventid_t,nsIDOMEvent*,BOOL*);
|
2017-10-18 16:39:22 +02:00
|
|
|
ConnectionPointContainer *(*get_cp_container)(DispatchEx*);
|
2017-10-19 17:01:43 +02:00
|
|
|
IHTMLEventObj *(*set_current_event)(DispatchEx*,IHTMLEventObj*);
|
2017-10-18 16:38:51 +02:00
|
|
|
} event_target_vtbl_t;
|
|
|
|
|
2017-10-19 17:01:43 +02:00
|
|
|
IHTMLEventObj *default_set_current_event(HTMLInnerWindow*,IHTMLEventObj*) DECLSPEC_HIDDEN;
|
|
|
|
|
2017-10-16 22:31:42 +02: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 22:46:20 +02:00
|
|
|
static inline HRESULT set_node_event(HTMLDOMNode *node, eventid_t eid, VARIANT *var)
|
|
|
|
{
|
2017-10-16 22:31:42 +02:00
|
|
|
return set_event_handler(get_node_event_prop_target(node, eid), eid, var);
|
2008-10-10 22:46:20 +02:00
|
|
|
}
|
|
|
|
|
2008-10-10 22:46:32 +02:00
|
|
|
static inline HRESULT get_node_event(HTMLDOMNode *node, eventid_t eid, VARIANT *var)
|
|
|
|
{
|
2017-10-16 22:31:42 +02:00
|
|
|
return get_event_handler(get_node_event_prop_target(node, eid), eid, var);
|
2008-10-10 22:46:32 +02:00
|
|
|
}
|
|
|
|
|
2008-10-10 22:46:20 +02:00
|
|
|
static inline HRESULT set_doc_event(HTMLDocument *doc, eventid_t eid, VARIANT *var)
|
|
|
|
{
|
2017-10-16 22:31:42 +02:00
|
|
|
return set_event_handler(&doc->doc_node->node.event_target, eid, var);
|
2008-10-10 22:46:20 +02:00
|
|
|
}
|
2008-10-10 22:46:32 +02:00
|
|
|
|
|
|
|
static inline HRESULT get_doc_event(HTMLDocument *doc, eventid_t eid, VARIANT *var)
|
|
|
|
{
|
2017-10-16 22:31:42 +02:00
|
|
|
return get_event_handler(&doc->doc_node->node.event_target, eid, var);
|
2008-10-10 22:46:32 +02:00
|
|
|
}
|