summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2010-08-30 13:06:19 (GMT)
committer John Mark Bell <jmb@netsurf-browser.org>2010-08-30 13:06:19 (GMT)
commitb657c277f517f4ab0a4da21e4f8c4cb6f8f53013 (patch)
tree4ce25caee01c0a2a2ebbe052999b5eb8a2fbe2e3
parent229af12d7ab2c071a6888eb8ffc49bb0bbeb9ddd (diff)
downloadlibdom-b657c277f517f4ab0a4da21e4f8c4cb6f8f53013.tar.gz
libdom-b657c277f517f4ab0a4da21e4f8c4cb6f8f53013.tar.bz2
Merge branches/struggleyb/libdom-html to trunk.
A few additional fixes to reduce the number of regressions to single figures. svn path=/trunk/dom/; revision=10724
-rw-r--r--Makefile2
-rw-r--r--include/dom/bootstrap/implpriv.h17
-rw-r--r--include/dom/core/attr.h46
-rw-r--r--include/dom/core/exceptions.h3
-rw-r--r--include/dom/events/document_event.h67
-rw-r--r--include/dom/html/html_anchor_element.h7
-rw-r--r--include/dom/html/html_applet_element.h7
-rw-r--r--include/dom/html/html_area_element.h7
-rw-r--r--include/dom/html/html_base_element.h14
-rw-r--r--include/dom/html/html_basefont_element.h7
-rw-r--r--include/dom/html/html_body_element.h14
-rw-r--r--include/dom/html/html_br_element.h7
-rw-r--r--include/dom/html/html_button_element.h7
-rw-r--r--include/dom/html/html_collection.h29
-rw-r--r--include/dom/html/html_directory_element.h7
-rw-r--r--include/dom/html/html_div_element.h7
-rw-r--r--include/dom/html/html_dlist_element.h7
-rw-r--r--include/dom/html/html_document.h97
-rw-r--r--include/dom/html/html_element.h26
-rw-r--r--include/dom/html/html_fieldset_element.h7
-rw-r--r--include/dom/html/html_font_element.h7
-rw-r--r--include/dom/html/html_form_element.h25
-rw-r--r--include/dom/html/html_frame_element.h7
-rw-r--r--include/dom/html/html_frameset_element.h7
-rw-r--r--include/dom/html/html_head_element.h14
-rw-r--r--include/dom/html/html_heading_element.h7
-rw-r--r--include/dom/html/html_hr_element.h7
-rw-r--r--include/dom/html/html_html_element.h14
-rw-r--r--include/dom/html/html_iframe_element.h7
-rw-r--r--include/dom/html/html_image_element.h7
-rw-r--r--include/dom/html/html_input_element.h7
-rw-r--r--include/dom/html/html_isindex_element.h26
-rw-r--r--include/dom/html/html_label_element.h7
-rw-r--r--include/dom/html/html_legend_element.h7
-rw-r--r--include/dom/html/html_li_element.h7
-rw-r--r--include/dom/html/html_link_element.h23
-rw-r--r--include/dom/html/html_map_element.h7
-rw-r--r--include/dom/html/html_menu_element.h7
-rw-r--r--include/dom/html/html_meta_element.h14
-rw-r--r--include/dom/html/html_mod_element.h7
-rw-r--r--include/dom/html/html_object_element.h7
-rw-r--r--include/dom/html/html_olist_element.h7
-rw-r--r--include/dom/html/html_optgroup_element.h7
-rw-r--r--include/dom/html/html_option_element.h7
-rw-r--r--include/dom/html/html_options_collection.h33
-rw-r--r--include/dom/html/html_paragraph_element.h7
-rw-r--r--include/dom/html/html_param_element.h7
-rw-r--r--include/dom/html/html_pre_element.h7
-rw-r--r--include/dom/html/html_quote_element.h7
-rw-r--r--include/dom/html/html_script_element.h7
-rw-r--r--include/dom/html/html_select_element.h55
-rw-r--r--include/dom/html/html_style_element.h23
-rw-r--r--include/dom/html/html_table_element.h7
-rw-r--r--include/dom/html/html_tablecaption_element.h7
-rw-r--r--include/dom/html/html_tablecell_element.h7
-rw-r--r--include/dom/html/html_tablecol_element.h7
-rw-r--r--include/dom/html/html_tablerow_element.h7
-rw-r--r--include/dom/html/html_tablesection_element.h7
-rw-r--r--include/dom/html/html_textarea_element.h7
-rw-r--r--include/dom/html/html_title_element.h24
-rw-r--r--include/dom/html/html_ulist_element.h7
-rw-r--r--src/bootstrap/implementation.c5
-rw-r--r--src/core/attr.c266
-rw-r--r--src/core/attr.h5
-rw-r--r--src/core/document.c5
-rw-r--r--src/core/document.h29
-rw-r--r--src/core/document_type.c2
-rw-r--r--src/core/document_type.h6
-rw-r--r--src/core/element.c55
-rw-r--r--src/core/element.h42
-rw-r--r--src/core/node.c29
-rw-r--r--src/core/node.h2
-rw-r--r--src/events/event_target.c107
-rw-r--r--src/events/event_target.h4
-rw-r--r--src/html/Makefile25
-rw-r--r--src/html/html_anchor_element.c7
-rw-r--r--src/html/html_anchor_element.h7
-rw-r--r--src/html/html_applet_element.c7
-rw-r--r--src/html/html_applet_element.h7
-rw-r--r--src/html/html_area_element.c7
-rw-r--r--src/html/html_area_element.h7
-rw-r--r--src/html/html_base_element.c137
-rw-r--r--src/html/html_base_element.h55
-rw-r--r--src/html/html_basefont_element.c7
-rw-r--r--src/html/html_basefont_element.h7
-rw-r--r--src/html/html_body_element.c137
-rw-r--r--src/html/html_body_element.h55
-rw-r--r--src/html/html_br_element.c7
-rw-r--r--src/html/html_br_element.h7
-rw-r--r--src/html/html_button_element.c7
-rw-r--r--src/html/html_button_element.h7
-rw-r--r--src/html/html_collection.c300
-rw-r--r--src/html/html_collection.h50
-rw-r--r--src/html/html_directory_element.c7
-rw-r--r--src/html/html_directory_element.h7
-rw-r--r--src/html/html_div_element.c7
-rw-r--r--src/html/html_div_element.h7
-rw-r--r--src/html/html_dlist_element.c7
-rw-r--r--src/html/html_dlist_element.h7
-rw-r--r--src/html/html_document.c118
-rw-r--r--src/html/html_document.h47
-rw-r--r--src/html/html_element.c207
-rw-r--r--src/html/html_element.h58
-rw-r--r--src/html/html_fieldset_element.c7
-rw-r--r--src/html/html_fieldset_element.h7
-rw-r--r--src/html/html_font_element.c7
-rw-r--r--src/html/html_font_element.h7
-rw-r--r--src/html/html_form_element.c256
-rw-r--r--src/html/html_form_element.h59
-rw-r--r--src/html/html_frame_element.c7
-rw-r--r--src/html/html_frame_element.h7
-rw-r--r--src/html/html_frameset_element.c7
-rw-r--r--src/html/html_frameset_element.h7
-rw-r--r--src/html/html_head_element.c137
-rw-r--r--src/html/html_head_element.h55
-rw-r--r--src/html/html_heading_element.c7
-rw-r--r--src/html/html_heading_element.h7
-rw-r--r--src/html/html_hr_element.c7
-rw-r--r--src/html/html_hr_element.h7
-rw-r--r--src/html/html_html_element.c137
-rw-r--r--src/html/html_html_element.h55
-rw-r--r--src/html/html_iframe_element.c7
-rw-r--r--src/html/html_iframe_element.h7
-rw-r--r--src/html/html_image_element.c7
-rw-r--r--src/html/html_image_element.h7
-rw-r--r--src/html/html_input_element.c7
-rw-r--r--src/html/html_input_element.h7
-rw-r--r--src/html/html_isindex_element.c162
-rw-r--r--src/html/html_isindex_element.h57
-rw-r--r--src/html/html_label_element.c7
-rw-r--r--src/html/html_label_element.h7
-rw-r--r--src/html/html_legend_element.c7
-rw-r--r--src/html/html_legend_element.h7
-rw-r--r--src/html/html_li_element.c7
-rw-r--r--src/html/html_li_element.h7
-rw-r--r--src/html/html_link_element.c171
-rw-r--r--src/html/html_link_element.h55
-rw-r--r--src/html/html_map_element.c7
-rw-r--r--src/html/html_map_element.h7
-rw-r--r--src/html/html_menu_element.c7
-rw-r--r--src/html/html_menu_element.h7
-rw-r--r--src/html/html_meta_element.c137
-rw-r--r--src/html/html_meta_element.h55
-rw-r--r--src/html/html_mod_element.c7
-rw-r--r--src/html/html_mod_element.h7
-rw-r--r--src/html/html_object_element.c7
-rw-r--r--src/html/html_object_element.h7
-rw-r--r--src/html/html_olist_element.c7
-rw-r--r--src/html/html_olist_element.h7
-rw-r--r--src/html/html_optgroup_element.c7
-rw-r--r--src/html/html_optgroup_element.h7
-rw-r--r--src/html/html_option_element.c7
-rw-r--r--src/html/html_option_element.h7
-rw-r--r--src/html/html_options_collection.c177
-rw-r--r--src/html/html_options_collection.h42
-rw-r--r--src/html/html_paragraph_element.c7
-rw-r--r--src/html/html_paragraph_element.h7
-rw-r--r--src/html/html_param_element.c7
-rw-r--r--src/html/html_param_element.h7
-rw-r--r--src/html/html_pre_element.c7
-rw-r--r--src/html/html_pre_element.h7
-rw-r--r--src/html/html_quote_element.c7
-rw-r--r--src/html/html_quote_element.h7
-rw-r--r--src/html/html_script_element.c7
-rw-r--r--src/html/html_script_element.h7
-rw-r--r--src/html/html_select_element.c344
-rw-r--r--src/html/html_select_element.h60
-rw-r--r--src/html/html_style_element.c168
-rw-r--r--src/html/html_style_element.h55
-rw-r--r--src/html/html_table_element.c7
-rw-r--r--src/html/html_table_element.h7
-rw-r--r--src/html/html_tablecaption_element.c7
-rw-r--r--src/html/html_tablecaption_element.h7
-rw-r--r--src/html/html_tablecell_element.c7
-rw-r--r--src/html/html_tablecell_element.h7
-rw-r--r--src/html/html_tablecol_element.c7
-rw-r--r--src/html/html_tablecol_element.h7
-rw-r--r--src/html/html_tablerow_element.c7
-rw-r--r--src/html/html_tablerow_element.h7
-rw-r--r--src/html/html_tablesection_element.c7
-rw-r--r--src/html/html_tablesection_element.h7
-rw-r--r--src/html/html_textarea_element.c7
-rw-r--r--src/html/html_textarea_element.h7
-rw-r--r--src/html/html_title_element.c187
-rw-r--r--src/html/html_title_element.h55
-rw-r--r--src/html/html_ulist_element.c7
-rw-r--r--src/html/html_ulist_element.h7
187 files changed, 5527 insertions, 70 deletions
diff --git a/Makefile b/Makefile
index 7d9a40b..ef38201 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ WARNFLAGS := -Wall -W -Wundef -Wpointer-arith -Wcast-align \
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \
-Wmissing-declarations -Wnested-externs -Werror -pedantic
CFLAGS := -std=c99 -D_BSD_SOURCE -I$(CURDIR)/include/ \
- -I$(CURDIR)/src $(WARNFLAGS) $(CFLAGS)
+ -I$(CURDIR)/src -I$(CURDIR)/binding $(WARNFLAGS) $(CFLAGS)
# Parserutils & wapcaplet
ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
diff --git a/include/dom/bootstrap/implpriv.h b/include/dom/bootstrap/implpriv.h
index 93ce34d..89d3f96 100644
--- a/include/dom/bootstrap/implpriv.h
+++ b/include/dom/bootstrap/implpriv.h
@@ -243,21 +243,4 @@ struct dom_implementation_source {
/* Register a source with the DOM library */
dom_exception dom_register_source(struct dom_implementation_source *source);
-/* Create a DOM document */
-dom_exception dom_document_create(struct dom_implementation *impl,
- dom_alloc alloc, void *pw,
- dom_events_default_action_fetcher daf,
- struct dom_document **doc);
-
-/* Set a document's buffer */
-void dom_document_set_buffer(struct dom_document *doc, uint8_t *buffer,
- size_t buffer_len);
-
-/* Create a DOM document type */
-dom_exception dom_document_type_create(struct dom_string *qname,
- struct dom_string *public_id,
- struct dom_string *system_id,
- dom_alloc alloc, void *pw,
- struct dom_document_type **doctype);
-
#endif
diff --git a/include/dom/core/attr.h b/include/dom/core/attr.h
index 7ac3956..f5105f7 100644
--- a/include/dom/core/attr.h
+++ b/include/dom/core/attr.h
@@ -21,6 +21,17 @@ struct dom_string;
typedef struct dom_attr dom_attr;
+/**
+ * The attribute type
+ */
+typedef enum {
+ DOM_ATTR_UNSET = 0,
+ DOM_ATTR_STRING,
+ DOM_ATTR_BOOL,
+ DOM_ATTR_SHORT,
+ DOM_ATTR_INTEGER
+} dom_attr_type;
+
/* DOM Attr vtable */
typedef struct dom_attr_vtable {
struct dom_node_vtable base;
@@ -102,4 +113,39 @@ static inline dom_exception dom_attr_is_id(struct dom_attr *attr, bool *result)
#define dom_attr_is_id(a, r) dom_attr_is_id((struct dom_attr *) (a), \
(bool *) (r))
+/*-----------------------------------------------------------------------*/
+/**
+ * Following are our implementation specific APIs.
+ *
+ * These APIs are defined for the purpose that there are some attributes in
+ * HTML and other DOM module whose type is not DOMString, but unsigned long or
+ * boolean, for those types of attributes, clients should call one of the
+ * following APIs to set it.
+ *
+ * When an Attr node is created, its type is unset and it can be turned into
+ * any of the four types. Once the type is fixed by calling any of the four
+ * APIs:
+ * dom_attr_set_value
+ * dom_attr_set_integer
+ * dom_attr_set_short
+ * dom_attr_set_bool
+ * it can't be modified in future.
+ *
+ * For integer/short/bool type of attributes, we provide no string
+ * repensentation of them, so when you call dom_attr_get_value on these
+ * three type of attribute nodes, you will always get a empty dom_string.
+ * If you want to do something with Attr node, you must know its type
+ * firstly by calling dom_attr_get_type before you decide to call other
+ * dom_attr_get_* functions.
+ */
+dom_attr_type dom_attr_get_type(dom_attr *a);
+dom_exception dom_attr_get_integer(dom_attr *a, unsigned long *value);
+dom_exception dom_attr_set_integer(dom_attr *a, unsigned long value);
+dom_exception dom_attr_get_short(dom_attr *a, unsigned short *value);
+dom_exception dom_attr_set_short(dom_attr *a, unsigned short value);
+dom_exception dom_attr_get_bool(dom_attr *a, bool *value);
+dom_exception dom_attr_set_bool(dom_attr *a, bool value);
+/* Make a attribute node readonly */
+void dom_attr_mark_readonly(dom_attr *a);
+
#endif
diff --git a/include/dom/core/exceptions.h b/include/dom/core/exceptions.h
index e128016..04c7f18 100644
--- a/include/dom/core/exceptions.h
+++ b/include/dom/core/exceptions.h
@@ -44,7 +44,8 @@ typedef enum {
DOM_UNSPECIFIED_EVENT_TYPE_ERR = DOM_EXCEPTION_CLASS_EVENT + 0,
DOM_DISPATCH_REQUEST_ERR = DOM_EXCEPTION_CLASS_EVENT + 1,
- DOM_NO_MEM_ERR = DOM_EXCEPTION_CLASS_INTERNAL + 0
+ DOM_NO_MEM_ERR = DOM_EXCEPTION_CLASS_INTERNAL + 0,
+ DOM_ATTR_WRONG_TYPE_ERR = DOM_EXCEPTION_CLASS_INTERNAL + 1
/* our own internal error */
} dom_exception;
diff --git a/include/dom/events/document_event.h b/include/dom/events/document_event.h
index 3c1ea1b..be0646f 100644
--- a/include/dom/events/document_event.h
+++ b/include/dom/events/document_event.h
@@ -8,6 +8,8 @@
#ifndef dom_events_document_event_h_
#define dom_events_document_event_h_
+#include <stdbool.h>
+
#include <dom/core/exceptions.h>
struct dom_string;
@@ -18,15 +20,68 @@ struct lwc_string_s;
typedef struct dom_document dom_document_event;
/**
+ * The callback function which is used to process the default action of any
+ * event.
+ *
+ * As ::dom_default_action_phase defines, we have three points in our
+ * implementation where these kinds of callbacks get invoked.
+ *
+ * When the implementation start to dispatch certain event, it firstly invoke
+ * the following callback, which should process the event before the normal
+ * event flow.
+ *
+ * Take a MousePressed event on a check box object as example:
+ * 1. The 'pressed' event is generated by OS and catched by our UI code;
+ * 2. The UI code dispatch the event to DOM;
+ * 3. DOM trys to dispatch the event as what the spec said;
+ * 4. Before the real event flow happens, DOM get the
+ * dom_default_action_callback function from the
+ * dom_events_default_action_fetcher with param
+ * DOM_DEFAULT_ACTION_STARTED, and then call it;
+ * 5. The callback function invoke some System-denpendent API to make the
+ * checkbox checked and then return;
+ * 6. Normal event flow goes on.
+ * 7. When the implementation reach the end of the event flow, it check whether
+ * the event's default action is prevented, if it is, then go to step 8,
+ * else go to step 9.
+ * 8. The event's default action get prevented, DOM get the
+ * dom_default_action_callback function from the
+ * dom_events_default_action_fetcher with param
+ * DOM_DEFAULT_ACTION_PREVENTED, and then call it.
+ * 8. The event's default action does not get prevented, DOM get the
+ * dom_default_action_callback function from the
+ * dom_events_default_action_fetcher with param
+ * DOM_DEFAULT_ACTION_END, and then call it.
+ *
+ * @note: the point here is that we want the UI related stuff to be done
+ * within the default action code. The DOM only take care of the content tree
+ * and the event flow itself.
+ */
+typedef void (*dom_default_action_callback)(struct dom_event *evt, void *pw);
+
+/**
+ * The default action phase
+ *
+ * @note: we define the following three values to fetch three different types
+ * of dom_default_action_callback function and their private data.
+ */
+typedef enum {
+ DOM_DEFAULT_ACTION_STARTED = 0,
+ DOM_DEFAULT_ACTION_PREVENTED,
+ DOM_DEFAULT_ACTION_END
+} dom_default_action_phase;
+
+/**
* The default action fetcher
*
- * @note: When the implementation reach the end of the event flow, it will call
- * this function to get the default action handler. If it does not return a
- * NULL, the returned dom_event_listener will be invoked as the event is not
- * canceled.
+ * \param type The type of the event
+ * \param phase The phase of the default action callback
+ * \param pw The return privat data of the callback function
+ * \return a callback function, NULL if there is none.
*/
-typedef struct dom_event_listener *(*dom_events_default_action_fetcher)
- (struct lwc_string_s *name, struct lwc_string_s *type);
+typedef dom_default_action_callback (*dom_events_default_action_fetcher)
+ (struct lwc_string_s *type, dom_default_action_phase phase,
+ void **pw);
dom_exception _dom_document_event_create_event(dom_document_event *de,
struct dom_string *type, struct dom_event **evt);
diff --git a/include/dom/html/html_anchor_element.h b/include/dom/html/html_anchor_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_anchor_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_applet_element.h b/include/dom/html/html_applet_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_applet_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_area_element.h b/include/dom/html/html_area_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_area_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_base_element.h b/include/dom/html/html_base_element.h
new file mode 100644
index 0000000..5ff28ee
--- a/dev/null
+++ b/include/dom/html/html_base_element.h
@@ -0,0 +1,14 @@
+/*
+ * 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.com>
+ */
+
+#ifndef dom_html_base_element_h_
+#define dom_html_base_element_h_
+
+typedef struct dom_html_base_element dom_html_base_element;
+
+#endif
+
diff --git a/include/dom/html/html_basefont_element.h b/include/dom/html/html_basefont_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_basefont_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_body_element.h b/include/dom/html/html_body_element.h
new file mode 100644
index 0000000..4df4ead
--- a/dev/null
+++ b/include/dom/html/html_body_element.h
@@ -0,0 +1,14 @@
+/*
+ * 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.com>
+ */
+
+#ifndef dom_html_body_element_h_
+#define dom_html_body_element_h_
+
+typedef struct dom_html_body_element dom_html_body_element;
+
+#endif
+
diff --git a/include/dom/html/html_br_element.h b/include/dom/html/html_br_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_br_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_button_element.h b/include/dom/html/html_button_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_button_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_collection.h b/include/dom/html/html_collection.h
new file mode 100644
index 0000000..09cf6ed
--- a/dev/null
+++ b/include/dom/html/html_collection.h
@@ -0,0 +1,29 @@
+/*
+ * 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_collection_h_
+#define dom_html_collection_h_
+
+#include <dom/core/exceptions.h>
+
+struct dom_node;
+struct dom_string;
+
+typedef struct dom_html_collection dom_html_collection;
+
+dom_exception dom_html_collection_get_length(dom_html_collection *col,
+ unsigned long *len);
+dom_exception dom_html_collection_item(dom_html_collection *col,
+ unsigned long index, struct dom_node **node);
+dom_exception dom_html_collection_named_item(dom_html_collection *col,
+ struct dom_string *name, struct dom_node **node);
+
+void dom_html_collection_ref(dom_html_collection *col);
+void dom_html_collection_unref(dom_html_collection *col);
+
+#endif
+
diff --git a/include/dom/html/html_directory_element.h b/include/dom/html/html_directory_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_directory_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_div_element.h b/include/dom/html/html_div_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_div_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_dlist_element.h b/include/dom/html/html_dlist_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_dlist_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_document.h b/include/dom/html/html_document.h
new file mode 100644
index 0000000..00a355e
--- a/dev/null
+++ b/include/dom/html/html_document.h
@@ -0,0 +1,97 @@
+/*
+ * 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/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;
+
+typedef enum {
+ DOM_HTML_PARSER = 0,
+ DOM_XML_PARSER = 1
+} dom_parser_type;
+
+/**
+ * Callbacks for UI related function calls
+ */
+struct dom_ui_handler {
+ dom_exception (*element_focus)(struct dom_element *element);
+ /* Callback for a focus DOM call */
+ dom_exception (*element_select)(struct dom_element *element);
+ /* Callback for a select DOM call */
+ dom_exception (*element_blur)(struct dom_element *element);
+ /* Callback for a blur DOM call */
+ dom_exception (*element_enable)(struct dom_element *element,
+ bool enable);
+ /* Callback for enable/disable an element */
+};
+typedef struct dom_ui_handler dom_ui_handler;
+
+/* Create a HTMLDocument */
+dom_exception dom_html_document_create(dom_alloc alloc, void *pw, dom_msg msg,
+ void *msg_pw,
+ dom_events_default_action_fetcher daf, dom_ui_handler ui,
+ dom_parser_type pt, dom_html_document **doc);
+
+/* Parse a data chunk into the HTMLDocument */
+dom_exception dom_html_document_write_data(uint8_t *data, size_t len);
+
+/* Notify the HTMLDocument that it is completed */
+dom_exception dom_html_document_complete(void);
+
+/*-----------------------------------------------------------------------*/
+/* The DOM spec public API */
+
+dom_exception dom_html_document_get_title(dom_html_document *doc,
+ struct dom_string **title);
+dom_exception dom_html_document_set_title(dom_html_document *doc,
+ struct dom_string *title);
+dom_exception dom_html_document_get_referer(dom_html_document *doc,
+ struct dom_string **referer);
+dom_exception dom_html_document_get_domain(dom_html_document *doc,
+ struct dom_string **domain);
+dom_exception dom_html_document_get_url(dom_html_document *doc,
+ struct dom_string **url);
+dom_exception dom_html_document_get_body(dom_html_document *doc,
+ struct dom_html_element **body);
+dom_exception dom_html_document_set_body(dom_html_document *doc,
+ struct dom_html_element *body);
+dom_exception dom_html_document_get_images(dom_html_document *doc,
+ struct dom_html_collection **col);
+dom_exception dom_html_document_get_applets(dom_html_document *doc,
+ struct dom_html_collection **col);
+dom_exception dom_html_document_get_links(dom_html_document *doc,
+ struct dom_html_collection **col);
+dom_exception dom_html_document_get_forms(dom_html_document *doc,
+ struct dom_html_collection **col);
+dom_exception dom_html_document_get_anchors(dom_html_document *doc,
+ struct dom_html_collection **col);
+dom_exception dom_html_document_get_cookie(dom_html_document *doc,
+ struct dom_string **cookie);
+dom_exception dom_html_document_set_cookie(dom_html_document *doc,
+ struct dom_string *cookie);
+
+dom_exception dom_html_document_open(dom_html_document *doc);
+dom_exception dom_html_document_close(dom_html_document *doc);
+dom_exception dom_html_document_write(dom_html_document *doc,
+ struct dom_string *text);
+dom_exception dom_html_document_writeln(dom_html_document *doc,
+ struct dom_string *text);
+dom_exception dom_html_document_get_elements_by_name(dom_html_document *doc,
+ struct dom_string *name, struct dom_nodelist **list);
+
+#endif
+
diff --git a/include/dom/html/html_element.h b/include/dom/html/html_element.h
new file mode 100644
index 0000000..8c41664
--- a/dev/null
+++ b/include/dom/html/html_element.h
@@ -0,0 +1,26 @@
+/*
+ * 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_element_h_
+#define dom_html_element_h_
+
+typedef struct dom_html_element dom_html_element;
+
+/**
+ * Note: DOM HTML spec is used to provide a more convenient way to
+ * access Element's attribute through property. But, for implementation like
+ * C, such propery provide no more convenience than Element.get(set)Attribute
+ * function, so we ignore all the propety whose type is DOMString in this
+ * implementation, clients can always access these property through
+ * get(set)Attribute methods.
+ *
+ * For the readonly property, an readonly Attr node should be created, so once
+ * these Attr nodes are created, they can not be changed any more.
+ */
+
+#endif
+
diff --git a/include/dom/html/html_fieldset_element.h b/include/dom/html/html_fieldset_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_fieldset_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_font_element.h b/include/dom/html/html_font_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_font_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_form_element.h b/include/dom/html/html_form_element.h
new file mode 100644
index 0000000..230846c
--- a/dev/null
+++ b/include/dom/html/html_form_element.h
@@ -0,0 +1,25 @@
+/*
+ * 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.com>
+ */
+
+#ifndef dom_html_form_element_h_
+#define dom_html_form_element_h_
+
+#include <dom/core/exceptions.h>
+
+struct dom_html_collection;
+
+typedef struct dom_html_form_element dom_html_form_element;
+
+dom_exception dom_html_form_element_get_elements(dom_html_form_element *ele,
+ struct dom_html_collection **col);
+dom_exception dom_html_form_element_get_length(dom_html_form_element *ele,
+ unsigned long *len);
+dom_exception dom_html_form_element_submit(dom_html_form_element *ele);
+dom_exception dom_html_form_element_reset(dom_html_form_element *ele);
+
+#endif
+
diff --git a/include/dom/html/html_frame_element.h b/include/dom/html/html_frame_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_frame_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_frameset_element.h b/include/dom/html/html_frameset_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_frameset_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_head_element.h b/include/dom/html/html_head_element.h
new file mode 100644
index 0000000..e00fc19
--- a/dev/null
+++ b/include/dom/html/html_head_element.h
@@ -0,0 +1,14 @@
+/*
+ * 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.com>
+ */
+
+#ifndef dom_html_head_element_h_
+#define dom_html_head_element_h_
+
+typedef struct dom_html_head_element dom_html_head_element;
+
+#endif
+
diff --git a/include/dom/html/html_heading_element.h b/include/dom/html/html_heading_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_heading_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_hr_element.h b/include/dom/html/html_hr_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_hr_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_html_element.h b/include/dom/html/html_html_element.h
new file mode 100644
index 0000000..80ef6af
--- a/dev/null
+++ b/include/dom/html/html_html_element.h
@@ -0,0 +1,14 @@
+/*
+ * 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.com>
+ */
+
+#ifndef dom_html_html_element_h_
+#define dom_html_html_element_h_
+
+typedef struct dom_html_html_element dom_html_html_element;
+
+#endif
+
diff --git a/include/dom/html/html_iframe_element.h b/include/dom/html/html_iframe_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_iframe_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_image_element.h b/include/dom/html/html_image_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_image_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_input_element.h b/include/dom/html/html_input_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_input_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_isindex_element.h b/include/dom/html/html_isindex_element.h
new file mode 100644
index 0000000..4961ccc
--- a/dev/null
+++ b/include/dom/html/html_isindex_element.h
@@ -0,0 +1,26 @@
+/*
+ * 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.com>
+ */
+
+#ifndef dom_html_isindex_element_h_
+#define dom_html_isindex_element_h_
+
+#include <dom/core/exceptions.h>
+
+struct dom_html_form_element;
+
+/**
+ * Note: the HTML 4.01 spec said: this element is deprecated, use
+ * <INPUT> element instead.
+ */
+
+typedef struct dom_html_isindex_element dom_html_isindex_element;
+
+dom_exception dom_html_isindex_element_get_form(dom_html_isindex_element *ele,
+ struct dom_html_form_element **form);
+
+#endif
+
diff --git a/include/dom/html/html_label_element.h b/include/dom/html/html_label_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_label_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_legend_element.h b/include/dom/html/html_legend_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_legend_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_li_element.h b/include/dom/html/html_li_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_li_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_link_element.h b/include/dom/html/html_link_element.h
new file mode 100644
index 0000000..c96d020
--- a/dev/null
+++ b/include/dom/html/html_link_element.h
@@ -0,0 +1,23 @@
+/*
+ * 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.com>
+ */
+
+#ifndef dom_html_link_element_h_
+#define dom_html_link_element_h_
+
+#include <stdbool.h>
+#include <dom/core/exceptions.h>
+
+typedef struct dom_html_link_element dom_html_link_element;
+
+dom_exception dom_html_link_element_get_disabled(dom_html_link_element *ele,
+ bool *disabled);
+
+dom_exception dom_html_link_element_set_disabled(dom_html_link_element *ele,
+ bool disabled);
+
+#endif
+
diff --git a/include/dom/html/html_map_element.h b/include/dom/html/html_map_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_map_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_menu_element.h b/include/dom/html/html_menu_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_menu_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_meta_element.h b/include/dom/html/html_meta_element.h
new file mode 100644
index 0000000..8ceb459
--- a/dev/null
+++ b/include/dom/html/html_meta_element.h
@@ -0,0 +1,14 @@
+/*
+ * 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.com>
+ */
+
+#ifndef dom_html_meta_element_h_
+#define dom_html_meta_element_h_
+
+typedef struct dom_html_meta_element dom_html_meta_element;
+
+#endif
+
diff --git a/include/dom/html/html_mod_element.h b/include/dom/html/html_mod_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_mod_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_object_element.h b/include/dom/html/html_object_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_object_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_olist_element.h b/include/dom/html/html_olist_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_olist_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_optgroup_element.h b/include/dom/html/html_optgroup_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_optgroup_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_option_element.h b/include/dom/html/html_option_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_option_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_options_collection.h b/include/dom/html/html_options_collection.h
new file mode 100644
index 0000000..ad8e6aa
--- a/dev/null
+++ b/include/dom/html/html_options_collection.h
@@ -0,0 +1,33 @@
+/*
+ * 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_options_collection_h_
+#define dom_html_options_collection_h_
+
+#include <dom/core/exceptions.h>
+
+struct dom_node;
+struct dom_string;
+
+typedef struct dom_html_options_collection dom_html_options_collection;
+
+dom_exception dom_html_options_collection_get_length(
+ dom_html_options_collection *col, unsigned long *len);
+dom_exception dom_html_options_collection_set_length(
+ dom_html_options_collection *col, unsigned long len);
+dom_exception dom_html_options_collection_item(
+ dom_html_options_collection *col, unsigned long index,
+ struct dom_node **node);
+dom_exception dom_html_options_collection_named_item(
+ dom_html_options_collection *col, struct dom_string *name,
+ struct dom_node **node);
+
+void dom_html_options_collection_ref(dom_html_options_collection *col);
+void dom_html_options_collection_unref(dom_html_options_collection *col);
+
+#endif
+
diff --git a/include/dom/html/html_paragraph_element.h b/include/dom/html/html_paragraph_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_paragraph_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_param_element.h b/include/dom/html/html_param_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_param_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_pre_element.h b/include/dom/html/html_pre_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_pre_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_quote_element.h b/include/dom/html/html_quote_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_quote_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_script_element.h b/include/dom/html/html_script_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_script_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_select_element.h b/include/dom/html/html_select_element.h
new file mode 100644
index 0000000..10c002a
--- a/dev/null
+++ b/include/dom/html/html_select_element.h
@@ -0,0 +1,55 @@
+/*
+ * 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_select_element_h_
+#define dom_html_select_element_h_
+
+#include <stdbool.h>
+
+#include <dom/core/exceptions.h>
+
+typedef struct dom_html_select_element dom_html_select_element;
+
+struct dom_html_options_collection;
+struct dom_html_element;
+
+dom_exception dom_html_select_element_get_selected_index(
+ dom_html_select_element *ele, unsigned long *index);
+dom_exception dom_html_select_element_set_selected_index(
+ dom_html_select_element *ele, unsigned long index);
+dom_exception dom_html_select_element_get_length(
+ dom_html_select_element *ele, unsigned long *len);
+dom_exception dom_html_select_element_set_length(
+ dom_html_select_element *ele, unsigned long len);
+dom_exception dom_html_select_element_get_options(
+ dom_html_select_element *ele,
+ struct dom_html_options_collection **col);
+dom_exception dom_html_select_element_get_disabled(
+ dom_html_select_element *ele, bool *disabled);
+dom_exception dom_html_select_element_set_disabled(
+ dom_html_select_element *ele, bool disabled);
+dom_exception dom_html_select_element_get_multiple(
+ dom_html_select_element *ele, bool *multiple);
+dom_exception dom_html_select_element_set_multiple(
+ dom_html_select_element *ele, bool multiple);
+dom_exception dom_html_select_element_get_size(
+ dom_html_select_element *ele, unsigned long *size);
+dom_exception dom_html_select_element_set_size(
+ dom_html_select_element *ele, unsigned long size);
+dom_exception dom_html_select_element_get_tab_index(
+ dom_html_select_element *ele, unsigned long *tab_index);
+dom_exception dom_html_select_element_set_tab_index(
+ dom_html_select_element *ele, unsigned long tab_index);
+
+/* Functions */
+dom_exception dom_html_select_element_add(struct dom_html_element *ele,
+ struct dom_html_element *before);
+dom_exception dom_html_element_blur(struct dom_html_select_element *ele);
+dom_exception dom_html_element_focus(struct dom_html_select_element *ele);
+
+#endif
+
diff --git a/include/dom/html/html_style_element.h b/include/dom/html/html_style_element.h
new file mode 100644
index 0000000..868a043
--- a/dev/null
+++ b/include/dom/html/html_style_element.h
@@ -0,0 +1,23 @@
+/*
+ * 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.com>
+ */
+
+#ifndef dom_html_style_element_h_
+#define dom_html_style_element_h_
+
+#include <stdbool.h>
+#include <dom/core/exceptions.h>
+
+typedef struct dom_html_style_element dom_html_style_element;
+
+dom_exception dom_html_style_element_get_disabled(dom_html_style_element *ele,
+ bool *disabled);
+
+dom_exception dom_html_style_element_set_disabled(dom_html_style_element *ele,
+ bool disabled);
+
+#endif
+
diff --git a/include/dom/html/html_table_element.h b/include/dom/html/html_table_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_table_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_tablecaption_element.h b/include/dom/html/html_tablecaption_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_tablecaption_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_tablecell_element.h b/include/dom/html/html_tablecell_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_tablecell_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_tablecol_element.h b/include/dom/html/html_tablecol_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_tablecol_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_tablerow_element.h b/include/dom/html/html_tablerow_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_tablerow_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_tablesection_element.h b/include/dom/html/html_tablesection_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_tablesection_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_textarea_element.h b/include/dom/html/html_textarea_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_textarea_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/include/dom/html/html_title_element.h b/include/dom/html/html_title_element.h
new file mode 100644
index 0000000..5da766a
--- a/dev/null
+++ b/include/dom/html/html_title_element.h
@@ -0,0 +1,24 @@
+/*
+ * 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.com>
+ */
+
+#ifndef dom_html_title_element_h_
+#define dom_html_title_element_h_
+
+#include <dom/core/exceptions.h>
+
+struct dom_string;
+
+typedef struct dom_html_title_element dom_html_title_element;
+
+dom_exception dom_html_title_element_get_text(dom_html_title_element *ele,
+ struct dom_string **text);
+
+dom_exception dom_html_title_element_set_text(dom_html_title_element *ele,
+ struct dom_string *text);
+
+#endif
+
diff --git a/include/dom/html/html_ulist_element.h b/include/dom/html/html_ulist_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/include/dom/html/html_ulist_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/bootstrap/implementation.c b/src/bootstrap/implementation.c
index 6b9dcd7..a27edfc 100644
--- a/src/bootstrap/implementation.c
+++ b/src/bootstrap/implementation.c
@@ -23,6 +23,7 @@
#include <libwapcaplet/libwapcaplet.h>
#include "core/node.h"
+#include "core/document.h"
#include "core/document_type.h"
#include "utils/utils.h"
@@ -231,7 +232,7 @@ dom_exception impl_implementation_create_document_type(
return DOM_NAMESPACE_ERR;
/* Create the doctype */
- err = dom_document_type_create(qname, public_id, system_id,
+ err = _dom_document_type_create(qname, public_id, system_id,
alloc, pw, &d);
if (err != DOM_NO_ERR)
return err;
@@ -308,7 +309,7 @@ dom_exception impl_implementation_create_document(
}
/* Create document object */
- err = dom_document_create(impl, alloc, pw, daf, &d);
+ err = _dom_document_create(impl, alloc, pw, daf, &d);
if (err != DOM_NO_ERR)
return err;
diff --git a/src/core/attr.c b/src/core/attr.c
index f1c4f54..4cd9e76 100644
--- a/src/core/attr.c
+++ b/src/core/attr.c
@@ -19,12 +19,13 @@
#include "core/document.h"
#include "core/entity_ref.h"
#include "core/node.h"
+#include "core/element.h"
#include "utils/utils.h"
struct dom_element;
/**
- * DOM node attribute
+ * DOM attribute node
*/
struct dom_attr {
struct dom_node_internal base; /**< Base node */
@@ -35,6 +36,16 @@ struct dom_attr {
struct dom_type_info *schema_type_info; /**< Type information */
bool is_id; /**< Whether this attribute is a ID attribute */
+
+ dom_attr_type type; /**< The type of this attribute */
+
+ union {
+ unsigned long lvalue;
+ unsigned short svalue;
+ bool bvalue;
+ } value; /**< The special type value of this attribute */
+
+ bool read_only; /**< Whether this attribute is readonly */
};
/* The vtable for dom_attr node */
@@ -62,7 +73,7 @@ static struct dom_node_protect_vtable attr_protect_vtable = {
* \param name The (local) name of the node to create
* \param namespace The namespace URI of the attribute, or NULL
* \param prefix The namespace prefix of the attribute, or NULL
- * \param specified Whtether this attribute is specified
+ * \param specified Whether this attribute is specified
* \param result Pointer to location to receive created attribute
* \return DOM_NO_ERR on success,
* DOM_NO_MEM_ERR on memory exhaustion.
@@ -127,6 +138,9 @@ dom_exception _dom_attr_initialise(dom_attr *a,
a->specified = specified;
a->schema_type_info = NULL;
a->is_id = false;
+ /* The attribute type is unset when it is created */
+ a->type = DOM_ATTR_UNSET;
+ a->read_only = false;
*result = a;
@@ -165,6 +179,206 @@ void _dom_attr_destroy(struct dom_document *doc, struct dom_attr *attr)
_dom_document_alloc(doc, attr, 0);
}
+/*-----------------------------------------------------------------------*/
+/* Following are our implementation specific APIs */
+
+/**
+ * Get the Attr Node type
+ *
+ * \param a The attribute node
+ * \return the type
+ */
+dom_attr_type dom_attr_get_type(dom_attr *a)
+{
+ return a->type;
+}
+
+/**
+ * Get the integer value of this attribute
+ *
+ * \param a The attribute object
+ * \param value The returned value
+ * \return DOM_NO_ERR on success,
+ * DOM_ATTR_WRONG_TYPE_ERR if the attribute node is not a integer
+ * attribute
+ */
+dom_exception dom_attr_get_integer(dom_attr *a, unsigned long *value)
+{
+ if (a->type != DOM_ATTR_INTEGER)
+ return DOM_ATTR_WRONG_TYPE_ERR;
+
+ *value = a->value.lvalue;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Set the integer value of this attribute
+ *
+ * \param a The attribute object
+ * \param value The new value
+ * \return DOM_NO_ERR on success,
+ * DOM_ATTR_WRONG_TYPE_ERR if the attribute node is not a integer
+ * attribute
+ */
+dom_exception dom_attr_set_integer(dom_attr *a, unsigned long value)
+{
+ /* If this is the first set method, we should fix this attribute
+ * type */
+ if (a->type == DOM_ATTR_UNSET)
+ a->type = DOM_ATTR_INTEGER;
+
+ if (a->type != DOM_ATTR_INTEGER)
+ return DOM_ATTR_WRONG_TYPE_ERR;
+
+ if (a->value.lvalue == value)
+ return DOM_NO_ERR;
+
+ a->value.lvalue = value;
+
+ struct dom_document *doc = dom_node_get_owner(a);
+ struct dom_node_internal *ele = dom_node_get_parent(a);
+ bool success = true;
+ dom_exception err;
+ err = _dom_dispatch_attr_modified_event(doc, ele, NULL, NULL,
+ (dom_event_target *) a, NULL,
+ DOM_MUTATION_MODIFICATION, &success);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ success = true;
+ err = _dom_dispatch_subtree_modified_event(doc,
+ (dom_event_target *) a, &success);
+ return err;
+}
+
+/**
+ * Get the short value of this attribute
+ *
+ * \param a The attribute object
+ * \param value The returned value
+ * \return DOM_NO_ERR on success,
+ * DOM_ATTR_WRONG_TYPE_ERR if the attribute node is not a short
+ * attribute
+ */
+dom_exception dom_attr_get_short(dom_attr *a, unsigned short *value)
+{
+ if (a->type != DOM_ATTR_SHORT)
+ return DOM_ATTR_WRONG_TYPE_ERR;
+
+ *value = a->value.svalue;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Set the short value of this attribute
+ *
+ * \param a The attribute object
+ * \param value The new value
+ * \return DOM_NO_ERR on success,
+ * DOM_ATTR_WRONG_TYPE_ERR if the attribute node is not a short
+ * attribute
+ */
+dom_exception dom_attr_set_short(dom_attr *a, unsigned short value)
+{
+ /* If this is the first set method, we should fix this attribute
+ * type */
+ if (a->type == DOM_ATTR_UNSET)
+ a->type = DOM_ATTR_SHORT;
+
+ if (a->type != DOM_ATTR_SHORT)
+ return DOM_ATTR_WRONG_TYPE_ERR;
+
+ if (a->value.svalue == value)
+ return DOM_NO_ERR;
+
+ a->value.svalue = value;
+
+ struct dom_document *doc = dom_node_get_owner(a);
+ struct dom_node_internal *ele = dom_node_get_parent(a);
+ bool success = true;
+ dom_exception err;
+ err = _dom_dispatch_attr_modified_event(doc, ele, NULL, NULL,
+ (dom_event_target *) a, NULL,
+ DOM_MUTATION_MODIFICATION, &success);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ success = true;
+ err = _dom_dispatch_subtree_modified_event(doc,
+ (dom_event_target *) a, &success);
+ return err;
+}
+
+/**
+ * Get the bool value of this attribute
+ *
+ * \param a The attribute object
+ * \param value The returned value
+ * \return DOM_NO_ERR on success,
+ * DOM_ATTR_WRONG_TYPE_ERR if the attribute node is not a bool
+ * attribute
+ */
+dom_exception dom_attr_get_bool(dom_attr *a, bool *value)
+{
+ if (a->type != DOM_ATTR_BOOL)
+ return DOM_ATTR_WRONG_TYPE_ERR;
+
+ *value = a->value.bvalue;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Set the bool value of this attribute
+ *
+ * \param a The attribute object
+ * \param value The new value
+ * \return DOM_NO_ERR on success,
+ * DOM_ATTR_WRONG_TYPE_ERR if the attribute node is not a bool
+ * attribute
+ */
+dom_exception dom_attr_set_bool(dom_attr *a, bool value)
+{
+ /* If this is the first set method, we should fix this attribute
+ * type */
+ if (a->type == DOM_ATTR_UNSET)
+ a->type = DOM_ATTR_BOOL;
+
+ if (a->type != DOM_ATTR_BOOL)
+ return DOM_ATTR_WRONG_TYPE_ERR;
+
+ if (a->value.bvalue == value)
+ return DOM_NO_ERR;
+
+ a->value.bvalue = value;
+
+ struct dom_document *doc = dom_node_get_owner(a);
+ struct dom_node_internal *ele = dom_node_get_parent(a);
+ bool success = true;
+ dom_exception err;
+ err = _dom_dispatch_attr_modified_event(doc, ele, NULL, NULL,
+ (dom_event_target *) a, NULL,
+ DOM_MUTATION_MODIFICATION, &success);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ success = true;
+ err = _dom_dispatch_subtree_modified_event(doc,
+ (dom_event_target *) a, &success);
+ return err;
+}
+
+/**
+ * Set the node as a readonly attribute
+ *
+ * \param a The attribute
+ */
+void dom_attr_mark_readonly(dom_attr *a)
+{
+ a->read_only = true;
+}
/* -------------------------------------------------------------------- */
@@ -227,6 +441,18 @@ dom_exception _dom_attr_get_value(struct dom_attr *attr,
return err;
}
+ /* Force unknown types to strings, if necessary */
+ if (attr->type == DOM_ATTR_UNSET && a->first_child != NULL) {
+ attr->type = DOM_ATTR_STRING;
+ }
+
+ /* If this attribute node is not a string one, we just return an empty
+ * string */
+ if (attr->type != DOM_ATTR_STRING) {
+ *result = value;
+ return DOM_NO_ERR;
+ }
+
/* Traverse children, building a string representation as we go */
for (c = a->first_child; c != NULL; c = c->next) {
if (c->type == DOM_TEXT_NODE && c->value != NULL) {
@@ -298,10 +524,33 @@ dom_exception _dom_attr_set_value(struct dom_attr *attr,
if (_dom_node_readonly(a))
return DOM_NO_MODIFICATION_ALLOWED_ERR;
+ /* If this is the first set method, we should fix this attribute
+ * type */
+ if (attr->type == DOM_ATTR_UNSET)
+ attr->type = DOM_ATTR_STRING;
+
+ if (attr->type != DOM_ATTR_STRING)
+ return DOM_ATTR_WRONG_TYPE_ERR;
+
+ dom_string *name = NULL;
+
+ err = _dom_attr_get_name(attr, &name);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ dom_string *parsed = NULL;
+ err = dom_element_parse_attribute(a->parent, name, value, &parsed);
+ if (err != DOM_NO_ERR) {
+ dom_string_unref(name);
+ return err;
+ }
+
/* Create text node containing new value */
- err = dom_document_create_text_node(a->owner, value, &text);
+ err = dom_document_create_text_node(a->owner, parsed, &text);
if (err != DOM_NO_ERR)
return err;
+
+ dom_string_unref(parsed);
/* Destroy children of this node */
for (c = a->first_child; c != NULL; c = d) {
@@ -561,3 +810,14 @@ void _dom_attr_set_specified(struct dom_attr *attr, bool specified)
attr->specified = specified;
}
+/**
+ * Whether this attribute node is readonly
+ *
+ * \param a The node
+ * \return true if this Attr is readonly, false otherwise
+ */
+bool _dom_attr_readonly(const dom_attr *a)
+{
+ return a->read_only;
+}
+
diff --git a/src/core/attr.h b/src/core/attr.h
index ab51247..b94715a 100644
--- a/src/core/attr.h
+++ b/src/core/attr.h
@@ -8,7 +8,7 @@
#ifndef dom_internal_core_attr_h_
#define dom_internal_core_attr_h_
-#include <dom/core/exceptions.h>
+#include <dom/core/attr.h>
struct dom_document;
struct dom_string;
@@ -24,7 +24,7 @@ dom_exception _dom_attr_initialise(struct dom_attr *a,
struct dom_document *doc, struct lwc_string_s *name,
struct lwc_string_s *namespace, struct lwc_string_s *prefix,
bool specified, struct dom_attr **result);
-void _dom_attr_finalise(dom_document *doc, struct dom_attr *attr);
+void _dom_attr_finalise(struct dom_document *doc, struct dom_attr *attr);
/* Virtual functions for dom_attr */
dom_exception _dom_attr_get_name(struct dom_attr *attr,
@@ -117,5 +117,6 @@ dom_exception _dom_attr_copy(struct dom_node_internal *new,
void _dom_attr_set_isid(struct dom_attr *attr, bool is_id);
void _dom_attr_set_specified(struct dom_attr *attr, bool specified);
+bool _dom_attr_readonly(const dom_attr *a);
#endif
diff --git a/src/core/document.c b/src/core/document.c
index 74fb534..ad25bd7 100644
--- a/src/core/document.c
+++ b/src/core/document.c
@@ -76,13 +76,14 @@ static dom_exception dom_document_dup_node(dom_document *doc,
* \param pw Pointer to client-specific private data
* \param doc Pointer to location to receive created document
* \param daf The default action fetcher
+ * \param daf The default action fetcher
* \return DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion.
*
* ::impl will have its reference count increased.
*
* The returned document will already be referenced.
*/
-dom_exception dom_document_create(struct dom_implementation *impl,
+dom_exception _dom_document_create(struct dom_implementation *impl,
dom_alloc alloc, void *pw,
dom_events_default_action_fetcher daf,
struct dom_document **doc)
@@ -186,6 +187,8 @@ bool _dom_document_finalise(struct dom_document *doc)
lwc_string_unref(doc->id_name);
_dom_document_event_internal_finalise(doc, &doc->dei);
+
+ _dom_document_event_internal_finalise(doc, &doc->dei);
return true;
}
diff --git a/src/core/document.h b/src/core/document.h
index a7cab6d..e657530 100644
--- a/src/core/document.h
+++ b/src/core/document.h
@@ -12,6 +12,7 @@
#include <stddef.h>
#include <dom/core/node.h>
+#include <dom/core/document.h>
#include "core/string.h"
#include "core/node.h"
@@ -66,6 +67,12 @@ struct dom_document {
/**< The DocumentEVent interface */
};
+/* Create a DOM document */
+dom_exception _dom_document_create(struct dom_implementation *impl,
+ dom_alloc alloc, void *pw,
+ dom_events_default_action_fetcher daf,
+ struct dom_document **doc);
+
/* Initialise the document */
dom_exception _dom_document_initialise(struct dom_document *doc,
struct dom_implementation *impl, dom_alloc alloc, void *pw,
@@ -194,6 +201,28 @@ dom_exception _dom_document_rename_node(struct dom_document *doc,
_dom_document_rename_node
/* End of vtable */
+/**
+ * The internal used vtable for document
+ */
+struct dom_document_protected_vtable {
+ struct dom_node_protect_vtable base;
+ dom_exception (*dom_document_get_base)(dom_document *doc,
+ struct dom_string **base_uri);
+ /* Get the document's base uri */
+};
+
+typedef struct dom_document_protected_vtable dom_document_protected_vtable;
+
+/* Get the document's base URI */
+static inline dom_exception dom_document_get_base(dom_document *doc,
+ struct dom_string **base_uri)
+{
+ struct dom_node_internal *node = (struct dom_node_internal *) doc;
+ return ((dom_document_protected_vtable *) node->vtable)->
+ dom_document_get_base(doc, base_uri);
+}
+#define dom_document_get_base(d, b) dom_document_get_base( \
+ (dom_document *) (d), (struct dom_string **) (b))
/* Following comes the protected vtable */
void _dom_document_destroy(struct dom_node_internal *node);
diff --git a/src/core/document_type.c b/src/core/document_type.c
index c8b3ff2..4b07e3f 100644
--- a/src/core/document_type.c
+++ b/src/core/document_type.c
@@ -64,7 +64,7 @@ static struct dom_node_protect_vtable dt_protect_vtable = {
* explicitly. The client must unref the doctype once it has
* finished with it.
*/
-dom_exception dom_document_type_create(struct dom_string *qname,
+dom_exception _dom_document_type_create(struct dom_string *qname,
struct dom_string *public_id, struct dom_string *system_id,
dom_alloc alloc, void *pw,
struct dom_document_type **doctype)
diff --git a/src/core/document_type.h b/src/core/document_type.h
index 50dd5ea..93db617 100644
--- a/src/core/document_type.h
+++ b/src/core/document_type.h
@@ -12,6 +12,12 @@ struct dom_document_type;
struct dom_resource_mgr;
struct dom_implementation;
+/* Create a DOM document type */
+dom_exception _dom_document_type_create(struct dom_string *qname,
+ struct dom_string *public_id,
+ struct dom_string *system_id,
+ dom_alloc alloc, void *pw,
+ struct dom_document_type **doctype);
/* Destroy a document type */
void _dom_document_type_destroy(struct dom_node_internal *doctypenode);
dom_exception _dom_document_type_initialise(struct dom_document_type *doctype,
diff --git a/src/core/element.c b/src/core/element.c
index 9c1263a..1069e60 100644
--- a/src/core/element.c
+++ b/src/core/element.c
@@ -35,14 +35,17 @@
#define CHAINS_NAMESPACE 7
#define CHAINS_NS_ATTRIBUTES 31
-static struct dom_element_vtable element_vtable = {
+struct dom_element_vtable _dom_element_vtable = {
{
DOM_NODE_VTABLE_ELEMENT
},
DOM_ELEMENT_VTABLE
};
-static struct dom_node_protect_vtable element_protect_vtable = {
+static struct dom_element_protected_vtable element_protect_vtable = {
+ {
+ DOM_NODE_PROTECT_VTABLE_ELEMENT
+ },
DOM_ELEMENT_PROTECT_VTABLE
};
@@ -145,7 +148,7 @@ dom_exception _dom_element_create(struct dom_document *doc,
return DOM_NO_MEM_ERR;
/* Initialise the vtables */
- (*result)->base.base.vtable = &element_vtable;
+ (*result)->base.base.vtable = &_dom_element_vtable;
(*result)->base.vtable = &element_protect_vtable;
return _dom_element_initialise(doc, *result, name, namespace, prefix);
@@ -1109,6 +1112,44 @@ dom_exception _dom_element_lookup_namespace(dom_node_internal *node,
/*----------------------------------------------------------------------*/
/* The protected virtual functions */
+/**
+ * The virtual function to parse some dom attribute
+ *
+ * \param ele The element object
+ * \param name The name of the attribute
+ * \param value The new value of the attribute
+ * \param parsed The parsed value of the attribute
+ * \return DOM_NO_ERR on success.
+ *
+ * @note: This virtual method is provided to serve as a template method.
+ * When any attribute is set or added, the attribute's value should be
+ * checked to make sure that it is a valid one. And the child class of
+ * dom_element may to do some special stuff on the attribute is set. Take
+ * some integer attribute as example:
+ *
+ * 1. The client call dom_element_set_attribute("size", "10.1"), but the
+ * size attribute may only accept an integer, and only the specific
+ * dom_element know this. And the dom_attr_set_value method, which is
+ * called by dom_element_set_attribute should call the this virtual
+ * template method.
+ * 2. The overload virtual function of following one will truncate the
+ * "10.1" to "10" to make sure it is a integer. And of course, the
+ * overload method may also save the integer as a 'int' C type for
+ * later easy accessing by any client.
+ */
+dom_exception _dom_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed)
+{
+ UNUSED(ele);
+ UNUSED(name);
+
+ dom_string_ref(value);
+ *parsed = value;
+
+ return DOM_NO_ERR;
+}
+
/* The destroy virtual function of dom_element */
void __dom_element_destroy(struct dom_node_internal *node)
{
@@ -1296,9 +1337,13 @@ dom_exception _dom_element_set_attr(struct dom_element *element,
if (err != DOM_NO_ERR)
return err;
+ /* Set its parent, so that value parsing works */
+ dom_node_set_parent(attr, element);
+
/* Set its value */
err = dom_attr_set_value(attr, value);
if (err != DOM_NO_ERR) {
+ dom_node_set_parent(attr, NULL);
dom_node_unref(attr);
return err;
}
@@ -1310,6 +1355,7 @@ dom_exception _dom_element_set_attr(struct dom_element *element,
(dom_event_target *) attr, name,
DOM_MUTATION_ADDITION, &success);
if (err != DOM_NO_ERR) {
+ dom_node_set_parent(attr, NULL);
dom_node_unref(attr);
return err;
}
@@ -1319,6 +1365,7 @@ dom_exception _dom_element_set_attr(struct dom_element *element,
(dom_event_target *) element,
DOM_MUTATION_ADDITION, &success);
if (err != DOM_NO_ERR) {
+ dom_node_set_parent(attr, NULL);
dom_node_unref(attr);
return err;
}
@@ -1326,11 +1373,11 @@ dom_exception _dom_element_set_attr(struct dom_element *element,
added = _dom_hash_add(hs, str, attr, false);
if (added == false) {
/* If we failed at this step, there must be no memory */
+ dom_node_set_parent(attr, NULL);
dom_node_unref(attr);
return DOM_NO_MEM_ERR;
}
- dom_node_set_parent(attr, element);
dom_node_unref(attr);
dom_node_remove_pending(attr);
diff --git a/src/core/element.h b/src/core/element.h
index 51e1268..8a64314 100644
--- a/src/core/element.h
+++ b/src/core/element.h
@@ -10,7 +10,9 @@
#include <stdbool.h>
-#include <dom/core/exceptions.h>
+#include <dom/core/element.h>
+
+#include "core/node.h"
struct dom_document;
struct dom_element;
@@ -175,8 +177,41 @@ dom_exception _dom_element_lookup_namespace(dom_node_internal *node,
_dom_node_set_user_data, \
_dom_node_get_user_data
+/**
+ * The internal used vtable for element
+ */
+struct dom_element_protected_vtable {
+ struct dom_node_protect_vtable base;
+
+ dom_exception (*dom_element_parse_attribute)(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed);
+ /**< Called by dom_attr_set_value, and used to check
+ * whether the new attribute value is valid and
+ * return a valid on if it is not
+ */
+};
+
+typedef struct dom_element_protected_vtable dom_element_protected_vtable;
+
+/* Parse the attribute's value */
+static inline dom_exception dom_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed)
+{
+ struct dom_node_internal *node = (struct dom_node_internal *) ele;
+ return ((dom_element_protected_vtable *) node->vtable)->
+ dom_element_parse_attribute(ele, name, value, parsed);
+}
+#define dom_element_parse_attribute(e, n, v, p) dom_element_parse_attribute( \
+ (dom_element *) (e), (struct dom_string *) (n), \
+ (struct dom_string *) (v), (struct dom_string **) (p))
+
/* The protected virtual function */
+dom_exception _dom_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed);
void __dom_element_destroy(dom_node_internal *node);
dom_exception _dom_element_alloc(struct dom_document *doc,
struct dom_node_internal *n, struct dom_node_internal **ret);
@@ -184,6 +219,9 @@ dom_exception _dom_element_copy(struct dom_node_internal *new,
struct dom_node_internal *old);
#define DOM_ELEMENT_PROTECT_VTABLE \
+ _dom_element_parse_attribute
+
+#define DOM_NODE_PROTECT_VTABLE_ELEMENT \
__dom_element_destroy, \
_dom_element_alloc, \
_dom_element_copy
@@ -192,4 +230,6 @@ dom_exception _dom_element_copy(struct dom_node_internal *new,
dom_exception _dom_element_get_id(struct dom_element *ele,
struct lwc_string_s **id);
+extern struct dom_element_vtable _dom_element_vtable;
+
#endif
diff --git a/src/core/node.c b/src/core/node.c
index 5f35f61..ef2baf2 100644
--- a/src/core/node.c
+++ b/src/core/node.c
@@ -1491,10 +1491,10 @@ dom_exception _dom_node_has_attributes(dom_node_internal *node, bool *result)
dom_exception _dom_node_get_base(dom_node_internal *node,
struct dom_string **result)
{
- UNUSED(node);
- UNUSED(result);
+ struct dom_document *doc = node->owner;
+ assert(doc != NULL);
- return DOM_NOT_SUPPORTED_ERR;
+ return dom_document_get_base(doc, result);
}
/**
@@ -2072,6 +2072,10 @@ bool _dom_node_readonly(const dom_node_internal *node)
if (n->type == DOM_DOCUMENT_TYPE_NODE ||
n->type == DOM_NOTATION_NODE)
return true;
+
+ /* Some Attr node are readonly */
+ if (n->type == DOM_ATTRIBUTE_NODE)
+ return _dom_attr_readonly((const dom_attr *) n);
/* Entity ns and their descendants are read only
* EntityReference ns and their descendants are read only */
@@ -2363,6 +2367,25 @@ void _dom_node_unref_intern_string(dom_node_internal *node,
}
/**
+ * Create a lwc_string using the node's owner's lwc_context
+ *
+ * \param node The node object
+ * \param data The string data
+ * \param len The length of the string data
+ * \param str The returned lwc_string
+ * \return DOM_NO_ERR on success, appropirate dom_exception on failure.
+ */
+dom_exception _dom_node_create_lwcstring(dom_node_internal *node,
+ const uint8_t *data, size_t len, struct lwc_string_s **str)
+{
+ dom_document *doc = dom_node_get_owner(node);
+
+ assert(doc != NULL);
+
+ return _dom_document_create_lwcstring(doc, data, len, str);
+}
+
+/**
* Try to destroy this node.
*
* \param node The node to destroy
diff --git a/src/core/node.h b/src/core/node.h
index 4144b6e..70187d6 100644
--- a/src/core/node.h
+++ b/src/core/node.h
@@ -286,6 +286,8 @@ dom_exception _dom_node_get_intern_string(dom_node_internal *node,
struct dom_string *str, struct lwc_string_s **intern);
void _dom_node_unref_intern_string(dom_node_internal *node,
struct lwc_string_s *inter);
+dom_exception _dom_node_create_lwcstring(dom_node_internal *node,
+ const uint8_t *data, size_t len, struct lwc_string_s **str);
/* Try to destroy the node, if its refcnt is not zero, then append it to the
* owner document's pending list */
diff --git a/src/events/event_target.c b/src/events/event_target.c
index e409e02..5428557 100644
--- a/src/events/event_target.c
+++ b/src/events/event_target.c
@@ -255,12 +255,9 @@ dom_exception _dom_event_target_dispatch_event(dom_event_target *et,
}
dom_string_unref(type);
- lwc_string *t = evt->type;
dom_event_target_entry list;
dom_event_target *target = et;
- assert(t != NULL);
-
*success = true;
/* Compose the event target list */
@@ -287,6 +284,17 @@ dom_exception _dom_event_target_dispatch_event(dom_event_target *et,
evt->target = et;
evt->phase = DOM_CAPTURING_PHASE;
+ /* The started callback of default action */
+ struct dom_document_event_internal *dei = &doc->dei;
+ void *pw = NULL;
+ if (dei->actions != NULL) {
+ dom_default_action_callback cb = dei->actions(evt->type,
+ DOM_DEFAULT_ACTION_STARTED, &pw);
+ if (cb != NULL) {
+ cb(evt, pw);
+ }
+ }
+
/* The capture phase */
struct list_entry *e = list.entry.prev;
for (; e != &list.entry; e = e->prev) {
@@ -329,33 +337,27 @@ dom_exception _dom_event_target_dispatch_event(dom_event_target *et,
goto cleanup;
}
- struct dom_document_event_internal *dei = &doc->dei;
- if (dei->actions == NULL || evt->prevent_default == true)
+ if (dei->actions == NULL)
goto cleanup;
- /* The default action */
- struct dom_string *nodename;
- err = dom_node_get_node_name(et, &nodename);
- if (err != DOM_NO_ERR) {
- ret = err;
- goto cleanup;
- }
- lwc_string *lnodename = NULL;
- err = dom_string_get_intern(nodename, &lnodename);
- if (err != DOM_NO_ERR) {
- dom_string_unref(nodename);
- ret = err;
- goto cleanup;
+ /* The end callback of default action */
+ if (evt->prevent_default != true) {
+ dom_default_action_callback cb = dei->actions(evt->type,
+ DOM_DEFAULT_ACTION_END, &pw);
+ if (cb != NULL) {
+ cb(evt, pw);
+ }
}
- dom_event_listener *da = dei->actions(lnodename, t);
- if (da != NULL) {
- da->handler(evt, da->pw);
+ /* The prevented callback of default action */
+ if (evt->prevent_default != true) {
+ dom_default_action_callback cb = dei->actions(evt->type,
+ DOM_DEFAULT_ACTION_PREVENTED, &pw);
+ if (cb != NULL) {
+ cb(evt, pw);
+ }
}
- dom_string_unref(nodename);
- lwc_string_unref(lnodename);
-
cleanup:
if (evt->prevent_default == true) {
*success = false;
@@ -707,9 +709,10 @@ cleanup:
/**
* Dispatch a DOMCharacterDataModified event
*
- * \param et The EventTarget object
- * \param prev The preValue of the DOMCharacterData
- * \param new The newValue of the DOMCharacterData
+ * \param et The EventTarget object
+ * \param prev The preValue of the DOMCharacterData
+ * \param new The newValue of the DOMCharacterData
+ * \param success Whether this event's default handler get called
* \return DOM_NO_ERR on success, appropirate dom_exception on failure.
*
* TODO:
@@ -761,7 +764,7 @@ cleanup:
*
* \param doc The Document
* \param et The EventTarget object
- * \param success The newValue of the DOMCharacterData
+ * \param success Whether this event's default handler get called
* \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
dom_exception _dom_dispatch_subtree_modified_event(struct dom_document *doc,
@@ -802,3 +805,51 @@ cleanup:
return err;
}
+/**
+ * Dispatch a generic event
+ *
+ * \param doc The Document
+ * \param et The EventTarget object
+ * \param name The name of the event
+ * \param len The length of the name string
+ * \param bubble Whether this event bubbles
+ * \param cancelable Whether this event can be cancelable
+ * \param success Whether this event's default handler get called
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_dispatch_generic_event(struct dom_document *doc,
+ dom_event_target *et, const uint8_t *name, size_t len,
+ bool bubble, bool cancelable, bool *success)
+{
+ struct dom_event *evt;
+ dom_exception err;
+
+ err = _dom_event_create(doc, &evt);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ lwc_string *type = NULL;
+ err = _dom_document_create_lwcstring(doc, name, len, &type);
+ if (err != DOM_NO_ERR)
+ goto cleanup;
+
+ dom_string *t = NULL;
+ err = _dom_document_create_string_from_lwcstring(doc, type, &t);
+ _dom_document_unref_lwcstring(doc, type);
+ if (err != DOM_NO_ERR)
+ goto cleanup;
+
+ err = dom_event_init(evt, t, bubble, cancelable);
+ dom_string_unref(t);
+ if (err != DOM_NO_ERR) {
+ goto cleanup;
+ }
+
+ err = dom_event_target_dispatch_event(et, evt, success);
+
+cleanup:
+ _dom_event_destroy(doc, evt);
+
+ return err;
+}
+
diff --git a/src/events/event_target.h b/src/events/event_target.h
index a92963e..e6ad7b6 100644
--- a/src/events/event_target.h
+++ b/src/events/event_target.h
@@ -85,4 +85,8 @@ dom_exception _dom_dispatch_attr_modified_event(struct dom_document *doc,
dom_exception _dom_dispatch_subtree_modified_event(struct dom_document *doc,
dom_event_target *et, bool *success);
+/* Dispatch a generic event */
+dom_exception _dom_dispatch_generic_event(struct dom_document *doc,
+ dom_event_target *et, const uint8_t *name, size_t len,
+ bool bubble, bool cancelable, bool *success);
#endif
diff --git a/src/html/Makefile b/src/html/Makefile
new file mode 100644
index 0000000..a154a99
--- a/dev/null
+++ b/src/html/Makefile
@@ -0,0 +1,25 @@
+# Sources
+DIR_SOURCES := \
+ html_document.c html_collection.c html_options_collection.c \
+ html_element.c html_html_element.c html_head_element.c \
+ html_link_element.c html_title_element.c html_meta_element.c \
+ html_base_element.c html_isindex_element.c html_style_element.c \
+ html_body_element.c html_form_element.c html_select_element.c
+
+UNINMPLEMENTED_SOURCES := html_optgroup_element.c \
+ html_option_element.c html_input_element.c html_textarea_element.c \
+ html_button_element.c html_label_element.c html_fieldset_element.c \
+ html_legend_element.c html_ulist_element.c html_olist_element.c \
+ html_dlist_element.c html_directory_element.c html_menu_element.c \
+ html_li_element.c html_div_element.c html_paragraph_element.c \
+ html_heading_element.c html_quote_element.c html_pre_element.c \
+ html_br_element.c html_basefont_element.c html_font_element.c \
+ html_hr_element.c html_mod_element.c html_anchor_element.c \
+ html_image_element.c html_object_element.c html_param_element.c \
+ html_applet_element.c html_map_element.c html_area_element.c \
+ html_script_element.c html_table_element.c html_tablecaption_element.c \
+ html_tablecol_element.c html_tablesection_element.c html_tablerow_element.c \
+ html_tablecell_element.c html_frameset_element.c html_frame_element.c \
+ html_iframe_element.c
+
+include build/makefiles/Makefile.subdir
diff --git a/src/html/html_anchor_element.c b/src/html/html_anchor_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_anchor_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_anchor_element.h b/src/html/html_anchor_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_anchor_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_applet_element.c b/src/html/html_applet_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_applet_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_applet_element.h b/src/html/html_applet_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_applet_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_area_element.c b/src/html/html_area_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_area_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_area_element.h b/src/html/html_area_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_area_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_base_element.c b/src/html/html_base_element.c
new file mode 100644
index 0000000..f8aa14e
--- a/dev/null
+++ b/src/html/html_base_element.c
@@ -0,0 +1,137 @@
+/*
+ * 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.com>
+ */
+
+#include "html/html_base_element.h"
+
+#include "core/node.h"
+#include "core/document.h"
+#include "utils/utils.h"
+
+static struct dom_element_protected_vtable _protect_vtable = {
+ {
+ DOM_NODE_PROTECT_VTABLE_HTML_BASE_ELEMENT
+ },
+ DOM_HTML_BASE_ELEMENT_PROTECT_VTABLE
+};
+
+/**
+ * Create a dom_html_base_element object
+ *
+ * \param doc The document object
+ * \param ele The returned element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_base_element_create(struct dom_document *doc,
+ struct dom_html_base_element **ele)
+{
+ *ele = _dom_document_alloc(doc, NULL, sizeof(dom_html_base_element));
+ if (*ele == NULL)
+ return DOM_NO_MEM_ERR;
+
+ /* Set up vtables */
+ struct dom_node_internal *node = (struct dom_node_internal *) *ele;
+ node->base.vtable = &_dom_element_vtable;
+ node->vtable = &_protect_vtable;
+
+ return _dom_html_base_element_initialise(doc, *ele);
+}
+
+/**
+ * Initialise a dom_html_base_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_base_element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_base_element_initialise(struct dom_document *doc,
+ struct dom_html_base_element *ele)
+{
+ const char *str = "BASE";
+ lwc_string *name = NULL;
+ dom_exception err;
+
+ err = _dom_document_create_lwcstring(doc, (const uint8_t *) str, SLEN(str),
+ &name);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
+ _dom_document_unref_lwcstring(doc, name);
+
+ return err;
+}
+
+/**
+ * Finalise a dom_html_base_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_base_element object
+ */
+void _dom_html_base_element_finalise(struct dom_document *doc,
+ struct dom_html_base_element *ele)
+{
+ _dom_html_element_finalise(doc, &ele->base);
+}
+
+/**
+ * Destroy a dom_html_base_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_base_element object
+ */
+void _dom_html_base_element_destroy(struct dom_document *doc,
+ struct dom_html_base_element *ele)
+{
+ _dom_html_base_element_finalise(doc, ele);
+ _dom_document_alloc(doc, ele, 0);
+}
+
+/*------------------------------------------------------------------------*/
+/* The protected virtual functions */
+
+/* The virtual function used to parse attribute value, see src/core/element.c
+ * for detail */
+dom_exception _dom_html_base_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed)
+{
+ UNUSED(ele);
+ UNUSED(name);
+
+ dom_string_ref(value);
+ *parsed = value;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual destroy function, see src/core/node.c for detail */
+void _dom_virtual_html_base_element_destroy(dom_node_internal *node)
+{
+ struct dom_document *doc = dom_node_get_owner(node);
+ _dom_html_base_element_destroy(doc, (struct dom_html_base_element *) node);
+}
+
+/* The virtual allocation function, see src/core/node.c for detail */
+dom_exception _dom_html_base_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(n);
+
+ *ret = _dom_document_alloc(doc, NULL, sizeof(dom_html_base_element));
+ if (*ret == NULL)
+ return DOM_NO_MEM_ERR;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual copy function, see src/core/node.c for detail */
+dom_exception _dom_html_base_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ return _dom_html_element_copy(new, old);
+}
+
diff --git a/src/html/html_base_element.h b/src/html/html_base_element.h
new file mode 100644
index 0000000..7e58cc2
--- a/dev/null
+++ b/src/html/html_base_element.h
@@ -0,0 +1,55 @@
+/*
+ * 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.com>
+ */
+
+#ifndef dom_internal_html_base_element_h_
+#define dom_internal_html_base_element_h_
+
+#include <dom/html/html_base_element.h>
+
+#include "html/html_element.h"
+
+struct dom_html_base_element {
+ struct dom_html_element base;
+ /**< The base class */
+};
+
+/* Create a dom_html_base_element object */
+dom_exception _dom_html_base_element_create(struct dom_document *doc,
+ struct dom_html_base_element **ele);
+
+/* Initialise a dom_html_base_element object */
+dom_exception _dom_html_base_element_initialise(struct dom_document *doc,
+ struct dom_html_base_element *ele);
+
+/* Finalise a dom_html_base_element object */
+void _dom_html_base_element_finalise(struct dom_document *doc,
+ struct dom_html_base_element *ele);
+
+/* Destroy a dom_html_base_element object */
+void _dom_html_base_element_destroy(struct dom_document *doc,
+ struct dom_html_base_element *ele);
+
+/* The protected virtual functions */
+dom_exception _dom_html_base_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed);
+void _dom_virtual_html_base_element_destroy(dom_node_internal *node);
+dom_exception _dom_html_base_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_html_base_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+#define DOM_HTML_BASE_ELEMENT_PROTECT_VTABLE \
+ _dom_html_base_element_parse_attribute
+
+#define DOM_NODE_PROTECT_VTABLE_HTML_BASE_ELEMENT \
+ _dom_virtual_html_base_element_destroy, \
+ _dom_html_base_element_alloc, \
+ _dom_html_base_element_copy
+
+#endif
+
diff --git a/src/html/html_basefont_element.c b/src/html/html_basefont_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_basefont_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_basefont_element.h b/src/html/html_basefont_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_basefont_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_body_element.c b/src/html/html_body_element.c
new file mode 100644
index 0000000..7512910
--- a/dev/null
+++ b/src/html/html_body_element.c
@@ -0,0 +1,137 @@
+/*
+ * 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.com>
+ */
+
+#include "html/html_body_element.h"
+
+#include "core/node.h"
+#include "core/document.h"
+#include "utils/utils.h"
+
+static struct dom_element_protected_vtable _protect_vtable = {
+ {
+ DOM_NODE_PROTECT_VTABLE_HTML_BODY_ELEMENT
+ },
+ DOM_HTML_BODY_ELEMENT_PROTECT_VTABLE
+};
+
+/**
+ * Create a dom_html_body_element object
+ *
+ * \param doc The document object
+ * \param ele The returned element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_body_element_create(struct dom_document *doc,
+ struct dom_html_body_element **ele)
+{
+ *ele = _dom_document_alloc(doc, NULL, sizeof(dom_html_body_element));
+ if (*ele == NULL)
+ return DOM_NO_MEM_ERR;
+
+ /* Set up vtables */
+ struct dom_node_internal *node = (struct dom_node_internal *) *ele;
+ node->base.vtable = &_dom_element_vtable;
+ node->vtable = &_protect_vtable;
+
+ return _dom_html_body_element_initialise(doc, *ele);
+}
+
+/**
+ * Initialise a dom_html_body_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_body_element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_body_element_initialise(struct dom_document *doc,
+ struct dom_html_body_element *ele)
+{
+ const char *str = "BODY";
+ lwc_string *name = NULL;
+ dom_exception err;
+
+ err = _dom_document_create_lwcstring(doc, (const uint8_t *) str, SLEN(str),
+ &name);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
+ _dom_document_unref_lwcstring(doc, name);
+
+ return err;
+}
+
+/**
+ * Finalise a dom_html_body_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_body_element object
+ */
+void _dom_html_body_element_finalise(struct dom_document *doc,
+ struct dom_html_body_element *ele)
+{
+ _dom_html_element_finalise(doc, &ele->base);
+}
+
+/**
+ * Destroy a dom_html_body_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_body_element object
+ */
+void _dom_html_body_element_destroy(struct dom_document *doc,
+ struct dom_html_body_element *ele)
+{
+ _dom_html_body_element_finalise(doc, ele);
+ _dom_document_alloc(doc, ele, 0);
+}
+
+/*------------------------------------------------------------------------*/
+/* The protected virtual functions */
+
+/* The virtual function used to parse attribute value, see src/core/element.c
+ * for detail */
+dom_exception _dom_html_body_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed)
+{
+ UNUSED(ele);
+ UNUSED(name);
+
+ dom_string_ref(value);
+ *parsed = value;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual destroy function, see src/core/node.c for detail */
+void _dom_virtual_html_body_element_destroy(dom_node_internal *node)
+{
+ struct dom_document *doc = dom_node_get_owner(node);
+ _dom_html_body_element_destroy(doc, (struct dom_html_body_element *) node);
+}
+
+/* The virtual allocation function, see src/core/node.c for detail */
+dom_exception _dom_html_body_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(n);
+
+ *ret = _dom_document_alloc(doc, NULL, sizeof(dom_html_body_element));
+ if (*ret == NULL)
+ return DOM_NO_MEM_ERR;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual copy function, see src/core/node.c for detail */
+dom_exception _dom_html_body_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ return _dom_html_element_copy(new, old);
+}
+
diff --git a/src/html/html_body_element.h b/src/html/html_body_element.h
new file mode 100644
index 0000000..e62ff78
--- a/dev/null
+++ b/src/html/html_body_element.h
@@ -0,0 +1,55 @@
+/*
+ * 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.com>
+ */
+
+#ifndef dom_internal_html_body_element_h_
+#define dom_internal_html_body_element_h_
+
+#include <dom/html/html_body_element.h>
+
+#include "html/html_element.h"
+
+struct dom_html_body_element {
+ struct dom_html_element base;
+ /**< The base class */
+};
+
+/* Create a dom_html_body_element object */
+dom_exception _dom_html_body_element_create(struct dom_document *doc,
+ struct dom_html_body_element **ele);
+
+/* Initialise a dom_html_body_element object */
+dom_exception _dom_html_body_element_initialise(struct dom_document *doc,
+ struct dom_html_body_element *ele);
+
+/* Finalise a dom_html_body_element object */
+void _dom_html_body_element_finalise(struct dom_document *doc,
+ struct dom_html_body_element *ele);
+
+/* Destroy a dom_html_body_element object */
+void _dom_html_body_element_destroy(struct dom_document *doc,
+ struct dom_html_body_element *ele);
+
+/* The protected virtual functions */
+dom_exception _dom_html_body_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed);
+void _dom_virtual_html_body_element_destroy(dom_node_internal *node);
+dom_exception _dom_html_body_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_html_body_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+#define DOM_HTML_BODY_ELEMENT_PROTECT_VTABLE \
+ _dom_html_body_element_parse_attribute
+
+#define DOM_NODE_PROTECT_VTABLE_HTML_BODY_ELEMENT \
+ _dom_virtual_html_body_element_destroy, \
+ _dom_html_body_element_alloc, \
+ _dom_html_body_element_copy
+
+#endif
+
diff --git a/src/html/html_br_element.c b/src/html/html_br_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_br_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_br_element.h b/src/html/html_br_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_br_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_button_element.c b/src/html/html_button_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_button_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_button_element.h b/src/html/html_button_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_button_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_collection.c b/src/html/html_collection.c
new file mode 100644
index 0000000..e0c96b9
--- a/dev/null
+++ b/src/html/html_collection.c
@@ -0,0 +1,300 @@
+/*
+ * 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>
+ */
+
+#include <assert.h>
+
+#include <libwapcaplet/libwapcaplet.h>
+
+#include "html/html_collection.h"
+
+#include "core/node.h"
+#include "core/document.h"
+#include "core/element.h"
+#include "core/string.h"
+
+/*-----------------------------------------------------------------------*/
+/* Constructor and destructor */
+
+/**
+ * Create a dom_html_collection
+ *
+ * \param doc The document
+ * \param root The root element of the collection
+ * \param ic The callback function used to determin whether certain node
+ * belongs to the collection
+ * \param col The result collection object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_collection_create(struct dom_document *doc,
+ struct dom_node_internal *root,
+ dom_callback_is_in_collection ic,
+ struct dom_html_collection **col)
+{
+ *col = _dom_document_alloc(doc, NULL, sizeof(dom_html_collection));
+ if (*col == NULL)
+ return DOM_NO_MEM_ERR;
+
+ return _dom_html_collection_initialise(doc, *col, root, ic);
+}
+
+/**
+ * Intialiase a dom_html_collection
+ *
+ * \param doc The document
+ * \param col The collection object to be initialised
+ * \param root The root element of the collection
+ * \param ic The callback function used to determin whether certain node
+ * belongs to the collection
+ * \return DOM_NO_ERR on success.
+ */
+dom_exception _dom_html_collection_initialise(struct dom_document *doc,
+ struct dom_html_collection *col,
+ struct dom_node_internal *root,
+ dom_callback_is_in_collection ic)
+{
+ assert(doc != NULL);
+ assert(ic != NULL);
+ assert(root != NULL);
+
+ col->doc = doc;
+ dom_node_ref(doc);
+
+ col->root = root;
+ dom_node_ref(root);
+
+ col->ic = ic;
+ col->refcnt = 1;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Finalise a dom_html_collection object
+ *
+ * \param col The dom_html_collection object
+ */
+void _dom_html_collection_finalise(struct dom_html_collection *col)
+{
+ dom_node_unref(col->doc);
+ col->doc = NULL;
+
+ dom_node_unref(col->root);
+ col->root = NULL;
+
+ col->ic = NULL;
+}
+
+/**
+ * Destroy a dom_html_collection object
+ * \param col The dom_html_collection object
+ */
+void _dom_html_collection_destroy(struct dom_html_collection *col)
+{
+ struct dom_document *doc = col->doc;
+ _dom_html_collection_finalise(col);
+
+ _dom_document_alloc(doc, col, 0);
+}
+
+
+/*-----------------------------------------------------------------------*/
+/* Public API */
+
+/**
+ * Get the length of this dom_html_collection
+ *
+ * \param col The dom_html_collection object
+ * \param len The returned length of this collection
+ * \return DOM_NO_ERR on success.
+ */
+dom_exception dom_html_collection_get_length(dom_html_collection *col,
+ unsigned long *len)
+{
+ struct dom_node_internal *node = col->root;
+ *len = 0;
+
+ while (node != NULL) {
+ if (node->type == DOM_ELEMENT_NODE && col->ic(node) == true)
+ (*len)++;
+
+ /* Depth first iterating */
+ if (node->first_child != NULL) {
+ node = node->first_child;
+ } else if (node->next != NULL) {
+ node = node->next;
+ } else {
+ /* No children and siblings */
+ struct dom_node_internal *parent = node->parent;
+
+ while (parent != col->root &&
+ node == parent->last_child) {
+ node = parent;
+ parent = parent->parent;
+ }
+
+ if (parent == col->root)
+ node = NULL;
+ else
+ node = node->next;
+ }
+ }
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Get the node with certain index
+ *
+ * \param col The dom_html_collection object
+ * \param index The index number based on zero
+ * \param node The returned node object
+ * \return DOM_NO_ERR on success.
+ */
+dom_exception dom_html_collection_item(dom_html_collection *col,
+ unsigned long index, struct dom_node **node)
+{
+ struct dom_node_internal *n = col->root;
+ unsigned long len = 0;
+
+ while (n != NULL) {
+ if (n->type == DOM_ELEMENT_NODE && col->ic(n) == true)
+ len++;
+
+ if (len == index + 1) {
+ dom_node_ref(n);
+ *node = (struct dom_node *) n;
+ return DOM_NO_ERR;
+ }
+
+ /* Depth first iterating */
+ if (n->first_child != NULL) {
+ n = n->first_child;
+ } else if (n->next != NULL) {
+ n = n->next;
+ } else {
+ /* No children and siblings */
+ struct dom_node_internal *parent = n->parent;
+
+ while (parent != col->root &&
+ n == parent->last_child) {
+ n = parent;
+ parent = parent->parent;
+ }
+
+ if (parent == col->root)
+ n = NULL;
+ else
+ n = n->next;
+ }
+ }
+
+ /* Not find the node */
+ *node = NULL;
+ return DOM_NO_ERR;
+}
+
+/**
+ * Get the node in the collection according name
+ *
+ * \param col The collection
+ * \param name The name of target node
+ * \param node The returned node object
+ * \return DOM_NO_ERR on success.
+ */
+dom_exception dom_html_collection_named_item(dom_html_collection *col,
+ struct dom_string *name, struct dom_node **node)
+{
+ struct dom_node_internal *n = col->root;
+ dom_exception err;
+ lwc_string *str = NULL;
+ err = _dom_node_get_intern_string(n, name, &str);
+ if (err != DOM_NO_ERR)
+ return err;
+
+
+ while (node != NULL) {
+ if (n->type == DOM_ELEMENT_NODE && col->ic(n) == true) {
+ lwc_string *id = NULL;
+ err = _dom_element_get_id((struct dom_element *) n,
+ &id);
+ if (err != DOM_NO_ERR) {
+ _dom_node_unref_intern_string(n, id);
+ return err;
+ }
+
+ /* Compare the lwc_string directly */
+ if (str == id) {
+ *node = (struct dom_node *) n;
+ dom_node_ref(n);
+ _dom_node_unref_intern_string(n, id);
+ _dom_node_unref_intern_string(n, str);
+
+ return DOM_NO_ERR;
+ }
+
+ _dom_node_unref_intern_string(n, id);
+ }
+
+ /* Depth first iterating */
+ if (n->first_child != NULL) {
+ n = n->first_child;
+ } else if (n->next != NULL) {
+ n = n->next;
+ } else {
+ /* No children and siblings */
+ struct dom_node_internal *parent = n->parent;
+
+ while (parent != col->root &&
+ n == parent->last_child) {
+ n = parent;
+ parent = parent->parent;
+ }
+
+ if (parent == col->root)
+ n = NULL;
+ else
+ n = n->next;
+ }
+ }
+
+ /* Not found the target node */
+ *node = NULL;
+ _dom_node_unref_intern_string(n, str);
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Claim a reference on this collection
+ *
+ * \pram col The collection object
+ */
+void dom_html_collection_ref(dom_html_collection *col)
+{
+ if (col == NULL)
+ return;
+
+ col->refcnt ++;
+}
+
+/**
+ * Relese a reference on this collection
+ *
+ * \pram col The collection object
+ */
+void dom_html_collection_unref(dom_html_collection *col)
+{
+ if (col == NULL)
+ return;
+
+ if (col->refcnt > 0)
+ col->refcnt --;
+
+ if (col->refcnt == 0)
+ _dom_html_collection_destroy(col);
+}
+
diff --git a/src/html/html_collection.h b/src/html/html_collection.h
new file mode 100644
index 0000000..dc9e67d
--- a/dev/null
+++ b/src/html/html_collection.h
@@ -0,0 +1,50 @@
+/*
+ * 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_html_collection_h_
+#define dom_internal_html_collection_h_
+
+#include <dom/html/html_collection.h>
+
+struct dom_node_internal;
+
+typedef bool (*dom_callback_is_in_collection)(struct dom_node_internal *node);
+
+/**
+ * The html_collection structure
+ */
+struct dom_html_collection {
+ dom_callback_is_in_collection ic;
+ /**< The function pointer used to test
+ * whether some node is an element of
+ * this collection
+ */
+ struct dom_document *doc; /**< The document created this
+ * collection
+ */
+ struct dom_node_internal *root;
+ /**< The root node of this collection */
+ uint32_t refcnt;
+ /**< Reference counting */
+};
+
+dom_exception _dom_html_collection_create(struct dom_document *doc,
+ struct dom_node_internal *root,
+ dom_callback_is_in_collection ic,
+ struct dom_html_collection **col);
+
+dom_exception _dom_html_collection_initialise(struct dom_document *doc,
+ struct dom_html_collection *col,
+ struct dom_node_internal *root,
+ dom_callback_is_in_collection ic);
+
+void _dom_html_collection_finalise(struct dom_html_collection *col);
+
+void _dom_html_collection_destroy(struct dom_html_collection *col);
+
+#endif
+
diff --git a/src/html/html_directory_element.c b/src/html/html_directory_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_directory_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_directory_element.h b/src/html/html_directory_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_directory_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_div_element.c b/src/html/html_div_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_div_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_div_element.h b/src/html/html_div_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_div_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_dlist_element.c b/src/html/html_dlist_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_dlist_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_dlist_element.h b/src/html/html_dlist_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_dlist_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_document.c b/src/html/html_document.c
new file mode 100644
index 0000000..d62714e
--- a/dev/null
+++ b/src/html/html_document.c
@@ -0,0 +1,118 @@
+/*
+ * 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>
+ */
+
+#include <assert.h>
+
+#include "html/html_document.h"
+
+#include "core/string.h"
+#include "utils/utils.h"
+
+/* Create a HTMLDocument */
+dom_exception dom_html_document_create(dom_alloc alloc, void *pw, dom_msg msg,
+ void *msg_pw,
+ dom_events_default_action_fetcher daf, dom_ui_handler ui,
+ dom_parser_type pt, dom_html_document **doc)
+{
+ assert(alloc != NULL);
+ *doc = alloc(NULL, sizeof(dom_html_document), pw);
+ if (*doc == NULL)
+ return DOM_NO_MEM_ERR;
+
+ return _dom_html_document_initialise(*doc, alloc, pw, msg, msg_pw,
+ daf, ui, pt);
+}
+
+/* Initialise a HTMLDocument */
+dom_exception _dom_html_document_initialise(dom_html_document *doc,
+ dom_alloc alloc, void *pw, dom_msg msg, void *msg_pw,
+ dom_events_default_action_fetcher daf, dom_ui_handler ui,
+ dom_parser_type pt)
+{
+ UNUSED(doc);
+ UNUSED(alloc);
+ UNUSED(pw);
+ UNUSED(msg);
+ UNUSED(msg_pw);
+ UNUSED(daf);
+ UNUSED(ui);
+ UNUSED(pt);
+
+ return DOM_NO_ERR;
+}
+
+/* Finalise a HTMLDocument */
+void _dom_html_document_finalise(dom_html_document *doc);
+/* Destroy a HTMLDocument */
+void _dom_html_document_destroy(dom_html_document *doc);
+
+/* Parse a data chunk into the HTMLDocument */
+dom_exception dom_html_document_write_data(uint8_t *data, size_t len);
+
+/* Notify the HTMLDocument that it is completed */
+dom_exception dom_html_document_complete(void);
+
+/*-----------------------------------------------------------------------*/
+/* The DOM spec public API */
+
+/**
+ * Get the title of this HTMLDocument
+ * \param doc The document object
+ * \param title The reutrned title string
+ * \return DOM_NO_ERR on success, appropriated dom_exception on failure.
+ *
+ * @note: this method find a title for the document as following:
+ * 1. If there is a title in the document object set by
+ * dom_html_document_set_title, then use it;
+ * 2. If there is no such one, find the <title> element and use its text
+ * as the returned title.
+ */
+dom_exception dom_html_document_get_title(dom_html_document *doc,
+ struct dom_string **title)
+{
+ UNUSED(doc);
+ UNUSED(title);
+
+ return DOM_NO_ERR;
+}
+
+dom_exception dom_html_document_set_title(dom_html_document *doc,
+ struct dom_string *title);
+dom_exception dom_html_document_get_referer(dom_html_document *doc,
+ struct dom_string **referer);
+dom_exception dom_html_document_get_domain(dom_html_document *doc,
+ struct dom_string **domain);
+dom_exception dom_html_document_get_url(dom_html_document *doc,
+ struct dom_string **url);
+dom_exception dom_html_document_get_body(dom_html_document *doc,
+ struct dom_html_element **body);
+dom_exception dom_html_document_set_body(dom_html_document *doc,
+ struct dom_html_element *body);
+dom_exception dom_html_document_get_images(dom_html_document *doc,
+ struct dom_html_collection **col);
+dom_exception dom_html_document_get_applets(dom_html_document *doc,
+ struct dom_html_collection **col);
+dom_exception dom_html_document_get_links(dom_html_document *doc,
+ struct dom_html_collection **col);
+dom_exception dom_html_document_get_forms(dom_html_document *doc,
+ struct dom_html_collection **col);
+dom_exception dom_html_document_get_anchors(dom_html_document *doc,
+ struct dom_html_collection **col);
+dom_exception dom_html_document_get_cookie(dom_html_document *doc,
+ struct dom_string **cookie);
+dom_exception dom_html_document_set_cookie(dom_html_document *doc,
+ struct dom_string *cookie);
+
+dom_exception dom_html_document_open(dom_html_document *doc);
+dom_exception dom_html_document_close(dom_html_document *doc);
+dom_exception dom_html_document_write(dom_html_document *doc,
+ struct dom_string *text);
+dom_exception dom_html_document_writeln(dom_html_document *doc,
+ struct dom_string *text);
+dom_exception dom_html_document_get_elements_by_name(dom_html_document *doc,
+ struct dom_string *name, struct dom_nodelist **list);
+
diff --git a/src/html/html_document.h b/src/html/html_document.h
new file mode 100644
index 0000000..4abab09
--- a/dev/null
+++ b/src/html/html_document.h
@@ -0,0 +1,47 @@
+/*
+ * 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_html_document_h_
+#define dom_internal_html_document_h_
+
+#include <dom/html/html_document.h>
+
+#include "core/document.h"
+
+struct dom_hubbub_parser;
+struct dom_xml_parser;
+
+/**
+ * The dom_html_document class
+ */
+struct dom_html_document {
+ struct dom_document base; /**< The base class */
+ union {
+ struct dom_hubbub_parser *hp;
+ struct dom_xml_parser *xp;
+ } parser;
+ /**< The underlaying parser of this document */
+
+ struct dom_string *title; /**< HTML document title */
+ struct dom_string *referer; /**< HTML document referer */
+ struct dom_string *domain; /**< HTML document domain */
+ struct dom_string *url; /**< HTML document URL */
+ struct dom_string *cookie; /**< HTML document cookie */
+};
+
+/* Initialise a HTMLDocument */
+dom_exception _dom_html_document_initialise(dom_html_document *doc,
+ dom_alloc alloc, void *pw, dom_msg msg, void *msg_pw,
+ dom_events_default_action_fetcher daf, dom_ui_handler ui,
+ dom_parser_type pt);
+/* Finalise a HTMLDocument */
+void _dom_html_document_finalise(dom_html_document *doc);
+/* Destroy a HTMLDocument */
+void _dom_html_document_destroy(dom_html_document *doc);
+
+#endif
+
diff --git a/src/html/html_element.c b/src/html/html_element.c
new file mode 100644
index 0000000..4610c67
--- a/dev/null
+++ b/src/html/html_element.c
@@ -0,0 +1,207 @@
+/*
+ * 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.com>
+ */
+
+#include <assert.h>
+
+#include "html/html_element.h"
+
+#include "core/node.h"
+#include "core/attr.h"
+#include "core/document.h"
+#include "utils/utils.h"
+
+dom_exception _dom_html_element_initialise(struct dom_document *doc,
+ struct dom_html_element *el, struct lwc_string_s *name,
+ struct lwc_string_s *namespace, struct lwc_string_s *prefix)
+{
+ dom_exception err;
+
+ err = _dom_element_initialise(doc, &el->base, name, namespace, prefix);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ el->form = NULL;
+ return err;
+}
+
+void _dom_html_element_finalise(struct dom_document *doc,
+ struct dom_html_element *ele)
+{
+ dom_node_unref(ele->form);
+ ele->form = NULL;
+
+ _dom_element_finalise(doc, &ele->base);
+}
+
+/*------------------------------------------------------------------------*/
+/* The protected virtual functions */
+
+/* The virtual destroy function, see src/core/node.c for detail */
+void _dom_virtual_html_element_destroy(dom_node_internal *node)
+{
+ UNUSED(node);
+ assert("Should never be here" == NULL);
+}
+
+/* The virtual allocation function, see src/core/node.c for detail */
+dom_exception _dom_html_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(doc);
+ UNUSED(n);
+ UNUSED(ret);
+
+ assert("Should never be here" == NULL);
+
+ return DOM_NO_MEM_ERR;
+}
+
+/* The virtual copy function, see src/core/node.c for detail */
+dom_exception _dom_html_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ return _dom_element_copy(new, old);
+}
+
+/*-----------------------------------------------------------------------*/
+/* Common functions */
+
+/**
+ * Get the a bool property
+ *
+ * \param ele The dom_html_element object
+ * \param name The name of the attribute
+ * \param len The length of ::name
+ * \param has The returned status
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_html_element_get_bool_property(dom_html_element *ele,
+ const char *name, unsigned long len, bool *has)
+{
+ dom_document *doc = dom_node_get_owner(ele);
+ dom_string *str = NULL;
+ dom_attr *a = NULL;
+ dom_exception err;
+
+ err = _dom_document_create_string(doc, (const uint8_t *) name,
+ len, &str);
+ if (err != DOM_NO_ERR)
+ goto fail;
+
+ err = dom_element_get_attribute_node(ele, str, &a);
+ if (err != DOM_NO_ERR)
+ goto cleanup1;
+
+ if (a != NULL) {
+ *has = true;
+ } else {
+ *has = false;
+ }
+
+ dom_node_unref(a);
+
+cleanup1:
+ dom_string_unref(str);
+
+fail:
+ return err;
+}
+
+/**
+ * Set a bool property
+ *
+ * \param ele The dom_html_element object
+ * \param name The name of the attribute
+ * \param len The length of ::name
+ * \param has The status
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_html_element_set_bool_property(dom_html_element *ele,
+ const char *name, unsigned long len, bool has)
+{
+ dom_document *doc = dom_node_get_owner(ele);
+ dom_string *str = NULL;
+ dom_attr *a = NULL;
+ dom_exception err;
+
+ err = _dom_document_create_string(doc, (const uint8_t *) name,
+ len, &str);
+ if (err != DOM_NO_ERR)
+ goto fail;
+
+ err = dom_element_get_attribute_node(ele, str, &a);
+ if (err != DOM_NO_ERR)
+ goto cleanup1;
+
+ if (a != NULL && has == false) {
+ dom_attr *res = NULL;
+
+ err = dom_element_remove_attribute_node(ele, a, &res);
+ if (err != DOM_NO_ERR)
+ goto cleanup2;
+
+ dom_node_unref(res);
+ } else if (a == NULL && has == true) {
+ dom_attr *res = NULL;
+ lwc_string *lstr = NULL;
+
+ err = _dom_string_intern(str, &lstr);
+ if (err != DOM_NO_ERR)
+ goto cleanup1;
+
+ err = _dom_attr_create(doc, lstr, NULL, NULL, true, &a);
+ if (err != DOM_NO_ERR) {
+ lwc_string_unref(lstr);
+ goto cleanup1;
+ }
+ lwc_string_unref(lstr);
+
+ err = dom_element_set_attribute_node(ele, a, &res);
+ if (err != DOM_NO_ERR)
+ goto cleanup2;
+
+ dom_node_unref(res);
+ }
+
+cleanup2:
+ dom_node_unref(a);
+
+cleanup1:
+ dom_string_unref(str);
+
+fail:
+ return err;
+}
+
+/**
+ * Get the form element if this element is a form control
+ *
+ * \param ele The element object
+ * \param form The form object
+ */
+void _dom_html_element_get_form(dom_html_element *ele,
+ struct dom_html_form_element **form)
+{
+ *form = ele->form;
+ dom_node_ref(*form);
+}
+
+/**
+ * Set the form element if this element is a form control
+ *
+ * \param ele The element object
+ * \param form The form object
+ */
+void _dom_html_element_associate_form(dom_html_element *ele,
+ struct dom_html_form_element *form)
+{
+ /* Unref the form if there is any */
+ dom_node_unref(form);
+ ele->form = form;
+ dom_node_ref(form);
+}
+
diff --git a/src/html/html_element.h b/src/html/html_element.h
new file mode 100644
index 0000000..430dac4
--- a/dev/null
+++ b/src/html/html_element.h
@@ -0,0 +1,58 @@
+/*
+ * 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_html_element_h_
+#define dom_internal_html_element_h_
+
+#include <dom/html/html_element.h>
+
+#include "core/element.h"
+
+struct dom_html_form_element;
+
+/**
+ * The dom_html_element class
+ *
+ * Note: For now, there is no new members and methods in this class,
+ * but in future, we may add common abstracted functions from child class
+ * to here.
+ */
+struct dom_html_element {
+ struct dom_element base;
+ /**< The base class */
+ struct dom_html_form_element *form;
+ /**< The form element which contains this element if
+ * this element is a form control
+ */
+};
+
+dom_exception _dom_html_element_initialise(struct dom_document *doc,
+ struct dom_html_element *el, struct lwc_string_s *name,
+ struct lwc_string_s *namespace, struct lwc_string_s *prefix);
+
+void _dom_html_element_finalise(struct dom_document *doc,
+ struct dom_html_element *ele);
+
+/* The protected virtual functions */
+void _dom_virtual_html_element_destroy(dom_node_internal *node);
+dom_exception _dom_html_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_html_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+/* Some common functions used by all child classes */
+dom_exception dom_html_element_get_bool_property(dom_html_element *ele,
+ const char *name, unsigned long len, bool *has);
+dom_exception dom_html_element_set_bool_property(dom_html_element *ele,
+ const char *name, unsigned long len, bool has);
+void _dom_html_element_get_form(dom_html_element *ele,
+ struct dom_html_form_element **form);
+void _dom_html_element_associate_form(dom_html_element *ele,
+ struct dom_html_form_element *form);
+
+#endif
+
diff --git a/src/html/html_fieldset_element.c b/src/html/html_fieldset_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_fieldset_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_fieldset_element.h b/src/html/html_fieldset_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_fieldset_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_font_element.c b/src/html/html_font_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_font_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_font_element.h b/src/html/html_font_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_font_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_form_element.c b/src/html/html_form_element.c
new file mode 100644
index 0000000..7c0e9af
--- a/dev/null
+++ b/src/html/html_form_element.c
@@ -0,0 +1,256 @@
+/*
+ * 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.com>
+ */
+
+#include <assert.h>
+
+#include "html/html_form_element.h"
+
+#include "html/html_collection.h"
+
+#include "core/node.h"
+#include "core/document.h"
+#include "utils/utils.h"
+
+static struct dom_element_protected_vtable _protect_vtable = {
+ {
+ DOM_NODE_PROTECT_VTABLE_HTML_FORM_ELEMENT
+ },
+ DOM_HTML_FORM_ELEMENT_PROTECT_VTABLE
+};
+
+static bool _dom_is_form_control(struct dom_node_internal *node);
+
+/**
+ * Create a dom_html_form_element object
+ *
+ * \param doc The document object
+ * \param ele The returned element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_form_element_create(struct dom_document *doc,
+ struct dom_html_form_element **ele)
+{
+ *ele = _dom_document_alloc(doc, NULL, sizeof(dom_html_form_element));
+ if (*ele == NULL)
+ return DOM_NO_MEM_ERR;
+
+ /* Set up vtables */
+ struct dom_node_internal *node = (struct dom_node_internal *) *ele;
+ node->base.vtable = &_dom_element_vtable;
+ node->vtable = &_protect_vtable;
+
+ return _dom_html_form_element_initialise(doc, *ele);
+}
+
+/**
+ * Initialise a dom_html_form_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_form_element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_form_element_initialise(struct dom_document *doc,
+ struct dom_html_form_element *ele)
+{
+ const char *str = "FORM";
+ lwc_string *name = NULL;
+ dom_exception err;
+
+ err = _dom_document_create_lwcstring(doc, (const uint8_t *) str, SLEN(str),
+ &name);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
+ _dom_document_unref_lwcstring(doc, name);
+
+ ele->col = NULL;
+
+ return err;
+}
+
+/**
+ * Finalise a dom_html_form_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_form_element object
+ */
+void _dom_html_form_element_finalise(struct dom_document *doc,
+ struct dom_html_form_element *ele)
+{
+ _dom_html_element_finalise(doc, &ele->base);
+}
+
+/**
+ * Destroy a dom_html_form_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_form_element object
+ */
+void _dom_html_form_element_destroy(struct dom_document *doc,
+ struct dom_html_form_element *ele)
+{
+ _dom_html_form_element_finalise(doc, ele);
+ _dom_document_alloc(doc, ele, 0);
+}
+
+/*------------------------------------------------------------------------*/
+/* The protected virtual functions */
+
+/* The virtual function used to parse attribute value, see src/core/element.c
+ * for detail */
+dom_exception _dom_html_form_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed)
+{
+ UNUSED(ele);
+ UNUSED(name);
+
+ dom_string_ref(value);
+ *parsed = value;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual destroy function, see src/core/node.c for detail */
+void _dom_virtual_html_form_element_destroy(dom_node_internal *node)
+{
+ struct dom_document *doc = dom_node_get_owner(node);
+ _dom_html_form_element_destroy(doc, (struct dom_html_form_element *) node);
+}
+
+/* The virtual allocation function, see src/core/node.c for detail */
+dom_exception _dom_html_form_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(n);
+
+ *ret = _dom_document_alloc(doc, NULL, sizeof(dom_html_form_element));
+ if (*ret == NULL)
+ return DOM_NO_MEM_ERR;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual copy function, see src/core/node.c for detail */
+dom_exception _dom_html_form_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ return _dom_html_element_copy(new, old);
+}
+
+/*-----------------------------------------------------------------------*/
+/* Public APIs */
+
+/**
+ * Get the form controls under this form element
+ *
+ * \param ele The form object
+ * \param col The collection of form controls
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_html_form_element_get_elements(dom_html_form_element *ele,
+ struct dom_html_collection **col)
+{
+ dom_exception err;
+
+ if (ele->col == NULL) {
+ dom_document *doc = dom_node_get_owner(ele);
+ assert(doc != NULL);
+ err = _dom_html_collection_create(doc,
+ (dom_node_internal *) ele,
+ _dom_is_form_control, col);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ ele->col = *col;
+ }
+
+ *col = ele->col;
+ dom_html_collection_ref(*col);
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Get the number of form controls under this form element
+ *
+ * \param ele The form object
+ * \param len The number of controls
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_html_form_element_get_length(dom_html_form_element *ele,
+ unsigned long *len)
+{
+ dom_exception err;
+
+ if (ele->col == NULL) {
+ dom_document *doc = dom_node_get_owner(ele);
+ assert(doc != NULL);
+ err = _dom_html_collection_create(doc,
+ (dom_node_internal *) ele,
+ _dom_is_form_control, &ele->col);
+ if (err != DOM_NO_ERR)
+ return err;
+ }
+
+ return dom_html_collection_get_length(ele->col, len);
+}
+
+/**
+ * Submit this form
+ *
+ * \param ele The form object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_html_form_element_submit(dom_html_form_element *ele)
+{
+ struct dom_document *doc = dom_node_get_owner(ele);
+ bool success = false;
+ assert(doc != NULL);
+
+ /* Dispatch an event and let the default action handler to deal with
+ * the submit action, and a 'submit' event is bubbling and cancelable
+ */
+ return _dom_dispatch_generic_event(doc, (dom_event_target *) ele,
+ (const uint8_t *) "submit", SLEN("submit"), true,
+ true, &success);
+}
+
+/**
+ * Reset this form
+ *
+ * \param ele The form object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_html_form_element_reset(dom_html_form_element *ele)
+{
+ struct dom_document *doc = dom_node_get_owner(ele);
+ bool success = false;
+ assert(doc != NULL);
+
+ /* Dispatch an event and let the default action handler to deal with
+ * the reset action, and a 'reset' event is bubbling and cancelable
+ */
+ return _dom_dispatch_generic_event(doc, (dom_event_target *) ele,
+ (const uint8_t *) "reset", SLEN("reset"), true,
+ true, &success);
+}
+
+/*-----------------------------------------------------------------------*/
+/* Internal functions */
+
+/* Callback function to test whether certain node is a form control, see
+ * src/html/html_collection.h for detail. */
+static bool _dom_is_form_control(struct dom_node_internal *node)
+{
+ assert(node->type == DOM_ELEMENT_NODE);
+ dom_html_element *ele = (dom_html_element *) node;
+
+ return ele->form != NULL;
+}
+
diff --git a/src/html/html_form_element.h b/src/html/html_form_element.h
new file mode 100644
index 0000000..9b8105d
--- a/dev/null
+++ b/src/html/html_form_element.h
@@ -0,0 +1,59 @@
+/*
+ * 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.com>
+ */
+
+#ifndef dom_internal_html_form_element_h_
+#define dom_internal_html_form_element_h_
+
+#include <dom/html/html_form_element.h>
+
+#include "html/html_element.h"
+
+struct dom_html_collection;
+
+struct dom_html_form_element {
+ struct dom_html_element base;
+ /**< The base class */
+ struct dom_html_collection *col;
+ /**< The collection of form controls */
+};
+
+/* Create a dom_html_form_element object */
+dom_exception _dom_html_form_element_create(struct dom_document *doc,
+ struct dom_html_form_element **ele);
+
+/* Initialise a dom_html_form_element object */
+dom_exception _dom_html_form_element_initialise(struct dom_document *doc,
+ struct dom_html_form_element *ele);
+
+/* Finalise a dom_html_form_element object */
+void _dom_html_form_element_finalise(struct dom_document *doc,
+ struct dom_html_form_element *ele);
+
+/* Destroy a dom_html_form_element object */
+void _dom_html_form_element_destroy(struct dom_document *doc,
+ struct dom_html_form_element *ele);
+
+/* The protected virtual functions */
+dom_exception _dom_html_form_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed);
+void _dom_virtual_html_form_element_destroy(dom_node_internal *node);
+dom_exception _dom_html_form_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_html_form_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+#define DOM_HTML_FORM_ELEMENT_PROTECT_VTABLE \
+ _dom_html_form_element_parse_attribute
+
+#define DOM_NODE_PROTECT_VTABLE_HTML_FORM_ELEMENT \
+ _dom_virtual_html_form_element_destroy, \
+ _dom_html_form_element_alloc, \
+ _dom_html_form_element_copy
+
+#endif
+
diff --git a/src/html/html_frame_element.c b/src/html/html_frame_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_frame_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_frame_element.h b/src/html/html_frame_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_frame_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_frameset_element.c b/src/html/html_frameset_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_frameset_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_frameset_element.h b/src/html/html_frameset_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_frameset_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_head_element.c b/src/html/html_head_element.c
new file mode 100644
index 0000000..9ab53b6
--- a/dev/null
+++ b/src/html/html_head_element.c
@@ -0,0 +1,137 @@
+/*
+ * 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.com>
+ */
+
+#include "html/html_head_element.h"
+
+#include "core/node.h"
+#include "core/document.h"
+#include "utils/utils.h"
+
+static struct dom_element_protected_vtable _protect_vtable = {
+ {
+ DOM_NODE_PROTECT_VTABLE_HTML_HEAD_ELEMENT
+ },
+ DOM_HTML_HEAD_ELEMENT_PROTECT_VTABLE
+};
+
+/**
+ * Create a dom_html_head_element object
+ *
+ * \param doc The document object
+ * \param ele The returned element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_head_element_create(struct dom_document *doc,
+ struct dom_html_head_element **ele)
+{
+ *ele = _dom_document_alloc(doc, NULL, sizeof(dom_html_head_element));
+ if (*ele == NULL)
+ return DOM_NO_MEM_ERR;
+
+ /* Set up vtables */
+ struct dom_node_internal *node = (struct dom_node_internal *) *ele;
+ node->base.vtable = &_dom_element_vtable;
+ node->vtable = &_protect_vtable;
+
+ return _dom_html_head_element_initialise(doc, *ele);
+}
+
+/**
+ * Initialise a dom_html_head_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_head_element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_head_element_initialise(struct dom_document *doc,
+ struct dom_html_head_element *ele)
+{
+ const char *str = "HEAD";
+ lwc_string *name = NULL;
+ dom_exception err;
+
+ err = _dom_document_create_lwcstring(doc, (const uint8_t *) str, SLEN(str),
+ &name);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
+ _dom_document_unref_lwcstring(doc, name);
+
+ return err;
+}
+
+/**
+ * Finalise a dom_html_head_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_head_element object
+ */
+void _dom_html_head_element_finalise(struct dom_document *doc,
+ struct dom_html_head_element *ele)
+{
+ _dom_html_element_finalise(doc, &ele->base);
+}
+
+/**
+ * Destroy a dom_html_head_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_head_element object
+ */
+void _dom_html_head_element_destroy(struct dom_document *doc,
+ struct dom_html_head_element *ele)
+{
+ _dom_html_head_element_finalise(doc, ele);
+ _dom_document_alloc(doc, ele, 0);
+}
+
+/*------------------------------------------------------------------------*/
+/* The protected virtual functions */
+
+/* The virtual function used to parse attribute value, see src/core/element.c
+ * for detail */
+dom_exception _dom_html_head_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed)
+{
+ UNUSED(ele);
+ UNUSED(name);
+
+ dom_string_ref(value);
+ *parsed = value;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual destroy function, see src/core/node.c for detail */
+void _dom_virtual_html_head_element_destroy(dom_node_internal *node)
+{
+ struct dom_document *doc = dom_node_get_owner(node);
+ _dom_html_head_element_destroy(doc, (struct dom_html_head_element *) node);
+}
+
+/* The virtual allocation function, see src/core/node.c for detail */
+dom_exception _dom_html_head_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(n);
+
+ *ret = _dom_document_alloc(doc, NULL, sizeof(dom_html_head_element));
+ if (*ret == NULL)
+ return DOM_NO_MEM_ERR;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual copy function, see src/core/node.c for detail */
+dom_exception _dom_html_head_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ return _dom_html_element_copy(new, old);
+}
+
diff --git a/src/html/html_head_element.h b/src/html/html_head_element.h
new file mode 100644
index 0000000..d92c656
--- a/dev/null
+++ b/src/html/html_head_element.h
@@ -0,0 +1,55 @@
+/*
+ * 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.com>
+ */
+
+#ifndef dom_internal_html_head_element_h_
+#define dom_internal_html_head_element_h_
+
+#include <dom/html/html_head_element.h>
+
+#include "html/html_element.h"
+
+struct dom_html_head_element {
+ struct dom_html_element base;
+ /**< The base class */
+};
+
+/* Create a dom_html_head_element object */
+dom_exception _dom_html_head_element_create(struct dom_document *doc,
+ struct dom_html_head_element **ele);
+
+/* Initialise a dom_html_head_element object */
+dom_exception _dom_html_head_element_initialise(struct dom_document *doc,
+ struct dom_html_head_element *ele);
+
+/* Finalise a dom_html_head_element object */
+void _dom_html_head_element_finalise(struct dom_document *doc,
+ struct dom_html_head_element *ele);
+
+/* Destroy a dom_html_head_element object */
+void _dom_html_head_element_destroy(struct dom_document *doc,
+ struct dom_html_head_element *ele);
+
+/* The protected virtual functions */
+dom_exception _dom_html_head_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed);
+void _dom_virtual_html_head_element_destroy(dom_node_internal *node);
+dom_exception _dom_html_head_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_html_head_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+#define DOM_HTML_HEAD_ELEMENT_PROTECT_VTABLE \
+ _dom_html_head_element_parse_attribute
+
+#define DOM_NODE_PROTECT_VTABLE_HTML_HEAD_ELEMENT \
+ _dom_virtual_html_head_element_destroy, \
+ _dom_html_head_element_alloc, \
+ _dom_html_head_element_copy
+
+#endif
+
diff --git a/src/html/html_heading_element.c b/src/html/html_heading_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_heading_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_heading_element.h b/src/html/html_heading_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_heading_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_hr_element.c b/src/html/html_hr_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_hr_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_hr_element.h b/src/html/html_hr_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_hr_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_html_element.c b/src/html/html_html_element.c
new file mode 100644
index 0000000..8e08382
--- a/dev/null
+++ b/src/html/html_html_element.c
@@ -0,0 +1,137 @@
+/*
+ * 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.com>
+ */
+
+#include "html/html_html_element.h"
+
+#include "core/node.h"
+#include "core/document.h"
+#include "utils/utils.h"
+
+static struct dom_element_protected_vtable _protect_vtable = {
+ {
+ DOM_NODE_PROTECT_VTABLE_HTML_HTML_ELEMENT
+ },
+ DOM_HTML_HTML_ELEMENT_PROTECT_VTABLE
+};
+
+/**
+ * Create a dom_html_html_element object
+ *
+ * \param doc The document object
+ * \param ele The returned element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_html_element_create(struct dom_document *doc,
+ struct dom_html_html_element **ele)
+{
+ *ele = _dom_document_alloc(doc, NULL, sizeof(dom_html_html_element));
+ if (*ele == NULL)
+ return DOM_NO_MEM_ERR;
+
+ /* Set up vtables */
+ struct dom_node_internal *node = (struct dom_node_internal *) *ele;
+ node->base.vtable = &_dom_element_vtable;
+ node->vtable = &_protect_vtable;
+
+ return _dom_html_html_element_initialise(doc, *ele);
+}
+
+/**
+ * Initialise a dom_html_html_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_html_element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_html_element_initialise(struct dom_document *doc,
+ struct dom_html_html_element *ele)
+{
+ const char *str = "HTML";
+ lwc_string *name = NULL;
+ dom_exception err;
+
+ err = _dom_document_create_lwcstring(doc, (const uint8_t *) str, SLEN(str),
+ &name);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
+ _dom_document_unref_lwcstring(doc, name);
+
+ return err;
+}
+
+/**
+ * Finalise a dom_html_html_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_html_element object
+ */
+void _dom_html_html_element_finalise(struct dom_document *doc,
+ struct dom_html_html_element *ele)
+{
+ _dom_html_element_finalise(doc, &ele->base);
+}
+
+/**
+ * Destroy a dom_html_html_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_html_element object
+ */
+void _dom_html_html_element_destroy(struct dom_document *doc,
+ struct dom_html_html_element *ele)
+{
+ _dom_html_html_element_finalise(doc, ele);
+ _dom_document_alloc(doc, ele, 0);
+}
+
+/*------------------------------------------------------------------------*/
+/* The protected virtual functions */
+
+/* The virtual function used to parse attribute value, see src/core/element.c
+ * for detail */
+dom_exception _dom_html_html_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed)
+{
+ UNUSED(ele);
+ UNUSED(name);
+
+ dom_string_ref(value);
+ *parsed = value;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual destroy function, see src/core/node.c for detail */
+void _dom_virtual_html_html_element_destroy(dom_node_internal *node)
+{
+ struct dom_document *doc = dom_node_get_owner(node);
+ _dom_html_html_element_destroy(doc, (struct dom_html_html_element *) node);
+}
+
+/* The virtual allocation function, see src/core/node.c for detail */
+dom_exception _dom_html_html_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(n);
+
+ *ret = _dom_document_alloc(doc, NULL, sizeof(dom_html_html_element));
+ if (*ret == NULL)
+ return DOM_NO_MEM_ERR;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual copy function, see src/core/node.c for detail */
+dom_exception _dom_html_html_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ return _dom_html_element_copy(new, old);
+}
+
diff --git a/src/html/html_html_element.h b/src/html/html_html_element.h
new file mode 100644
index 0000000..4e81d18
--- a/dev/null
+++ b/src/html/html_html_element.h
@@ -0,0 +1,55 @@
+/*
+ * 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.com>
+ */
+
+#ifndef dom_internal_html_html_element_h_
+#define dom_internal_html_html_element_h_
+
+#include <dom/html/html_html_element.h>
+
+#include "html/html_element.h"
+
+struct dom_html_html_element {
+ struct dom_html_element base;
+ /**< The base class */
+};
+
+/* Create a dom_html_html_element object */
+dom_exception _dom_html_html_element_create(struct dom_document *doc,
+ struct dom_html_html_element **ele);
+
+/* Initialise a dom_html_html_element object */
+dom_exception _dom_html_html_element_initialise(struct dom_document *doc,
+ struct dom_html_html_element *ele);
+
+/* Finalise a dom_html_html_element object */
+void _dom_html_html_element_finalise(struct dom_document *doc,
+ struct dom_html_html_element *ele);
+
+/* Destroy a dom_html_html_element object */
+void _dom_html_html_element_destroy(struct dom_document *doc,
+ struct dom_html_html_element *ele);
+
+/* The protected virtual functions */
+dom_exception _dom_html_html_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed);
+void _dom_virtual_html_html_element_destroy(dom_node_internal *node);
+dom_exception _dom_html_html_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_html_html_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+#define DOM_HTML_HTML_ELEMENT_PROTECT_VTABLE \
+ _dom_html_html_element_parse_attribute
+
+#define DOM_NODE_PROTECT_VTABLE_HTML_HTML_ELEMENT \
+ _dom_virtual_html_html_element_destroy, \
+ _dom_html_html_element_alloc, \
+ _dom_html_html_element_copy
+
+#endif
+
diff --git a/src/html/html_iframe_element.c b/src/html/html_iframe_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_iframe_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_iframe_element.h b/src/html/html_iframe_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_iframe_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_image_element.c b/src/html/html_image_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_image_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_image_element.h b/src/html/html_image_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_image_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_input_element.c b/src/html/html_input_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_input_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_input_element.h b/src/html/html_input_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_input_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_isindex_element.c b/src/html/html_isindex_element.c
new file mode 100644
index 0000000..42db2e5
--- a/dev/null
+++ b/src/html/html_isindex_element.c
@@ -0,0 +1,162 @@
+/*
+ * 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.com>
+ */
+
+#include "html/html_isindex_element.h"
+
+#include "core/node.h"
+#include "core/document.h"
+#include "utils/utils.h"
+
+static struct dom_element_protected_vtable _protect_vtable = {
+ {
+ DOM_NODE_PROTECT_VTABLE_HTML_ISINDEX_ELEMENT
+ },
+ DOM_HTML_ISINDEX_ELEMENT_PROTECT_VTABLE
+};
+
+/**
+ * Create a dom_html_isindex_element object
+ *
+ * \param doc The document object
+ * \param form The form element which contains this element
+ * \param ele The returned element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_isindex_element_create(struct dom_document *doc,
+ struct dom_html_form_element *form,
+ struct dom_html_isindex_element **ele)
+{
+ *ele = _dom_document_alloc(doc, NULL, sizeof(dom_html_isindex_element));
+ if (*ele == NULL)
+ return DOM_NO_MEM_ERR;
+
+ /* Set up vtables */
+ struct dom_node_internal *node = (struct dom_node_internal *) *ele;
+ node->base.vtable = &_dom_element_vtable;
+ node->vtable = &_protect_vtable;
+
+ return _dom_html_isindex_element_initialise(doc, form, *ele);
+}
+
+/**
+ * Initialise a dom_html_isindex_element object
+ *
+ * \param doc The document object
+ * \param form The form element which contains this element
+ * \param ele The dom_html_isindex_element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_isindex_element_initialise(struct dom_document *doc,
+ struct dom_html_form_element *form,
+ struct dom_html_isindex_element *ele)
+{
+ const char *str = "ISINDEX";
+ lwc_string *name = NULL;
+ dom_exception err;
+
+ err = _dom_document_create_lwcstring(doc, (const uint8_t *) str, SLEN(str),
+ &name);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
+ _dom_document_unref_lwcstring(doc, name);
+
+ ele->base.form = form;
+ dom_node_ref(form);
+
+ return err;
+}
+
+/**
+ * Finalise a dom_html_isindex_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_isindex_element object
+ */
+void _dom_html_isindex_element_finalise(struct dom_document *doc,
+ struct dom_html_isindex_element *ele)
+{
+ _dom_html_element_finalise(doc, &ele->base);
+}
+
+/**
+ * Destroy a dom_html_isindex_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_isindex_element object
+ */
+void _dom_html_isindex_element_destroy(struct dom_document *doc,
+ struct dom_html_isindex_element *ele)
+{
+ _dom_html_isindex_element_finalise(doc, ele);
+ _dom_document_alloc(doc, ele, 0);
+}
+
+/*------------------------------------------------------------------------*/
+/* The protected virtual functions */
+
+/* The virtual function used to parse attribute value, see src/core/element.c
+ * for detail */
+dom_exception _dom_html_isindex_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed)
+{
+ UNUSED(ele);
+ UNUSED(name);
+
+ dom_string_ref(value);
+ *parsed = value;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual destroy function, see src/core/node.c for detail */
+void _dom_virtual_html_isindex_element_destroy(dom_node_internal *node)
+{
+ struct dom_document *doc = dom_node_get_owner(node);
+ _dom_html_isindex_element_destroy(doc, (struct dom_html_isindex_element *) node);
+}
+
+/* The virtual allocation function, see src/core/node.c for detail */
+dom_exception _dom_html_isindex_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(n);
+
+ *ret = _dom_document_alloc(doc, NULL, sizeof(dom_html_isindex_element));
+ if (*ret == NULL)
+ return DOM_NO_MEM_ERR;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual copy function, see src/core/node.c for detail */
+dom_exception _dom_html_isindex_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ return _dom_html_element_copy(new, old);
+}
+
+
+/*-----------------------------------------------------------------------*/
+/* Public APIs */
+
+/**
+ * Get the form element which contains this element
+ *
+ * \param ele The dom_html_isindex_element
+ * \param form The form element
+ * \return DOM_NO_ERR on success.
+ */
+dom_exception dom_html_isindex_element_get_form(dom_html_isindex_element *ele,
+ struct dom_html_form_element **form)
+{
+ _dom_html_element_get_form(&ele->base, form);
+
+ return DOM_NO_ERR;
+}
diff --git a/src/html/html_isindex_element.h b/src/html/html_isindex_element.h
new file mode 100644
index 0000000..3aad119
--- a/dev/null
+++ b/src/html/html_isindex_element.h
@@ -0,0 +1,57 @@
+/*
+ * 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.com>
+ */
+
+#ifndef dom_internal_html_isindex_element_h_
+#define dom_internal_html_isindex_element_h_
+
+#include <dom/html/html_isindex_element.h>
+
+#include "html/html_element.h"
+
+struct dom_html_isindex_element {
+ struct dom_html_element base;
+ /**< The base class */
+};
+
+/* Create a dom_html_isindex_element object */
+dom_exception _dom_html_isindex_element_create(struct dom_document *doc,
+ struct dom_html_form_element *form,
+ struct dom_html_isindex_element **ele);
+
+/* Initialise a dom_html_isindex_element object */
+dom_exception _dom_html_isindex_element_initialise(struct dom_document *doc,
+ struct dom_html_form_element *form,
+ struct dom_html_isindex_element *ele);
+
+/* Finalise a dom_html_isindex_element object */
+void _dom_html_isindex_element_finalise(struct dom_document *doc,
+ struct dom_html_isindex_element *ele);
+
+/* Destroy a dom_html_isindex_element object */
+void _dom_html_isindex_element_destroy(struct dom_document *doc,
+ struct dom_html_isindex_element *ele);
+
+/* The protected virtual functions */
+dom_exception _dom_html_isindex_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed);
+void _dom_virtual_html_isindex_element_destroy(dom_node_internal *node);
+dom_exception _dom_html_isindex_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_html_isindex_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+#define DOM_HTML_ISINDEX_ELEMENT_PROTECT_VTABLE \
+ _dom_html_isindex_element_parse_attribute
+
+#define DOM_NODE_PROTECT_VTABLE_HTML_ISINDEX_ELEMENT \
+ _dom_virtual_html_isindex_element_destroy, \
+ _dom_html_isindex_element_alloc, \
+ _dom_html_isindex_element_copy
+
+#endif
+
diff --git a/src/html/html_label_element.c b/src/html/html_label_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_label_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_label_element.h b/src/html/html_label_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_label_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_legend_element.c b/src/html/html_legend_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_legend_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_legend_element.h b/src/html/html_legend_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_legend_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_li_element.c b/src/html/html_li_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_li_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_li_element.h b/src/html/html_li_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_li_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_link_element.c b/src/html/html_link_element.c
new file mode 100644
index 0000000..ce0d6ac
--- a/dev/null
+++ b/src/html/html_link_element.c
@@ -0,0 +1,171 @@
+/*
+ * 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.com>
+ */
+
+#include <assert.h>
+
+#include "html/html_link_element.h"
+
+#include "core/node.h"
+#include "core/attr.h"
+#include "core/document.h"
+#include "utils/utils.h"
+
+static struct dom_element_protected_vtable _protect_vtable = {
+ {
+ DOM_NODE_PROTECT_VTABLE_HTML_LINK_ELEMENT
+ },
+ DOM_HTML_LINK_ELEMENT_PROTECT_VTABLE
+};
+
+/**
+ * Create a dom_html_link_element object
+ *
+ * \param doc The document object
+ * \param ele The returned element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_link_element_create(struct dom_document *doc,
+ struct dom_html_link_element **ele)
+{
+ *ele = _dom_document_alloc(doc, NULL, sizeof(dom_html_link_element));
+ if (*ele == NULL)
+ return DOM_NO_MEM_ERR;
+
+ /* Set up vtables */
+ struct dom_node_internal *node = (struct dom_node_internal *) *ele;
+ node->base.vtable = &_dom_element_vtable;
+ node->vtable = &_protect_vtable;
+
+ return _dom_html_link_element_initialise(doc, *ele);
+}
+
+/**
+ * Initialise a dom_html_link_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_link_element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_link_element_initialise(struct dom_document *doc,
+ struct dom_html_link_element *ele)
+{
+ const char *str = "LINK";
+ lwc_string *name = NULL;
+ dom_exception err;
+
+ err = _dom_document_create_lwcstring(doc, (const uint8_t *) str, SLEN(str),
+ &name);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
+ _dom_document_unref_lwcstring(doc, name);
+
+ return err;
+}
+
+/**
+ * Finalise a dom_html_link_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_link_element object
+ */
+void _dom_html_link_element_finalise(struct dom_document *doc,
+ struct dom_html_link_element *ele)
+{
+ _dom_html_element_finalise(doc, &ele->base);
+}
+
+/**
+ * Destroy a dom_html_link_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_link_element object
+ */
+void _dom_html_link_element_destroy(struct dom_document *doc,
+ struct dom_html_link_element *ele)
+{
+ _dom_html_link_element_finalise(doc, ele);
+ _dom_document_alloc(doc, ele, 0);
+}
+
+/*-----------------------------------------------------------------------*/
+/* Public APIs */
+
+/**
+ * Get the disabled property
+ *
+ * \param ele The dom_html_link_element object
+ * \param disabled The returned status
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_html_link_element_get_disabled(dom_html_link_element *ele,
+ bool *disabled)
+{
+ return dom_html_element_get_bool_property(&ele->base, "disabled",
+ SLEN("disabled"), disabled);
+}
+
+/**
+ * Set the disabled property
+ *
+ * \param ele The dom_html_link_element object
+ * \param disabled The status
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_html_link_element_set_disabled(dom_html_link_element *ele,
+ bool disabled)
+{
+ return dom_html_element_set_bool_property(&ele->base, "disabled",
+ SLEN("disabled"), disabled);
+}
+
+/*------------------------------------------------------------------------*/
+/* The protected virtual functions */
+
+/* The virtual function used to parse attribute value, see src/core/element.c
+ * for detail */
+dom_exception _dom_html_link_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed)
+{
+ UNUSED(ele);
+ UNUSED(name);
+
+ dom_string_ref(value);
+ *parsed = value;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual destroy function, see src/core/node.c for detail */
+void _dom_virtual_html_link_element_destroy(dom_node_internal *node)
+{
+ struct dom_document *doc = dom_node_get_owner(node);
+ _dom_html_link_element_destroy(doc, (struct dom_html_link_element *) node);
+}
+
+/* The virtual allocation function, see src/core/node.c for detail */
+dom_exception _dom_html_link_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(n);
+
+ *ret = _dom_document_alloc(doc, NULL, sizeof(dom_html_link_element));
+ if (*ret == NULL)
+ return DOM_NO_MEM_ERR;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual copy function, see src/core/node.c for detail */
+dom_exception _dom_html_link_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ return _dom_html_element_copy(new, old);
+}
+
diff --git a/src/html/html_link_element.h b/src/html/html_link_element.h
new file mode 100644
index 0000000..4c6fe55
--- a/dev/null
+++ b/src/html/html_link_element.h
@@ -0,0 +1,55 @@
+/*
+ * 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.com>
+ */
+
+#ifndef dom_internal_html_link_element_h_
+#define dom_internal_html_link_element_h_
+
+#include <dom/html/html_link_element.h>
+
+#include "html/html_element.h"
+
+struct dom_html_link_element {
+ struct dom_html_element base;
+ /**< The base class */
+};
+
+/* Create a dom_html_link_element object */
+dom_exception _dom_html_link_element_create(struct dom_document *doc,
+ struct dom_html_link_element **ele);
+
+/* Initialise a dom_html_link_element object */
+dom_exception _dom_html_link_element_initialise(struct dom_document *doc,
+ struct dom_html_link_element *ele);
+
+/* Finalise a dom_html_link_element object */
+void _dom_html_link_element_finalise(struct dom_document *doc,
+ struct dom_html_link_element *ele);
+
+/* Destroy a dom_html_link_element object */
+void _dom_html_link_element_destroy(struct dom_document *doc,
+ struct dom_html_link_element *ele);
+
+/* The protected virtual functions */
+dom_exception _dom_html_link_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed);
+void _dom_virtual_html_link_element_destroy(dom_node_internal *node);
+dom_exception _dom_html_link_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_html_link_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+#define DOM_HTML_LINK_ELEMENT_PROTECT_VTABLE \
+ _dom_html_link_element_parse_attribute
+
+#define DOM_NODE_PROTECT_VTABLE_HTML_LINK_ELEMENT \
+ _dom_virtual_html_link_element_destroy, \
+ _dom_html_link_element_alloc, \
+ _dom_html_link_element_copy
+
+#endif
+
diff --git a/src/html/html_map_element.c b/src/html/html_map_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_map_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_map_element.h b/src/html/html_map_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_map_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_menu_element.c b/src/html/html_menu_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_menu_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_menu_element.h b/src/html/html_menu_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_menu_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_meta_element.c b/src/html/html_meta_element.c
new file mode 100644
index 0000000..a525e13
--- a/dev/null
+++ b/src/html/html_meta_element.c
@@ -0,0 +1,137 @@
+/*
+ * 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.com>
+ */
+
+#include "html/html_meta_element.h"
+
+#include "core/node.h"
+#include "core/document.h"
+#include "utils/utils.h"
+
+static struct dom_element_protected_vtable _protect_vtable = {
+ {
+ DOM_NODE_PROTECT_VTABLE_HTML_META_ELEMENT
+ },
+ DOM_HTML_META_ELEMENT_PROTECT_VTABLE
+};
+
+/**
+ * Create a dom_html_meta_element object
+ *
+ * \param doc The document object
+ * \param ele The returned element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_meta_element_create(struct dom_document *doc,
+ struct dom_html_meta_element **ele)
+{
+ *ele = _dom_document_alloc(doc, NULL, sizeof(dom_html_meta_element));
+ if (*ele == NULL)
+ return DOM_NO_MEM_ERR;
+
+ /* Set up vtables */
+ struct dom_node_internal *node = (struct dom_node_internal *) *ele;
+ node->base.vtable = &_dom_element_vtable;
+ node->vtable = &_protect_vtable;
+
+ return _dom_html_meta_element_initialise(doc, *ele);
+}
+
+/**
+ * Initialise a dom_html_meta_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_meta_element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_meta_element_initialise(struct dom_document *doc,
+ struct dom_html_meta_element *ele)
+{
+ const char *str = "META";
+ lwc_string *name = NULL;
+ dom_exception err;
+
+ err = _dom_document_create_lwcstring(doc, (const uint8_t *) str, SLEN(str),
+ &name);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
+ _dom_document_unref_lwcstring(doc, name);
+
+ return err;
+}
+
+/**
+ * Finalise a dom_html_meta_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_meta_element object
+ */
+void _dom_html_meta_element_finalise(struct dom_document *doc,
+ struct dom_html_meta_element *ele)
+{
+ _dom_html_element_finalise(doc, &ele->base);
+}
+
+/**
+ * Destroy a dom_html_meta_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_meta_element object
+ */
+void _dom_html_meta_element_destroy(struct dom_document *doc,
+ struct dom_html_meta_element *ele)
+{
+ _dom_html_meta_element_finalise(doc, ele);
+ _dom_document_alloc(doc, ele, 0);
+}
+
+/*------------------------------------------------------------------------*/
+/* The protected virtual functions */
+
+/* The virtual function used to parse attribute value, see src/core/element.c
+ * for detail */
+dom_exception _dom_html_meta_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed)
+{
+ UNUSED(ele);
+ UNUSED(name);
+
+ dom_string_ref(value);
+ *parsed = value;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual destroy function, see src/core/node.c for detail */
+void _dom_virtual_html_meta_element_destroy(dom_node_internal *node)
+{
+ struct dom_document *doc = dom_node_get_owner(node);
+ _dom_html_meta_element_destroy(doc, (struct dom_html_meta_element *) node);
+}
+
+/* The virtual allocation function, see src/core/node.c for detail */
+dom_exception _dom_html_meta_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(n);
+
+ *ret = _dom_document_alloc(doc, NULL, sizeof(dom_html_meta_element));
+ if (*ret == NULL)
+ return DOM_NO_MEM_ERR;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual copy function, see src/core/node.c for detail */
+dom_exception _dom_html_meta_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ return _dom_html_element_copy(new, old);
+}
+
diff --git a/src/html/html_meta_element.h b/src/html/html_meta_element.h
new file mode 100644
index 0000000..2f50719
--- a/dev/null
+++ b/src/html/html_meta_element.h
@@ -0,0 +1,55 @@
+/*
+ * 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.com>
+ */
+
+#ifndef dom_internal_html_meta_element_h_
+#define dom_internal_html_meta_element_h_
+
+#include <dom/html/html_meta_element.h>
+
+#include "html/html_element.h"
+
+struct dom_html_meta_element {
+ struct dom_html_element base;
+ /**< The base class */
+};
+
+/* Create a dom_html_meta_element object */
+dom_exception _dom_html_meta_element_create(struct dom_document *doc,
+ struct dom_html_meta_element **ele);
+
+/* Initialise a dom_html_meta_element object */
+dom_exception _dom_html_meta_element_initialise(struct dom_document *doc,
+ struct dom_html_meta_element *ele);
+
+/* Finalise a dom_html_meta_element object */
+void _dom_html_meta_element_finalise(struct dom_document *doc,
+ struct dom_html_meta_element *ele);
+
+/* Destroy a dom_html_meta_element object */
+void _dom_html_meta_element_destroy(struct dom_document *doc,
+ struct dom_html_meta_element *ele);
+
+/* The protected virtual functions */
+dom_exception _dom_html_meta_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed);
+void _dom_virtual_html_meta_element_destroy(dom_node_internal *node);
+dom_exception _dom_html_meta_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_html_meta_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+#define DOM_HTML_META_ELEMENT_PROTECT_VTABLE \
+ _dom_html_meta_element_parse_attribute
+
+#define DOM_NODE_PROTECT_VTABLE_HTML_META_ELEMENT \
+ _dom_virtual_html_meta_element_destroy, \
+ _dom_html_meta_element_alloc, \
+ _dom_html_meta_element_copy
+
+#endif
+
diff --git a/src/html/html_mod_element.c b/src/html/html_mod_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_mod_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_mod_element.h b/src/html/html_mod_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_mod_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_object_element.c b/src/html/html_object_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_object_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_object_element.h b/src/html/html_object_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_object_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_olist_element.c b/src/html/html_olist_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_olist_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_olist_element.h b/src/html/html_olist_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_olist_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_optgroup_element.c b/src/html/html_optgroup_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_optgroup_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_optgroup_element.h b/src/html/html_optgroup_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_optgroup_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_option_element.c b/src/html/html_option_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_option_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_option_element.h b/src/html/html_option_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_option_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_options_collection.c b/src/html/html_options_collection.c
new file mode 100644
index 0000000..8b4c7bb
--- a/dev/null
+++ b/src/html/html_options_collection.c
@@ -0,0 +1,177 @@
+/*
+ * 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>
+ */
+
+#include <assert.h>
+
+#include <libwapcaplet/libwapcaplet.h>
+
+#include "html/html_options_collection.h"
+
+#include "core/node.h"
+#include "core/document.h"
+#include "core/element.h"
+#include "core/string.h"
+#include "utils/utils.h"
+
+/*-----------------------------------------------------------------------*/
+/* Constructor and destructor */
+
+/**
+ * Create a dom_html_options_collection
+ *
+ * \param doc The document
+ * \param root The root element of the collection
+ * \param ic The callback function used to determin whether certain node
+ * belongs to the collection
+ * \param col The result collection object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_options_collection_create(struct dom_document *doc,
+ struct dom_node_internal *root,
+ dom_callback_is_in_collection ic,
+ struct dom_html_options_collection **col)
+{
+ *col = _dom_document_alloc(doc, NULL,
+ sizeof(dom_html_options_collection));
+ if (*col == NULL)
+ return DOM_NO_MEM_ERR;
+
+ return _dom_html_options_collection_initialise(doc, *col, root, ic);
+}
+
+/**
+ * Intialiase a dom_html_options_collection
+ *
+ * \param doc The document
+ * \param col The collection object to be initialised
+ * \param root The root element of the collection
+ * \param ic The callback function used to determin whether certain node
+ * belongs to the collection
+ * \return DOM_NO_ERR on success.
+ */
+dom_exception _dom_html_options_collection_initialise(struct dom_document *doc,
+ struct dom_html_options_collection *col,
+ struct dom_node_internal *root,
+ dom_callback_is_in_collection ic)
+{
+ return _dom_html_collection_initialise(doc, &col->base, root, ic);
+}
+
+/**
+ * Finalise a dom_html_options_collection object
+ *
+ * \param col The dom_html_options_collection object
+ */
+void _dom_html_options_collection_finalise(struct dom_html_options_collection *col)
+{
+ _dom_html_collection_finalise(&col->base);
+}
+
+/**
+ * Destroy a dom_html_options_collection object
+ * \param col The dom_html_options_collection object
+ */
+void _dom_html_options_collection_destroy(struct dom_html_options_collection *col)
+{
+ struct dom_document *doc = col->base.doc;
+ _dom_html_options_collection_finalise(col);
+
+ _dom_document_alloc(doc, col, 0);
+}
+
+
+/*-----------------------------------------------------------------------*/
+/* Public API */
+
+/**
+ * Get the length of this dom_html_options_collection
+ *
+ * \param col The dom_html_options_collection object
+ * \param len The returned length of this collection
+ * \return DOM_NO_ERR on success.
+ */
+dom_exception dom_html_options_collection_get_length(dom_html_options_collection *col,
+ unsigned long *len)
+{
+ return dom_html_collection_get_length(&col->base, len);
+}
+
+/**
+ * Set the length of this dom_html_options_collection
+ *
+ * \param col The dom_html_options_collection object
+ * \param len The length of this collection to be set
+ * \return DOM_NO_ERR on success.
+ */
+dom_exception dom_html_options_collection_set_length(
+ dom_html_options_collection *col, unsigned long len)
+{
+ UNUSED(col);
+ UNUSED(len);
+
+ /* TODO: how to deal with this */
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Get the node with certain index
+ *
+ * \param col The dom_html_options_collection object
+ * \param index The index number based on zero
+ * \param node The returned node object
+ * \return DOM_NO_ERR on success.
+ */
+dom_exception dom_html_options_collection_item(dom_html_options_collection *col,
+ unsigned long index, struct dom_node **node)
+{
+ return dom_html_collection_item(&col->base, index, node);
+}
+
+/**
+ * Get the node in the collection according name
+ *
+ * \param col The collection
+ * \param name The name of target node
+ * \param node The returned node object
+ * \return DOM_NO_ERR on success.
+ */
+dom_exception dom_html_options_collection_named_item(dom_html_options_collection *col,
+ struct dom_string *name, struct dom_node **node)
+{
+ return dom_html_collection_named_item(&col->base, name, node);
+}
+
+/**
+ * Claim a reference on this collection
+ *
+ * \pram col The collection object
+ */
+void dom_html_options_collection_ref(dom_html_options_collection *col)
+{
+ if (col == NULL)
+ return;
+
+ col->base.refcnt ++;
+}
+
+/**
+ * Relese a reference on this collection
+ *
+ * \pram col The collection object
+ */
+void dom_html_options_collection_unref(dom_html_options_collection *col)
+{
+ if (col == NULL)
+ return;
+
+ if (col->base.refcnt > 0)
+ col->base.refcnt --;
+
+ if (col->base.refcnt == 0)
+ _dom_html_options_collection_destroy(col);
+}
+
diff --git a/src/html/html_options_collection.h b/src/html/html_options_collection.h
new file mode 100644
index 0000000..e82cc5c
--- a/dev/null
+++ b/src/html/html_options_collection.h
@@ -0,0 +1,42 @@
+/*
+ * 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_html_options_collection_h_
+#define dom_internal_html_options_collection_h_
+
+#include <dom/html/html_options_collection.h>
+
+#include "html/html_collection.h"
+
+struct dom_node_internal;
+
+/**
+ * The html_options_collection structure
+ */
+struct dom_html_options_collection {
+ struct dom_html_collection base;
+ /**< The base class */
+};
+
+dom_exception _dom_html_options_collection_create(struct dom_document *doc,
+ struct dom_node_internal *root,
+ dom_callback_is_in_collection ic,
+ struct dom_html_options_collection **col);
+
+dom_exception _dom_html_options_collection_initialise(struct dom_document *doc,
+ struct dom_html_options_collection *col,
+ struct dom_node_internal *root,
+ dom_callback_is_in_collection ic);
+
+void _dom_html_options_collection_finalise(
+ struct dom_html_options_collection *col);
+
+void _dom_html_options_collection_destroy(
+ struct dom_html_options_collection *col);
+
+#endif
+
diff --git a/src/html/html_paragraph_element.c b/src/html/html_paragraph_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_paragraph_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_paragraph_element.h b/src/html/html_paragraph_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_paragraph_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_param_element.c b/src/html/html_param_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_param_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_param_element.h b/src/html/html_param_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_param_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_pre_element.c b/src/html/html_pre_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_pre_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_pre_element.h b/src/html/html_pre_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_pre_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_quote_element.c b/src/html/html_quote_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_quote_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_quote_element.h b/src/html/html_quote_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_quote_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_script_element.c b/src/html/html_script_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_script_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_script_element.h b/src/html/html_script_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_script_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_select_element.c b/src/html/html_select_element.c
new file mode 100644
index 0000000..f4e54cb
--- a/dev/null
+++ b/src/html/html_select_element.c
@@ -0,0 +1,344 @@
+/*
+ * 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>
+ */
+
+#include <assert.h>
+
+#include "html/html_select_element.h"
+
+#include "core/node.h"
+#include "core/document.h"
+#include "utils/utils.h"
+
+static struct dom_element_protected_vtable _protect_vtable = {
+ {
+ DOM_NODE_PROTECT_VTABLE_HTML_SELECT_ELEMENT
+ },
+ DOM_HTML_SELECT_ELEMENT_PROTECT_VTABLE
+};
+
+static bool is_option(struct dom_node_internal *node);
+/**
+ * Create a dom_html_select_element object
+ *
+ * \param doc The document object
+ * \param ele The returned element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_select_element_create(struct dom_document *doc,
+ struct dom_html_select_element **ele)
+{
+ *ele = _dom_document_alloc(doc, NULL, sizeof(dom_html_select_element));
+ if (*ele == NULL)
+ return DOM_NO_MEM_ERR;
+
+ /* Set up vtables */
+ struct dom_node_internal *node = (struct dom_node_internal *) *ele;
+ node->base.vtable = &_dom_element_vtable;
+ node->vtable = &_protect_vtable;
+
+ return _dom_html_select_element_initialise(doc, *ele);
+}
+
+/**
+ * Initialise a dom_html_select_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_select_element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_select_element_initialise(struct dom_document *doc,
+ struct dom_html_select_element *ele)
+{
+ const char *str = "SELECT";
+ lwc_string *name = NULL;
+ dom_exception err;
+
+ err = _dom_document_create_lwcstring(doc, (const uint8_t *) str, SLEN(str),
+ &name);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
+ _dom_document_unref_lwcstring(doc, name);
+
+ ele->selected = -1;
+ ele->options = NULL;
+
+ return err;
+}
+
+/**
+ * Finalise a dom_html_select_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_select_element object
+ */
+void _dom_html_select_element_finalise(struct dom_document *doc,
+ struct dom_html_select_element *ele)
+{
+ _dom_html_element_finalise(doc, &ele->base);
+}
+
+/**
+ * Destroy a dom_html_select_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_select_element object
+ */
+void _dom_html_select_element_destroy(struct dom_document *doc,
+ struct dom_html_select_element *ele)
+{
+ _dom_html_select_element_finalise(doc, ele);
+ _dom_document_alloc(doc, ele, 0);
+}
+
+/*------------------------------------------------------------------------*/
+/* The protected virtual functions */
+
+/* The virtual function used to parse attribute value, see src/core/element.c
+ * for detail */
+dom_exception _dom_html_select_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed)
+{
+ UNUSED(ele);
+ UNUSED(name);
+
+ dom_string_ref(value);
+ *parsed = value;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual destroy function, see src/core/node.c for detail */
+void _dom_virtual_html_select_element_destroy(dom_node_internal *node)
+{
+ struct dom_document *doc = dom_node_get_owner(node);
+ _dom_html_select_element_destroy(doc, (struct dom_html_select_element *) node);
+}
+
+/* The virtual allocation function, see src/core/node.c for detail */
+dom_exception _dom_html_select_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(n);
+
+ *ret = _dom_document_alloc(doc, NULL, sizeof(dom_html_select_element));
+ if (*ret == NULL)
+ return DOM_NO_MEM_ERR;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual copy function, see src/core/node.c for detail */
+dom_exception _dom_html_select_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ return _dom_html_element_copy(new, old);
+}
+
+/*-----------------------------------------------------------------------*/
+/* Public APIs */
+
+/**
+ * Get the ordinal index of the selected option
+ *
+ * \param ele The element object
+ * \param index The returned index
+ * \return DOM_NO_ERR on success.
+ */
+dom_exception dom_html_select_element_get_selected_index(
+ dom_html_select_element *ele, unsigned long *index)
+{
+ *index = ele->selected;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Set the ordinal index of the selected option
+ *
+ * \param ele The element object
+ * \param index The new index
+ * \return DOM_NO_ERR on success.
+ */
+dom_exception dom_html_select_element_set_selected_index(
+ dom_html_select_element *ele, unsigned long index)
+{
+ ele->selected = index;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Get the number of options in this select element
+ *
+ * \param ele The element object
+ * \param len The returned len
+ * \return DOM_NO_ERR on success.
+ */
+dom_exception dom_html_select_element_get_length(
+ dom_html_select_element *ele, unsigned long *len)
+{
+ dom_exception err;
+ dom_document *doc = dom_node_get_owner(ele);
+ assert(doc != NULL);
+
+ if (ele->options == NULL) {
+ err = _dom_html_options_collection_create(doc,
+ (dom_node_internal *) ele,
+ is_option, &ele->options);
+ if (err != DOM_NO_ERR)
+ return err;
+ }
+
+ return dom_html_options_collection_get_length(ele->options, len);
+}
+
+/**
+ * Set the number of options in this select element
+ *
+ * \param ele The element object
+ * \param len The new len
+ * \return DOM_NOT_SUPPORTED_ERR.
+ *
+ * todo: how to deal with set the len of the children option objects?
+ */
+dom_exception dom_html_select_element_set_length(
+ dom_html_select_element *ele, unsigned long len)
+{
+ UNUSED(ele);
+ UNUSED(len);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * The collection of OPTION elements of this element
+ *
+ * \param ele The element object
+ * \param col THe returned collection object
+ * \return DOM_NO_ERR on success.
+ */
+dom_exception dom_html_select_element_get_options(
+ dom_html_select_element *ele,
+ struct dom_html_options_collection **col)
+{
+ dom_exception err;
+ dom_document *doc = dom_node_get_owner(ele);
+ assert(doc != NULL);
+
+ if (ele->options == NULL) {
+ err = _dom_html_options_collection_create(doc,
+ (dom_node_internal *) ele,
+ is_option, &ele->options);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ *col = ele->options;
+ return DOM_NO_ERR;
+ }
+
+ dom_html_options_collection_ref(ele->options);
+ *col = ele->options;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Whether this element is disabled
+ *
+ * \param ele The element object
+ * \param disabled The returned status
+ * \return DOM_NO_ERR on success.
+ */
+dom_exception dom_html_select_element_get_disabled(
+ dom_html_select_element *ele, bool *disabled)
+{
+ return dom_html_element_get_bool_property(&ele->base,
+ "disabled", SLEN("disabled"), disabled);
+}
+
+/**
+ * Set the disabled status of this element
+ *
+ * \param ele The element object
+ * \param disabled The disabled status
+ * \return DOM_NO_ERR on success.
+ */
+dom_exception dom_html_select_element_set_disabled(
+ dom_html_select_element *ele, bool disabled)
+{
+ return dom_html_element_set_bool_property(&ele->base,
+ "disabled", SLEN("disabled"), disabled);
+}
+
+/**
+ * Whether this element can be multiple selected
+ *
+ * \param ele The element object
+ * \param multiple The returned status
+ * \return DOM_NO_ERR on success.
+ */
+dom_exception dom_html_select_element_get_multiple(
+ dom_html_select_element *ele, bool *multiple)
+{
+ return dom_html_element_get_bool_property(&ele->base,
+ "multiple", SLEN("multiple"), multiple);
+}
+
+/**
+ * Set whether this element can be multiple selected
+ *
+ * \param ele The element object
+ * \param multiple The status
+ * \return DOM_NO_ERR on success.
+ */
+dom_exception dom_html_select_element_set_multiple(
+ dom_html_select_element *ele, bool multiple)
+{
+ return dom_html_element_set_bool_property(&ele->base,
+ "multiple", SLEN("multiple"), multiple);
+}
+
+dom_exception dom_html_select_element_get_size(
+ dom_html_select_element *ele, unsigned long *size);
+dom_exception dom_html_select_element_set_size(
+ dom_html_select_element *ele, unsigned long size);
+dom_exception dom_html_select_element_get_tab_index(
+ dom_html_select_element *ele, unsigned long *tab_index);
+dom_exception dom_html_select_element_set_tab_index(
+ dom_html_select_element *ele, unsigned long tab_index);
+
+/* Functions */
+dom_exception dom_html_select_element_add(struct dom_html_element *ele,
+ struct dom_html_element *before);
+dom_exception dom_html_element_blur(struct dom_html_select_element *ele);
+dom_exception dom_html_element_focus(struct dom_html_select_element *ele);
+
+
+/*-----------------------------------------------------------------------*/
+/* Helper functions */
+
+/* Test whether certain node is an option node */
+bool is_option(struct dom_node_internal *node)
+{
+ lwc_string *name = NULL;
+ bool ret = false;
+ dom_exception err;
+
+ err = _dom_node_create_lwcstring(node, (const uint8_t *) "OPTION",
+ SLEN("OPTION"), &name);
+ assert(err == DOM_NO_ERR);
+
+ if (name == node->name)
+ ret = true;
+
+ _dom_node_unref_intern_string(node, name);
+
+ return ret;
+}
diff --git a/src/html/html_select_element.h b/src/html/html_select_element.h
new file mode 100644
index 0000000..28b4956
--- a/dev/null
+++ b/src/html/html_select_element.h
@@ -0,0 +1,60 @@
+/*
+ * 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_html_select_element_h_
+#define dom_internal_html_select_element_h_
+
+#include <dom/html/html_select_element.h>
+
+#include "html/html_element.h"
+#include "html/html_options_collection.h"
+
+struct dom_html_select_element {
+ struct dom_html_element base;
+ /**< The base class */
+ long selected;
+ /**< The selected element's index */
+ dom_html_options_collection *options;
+ /**< The options objects */
+};
+
+/* Create a dom_html_select_element object */
+dom_exception _dom_html_select_element_create(struct dom_document *doc,
+ struct dom_html_select_element **ele);
+
+/* Initialise a dom_html_select_element object */
+dom_exception _dom_html_select_element_initialise(struct dom_document *doc,
+ struct dom_html_select_element *ele);
+
+/* Finalise a dom_html_select_element object */
+void _dom_html_select_element_finalise(struct dom_document *doc,
+ struct dom_html_select_element *ele);
+
+/* Destroy a dom_html_select_element object */
+void _dom_html_select_element_destroy(struct dom_document *doc,
+ struct dom_html_select_element *ele);
+
+/* The protected virtual functions */
+dom_exception _dom_html_select_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed);
+void _dom_virtual_html_select_element_destroy(dom_node_internal *node);
+dom_exception _dom_html_select_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_html_select_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+#define DOM_HTML_SELECT_ELEMENT_PROTECT_VTABLE \
+ _dom_html_select_element_parse_attribute
+
+#define DOM_NODE_PROTECT_VTABLE_HTML_SELECT_ELEMENT \
+ _dom_virtual_html_select_element_destroy, \
+ _dom_html_select_element_alloc, \
+ _dom_html_select_element_copy
+
+#endif
+
diff --git a/src/html/html_style_element.c b/src/html/html_style_element.c
new file mode 100644
index 0000000..288b1cf
--- a/dev/null
+++ b/src/html/html_style_element.c
@@ -0,0 +1,168 @@
+/*
+ * 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.com>
+ */
+
+#include "html/html_style_element.h"
+
+#include "core/node.h"
+#include "core/document.h"
+#include "utils/utils.h"
+
+static struct dom_element_protected_vtable _protect_vtable = {
+ {
+ DOM_NODE_PROTECT_VTABLE_HTML_STYLE_ELEMENT
+ },
+ DOM_HTML_STYLE_ELEMENT_PROTECT_VTABLE
+};
+
+/**
+ * Create a dom_html_style_element object
+ *
+ * \param doc The document object
+ * \param ele The returned element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_style_element_create(struct dom_document *doc,
+ struct dom_html_style_element **ele)
+{
+ *ele = _dom_document_alloc(doc, NULL, sizeof(dom_html_style_element));
+ if (*ele == NULL)
+ return DOM_NO_MEM_ERR;
+
+ /* Set up vtables */
+ struct dom_node_internal *node = (struct dom_node_internal *) *ele;
+ node->base.vtable = &_dom_element_vtable;
+ node->vtable = &_protect_vtable;
+
+ return _dom_html_style_element_initialise(doc, *ele);
+}
+
+/**
+ * Initialise a dom_html_style_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_style_element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_style_element_initialise(struct dom_document *doc,
+ struct dom_html_style_element *ele)
+{
+ const char *str = "STYLE";
+ lwc_string *name = NULL;
+ dom_exception err;
+
+ err = _dom_document_create_lwcstring(doc, (const uint8_t *) str, SLEN(str),
+ &name);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
+ _dom_document_unref_lwcstring(doc, name);
+
+ return err;
+}
+
+/**
+ * Finalise a dom_html_style_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_style_element object
+ */
+void _dom_html_style_element_finalise(struct dom_document *doc,
+ struct dom_html_style_element *ele)
+{
+ _dom_html_element_finalise(doc, &ele->base);
+}
+
+/**
+ * Destroy a dom_html_style_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_style_element object
+ */
+void _dom_html_style_element_destroy(struct dom_document *doc,
+ struct dom_html_style_element *ele)
+{
+ _dom_html_style_element_finalise(doc, ele);
+ _dom_document_alloc(doc, ele, 0);
+}
+
+/*------------------------------------------------------------------------*/
+/* The protected virtual functions */
+
+/* The virtual function used to parse attribute value, see src/core/element.c
+ * for detail */
+dom_exception _dom_html_style_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed)
+{
+ UNUSED(ele);
+ UNUSED(name);
+
+ dom_string_ref(value);
+ *parsed = value;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual destroy function, see src/core/node.c for detail */
+void _dom_virtual_html_style_element_destroy(dom_node_internal *node)
+{
+ struct dom_document *doc = dom_node_get_owner(node);
+ _dom_html_style_element_destroy(doc, (struct dom_html_style_element *) node);
+}
+
+/* The virtual allocation function, see src/core/node.c for detail */
+dom_exception _dom_html_style_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(n);
+
+ *ret = _dom_document_alloc(doc, NULL, sizeof(dom_html_style_element));
+ if (*ret == NULL)
+ return DOM_NO_MEM_ERR;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual copy function, see src/core/node.c for detail */
+dom_exception _dom_html_style_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ return _dom_html_element_copy(new, old);
+}
+
+/*-----------------------------------------------------------------------*/
+/* Public APIs */
+
+/**
+ * Get the disabled property
+ *
+ * \param ele The dom_html_style_element object
+ * \param disabled The returned status
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_html_style_element_get_disabled(dom_html_style_element *ele,
+ bool *disabled)
+{
+ return dom_html_element_get_bool_property(&ele->base, "disabled",
+ SLEN("disabled"), disabled);
+}
+
+/**
+ * Set the disabled property
+ *
+ * \param ele The dom_html_style_element object
+ * \param disabled The status
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_html_style_element_set_disabled(dom_html_style_element *ele,
+ bool disabled)
+{
+ return dom_html_element_set_bool_property(&ele->base, "disabled",
+ SLEN("disabled"), disabled);
+}
+
diff --git a/src/html/html_style_element.h b/src/html/html_style_element.h
new file mode 100644
index 0000000..3ac8cf5
--- a/dev/null
+++ b/src/html/html_style_element.h
@@ -0,0 +1,55 @@
+/*
+ * 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.com>
+ */
+
+#ifndef dom_internal_html_style_element_h_
+#define dom_internal_html_style_element_h_
+
+#include <dom/html/html_style_element.h>
+
+#include "html/html_element.h"
+
+struct dom_html_style_element {
+ struct dom_html_element base;
+ /**< The base class */
+};
+
+/* Create a dom_html_style_element object */
+dom_exception _dom_html_style_element_create(struct dom_document *doc,
+ struct dom_html_style_element **ele);
+
+/* Initialise a dom_html_style_element object */
+dom_exception _dom_html_style_element_initialise(struct dom_document *doc,
+ struct dom_html_style_element *ele);
+
+/* Finalise a dom_html_style_element object */
+void _dom_html_style_element_finalise(struct dom_document *doc,
+ struct dom_html_style_element *ele);
+
+/* Destroy a dom_html_style_element object */
+void _dom_html_style_element_destroy(struct dom_document *doc,
+ struct dom_html_style_element *ele);
+
+/* The protected virtual functions */
+dom_exception _dom_html_style_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed);
+void _dom_virtual_html_style_element_destroy(dom_node_internal *node);
+dom_exception _dom_html_style_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_html_style_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+#define DOM_HTML_STYLE_ELEMENT_PROTECT_VTABLE \
+ _dom_html_style_element_parse_attribute
+
+#define DOM_NODE_PROTECT_VTABLE_HTML_STYLE_ELEMENT \
+ _dom_virtual_html_style_element_destroy, \
+ _dom_html_style_element_alloc, \
+ _dom_html_style_element_copy
+
+#endif
+
diff --git a/src/html/html_table_element.c b/src/html/html_table_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_table_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_table_element.h b/src/html/html_table_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_table_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_tablecaption_element.c b/src/html/html_tablecaption_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_tablecaption_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_tablecaption_element.h b/src/html/html_tablecaption_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_tablecaption_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_tablecell_element.c b/src/html/html_tablecell_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_tablecell_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_tablecell_element.h b/src/html/html_tablecell_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_tablecell_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_tablecol_element.c b/src/html/html_tablecol_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_tablecol_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_tablecol_element.h b/src/html/html_tablecol_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_tablecol_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_tablerow_element.c b/src/html/html_tablerow_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_tablerow_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_tablerow_element.h b/src/html/html_tablerow_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_tablerow_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_tablesection_element.c b/src/html/html_tablesection_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_tablesection_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_tablesection_element.h b/src/html/html_tablesection_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_tablesection_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_textarea_element.c b/src/html/html_textarea_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_textarea_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_textarea_element.h b/src/html/html_textarea_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_textarea_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_title_element.c b/src/html/html_title_element.c
new file mode 100644
index 0000000..c914d4a
--- a/dev/null
+++ b/src/html/html_title_element.c
@@ -0,0 +1,187 @@
+/*
+ * 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.com>
+ */
+
+#include <assert.h>
+
+#include <dom/core/characterdata.h>
+#include <dom/core/text.h>
+
+#include "html/html_title_element.h"
+
+#include "core/node.h"
+#include "core/document.h"
+#include "utils/utils.h"
+
+static struct dom_element_protected_vtable _protect_vtable = {
+ {
+ DOM_NODE_PROTECT_VTABLE_HTML_TITLE_ELEMENT
+ },
+ DOM_HTML_TITLE_ELEMENT_PROTECT_VTABLE
+};
+
+/**
+ * Create a dom_html_title_element object
+ *
+ * \param doc The document object
+ * \param ele The returned element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_title_element_create(struct dom_document *doc,
+ struct dom_html_title_element **ele)
+{
+ *ele = _dom_document_alloc(doc, NULL, sizeof(dom_html_title_element));
+ if (*ele == NULL)
+ return DOM_NO_MEM_ERR;
+
+ /* Set up vtables */
+ struct dom_node_internal *node = (struct dom_node_internal *) *ele;
+ node->base.vtable = &_dom_element_vtable;
+ node->vtable = &_protect_vtable;
+
+ return _dom_html_title_element_initialise(doc, *ele);
+}
+
+/**
+ * Initialise a dom_html_title_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_title_element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_title_element_initialise(struct dom_document *doc,
+ struct dom_html_title_element *ele)
+{
+ const char *str = "TITLE";
+ lwc_string *name = NULL;
+ dom_exception err;
+
+ err = _dom_document_create_lwcstring(doc, (const uint8_t *) str, SLEN(str),
+ &name);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
+ _dom_document_unref_lwcstring(doc, name);
+
+ return err;
+}
+
+/**
+ * Finalise a dom_html_title_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_title_element object
+ */
+void _dom_html_title_element_finalise(struct dom_document *doc,
+ struct dom_html_title_element *ele)
+{
+ _dom_html_element_finalise(doc, &ele->base);
+}
+
+/**
+ * Destroy a dom_html_title_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_title_element object
+ */
+void _dom_html_title_element_destroy(struct dom_document *doc,
+ struct dom_html_title_element *ele)
+{
+ _dom_html_title_element_finalise(doc, ele);
+ _dom_document_alloc(doc, ele, 0);
+}
+
+/*------------------------------------------------------------------------*/
+/* The protected virtual functions */
+
+/* The virtual function used to parse attribute value, see src/core/element.c
+ * for detail */
+dom_exception _dom_html_title_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed)
+{
+ UNUSED(ele);
+ UNUSED(name);
+
+ dom_string_ref(value);
+ *parsed = value;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual destroy function, see src/core/node.c for detail */
+void _dom_virtual_html_title_element_destroy(dom_node_internal *node)
+{
+ struct dom_document *doc = dom_node_get_owner(node);
+ _dom_html_title_element_destroy(doc, (struct dom_html_title_element *) node);
+}
+
+/* The virtual allocation function, see src/core/node.c for detail */
+dom_exception _dom_html_title_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(n);
+
+ *ret = _dom_document_alloc(doc, NULL, sizeof(dom_html_title_element));
+ if (*ret == NULL)
+ return DOM_NO_MEM_ERR;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual copy function, see src/core/node.c for detail */
+dom_exception _dom_html_title_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ return _dom_html_element_copy(new, old);
+}
+
+/*-----------------------------------------------------------------------*/
+/* Public APIs */
+
+/**
+ * Get the text of title
+ *
+ * \param ele The title element
+ * \param text The returned text
+ * \return DOM_NO_ERR on success, appropriated dom_exception on failure.
+ */
+dom_exception dom_html_title_element_get_text(dom_html_title_element *ele,
+ struct dom_string **text)
+{
+ dom_node_internal *node = (dom_node_internal *) ele;
+ dom_node_internal *n = node->first_child;
+
+ /* There should be only one child of title element */
+ assert(node->first_child == node->last_child);
+ /* And it should be a text node */
+ assert(n->type == DOM_TEXT_NODE);
+
+ return dom_characterdata_get_data(n, text);
+}
+
+/**
+ * Set the text of title
+ *
+ * \param ele The title element
+ * \param text The text data to be set
+ * \return DOM_NO_ERR on success, appropriated dom_exception on failure.
+ */
+dom_exception dom_html_title_element_set_text(dom_html_title_element *ele,
+ struct dom_string *text)
+{
+ dom_node_internal *node = (dom_node_internal *) ele;
+ dom_node_internal *n = node->first_child;
+
+ /* There should be only one child of title element */
+ assert(node->first_child == node->last_child);
+ /* And it should be a text node */
+ assert(n->type == DOM_TEXT_NODE);
+
+ return dom_characterdata_set_data(n, text);
+}
+
diff --git a/src/html/html_title_element.h b/src/html/html_title_element.h
new file mode 100644
index 0000000..1433189
--- a/dev/null
+++ b/src/html/html_title_element.h
@@ -0,0 +1,55 @@
+/*
+ * 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.com>
+ */
+
+#ifndef dom_internal_html_title_element_h_
+#define dom_internal_html_title_element_h_
+
+#include <dom/html/html_title_element.h>
+
+#include "html/html_element.h"
+
+struct dom_html_title_element {
+ struct dom_html_element base;
+ /**< The base class */
+};
+
+/* Create a dom_html_title_element object */
+dom_exception _dom_html_title_element_create(struct dom_document *doc,
+ struct dom_html_title_element **ele);
+
+/* Initialise a dom_html_title_element object */
+dom_exception _dom_html_title_element_initialise(struct dom_document *doc,
+ struct dom_html_title_element *ele);
+
+/* Finalise a dom_html_title_element object */
+void _dom_html_title_element_finalise(struct dom_document *doc,
+ struct dom_html_title_element *ele);
+
+/* Destroy a dom_html_title_element object */
+void _dom_html_title_element_destroy(struct dom_document *doc,
+ struct dom_html_title_element *ele);
+
+/* The protected virtual functions */
+dom_exception _dom_html_title_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed);
+void _dom_virtual_html_title_element_destroy(dom_node_internal *node);
+dom_exception _dom_html_title_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_html_title_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+#define DOM_HTML_TITLE_ELEMENT_PROTECT_VTABLE \
+ _dom_html_title_element_parse_attribute
+
+#define DOM_NODE_PROTECT_VTABLE_HTML_TITLE_ELEMENT \
+ _dom_virtual_html_title_element_destroy, \
+ _dom_html_title_element_alloc, \
+ _dom_html_title_element_copy
+
+#endif
+
diff --git a/src/html/html_ulist_element.c b/src/html/html_ulist_element.c
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_ulist_element.c
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+
diff --git a/src/html/html_ulist_element.h b/src/html/html_ulist_element.h
new file mode 100644
index 0000000..2e182d5
--- a/dev/null
+++ b/src/html/html_ulist_element.h
@@ -0,0 +1,7 @@
+/*
+ * 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>
+ */
+