summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2012-07-22 12:07:26 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2012-07-22 12:07:26 +0100
commitf3a8f9b62f805739acd19082026eb5afd3df9640 (patch)
treecb51116e0216a1e5c16178a37e45630e0409b2c5
parent9f74d817eec3a46f0c34dcd43ad2325fb9cc06bd (diff)
downloadlibdom-f3a8f9b62f805739acd19082026eb5afd3df9640.tar.gz
libdom-f3a8f9b62f805739acd19082026eb5afd3df9640.tar.bz2
HTMLBodyElement: Implementation and test enabling
-rw-r--r--Makefile1
-rw-r--r--include/dom/dom.h1
-rw-r--r--include/dom/html/html_body_element.h41
-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
-rw-r--r--test/testcases/tests/level1/html/HTMLBodyElement01.xml (renamed from test/testcases/tests/level1/html/HTMLBodyElement01.xml.notimpl)0
-rw-r--r--test/testcases/tests/level1/html/HTMLBodyElement02.xml (renamed from test/testcases/tests/level1/html/HTMLBodyElement02.xml.notimpl)0
-rw-r--r--test/testcases/tests/level1/html/HTMLBodyElement03.xml (renamed from test/testcases/tests/level1/html/HTMLBodyElement03.xml.notimpl)0
-rw-r--r--test/testcases/tests/level1/html/HTMLBodyElement04.xml (renamed from test/testcases/tests/level1/html/HTMLBodyElement04.xml.notimpl)0
-rw-r--r--test/testcases/tests/level1/html/HTMLBodyElement05.xml (renamed from test/testcases/tests/level1/html/HTMLBodyElement05.xml.notimpl)0
-rw-r--r--test/testcases/tests/level1/html/HTMLBodyElement06.xml (renamed from test/testcases/tests/level1/html/HTMLBodyElement06.xml.notimpl)0
13 files changed, 109 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index be9cc2d..6918bb7 100644
--- a/Makefile
+++ b/Makefile
@@ -86,6 +86,7 @@ INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_html_element.h
INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_head_element.h
INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_link_element.h
INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_title_element.h
+INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_body_element.h
INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_meta_element.h
INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_form_element.h
INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_button_element.h
diff --git a/include/dom/dom.h b/include/dom/dom.h
index 7a17152..b68085a 100644
--- a/include/dom/dom.h
+++ b/include/dom/dom.h
@@ -45,6 +45,7 @@
#include <dom/html/html_head_element.h>
#include <dom/html/html_link_element.h>
#include <dom/html/html_title_element.h>
+#include <dom/html/html_body_element.h>
#include <dom/html/html_meta_element.h>
#include <dom/html/html_form_element.h>
#include <dom/html/html_input_element.h>
diff --git a/include/dom/html/html_body_element.h b/include/dom/html/html_body_element.h
index 4df4ead..febd285 100644
--- a/include/dom/html/html_body_element.h
+++ b/include/dom/html/html_body_element.h
@@ -2,13 +2,52 @@
* 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>
+ * Copyright 2012 Daniel Silverstone <dsilvers@netsurf-browser.org>
*/
#ifndef dom_html_body_element_h_
#define dom_html_body_element_h_
+#include <dom/core/exceptions.h>
+#include <dom/core/string.h>
+
typedef struct dom_html_body_element dom_html_body_element;
+dom_exception dom_html_body_element_get_a_link(dom_html_body_element *ele,
+ dom_string **a_link);
+
+dom_exception dom_html_body_element_set_a_link(dom_html_body_element *ele,
+ dom_string *a_link);
+
+dom_exception dom_html_body_element_get_v_link(dom_html_body_element *ele,
+ dom_string **v_link);
+
+dom_exception dom_html_body_element_set_v_link(dom_html_body_element *ele,
+ dom_string *v_link);
+
+dom_exception dom_html_body_element_get_background(dom_html_body_element *ele,
+ dom_string **background);
+
+dom_exception dom_html_body_element_set_background(dom_html_body_element *ele,
+ dom_string *background);
+
+dom_exception dom_html_body_element_get_bg_color(dom_html_body_element *ele,
+ dom_string **bg_color);
+
+dom_exception dom_html_body_element_set_bg_color(dom_html_body_element *ele,
+ dom_string *bg_color);
+
+dom_exception dom_html_body_element_get_link(dom_html_body_element *ele,
+ dom_string **link);
+
+dom_exception dom_html_body_element_set_link(dom_html_body_element *ele,
+ dom_string *link);
+
+dom_exception dom_html_body_element_get_text(dom_html_body_element *ele,
+ dom_string **text);
+
+dom_exception dom_html_body_element_set_text(dom_html_body_element *ele,
+ dom_string *text);
+
#endif
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)
diff --git a/test/testcases/tests/level1/html/HTMLBodyElement01.xml.notimpl b/test/testcases/tests/level1/html/HTMLBodyElement01.xml
index 95438c6..95438c6 100644
--- a/test/testcases/tests/level1/html/HTMLBodyElement01.xml.notimpl
+++ b/test/testcases/tests/level1/html/HTMLBodyElement01.xml
diff --git a/test/testcases/tests/level1/html/HTMLBodyElement02.xml.notimpl b/test/testcases/tests/level1/html/HTMLBodyElement02.xml
index e5e7d34..e5e7d34 100644
--- a/test/testcases/tests/level1/html/HTMLBodyElement02.xml.notimpl
+++ b/test/testcases/tests/level1/html/HTMLBodyElement02.xml
diff --git a/test/testcases/tests/level1/html/HTMLBodyElement03.xml.notimpl b/test/testcases/tests/level1/html/HTMLBodyElement03.xml
index 3f0d492..3f0d492 100644
--- a/test/testcases/tests/level1/html/HTMLBodyElement03.xml.notimpl
+++ b/test/testcases/tests/level1/html/HTMLBodyElement03.xml
diff --git a/test/testcases/tests/level1/html/HTMLBodyElement04.xml.notimpl b/test/testcases/tests/level1/html/HTMLBodyElement04.xml
index 0bbab8c..0bbab8c 100644
--- a/test/testcases/tests/level1/html/HTMLBodyElement04.xml.notimpl
+++ b/test/testcases/tests/level1/html/HTMLBodyElement04.xml
diff --git a/test/testcases/tests/level1/html/HTMLBodyElement05.xml.notimpl b/test/testcases/tests/level1/html/HTMLBodyElement05.xml
index b9b1596..b9b1596 100644
--- a/test/testcases/tests/level1/html/HTMLBodyElement05.xml.notimpl
+++ b/test/testcases/tests/level1/html/HTMLBodyElement05.xml
diff --git a/test/testcases/tests/level1/html/HTMLBodyElement06.xml.notimpl b/test/testcases/tests/level1/html/HTMLBodyElement06.xml
index e2adef5..e2adef5 100644
--- a/test/testcases/tests/level1/html/HTMLBodyElement06.xml.notimpl
+++ b/test/testcases/tests/level1/html/HTMLBodyElement06.xml