Author: jmb
Date: Mon Sep 17 18:33:03 2007
New Revision: 3546
URL:
http://source.netsurf-browser.org?rev=3546&view=rev
Log:
Partial implementation of dom_node_insert_before. This has utterly no sanity checking at
present so will probably break, badly.
Modified:
trunk/dom/src/core/node.c
Modified: trunk/dom/src/core/node.c
URL:
http://source.netsurf-browser.org/trunk/dom/src/core/node.c?rev=3546&...
==============================================================================
--- trunk/dom/src/core/node.c (original)
+++ trunk/dom/src/core/node.c Mon Sep 17 18:33:03 2007
@@ -537,12 +537,36 @@
struct dom_node *new_child, struct dom_node *ref_child,
struct dom_node **result)
{
- UNUSED(node);
- UNUSED(new_child);
- UNUSED(ref_child);
- UNUSED(result);
-
- return DOM_NOT_SUPPORTED_ERR;
+ /** \todo sanity checking etc. */
+
+ 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;
}
/**