]> gitweb.michael.orlitzky.com - libsvgtiny.git/commitdiff
src/svgtiny_internal.h: add CSS context to parser state
authorMichael Orlitzky <michael@orlitzky.com>
Wed, 4 Oct 2023 02:51:38 +0000 (22:51 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Wed, 4 Oct 2023 03:17:25 +0000 (23:17 -0400)
Add a css_select_ctx pointer to the svgtiny_parse_state that is
threaded through each phase of SVG parsing. This will allow us to
populate the context with any <style> sheets we find; later, we can
consult those stylesheets while constructing our svgtiny_diagram (the
abstract representation into which we parse an SVG).

src/svgtiny_internal.h

index 133513c7d7ff886d7105b66dfdf2585afd550b8c..7480f233539cdeb11b89aa7c319ec5d084c74dc3 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,6 +47,13 @@ struct svgtiny_parse_state {
                float a, b, c, d, e, f;
        } ctm;
 
+       /* 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;
+
        /* paint attributes */
        svgtiny_colour fill;
        svgtiny_colour stroke;