diff options
author | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2012-07-22 11:47:43 +0100 |
---|---|---|
committer | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2012-07-22 11:47:43 +0100 |
commit | bd0a5acd849ceac494c19a67d2180030e7bea083 (patch) | |
tree | b1ae865d9e69e1cc7ca8d453a0669e547709d28e /src/html/html_document.c | |
parent | 87cb5c0e426c5022a43598d4977f4924436ed058 (diff) | |
parent | d0499715bb2184a48ee7f2fdfc093fbf3fcf3286 (diff) | |
download | libdom-bd0a5acd849ceac494c19a67d2180030e7bea083.tar.gz libdom-bd0a5acd849ceac494c19a67d2180030e7bea083.tar.bz2 |
Merge branch 'master' of git://git.netsurf-browser.org/libdom into chris/amiga-hubbub-lib-compat
Diffstat (limited to 'src/html/html_document.c')
-rw-r--r-- | src/html/html_document.c | 91 |
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, |