summaryrefslogtreecommitdiff
path: root/src/core/text.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2007-07-26 22:19:48 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2007-07-26 22:19:48 +0000
commit4aa51a22bf3e600ed7d8fde4a7ca60bc2ecca02b (patch)
tree07ad40b1cb4623ecd3d1d7df5be0cc5211156fec /src/core/text.c
parentd208ad37e9dea0e3854e70eef40e33716c54aff0 (diff)
downloadlibdom-4aa51a22bf3e600ed7d8fde4a7ca60bc2ecca02b.tar.gz
libdom-4aa51a22bf3e600ed7d8fde4a7ca60bc2ecca02b.tar.bz2
Implement type-specific node constructors and veneer the appropriate Document APIs onto them.
svn path=/trunk/dom/; revision=3463
Diffstat (limited to 'src/core/text.c')
-rw-r--r--src/core/text.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/core/text.c b/src/core/text.c
index dd85bfe..5c2308a 100644
--- a/src/core/text.c
+++ b/src/core/text.c
@@ -9,8 +9,13 @@
#include <dom/core/text.h>
#include "core/characterdata.h"
+#include "core/document.h"
+#include "core/text.h"
#include "utils/utils.h"
+/**
+ * A DOM text node
+ */
struct dom_text {
struct dom_characterdata base; /**< Base node */
@@ -19,6 +24,48 @@ struct dom_text {
};
/**
+ * Create a text node
+ *
+ * \param doc The owning document
+ * \param type The type of text node to create
+ * \param name The name of the node to create
+ * \param value The text content of the node
+ * \param result Pointer to location to receive created node
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MEM_ERR on memory exhaustion.
+ *
+ * ::doc, ::name and ::value will have their reference counts increased.
+ *
+ * The returned node will already be referenced.
+ */
+dom_exception dom_text_create(struct dom_document *doc, dom_node_type type,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_text **result)
+{
+ struct dom_text *t;
+ dom_exception err;
+
+ /* Allocate the element */
+ t = dom_document_alloc(doc, NULL, sizeof(struct dom_text));
+ if (t == NULL)
+ return DOM_NO_MEM_ERR;
+
+ /* Initialise the base class */
+ err = dom_characterdata_initialise(&t->base, doc, type, name, value);
+ if (err != DOM_NO_ERR) {
+ dom_document_alloc(doc, t, 0);
+ return err;
+ }
+
+ /* Perform our type-specific initialisation */
+ t->element_content_whitespace = false;
+
+ *result = t;
+
+ return DOM_NO_ERR;
+}
+
+/**
* Split a text node at a given character offset
*
* \param text The node to split