summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2012-07-07 15:14:26 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2012-07-07 15:14:26 +0100
commit96f36b38bdfb3008d5cd6e94da6ad13faf93fd97 (patch)
treeecf3ff81b6f25bc069396dfb901c10cf52c2aa8e
parent4a4a68d432a41038397d44faaebf23c05f7d544a (diff)
downloadlibdom-96f36b38bdfb3008d5cd6e94da6ad13faf93fd97.tar.gz
libdom-96f36b38bdfb3008d5cd6e94da6ad13faf93fd97.tar.bz2
HTMLHeadElement: Support for the element, enable the test
-rw-r--r--Makefile1
-rw-r--r--include/dom/dom.h1
-rw-r--r--include/dom/html/html_head_element.h30
-rw-r--r--src/html/TODO2
-rw-r--r--src/html/html_document.c6
-rw-r--r--src/html/html_document_strings.h2
-rw-r--r--src/html/html_head_element.c69
-rw-r--r--src/html/html_head_element.h12
-rw-r--r--test/testcases/tests/level1/html/HTMLHeadElement01.xml (renamed from test/testcases/tests/level1/html/HTMLHeadElement01.xml.kfail)0
9 files changed, 109 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index 15954de..eab868d 100644
--- a/Makefile
+++ b/Makefile
@@ -82,6 +82,7 @@ I := /include/dom/html
INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_document.h
INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_element.h
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_form_element.h
INSTALL_ITEMS := $(INSTALL_ITEMS) /lib/pkgconfig:lib$(COMPONENT).pc.in
diff --git a/include/dom/dom.h b/include/dom/dom.h
index 0ce0a23..77a40b3 100644
--- a/include/dom/dom.h
+++ b/include/dom/dom.h
@@ -41,6 +41,7 @@
#include <dom/html/html_document.h>
#include <dom/html/html_element.h>
#include <dom/html/html_html_element.h>
+#include <dom/html/html_head_element.h>
#include <dom/html/html_form_element.h>
/* DOM Events header */
diff --git a/include/dom/html/html_head_element.h b/include/dom/html/html_head_element.h
index e00fc19..ce2a817 100644
--- a/include/dom/html/html_head_element.h
+++ b/include/dom/html/html_head_element.h
@@ -8,7 +8,37 @@
#ifndef dom_html_head_element_h_
#define dom_html_head_element_h_
+#include <dom/html/html_element.h>
+
typedef struct dom_html_head_element dom_html_head_element;
+typedef struct dom_html_head_element_vtable {
+ struct dom_html_element_vtable base;
+
+ dom_exception (*dom_html_head_element_get_profile)(struct dom_html_head_element *element,
+ dom_string **profile);
+ dom_exception (*dom_html_head_element_set_profile)(struct dom_html_head_element *element,
+ dom_string *profile);
+} dom_html_head_element_vtable;
+
+static inline dom_exception dom_html_head_element_get_profile(
+ struct dom_html_head_element *element, dom_string **profile)
+{
+ return ((dom_html_head_element_vtable *) ((dom_node *) element)->vtable)->
+ dom_html_head_element_get_profile(element, profile);
+}
+#define dom_html_head_element_get_profile(e, profile) \
+ dom_html_head_element_get_profile((dom_html_head_element *) (e), (profile))
+
+static inline dom_exception dom_html_head_element_set_profile(
+ struct dom_html_head_element *element, dom_string *profile)
+{
+ return ((dom_html_head_element_vtable *) ((dom_node *) element)->vtable)->
+ dom_html_head_element_set_profile(element, profile);
+}
+#define dom_html_head_element_set_profile(e, profile) \
+ dom_html_head_element_set_profile((dom_html_head_element *) (e), (profile))
+
+
#endif
diff --git a/src/html/TODO b/src/html/TODO
index 41ad83c..491e916 100644
--- a/src/html/TODO
+++ b/src/html/TODO
@@ -2,7 +2,7 @@ The following is the status of the HTML Element and derived objects
HTMLElement html_element UNFINISHED
HTMLHtmlElement html_html_element DONE
-HTMLHeadElement html_head_element MISSING
+HTMLHeadElement html_head_element DONE
HTMLLinkElement html_link_element MISSING
HTMLTitleElement html_title_element MISSING
HTMLMetaElement html_meta_element MISSING
diff --git a/src/html/html_document.c b/src/html/html_document.c
index b93b253..6978e06 100644
--- a/src/html/html_document.c
+++ b/src/html/html_document.c
@@ -12,6 +12,7 @@
#include "html/html_element.h"
#include "html/html_collection.h"
#include "html/html_html_element.h"
+#include "html/html_head_element.h"
#include "core/string.h"
#include "utils/namespace.h"
@@ -164,6 +165,11 @@ _dom_html_document_create_element_internal(dom_html_document *html,
(dom_html_html_element **) result);
}
+ if (dom_string_caseless_isequal(tag_name, html->memoised[hds_HEAD])) {
+ return _dom_html_head_element_create(html, namespace, prefix,
+ (dom_html_head_element **) result);
+ }
+
return _dom_html_element_create(html, tag_name, namespace, prefix,
result);
}
diff --git a/src/html/html_document_strings.h b/src/html/html_document_strings.h
index ffa33b3..6be5846 100644
--- a/src/html/html_document_strings.h
+++ b/src/html/html_document_strings.h
@@ -32,6 +32,8 @@ HTML_DOCUMENT_STRINGS_ACTION(dir)
HTML_DOCUMENT_STRINGS_ACTION(class)
/* Useful attributes used by HTMLHtmlElement */
HTML_DOCUMENT_STRINGS_ACTION(version)
+/* Useful attributes used by HTMLHeadElement */
+HTML_DOCUMENT_STRINGS_ACTION(profile)
/* Names for elements which get specialised. */
HTML_DOCUMENT_STRINGS_ACTION(HTML)
HTML_DOCUMENT_STRINGS_ACTION(HEAD)
diff --git a/src/html/html_head_element.c b/src/html/html_head_element.c
index d74b8d1..6c5b99b 100644
--- a/src/html/html_head_element.c
+++ b/src/html/html_head_element.c
@@ -7,6 +7,7 @@
#include <stdlib.h>
+#include "html/html_document.h"
#include "html/html_head_element.h"
#include "core/node.h"
@@ -19,6 +20,22 @@ static struct dom_element_protected_vtable _protect_vtable = {
DOM_HTML_HEAD_ELEMENT_PROTECT_VTABLE
};
+static struct dom_html_head_element_vtable _vtable = {
+ {
+ {
+ {
+ {
+ DOM_NODE_EVENT_TARGET_VTABLE
+ },
+ DOM_NODE_VTABLE_ELEMENT,
+ },
+ DOM_ELEMENT_VTABLE
+ },
+ DOM_HTML_ELEMENT_VTABLE
+ },
+ DOM_HTML_HEAD_ELEMENT_VTABLE
+};
+
/**
* Create a dom_html_head_element object
*
@@ -27,6 +44,7 @@ static struct dom_element_protected_vtable _protect_vtable = {
* \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
dom_exception _dom_html_head_element_create(struct dom_html_document *doc,
+ dom_string *namespace, dom_string *prefix,
struct dom_html_head_element **ele)
{
struct dom_node_internal *node;
@@ -37,10 +55,10 @@ dom_exception _dom_html_head_element_create(struct dom_html_document *doc,
/* Set up vtables */
node = (struct dom_node_internal *) *ele;
- node->base.vtable = &_dom_element_vtable;
+ node->base.vtable = &_vtable;
node->vtable = &_protect_vtable;
- return _dom_html_head_element_initialise(doc, *ele);
+ return _dom_html_head_element_initialise(doc, namespace, prefix, *ele);
}
/**
@@ -51,19 +69,12 @@ dom_exception _dom_html_head_element_create(struct dom_html_document *doc,
* \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
dom_exception _dom_html_head_element_initialise(struct dom_html_document *doc,
+ dom_string *namespace, dom_string *prefix,
struct dom_html_head_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_HEAD],
+ namespace, prefix);
}
/**
@@ -118,3 +129,35 @@ dom_exception _dom_html_head_element_copy(dom_node_internal *old,
return _dom_html_element_copy(old, copy);
}
+/*-----------------------------------------------------------------------*/
+/* API functions */
+
+dom_exception _dom_html_head_element_get_profile(dom_html_head_element *element,
+ dom_string **profile)
+{
+ dom_exception ret;
+ dom_string *_memo_profile;
+
+ _memo_profile =
+ ((struct dom_html_document *)
+ ((struct dom_node_internal *)element)->owner)->memoised[hds_profile];
+
+ ret = dom_element_get_attribute(element, _memo_profile, profile);
+
+ return ret;
+}
+
+dom_exception _dom_html_head_element_set_profile(dom_html_head_element *element,
+ dom_string *profile)
+{
+ dom_exception ret;
+ dom_string *_memo_profile;
+
+ _memo_profile =
+ ((struct dom_html_document *)
+ ((struct dom_node_internal *)element)->owner)->memoised[hds_profile];
+
+ ret = dom_element_set_attribute(element, _memo_profile, profile);
+
+ return ret;
+}
diff --git a/src/html/html_head_element.h b/src/html/html_head_element.h
index aa6e21a..65cc3c5 100644
--- a/src/html/html_head_element.h
+++ b/src/html/html_head_element.h
@@ -19,10 +19,12 @@ struct dom_html_head_element {
/* Create a dom_html_head_element object */
dom_exception _dom_html_head_element_create(struct dom_html_document *doc,
+ dom_string *namespace, dom_string *prefix,
struct dom_html_head_element **ele);
/* Initialise a dom_html_head_element object */
dom_exception _dom_html_head_element_initialise(struct dom_html_document *doc,
+ dom_string *namespace, dom_string *prefix,
struct dom_html_head_element *ele);
/* Finalise a dom_html_head_element object */
@@ -46,5 +48,15 @@ dom_exception _dom_html_head_element_copy(dom_node_internal *old,
_dom_virtual_html_head_element_destroy, \
_dom_html_head_element_copy
+/* The API functions */
+dom_exception _dom_html_head_element_get_profile(dom_html_head_element *element,
+ dom_string **profile);
+dom_exception _dom_html_head_element_set_profile(dom_html_head_element *element,
+ dom_string *profile);
+
+#define DOM_HTML_HEAD_ELEMENT_VTABLE \
+ _dom_html_head_element_get_profile, \
+ _dom_html_head_element_set_profile
+
#endif
diff --git a/test/testcases/tests/level1/html/HTMLHeadElement01.xml.kfail b/test/testcases/tests/level1/html/HTMLHeadElement01.xml
index a0fd82b..a0fd82b 100644
--- a/test/testcases/tests/level1/html/HTMLHeadElement01.xml.kfail
+++ b/test/testcases/tests/level1/html/HTMLHeadElement01.xml