summaryrefslogtreecommitdiff
path: root/src/node.h
blob: b21352ac6af8bd9ddff2eaf98a85878522e84cdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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