summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2018-08-15 16:06:24 +0100
committerMichael Drake <michael.drake@codethink.co.uk>2018-09-28 17:01:50 +0100
commitfd5ccee08973a2a5ada67e87c8d76b8086cd6ec5 (patch)
tree56bc112ca16516f154aefb292706aaae1717acfd
parentaf02dd42e2e9adb341900dac10f96e684458dee6 (diff)
downloadlibnslayout-tlsa/layout-nodes.tar.gz
libnslayout-tlsa/layout-nodes.tar.bz2
WIP: Layout node stuff. Not a lot here.tlsa/layout-nodes
-rw-r--r--src/Makefile2
-rw-r--r--src/node.c25
-rw-r--r--src/node.h61
3 files changed, 87 insertions, 1 deletions
diff --git a/src/Makefile b/src/Makefile
index 7a6251d..b02f0b9 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -6,6 +6,6 @@
# Released under the ISC License (see COPYING file)
# Sources
-DIR_SOURCES := layout.c
+DIR_SOURCES := layout.c node.c
include $(NSBUILD)/Makefile.subdir
diff --git a/src/node.c b/src/node.c
new file mode 100644
index 0000000..233e6c4
--- /dev/null
+++ b/src/node.c
@@ -0,0 +1,25 @@
+/*
+ * 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/node.c
+ * Layout node handling
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include "libnslayout/nslayout.h"
+
+#include "layout.h"
+#include "util/util.h"
+#include "util/dom-str.h"
+
+
+/**
+ * The layout node object.
+ */
+struct nsl_node {
+};
diff --git a/src/node.h b/src/node.h
new file mode 100644
index 0000000..b21352a
--- /dev/null
+++ b/src/node.h
@@ -0,0 +1,61 @@
+/*
+ * 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/node.h
+ * Layout node handling
+ */
+
+#ifndef nsl_node_h_
+#define nsl_node_h_
+
+typedef struct nsl_node nsl_node;
+
+/** Layout node types */
+enum nsl_node {
+ NSL_NODE_INLINE = 1,
+ NSL_NODE_BLOCK = ( 1 << 1),
+ NSL_NODE_FLEX = ( 2 << 1),
+ NSL_NODE_GRID = ( 3 << 1),
+ NSL_NODE_TABLE = ( 4 << 1),
+ NSL_NODE_TABLE_CAP = ( 5 << 1),
+ NSL_NODE_TABLE_COL_GROUP = ( 6 << 1),
+ NSL_NODE_TABLE_ROW_GROUP = ( 7 << 1),
+ NSL_NODE_TABLE_CELL = ( 8 << 1),
+ NSL_NODE_TABLE_COL = ( 9 << 1),
+ NSL_NODE_TABLE_ROW = (10 << 1),
+ NSL_NODE_INLINE_BLOCK = NSL_NODE_INLINE | NSL_NODE_BLOCK,
+ NSL_NODE_INLINE_FLEX = NSL_NODE_INLINE | NSL_NODE_FLEX,
+ NSL_NODE_INLINE_GRID = NSL_NODE_INLINE | NSL_NODE_GRID,
+ NSL_NODE_INLINE_TABLE = NSL_NODE_INLINE | NSL_NODE_TABLE,
+};
+
+/**
+ * Test whether a layout node participates in inline flow.
+ *
+ * \param[in] node Node to test.
+ * \return true if node participates in inline flow, false otherwise.
+ */
+static inline bool nsl_node_is_inline(struct nsl_node *node)
+{
+ return node->type & NSL_NODE_INLINE;
+}
+
+/**
+ * Test whether a layout node participates in block flow.
+ *
+ * \param[in] node Node to test.
+ * \return true if node participates in block flow, false otherwise.
+ */
+static inline bool nsl_node_is_block(struct nsl_node *node)
+{
+ return !nsl_node_is_inline(node);
+}
+
+nsl_error nsl__node_create(nsl_node **node_out);
+
+void nsl__node_destroy(nsl_node *node_out);
+
+#endif