summaryrefslogtreecommitdiff
path: root/src/html/html_link_element.c
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2012-07-07 17:59:30 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2012-07-07 17:59:30 +0100
commit836b1bdd7ce363b318c7eabd688a55c5c707f380 (patch)
tree419779005bccb589561e1e4466d4e8adfa56d064 /src/html/html_link_element.c
parente3045cbd63f139c0448496b369a428657ae5bdf2 (diff)
downloadlibdom-836b1bdd7ce363b318c7eabd688a55c5c707f380.tar.gz
libdom-836b1bdd7ce363b318c7eabd688a55c5c707f380.tar.bz2
HTMLLinkElement: Implement and enable tests
Diffstat (limited to 'src/html/html_link_element.c')
-rw-r--r--src/html/html_link_element.c61
1 files changed, 49 insertions, 12 deletions
diff --git a/src/html/html_link_element.c b/src/html/html_link_element.c
index 92ca4f5..cf3d0e9 100644
--- a/src/html/html_link_element.c
+++ b/src/html/html_link_element.c
@@ -8,6 +8,7 @@
#include <assert.h>
#include <stdlib.h>
+#include "html/html_document.h"
#include "html/html_link_element.h"
#include "core/node.h"
@@ -29,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_link_element_create(struct dom_html_document *doc,
+ dom_string *namespace, dom_string *prefix,
struct dom_html_link_element **ele)
{
struct dom_node_internal *node;
@@ -42,7 +44,7 @@ dom_exception _dom_html_link_element_create(struct dom_html_document *doc,
node->base.vtable = &_dom_element_vtable;
node->vtable = &_protect_vtable;
- return _dom_html_link_element_initialise(doc, *ele);
+ return _dom_html_link_element_initialise(doc, namespace, prefix, *ele);
}
/**
@@ -53,19 +55,12 @@ dom_exception _dom_html_link_element_create(struct dom_html_document *doc,
* \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
dom_exception _dom_html_link_element_initialise(struct dom_html_document *doc,
+ dom_string *namespace, dom_string *prefix,
struct dom_html_link_element *ele)
{
- dom_string *name = NULL;
- dom_exception err;
-
- err = dom_string_create((const uint8_t *) "HEAD", SLEN("HEAD"), &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_LINK],
+ namespace, prefix);
}
/**
@@ -151,3 +146,45 @@ dom_exception _dom_html_link_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_link_element_get_##fattr(dom_html_link_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_link_element_set_##fattr(dom_html_link_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(charset,charset)
+SIMPLE_GET_SET(href,href)
+SIMPLE_GET_SET(hreflang,hreflang)
+SIMPLE_GET_SET(media,media)
+SIMPLE_GET_SET(rel,rel)
+SIMPLE_GET_SET(rev,rev)
+SIMPLE_GET_SET(target,target)
+SIMPLE_GET_SET(type,type)