Author: jmb
Date: Wed Jul 11 02:04:21 2007
New Revision: 3398
URL:
http://source.netsurf-browser.org?rev=3398&view=rev
Log:
Make CharacterData struct public (within library)
Add Text.
Added:
trunk/dom/include/dom/core/text.h
trunk/dom/src/core/characterdata.h
trunk/dom/src/core/text.c
Modified:
trunk/dom/src/core/Makefile
trunk/dom/src/core/characterdata.c
Added: trunk/dom/include/dom/core/text.h
URL:
http://source.netsurf-browser.org/trunk/dom/include/dom/core/text.h?rev=3...
==============================================================================
--- trunk/dom/include/dom/core/text.h (added)
+++ trunk/dom/include/dom/core/text.h Wed Jul 11 02:04:21 2007
@@ -1,0 +1,28 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ *
http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#ifndef dom_core_text_h_
+#define dom_core_text_h_
+
+#include <stdbool.h>
+
+#include <dom/core/exceptions.h>
+
+struct dom_characterdata;
+struct dom_string;
+struct dom_text;
+
+dom_exception dom_text_split_text(struct dom_text *text,
+ unsigned long offset, struct dom_text **result);
+dom_exception dom_text_get_is_element_content_whitespace(
+ struct dom_text *text, bool *result);
+dom_exception dom_text_get_whole_text(struct dom_text *text,
+ struct dom_string **result);
+dom_exception dom_text_replace_whole_text(struct dom_text *text,
+ struct dom_string *content, struct dom_text **result);
+
+#endif
Modified: trunk/dom/src/core/Makefile
URL:
http://source.netsurf-browser.org/trunk/dom/src/core/Makefile?rev=3398&am...
==============================================================================
--- trunk/dom/src/core/Makefile (original)
+++ trunk/dom/src/core/Makefile Wed Jul 11 02:04:21 2007
@@ -22,7 +22,7 @@
CFLAGS += -I$(CURDIR)
# Objects
-OBJS = attr characterdata document namednodemap node nodelist string
+OBJS = attr characterdata document namednodemap node nodelist string text
.PHONY: clean debug distclean export release setup test
Modified: trunk/dom/src/core/characterdata.c
URL:
http://source.netsurf-browser.org/trunk/dom/src/core/characterdata.c?rev=...
==============================================================================
--- trunk/dom/src/core/characterdata.c (original)
+++ trunk/dom/src/core/characterdata.c Wed Jul 11 02:04:21 2007
@@ -8,15 +8,8 @@
#include <dom/core/characterdata.h>
#include <dom/core/string.h>
-#include "core/node.h"
+#include "core/characterdata.h"
#include "utils/utils.h"
-
-/**
- * DOM character data node
- */
-struct dom_characterdata {
- struct dom_node base; /**< Base node */
-};
/**
* Retrieve data from a character data node
Added: trunk/dom/src/core/characterdata.h
URL:
http://source.netsurf-browser.org/trunk/dom/src/core/characterdata.h?rev=...
==============================================================================
--- trunk/dom/src/core/characterdata.h (added)
+++ trunk/dom/src/core/characterdata.h Wed Jul 11 02:04:21 2007
@@ -1,0 +1,20 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ *
http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#ifndef dom_internal_core_characterdata_h_
+#define dom_internal_core_characterdata_h_
+
+#include "core/node.h"
+
+/**
+ * DOM character data node
+ */
+struct dom_characterdata {
+ struct dom_node base; /**< Base node */
+};
+
+#endif
Added: trunk/dom/src/core/text.c
URL:
http://source.netsurf-browser.org/trunk/dom/src/core/text.c?rev=3398&...
==============================================================================
--- trunk/dom/src/core/text.c (added)
+++ trunk/dom/src/core/text.c Wed Jul 11 02:04:21 2007
@@ -1,0 +1,98 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ *
http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#include <dom/core/string.h>
+#include <dom/core/text.h>
+
+#include "core/characterdata.h"
+#include "utils/utils.h"
+
+struct dom_text {
+ struct dom_characterdata base; /**< Base node */
+
+ bool element_content_whitespace; /**< This node is element
+ * content whitespace */
+};
+
+/**
+ * Split a text node at a given character offset
+ *
+ * \param text The node to split
+ * \param offset Character offset to split at
+ * \param result Pointer to location to receive new node
+ * \return DOM_NO_ERR on success,
+ * DOM_INDEX_SIZE_ERR if ::offset is greater than the
+ * number of characters in ::text,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::text is readonly.
+ *
+ * The returned node will be referenced. The client should unref the node
+ * once it has finished with it.
+ */
+dom_exception dom_text_split_text(struct dom_text *text,
+ unsigned long offset, struct dom_text **result)
+{
+ UNUSED(text);
+ UNUSED(offset);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Determine if a text node contains element content whitespace
+ *
+ * \param text The node to consider
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ */
+dom_exception dom_text_get_is_element_content_whitespace(
+ struct dom_text *text, bool *result)
+{
+ *result = text->element_content_whitespace;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Retrieve all text in Text nodes logically adjacent to a Text node
+ *
+ * \param text Text node to consider
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ */
+dom_exception dom_text_get_whole_text(struct dom_text *text,
+ struct dom_string **result)
+{
+ UNUSED(text);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Replace the text of a Text node and all logically adjacent Text nodes
+ *
+ * \param text Text node to consider
+ * \param content Replacement content
+ * \param result Pointer to location to receive Text node
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if one of the Text nodes being
+ * replaced is readonly.
+ *
+ * The returned node will be referenced. The client should unref the node
+ * once it has finished with it.
+ */
+dom_exception dom_text_replace_whole_text(struct dom_text *text,
+ struct dom_string *content, struct dom_text **result)
+{
+ UNUSED(text);
+ UNUSED(content);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+