]> gitweb.michael.orlitzky.com - libsvgtiny.git/blob - src/svgtiny_css.c
src/svgtiny_css.c: new function svgtiny_create_stylesheet()
[libsvgtiny.git] / src / svgtiny_css.c
1 #include <libcss/libcss.h>
2
3 #include "svgtiny.h"
4 #include "svgtiny_internal.h"
5
6 /**
7 * Resolve a relative URL to an absolute one by doing nothing. This is
8 * the simplest possible implementation of a URL resolver, needed for
9 * parsing CSS.
10 */
11 css_error svgtiny_resolve_url(void *pw,
12 const char *base, lwc_string *rel, lwc_string **abs)
13 {
14 UNUSED(pw);
15 UNUSED(base);
16
17 /* Copy the relative URL to the absolute one (the return
18 value) */
19 *abs = lwc_string_ref(rel);
20 return CSS_OK;
21 }
22
23 /**
24 * Create a stylesheet with the default set of params.
25 *
26 * \param sheet A stylesheet pointer, passed in by reference, that
27 * we use to store the newly-created stylesheet.
28 * \param inline_style True if this stylesheet represents an inline
29 * style, and false otherwise.
30 *
31 * \return The return value from css_stylesheet_create() is returned.
32 */
33 css_error svgtiny_create_stylesheet(css_stylesheet **sheet,
34 bool inline_style)
35 {
36 css_stylesheet_params params;
37
38 params.params_version = CSS_STYLESHEET_PARAMS_VERSION_1;
39 params.level = CSS_LEVEL_DEFAULT;
40 params.charset = NULL;
41 params.url = "";
42 params.title = NULL;
43 params.allow_quirks = false;
44 params.inline_style = inline_style;
45 params.resolve = svgtiny_resolve_url;
46 params.resolve_pw = NULL;
47 params.import = NULL;
48 params.import_pw = NULL;
49 params.color = NULL;
50 params.color_pw = NULL;
51 params.font = NULL;
52 params.font_pw = NULL;
53
54 return css_stylesheet_create(&params, sheet);
55 }