summaryrefslogtreecommitdiff
path: root/include/dom/html/html_document.h
blob: 0f23bfa1e7e549ef53e82f5afd9d726d19e6bd45 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/*
 * 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_html_document_h_
#define dom_html_document_h_

#include <dom/core/document.h>
#include <dom/core/exceptions.h>
#include <dom/functypes.h>
#include <dom/events/document_event.h>

struct dom_element;
struct dom_html_collection;
struct dom_html_element;
struct dom_nodelist;

typedef struct dom_html_document dom_html_document;

/**
 * Quirks mode flag
 */
typedef enum dom_html_document_quirks_mode {
	DOM_HTML_DOCUMENT_QUIRKS_MODE_NONE,
	DOM_HTML_DOCUMENT_QUIRKS_MODE_LIMITED,
	DOM_HTML_DOCUMENT_QUIRKS_MODE_FULL
} dom_html_document_quirks_mode;


typedef struct dom_html_document_vtable {
	struct dom_document_vtable base;

	dom_exception (*get_title)(dom_html_document *doc,
			dom_string **title);
	dom_exception (*set_title)(dom_html_document *doc,
			dom_string *title);
	dom_exception (*get_referer)(dom_html_document *doc,
			dom_string **referer);
	dom_exception (*get_domain)(dom_html_document *doc,
			dom_string **domain);
	dom_exception (*get_url)(dom_html_document *doc,
			dom_string **url);
	dom_exception (*get_body)(dom_html_document *doc,
			struct dom_html_element **body);
	dom_exception (*set_body)(dom_html_document *doc,
			struct dom_html_element *body);
	dom_exception (*get_images)(dom_html_document *doc,
			struct dom_html_collection **col);
	dom_exception (*get_applets)(dom_html_document *doc,
			struct dom_html_collection **col);
	dom_exception (*get_links)(dom_html_document *doc,
			struct dom_html_collection **col);
	dom_exception (*get_forms)(dom_html_document *doc,
			struct dom_html_collection **col);
	dom_exception (*get_anchors)(dom_html_document *doc,
			struct dom_html_collection **col);
	dom_exception (*get_cookie)(dom_html_document *doc,
			dom_string **cookie);
	dom_exception (*set_cookie)(dom_html_document *doc,
			dom_string *cookie);

	dom_exception (*open)(dom_html_document *doc);
	dom_exception (*close)(dom_html_document *doc);
	dom_exception (*write)(dom_html_document *doc,
			dom_string *text);
	dom_exception (*writeln)(dom_html_document *doc,
			dom_string *text);
	dom_exception (*get_elements_by_name)(dom_html_document *doc,
			dom_string *name, struct dom_nodelist **list);
	dom_exception (*get_quirks_mode)(dom_html_document *doc,
					 dom_html_document_quirks_mode *result);
	dom_exception (*set_quirks_mode)(dom_html_document *doc,
					 dom_html_document_quirks_mode quirks);
} dom_html_document_vtable;

static inline dom_exception dom_html_document_get_title(
		dom_html_document *doc, dom_string **title)
{
	return ((dom_html_document_vtable *) ((dom_node *) doc)->vtable)->
		get_title(doc, title);
}
#define dom_html_document_get_title(d, t) \
		dom_html_document_get_title((dom_html_document *) (d), \
				(dom_string **) (t))

static inline dom_exception dom_html_document_set_title(dom_html_document *doc,
		dom_string *title)
{
	return ((dom_html_document_vtable *) ((dom_node *) doc)->vtable)->
		set_title(doc, title);
}
#define dom_html_document_set_title(d, t) \
		dom_html_document_set_title((dom_html_document *) (d), \
				(dom_string **) (t))

static inline dom_exception dom_html_document_get_referer(dom_html_document *doc,
		dom_string **referer)
{
	return ((dom_html_document_vtable *) ((dom_node *) doc)->vtable)->
		get_referer(doc, referer);
}
#define dom_html_document_get_referer(d, r) \
		dom_html_document_get_referer((dom_html_document *) (d), \
				(dom_string **) (r))

static inline dom_exception dom_html_document_get_domain(dom_html_document *doc,
		dom_string **domain)
{
	return ((dom_html_document_vtable *) ((dom_node *) doc)->vtable)->
		get_domain(doc, domain);
}
#define dom_html_document_get_domain(d, t) \
		dom_html_document_get_domain((dom_html_document *) (d), \
				(dom_string **) (t))

static inline dom_exception dom_html_document_get_url(dom_html_document *doc,
		dom_string **url)
{
	return ((dom_html_document_vtable *) ((dom_node *) doc)->vtable)->
		get_url(doc, url);
}
#define dom_html_document_get_url(d, u) \
		dom_html_document_get_url((dom_html_document *) (d), \
				(dom_string **) (u))

static inline dom_exception dom_html_document_get_body(dom_html_document *doc,
		struct dom_html_element **body)
{
	return ((dom_html_document_vtable *) ((dom_node *) doc)->vtable)->
		get_body(doc, body);
}
#define dom_html_document_get_body(d, b) \
		dom_html_document_get_title((dom_html_document *) (d), \
				(struct dom_html_element **) (b))

static inline dom_exception dom_html_document_set_body(dom_html_document *doc,
		struct dom_html_element *body)
{
	return ((dom_html_document_vtable *) ((dom_node *) doc)->vtable)->
		set_body(doc, body);
}
#define dom_html_document_set_body(d, b) \
		dom_html_document_set_body((dom_html_document *) (d), \
				(struct dom_html_element **) (b))

static inline dom_exception dom_html_document_get_images(dom_html_document *doc,
		struct dom_html_collection **col)
{
	return ((dom_html_document_vtable *) ((dom_node *) doc)->vtable)->
		get_images(doc, col);
}
#define dom_html_document_get_images(d, c) \
		dom_html_document_get_images((dom_html_document *) (d), \
				(struct dom_html_collection **) (c))

static inline dom_exception dom_html_document_get_applets(dom_html_document *doc,
		struct dom_html_collection **col)
{
	return ((dom_html_document_vtable *) ((dom_node *) doc)->vtable)->
		get_applets(doc, col);
}
#define dom_html_document_get_applets(d, c) \
		dom_html_document_get_applets((dom_html_document *) (d), \
				(struct dom_html_collection **) (c))

static inline dom_exception dom_html_document_get_links(dom_html_document *doc,
		struct dom_html_collection **col)
{
	return ((dom_html_document_vtable *) ((dom_node *) doc)->vtable)->
		get_links(doc, col);
}
#define dom_html_document_get_links(d, c) \
		dom_html_document_get_links((dom_html_document *) (d), \
				(struct dom_html_collection **) (c))

static inline dom_exception dom_html_document_get_forms(dom_html_document *doc,
		struct dom_html_collection **col)
{
	return ((dom_html_document_vtable *) ((dom_node *) doc)->vtable)->
		get_forms(doc, col);
}
#define dom_html_document_get_forms(d, c) \
		dom_html_document_get_forms((dom_html_document *) (d), \
				(struct dom_html_collection **) (c))

static inline dom_exception dom_html_document_get_anchors(dom_html_document *doc,
		struct dom_html_collection **col)
{
	return ((dom_html_document_vtable *) ((dom_node *) doc)->vtable)->
		get_anchors(doc, col);
}
#define dom_html_document_get_anchors(d, c) \
		dom_html_document_get_title((dom_html_document *) (d), \
				(struct dom_html_collection **) (c))

static inline dom_exception dom_html_document_get_cookie(dom_html_document *doc,
		dom_string **cookie)
{
	return ((dom_html_document_vtable *) ((dom_node *) doc)->vtable)->
		get_cookie(doc, cookie);
}
#define dom_html_document_get_cookie(d, c) \
		dom_html_document_get_title((dom_html_document *) (d), \
				(dom_string **) (c))

static inline dom_exception dom_html_document_set_cookie(dom_html_document *doc,
		dom_string *cookie)
{
	return ((dom_html_document_vtable *) ((dom_node *) doc)->vtable)->
		set_cookie(doc, cookie);
}
#define dom_html_document_set_cookie(d, c) \
		dom_html_document_set_cookie((dom_html_document *) (d), \
				(dom_string **) (c))


static inline dom_exception dom_html_document_open(dom_html_document *doc)
{
	return ((dom_html_document_vtable *) ((dom_node *) doc)->vtable)->
		open(doc);
}
#define dom_html_document_open(d) \
		dom_html_document_open((dom_html_document *) (d))

static inline dom_exception dom_html_document_close(dom_html_document *doc)
{
	return ((dom_html_document_vtable *) ((dom_node *) doc)->vtable)->
		close(doc);
}
#define dom_html_document_close(d) \
		dom_html_document_close((dom_html_document *) (d))


static inline dom_exception dom_html_document_write(dom_html_document *doc,
		dom_string *text)
{
	return ((dom_html_document_vtable *) ((dom_node *) doc)->vtable)->
		write(doc, text);
}
#define dom_html_document_write(d, t) \
		dom_html_document_write((dom_html_document *) (d), \
			(dom_string *) (t))

static inline dom_exception dom_html_document_writeln(dom_html_document *doc,
		dom_string *text)
{
	return ((dom_html_document_vtable *) ((dom_node *) doc)->vtable)->
		writeln(doc, text);
}
#define dom_html_document_writeln(d, t) \
		dom_html_document_writeln((dom_html_document *) (d), \
			(dom_string *) (t))

static inline dom_exception dom_html_document_get_elements_by_name(dom_html_document *doc,
		dom_string *name, struct dom_nodelist **list)
{
	return ((dom_html_document_vtable *) ((dom_node *) doc)->vtable)->
		get_elements_by_name(doc, name, list);
}
#define dom_html_document_get_elements_by_name(d, n, l) \
		dom_html_document_get_element_by_name((dom_html_document *) (d), \
			(dom_string *) (n), (struct dom_nodelist **) (l))

static inline dom_exception dom_html_document_get_quirks_mode(
	dom_html_document *doc, dom_html_document_quirks_mode *result)
{
	return ((dom_html_document_vtable *) ((dom_node *) doc)->vtable)->
		get_quirks_mode(doc, result);
}
#define dom_html_document_get_quirks_mode(d, r) \
	dom_html_document_get_quirks_mode((dom_html_document *) (d), (r))

static inline dom_exception dom_html_document_set_quirks_mode(
	dom_html_document *doc, dom_html_document_quirks_mode quirks)
{
	return ((dom_html_document_vtable *) ((dom_node *) doc)->vtable)->
		set_quirks_mode(doc, quirks);
}
#define dom_html_document_set_quirks_mode(d, q) \
	dom_html_document_set_quirks_mode((dom_html_document *) (d), (q))

#endif