libdom
Loading...
Searching...
No Matches
node.h
Go to the documentation of this file.
1/*
2 * This file is part of libdom.
3 * Licensed under the MIT License,
4 * http://www.opensource.org/licenses/mit-license.php
5 * Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
6 */
7
8#ifndef dom_internal_core_node_h_
9#define dom_internal_core_node_h_
10
11#include <stdbool.h>
12
13#include <libwapcaplet/libwapcaplet.h>
14
15#include <dom/core/node.h>
16#include <dom/functypes.h>
17
18#include "events/event_target.h"
19#include "events/mutation_event.h"
20
21#include "utils/list.h"
22
35
48
80
82
84 struct dom_document *doc, dom_node_type type,
85 dom_string *name, dom_string *value,
86 dom_string *namespace, dom_string *prefix);
87
89
91
92/* Event Target implementation */
94 dom_string *type, struct dom_event_listener *listener,
95 bool capture);
97 dom_string *type, struct dom_event_listener *listener,
98 bool capture);
100 dom_string *namespace, dom_string *type,
101 struct dom_event_listener *listener, bool capture);
103 dom_string *namespace, dom_string *type,
104 struct dom_event_listener *listener, bool capture);
106 struct dom_event *evt, bool *success);
107
108/* The DOM Node's vtable methods */
110 dom_string **result);
112 dom_string **result);
114 dom_string *value);
116 dom_node_type *result);
118 dom_node_internal **result);
120 struct dom_nodelist **result);
122 dom_node_internal **result);
124 dom_node_internal **result);
126 dom_node_internal **result);
128 dom_node_internal **result);
130 struct dom_namednodemap **result);
132 struct dom_document **result);
134 dom_node_internal *new_child, dom_node_internal *ref_child,
135 dom_node_internal **result);
137 dom_node_internal *new_child, dom_node_internal *old_child,
138 dom_node_internal **result);
140 dom_node_internal *old_child,
141 dom_node_internal **result);
143 dom_node_internal *new_child,
144 dom_node_internal **result);
147 dom_node_internal **result);
150 dom_string *feature, dom_string *version,
151 bool *result);
153 dom_string **result);
155 dom_string **result);
157 dom_string *prefix);
159 dom_string **result);
162 dom_string **result);
164 dom_node_internal *other, uint16_t *result);
166 dom_string **result);
168 dom_string *content);
170 dom_node_internal *other, bool *result);
172 dom_string *namespace, dom_string **result);
174 dom_string *namespace, bool *result);
176 dom_string *prefix, dom_string **result);
178 dom_node_internal *other, bool *result);
180 dom_string *feature, dom_string *version,
181 void **result);
183 dom_string *key, void *data,
184 dom_user_data_handler handler, void **result);
186 const dom_string *key, void **result);
187
188#define DOM_NODE_EVENT_TARGET_VTABLE \
189 _dom_node_add_event_listener, \
190 _dom_node_remove_event_listener, \
191 _dom_node_dispatch_event, \
192 _dom_node_add_event_listener_ns, \
193 _dom_node_remove_event_listener_ns
194
195#define DOM_NODE_VTABLE \
196 _dom_node_try_destroy, \
197 _dom_node_get_node_name, \
198 _dom_node_get_node_value, \
199 _dom_node_set_node_value, \
200 _dom_node_get_node_type, \
201 _dom_node_get_parent_node, \
202 _dom_node_get_child_nodes, \
203 _dom_node_get_first_child, \
204 _dom_node_get_last_child, \
205 _dom_node_get_previous_sibling, \
206 _dom_node_get_next_sibling, \
207 _dom_node_get_attributes, \
208 _dom_node_get_owner_document, \
209 _dom_node_insert_before, \
210 _dom_node_replace_child, \
211 _dom_node_remove_child, \
212 _dom_node_append_child, \
213 _dom_node_has_child_nodes, \
214 _dom_node_clone_node, \
215 _dom_node_normalize, \
216 _dom_node_is_supported, \
217 _dom_node_get_namespace, \
218 _dom_node_get_prefix, \
219 _dom_node_set_prefix, \
220 _dom_node_get_local_name, \
221 _dom_node_has_attributes, \
222 _dom_node_get_base, \
223 _dom_node_compare_document_position, \
224 _dom_node_get_text_content, \
225 _dom_node_set_text_content, \
226 _dom_node_is_same, \
227 _dom_node_lookup_prefix, \
228 _dom_node_is_default_namespace, \
229 _dom_node_lookup_namespace, \
230 _dom_node_is_equal, \
231 _dom_node_get_feature, \
232 _dom_node_set_user_data, \
233 _dom_node_get_user_data
234
235
236/* Following comes the protected vtable */
237void _dom_node_destroy(struct dom_node_internal *node);
239 struct dom_node_internal **copy);
240
241#define DOM_NODE_PROTECT_VTABLE \
242 _dom_node_destroy, \
243 _dom_node_copy
244
245
246/* The destroy API should be used inside DOM module */
247static inline void dom_node_destroy(struct dom_node_internal *node)
248{
249 ((dom_node_protect_vtable *) node->vtable)->destroy(node);
250}
251#define dom_node_destroy(n) dom_node_destroy((dom_node_internal *) (n))
252
253/* Copy the Node old to new */
254static inline dom_exception dom_node_copy(struct dom_node_internal *old,
255 struct dom_node_internal **copy)
256{
257 return ((dom_node_protect_vtable *) old->vtable)->copy(old, copy);
258}
259#define dom_node_copy(o,c) dom_node_copy((dom_node_internal *) (o), \
260 (dom_node_internal **) (c))
261
262/* Following are some helper functions */
264 dom_node_internal *new);
265#define dom_node_copy_internal(o, n) _dom_node_copy_internal( \
266 (dom_node_internal *) (o), (dom_node_internal *) (n))
267
268#define dom_node_get_owner(n) ((dom_node_internal *) (n))->owner
269
270#define dom_node_set_owner(n, d) ((dom_node_internal *) (n))->owner = \
271 (struct dom_document *) (d)
272
273#define dom_node_get_parent(n) ((dom_node_internal *) (n))->parent
274
275#define dom_node_set_parent(n, p) ((dom_node_internal *) (n))->parent = \
276 (dom_node_internal *) (p)
277
278#define dom_node_get_refcount(n) ((dom_node_internal *) (n))->refcnt
279
282
283/* Try to destroy the node, if its refcnt is not zero, then append it to the
284 * owner document's pending list */
286
287/* To add some node to the pending list */
289#define dom_node_mark_pending(n) _dom_node_mark_pending(\
290 (dom_node_internal *) (n))
291/* To remove the node from the pending list, this may happen when
292 * a node is removed and then appended to another parent */
294#define dom_node_remove_pending(n) _dom_node_remove_pending(\
295 (dom_node_internal *) (n))
296
298 dom_node_internal *node, dom_node_internal *related,
299 dom_mutation_type change, bool *success);
300#define dom_node_dispatch_node_change_event( \
301 doc, node, related, change, success) \
302 _dom_node_dispatch_node_change_event((dom_document *) (doc), \
303 (dom_node_internal *) (node), \
304 (dom_node_internal *) (related), \
305 (dom_mutation_type) (change), \
306 (bool *) (success))
307
308#endif
dom_exception
Definition exceptions.h:24
void(* dom_user_data_handler)(dom_node_operation operation, dom_string *key, void *data, struct dom_node *src, struct dom_node *dst)
Definition node.h:49
dom_node_type
Definition node.h:56
dom_mutation_type
Definition mutation_event.h:17
struct dom_node_protect_vtable dom_node_protect_vtable
dom_exception _dom_node_remove_child(dom_node_internal *node, dom_node_internal *old_child, dom_node_internal **result)
Definition node.c:966
dom_exception _dom_node_get_text_content(dom_node_internal *node, dom_string **result)
Definition node.c:1447
dom_exception _dom_node_set_user_data(dom_node_internal *node, dom_string *key, void *data, dom_user_data_handler handler, void **result)
Definition node.c:1761
bool _dom_node_readonly(const dom_node_internal *node)
Definition node.c:2014
dom_exception _dom_node_initialise(struct dom_node_internal *node, struct dom_document *doc, dom_node_type type, dom_string *name, dom_string *value, dom_string *namespace, dom_string *prefix)
Definition node.c:146
dom_exception _dom_node_is_default_namespace(dom_node_internal *node, dom_string *namespace, bool *result)
Definition node.c:1575
dom_exception _dom_node_add_event_listener_ns(dom_event_target *et, dom_string *namespace, dom_string *type, struct dom_event_listener *listener, bool capture)
Definition node.c:2350
dom_exception _dom_merge_adjacent_text(dom_node_internal *p, dom_node_internal *n)
Definition node.c:2235
dom_exception _dom_node_is_equal(dom_node_internal *node, dom_node_internal *other, bool *result)
Definition node.c:1629
dom_exception _dom_node_get_base(dom_node_internal *node, dom_string **result)
Definition node.c:1397
void _dom_node_destroy(struct dom_node_internal *node)
Definition node.c:101
dom_exception _dom_node_lookup_prefix(dom_node_internal *node, dom_string *namespace, dom_string **result)
Definition node.c:1556
dom_exception _dom_node_get_previous_sibling(dom_node_internal *node, dom_node_internal **result)
Definition node.c:595
dom_exception _dom_node_get_first_child(dom_node_internal *node, dom_node_internal **result)
Definition node.c:549
void _dom_node_mark_pending(dom_node_internal *node)
Definition node.c:2292
dom_exception _dom_node_get_user_data(const dom_node_internal *node, const dom_string *key, void **result)
Definition node.c:1830
dom_exception _dom_node_has_child_nodes(dom_node_internal *node, bool *result)
Definition node.c:1054
dom_exception _dom_node_get_namespace(dom_node_internal *node, dom_string **result)
Definition node.c:1236
dom_exception _dom_node_has_attributes(dom_node_internal *node, bool *result)
Definition node.c:1375
dom_exception _dom_node_try_destroy(dom_node_internal *node)
Definition node.c:2268
#define dom_node_destroy(n)
Definition node.h:251
dom_exception _dom_node_set_prefix(dom_node_internal *node, dom_string *prefix)
Definition node.c:1298
dom_exception _dom_node_set_text_content(dom_node_internal *node, dom_string *content)
Definition node.c:1486
dom_exception _dom_node_replace_child(dom_node_internal *node, dom_node_internal *new_child, dom_node_internal *old_child, dom_node_internal **result)
Definition node.c:868
dom_exception _dom_node_get_feature(dom_node_internal *node, dom_string *feature, dom_string *version, void **result)
Definition node.c:1733
dom_exception _dom_node_clone_node(dom_node_internal *node, bool deep, dom_node_internal **result)
Definition node.c:1104
dom_exception _dom_node_is_same(dom_node_internal *node, dom_node_internal *other, bool *result)
Definition node.c:1536
dom_exception _dom_node_append_child(dom_node_internal *node, dom_node_internal *new_child, dom_node_internal **result)
Definition node.c:1039
dom_exception _dom_node_copy(struct dom_node_internal *old, struct dom_node_internal **copy)
Definition node.c:1855
void _dom_node_remove_pending(dom_node_internal *node)
Definition node.c:2314
dom_exception _dom_node_add_event_listener(dom_event_target *et, dom_string *type, struct dom_event_listener *listener, bool capture)
Definition node.c:2330
dom_exception _dom_node_get_owner_document(dom_node_internal *node, struct dom_document **result)
Definition node.c:674
dom_exception _dom_node_get_prefix(dom_node_internal *node, dom_string **result)
Definition node.c:1261
dom_exception _dom_node_is_supported(dom_node_internal *node, dom_string *feature, dom_string *version, bool *result)
Definition node.c:1209
dom_exception _dom_node_get_local_name(dom_node_internal *node, dom_string **result)
Definition node.c:1347
dom_exception _dom_node_lookup_namespace(dom_node_internal *node, dom_string *prefix, dom_string **result)
Definition node.c:1597
dom_exception _dom_node_insert_before(dom_node_internal *node, dom_node_internal *new_child, dom_node_internal *ref_child, dom_node_internal **result)
Definition node.c:725
dom_exception _dom_node_normalize(dom_node_internal *node)
Definition node.c:1165
#define dom_node_copy(o, c)
Definition node.h:259
void _dom_node_finalise(dom_node_internal *node)
Definition node.c:221
dom_exception _dom_node_get_node_value(dom_node_internal *node, dom_string **result)
Definition node.c:409
dom_node_internal * _dom_node_create(void)
Definition node.c:76
dom_exception _dom_node_get_node_name(dom_node_internal *node, dom_string **result)
Definition node.c:342
dom_exception _dom_node_remove_event_listener(dom_event_target *et, dom_string *type, struct dom_event_listener *listener, bool capture)
Definition node.c:2340
dom_exception _dom_node_get_child_nodes(dom_node_internal *node, struct dom_nodelist **result)
Definition node.c:524
dom_exception _dom_node_set_node_value(dom_node_internal *node, dom_string *value)
Definition node.c:433
dom_exception _dom_node_compare_document_position(dom_node_internal *node, dom_node_internal *other, uint16_t *result)
Definition node.c:1421
dom_exception _dom_node_dispatch_event(dom_event_target *et, struct dom_event *evt, bool *success)
Definition node.c:2421
dom_exception _dom_node_get_parent_node(dom_node_internal *node, dom_node_internal **result)
Definition node.c:496
dom_exception _dom_node_remove_event_listener_ns(dom_event_target *et, dom_string *namespace, dom_string *type, struct dom_event_listener *listener, bool capture)
Definition node.c:2360
dom_exception _dom_node_get_node_type(dom_node_internal *node, dom_node_type *result)
Definition node.c:477
dom_exception _dom_node_get_last_child(dom_node_internal *node, dom_node_internal **result)
Definition node.c:572
dom_exception _dom_node_get_next_sibling(dom_node_internal *node, dom_node_internal **result)
Definition node.c:624
dom_exception _dom_node_dispatch_node_change_event(dom_document *doc, dom_node_internal *node, dom_node_internal *related, dom_mutation_type change, bool *success)
Definition node.c:2596
dom_exception _dom_node_copy_internal(dom_node_internal *old, dom_node_internal *new)
Definition node.c:1875
dom_exception _dom_node_get_attributes(dom_node_internal *node, struct dom_namednodemap **result)
Definition node.c:654
Definition document.h:43
Definition event_listener.h:18
Definition event_target.h:36
Definition event_target.h:20
Definition event.h:27
Definition namednodemap.c:26
Definition node.h:54
dom_string * value
Definition node.h:61
struct dom_document * owner
Definition node.h:69
dom_node_internal * parent
Definition node.h:63
dom_node_internal * first_child
Definition node.h:64
const void * vtable
Definition node.h:56
dom_node_type type
Definition node.h:62
dom_node_internal * last_child
Definition node.h:65
struct list_entry pending_list
Definition node.h:76
dom_string * prefix
Definition node.h:71
dom_node_internal * next
Definition node.h:67
dom_node_internal * previous
Definition node.h:66
struct dom_node base
Definition node.h:55
dom_string * name
Definition node.h:58
dom_event_target_internal eti
Definition node.h:78
struct dom_user_data * user_data
Definition node.h:74
Definition node.h:39
void(* destroy)(dom_node_internal *n)
Definition node.h:41
dom_exception(* copy)(dom_node_internal *old, dom_node_internal **copy)
Definition node.h:44
Definition node.h:79
Definition nodelist.c:26
Definition string.h:19
Definition node.h:26
dom_user_data_handler handler
Definition node.h:29
void * data
Definition node.h:28
struct dom_user_data * next
Definition node.h:31
dom_string * key
Definition node.h:27
struct dom_user_data * prev
Definition node.h:32
Definition list.h:17