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
76
77/* Create a DOM document */
79 void *daf_ctx,
80 dom_document **doc);
81
82/* Initialise the document */
85 void *daf_ctx);
86
87/* Finalise the document */
89
90/* Begin the virtual functions */
92 dom_document_type **result);
94 dom_implementation **result);
96 dom_element **result);
98 dom_string *tag_name, dom_element **result);
100 dom_document_fragment **result);
102 dom_string *data, dom_text **result);
104 dom_string *data, dom_comment **result);
106 dom_string *data, dom_cdata_section **result);
108 dom_document *doc, dom_string *target,
109 dom_string *data,
112 dom_string *name, dom_attr **result);
114 dom_string *name,
115 dom_entity_reference **result);
117 dom_string *tagname, dom_nodelist **result);
119 dom_node *node, bool deep, dom_node **result);
121 dom_string *namespace, dom_string *qname,
122 dom_element **result);
124 dom_string *namespace, dom_string *qname,
125 dom_attr **result);
127 dom_document *doc, dom_string *namespace,
128 dom_string *localname, dom_nodelist **result);
130 dom_string *id, dom_element **result);
132 dom_string **result);
134 dom_string **result);
136 bool *result);
138 bool standalone);
140 dom_string **result);
142 dom_string *version);
144 dom_document *doc, bool *result);
146 dom_document *doc, bool strict);
148 dom_string **result);
150 dom_string *uri);
152 dom_node *node, dom_node **result);
154 struct dom_configuration **result);
157 dom_node *node,
158 dom_string *namespace, dom_string *qname,
159 dom_node **result);
164
165
167 dom_string **result);
169 dom_string *content);
170
171#define DOM_DOCUMENT_VTABLE \
172 _dom_document_get_doctype, \
173 _dom_document_get_implementation, \
174 _dom_document_get_document_element, \
175 _dom_document_create_element, \
176 _dom_document_create_document_fragment, \
177 _dom_document_create_text_node, \
178 _dom_document_create_comment, \
179 _dom_document_create_cdata_section, \
180 _dom_document_create_processing_instruction, \
181 _dom_document_create_attribute, \
182 _dom_document_create_entity_reference, \
183 _dom_document_get_elements_by_tag_name, \
184 _dom_document_import_node, \
185 _dom_document_create_element_ns, \
186 _dom_document_create_attribute_ns, \
187 _dom_document_get_elements_by_tag_name_ns, \
188 _dom_document_get_element_by_id, \
189 _dom_document_get_input_encoding, \
190 _dom_document_get_xml_encoding, \
191 _dom_document_get_xml_standalone, \
192 _dom_document_set_xml_standalone, \
193 _dom_document_get_xml_version, \
194 _dom_document_set_xml_version, \
195 _dom_document_get_strict_error_checking, \
196 _dom_document_set_strict_error_checking, \
197 _dom_document_get_uri, \
198 _dom_document_set_uri, \
199 _dom_document_adopt_node, \
200 _dom_document_get_dom_config, \
201 _dom_document_normalize, \
202 _dom_document_rename_node, \
203 _dom_document_get_quirks_mode, \
204 _dom_document_set_quirks_mode
205
206/* End of vtable */
207
208#define DOM_NODE_VTABLE_DOCUMENT \
209 _dom_node_try_destroy, \
210 _dom_node_get_node_name, \
211 _dom_node_get_node_value, \
212 _dom_node_set_node_value, \
213 _dom_node_get_node_type, \
214 _dom_node_get_parent_node, \
215 _dom_node_get_child_nodes, \
216 _dom_node_get_first_child, \
217 _dom_node_get_last_child, \
218 _dom_node_get_previous_sibling, \
219 _dom_node_get_next_sibling, \
220 _dom_node_get_attributes, \
221 _dom_node_get_owner_document, \
222 _dom_node_insert_before, \
223 _dom_node_replace_child, \
224 _dom_node_remove_child, \
225 _dom_node_append_child, \
226 _dom_node_has_child_nodes, \
227 _dom_node_clone_node, \
228 _dom_node_normalize, \
229 _dom_node_is_supported, \
230 _dom_node_get_namespace, \
231 _dom_node_get_prefix, \
232 _dom_node_set_prefix, \
233 _dom_node_get_local_name, \
234 _dom_node_has_attributes, \
235 _dom_node_get_base, \
236 _dom_node_compare_document_position, \
237 _dom_document_get_text_content, \
238 _dom_document_set_text_content, \
239 _dom_node_is_same, \
240 _dom_node_lookup_prefix, \
241 _dom_node_is_default_namespace, \
242 _dom_node_lookup_namespace, \
243 _dom_node_is_equal, \
244 _dom_node_get_feature, \
245 _dom_node_set_user_data, \
246 _dom_node_get_user_data
247
248/* Following comes the protected vtable */
251 dom_node_internal **copy);
252
253#define DOM_DOCUMENT_PROTECT_VTABLE \
254 _dom_document_destroy, \
255 _dom_document_copy
256
257
258/*---------------------------- Helper functions ---------------------------*/
259
260/* Try to destroy the document:
261 * When the refcnt is zero and the pending list is empty, we can destroy this
262 * document. */
264
265/* Get a nodelist, creating one if necessary */
268 dom_string *tagname, dom_string *namespace,
269 dom_string *localname, dom_nodelist **list);
270/* Remove a nodelist */
272
273/* Find element with certain ID in the subtree rooted at root */
275 dom_string *id, dom_element **result);
276
277/* Set the ID attribute name of this document */
279
280#define _dom_document_get_id_name(d) (d->id_name)
281
282#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:408
void _dom_document_set_id_name(dom_document *doc, dom_string *name)
Definition document.c:1535
dom_exception _dom_document_create_element(dom_document *doc, dom_string *tag_name, dom_element **result)
Definition document.c:442
dom_exception _dom_document_set_strict_error_checking(dom_document *doc, bool strict)
Definition document.c:1015
dom_exception _dom_document_get_strict_error_checking(dom_document *doc, bool *result)
Definition document.c:999
dom_exception _dom_document_set_quirks_mode(dom_document *doc, dom_document_quirks_mode result)
Definition document.c:1552
dom_exception _dom_find_element_by_id(dom_node_internal *root, dom_string *id, dom_element **result)
Definition document.c:1375
dom_exception _dom_document_create_element_ns(dom_document *doc, dom_string *namespace, dom_string *qname, dom_element **result)
Definition document.c:714
dom_exception _dom_document_get_dom_config(dom_document *doc, struct dom_configuration **result)
Definition document.c:1147
dom_exception _dom_document_set_uri(dom_document *doc, dom_string *uri)
Definition document.c:1054
dom_exception _dom_document_rename_node(dom_document *doc, dom_node *node, dom_string *namespace, dom_string *qname, dom_node **result)
Definition document.c:1203
dom_exception _dom_document_create_cdata_section(dom_document *doc, dom_string *data, dom_cdata_section **result)
Definition document.c:550
dom_exception _dom_document_create_entity_reference(dom_document *doc, dom_string *name, dom_entity_reference **result)
Definition document.c:631
dom_exception _dom_document_get_elements_by_tag_name(dom_document *doc, dom_string *tagname, dom_nodelist **result)
Definition document.c:653
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:829
dom_exception _dom_document_get_quirks_mode(dom_document *doc, dom_document_quirks_mode *result)
Definition document.c:1545
dom_exception _dom_document_get_element_by_id(dom_document *doc, dom_string *id, dom_element **result)
Definition document.c:850
dom_exception _dom_document_create_attribute(dom_document *doc, dom_string *name, dom_attr **result)
Definition document.c:608
dom_exception _dom_document_create_text_node(dom_document *doc, dom_string *data, dom_text **result)
Definition document.c:491
dom_exception _dom_document_get_uri(dom_document *doc, dom_string **result)
Definition document.c:1035
void _dom_document_destroy(dom_node_internal *node)
Definition document.c:1241
dom_exception _dom_document_get_implementation(dom_document *doc, dom_implementation **result)
Definition document.c:387
void _dom_document_try_destroy(dom_document *doc)
Definition document.c:1521
dom_exception _dom_document_get_xml_encoding(dom_document *doc, dom_string **result)
Definition document.c:902
dom_exception _dom_document_create_comment(dom_document *doc, dom_string *data, dom_comment **result)
Definition document.c:520
dom_exception _dom_document_get_xml_standalone(dom_document *doc, bool *result)
Definition document.c:918
dom_exception _dom_document_set_text_content(dom_node_internal *node, dom_string *content)
Definition document.c:1227
dom_exception _dom_document_get_text_content(dom_node_internal *node, dom_string **result)
Definition document.c:1217
dom_exception _dom_document_create_document_fragment(dom_document *doc, dom_document_fragment **result)
Definition document.c:462
dom_exception _dom_document_get_input_encoding(dom_document *doc, dom_string **result)
Definition document.c:882
dom_exception _dom_document_get_xml_version(dom_document *doc, dom_string **result)
Definition document.c:962
void _dom_document_remove_nodelist(dom_document *doc, dom_nodelist *list)
Definition document.c:1339
dom_exception _dom_document_import_node(dom_document *doc, dom_node *node, bool deep, dom_node **result)
Definition document.c:677
dom_exception _dom_document_set_xml_version(dom_document *doc, dom_string *version)
Definition document.c:983
dom_exception _dom_document_create_attribute_ns(dom_document *doc, dom_string *namespace, dom_string *qname, dom_attr **result)
Definition document.c:779
dom_exception _dom_document_copy(dom_node_internal *old, dom_node_internal **copy)
Definition document.c:1251
dom_exception _dom_document_set_xml_standalone(dom_document *doc, bool standalone)
Definition document.c:939
dom_exception _dom_document_get_doctype(dom_document *doc, dom_document_type **result)
Definition document.c:358
dom_exception _dom_document_adopt_node(dom_document *doc, dom_node *node, dom_node **result)
Definition document.c:1086
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:1162
bool _dom_document_finalise(dom_document *doc)
Definition document.c:297
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:582
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:1281
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
uint32_t dispatching_mutation
Definition document.h:74
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