[librsvg: 60/95] rsvg_parse_style_pair(): Take an RsvgAttribute arg; don't compute it here



commit e8fc72e78e3ab0f8116016dc6aca2b9b2d04fe5e
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Feb 21 10:40:17 2018 -0600

    rsvg_parse_style_pair(): Take an RsvgAttribute arg; don't compute it here

 rsvg-styles.c | 47 +++++++++++++++++++++++++++++++----------------
 1 file changed, 31 insertions(+), 16 deletions(-)
---
diff --git a/rsvg-styles.c b/rsvg-styles.c
index 0e5acee3..3f18bc15 100644
--- a/rsvg-styles.c
+++ b/rsvg-styles.c
@@ -529,14 +529,14 @@ typedef enum {
 
 /* Parse a CSS2 style argument, setting the SVG context attributes. */
 static void
-rsvg_parse_style_pair (RsvgState * state,
-                       const gchar * name,
-                       const gchar * value,
+rsvg_parse_style_pair (RsvgState *state,
+                       const gchar *name,
+                       RsvgAttribute attr,
+                       const gchar *value,
                        gboolean important,
                        PairSource source)
 {
     StyleValueData *data;
-    RsvgAttribute attr;
 
     data = g_hash_table_lookup (state->styles, name);
     if (data && data->important && !important)
@@ -549,10 +549,6 @@ rsvg_parse_style_pair (RsvgState * state,
                          (gpointer) g_strdup (name),
                          (gpointer) style_value_data_new (value, important));
 
-    if (!rsvg_attribute_from_name (name, &attr)) {
-        return;
-    }
-
     switch (attr) {
     case RSVG_ATTRIBUTE_COLOR:
     {
@@ -1184,7 +1180,13 @@ rsvg_parse_presentation_attributes (RsvgState * state, RsvgPropertyBag * atts)
     iter = rsvg_property_bag_iter_begin (atts);
 
     while (rsvg_property_bag_iter_next (iter, &key, &value)) {
-        rsvg_parse_style_pair (state, key, value, FALSE, PAIR_SOURCE_PRESENTATION_ATTRIBUTE);
+        RsvgAttribute attr;
+
+        if (!rsvg_attribute_from_name (key, &attr)) {
+            continue;
+        }
+
+        rsvg_parse_style_pair (state, key, attr, value, FALSE, PAIR_SOURCE_PRESENTATION_ATTRIBUTE);
     }
 
     rsvg_property_bag_iter_end (iter);
@@ -1265,12 +1267,21 @@ rsvg_parse_style (RsvgState *state, const char *str)
             second_value = g_strjoinv(NULL, split_list);
             g_strfreev(split_list);
 
-            if (parse_style_value (second_value, &style_value, &important))
-                rsvg_parse_style_pair (state,
-                                       g_strstrip (first_value),
-                                       style_value,
-                                       important,
-                                       PAIR_SOURCE_STYLE);
+            if (parse_style_value (second_value, &style_value, &important)) {
+                RsvgAttribute attr;
+
+                g_strstrip (first_value);
+
+                if (rsvg_attribute_from_name (first_value, &attr)) {
+                    rsvg_parse_style_pair (state,
+                                           first_value,
+                                           attr,
+                                           style_value,
+                                           important,
+                                           PAIR_SOURCE_STYLE);
+                }
+            }
+
             g_free (style_value);
             g_free (second_value);
         }
@@ -1517,7 +1528,11 @@ static void
 apply_style (const gchar *key, StyleValueData *value, gpointer user_data)
 {
     RsvgState *state = user_data;
-    rsvg_parse_style_pair (state, key, value->value, value->important, PAIR_SOURCE_STYLE);
+    RsvgAttribute attr;
+
+    if (rsvg_attribute_from_name (key, &attr)) {
+        rsvg_parse_style_pair (state, key, attr, value->value, value->important, PAIR_SOURCE_STYLE);
+    }
 }
 
 static gboolean


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]