[librsvg: 12/48] standard_element_end(): Extract this function from sax_end_element_cb()



commit 94155d9b3bf3d08bc31b3614aa76af6e44e7b605
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Sep 6 20:43:52 2018 -0500

    standard_element_end(): Extract this function from sax_end_element_cb()
    
    This makes sax_end_element_cb() more symmetrical to sax_start_element_cb().

 librsvg/rsvg-load.c | 43 +++++++++++++++++++++++++------------------
 1 file changed, 25 insertions(+), 18 deletions(-)
---
diff --git a/librsvg/rsvg-load.c b/librsvg/rsvg-load.c
index 81baf2ad..da9baeee 100644
--- a/librsvg/rsvg-load.c
+++ b/librsvg/rsvg-load.c
@@ -582,6 +582,30 @@ sax_start_element_cb (void *data, const xmlChar * name, const xmlChar ** atts)
     rsvg_property_bag_free (bag);
 }
 
+static void
+standard_element_end (RsvgLoad *load, const char *name)
+{
+    RsvgNode *current_node;
+
+    current_node = rsvg_xml_state_get_current_node (load->xml.rust_state);
+
+    if (current_node) {
+        rsvg_load_set_svg_node_atts (load->handle, current_node);
+    }
+
+    if (current_node && rsvg_xml_state_topmost_element_name_is (load->xml.rust_state, name)) {
+        RsvgNode *parent;
+
+        parent = rsvg_node_get_parent (current_node);
+        rsvg_xml_state_set_current_node (load->xml.rust_state, parent);
+        parent = rsvg_node_unref (parent);
+
+        rsvg_xml_state_pop_element_name (load->xml.rust_state);
+    }
+
+    current_node = rsvg_node_unref (current_node);
+}
+
 static void
 sax_end_element_cb (void *data, const xmlChar * xmlname)
 {
@@ -593,7 +617,6 @@ sax_end_element_cb (void *data, const xmlChar * xmlname)
         load->xml.handler_nest--;
     } else {
         const char *tempname;
-        RsvgNode *current_node;
 
         for (tempname = name; *tempname != '\0'; tempname++)
             if (*tempname == ':')
@@ -604,23 +627,7 @@ sax_end_element_cb (void *data, const xmlChar * xmlname)
             load->xml.handler = NULL;
         }
 
-        current_node = rsvg_xml_state_get_current_node (load->xml.rust_state);
-
-        if (current_node) {
-            rsvg_load_set_svg_node_atts (load->handle, current_node);
-        }
-
-        if (current_node && rsvg_xml_state_topmost_element_name_is (load->xml.rust_state, name)) {
-            RsvgNode *parent;
-
-            parent = rsvg_node_get_parent (current_node);
-            rsvg_xml_state_set_current_node (load->xml.rust_state, parent);
-            parent = rsvg_node_unref (parent);
-
-            rsvg_xml_state_pop_element_name (load->xml.rust_state);
-        }
-
-        current_node = rsvg_node_unref (current_node);
+        standard_element_end (load, name);
     }
 }
 


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