blob: b3b57cede50e87557b6ef66b5753c6a6c98f7569 (
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
/*
* 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/layout.c
* Layout object 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 object for a DOM document
*/
struct nsl_layout {
dom_document *document;
css_select_ctx *css_ctx;
css_media_type *media;
nsl_callback cb;
void *pw;
};
/* Publically exported function, documented in include/libnslayout/nslayout.h */
nsl_error nsl_init(void)
{
return nsl_dom_str_init();
}
/* Publically exported function, documented in include/libnslayout/nslayout.h */
nsl_error nsl_fini(void)
{
return nsl_dom_str_fini();
}
/* Publically exported function, documented in include/libnslayout/nslayout.h */
nsl_error nsl_layout_create(
dom_document *doc,
css_select_ctx *css_ctx,
css_media_type *media,
nsl_callback cb,
void *pw,
nsl_layout **layout)
{
nsl_layout *l = NULL;
assert(doc != NULL);
assert(css_ctx != NULL);
assert(media != NULL);
assert(cb != NULL);
l = calloc(1, sizeof(nsl_layout));
if (l == NULL) {
return NSL_NO_MEM;
}
/* TODO: Decide: ownership will probably be passed to libnslayout */
l->document = doc;
l->css_ctx = css_ctx;
l->media = media;
l->cb = cb;
l->pw = pw;
*layout = l;
return NSL_OK;
}
/* Publically exported function, documented in include/libnslayout/nslayout.h */
nsl_error nsl_layout_destroy(
nsl_layout *layout)
{
assert(layout != NULL);
/* TODO: free/unref the stuff we own in the layout */
free(layout);
return NSL_OK;
}
|