static svgtiny_code svgtiny_parse_style_element(dom_element *style,
struct svgtiny_parse_state state);
+static css_stylesheet *svgtiny_parse_style_inline(const uint8_t *data,
+ size_t len);
static svgtiny_code svgtiny_preparse_styles(dom_element *svg,
struct svgtiny_parse_state state);
static svgtiny_code svgtiny_parse_svg(dom_element *svg,
}
+/**
+ * Parse the contents of an inline style and return (a pointer to) the
+ * corresponding stylesheet for use with css_select_style(). Returns
+ * NULL if anything goes wrong.
+ */
+css_stylesheet *svgtiny_parse_style_inline(const uint8_t *data,
+ size_t len)
+{
+ css_stylesheet *sheet;
+ css_error code;
+
+ code = svgtiny_create_stylesheet(&sheet, true);
+ if (code != CSS_OK) {
+ return NULL;
+ }
+
+ code = css_stylesheet_append_data(sheet, data, len);
+ if (code != CSS_OK && code != CSS_NEEDDATA) {
+ css_stylesheet_destroy(sheet);
+ return NULL;
+ }
+
+ code = css_stylesheet_data_done(sheet);
+ if (code != CSS_OK) {
+ css_stylesheet_destroy(sheet);
+ return NULL;
+ }
+
+ return sheet;
+}
+
/**
* Parse all <style> elements within a root <svg> element. This
* should be called before svgtiny_parse_svg() because that function