[librsvg: 18/22] Defs::lookup() - take a LoadOptions, not a handle
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 18/22] Defs::lookup() - take a LoadOptions, not a handle
- Date: Tue, 8 Jan 2019 17:54:43 +0000 (UTC)
commit 12c391fff6c102fb467d8c554ca3063aa62964e4
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Jan 7 22:11:12 2019 -0600
Defs::lookup() - take a LoadOptions, not a handle
rsvg_internals/src/defs.rs | 12 +++---------
rsvg_internals/src/handle.rs | 2 +-
rsvg_internals/src/svg.rs | 8 +++++---
3 files changed, 9 insertions(+), 13 deletions(-)
---
diff --git a/rsvg_internals/src/defs.rs b/rsvg_internals/src/defs.rs
index 42a075f9..5e3e4bec 100644
--- a/rsvg_internals/src/defs.rs
+++ b/rsvg_internals/src/defs.rs
@@ -3,8 +3,6 @@ use std::collections::HashMap;
use std::fmt;
use std::rc::Rc;
-use url::Url;
-
use allowed_url::AllowedUrl;
use error::ValueErrorKind;
use handle::{self, LoadOptions, RsvgHandle};
@@ -24,12 +22,9 @@ impl Defs {
/// Returns a node referenced by a fragment ID, from an
/// externally-loaded SVG file.
- pub fn lookup(&mut self, handle: *const RsvgHandle, fragment: &Fragment) -> Option<Rc<Node>> {
+ pub fn lookup(&mut self, load_options: &LoadOptions, fragment: &Fragment) -> Option<Rc<Node>> {
if let Some(ref href) = fragment.uri() {
- 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) {
+ match self.get_extern_handle(load_options, href) {
Ok(extern_handle) => handle::lookup_fragment_id(extern_handle, fragment.fragment()),
Err(()) => None,
}
@@ -41,10 +36,9 @@ impl Defs {
fn get_extern_handle(
&mut self,
load_options: &LoadOptions,
- base_url: Option<Url>,
href: &str,
) -> Result<*const RsvgHandle, ()> {
- let aurl = AllowedUrl::from_href(href, base_url.as_ref()).map_err(|_| ())?;
+ let aurl = AllowedUrl::from_href(href, load_options.base_url.as_ref()).map_err(|_| ())?;
match self.externs.entry(aurl) {
Entry::Occupied(e) => Ok(*(e.get())),
diff --git a/rsvg_internals/src/handle.rs b/rsvg_internals/src/handle.rs
index c79c9e3c..9729c324 100644
--- a/rsvg_internals/src/handle.rs
+++ b/rsvg_internals/src/handle.rs
@@ -186,7 +186,7 @@ impl Handle {
cancellable: Option<gio::Cancellable>,
) -> Result<(), LoadingError> {
*self.svg.borrow_mut() = Some(Rc::new(Svg::load_from_stream(
- self.load_options(),
+ &self.load_options(),
handle,
stream,
cancellable,
diff --git a/rsvg_internals/src/svg.rs b/rsvg_internals/src/svg.rs
index 8f4488ac..37c72bf2 100644
--- a/rsvg_internals/src/svg.rs
+++ b/rsvg_internals/src/svg.rs
@@ -6,7 +6,7 @@ use gio;
use css::CssStyles;
use defs::{Defs, Fragment};
use error::LoadingError;
-use handle::{LoadOptions, RsvgHandle};
+use handle::{self, LoadOptions, RsvgHandle};
use node::RsvgNode;
use tree::Tree;
use xml::XmlState;
@@ -49,7 +49,7 @@ impl Svg {
}
pub fn load_from_stream(
- load_options: LoadOptions,
+ load_options: &LoadOptions,
handle: *mut RsvgHandle,
stream: gio::InputStream,
cancellable: Option<gio::Cancellable>,
@@ -70,7 +70,9 @@ impl Svg {
pub fn lookup(&self, fragment: &Fragment) -> Option<RsvgNode> {
if fragment.uri().is_some() {
- self.defs.borrow_mut().lookup(self.handle, fragment)
+ self.defs
+ .borrow_mut()
+ .lookup(&handle::get_load_options(self.handle), fragment)
} else {
self.lookup_node_by_id(fragment.fragment())
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]