[librsvg/librsvg-2.44] Now that nodes know their element name, don't pass it down the rsvg_load_set_node_atts() chain



commit 1a042674b6253f4fc440ca18d967afd2cbca3c63
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Sep 14 11:00:49 2018 -0500

    Now that nodes know their element name, don't pass it down the rsvg_load_set_node_atts() chain

 librsvg/rsvg-load.c             |  4 ++--
 rsvg_internals/src/load.rs      | 13 +++++++++----
 rsvg_internals/src/node.rs      | 14 +++++++-------
 rsvg_internals/src/structure.rs |  2 +-
 4 files changed, 19 insertions(+), 14 deletions(-)
---
diff --git a/librsvg/rsvg-load.c b/librsvg/rsvg-load.c
index f3f3bdbe..9287ad0e 100644
--- a/librsvg/rsvg-load.c
+++ b/librsvg/rsvg-load.c
@@ -44,7 +44,7 @@ RsvgNode *rsvg_load_new_node (const char *element_name, RsvgNode *parent, RsvgPr
 
 /* Implemented in rsvg_internals/src/load.rs */
 G_GNUC_INTERNAL
-void rsvg_load_set_node_atts (RsvgHandle *handle, RsvgNode *node, const char *element_name, RsvgPropertyBag 
atts);
+void rsvg_load_set_node_atts (RsvgHandle *handle, RsvgNode *node, RsvgPropertyBag atts);
 
 /* Implemented in rsvg_internals/src/load.rs */
 G_GNUC_INTERNAL
@@ -314,7 +314,7 @@ standard_element_start (RsvgLoad *load, const char *name, RsvgPropertyBag * atts
 
     load->currentnode = rsvg_node_ref (newnode);
 
-    rsvg_load_set_node_atts (load->handle, newnode, name, atts);
+    rsvg_load_set_node_atts (load->handle, newnode, atts);
 
     newnode = rsvg_node_unref (newnode);
 }
diff --git a/rsvg_internals/src/load.rs b/rsvg_internals/src/load.rs
index 18250e83..b715444a 100644
--- a/rsvg_internals/src/load.rs
+++ b/rsvg_internals/src/load.rs
@@ -45,7 +45,14 @@ macro_rules! node_create_fn {
             class: Option<&str>,
             parent: *const RsvgNode,
         ) -> *const RsvgNode {
-            boxed_node_new(NodeType::$node_type, parent, element_name, id, class, Box::new($new_fn()))
+            boxed_node_new(
+                NodeType::$node_type,
+                parent,
+                element_name,
+                id,
+                class,
+                Box::new($new_fn()),
+            )
         }
     };
 }
@@ -317,14 +324,12 @@ pub extern "C" fn rsvg_load_new_node(
 pub extern "C" fn rsvg_load_set_node_atts(
     handle: *const RsvgHandle,
     raw_node: *mut RsvgNode,
-    tag: *const libc::c_char,
     pbag: *const PropertyBag,
 ) {
     assert!(!raw_node.is_null());
     assert!(!pbag.is_null());
 
     let node: &RsvgNode = unsafe { &*raw_node };
-    let tag = unsafe { utf8_cstr(tag) };
     let pbag = unsafe { &*pbag };
 
     node.set_atts(node, handle, pbag);
@@ -333,7 +338,7 @@ pub extern "C" fn rsvg_load_set_node_atts(
     // attributes until the end, when sax_end_element_cb() calls
     // rsvg_node_svg_apply_atts()
     if node.get_type() != NodeType::Svg {
-        node.set_style(handle, tag, pbag);
+        node.set_style(handle, pbag);
     }
 
     node.set_overridden_properties();
diff --git a/rsvg_internals/src/node.rs b/rsvg_internals/src/node.rs
index 8ed0f88b..af783869 100644
--- a/rsvg_internals/src/node.rs
+++ b/rsvg_internals/src/node.rs
@@ -437,7 +437,7 @@ impl Node {
     }
 
     /// Implements a very limited CSS selection engine
-    fn set_css_styles(&self, handle: *const RsvgHandle, tag: &str) {
+    fn set_css_styles(&self, handle: *const RsvgHandle) {
         // Try to properly support all of the following, including inheritance:
         // *
         // #id
@@ -455,7 +455,7 @@ impl Node {
             rsvg_lookup_apply_css_style(handle, "*".to_glib_none().0, state_ptr);
 
             // tag
-            rsvg_lookup_apply_css_style(handle, tag.to_glib_none().0, state_ptr);
+            rsvg_lookup_apply_css_style(handle, self.element_name.to_glib_none().0, state_ptr);
 
             if let Some(klazz) = self.get_class() {
                 for cls in klazz.split_whitespace() {
@@ -464,7 +464,7 @@ impl Node {
                     if !cls.is_empty() {
                         // tag.class#id
                         if let Some(id) = self.get_id() {
-                            let target = format!("{}.{}#{}", tag, cls, id);
+                            let target = format!("{}.{}#{}", self.element_name, cls, id);
                             found = found || from_glib(rsvg_lookup_apply_css_style(
                                 handle,
                                 target.to_glib_none().0,
@@ -483,7 +483,7 @@ impl Node {
                         }
 
                         // tag.class
-                        let target = format!("{}.{}", tag, cls);
+                        let target = format!("{}.{}", self.element_name, cls);
                         found = found || from_glib(rsvg_lookup_apply_css_style(
                             handle,
                             target.to_glib_none().0,
@@ -505,7 +505,7 @@ impl Node {
                 rsvg_lookup_apply_css_style(handle, target.to_glib_none().0, state_ptr);
 
                 // tag#id
-                let target = format!("{}#{}", tag, id);
+                let target = format!("{}#{}", self.element_name, id);
                 rsvg_lookup_apply_css_style(handle, target.to_glib_none().0, state_ptr);
             }
         }
@@ -530,9 +530,9 @@ impl Node {
 
     // Sets the node's state from the style-related attributes in the pbag.  Also applies
     // CSS rules in our limited way based on the node's tag/class/id.
-    pub fn set_style(&self, handle: *const RsvgHandle, tag: &str, pbag: &PropertyBag<'_>) {
+    pub fn set_style(&self, handle: *const RsvgHandle, pbag: &PropertyBag<'_>) {
         self.set_presentation_attributes(pbag);
-        self.set_css_styles(handle, tag);
+        self.set_css_styles(handle);
         self.set_style_attribute(pbag);
     }
 
diff --git a/rsvg_internals/src/structure.rs b/rsvg_internals/src/structure.rs
index 28fb70ae..e5d5eb3d 100644
--- a/rsvg_internals/src/structure.rs
+++ b/rsvg_internals/src/structure.rs
@@ -119,7 +119,7 @@ impl NodeSvg {
     pub fn set_delayed_style(&self, node: &RsvgNode, handle: *const RsvgHandle) {
         if let Some(owned_pbag) = self.pbag.borrow().as_ref() {
             let pbag = PropertyBag::from_owned(owned_pbag);
-            node.set_style(handle, "svg", &pbag);
+            node.set_style(handle, &pbag);
         }
     }
 }


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