From 890da96b1b601f622a12a7832c3cb654b146e693 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sat, 7 Jul 2012 18:12:12 +0100 Subject: HTMLMetaElement: Implement, install, enable tests --- src/html/html_meta_element.c | 57 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 12 deletions(-) (limited to 'src/html/html_meta_element.c') diff --git a/src/html/html_meta_element.c b/src/html/html_meta_element.c index f1b6c3f..9cc8067 100644 --- a/src/html/html_meta_element.c +++ b/src/html/html_meta_element.c @@ -7,6 +7,7 @@ #include +#include "html/html_document.h" #include "html/html_meta_element.h" #include "core/node.h" @@ -27,6 +28,7 @@ static struct dom_element_protected_vtable _protect_vtable = { * \return DOM_NO_ERR on success, appropriate dom_exception on failure. */ dom_exception _dom_html_meta_element_create(struct dom_html_document *doc, + dom_string *namespace, dom_string *prefix, struct dom_html_meta_element **ele) { struct dom_node_internal *node; @@ -40,7 +42,7 @@ dom_exception _dom_html_meta_element_create(struct dom_html_document *doc, node->base.vtable = &_dom_element_vtable; node->vtable = &_protect_vtable; - return _dom_html_meta_element_initialise(doc, *ele); + return _dom_html_meta_element_initialise(doc, namespace, prefix, *ele); } /** @@ -51,19 +53,12 @@ dom_exception _dom_html_meta_element_create(struct dom_html_document *doc, * \return DOM_NO_ERR on success, appropriate dom_exception on failure. */ dom_exception _dom_html_meta_element_initialise(struct dom_html_document *doc, + dom_string *namespace, dom_string *prefix, struct dom_html_meta_element *ele) { - dom_string *name = NULL; - dom_exception err; - - err = dom_string_create((const uint8_t *) "META", SLEN("META"), &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_META], + namespace, prefix); } /** @@ -118,3 +113,41 @@ dom_exception _dom_html_meta_element_copy(dom_node_internal *old, return _dom_html_element_copy(old, copy); } +/*-----------------------------------------------------------------------*/ +/* API functions */ + +#define SIMPLE_GET_SET(fattr,attr) \ +dom_exception dom_html_meta_element_get_##fattr(dom_html_meta_element *element, \ + dom_string **fattr) \ +{ \ + 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, fattr); \ + \ + return ret; \ +} \ + \ +dom_exception dom_html_meta_element_set_##fattr(dom_html_meta_element *element, \ + dom_string *fattr) \ +{ \ + 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, fattr); \ + \ + return ret; \ +} + +SIMPLE_GET_SET(content,content) +SIMPLE_GET_SET(http_equiv,http_equiv) +SIMPLE_GET_SET(name,name) +SIMPLE_GET_SET(scheme,scheme) -- cgit v1.2.3