[librsvg: 4/10] image: store href attr as a String




commit 9b08e4cfb4db573a4d326fa832255dc9f8900342
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat Dec 12 16:06:54 2020 +0100

    image: store href attr as a String
    
    Parsing it as a HRef is not very useful since Href::WithFragment is not
    a valid value anyway.
    The url is checked once the image is loaded and if it is not valid, we
    will get a io error.

 src/image.rs | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)
---
diff --git a/src/image.rs b/src/image.rs
index a19f129a..a62052b2 100644
--- a/src/image.rs
+++ b/src/image.rs
@@ -14,7 +14,6 @@ use crate::length::*;
 use crate::node::{CascadedValues, Node};
 use crate::parsers::ParseValue;
 use crate::rect::Rect;
-use crate::url_resolver::Href;
 
 #[derive(Default)]
 pub struct Image {
@@ -23,7 +22,7 @@ pub struct Image {
     width: Length<Horizontal>,
     height: Length<Vertical>,
     aspect: AspectRatio,
-    href: Option<Href>,
+    href: Option<String>,
 }
 
 impl SetAttributes for Image {
@@ -42,11 +41,7 @@ impl SetAttributes for Image {
 
                 // "path" is used by some older Adobe Illustrator versions
                 ref a if is_href(a) || *a == expanded_name!("", "path") => {
-                    let href = Href::parse(value)
-                        .map_err(|_| ValueErrorKind::parse_error("could not parse href"))
-                        .attribute(attr.clone())?;
-
-                    set_href(a, &mut self.href, href);
+                    set_href(a, &mut self.href, value.to_string())
                 }
 
                 _ => (),
@@ -67,21 +62,13 @@ impl Draw for Image {
         clipping: bool,
     ) -> Result<BoundingBox, RenderingError> {
         let surface = match self.href {
-            Some(Href::PlainUrl(ref url)) => match acquired_nodes.lookup_image(url) {
+            Some(ref url) => match acquired_nodes.lookup_image(url) {
                 Ok(surf) => surf,
                 Err(e) => {
                     rsvg_log!("could not load image \"{}\": {}", url, e);
                     return Ok(draw_ctx.empty_bbox());
                 }
             },
-            Some(_) => {
-                rsvg_log!(
-                    "not rendering {} because its href cannot contain a fragment identifier",
-                    node
-                );
-
-                return Ok(draw_ctx.empty_bbox());
-            }
             None => return Ok(draw_ctx.empty_bbox()),
         };
 


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