[librsvg: 2/12] state: move the parsing of conditional processing attributes



commit 725da80911a3fb78f29287a523786c60a25d7db6
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat Apr 21 15:04:21 2018 +0200

    state: move the parsing of conditional processing attributes
    
    Move (and slightly refactor) the parsing of conditional processing
    attributes from rsvg_parse_presentation_attributes to its caller
    rsvg_parse_style_attrs. This is not only cleaner (since the caller
    is where we parse different categories of attributes), but it is
    also more correct since rsvg_parse_presentation_attributes has
    another caller in stop.rs and according to the spec that element
    does not support conditional processing (one has to make the
    whole gradient conditional, not just a gradient stop).

 librsvg/rsvg-styles.c | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)
---
diff --git a/librsvg/rsvg-styles.c b/librsvg/rsvg-styles.c
index 0477e8c7..4e4d5ada 100644
--- a/librsvg/rsvg-styles.c
+++ b/librsvg/rsvg-styles.c
@@ -535,8 +535,8 @@ rsvg_parse_style_pair (RsvgState *state,
 
 /* returns TRUE if this element should be processed according to <switch> semantics
    http://www.w3.org/TR/SVG/struct.html#SwitchElement */
-static gboolean
-rsvg_eval_switch_attributes (RsvgPropertyBag * atts, gboolean * p_has_cond)
+static void
+rsvg_parse_conditional_processing_attributes (RsvgState * state, RsvgPropertyBag * atts)
 {
     gboolean required_features_ok = TRUE;
     gboolean required_extensions_ok = TRUE;
@@ -574,10 +574,10 @@ rsvg_eval_switch_attributes (RsvgPropertyBag * atts, gboolean * p_has_cond)
 
     rsvg_property_bag_iter_end (iter);
 
-    if (p_has_cond)
-        *p_has_cond = has_cond;
-
-    return required_features_ok && required_extensions_ok && system_language_ok;
+    if (has_cond) {
+        state->cond_true = required_features_ok && required_extensions_ok && system_language_ok;
+        state->has_cond = TRUE;
+    }
 }
 
 /* take a pair of the form (fill="#ff00ff") and parse it as a style */
@@ -603,18 +603,6 @@ rsvg_parse_presentation_attributes (RsvgState * state, RsvgPropertyBag * atts)
     if (!success) {
         return; /* FIXME: propagate errors upstream */
     }
-
-    {
-        /* TODO: this conditional behavior isn't quite correct, and i'm not sure it should reside here */
-        gboolean cond_true, has_cond;
-
-        cond_true = rsvg_eval_switch_attributes (atts, &has_cond);
-
-        if (has_cond) {
-            state->cond_true = cond_true;
-            state->has_cond = TRUE;
-        }
-    }
 }
 
 static gboolean
@@ -999,6 +987,9 @@ rsvg_parse_style_attrs (RsvgHandle *handle,
 
     rsvg_parse_presentation_attributes (state, atts);
 
+    /* TODO: i'm not sure it should reside here */
+    rsvg_parse_conditional_processing_attributes (state, atts);
+
     /* Try to properly support all of the following, including inheritance:
      * *
      * #id


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