libdom
Loading...
Searching...
No Matches
document.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_document_h_
9#define dom_internal_core_document_h_
10
11#include <inttypes.h>
12#include <stddef.h>
13
14#include <dom/core/node.h>
15#include <dom/core/attr.h>
17#include <dom/core/comment.h>
18#include <dom/core/document.h>
21#include <dom/core/element.h>
22#include <dom/core/entity_ref.h>
23#include <dom/core/pi.h>
24#include <dom/core/text.h>
26
27#include "core/string.h"
28#include "core/node.h"
29#include "core/nodelist.h"
30
31#include "utils/hashtable.h"
32#include "utils/list.h"
33
34#include "events/document_event.h"
35
36struct dom_doc_nl;
37
74
75/* Create a DOM document */
77 void *daf_ctx,
78 dom_document **doc);
79
80/* Initialise the document */
83 void *daf_ctx);
84
85/* Finalise the document */
87
88/* Begin the virtual functions */
90 dom_document_type **result);
92 dom_implementation **result);
94 dom_element **result);
96 dom_string *tag_name, dom_element **result);
98 dom_document_fragment **result);
100 dom_string *data, dom_text **result);
102 dom_string *data, dom_comment **result);
104 dom_string *data, dom_cdata_section **result);
106 dom_document *doc, dom_string *target,
107 dom_string *data,
110 dom_string *name, dom_attr **result);
112 dom_string *name,
113 dom_entity_reference **result);
115 dom_string *tagname, dom_nodelist **result);
117 dom_node *node, bool deep, dom_node **result);
119 dom_string *namespace, dom_string *qname,
120 dom_element **result);
122 dom_string *namespace, dom_string *qname,
123 dom_attr **result);
125 dom_document *doc, dom_string *namespace,
126 dom_string *localname, dom_nodelist **result);
128 dom_string *id, dom_element **result);
130 dom_string **result);
132 dom_string **result);
134 bool *result);
136 bool standalone);
138 dom_string **result);
140 dom_string *version);
142 dom_document *doc, bool *result);
144 dom_document *doc, bool strict);
146 dom_string **result);
148 dom_string *uri);
150 dom_node *node, dom_node **result);
152 struct dom_configuration **result);
155 dom_node *node,
156 dom_string *namespace, dom_string *qname,
157 dom_node **result);
162
163
165 dom_string **result);
167 dom_string *content);
168
169#define DOM_DOCUMENT_VTABLE \
170 _dom_document_get_doctype, \
171 _dom_document_get_implementation, \
172 _dom_document_get_document_element, \
173 _dom_document_create_element, \
174 _dom_document_create_document_fragment, \
175 _dom_document_create_text_node, \
176 _dom_document_create_comment, \
177 _dom_document_create_cdata_section, \
178 _dom_document_create_processing_instruction, \
179 _dom_document_create_attribute, \
180 _dom_document_create_entity_reference, \
181 _dom_document_get_elements_by_tag_name, \
182 _dom_document_import_node, \
183 _dom_document_create_element_ns, \
184 _dom_document_create_attribute_ns, \
185 _dom_document_get_elements_by_tag_name_ns, \
186 _dom_document_get_element_by_id, \
187 _dom_document_get_input_encoding, \
188 _dom_document_get_xml_encoding, \
189 _dom_document_get_xml_standalone, \
190 _dom_document_set_xml_standalone, \
191 _dom_document_get_xml_version, \
192 _dom_document_set_xml_version, \
193 _dom_document_get_strict_error_checking, \
194 _dom_document_set_strict_error_checking, \
195 _dom_document_get_uri, \
196 _dom_document_set_uri, \
197 _dom_document_adopt_node, \
198 _dom_document_get_dom_config, \
199 _dom_document_normalize, \
200 _dom_document_rename_node, \
201 _dom_document_get_quirks_mode, \
202 _dom_document_set_quirks_mode
203
204/* End of vtable */
205
206#define DOM_NODE_VTABLE_DOCUMENT \
207 _dom_node_try_destroy, \
208 _dom_node_get_node_name, \
209 _dom_node_get_node_value, \
210 _dom_node_set_node_value, \
211 _dom_node_get_node_type, \
212 _dom_node_get_parent_node, \
213 _dom_node_get_child_nodes, \
214 _dom_node_get_first_child, \
215 _dom_node_get_last_child, \
216 _dom_node_get_previous_sibling, \
217 _dom_node_get_next_sibling, \
218 _dom_node_get_attributes, \
219 _dom_node_get_owner_document, \
220 _dom_node_insert_before, \
221 _dom_node_replace_child, \
222 _dom_node_remove_child, \
223 _dom_node_append_child, \
224 _dom_node_has_child_nodes, \
225 _dom_node_clone_node, \
226 _dom_node_normalize, \
227 _dom_node_is_supported, \
228 _dom_node_get_namespace, \
229 _dom_node_get_prefix, \
230 _dom_node_set_prefix, \
231 _dom_node_get_local_name, \
232 _dom_node_has_attributes, \
233 _dom_node_get_base, \
234 _dom_node_compare_document_position, \
235 _dom_document_get_text_content, \
236 _dom_document_set_text_content, \
237 _dom_node_is_same, \
238 _dom_node_lookup_prefix, \
239 _dom_node_is_default_namespace, \
240 _dom_node_lookup_namespace, \
241 _dom_node_is_equal, \
242 _dom_node_get_feature, \
243 _dom_node_set_user_data, \
244 _dom_node_get_user_data
245
246/* Following comes the protected vtable */
249 dom_node_internal **copy);
250
251#define DOM_DOCUMENT_PROTECT_VTABLE \
252 _dom_document_destroy, \
253 _dom_document_copy
254
255
256/*---------------------------- Helper functions ---------------------------*/
257
258/* Try to destroy the document:
259 * When the refcnt is zero and the pending list is empty, we can destroy this
260 * document. */
262
263/* Get a nodelist, creating one if necessary */
266 dom_string *tagname, dom_string *namespace,
267 dom_string *localname, dom_nodelist **list);
268/* Remove a nodelist */
270
271/* Find element with certain ID in the subtree rooted at root */
273 dom_string *id, dom_element **result);
274
275/* Set the ID attribute name of this document */
277
278#define _dom_document_get_id_name(d) (d->id_name)
279
280#endif
dom_exception
Definition exceptions.h:24
const char dom_implementation
Definition implementation.h:20
dom_document_quirks_mode
Definition document.h:40
dom_default_action_callback(* dom_events_default_action_fetcher)(dom_string *type, dom_default_action_phase phase, void **pw)
Definition document_event.h:83
dom_exception _dom_document_get_document_element(dom_document *doc, dom_element **result)
Definition document.c:406
void _dom_document_set_id_name(dom_document *doc, dom_string *name)
Definition document.c:1532
dom_exception _dom_document_create_element(dom_document *doc, dom_string *tag_name, dom_element **result)
Definition document.c:440
dom_exception _dom_document_set_strict_error_checking(dom_document *doc, bool strict)
Definition document.c:1012
dom_exception _dom_document_get_strict_error_checking(dom_document *doc, bool *result)
Definition document.c:996
dom_exception _dom_document_set_quirks_mode(dom_document *doc, dom_document_quirks_mode result)
Definition document.c:1549
dom_exception _dom_find_element_by_id(dom_node_internal *root, dom_string *id, dom_element **result)
Definition document.c:1372
dom_exception _dom_document_create_element_ns(dom_document *doc, dom_string *namespace, dom_string *qname, dom_element **result)
Definition document.c:711
dom_exception _dom_document_get_dom_config(dom_document *doc, struct dom_configuration **result)
Definition document.c:1144
dom_exception _dom_document_set_uri(dom_document *doc, dom_string *uri)
Definition document.c:1051
dom_exception _dom_document_rename_node(dom_document *doc, dom_node *node, dom_string *namespace, dom_string *qname, dom_node **result)
Definition document.c:1200
dom_exception _dom_document_create_cdata_section(dom_document *doc, dom_string *data, dom_cdata_section **result)
Definition document.c:548
dom_exception _dom_document_create_entity_reference(dom_document *doc, dom_string *name, dom_entity_reference **result)
Definition document.c:629
dom_exception _dom_document_get_elements_by_tag_name(dom_document *doc, dom_string *tagname, dom_nodelist **result)
Definition document.c:651
dom_exception _dom_document_get_elements_by_tag_name_ns(dom_document *doc, dom_string *namespace, dom_string *localname, dom_nodelist **result)
Definition document.c:826
dom_exception _dom_document_get_quirks_mode(dom_document *doc, dom_document_quirks_mode *result)
Definition document.c:1542
dom_exception _dom_document_get_element_by_id(dom_document *doc, dom_string *id, dom_element **result)
Definition document.c:847
dom_exception _dom_document_create_attribute(dom_document *doc, dom_string *name, dom_attr **result)
Definition document.c:606
dom_exception _dom_document_create_text_node(dom_document *doc, dom_string *data, dom_text **result)
Definition document.c:489
dom_exception _dom_document_get_uri(dom_document *doc, dom_string **result)
Definition document.c:1032
void _dom_document_destroy(dom_node_internal *node)
Definition document.c:1238
dom_exception _dom_document_get_implementation(dom_document *doc, dom_implementation **result)
Definition document.c:385
void _dom_document_try_destroy(dom_document *doc)
Definition document.c:1518
dom_exception _dom_document_get_xml_encoding(dom_document *doc, dom_string **result)
Definition document.c:899
dom_exception _dom_document_create_comment(dom_document *doc, dom_string *data, dom_comment **result)
Definition document.c:518
dom_exception _dom_document_get_xml_standalone(dom_document *doc, bool *result)
Definition document.c:915
dom_exception _dom_document_set_text_content(dom_node_internal *node, dom_string *content)
Definition document.c:1224
dom_exception _dom_document_get_text_content(dom_node_internal *node, dom_string **result)
Definition document.c:1214
dom_exception _dom_document_create_document_fragment(dom_document *doc, dom_document_fragment **result)
Definition document.c:460
dom_exception _dom_document_get_input_encoding(dom_document *doc, dom_string **result)
Definition document.c:879
dom_exception _dom_document_get_xml_version(dom_document *doc, dom_string **result)
Definition document.c:959
void _dom_document_remove_nodelist(dom_document *doc, dom_nodelist *list)
Definition document.c:1336
dom_exception _dom_document_import_node(dom_document *doc, dom_node *node, bool deep, dom_node **result)
Definition document.c:674
dom_exception _dom_document_set_xml_version(dom_document *doc, dom_string *version)
Definition document.c:980
dom_exception _dom_document_create_attribute_ns(dom_document *doc, dom_string *namespace, dom_string *qname, dom_attr **result)
Definition document.c:776
dom_exception _dom_document_copy(dom_node_internal *old, dom_node_internal **copy)
Definition document.c:1248
dom_exception _dom_document_set_xml_standalone(dom_document *doc, bool standalone)
Definition document.c:936
dom_exception _dom_document_get_doctype(dom_document *doc, dom_document_type **result)
Definition document.c:356
dom_exception _dom_document_adopt_node(dom_document *doc, dom_node *node, dom_node **result)
Definition document.c:1083
dom_exception _dom_document_create(dom_events_default_action_fetcher daf, void *daf_ctx, dom_document **doc)
Definition document.c:81
dom_exception _dom_document_normalize(dom_document *doc)
Definition document.c:1159
bool _dom_document_finalise(dom_document *doc)
Definition document.c:295
dom_exception _dom_document_initialise(dom_document *doc, dom_events_default_action_fetcher daf, void *daf_ctx)
Definition document.c:115
dom_exception _dom_document_create_processing_instruction(dom_document *doc, dom_string *target, dom_string *data, dom_processing_instruction **result)
Definition document.c:580
dom_exception _dom_document_get_nodelist(dom_document *doc, nodelist_type type, dom_node_internal *root, dom_string *tagname, dom_string *namespace, dom_string *localname, dom_nodelist **list)
Definition document.c:1278
nodelist_type
Definition nodelist.h:22
Definition attr.c:31
Definition cdatasection.c:19
Definition comment.c:20
Definition document.c:37
Definition document_event.h:38
Definition doc_fragment.c:21
Definition document_type.c:23
Definition document.h:43
dom_string * class_string
Definition document.h:55
dom_string * _memo_domattrmodified
Definition document.h:70
dom_string * _memo_domnodeinserted
Definition document.h:66
dom_document_quirks_mode quirks
Definition document.h:61
struct dom_doc_nl * nodelists
Definition document.h:46
dom_document_event_internal dei
Definition document.h:59
dom_string * _memo_domnoderemovedfromdocument
Definition document.h:69
dom_string * _memo_domnodeinsertedintodocument
Definition document.h:68
dom_string * _memo_domsubtreemodified
Definition document.h:72
dom_node_internal base
Definition document.h:44
dom_string * uri
Definition document.h:48
struct list_entry pending_nodes
Definition document.h:50
dom_string * _memo_domnoderemoved
Definition document.h:67
dom_string * id_name
Definition document.h:53
dom_string * script_string
Definition document.h:57
dom_string * _memo_domcharacterdatamodified
Definition document.h:71
dom_string * _memo_empty
Definition document.h:63
Definition element.h:29
Definition entity_ref.c:19
Definition node.h:54
Definition node.h:79
Definition nodelist.c:26
Definition pi.c:19
Definition string.h:19
Definition text.h:23
Definition list.h:17
Definition list.h:33