summaryrefslogtreecommitdiff
path: root/src/html/html_document.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/html/html_document.c')
-rw-r--r--src/html/html_document.c91
1 files changed, 45 insertions, 46 deletions
diff --git a/src/html/html_document.c b/src/html/html_document.c
index a2a7ed5..7644fde 100644
--- a/src/html/html_document.c
+++ b/src/html/html_document.c
@@ -116,15 +116,20 @@ out:
}
/* Finalise a HTMLDocument */
-void _dom_html_document_finalise(dom_html_document *doc)
+bool _dom_html_document_finalise(dom_html_document *doc)
{
int sidx;
- dom_string_unref(doc->cookie);
- dom_string_unref(doc->url);
- dom_string_unref(doc->domain);
- dom_string_unref(doc->referrer);
- dom_string_unref(doc->title);
+ if (doc->cookie != NULL)
+ dom_string_unref(doc->cookie);
+ if (doc->url != NULL)
+ dom_string_unref(doc->url);
+ if (doc->domain != NULL)
+ dom_string_unref(doc->domain);
+ if (doc->referrer != NULL)
+ dom_string_unref(doc->referrer);
+ if (doc->title != NULL)
+ dom_string_unref(doc->title);
if (doc->memoised != NULL) {
for(sidx = 0; sidx < hds_COUNT; ++sidx) {
@@ -136,7 +141,7 @@ void _dom_html_document_finalise(dom_html_document *doc)
doc->memoised = NULL;
}
- _dom_document_finalise(&doc->base);
+ return _dom_document_finalise(&doc->base);
}
/* Destroy a HTMLDocument */
@@ -144,9 +149,8 @@ void _dom_html_document_destroy(dom_node_internal *node)
{
dom_html_document *doc = (dom_html_document *) node;
- _dom_html_document_finalise(doc);
-
- free(doc);
+ if (_dom_html_document_finalise(doc) == true)
+ free(doc);
}
dom_exception _dom_html_document_copy(dom_node_internal *old,
@@ -163,58 +167,53 @@ dom_exception _dom_html_document_copy(dom_node_internal *old,
/** Internal method to support both kinds of create method */
static dom_exception
_dom_html_document_create_element_internal(dom_html_document *html,
- dom_string *tag_name,
+ dom_string *in_tag_name,
dom_string *namespace,
dom_string *prefix,
dom_html_element **result)
{
+ dom_exception exc;
+ dom_string *tag_name;
+
+ exc = dom_string_toupper(in_tag_name, true, &tag_name);
+ if (exc != DOM_NO_ERR)
+ return exc;
+
if (dom_string_caseless_isequal(tag_name, html->memoised[hds_HTML])) {
- return _dom_html_html_element_create(html, namespace, prefix,
+ exc = _dom_html_html_element_create(html, namespace, prefix,
(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,
+ } else if (dom_string_caseless_isequal(tag_name, html->memoised[hds_HEAD])) {
+ exc = _dom_html_head_element_create(html, namespace, prefix,
(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,
+ } 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);
- }
-
- if (dom_string_caseless_isequal(tag_name, html->memoised[hds_FORM])) {
- return _dom_html_form_element_create(html, namespace, prefix,
+ } 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);
- }
-
- if (dom_string_caseless_isequal(tag_name, html->memoised[hds_LINK])) {
- return _dom_html_link_element_create(html, namespace, prefix,
+ } else if (dom_string_caseless_isequal(tag_name, html->memoised[hds_LINK])) {
+ exc = _dom_html_link_element_create(html, namespace, prefix,
(dom_html_link_element **) result);
- }
-
- if (dom_string_caseless_isequal(tag_name, html->memoised[hds_BUTTON])) {
- return _dom_html_button_element_create(html, namespace, prefix,
+ } else if (dom_string_caseless_isequal(tag_name, html->memoised[hds_BUTTON])) {
+ exc = _dom_html_button_element_create(html, namespace, prefix,
(dom_html_button_element **) result);
- }
-
- if (dom_string_caseless_isequal(tag_name, html->memoised[hds_INPUT])) {
- return _dom_html_input_element_create(html, namespace, prefix,
+ } else if (dom_string_caseless_isequal(tag_name, html->memoised[hds_INPUT])) {
+ exc = _dom_html_input_element_create(html, namespace, prefix,
(dom_html_input_element **) result);
- }
-
- if (dom_string_caseless_isequal(tag_name, html->memoised[hds_TEXTAREA])) {
- return _dom_html_text_area_element_create(html, namespace, prefix,
+ } else if (dom_string_caseless_isequal(tag_name, html->memoised[hds_TEXTAREA])) {
+ exc = _dom_html_text_area_element_create(html, namespace, prefix,
(dom_html_text_area_element **) result);
- }
-
- if (dom_string_caseless_isequal(tag_name, html->memoised[hds_OPTGROUP])) {
- return _dom_html_opt_group_element_create(html, namespace, prefix,
+ } else if (dom_string_caseless_isequal(tag_name, html->memoised[hds_OPTGROUP])) {
+ exc = _dom_html_opt_group_element_create(html, namespace, prefix,
(dom_html_opt_group_element **) result);
+ } else {
+ exc = _dom_html_element_create(html, tag_name, namespace,
+ prefix, result);
}
- return _dom_html_element_create(html, tag_name, namespace, prefix,
- result);
+ dom_string_unref(tag_name);
+
+ return exc;
}
dom_exception _dom_html_document_create_element(dom_document *doc,