summaryrefslogtreecommitdiff
path: root/src/core/node.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2007-09-17 17:33:03 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2007-09-17 17:33:03 +0000
commitab4314ef357afee872d2a81e14c00826fb01b64e (patch)
tree9dce0d89a4de96fbe983ef8c490b0ffa70d65174 /src/core/node.c
parent78c1ad1966dbedf8e4ee49df466221188334426f (diff)
downloadlibdom-ab4314ef357afee872d2a81e14c00826fb01b64e.tar.gz
libdom-ab4314ef357afee872d2a81e14c00826fb01b64e.tar.bz2
Partial implementation of dom_node_insert_before. This has utterly no sanity checking at present so will probably break, badly.
svn path=/trunk/dom/; revision=3546
Diffstat (limited to 'src/core/node.c')
-rw-r--r--src/core/node.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/core/node.c b/src/core/node.c
index db4838b..c33e24d 100644
--- a/src/core/node.c
+++ b/src/core/node.c
@@ -537,12 +537,36 @@ dom_exception dom_node_insert_before(struct dom_node *node,
struct dom_node *new_child, struct dom_node *ref_child,
struct dom_node **result)
{
- UNUSED(node);
- UNUSED(new_child);
- UNUSED(ref_child);
- UNUSED(result);
+ /** \todo sanity checking etc. */
- return DOM_NOT_SUPPORTED_ERR;
+ new_child->parent = node;
+
+ if (ref_child == NULL) {
+ new_child->previous = node->last_child;
+ new_child->next = NULL;
+
+ if (node->last_child != NULL)
+ node->last_child->next = new_child;
+ else
+ node->first_child = new_child;
+
+ node->last_child = new_child;
+ } else {
+ new_child->previous = ref_child->previous;
+ new_child->next = ref_child;
+
+ if (ref_child->previous != NULL)
+ ref_child->previous->next = new_child;
+ else
+ node->first_child = new_child;
+
+ ref_child->previous = new_child;
+ }
+
+ dom_node_ref(new_child);
+ *result = new_child;
+
+ return DOM_NO_ERR;
}
/**