diff options
-rw-r--r-- | include/dom/core/document.h | 6 | ||||
-rw-r--r-- | src/core/doc_fragment.c | 20 |
2 files changed, 21 insertions, 5 deletions
diff --git a/include/dom/core/document.h b/include/dom/core/document.h index 08b46db..193c084 100644 --- a/include/dom/core/document.h +++ b/include/dom/core/document.h @@ -114,6 +114,9 @@ typedef struct dom_document_vtable { struct dom_string *qname, struct dom_node **result); } dom_document_vtable; +dom_exception dom_document_create_string(struct dom_document *doc, + const uint8_t *data, size_t len, struct dom_string **result); + static inline dom_exception dom_document_get_doctype(struct dom_document *doc, struct dom_document_type **result) { @@ -438,7 +441,4 @@ static inline dom_exception dom_document_rename_node(struct dom_document *doc, (dom_document *) (d), (struct dom_string *) (ns), \ (struct dom_string *) (q), (dom_node **) (r)) -dom_exception dom_document_create_string(struct dom_document *doc, - const uint8_t *data, size_t len, struct dom_string **result); - #endif diff --git a/src/core/doc_fragment.c b/src/core/doc_fragment.c index b6dbd26..d9eb272 100644 --- a/src/core/doc_fragment.c +++ b/src/core/doc_fragment.c @@ -5,6 +5,8 @@ * Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org> */ +#include <dom/core/node.h> + #include "core/document.h" #include "core/doc_fragment.h" #include "core/node.h" @@ -13,9 +15,11 @@ * A DOM document fragment */ struct dom_document_fragment { - struct dom_node base; /**< Base node */ + struct dom_node_internal base; /**< Base node */ }; +void _dom_document_fragment_destroy(struct dom_node_internal *node); + /** * Create a document fragment * @@ -51,6 +55,9 @@ dom_exception dom_document_fragment_create(struct dom_document *doc, return err; } + /* Set the virtual function of destroy */ + f->base.destroy = &_dom_document_fragment_destroy; + *result = f; return DOM_NO_ERR; @@ -67,7 +74,7 @@ dom_exception dom_document_fragment_create(struct dom_document *doc, void dom_document_fragment_destroy(struct dom_document *doc, struct dom_document_fragment *frag) { - struct dom_node *c, *d; + struct dom_node_internal *c, *d; /* Destroy children of this node */ for (c = frag->base.first_child; c != NULL; c = d) { @@ -97,3 +104,12 @@ void dom_document_fragment_destroy(struct dom_document *doc, /* Destroy fragment */ dom_document_alloc(doc, frag, 0); } + +void _dom_document_fragment_destroy(struct dom_node_internal *node) +{ + struct dom_document *doc; + dom_node_get_owner_document(node, &doc); + + dom_document_fragment_destroy(doc, + (struct dom_document_fragment *) node); +} |