[librsvg: 12/22] Defs::get_extern_handle(): Don't take a handle



commit 2cea7a27c3898b7050618fdd1e76d23b28fe03b0
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Jan 7 20:19:20 2019 -0600

    Defs::get_extern_handle(): Don't take a handle
    
    Pass the load_options and base_url individually.

 rsvg_internals/src/defs.rs | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/rsvg_internals/src/defs.rs b/rsvg_internals/src/defs.rs
index 151e1064..42a075f9 100644
--- a/rsvg_internals/src/defs.rs
+++ b/rsvg_internals/src/defs.rs
@@ -3,9 +3,11 @@ use std::collections::HashMap;
 use std::fmt;
 use std::rc::Rc;
 
+use url::Url;
+
 use allowed_url::AllowedUrl;
 use error::ValueErrorKind;
-use handle::{self, RsvgHandle};
+use handle::{self, LoadOptions, RsvgHandle};
 use node::Node;
 use parsers::ParseError;
 
@@ -24,7 +26,10 @@ impl Defs {
     /// externally-loaded SVG file.
     pub fn lookup(&mut self, handle: *const RsvgHandle, fragment: &Fragment) -> Option<Rc<Node>> {
         if let Some(ref href) = fragment.uri() {
-            match self.get_extern_handle(handle, href) {
+            let load_options = handle::get_load_options(handle);
+            let base_url = handle::get_base_url(handle).clone();
+
+            match self.get_extern_handle(&load_options, base_url, href) {
                 Ok(extern_handle) => handle::lookup_fragment_id(extern_handle, fragment.fragment()),
                 Err(()) => None,
             }
@@ -35,17 +40,16 @@ impl Defs {
 
     fn get_extern_handle(
         &mut self,
-        handle: *const RsvgHandle,
+        load_options: &LoadOptions,
+        base_url: Option<Url>,
         href: &str,
     ) -> Result<*const RsvgHandle, ()> {
-        let aurl =
-            AllowedUrl::from_href(href, handle::get_base_url(handle).as_ref()).map_err(|_| ())?;
+        let aurl = AllowedUrl::from_href(href, base_url.as_ref()).map_err(|_| ())?;
 
         match self.externs.entry(aurl) {
             Entry::Occupied(e) => Ok(*(e.get())),
             Entry::Vacant(e) => {
-                let load_options = handle::get_load_options(handle);
-                let extern_handle = handle::load_extern(&load_options, e.key())?;
+                let extern_handle = handle::load_extern(load_options, e.key())?;
                 e.insert(extern_handle);
                 Ok(extern_handle)
             }


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