summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2015-08-02 16:04:57 (GMT)
committer Michael Drake <tlsa@netsurf-browser.org>2015-08-03 21:30:20 (GMT)
commit277b1da1b4b6aa602c4eb1900cabaf427eb64a7f (patch)
tree71f973826afdb63e720ca8c7cae0c8959639a6dc
parent7772a81909b7a9bf73b014c2b9971be9e6a1f13c (diff)
downloadlibnslayout-277b1da1b4b6aa602c4eb1900cabaf427eb64a7f.tar.gz
libnslayout-277b1da1b4b6aa602c4eb1900cabaf427eb64a7f.tar.bz2
Improve documentation and naming for DOM change watcher.
-rw-r--r--src/dom/Makefile2
-rw-r--r--src/dom/event.h19
-rw-r--r--src/dom/watcher.c (renamed from src/dom/event.c)20
-rw-r--r--src/dom/watcher.h32
-rw-r--r--src/layout.c6
5 files changed, 52 insertions, 27 deletions
diff --git a/src/dom/Makefile b/src/dom/Makefile
index 30e1847..0baa497 100644
--- a/src/dom/Makefile
+++ b/src/dom/Makefile
@@ -6,6 +6,6 @@
# Released under the ISC License (see COPYING file)
# Sources
-DIR_SOURCES := event.c
+DIR_SOURCES := watcher.c
include $(NSBUILD)/Makefile.subdir
diff --git a/src/dom/event.h b/src/dom/event.h
deleted file mode 100644
index f519f40..0000000
--- a/src/dom/event.h
+++ b/dev/null
@@ -1,19 +0,0 @@
-/*
- * This file is part of LibNSLayout
- * Licensed under the ISC License, http://opensource.org/licenses/ISC
- * Copyright 2015 Michael Drake <tlsa@netsurf-browser.org>
- */
-
-/** \file src/dom/event.h
- * Layout object handling
- */
-
-#ifndef nslayout_dom_event_h_
-#define nslayout_dom_event_h_
-
-#include <libnslayout/nslayout.h>
-
-nslayout_error nsl_dom_event_layout_init(nslayout_layout *layout);
-nslayout_error nsl_dom_event_layout_fini(nslayout_layout *layout);
-
-#endif
diff --git a/src/dom/event.c b/src/dom/watcher.c
index e24b699..a4e8d64 100644
--- a/src/dom/event.c
+++ b/src/dom/watcher.c
@@ -4,7 +4,7 @@
* Copyright 2015 Michael Drake <tlsa@netsurf-browser.org>
*/
-/** \file src/dom/event.c
+/** \file src/dom/watcher.c
* DOM mutation handling
*/
@@ -14,10 +14,16 @@
#include <string.h>
#include "layout.h"
-#include "dom/event.h"
+#include "dom/watcher.h"
#include "util/dom-str.h"
#include "util/util.h"
+/**
+ * Convert a dom node type to a string
+ *
+ * \param[in] type DOM node type
+ * \return appropriate string.
+ */
static const char *nsl__dom_node_type_to_string(dom_node_type type)
{
const char *str[] = {
@@ -39,6 +45,12 @@ static const char *nsl__dom_node_type_to_string(dom_node_type type)
return str[type - 1];
}
+/**
+ * LibDOM event handler
+ *
+ * \param[in] evt The LibDOM event object
+ * \param[in] pw Pointer to our nslayout_layout object
+ */
static void nsl__dom_event_handler(struct dom_event *evt, void *pw)
{
dom_event_target *node = NULL;
@@ -97,7 +109,7 @@ fail:
}
/* Exported function, documented in src/dom/event.h */
-nslayout_error nsl_dom_event_layout_init(nslayout_layout *layout)
+nslayout_error nsl_dom_watcher_add_for_layout(nslayout_layout *layout)
{
nslayout_error err;
dom_exception exc;
@@ -139,7 +151,7 @@ fail:
}
/* Exported function, documented in src/dom/event.h */
-nslayout_error nsl_dom_event_layout_fini(nslayout_layout *layout)
+nslayout_error nsl_dom_watcher_remove_for_layout(nslayout_layout *layout)
{
dom_exception exc1, exc2;
diff --git a/src/dom/watcher.h b/src/dom/watcher.h
new file mode 100644
index 0000000..87f0a1b
--- a/dev/null
+++ b/src/dom/watcher.h
@@ -0,0 +1,32 @@
+/*
+ * This file is part of LibNSLayout
+ * Licensed under the ISC License, http://opensource.org/licenses/ISC
+ * Copyright 2015 Michael Drake <tlsa@netsurf-browser.org>
+ */
+
+/** \file src/dom/watcher.h
+ * Layout object handling
+ */
+
+#ifndef nslayout_dom_watcher_h_
+#define nslayout_dom_watcher_h_
+
+#include <libnslayout/nslayout.h>
+
+/**
+ * Add DOM change watchers to the layout's document.'
+ *
+ * \param[in] layout nslayout_layout object to set watchers for.
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+nslayout_error nsl_dom_watcher_add_for_layout(nslayout_layout *layout);
+
+/**
+ * Remove DOM change watchers from the layout's document.
+ *
+ * \param[in] layout nslayout_layout object remove watchers from.
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+nslayout_error nsl_dom_watcher_remove_for_layout(nslayout_layout *layout);
+
+#endif
diff --git a/src/layout.c b/src/layout.c
index f1a1490..1c341b6 100644
--- a/src/layout.c
+++ b/src/layout.c
@@ -13,7 +13,7 @@
#include <stdio.h>
#include "layout.h"
-#include "dom/event.h"
+#include "dom/watcher.h"
#include "util/dom-str.h"
@@ -62,7 +62,7 @@ nslayout_error nslayout_layout_create(
l->pw = pw;
/* TODO: error handling */
- nsl_dom_event_layout_init(l);
+ nsl_dom_watcher_add_for_layout(l);
*layout = l;
return NSLAYOUT_OK;
@@ -77,7 +77,7 @@ nslayout_error nslayout_layout_destroy(
/* TODO: free/unref the stuff we own in the layout */
/* TODO: error handling */
- nsl_dom_event_layout_fini(layout);
+ nsl_dom_watcher_remove_for_layout(layout);
free(layout);
return NSLAYOUT_OK;