[librsvg: 3/22] Svg::load_from_stream(): Move code from Handle::read_stream_internal()
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 3/22] Svg::load_from_stream(): Move code from Handle::read_stream_internal()
- Date: Tue, 8 Jan 2019 17:53:27 +0000 (UTC)
commit 6cd28b2e786cb2339a47dcb95b00d61910dd2d1e
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Jan 7 18:37:49 2019 -0600
Svg::load_from_stream(): Move code from Handle::read_stream_internal()
rsvg_internals/src/handle.rs | 17 ++++-------------
rsvg_internals/src/svg.rs | 27 ++++++++++++++++++++++++++-
2 files changed, 30 insertions(+), 14 deletions(-)
---
diff --git a/rsvg_internals/src/handle.rs b/rsvg_internals/src/handle.rs
index 21724d99..949444e1 100644
--- a/rsvg_internals/src/handle.rs
+++ b/rsvg_internals/src/handle.rs
@@ -34,8 +34,6 @@ use surface_utils::{
};
use svg::Svg;
use util::rsvg_g_warning;
-use xml::XmlState;
-use xml2_load::xml_state_load_from_possibly_compressed_stream;
// A *const RsvgHandle is just an opaque pointer we get from C
#[repr(C)]
@@ -171,20 +169,13 @@ impl Handle {
stream: gio::InputStream,
cancellable: Option<gio::Cancellable>,
) -> Result<(), LoadingError> {
- let load_options = self.load_options.get();
-
- let mut xml = XmlState::new(handle);
-
- xml_state_load_from_possibly_compressed_stream(
- &mut xml,
- &load_options,
+ *self.svg.borrow_mut() = Some(Rc::new(Svg::load_from_stream(
+ self.load_options.get(),
+ handle,
stream,
cancellable,
- )?;
+ )?));
- xml.validate_tree()?;
-
- *self.svg.borrow_mut() = Some(Rc::new(xml.steal_result()));
Ok(())
}
diff --git a/rsvg_internals/src/svg.rs b/rsvg_internals/src/svg.rs
index ca81c3fa..8f4488ac 100644
--- a/rsvg_internals/src/svg.rs
+++ b/rsvg_internals/src/svg.rs
@@ -1,11 +1,16 @@
use std::cell::RefCell;
use std::collections::HashMap;
+use gio;
+
use css::CssStyles;
use defs::{Defs, Fragment};
-use handle::RsvgHandle;
+use error::LoadingError;
+use handle::{LoadOptions, RsvgHandle};
use node::RsvgNode;
use tree::Tree;
+use xml::XmlState;
+use xml2_load::xml_state_load_from_possibly_compressed_stream;
/// A loaded SVG file and its derived data
///
@@ -43,6 +48,26 @@ impl Svg {
}
}
+ pub fn load_from_stream(
+ load_options: LoadOptions,
+ handle: *mut RsvgHandle,
+ stream: gio::InputStream,
+ cancellable: Option<gio::Cancellable>,
+ ) -> Result<Svg, LoadingError> {
+ let mut xml = XmlState::new(handle);
+
+ xml_state_load_from_possibly_compressed_stream(
+ &mut xml,
+ &load_options,
+ stream,
+ cancellable,
+ )?;
+
+ xml.validate_tree()?;
+
+ Ok(xml.steal_result())
+ }
+
pub fn lookup(&self, fragment: &Fragment) -> Option<RsvgNode> {
if fragment.uri().is_some() {
self.defs.borrow_mut().lookup(self.handle, fragment)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]