#include <dom/dom.h>
#include <dom/bindings/xml/xmlparser.h>
+#include <libcss/libcss.h>
+
#include "svgtiny.h"
#include "svgtiny_internal.h"
const char *buffer, size_t size, const char *url,
int viewport_width, int viewport_height)
{
+ css_error css_code;
dom_document *document;
dom_exception exc;
dom_xml_parser *parser;
state.viewport_width = viewport_width;
state.viewport_height = viewport_height;
+
+ /* Initialize CSS context */
+ if (state.select_ctx == NULL) {
+ css_code = css_select_ctx_create(&state.select_ctx);
+ if (css_code != CSS_OK) {
+ dom_node_unref(svg);
+ dom_node_unref(document);
+ return svgtiny_LIBCSS_ERROR;
+ }
+ }
+
#define SVGTINY_STRING_ACTION2(s,n) \
if (dom_string_create_interned((const uint8_t *) #n, \
strlen(#n), &state.interned_##s) \
dom_node_unref(svg);
dom_node_unref(document);
+ css_code = css_select_ctx_destroy(state.select_ctx);
+ if (css_code != CSS_OK) {
+ code = svgtiny_LIBCSS_ERROR;
+ }
cleanup:
svgtiny_cleanup_state_local(&state);