summaryrefslogtreecommitdiff
path: root/utils/libdom.h
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2012-10-12 16:21:29 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2012-10-12 16:21:29 +0100
commit4fccdf18f3956eaab6481597e38efd1939f16f81 (patch)
tree36b6a67b3139202a1669a969b324806b6454c4f3 /utils/libdom.h
parente7e33297676391c06d4465ea5b46630b8d26d511 (diff)
downloadnetsurf-4fccdf18f3956eaab6481597e38efd1939f16f81.tar.gz
netsurf-4fccdf18f3956eaab6481597e38efd1939f16f81.tar.bz2
Move dom walker to utils/libdom.{c|h}. Add a few HTML elements to core strings.
Diffstat (limited to 'utils/libdom.h')
-rw-r--r--utils/libdom.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/utils/libdom.h b/utils/libdom.h
new file mode 100644
index 000000000..e5a7c20c1
--- /dev/null
+++ b/utils/libdom.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2011 John-Mark Bell <jmb@netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+/** \file
+ * libdom utilities (implementation).
+ */
+
+#ifndef NETSURF_UTILS_LIBDOM_H_
+#define NETSURF_UTILS_LIBDOM_H_
+
+#include <stdbool.h>
+
+#include <dom/dom.h>
+
+/* depth-first walk the dom calling callback for each element
+ *
+ * \param root the dom node to use as the root of the tree walk
+ * \return true if all nodes were examined, false if the callback terminated
+ * the walk early.
+ */
+bool libdom_treewalk(dom_node *root,
+ bool (*callback)(dom_node *node, dom_string *name, void *ctx),
+ void *ctx);
+
+/**
+ * Search the descendants of a node for an element.
+ *
+ * \param node dom_node to search children of, or NULL
+ * \param element_name name of element to find
+ * \return first child of node which is an element and matches name, or
+ * NULL if not found or parameter node is NULL
+ */
+dom_node *libdom_find_element(dom_node *node, lwc_string *element_name);
+
+#endif