[librsvg: 58/95] rsvg_start_style(): Parse attributes with the PHF



commit 57f3d6bf9e4abadcc272a03836d2c80e18fd5c7f
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Feb 21 08:22:30 2018 -0600

    rsvg_start_style(): Parse attributes with the PHF

 rsvg-base.c | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)
---
diff --git a/rsvg-base.c b/rsvg-base.c
index af6fae6d..55822f3a 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -28,6 +28,7 @@
 #define _GNU_SOURCE 1
 
 #include "rsvg-private.h"
+#include "rsvg-attributes.h"
 #include "rsvg-css.h"
 #include "rsvg-styles.h"
 #include "rsvg-shapes.h"
@@ -168,9 +169,9 @@ static void
 rsvg_start_style (RsvgHandle *handle, RsvgPropertyBag *atts)
 {
     RsvgSaxHandlerStyle *handler = g_new0 (RsvgSaxHandlerStyle, 1);
-    const char *type;
-
-    type = rsvg_property_bag_lookup (atts, "type");
+    RsvgPropertyBagIter *iter;
+    const char *key;
+    const char *value;
 
     handler->super.free = rsvg_style_handler_free;
     handler->super.characters = rsvg_style_handler_characters;
@@ -180,6 +181,9 @@ rsvg_start_style (RsvgHandle *handle, RsvgPropertyBag *atts)
 
     handler->style = g_string_new (NULL);
 
+    handler->parent = (RsvgSaxHandlerDefs *) handle->priv->handler;
+    handle->priv->handler = &handler->super;
+
     /* FIXME: See these:
      *
      * https://www.w3.org/TR/SVG/styling.html#StyleElementTypeAttribute
@@ -192,10 +196,23 @@ rsvg_start_style (RsvgHandle *handle, RsvgPropertyBag *atts)
      * See where is_text_css is used to see where we parse the contents
      * of the style element.
      */
-    handler->is_text_css = (type == NULL) || (g_ascii_strcasecmp (type, "text/css") == 0);
+    handler->is_text_css = TRUE;
 
-    handler->parent = (RsvgSaxHandlerDefs *) handle->priv->handler;
-    handle->priv->handler = &handler->super;
+    iter = rsvg_property_bag_iter_begin (atts);
+
+    while (rsvg_property_bag_iter_next (iter, &key, &value)) {
+        RsvgAttribute attr;
+
+        if (!rsvg_attribute_from_name (key, &attr)) {
+            continue;
+        }
+
+        if (attr == RSVG_ATTRIBUTE_TYPE) {
+            handler->is_text_css = (g_ascii_strcasecmp (value, "text/css") == 0);
+        }
+    }
+
+    rsvg_property_bag_iter_end (iter);
 }
 
 static void


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