summaryrefslogtreecommitdiff
path: root/src/html
diff options
context:
space:
mode:
Diffstat (limited to 'src/html')
-rw-r--r--src/html/html_body_element.c66
-rw-r--r--src/html/html_body_element.h2
-rw-r--r--src/html/html_document.c4
-rw-r--r--src/html/html_document_strings.h7
4 files changed, 67 insertions, 12 deletions
diff --git a/src/html/html_body_element.c b/src/html/html_body_element.c
index 8c790b4..812a25c 100644
--- a/src/html/html_body_element.c
+++ b/src/html/html_body_element.c
@@ -7,7 +7,10 @@
#include <stdlib.h>
+#include <dom/html/html_body_element.h>
+
#include "html/html_body_element.h"
+#include "html/html_document.h"
#include "core/node.h"
#include "utils/utils.h"
@@ -27,6 +30,7 @@ static struct dom_element_protected_vtable _protect_vtable = {
* \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
dom_exception _dom_html_body_element_create(struct dom_html_document *doc,
+ dom_string *namespace, dom_string *prefix,
struct dom_html_body_element **ele)
{
struct dom_node_internal *node;
@@ -40,7 +44,7 @@ dom_exception _dom_html_body_element_create(struct dom_html_document *doc,
node->base.vtable = &_dom_element_vtable;
node->vtable = &_protect_vtable;
- return _dom_html_body_element_initialise(doc, *ele);
+ return _dom_html_body_element_initialise(doc, namespace, prefix, *ele);
}
/**
@@ -51,19 +55,11 @@ dom_exception _dom_html_body_element_create(struct dom_html_document *doc,
* \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
dom_exception _dom_html_body_element_initialise(struct dom_html_document *doc,
+ dom_string *namespace, dom_string *prefix,
struct dom_html_body_element *ele)
{
- dom_string *name = NULL;
- dom_exception err;
-
- err = dom_string_create((const uint8_t *) "BODY", SLEN("BODY"), &name);
- if (err != DOM_NO_ERR)
- return err;
-
- err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
- dom_string_unref(name);
-
- return err;
+ return _dom_html_element_initialise(doc, &ele->base,
+ doc->memoised[hds_BODY], namespace, prefix);
}
/**
@@ -118,3 +114,49 @@ dom_exception _dom_html_body_element_copy(dom_node_internal *old,
return _dom_html_element_copy(old, copy);
}
+/*-----------------------------------------------------------------------*/
+/* API functions */
+
+#define SIMPLE_GET(attr) \
+ dom_exception dom_html_body_element_get_##attr( \
+ dom_html_body_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_body_element_set_##attr( \
+ dom_html_body_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(a_link)
+SIMPLE_GET_SET(background)
+SIMPLE_GET_SET(bg_color)
+SIMPLE_GET_SET(link)
+SIMPLE_GET_SET(text)
+SIMPLE_GET_SET(v_link)
diff --git a/src/html/html_body_element.h b/src/html/html_body_element.h
index abf77da..2763680 100644
--- a/src/html/html_body_element.h
+++ b/src/html/html_body_element.h
@@ -19,10 +19,12 @@ struct dom_html_body_element {
/* Create a dom_html_body_element object */
dom_exception _dom_html_body_element_create(struct dom_html_document *doc,
+ dom_string *namespace, dom_string *prefix,
struct dom_html_body_element **ele);
/* Initialise a dom_html_body_element object */
dom_exception _dom_html_body_element_initialise(struct dom_html_document *doc,
+ dom_string *namespace, dom_string *prefix,
struct dom_html_body_element *ele);
/* Finalise a dom_html_body_element object */
diff --git a/src/html/html_document.c b/src/html/html_document.c
index 7644fde..ffc2e1c 100644
--- a/src/html/html_document.c
+++ b/src/html/html_document.c
@@ -13,6 +13,7 @@
#include "html/html_collection.h"
#include "html/html_html_element.h"
#include "html/html_head_element.h"
+#include "html/html_body_element.h"
#include "html/html_link_element.h"
#include "html/html_title_element.h"
#include "html/html_meta_element.h"
@@ -188,6 +189,9 @@ _dom_html_document_create_element_internal(dom_html_document *html,
} else if (dom_string_caseless_isequal(tag_name, html->memoised[hds_TITLE])) {
exc = _dom_html_title_element_create(html, namespace, prefix,
(dom_html_title_element **) result);
+ } else if (dom_string_caseless_isequal(tag_name, html->memoised[hds_BODY])) {
+ exc = _dom_html_body_element_create(html, namespace, prefix,
+ (dom_html_body_element **) result);
} else if (dom_string_caseless_isequal(tag_name, html->memoised[hds_FORM])) {
exc = _dom_html_form_element_create(html, namespace, prefix,
(dom_html_form_element **) result);
diff --git a/src/html/html_document_strings.h b/src/html/html_document_strings.h
index f7ecf4e..bd33866 100644
--- a/src/html/html_document_strings.h
+++ b/src/html/html_document_strings.h
@@ -50,6 +50,13 @@ HTML_DOCUMENT_STRINGS_ACTION1(content)
HTML_DOCUMENT_STRINGS_ACTION(http_equiv,http-equiv)
HTML_DOCUMENT_STRINGS_ACTION1(name)
HTML_DOCUMENT_STRINGS_ACTION1(scheme)
+/* HTMLBodyElement attributes */
+HTML_DOCUMENT_STRINGS_ACTION(a_link,alink)
+HTML_DOCUMENT_STRINGS_ACTION(v_link,vlink)
+HTML_DOCUMENT_STRINGS_ACTION(bg_color,bgcolor)
+HTML_DOCUMENT_STRINGS_ACTION1(background)
+HTML_DOCUMENT_STRINGS_ACTION1(link)
+HTML_DOCUMENT_STRINGS_ACTION1(text)
/* Useful attributes used by HTMLFormElement */
HTML_DOCUMENT_STRINGS_ACTION(accept_charset,accept-charset)
HTML_DOCUMENT_STRINGS_ACTION1(action)