]> gitweb.michael.orlitzky.com - libsvgtiny.git/commitdiff
src/svgtiny_css.c: new file with new svgtiny_resolve_url() function
authorMichael Orlitzky <michael@orlitzky.com>
Wed, 4 Oct 2023 12:27:28 +0000 (08:27 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Wed, 11 Oct 2023 12:05:56 +0000 (08:05 -0400)
Define a stub relative-URL resolver that assumes all URLs are absolute
and returns them unmodified. Some method of doing this is required by
libcss. At the moment, libcss does not support any SVG properties that
take url() values, so not much is lost.

src/svgtiny_css.c [new file with mode: 0644]

diff --git a/src/svgtiny_css.c b/src/svgtiny_css.c
new file mode 100644 (file)
index 0000000..f112ca3
--- /dev/null
@@ -0,0 +1,21 @@
+#include <libcss/libcss.h>
+
+#include "svgtiny.h"
+#include "svgtiny_internal.h"
+
+/**
+ * Resolve a relative URL to an absolute one by doing nothing. This is
+ * the simplest possible implementation of a URL resolver, needed for
+ * parsing CSS.
+ */
+css_error svgtiny_resolve_url(void *pw,
+               const char *base, lwc_string *rel, lwc_string **abs)
+{
+       UNUSED(pw);
+       UNUSED(base);
+
+       /* Copy the relative URL to the absolute one (the return
+          value) */
+       *abs = lwc_string_ref(rel);
+       return CSS_OK;
+}