[librsvg: 46/95] rsvg_parse_style_attrs(): Parse attributes with the PHF
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 46/95] rsvg_parse_style_attrs(): Parse attributes with the PHF
- Date: Thu, 22 Feb 2018 03:17:00 +0000 (UTC)
commit cabd443ca19920f16bb3a787e87577b909a06518
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Feb 20 15:54:05 2018 -0600
rsvg_parse_style_attrs(): Parse attributes with the PHF
rsvg-styles.c | 51 +++++++++++++++++++++++++++++++++++++--------------
1 file changed, 37 insertions(+), 14 deletions(-)
---
diff --git a/rsvg-styles.c b/rsvg-styles.c
index cec664c1..e19e2fba 100644
--- a/rsvg-styles.c
+++ b/rsvg-styles.c
@@ -1535,6 +1535,40 @@ rsvg_lookup_apply_css_style (RsvgHandle *handle, const char *target, RsvgState *
return FALSE;
}
+struct parse_style_and_transform_closure {
+ RsvgState *state;
+ RsvgNode *node;
+};
+
+static void
+parse_style_and_transform (const char *key, const char *value, gpointer data)
+{
+ RsvgAttribute attr;
+ RsvgNode *node = data;
+ RsvgState *state = rsvg_node_get_state (node);
+
+ if (!rsvg_attribute_from_name (key, &attr)) {
+ return;
+ }
+
+ switch (attr) {
+ case RSVG_ATTRIBUTE_STYLE:
+ rsvg_parse_style (state, value);
+ break;
+
+ case RSVG_ATTRIBUTE_TRANSFORM:
+ if (!rsvg_parse_transform_attr (state, value)) {
+ rsvg_node_set_attribute_parse_error (node,
+ "transform",
+ "Invalid transformation");
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
/**
* rsvg_parse_style_attrs:
* @handle: Rsvg handle.
@@ -1636,20 +1670,9 @@ rsvg_parse_style_attrs (RsvgHandle *handle,
g_free (target);
}
- if (rsvg_property_bag_size (atts) > 0) {
- const char *value;
-
- if ((value = rsvg_property_bag_lookup (atts, "style")) != NULL)
- rsvg_parse_style (state, value);
-
- if ((value = rsvg_property_bag_lookup (atts, "transform")) != NULL) {
- if (!rsvg_parse_transform_attr (state, value)) {
- rsvg_node_set_attribute_parse_error (node,
- "transform",
- "Invalid transformation");
- }
- }
- }
+ rsvg_property_bag_enumerate (atts,
+ parse_style_and_transform,
+ node);
}
RsvgState *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]