summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrsk1994 <rsk1coder99@gmail.com>2014-05-17 05:59:23 +0530
committerRupinder Singh Khokhar <rsk1coder99@gmail.com>2014-06-11 04:27:08 +0530
commit644e93ff924466c41e55bad14fb7a42c468a4f7c (patch)
tree23352d4ea0bfdd9ef90bfda6de12b8acb4f502c8 /src
parentadea85fad0882b49e70087c03c173fae6bf8d121 (diff)
downloadlibdom-644e93ff924466c41e55bad14fb7a42c468a4f7c.tar.gz
libdom-644e93ff924466c41e55bad14fb7a42c468a4f7c.tar.bz2
Area Element & documentElement minor fix
Diffstat (limited to 'src')
-rw-r--r--src/html/Makefile5
-rw-r--r--src/html/html_area_element.c215
-rw-r--r--src/html/html_area_element.h45
-rw-r--r--src/html/html_collection.c2
4 files changed, 263 insertions, 4 deletions
diff --git a/src/html/Makefile b/src/html/Makefile
index 0d8bcae..ba76d6c 100644
--- a/src/html/Makefile
+++ b/src/html/Makefile
@@ -14,11 +14,10 @@ DIR_SOURCES := \
html_ulist_element.c html_olist_element.c html_li_element.c \
html_font_element.c html_mod_element.c html_anchor_element.c \
html_basefont_element.c html_image_element.c html_object_element.c \
- html_param_element.c html_applet_element.c
+ html_param_element.c html_applet_element.c html_area_element.c
UNINMPLEMENTED_SOURCES := \
- html_map_element.c \
- html_area_element.c html_script_element.c html_table_element.c \
+ html_map_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
diff --git a/src/html/html_area_element.c b/src/html/html_area_element.c
index 2e182d5..85a2a3e 100644
--- a/src/html/html_area_element.c
+++ b/src/html/html_area_element.c
@@ -3,5 +3,220 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ * Copyright 2014 Rupinder Singh Khokhar<rsk1coder99@gmail.com>
*/
+#include <assert.h>
+#include <stdlib.h>
+
+#include <dom/html/html_area_element.h>
+
+#include "html/html_document.h"
+#include "html/html_area_element.h"
+
+#include "core/node.h"
+#include "core/attr.h"
+#include "utils/utils.h"
+
+static struct dom_element_protected_vtable _protect_vtable = {
+ {
+ DOM_NODE_PROTECT_VTABLE_HTML_AREA_ELEMENT
+ },
+ DOM_HTML_AREA_ELEMENT_PROTECT_VTABLE
+};
+
+/**
+ * Create a dom_html_area_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_area_element_create(struct dom_html_document *doc,
+ dom_string *namespace, dom_string *prefix,
+ struct dom_html_area_element **ele)
+{
+ struct dom_node_internal *node;
+
+ *ele = malloc(sizeof(dom_html_area_element));
+ if (*ele == NULL)
+ return DOM_NO_MEM_ERR;
+
+ /* Set up vtables */
+ node = (struct dom_node_internal *) *ele;
+ node->base.vtable = &_dom_html_element_vtable;
+ node->vtable = &_protect_vtable;
+
+ return _dom_html_area_element_initialise(doc, namespace, prefix, *ele);
+}
+
+/**
+ * Initialise a dom_html_area_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_area_element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_area_element_initialise(struct dom_html_document *doc,
+ dom_string *namespace, dom_string *prefix,
+ struct dom_html_area_element *ele)
+{
+ return _dom_html_element_initialise(doc, &ele->base,
+ doc->memoised[hds_AREA],
+ namespace, prefix);
+}
+
+/**
+ * Finalise a dom_html_area_element object
+ *
+ * \param ele The dom_html_area_element object
+ */
+void _dom_html_area_element_finalise(struct dom_html_area_element *ele)
+{
+ _dom_html_element_finalise(&ele->base);
+}
+
+/**
+ * Destroy a dom_html_area_element object
+ *
+ * \param ele The dom_html_area_element object
+ */
+void _dom_html_area_element_destroy(struct dom_html_area_element *ele)
+{
+ _dom_html_area_element_finalise(ele);
+ free(ele);
+}
+
+/**
+ * Get the no_href property
+ *
+ * \param ele The dom_html_area_element object
+ * \param no_href The status
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_html_area_element_get_no_href(dom_html_area_element *ele,
+ bool *no_href)
+{
+ return dom_html_element_get_bool_property(&ele->base, "nohref",
+ SLEN("nohref"), no_href);
+}
+
+/**
+ * Set the no_href property
+ *
+ * \param ele The dom_html_area_element object
+ * \param no_href The status
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_html_area_element_set_no_href(dom_html_area_element *ele,
+ bool no_href)
+{
+ return dom_html_element_set_bool_property(&ele->base, "nohref",
+ SLEN("nohref"), no_href);
+}
+
+/**
+ * Set the tab_index property
+ *
+ * \param ele The dom_html_area_element object
+ * \param no_href The status
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_html_area_element_get_tab_index(
+ dom_html_area_element *area, int32_t *tab_index)
+{
+ return dom_html_element_get_int32_t_property(&area->base, "tabindex",
+ SLEN("tabindex"), tab_index);
+}
+
+/**
+ * Set the tab_index property
+ *
+ * \param ele The dom_html_area_element object
+ * \param no_href The status
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_html_area_element_set_tab_index(
+ dom_html_area_element *area, uint32_t tab_index)
+{
+ return dom_html_element_set_int32_t_property(&area->base, "tabindex",
+ SLEN("tabindex"), tab_index);
+}
+
+/*------------------------------------------------------------------------*/
+/* The protected virtual functions */
+
+/* The virtual function used to parse attribute value, see src/core/element.c
+ * for detail */
+dom_exception _dom_html_area_element_parse_attribute(dom_element *ele,
+ dom_string *name, dom_string *value,
+ 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_area_element_destroy(dom_node_internal *node)
+{
+ _dom_html_area_element_destroy((struct dom_html_area_element *) node);
+}
+
+/* The virtual copy function, see src/core/node.c for detail */
+dom_exception _dom_html_area_element_copy(dom_node_internal *old,
+ dom_node_internal **copy)
+{
+ return _dom_html_element_copy(old, copy);
+}
+
+/*-----------------------------------------------------------------------*/
+/* API functions */
+
+#define SIMPLE_GET(attr) \
+ dom_exception dom_html_area_element_get_##attr( \
+ dom_html_area_element *element, \
+ dom_string **attr) \
+ { \
+ dom_exception ret; \
+ dom_string *_memo_##attr; \
+ \
+ _memo_##attr = \
+ ((struct dom_html_document *) \
+ ((struct dom_node_internal *)element)->owner)->\
+ memoised[hds_##attr]; \
+ \
+ ret = dom_element_get_attribute(element, _memo_##attr, attr); \
+ \
+ return ret; \
+ }
+#define SIMPLE_SET(attr) \
+dom_exception dom_html_area_element_set_##attr( \
+ dom_html_area_element *element, \
+ dom_string *attr) \
+ { \
+ dom_exception ret; \
+ dom_string *_memo_##attr; \
+ \
+ _memo_##attr = \
+ ((struct dom_html_document *) \
+ ((struct dom_node_internal *)element)->owner)->\
+ memoised[hds_##attr]; \
+ \
+ ret = dom_element_set_attribute(element, _memo_##attr, attr); \
+ \
+ return ret; \
+ }
+
+#define SIMPLE_GET_SET(attr) SIMPLE_GET(attr) SIMPLE_SET(attr)
+
+SIMPLE_GET_SET(access_key);
+SIMPLE_GET_SET(alt);
+SIMPLE_GET_SET(coords);
+SIMPLE_GET_SET(href);
+SIMPLE_GET_SET(shape);
+SIMPLE_GET_SET(target);
diff --git a/src/html/html_area_element.h b/src/html/html_area_element.h
index 2e182d5..a45d1df 100644
--- a/src/html/html_area_element.h
+++ b/src/html/html_area_element.h
@@ -3,5 +3,50 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ * Copyright 2014 Rupinder Singh Khokhar <rsk1coder99@gmail.com>
*/
+#ifndef dom_internal_html_area_element_h_
+#define dom_internal_html_area_element_h_
+
+#include <dom/html/html_area_element.h>
+#include "html/html_element.h"
+
+
+struct dom_html_area_element {
+ struct dom_html_element base;
+ /**< The base class */
+};
+
+/* Create a dom_html_area_element object */
+dom_exception _dom_html_area_element_create(struct dom_html_document *doc,
+ dom_string *namespace, dom_string *prefix,
+ struct dom_html_area_element **ele);
+
+/* Initialise a dom_html_area_element object */
+dom_exception _dom_html_area_element_initialise(struct dom_html_document *doc,
+ dom_string *namespace, dom_string *prefix,
+ struct dom_html_area_element *ele);
+
+/* Finalise a dom_html_area_element object */
+void _dom_html_area_element_finalise(struct dom_html_area_element *ele);
+
+/* Destroy a dom_html_area_element object */
+void _dom_html_area_element_destroy(struct dom_html_area_element *ele);
+
+/* The protected virtual functions */
+dom_exception _dom_html_area_element_parse_attribute(dom_element *ele,
+ dom_string *name, dom_string *value,
+ dom_string **parsed);
+void _dom_virtual_html_area_element_destroy(dom_node_internal *node);
+dom_exception _dom_html_area_element_copy(dom_node_internal *old,
+ dom_node_internal **copy);
+
+#define DOM_HTML_AREA_ELEMENT_PROTECT_VTABLE \
+ _dom_html_area_element_parse_attribute
+
+#define DOM_NODE_PROTECT_VTABLE_HTML_AREA_ELEMENT \
+ _dom_virtual_html_area_element_destroy, \
+ _dom_html_area_element_copy
+
+#endif
diff --git a/src/html/html_collection.c b/src/html/html_collection.c
index a99297f..fb801d9 100644
--- a/src/html/html_collection.c
+++ b/src/html/html_collection.c
@@ -25,7 +25,7 @@
* \param doc The document
* \param root The root element of the collection
* \param ic The callback function used to determin whether certain node
- * beint32_ts to the collection
+ * belongs to the collection
* \param col The result collection object
* \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/