summaryrefslogtreecommitdiff
path: root/src/events/event.h
blob: 857f20adffe4bc440091594cb67f32ba0339faeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
 * This file is part of libdom.
 * Licensed under the MIT License,
 *                http://www.opensource.org/licenses/mit-license.php
 * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
 */

#ifndef dom_internal_events_event_h_
#define dom_internal_events_event_h_

#include <inttypes.h>

#include <dom/core/document.h>
#include <dom/events/event_target.h>
#include <dom/events/event.h>

#include "utils/list.h"

/* The private virtual table */
struct dom_event_private_vtable {
	void (*destroy)(dom_event *evt);
};

/**
 * The Event Object
 */
struct dom_event {
	dom_string *type;	/**< The type of the event */
	dom_event_target *target;	/**< The event target */
	dom_event_target *current; 	/**< The current event target */
	dom_event_flow_phase phase;		/**< The event phase */
	bool bubble;	/**< Whether this event is a bubbling event */
	bool cancelable;	/**< Whether this event is cancelable */
	unsigned int timestamp;
			/**< The timestamp this event is created */

	dom_string *namespace;	/**< The namespace of this event */

	bool stop; 		/**< Whether stopPropagation is called */
	bool stop_now;	/**< Whether stopImmediatePropagation is called */
	bool prevent_default;
			/**< Whether the default action is prevented */

	bool custom;	/**< Whether this is a custom event */

	uint32_t refcnt;	/**< The reference count of this object */

	struct dom_event_private_vtable *vtable;
			/**< The private virtual function table of Event */
	bool in_dispatch;	/**< Whether this event is in dispatch */
	bool is_initialised;	/**< Whether this event is initialised */
	bool is_trusted;	/**< Whether this event is trusted */
};

/* Destructor */
void _dom_event_destroy(dom_event *evt);

/* Initialise function */
dom_exception _dom_event_initialise(dom_event *evt);

/* Finalise function */
void _dom_event_finalise(dom_event *evt);


static inline void dom_event_destroy(dom_event *evt)
{
	evt->vtable->destroy(evt);
}
#define dom_event_destroy(e) dom_event_destroy((dom_event *) (e))

#endif