]> gitweb.michael.orlitzky.com - libsvgtiny.git/blobdiff - src/svgtiny_internal.h
src/svgtiny.c: use case-sensitive comparisons for SVG element names
[libsvgtiny.git] / src / svgtiny_internal.h
index 6bf5d64d99277f836fb9d59cad878977d8ed7571..5ece69d42c1ab66cfa52a46321e31d3f9b67fe8e 100644 (file)
@@ -11,6 +11,7 @@
 #include <stdbool.h>
 
 #include <dom/dom.h>
+#include <libcss/libcss.h>
 
 #ifndef UNUSED
 #define UNUSED(x) ((void) (x))
@@ -46,13 +47,31 @@ struct svgtiny_parse_state {
                float a, b, c, d, e, f;
        } ctm;
 
-       /*struct css_style style;*/
+       /* A libcss context to hold any stylesheets that are present
+        * in the SVG document. This should be pre-populated rather
+        * than on-the-fly, because, for example, a <style> sheet at
+        * the end of the document should affect the SVG elements that
+        * precede it. */
+       css_select_ctx *select_ctx;
+
+       /* A libcss unit context. This is used to compute and compose
+        * styles, and is convenient to create once and pass along
+        * with the rest of the state. */
+       css_unit_ctx unit_ctx;
+
+       /* Keep track of the parent element's computed style so that
+        * we can compose its children's computed styles with it. */
+       css_computed_style *parent_style;
 
        /* paint attributes */
        svgtiny_colour fill;
        svgtiny_colour stroke;
        int stroke_width;
 
+       /* alpha */
+       float fill_opacity;
+       float stroke_opacity;
+
        /* gradients */
        struct svgtiny_parse_state_gradient fill_grad;
        struct svgtiny_parse_state_gradient stroke_grad;
@@ -62,6 +81,14 @@ struct svgtiny_parse_state {
 #include "svgtiny_strings.h"
 #undef SVGTINY_STRING_ACTION2
 
+       /* Where we store the interned copy of the SVG XML namespace,
+        *
+        *   http://www.w3.org/2000/svg
+        *
+        * We handle it separately it has a different type
+        * (lwc_string) than those above (dom_string).
+        */
+       lwc_string *interned_svg_xmlns;
 };
 
 struct svgtiny_list;
@@ -85,6 +112,14 @@ char *svgtiny_strndup(const char *s, size_t n);
 #define strndup svgtiny_strndup
 #endif
 
+/* svgtiny_css.c */
+css_error svgtiny_create_stylesheet(css_stylesheet **sheet,
+               bool inline_style);
+css_error svgtiny_select_style(struct svgtiny_parse_state *state,
+                       dom_element *node,
+                       const css_stylesheet *inline_sheet,
+                       css_select_results **result);
+
 /* svgtiny_gradient.c */
 void svgtiny_find_gradient(const char *id,
                struct svgtiny_parse_state_gradient *grad,