[librsvg: 8/10] Don't pass a RsvgHandle where we just need a CssStyles



commit b0941218c5a97ad19cc0a751df1d67a73689840d
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Nov 22 13:27:32 2018 -0600

    Don't pass a RsvgHandle where we just need a CssStyles
    
    This further decouples RsvgHandle from the loaded data.

 rsvg_internals/src/node.rs      | 10 +++++-----
 rsvg_internals/src/structure.rs |  5 +++--
 rsvg_internals/src/xml.rs       |  6 ++++--
 3 files changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/rsvg_internals/src/node.rs b/rsvg_internals/src/node.rs
index ab1e1db6..5ce01b16 100644
--- a/rsvg_internals/src/node.rs
+++ b/rsvg_internals/src/node.rs
@@ -6,9 +6,10 @@ use std::rc::{Rc, Weak};
 
 use attributes::Attribute;
 use cond::{locale_from_environment, RequiredExtensions, RequiredFeatures, SystemLanguage};
+use css::CssStyles;
 use drawing_ctx::DrawingCtx;
 use error::*;
-use handle::{self, RsvgHandle};
+use handle::RsvgHandle;
 use parsers::Parse;
 use property_bag::PropertyBag;
 use state::{ComputedValues, Overflow, SpecifiedValue, State};
@@ -440,7 +441,7 @@ impl Node {
     }
 
     /// Implements a very limited CSS selection engine
-    fn set_css_styles(&self, handle: *const RsvgHandle) {
+    fn set_css_styles(&self, css_styles: &CssStyles) {
         // Try to properly support all of the following, including inheritance:
         // *
         // #id
@@ -451,7 +452,6 @@ impl Node {
         //
         // This is basically a semi-compliant CSS2 selection engine
 
-        let css_styles = handle::get_css_styles(handle);
         let mut state = self.state.borrow_mut();
 
         // *
@@ -520,9 +520,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, pbag: &PropertyBag<'_>) {
+    pub fn set_style(&self, css_styles: &CssStyles, pbag: &PropertyBag<'_>) {
         self.set_presentation_attributes(pbag);
-        self.set_css_styles(handle);
+        self.set_css_styles(css_styles);
         self.set_style_attribute(pbag);
     }
 
diff --git a/rsvg_internals/src/structure.rs b/rsvg_internals/src/structure.rs
index f384413e..7b2be1c7 100644
--- a/rsvg_internals/src/structure.rs
+++ b/rsvg_internals/src/structure.rs
@@ -6,6 +6,7 @@ use glib_sys;
 
 use aspect_ratio::*;
 use attributes::Attribute;
+use css::CssStyles;
 use drawing_ctx::DrawingCtx;
 use error::RenderingError;
 use float_eq_cairo::ApproxEqCairo;
@@ -116,10 +117,10 @@ impl NodeSvg {
         }
     }
 
-    pub fn set_delayed_style(&self, node: &RsvgNode, handle: *const RsvgHandle) {
+    pub fn set_delayed_style(&self, node: &RsvgNode, css_styles: &CssStyles) {
         if let Some(owned_pbag) = self.pbag.borrow().as_ref() {
             let pbag = PropertyBag::from_owned(owned_pbag);
-            node.set_style(handle, &pbag);
+            node.set_style(css_styles, &pbag);
         }
     }
 }
diff --git a/rsvg_internals/src/xml.rs b/rsvg_internals/src/xml.rs
index 075421db..a5cec38a 100644
--- a/rsvg_internals/src/xml.rs
+++ b/rsvg_internals/src/xml.rs
@@ -183,7 +183,8 @@ impl XmlState {
         // here, not during element creation.
         if node.get_type() == NodeType::Svg {
             node.with_impl(|svg: &NodeSvg| {
-                svg.set_delayed_style(&node, handle);
+                let css_styles = handle::get_css_styles(handle);
+                svg.set_delayed_style(&node, css_styles);
             });
         }
 
@@ -241,7 +242,8 @@ impl XmlState {
         // The "svg" node is special; it will parse its style attributes
         // until the end, in standard_element_end().
         if new_node.get_type() != NodeType::Svg {
-            new_node.set_style(handle, pbag);
+            let css_styles = handle::get_css_styles(handle);
+            new_node.set_style(css_styles, pbag);
         }
 
         new_node.set_overridden_properties();


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