diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2011-12-21 22:18:10 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2011-12-21 22:18:10 +0000 |
commit | 83f3338663c4969eebefd8c2c43bd3fc43587fdd (patch) | |
tree | e48ba69628c5ba793533094e308c1fce9acb21aa /src/html/html_element.c | |
parent | 4ade8ad1c7b23e6eeeee6681acbdb43fb10cab43 (diff) | |
download | libdom-83f3338663c4969eebefd8c2c43bd3fc43587fdd.tar.gz libdom-83f3338663c4969eebefd8c2c43bd3fc43587fdd.tar.bz2 |
Merge branches/jmb/dom-alloc-purge back to trunk
svn path=/trunk/libdom/; revision=13316
Diffstat (limited to 'src/html/html_element.c')
-rw-r--r-- | src/html/html_element.c | 63 |
1 files changed, 14 insertions, 49 deletions
diff --git a/src/html/html_element.c b/src/html/html_element.c index 3552c67..5fbf0da 100644 --- a/src/html/html_element.c +++ b/src/html/html_element.c @@ -6,6 +6,7 @@ */ #include <assert.h> +#include <stdlib.h> #include "html/html_element.h" @@ -15,8 +16,8 @@ #include "utils/utils.h" dom_exception _dom_html_element_initialise(struct dom_document *doc, - struct dom_html_element *el, struct lwc_string_s *name, - struct lwc_string_s *namespace, struct lwc_string_s *prefix) + struct dom_html_element *el, dom_string *name, + dom_string *namespace, dom_string *prefix) { dom_exception err; @@ -28,13 +29,12 @@ dom_exception _dom_html_element_initialise(struct dom_document *doc, return err; } -void _dom_html_element_finalise(struct dom_document *doc, - struct dom_html_element *ele) +void _dom_html_element_finalise(struct dom_html_element *ele) { dom_node_unref(ele->form); ele->form = NULL; - _dom_element_finalise(doc, &ele->base); + _dom_element_finalise(&ele->base); } /*------------------------------------------------------------------------*/ @@ -47,24 +47,11 @@ void _dom_virtual_html_element_destroy(dom_node_internal *node) assert("Should never be here" == NULL); } -/* The virtual allocation function, see src/core/node.c for detail */ -dom_exception _dom_html_element_alloc(struct dom_document *doc, - struct dom_node_internal *n, struct dom_node_internal **ret) -{ - UNUSED(doc); - UNUSED(n); - UNUSED(ret); - - assert("Should never be here" == NULL); - - return DOM_NO_MEM_ERR; -} - /* The virtual copy function, see src/core/node.c for detail */ -dom_exception _dom_html_element_copy(struct dom_node_internal *new, - struct dom_node_internal *old) +dom_exception _dom_html_element_copy(dom_node_internal *old, + dom_node_internal **copy) { - return _dom_element_copy(new, old); + return _dom_element_copy(old, copy); } /*-----------------------------------------------------------------------*/ @@ -74,15 +61,9 @@ dom_exception _dom_html_element_get_id(dom_html_element *element, dom_string **id) { dom_exception ret; - dom_document *doc; dom_string *idstr; - ret = dom_node_get_owner_document(element, &doc); - if (ret != DOM_NO_ERR) - return ret; - - ret = _dom_document_create_string(doc, (const uint8_t *) "id", - SLEN("id"), &idstr); + ret = dom_string_create((const uint8_t *) "id", SLEN("id"), &idstr); if (ret != DOM_NO_ERR) return ret; @@ -97,15 +78,9 @@ dom_exception _dom_html_element_set_id(dom_html_element *element, dom_string *id) { dom_exception ret; - dom_document *doc; dom_string *idstr; - ret = dom_node_get_owner_document(element, &doc); - if (ret != DOM_NO_ERR) - return ret; - - ret = _dom_document_create_string(doc, (const uint8_t *) "id", - SLEN("id"), &idstr); + ret = dom_string_create((const uint8_t *) "id", SLEN("id"), &idstr); if (ret != DOM_NO_ERR) return ret; @@ -131,13 +106,11 @@ dom_exception _dom_html_element_set_id(dom_html_element *element, dom_exception dom_html_element_get_bool_property(dom_html_element *ele, const char *name, unsigned long len, bool *has) { - dom_document *doc = dom_node_get_owner(ele); dom_string *str = NULL; dom_attr *a = NULL; dom_exception err; - err = _dom_document_create_string(doc, (const uint8_t *) name, - len, &str); + err = dom_string_create((const uint8_t *) name, len, &str); if (err != DOM_NO_ERR) goto fail; @@ -172,13 +145,11 @@ fail: dom_exception dom_html_element_set_bool_property(dom_html_element *ele, const char *name, unsigned long len, bool has) { - dom_document *doc = dom_node_get_owner(ele); dom_string *str = NULL; dom_attr *a = NULL; dom_exception err; - err = _dom_document_create_string(doc, (const uint8_t *) name, - len, &str); + err = dom_string_create((const uint8_t *) name, len, &str); if (err != DOM_NO_ERR) goto fail; @@ -195,19 +166,13 @@ dom_exception dom_html_element_set_bool_property(dom_html_element *ele, dom_node_unref(res); } else if (a == NULL && has == true) { + dom_document *doc = dom_node_get_owner(ele); dom_attr *res = NULL; - lwc_string *lstr = NULL; - - err = _dom_string_intern(str, &lstr); - if (err != DOM_NO_ERR) - goto cleanup1; - err = _dom_attr_create(doc, lstr, NULL, NULL, true, &a); + err = _dom_attr_create(doc, str, NULL, NULL, true, &a); if (err != DOM_NO_ERR) { - lwc_string_unref(lstr); goto cleanup1; } - lwc_string_unref(lstr); err = dom_element_set_attribute_node(ele, a, &res); if (err != DOM_NO_ERR) |