[librsvg] NodeUse: use Fragment instead of String for the link



commit 99a95149117bb18430aa30bd9d9248c11fb4fbb6
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Nov 29 18:03:29 2018 -0600

    NodeUse: use Fragment instead of String for the link

 rsvg_internals/src/structure.rs | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/rsvg_internals/src/structure.rs b/rsvg_internals/src/structure.rs
index f3c72181..060db1f2 100644
--- a/rsvg_internals/src/structure.rs
+++ b/rsvg_internals/src/structure.rs
@@ -7,8 +7,9 @@ use glib_sys;
 use aspect_ratio::*;
 use attributes::Attribute;
 use css::CssStyles;
+use defs::Fragment;
 use drawing_ctx::DrawingCtx;
-use error::RenderingError;
+use error::{AttributeResultExt, RenderingError};
 use float_eq_cairo::ApproxEqCairo;
 use handle::RsvgHandle;
 use length::*;
@@ -227,7 +228,7 @@ impl NodeTrait for NodeSvg {
 }
 
 pub struct NodeUse {
-    link: RefCell<Option<String>>,
+    link: RefCell<Option<Fragment>>,
     x: Cell<Length>,
     y: Cell<Length>,
     w: Cell<Option<Length>>,
@@ -250,7 +251,10 @@ impl NodeTrait for NodeUse {
     fn set_atts(&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag<'_>) -> NodeResult {
         for (_key, attr, value) in pbag.iter() {
             match attr {
-                Attribute::XlinkHref => *self.link.borrow_mut() = Some(value.to_owned()),
+                Attribute::XlinkHref => {
+                    *self.link.borrow_mut() =
+                        Some(Fragment::parse(value).attribute(Attribute::XlinkHref)?)
+                }
 
                 Attribute::X => self.x.set(parse("x", value, LengthDir::Horizontal)?),
                 Attribute::Y => self.y.set(parse("y", value, LengthDir::Vertical)?),
@@ -296,9 +300,9 @@ impl NodeTrait for NodeUse {
             return Ok(());
         }
 
-        let uri = link.as_ref().unwrap();
+        let link = link.as_ref().unwrap();
 
-        let child = if let Some(acquired) = draw_ctx.get_acquired_href(uri) {
+        let child = if let Some(acquired) = draw_ctx.get_acquired_node(link) {
             // Here we clone the acquired child, so that we can drop the AcquiredNode as
             // early as possible.  This is so that the child's drawing method will be able
             // to re-acquire the child for other purposes.
@@ -307,7 +311,7 @@ impl NodeTrait for NodeUse {
             rsvg_log!(
                 "element {} references nonexistent \"{}\"",
                 node.get_human_readable_name(),
-                uri,
+                link,
             );
             return Ok(());
         };


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