From 73cbed2db0bb587f2c544cdf92dbf56eb7a79971 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sat, 7 Jul 2012 15:31:40 +0100 Subject: HTMLTitleElement: Implementation and enabling of test --- src/html/TODO | 2 +- src/html/html_document.c | 16 +++++++--------- src/html/html_title_element.c | 20 +++++++------------- src/html/html_title_element.h | 2 ++ 4 files changed, 17 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/html/TODO b/src/html/TODO index 491e916..fa5f8f0 100644 --- a/src/html/TODO +++ b/src/html/TODO @@ -4,7 +4,7 @@ HTMLElement html_element UNFINISHED HTMLHtmlElement html_html_element DONE HTMLHeadElement html_head_element DONE HTMLLinkElement html_link_element MISSING -HTMLTitleElement html_title_element MISSING +HTMLTitleElement html_title_element DONE HTMLMetaElement html_meta_element MISSING HTMLBaseElement html_base_element MISSING HTMLIsIndexElement html_isindex_element MISSING diff --git a/src/html/html_document.c b/src/html/html_document.c index 6978e06..11ee899 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_title_element.h" #include "core/string.h" #include "utils/namespace.h" @@ -170,6 +171,11 @@ _dom_html_document_create_element_internal(dom_html_document *html, (dom_html_head_element **) result); } + if (dom_string_caseless_isequal(tag_name, html->memoised[hds_TITLE])) { + return _dom_html_title_element_create(html, namespace, prefix, + (dom_html_title_element **) result); + } + return _dom_html_element_create(html, tag_name, namespace, prefix, result); } @@ -293,20 +299,12 @@ dom_exception _dom_html_document_get_title(dom_html_document *doc, *title = dom_string_ref(doc->title); } else { dom_element *node; - dom_string *title_str; dom_nodelist *nodes; unsigned long len; - exc = dom_string_create_interned((uint8_t*)"title", - 5, &title_str); - if (exc != DOM_NO_ERR) { - return exc; - } - exc = dom_document_get_elements_by_tag_name(doc, - title_str, + doc->memoised[hds_TITLE], &nodes); - dom_string_unref(title_str); if (exc != DOM_NO_ERR) { return exc; } diff --git a/src/html/html_title_element.c b/src/html/html_title_element.c index ea4d24c..73870a6 100644 --- a/src/html/html_title_element.c +++ b/src/html/html_title_element.c @@ -11,6 +11,7 @@ #include #include +#include "html/html_document.h" #include "html/html_title_element.h" #include "core/node.h" @@ -31,6 +32,7 @@ static struct dom_element_protected_vtable _protect_vtable = { * \return DOM_NO_ERR on success, appropriate dom_exception on failure. */ dom_exception _dom_html_title_element_create(struct dom_html_document *doc, + dom_string *namespace, dom_string *prefix, struct dom_html_title_element **ele) { struct dom_node_internal *node; @@ -44,7 +46,7 @@ dom_exception _dom_html_title_element_create(struct dom_html_document *doc, node->base.vtable = &_dom_element_vtable; node->vtable = &_protect_vtable; - return _dom_html_title_element_initialise(doc, *ele); + return _dom_html_title_element_initialise(doc, namespace, prefix, *ele); } /** @@ -55,20 +57,12 @@ dom_exception _dom_html_title_element_create(struct dom_html_document *doc, * \return DOM_NO_ERR on success, appropriate dom_exception on failure. */ dom_exception _dom_html_title_element_initialise(struct dom_html_document *doc, + dom_string *namespace, dom_string *prefix, struct dom_html_title_element *ele) { - dom_string *name = NULL; - dom_exception err; - - err = dom_string_create((const uint8_t *) "TITLE", SLEN("TITLE"), - &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_TITLE], + namespace, prefix); } /** diff --git a/src/html/html_title_element.h b/src/html/html_title_element.h index 958c3fe..51adaf9 100644 --- a/src/html/html_title_element.h +++ b/src/html/html_title_element.h @@ -19,10 +19,12 @@ struct dom_html_title_element { /* Create a dom_html_title_element object */ dom_exception _dom_html_title_element_create(struct dom_html_document *doc, + dom_string *namespace, dom_string *prefix, struct dom_html_title_element **ele); /* Initialise a dom_html_title_element object */ dom_exception _dom_html_title_element_initialise(struct dom_html_document *doc, + dom_string *namespace, dom_string *prefix, struct dom_html_title_element *ele); /* Finalise a dom_html_title_element object */ -- cgit v1.2.3