diff options
author | Bo Yang <struggleyb.nku@gmail.com> | 2009-08-11 11:17:23 +0000 |
---|---|---|
committer | Bo Yang <struggleyb.nku@gmail.com> | 2009-08-11 11:17:23 +0000 |
commit | 399da01ae4eb5c5e3e9349bacc2063c946c3d4a1 (patch) | |
tree | 433c8bcde94fc7a6e6f2e5cbf23842a84db98146 /src/core/cdatasection.c | |
parent | eec057c7437e19b59ca1e698ce548cb56ce37240 (diff) | |
download | libdom-399da01ae4eb5c5e3e9349bacc2063c946c3d4a1.tar.gz libdom-399da01ae4eb5c5e3e9349bacc2063c946c3d4a1.tar.bz2 |
Merge the branches/struggleyb/libdom-remain back to trunk.
svn path=/trunk/dom/; revision=9191
Diffstat (limited to 'src/core/cdatasection.c')
-rw-r--r-- | src/core/cdatasection.c | 66 |
1 files changed, 57 insertions, 9 deletions
diff --git a/src/core/cdatasection.c b/src/core/cdatasection.c index 71d3d43..b470df2 100644 --- a/src/core/cdatasection.c +++ b/src/core/cdatasection.c @@ -3,11 +3,13 @@ * Licensed under the MIT License, * http://www.opensource.org/licenses/mit-license.php * Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org> + * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com> */ #include "core/cdatasection.h" #include "core/document.h" #include "core/text.h" +#include "utils/utils.h" /** * A DOM CDATA section @@ -16,6 +18,10 @@ struct dom_cdata_section { struct dom_text base; /**< Base node */ }; +static struct dom_node_protect_vtable cdata_section_protect_vtable = { + DOM_CDATA_SECTION_PROTECT_VTABLE +}; + /** * Create a CDATA section * @@ -30,23 +36,27 @@ struct dom_cdata_section { * * The returned node will already be referenced. */ -dom_exception dom_cdata_section_create(struct dom_document *doc, - struct dom_string *name, struct dom_string *value, +dom_exception _dom_cdata_section_create(struct dom_document *doc, + struct lwc_string_s *name, struct dom_string *value, struct dom_cdata_section **result) { struct dom_cdata_section *c; dom_exception err; /* Allocate the comment node */ - c = dom_document_alloc(doc, NULL, sizeof(struct dom_cdata_section)); + c = _dom_document_alloc(doc, NULL, sizeof(struct dom_cdata_section)); if (c == NULL) return DOM_NO_MEM_ERR; + + /* Set up vtable */ + ((dom_node_internal *) c)->base.vtable = &text_vtable; + ((dom_node_internal *) c)->vtable = &cdata_section_protect_vtable; /* And initialise the node */ - err = dom_text_initialise(&c->base, doc, DOM_CDATA_SECTION_NODE, - name, value); + err = _dom_cdata_section_initialise(&c->base, doc, + DOM_CDATA_SECTION_NODE, name, value); if (err != DOM_NO_ERR) { - dom_document_alloc(doc, c, 0); + _dom_document_alloc(doc, c, 0); return err; } @@ -63,12 +73,50 @@ dom_exception dom_cdata_section_create(struct dom_document *doc, * * The contents of ::cdata will be destroyed and ::cdata will be freed. */ -void dom_cdata_section_destroy(struct dom_document *doc, +void _dom_cdata_section_destroy(struct dom_document *doc, struct dom_cdata_section *cdata) { /* Clean up base node contents */ - dom_text_finalise(doc, &cdata->base); + _dom_cdata_section_finalise(doc, &cdata->base); /* Destroy the node */ - dom_document_alloc(doc, cdata, 0); + _dom_document_alloc(doc, cdata, 0); +} + +/*--------------------------------------------------------------------------*/ + +/* The protected virtual functions */ + +/* The virtual destroy function of this class */ +void __dom_cdata_section_destroy(struct dom_node_internal *node) +{ + struct dom_document *doc; + doc = dom_node_get_owner(node); + + _dom_cdata_section_destroy(doc, (struct dom_cdata_section *) node); +} + +/* The memory allocator of this class */ +dom_exception _dom_cdata_section_alloc(struct dom_document *doc, + struct dom_node_internal *n, struct dom_node_internal **ret) +{ + UNUSED(n); + dom_cdata_section *a; + + a = _dom_document_alloc(doc, NULL, sizeof(struct dom_cdata_section)); + if (a == NULL) + return DOM_NO_MEM_ERR; + + *ret = (dom_node_internal *) a; + dom_node_set_owner(*ret, doc); + + return DOM_NO_ERR; } + +/* The copy constructor of this class */ +dom_exception _dom_cdata_section_copy(struct dom_node_internal *new, + struct dom_node_internal *old) +{ + return _dom_characterdata_copy(new, old); +} + |