1 #include <libcss/libcss.h>
4 #include "svgtiny_internal.h"
6 static css_error
node_name(void *pw
, void *node
, css_qname
*qname
);
10 * Resolve a relative URL to an absolute one by doing nothing. This is
11 * the simplest possible implementation of a URL resolver, needed for
14 css_error
svgtiny_resolve_url(void *pw
,
15 const char *base
, lwc_string
*rel
, lwc_string
**abs
)
20 /* Copy the relative URL to the absolute one (the return
22 *abs
= lwc_string_ref(rel
);
27 * Create a stylesheet with the default set of params.
29 * \param sheet A stylesheet pointer, passed in by reference, that
30 * we use to store the newly-created stylesheet.
31 * \param inline_style True if this stylesheet represents an inline
32 * style, and false otherwise.
34 * \return The return value from css_stylesheet_create() is returned.
36 css_error
svgtiny_create_stylesheet(css_stylesheet
**sheet
,
39 css_stylesheet_params params
;
41 params
.params_version
= CSS_STYLESHEET_PARAMS_VERSION_1
;
42 params
.level
= CSS_LEVEL_DEFAULT
;
43 params
.charset
= NULL
;
46 params
.allow_quirks
= false;
47 params
.inline_style
= inline_style
;
48 params
.resolve
= svgtiny_resolve_url
;
49 params
.resolve_pw
= NULL
;
51 params
.import_pw
= NULL
;
53 params
.color_pw
= NULL
;
55 params
.font_pw
= NULL
;
57 return css_stylesheet_create(¶ms
, sheet
);
61 /**************************/
62 /* libcss select handlers */
63 /**************************/
65 * From here on we implement the "select handler "API defined in
66 * libcss's include/libcss/select.h and discussed briefly in its
72 * Retrieve the given node's name
74 * \param pw Pointer to the current SVG parser state
75 * \param node Libdom SVG node
76 * \param qname Address at which to store the node name
78 * \return CSS_OK on success, or CSS_NOMEM if anything goes wrong
80 css_error
node_name(void *pw
, void *node
, css_qname
*qname
)
84 struct svgtiny_parse_state
*state
;
86 err
= dom_node_get_node_name((dom_node
*)node
, &name
);
87 if (err
!= DOM_NO_ERR
) {
91 state
= (struct svgtiny_parse_state
*)pw
;
92 qname
->ns
= lwc_string_ref(state
->interned_svg_xmlns
);
94 err
= dom_string_intern(name
, &qname
->name
);
95 if (err
!= DOM_NO_ERR
) {
96 dom_string_unref(name
);
100 dom_string_unref(name
);