summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn-Mark Bell <jmb@netsurf-browser.org>2023-03-12 21:38:10 +0000
committerJohn-Mark Bell <jmb@netsurf-browser.org>2023-03-12 21:38:10 +0000
commitb56d74b5df9becb324ef2d49bfe079acc505e76b (patch)
tree5615df063a856d109c5ef2128ea30309e147a18b
parent7e6acf326bc52fbd97d5e330799240f977db5ccb (diff)
downloadnetsurf-b56d74b5df9becb324ef2d49bfe079acc505e76b.tar.gz
netsurf-b56d74b5df9becb324ef2d49bfe079acc505e76b.tar.bz2
Retire long-dead code
-rw-r--r--utils/libdom.c123
-rw-r--r--utils/libdom.h23
2 files changed, 0 insertions, 146 deletions
diff --git a/utils/libdom.c b/utils/libdom.c
index a996e98bf..c39aad343 100644
--- a/utils/libdom.c
+++ b/utils/libdom.c
@@ -28,129 +28,6 @@
#include "utils/log.h"
#include "utils/libdom.h"
-/* exported interface documented in libdom.h */
-bool libdom_treewalk(dom_node *root,
- bool (*callback)(dom_node *node, dom_string *name, void *ctx),
- void *ctx)
-{
- dom_node *node;
- bool result = true;
-
- node = dom_node_ref(root); /* tree root */
-
- while (node != NULL) {
- dom_node *next = NULL;
- dom_node_type type;
- dom_string *name;
- dom_exception exc;
-
- exc = dom_node_get_first_child(node, &next);
- if (exc != DOM_NO_ERR) {
- dom_node_unref(node);
- break;
- }
-
- if (next != NULL) {
- /* 1. Got children */
- dom_node_unref(node);
- node = next;
- } else {
- /* No children; siblings & ancestor's siblings */
- while (node != NULL) {
- exc = dom_node_get_next_sibling(node, &next);
- if (exc != DOM_NO_ERR) {
- dom_node_unref(node);
- node = NULL;
- break;
- }
-
- if (next != NULL) {
- /* 2. Got sibling */
- break;
- }
-
- exc = dom_node_get_parent_node(node, &next);
- if (exc != DOM_NO_ERR) {
- dom_node_unref(node);
- node = NULL;
- break;
- }
-
- /* 3. Try parent */
- dom_node_unref(node);
- node = next;
- }
-
- if (node == NULL)
- break;
-
- dom_node_unref(node);
- node = next;
- }
-
- assert(node != NULL);
-
- exc = dom_node_get_node_type(node, &type);
- if ((exc != DOM_NO_ERR) || (type != DOM_ELEMENT_NODE))
- continue;
-
- exc = dom_node_get_node_name(node, &name);
- if (exc != DOM_NO_ERR)
- continue;
-
- result = callback(node, name, ctx);
-
- dom_string_unref(name);
-
- if (result == false) {
- break; /* callback caused early termination */
- }
-
- }
- return result;
-}
-
-
-/* libdom_treewalk context for libdom_find_element */
-struct find_element_ctx {
- lwc_string *search;
- dom_node *found;
-};
-
-/* libdom_treewalk callback for libdom_find_element */
-static bool libdom_find_element_callback(dom_node *node, dom_string *name,
- void *ctx)
-{
- struct find_element_ctx *data = ctx;
-
- if (dom_string_caseless_lwc_isequal(name, data->search)) {
- /* Found element */
- data->found = node;
- return false; /* Discontinue search */
- }
-
- return true; /* Continue search */
-}
-
-
-/* exported interface documented in libdom.h */
-dom_node *libdom_find_element(dom_node *node, lwc_string *element_name)
-{
- struct find_element_ctx data;
-
- assert(element_name != NULL);
-
- if (node == NULL)
- return NULL;
-
- data.search = element_name;
- data.found = NULL;
-
- libdom_treewalk(node, libdom_find_element_callback, &data);
-
- return data.found;
-}
-
/* exported interface documented in libdom.h */
dom_node *libdom_find_first_element(dom_node *parent, lwc_string *element_name)
diff --git a/utils/libdom.h b/utils/libdom.h
index 306aa0f8b..63841934f 100644
--- a/utils/libdom.h
+++ b/utils/libdom.h
@@ -33,29 +33,6 @@
#include <dom/bindings/hubbub/errors.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
- * \param callback The function called for each element
- * \param ctx The context passed to the callback.
- * \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);
-
-/**
* Search children of a node for first named element
* \param parent dom_node to search children of, or NULL
* \param element_name name of element to find