[librsvg: 13/15] Remove rsvg-css.c
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 13/15] Remove rsvg-css.c
- Date: Sun, 8 Apr 2018 00:01:37 +0000 (UTC)
commit eef559a1c6bc1b73f9d71aae36f4eb0308d49860
Author: Paolo Borelli <pborelli gnome org>
Date: Sat Apr 7 22:21:13 2018 +0200
Remove rsvg-css.c
Move the two leftover functions in other files (rsvg-load.c is a
better fit anyway for the xml parsing hack)
Makefile.am | 1 -
librsvg/rsvg-css.c | 112 --------------------------------------------------
librsvg/rsvg-load.c | 64 ++++++++++++++++++++++++++++-
librsvg/rsvg-styles.c | 11 +++++
4 files changed, 74 insertions(+), 114 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index ef5a85d5..aba0944b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -34,7 +34,6 @@ librsvg_@RSVG_API_MAJOR_VERSION@_la_SOURCES = \
librsvg/rsvg-cairo-render.c \
librsvg/rsvg-cairo-render.h \
librsvg/rsvg-cairo.h \
- librsvg/rsvg-css.c \
librsvg/rsvg-css.h \
librsvg/rsvg-defs.c \
librsvg/rsvg-defs.h \
diff --git a/librsvg/rsvg-load.c b/librsvg/rsvg-load.c
index aca597bc..bd83e216 100644
--- a/librsvg/rsvg-load.c
+++ b/librsvg/rsvg-load.c
@@ -999,6 +999,68 @@ sax_error_cb (void *data, const char *msg, ...)
#endif
}
+static void
+xml_noerror (void *data, xmlErrorPtr error)
+{
+}
+
+/* This is quite hacky and not entirely correct, but apparently
+ * libxml2 has NO support for parsing pseudo attributes as defined
+ * by the xml-styleheet spec.
+ */
+static char **
+parse_xml_attribute_string (const char *attribute_string)
+{
+ xmlSAXHandler handler;
+ xmlParserCtxtPtr parser;
+ xmlDocPtr doc;
+ xmlNodePtr node;
+ xmlAttrPtr attr;
+ char *tag;
+ GPtrArray *attributes;
+ char **retval = NULL;
+
+ tag = g_strdup_printf ("<rsvg-hack %s />\n", attribute_string);
+
+ memset (&handler, 0, sizeof (handler));
+ xmlSAX2InitDefaultSAXHandler (&handler, 0);
+ handler.serror = xml_noerror;
+ parser = xmlCreatePushParserCtxt (&handler, NULL, tag, strlen (tag) + 1, NULL);
+ parser->options |= XML_PARSE_NONET;
+
+ if (xmlParseDocument (parser) != 0)
+ goto done;
+
+ if ((doc = parser->myDoc) == NULL ||
+ (node = doc->children) == NULL ||
+ strcmp ((const char *) node->name, "rsvg-hack") != 0 ||
+ node->next != NULL ||
+ node->properties == NULL)
+ goto done;
+
+ attributes = g_ptr_array_new ();
+ for (attr = node->properties; attr; attr = attr->next) {
+ xmlNodePtr content = attr->children;
+
+ g_ptr_array_add (attributes, g_strdup ((char *) attr->name));
+ if (content)
+ g_ptr_array_add (attributes, g_strdup ((char *) content->content));
+ else
+ g_ptr_array_add (attributes, g_strdup (""));
+ }
+
+ g_ptr_array_add (attributes, NULL);
+ retval = (char **) g_ptr_array_free (attributes, FALSE);
+
+ done:
+ if (parser->myDoc)
+ xmlFreeDoc (parser->myDoc);
+ xmlFreeParserCtxt (parser);
+ g_free (tag);
+
+ return retval;
+}
+
static void
sax_processing_instruction_cb (void *user_data, const xmlChar * target, const xmlChar * data)
{
@@ -1009,7 +1071,7 @@ sax_processing_instruction_cb (void *user_data, const xmlChar * target, const xm
RsvgPropertyBag *atts;
char **xml_atts;
- xml_atts = rsvg_css_parse_xml_attribute_string ((const char *) data);
+ xml_atts = parse_xml_attribute_string ((const char *) data);
if (xml_atts) {
const char *alternate = NULL;
diff --git a/librsvg/rsvg-styles.c b/librsvg/rsvg-styles.c
index aa8ceb39..a63f1b06 100644
--- a/librsvg/rsvg-styles.c
+++ b/librsvg/rsvg-styles.c
@@ -1489,3 +1489,14 @@ rsvg_state_get_state_rust (RsvgState *state)
{
return state->state_rust;
}
+
+/* This is defined like this so that we can export the Rust function... just for
+ * the benefit of rsvg-convert.c
+ */
+RsvgCssColorSpec
+rsvg_css_parse_color_ (const char *str,
+ AllowInherit allow_inherit,
+ AllowCurrentColor allow_current_color)
+{
+ return rsvg_css_parse_color (str, allow_inherit, allow_current_color);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]