summaryrefslogtreecommitdiff
path: root/src/layout.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2017-02-05 22:41:04 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2017-02-05 22:41:04 +0000
commitf18b7ad86fe25e32cac7d9bca1abe92c46437535 (patch)
tree6ec3bf938c0b7a20600151085325b04ea349f173 /src/layout.c
parent39f7357b388d2e00d307419ccd2d761180eb5c5c (diff)
downloadlibnslayout-f18b7ad86fe25e32cac7d9bca1abe92c46437535.tar.gz
libnslayout-f18b7ad86fe25e32cac7d9bca1abe92c46437535.tar.bz2
dom watcher: Add callback for dom mutation watching.
Diffstat (limited to 'src/layout.c')
-rw-r--r--src/layout.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/layout.c b/src/layout.c
index d894f13..e4824bf 100644
--- a/src/layout.c
+++ b/src/layout.c
@@ -14,6 +14,7 @@
#include "libnslayout/nslayout.h"
#include "layout.h"
+#include "util/util.h"
#include "dom/watcher.h"
#include "util/dom-str.h"
@@ -46,6 +47,40 @@ nslayout_error nslayout_fini(void)
}
+/**
+ * Callback function for dom modifications.
+ *
+ * \param[in] type The mutation type.
+ * \param[in] node The target node. (Caller yields ownership.)
+ * \param[in] node_type The type of node.
+ * \param[in] pw The layout object.
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+static nslayout_error nsl_layout_dom_watcher_cb(
+ enum nsl_dom_watcher_type type,
+ dom_event_target *node,
+ dom_node_type node_type,
+ void *pw)
+{
+ nslayout_layout *layout = pw;
+
+ UNUSED(type);
+ UNUSED(layout);
+ UNUSED(node_type);
+
+ /* TODO: Based on event type:
+ * 1. call to do (re)selection:
+ * a. all nodes?
+ * b. just this node?
+ * 2. call to update layout, if needed.
+ */
+
+ dom_node_unref(node);
+
+ return NSLAYOUT_OK;
+}
+
+
/* Publically exported function, documented in include/libnslayout/nslayout.h */
nslayout_error nslayout_layout_create(
dom_document *doc,
@@ -75,7 +110,8 @@ nslayout_error nslayout_layout_create(
l->cb = cb;
l->pw = pw;
- err = nsl_dom_watcher_create(&l->watcher, l->document);
+ err = nsl_dom_watcher_create(&l->watcher, l->document,
+ nsl_layout_dom_watcher_cb, l);
if (err != NSLAYOUT_OK) {
return err;
}