summaryrefslogtreecommitdiff
path: root/src/layout.c
diff options
context:
space:
mode:
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;
}