]> 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>
Sun, 8 Jun 2025 02:18:20 +0000 (22:18 -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 0197f6dd3d6b18305b6c5622c30ef26de4526170..00089ce305510b0b360479bd8763206a73b4b626 100644 (file)
@@ -11,6 +11,7 @@
 #include <stdbool.h>
 
 #include <dom/dom.h>
+#include <libcss/libcss.h>
 
 #ifndef UNUSED
 #define UNUSED(x) ((void) (x))
@@ -53,6 +54,13 @@ struct svgtiny_parse_state {
        /* current transformation matrix */
        struct svgtiny_transformation_matrix 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;