[librsvg] tree: remove module



commit 48724985305389c387079db0fcfcdb343f877d25
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Jan 13 12:51:39 2019 +0100

    tree: remove module
    
    The tree struct is not really useful anymore now that it is private
    to Svg and that there is no need to track if cascading alreay happened

 Makefile.am                |  1 -
 rsvg_internals/src/lib.rs  |  1 -
 rsvg_internals/src/svg.rs  | 11 ++++++-----
 rsvg_internals/src/tree.rs | 35 -----------------------------------
 rsvg_internals/src/xml.rs  | 15 +++++++--------
 5 files changed, 13 insertions(+), 50 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 1db04e25..be1926a4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -111,7 +111,6 @@ RUST_SRC =                                                  \
        rsvg_internals/src/svg.rs                               \
        rsvg_internals/src/text.rs                              \
        rsvg_internals/src/transform.rs                         \
-       rsvg_internals/src/tree.rs                              \
        rsvg_internals/src/tree_utils/mod.rs                    \
        rsvg_internals/src/unit_interval.rs                     \
        rsvg_internals/src/util.rs                              \
diff --git a/rsvg_internals/src/lib.rs b/rsvg_internals/src/lib.rs
index 88595530..a80ce2c2 100644
--- a/rsvg_internals/src/lib.rs
+++ b/rsvg_internals/src/lib.rs
@@ -136,7 +136,6 @@ pub mod surface_utils;
 mod svg;
 mod text;
 mod transform;
-mod tree;
 pub mod tree_utils;
 mod unit_interval;
 mod util;
diff --git a/rsvg_internals/src/svg.rs b/rsvg_internals/src/svg.rs
index 8885afc2..d55adefa 100644
--- a/rsvg_internals/src/svg.rs
+++ b/rsvg_internals/src/svg.rs
@@ -9,7 +9,7 @@ use allowed_url::{AllowedUrl, Fragment};
 use error::LoadingError;
 use handle::{self, LoadOptions, RsvgHandle};
 use node::RsvgNode;
-use tree::Tree;
+use state::ComputedValues;
 use xml::XmlState;
 use xml2_load::xml_state_load_from_possibly_compressed_stream;
 
@@ -18,7 +18,7 @@ use xml2_load::xml_state_load_from_possibly_compressed_stream;
 /// This contains the tree of nodes (SVG elements), the mapping
 /// of id to node, and the CSS styles defined for this SVG.
 pub struct Svg {
-    tree: Tree,
+    tree: RsvgNode,
 
     ids: HashMap<String, RsvgNode>,
 
@@ -32,8 +32,9 @@ pub struct Svg {
 }
 
 impl Svg {
-    pub fn new(tree: Tree, ids: HashMap<String, RsvgNode>, load_options: LoadOptions) -> Svg {
-        tree.cascade();
+    pub fn new(tree: RsvgNode, ids: HashMap<String, RsvgNode>, load_options: LoadOptions) -> Svg {
+        let values = ComputedValues::default();
+        tree.cascade(&values);
 
         Svg {
             tree,
@@ -57,7 +58,7 @@ impl Svg {
     }
 
     pub fn root(&self) -> RsvgNode {
-        self.tree.root()
+        self.tree.clone()
     }
 
     pub fn lookup(&self, fragment: &Fragment) -> Option<RsvgNode> {
diff --git a/rsvg_internals/src/xml.rs b/rsvg_internals/src/xml.rs
index d02a92c6..3d6dd20f 100644
--- a/rsvg_internals/src/xml.rs
+++ b/rsvg_internals/src/xml.rs
@@ -20,7 +20,6 @@ use structure::NodeSvg;
 use style::NodeStyle;
 use svg::Svg;
 use text::NodeChars;
-use tree::Tree;
 use xml2_load::{xml_state_parse_from_stream, ParseFromStreamError};
 
 #[derive(Clone)]
@@ -69,7 +68,7 @@ extern "C" {
 /// trait objects. Normally the context refers to a `NodeCreationContext` implementation which is
 /// what creates normal graphical elements.
 pub struct XmlState {
-    tree: Option<Tree>,
+    tree_root: Option<Rc<Node>>,
     ids: Option<HashMap<String, RsvgNode>>,
     css_styles: Option<CssStyles>,
     context_stack: Vec<Context>,
@@ -95,7 +94,7 @@ enum AcquireError {
 impl XmlState {
     pub fn new(load_options: LoadOptions) -> XmlState {
         XmlState {
-            tree: None,
+            tree_root: None,
             ids: Some(HashMap::new()),
             css_styles: Some(CssStyles::new()),
             context_stack: vec![Context::Start],
@@ -106,21 +105,21 @@ impl XmlState {
     }
 
     fn set_root(&mut self, root: &Rc<Node>) {
-        if self.tree.is_some() {
+        if self.tree_root.is_some() {
             panic!("The tree root has already been set");
         }
 
-        self.tree = Some(Tree::new(root));
+        self.tree_root = Some(root.clone());
     }
 
     pub fn steal_result(&mut self) -> Result<Svg, LoadingError> {
-        match self.tree {
+        match self.tree_root {
             None => Err(LoadingError::SvgHasNoElements),
-            Some(ref tree) if !tree.root_is_svg() => {
+            Some(ref root) if root.get_type() != NodeType::Svg => {
                 Err(LoadingError::RootElementIsNotSvg)
             }
             _ => Ok(Svg::new(
-                self.tree.take().unwrap(),
+                self.tree_root.take().unwrap(),
                 self.ids.take().unwrap(),
                 self.load_options.clone(),
             )),


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