From f3a8f9b62f805739acd19082026eb5afd3df9640 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sun, 22 Jul 2012 12:07:26 +0100 Subject: HTMLBodyElement: Implementation and test enabling --- Makefile | 1 + include/dom/dom.h | 1 + include/dom/html/html_body_element.h | 41 +++++++++++++- src/html/html_body_element.c | 66 ++++++++++++++++++---- src/html/html_body_element.h | 2 + src/html/html_document.c | 4 ++ src/html/html_document_strings.h | 7 +++ .../tests/level1/html/HTMLBodyElement01.xml | 42 ++++++++++++++ .../level1/html/HTMLBodyElement01.xml.notimpl | 42 -------------- .../tests/level1/html/HTMLBodyElement02.xml | 43 ++++++++++++++ .../level1/html/HTMLBodyElement02.xml.notimpl | 43 -------------- .../tests/level1/html/HTMLBodyElement03.xml | 42 ++++++++++++++ .../level1/html/HTMLBodyElement03.xml.notimpl | 42 -------------- .../tests/level1/html/HTMLBodyElement04.xml | 43 ++++++++++++++ .../level1/html/HTMLBodyElement04.xml.notimpl | 43 -------------- .../tests/level1/html/HTMLBodyElement05.xml | 42 ++++++++++++++ .../level1/html/HTMLBodyElement05.xml.notimpl | 42 -------------- .../tests/level1/html/HTMLBodyElement06.xml | 43 ++++++++++++++ .../level1/html/HTMLBodyElement06.xml.notimpl | 43 -------------- 19 files changed, 364 insertions(+), 268 deletions(-) create mode 100644 test/testcases/tests/level1/html/HTMLBodyElement01.xml delete mode 100644 test/testcases/tests/level1/html/HTMLBodyElement01.xml.notimpl create mode 100644 test/testcases/tests/level1/html/HTMLBodyElement02.xml delete mode 100644 test/testcases/tests/level1/html/HTMLBodyElement02.xml.notimpl create mode 100644 test/testcases/tests/level1/html/HTMLBodyElement03.xml delete mode 100644 test/testcases/tests/level1/html/HTMLBodyElement03.xml.notimpl create mode 100644 test/testcases/tests/level1/html/HTMLBodyElement04.xml delete mode 100644 test/testcases/tests/level1/html/HTMLBodyElement04.xml.notimpl create mode 100644 test/testcases/tests/level1/html/HTMLBodyElement05.xml delete mode 100644 test/testcases/tests/level1/html/HTMLBodyElement05.xml.notimpl create mode 100644 test/testcases/tests/level1/html/HTMLBodyElement06.xml delete mode 100644 test/testcases/tests/level1/html/HTMLBodyElement06.xml.notimpl 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 #include #include +#include #include #include #include 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 + * Copyright 2012 Daniel Silverstone */ #ifndef dom_html_body_element_h_ #define dom_html_body_element_h_ +#include +#include + 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 +#include + #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 b/test/testcases/tests/level1/html/HTMLBodyElement01.xml new file mode 100644 index 0000000..95438c6 --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLBodyElement01.xml @@ -0,0 +1,42 @@ + + + + + + + +HTMLBodyElement01 +NIST + + The aLink attribute specifies the color of active links. + + Retrieve the aLink attribute and examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLBodyElement01.xml.notimpl b/test/testcases/tests/level1/html/HTMLBodyElement01.xml.notimpl deleted file mode 100644 index 95438c6..0000000 --- a/test/testcases/tests/level1/html/HTMLBodyElement01.xml.notimpl +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - -HTMLBodyElement01 -NIST - - The aLink attribute specifies the color of active links. - - Retrieve the aLink attribute and examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLBodyElement02.xml b/test/testcases/tests/level1/html/HTMLBodyElement02.xml new file mode 100644 index 0000000..e5e7d34 --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLBodyElement02.xml @@ -0,0 +1,43 @@ + + + + + + + +HTMLBodyElement02 +NIST + + The background attribute specifies the URI fo the background texture + tile image. + + Retrieve the background attribute and examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLBodyElement02.xml.notimpl b/test/testcases/tests/level1/html/HTMLBodyElement02.xml.notimpl deleted file mode 100644 index e5e7d34..0000000 --- a/test/testcases/tests/level1/html/HTMLBodyElement02.xml.notimpl +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - -HTMLBodyElement02 -NIST - - The background attribute specifies the URI fo the background texture - tile image. - - Retrieve the background attribute and examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLBodyElement03.xml b/test/testcases/tests/level1/html/HTMLBodyElement03.xml new file mode 100644 index 0000000..3f0d492 --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLBodyElement03.xml @@ -0,0 +1,42 @@ + + + + + + + +HTMLBodyElement03 +NIST + + The bgColor attribute specifies the document background color. + + Retrieve the bgColor attribute and examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLBodyElement03.xml.notimpl b/test/testcases/tests/level1/html/HTMLBodyElement03.xml.notimpl deleted file mode 100644 index 3f0d492..0000000 --- a/test/testcases/tests/level1/html/HTMLBodyElement03.xml.notimpl +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - -HTMLBodyElement03 -NIST - - The bgColor attribute specifies the document background color. - - Retrieve the bgColor attribute and examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLBodyElement04.xml b/test/testcases/tests/level1/html/HTMLBodyElement04.xml new file mode 100644 index 0000000..0bbab8c --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLBodyElement04.xml @@ -0,0 +1,43 @@ + + + + + + + +HTMLBodyElement04 +NIST + + The link attribute specifies the color of links that are not active + and unvisited. + + Retrieve the link attribute and examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLBodyElement04.xml.notimpl b/test/testcases/tests/level1/html/HTMLBodyElement04.xml.notimpl deleted file mode 100644 index 0bbab8c..0000000 --- a/test/testcases/tests/level1/html/HTMLBodyElement04.xml.notimpl +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - -HTMLBodyElement04 -NIST - - The link attribute specifies the color of links that are not active - and unvisited. - - Retrieve the link attribute and examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLBodyElement05.xml b/test/testcases/tests/level1/html/HTMLBodyElement05.xml new file mode 100644 index 0000000..b9b1596 --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLBodyElement05.xml @@ -0,0 +1,42 @@ + + + + + + + +HTMLBodyElement05 +NIST + + The text attribute specifies the document text color. + + Retrieve the text attribute and examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLBodyElement05.xml.notimpl b/test/testcases/tests/level1/html/HTMLBodyElement05.xml.notimpl deleted file mode 100644 index b9b1596..0000000 --- a/test/testcases/tests/level1/html/HTMLBodyElement05.xml.notimpl +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - -HTMLBodyElement05 -NIST - - The text attribute specifies the document text color. - - Retrieve the text attribute and examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLBodyElement06.xml b/test/testcases/tests/level1/html/HTMLBodyElement06.xml new file mode 100644 index 0000000..e2adef5 --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLBodyElement06.xml @@ -0,0 +1,43 @@ + + + + + + + +HTMLBodyElement06 +NIST + + The vLink attribute specifies the color of links that have been + visited by the user. + + Retrieve the vLink attribute and examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLBodyElement06.xml.notimpl b/test/testcases/tests/level1/html/HTMLBodyElement06.xml.notimpl deleted file mode 100644 index e2adef5..0000000 --- a/test/testcases/tests/level1/html/HTMLBodyElement06.xml.notimpl +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - -HTMLBodyElement06 -NIST - - The vLink attribute specifies the color of links that have been - visited by the user. - - Retrieve the vLink attribute and examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - -- cgit v1.2.3