summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2019-05-04 11:58:16 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2019-05-04 11:58:16 +0100
commit9bdbe6e64d12c514888457d466f625524627af19 (patch)
tree7d08fa1ebdeaaf5cfc069cae09a6d25df8956342 /src/core
parent41b0a260811a0880e2f84e29e20e3ebea9d0b6fe (diff)
downloadlibdom-9bdbe6e64d12c514888457d466f625524627af19.tar.gz
libdom-9bdbe6e64d12c514888457d466f625524627af19.tar.bz2
Add dom_node_contains()
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/node.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/core/node.c b/src/core/node.c
index 17f93dd..2bd95d3 100644
--- a/src/core/node.c
+++ b/src/core/node.c
@@ -296,6 +296,36 @@ void _dom_node_finalise(dom_node_internal *node)
/* ---------------------------------------------------------------------*/
+/* The public non-virtual function of this interface Node */
+
+dom_exception _dom_node_contains(struct dom_node_internal *node,
+ struct dom_node_internal *other,
+ bool *contains)
+{
+ assert(node != NULL);
+ assert(other != NULL);
+ assert(contains != NULL);
+
+ if (node->owner != other->owner) {
+ *contains = false;
+ return DOM_NO_ERR;
+ }
+
+ while (other != NULL) {
+ if (other == node) {
+ *contains = true;
+ return DOM_NO_ERR;
+ }
+ other = other->parent;
+ }
+
+ *contains = false;
+ return DOM_NO_ERR;
+}
+
+
+/* ---------------------------------------------------------------------*/
+
/* The public virtual function of this interface Node */
/**