[librsvg] Make read_stream_sync() take a LoadOptions, not just a LoadFlags
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Make read_stream_sync() take a LoadOptions, not just a LoadFlags
- Date: Tue, 9 Apr 2019 16:45:04 +0000 (UTC)
commit 7704fbb68af06497fd35cd0fe31f629cc23a7322
Author: Federico Mena Quintero <federico gnome org>
Date: Fri Apr 5 14:58:36 2019 -0600
Make read_stream_sync() take a LoadOptions, not just a LoadFlags
This moves LoadOptions to the toplevel of the internal API.
Also, this makes CHandle construct a LoadOptions itself and pass it down.
Cargo.lock | 162 ++++++++++++++++++++-----------------
librsvg_crate/Cargo.toml | 1 +
librsvg_crate/src/lib.rs | 27 +++++--
rsvg_internals/src/c_api.rs | 80 ++++++++++++++----
rsvg_internals/src/handle.rs | 80 +++---------------
rsvg_internals/src/lib.rs | 2 +-
rsvg_internals/src/pixbuf_utils.rs | 24 +++++-
rsvg_internals/src/svg.rs | 4 +-
rsvg_internals/src/xml.rs | 6 +-
rsvg_internals/src/xml2_load.rs | 6 +-
10 files changed, 213 insertions(+), 179 deletions(-)
---
diff --git a/Cargo.lock b/Cargo.lock
index bb4603ce..2520ef63 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -8,12 +8,20 @@ dependencies = [
"memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "aho-corasick"
+version = "0.7.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "alga"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "approx 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "approx 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libm 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"num-complex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -21,7 +29,7 @@ dependencies = [
[[package]]
name = "approx"
-version = "0.3.1"
+version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -40,9 +48,9 @@ name = "atty"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -70,7 +78,7 @@ dependencies = [
"glib 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -79,9 +87,9 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"glib-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -121,7 +129,7 @@ dependencies = [
"cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
"criterion-plot 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "csv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "csv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -129,8 +137,8 @@ dependencies = [
"rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_xoshiro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
"tinytemplate 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -179,7 +187,7 @@ dependencies = [
[[package]]
name = "cssparser"
-version = "0.25.2"
+version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cssparser-macros 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -191,7 +199,7 @@ dependencies = [
"procedural-masquerade 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -203,16 +211,18 @@ dependencies = [
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"procedural-masquerade 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "csv"
-version = "1.0.5"
+version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"csv-core 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
+ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -251,7 +261,7 @@ dependencies = [
[[package]]
name = "either"
-version = "1.5.1"
+version = "1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -340,7 +350,7 @@ dependencies = [
"glib 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -351,7 +361,7 @@ dependencies = [
"gio-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -375,7 +385,7 @@ dependencies = [
"glib-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -385,7 +395,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"glib-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -398,7 +408,7 @@ dependencies = [
"glib-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -406,7 +416,7 @@ name = "glib-sys"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -416,7 +426,7 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"glib-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -435,7 +445,7 @@ name = "itertools"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -469,7 +479,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libc"
-version = "0.2.50"
+version = "0.2.51"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -486,6 +496,7 @@ dependencies = [
"glib 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"rsvg_internals 0.0.1",
+ "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -517,7 +528,7 @@ name = "memchr"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -527,11 +538,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "nalgebra"
-version = "0.17.2"
+version = "0.17.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"alga 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "approx 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "approx 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"matrixmultiply 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"num-complex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -563,7 +574,7 @@ name = "num_cpus"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -584,7 +595,7 @@ dependencies = [
"glib-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"pango-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -595,7 +606,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"glib-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -610,7 +621,7 @@ dependencies = [
"glib 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gobject-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"pango 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pango-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pangocairo-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -623,7 +634,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cairo-sys-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"pango-sys 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -699,7 +710,7 @@ version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -708,7 +719,7 @@ dependencies = [
"rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -754,9 +765,9 @@ name = "rand_jitter"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -766,10 +777,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -809,7 +820,7 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -820,7 +831,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -834,7 +845,7 @@ dependencies = [
[[package]]
name = "redox_syscall"
-version = "0.1.51"
+version = "0.1.52"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -842,7 +853,7 @@ name = "redox_termios"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
+ "redox_syscall 0.1.52 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -859,12 +870,12 @@ dependencies = [
[[package]]
name = "regex"
-version = "1.1.2"
+version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
"thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -879,7 +890,7 @@ dependencies = [
[[package]]
name = "regex-syntax"
-version = "0.6.5"
+version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -893,7 +904,7 @@ dependencies = [
"cairo-rs 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cairo-sys-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"criterion 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "cssparser 0.25.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cssparser 0.25.3 (registry+https://github.com/rust-lang/crates.io-index)",
"data-url 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"downcast-rs 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -908,9 +919,9 @@ dependencies = [
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"locale_config 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "nalgebra 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "nalgebra 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pango 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -919,7 +930,7 @@ dependencies = [
"phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)",
"phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -944,17 +955,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "serde"
-version = "1.0.89"
+version = "1.0.90"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "serde_derive"
-version = "1.0.89"
+version = "1.0.90"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -964,7 +975,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -984,7 +995,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "syn"
-version = "0.15.27"
+version = "0.15.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -997,8 +1008,8 @@ name = "termion"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
- "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
+ "redox_syscall 0.1.52 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -1023,7 +1034,7 @@ name = "tinytemplate"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -1084,7 +1095,7 @@ version = "2.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -1095,7 +1106,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi"
-version = "0.3.6"
+version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1117,7 +1128,7 @@ name = "winapi-util"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1132,8 +1143,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
"checksum aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" =
"81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5"
+"checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" =
"e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c"
"checksum alga 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" =
"2cc836ad7a40dc9d8049574e2a29979f5dc77deeea4d7ebcd29773452f0e9694"
-"checksum approx 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" =
"3c57ff1a5b00753647aebbbcf4ea67fa1e711a65ea7a30eb90dbf07de2485aee"
+"checksum approx 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" =
"f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3"
"checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" =
"92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71"
"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" =
"9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" =
"a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799"
@@ -1150,15 +1162,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" =
"f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3"
"checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" =
"927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150"
"checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" =
"2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9"
-"checksum cssparser 0.25.2 (registry+https://github.com/rust-lang/crates.io-index)" =
"37ad0cdd7a068448d43318ea1637fec1647f07f985799fd54c9c7d7613762f08"
+"checksum cssparser 0.25.3 (registry+https://github.com/rust-lang/crates.io-index)" =
"ba1ab4e1814be64bf6b6064ff532db0e34087f11b37706d6c96a21d32478761d"
"checksum cssparser-macros 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" =
"b16e382d9b983fdb9ac6a36b37fdeb84ce3ea81f749febfee3463cfa7f24275e"
-"checksum csv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" =
"9fd1c44c58078cfbeaf11fbb3eac9ae5534c23004ed770cc4bfb48e658ae4f04"
+"checksum csv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" =
"f0782c7154d8dd08f4adeb5aa22ab178c10281915f7da68d10bb646f03aaee73"
"checksum csv-core 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" =
"fa5cdef62f37e6ffe7d1f07a381bc0db32b7a3ff1cac0de56cb0d81e71f53d65"
"checksum data-url 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" =
"d33fe99ccedd6e84bc035f1931bb2e6be79739d6242bd895e7311c886c50dc9c"
"checksum downcast-rs 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" =
"18df8ce4470c189d18aa926022da57544f31e154631eb4cfe796aea97051fe6c"
"checksum dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" =
"6d301140eb411af13d3115f9a562c85cc6b541ade9dfa314132244aaee7489dd"
"checksum dtoa-short 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" =
"59020b8513b76630c49d918c33db9f4c91638e7d3404a28084083b87e33f76f2"
-"checksum either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" =
"c67353c641dc847124ea1902d69bd753dee9bb3beff9aa3662ecf86c971d1fac"
+"checksum either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" =
"5527cfe0d098f36e3f8839852688e63c8fff1c90b2b405aef730615f9a7bcf7b"
"checksum encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" =
"6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec"
"checksum encoding-index-japanese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" =
"04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91"
"checksum encoding-index-korean 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" =
"4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81"
@@ -1184,14 +1196,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" =
"a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a"
"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" =
"76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73"
"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" =
"bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14"
-"checksum libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" =
"aab692d7759f5cd8c859e169db98ae5b52c924add2af5fbbca11d12fefb567c1"
+"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" =
"bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917"
"checksum libm 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" =
"03c0bb6d5ce1b5cc6fd0578ec1cbc18c9d88b5b591a5c7c1d6c6175e266a0819"
"checksum locale_config 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" =
"14fbee0e39bc2dd6a2427c4fdea66e9826cc1fd09b0a0b7550359f5f6efe1dab"
"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" =
"7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
"checksum matrixmultiply 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" =
"dcfed72d871629daa12b25af198f110e8095d7650f5f4c61c5bac28364604f9b"
"checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" =
"2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39"
"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" =
"0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3"
-"checksum nalgebra 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)" =
"f76a29833cbba252d6799bcfd8e603610a2165a18b62c7f4307495d851c3d337"
+"checksum nalgebra 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)" =
"be539bb5e751c248d25c21c850b69105809306f367c35bf1daa8724f0cb786df"
"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" =
"2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945"
"checksum num-complex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" =
"107b9be86cd2481930688277b675b0114578227f034674726605b8a482d8baf8"
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" =
"0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
@@ -1225,22 +1237,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" =
"373814f27745b2686b350dd261bfd24576a6fb0e2c5919b3a2b6005f820b0473"
"checksum rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" =
"b055d1e92aba6877574d8fe604a63c8b5df60f60e5982bf7ccbb1338ea527356"
"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" =
"678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
-"checksum redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)" =
"423e376fffca3dfa06c9e9790a9ccd282fafb3cc6e6397d01dbf64f9bacc6b85"
+"checksum redox_syscall 0.1.52 (registry+https://github.com/rust-lang/crates.io-index)" =
"d32b3053e5ced86e4bc0411fec997389532bf56b000e66cb4884eeeb41413d69"
"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" =
"7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
"checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" =
"9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384"
-"checksum regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" =
"53ee8cfdddb2e0291adfb9f13d31d3bbe0a03c9a402c01b1e24188d86c35b24f"
+"checksum regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)" =
"559008764a17de49a3146b234641644ed37d118d1ef641a0bb573d146edc6ce0"
"checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" =
"7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7"
-"checksum regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" =
"8c2f35eedad5295fdf00a63d7d4b238135723f92b434ec06774dad15c7ab0861"
+"checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" =
"dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96"
"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" =
"eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7"
"checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" =
"8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267"
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" =
"94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
-"checksum serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)" =
"92514fb95f900c9b5126e32d020f5c6d40564c27a5ea6d1d7d9f157a96623560"
-"checksum serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)" =
"bb6eabf4b5914e88e24eea240bb7c9f9a2cbc1bbbe8d961d381975ec3c6b806c"
+"checksum serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)" =
"aa5f7c20820475babd2c077c3ab5f8c77a31c15e16ea38687b4c02d3e48680f4"
+"checksum serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)" =
"58fc82bec244f168b23d1963b45c8bf5726e9a15a9d146a067f9081aeed2de79"
"checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" =
"5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d"
"checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" =
"0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac"
"checksum smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" =
"c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be"
"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" =
"dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8"
-"checksum syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)" =
"525bd55255f03c816e5d7f615587bd13030c7103354fadb104993dcee6a788ec"
+"checksum syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)" =
"66c8865bf5a7cbb662d8b011950060b3c8743dca141b054bf7195b20d314d8e2"
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" =
"689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" =
"307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6"
"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" =
"c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
@@ -1255,7 +1267,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" =
"796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737"
"checksum walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)" =
"9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" =
"167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
-"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" =
"92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
+"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" =
"f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" =
"2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" =
"ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" =
"7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9"
diff --git a/librsvg_crate/Cargo.toml b/librsvg_crate/Cargo.toml
index 14dea355..1dfd1e4e 100644
--- a/librsvg_crate/Cargo.toml
+++ b/librsvg_crate/Cargo.toml
@@ -14,6 +14,7 @@ cairo-rs = "0.6.0"
glib = "0.7.0"
gio = { version="0.6.0", features=["v2_48"] } # per configure.ac
rsvg_internals = { path = "../rsvg_internals" }
+url = "1.7.2"
[dev-dependencies]
cairo-rs = { version = "0.6.0", features = ["png"] }
diff --git a/librsvg_crate/src/lib.rs b/librsvg_crate/src/lib.rs
index 585cf127..950dcbc2 100644
--- a/librsvg_crate/src/lib.rs
+++ b/librsvg_crate/src/lib.rs
@@ -91,6 +91,7 @@ use cairo;
use gio;
use glib;
use rsvg_internals;
+use url::Url;
use std::path::Path;
@@ -100,7 +101,7 @@ use glib::object::Cast;
use rsvg_internals::{Dpi, Handle, LoadFlags};
pub use rsvg_internals::{
- DefsLookupErrorKind, HrefError, Length, LengthUnit, LoadingError, RenderingError,
+ DefsLookupErrorKind, HrefError, Length, LengthUnit, LoadOptions, LoadingError, RenderingError,
};
/// Struct for loading an [`SvgHandle`][SvgHandle].
@@ -279,17 +280,29 @@ impl Loader {
cancellable: P,
) -> Result<SvgHandle, LoadingError> {
let handle = Handle::new();
- handle.construct_read_stream_sync(
- self.load_flags(),
- stream,
- base_file,
- cancellable.into(),
- )?;
+
+ let base_url = if let Some(base_file) = base_file {
+ Some(url_from_file(&base_file)?)
+ } else {
+ None
+ };
+
+ let load_options = LoadOptions::new(self.load_flags(), base_url);
+
+ handle.construct_read_stream_sync(&load_options, stream, cancellable.into())?;
Ok(SvgHandle(handle))
}
}
+fn url_from_file(file: &gio::File) -> Result<Url, LoadingError> {
+ if let Some(uri) = file.get_uri() {
+ Ok(Url::parse(&uri).map_err(|_| LoadingError::BadUrl)?)
+ } else {
+ Err(LoadingError::BadUrl)
+ }
+}
+
/// Handle used to hold SVG data in memory.
///
/// You can create this from one of the `read` methods in
diff --git a/rsvg_internals/src/c_api.rs b/rsvg_internals/src/c_api.rs
index 6396c42c..22119e4f 100644
--- a/rsvg_internals/src/c_api.rs
+++ b/rsvg_internals/src/c_api.rs
@@ -1,5 +1,5 @@
-use std::cell::Cell;
-use std::ffi::CStr;
+use std::cell::{Cell, RefCell};
+use std::ffi::{CStr, CString};
use std::ops;
use std::path::PathBuf;
use std::ptr;
@@ -25,7 +25,7 @@ use gobject_sys::{self, GEnumValue, GFlagsValue};
use crate::dpi::Dpi;
use crate::drawing_ctx::RsvgRectangle;
use crate::error::{set_gerror, LoadingError, RSVG_ERROR_FAILED};
-use crate::handle::{Handle, LoadFlags, LoadState};
+use crate::handle::{Handle, LoadFlags, LoadOptions, LoadState};
use crate::length::RsvgLength;
use url::Url;
@@ -159,6 +159,8 @@ pub struct RsvgHandle {
pub struct CHandle {
dpi: Cell<Dpi>,
load_flags: Cell<LoadFlags>,
+ base_url: RefCell<Option<Url>>,
+ base_url_cstring: RefCell<Option<CString>>, // needed because the C api returns *const char
handle: Handle,
}
@@ -287,6 +289,8 @@ impl ObjectSubclass for CHandle {
CHandle {
dpi: Cell::new(Dpi::default()),
load_flags: Cell::new(LoadFlags::default()),
+ base_url: RefCell::new(None),
+ base_url_cstring: RefCell::new(None),
handle: Handle::new(),
}
}
@@ -322,7 +326,7 @@ impl ObjectImpl for CHandle {
// construct-time property.
if let Some(s) = v {
- self.handle.set_base_url(&s);
+ self.set_base_url(&s);
}
}
@@ -343,7 +347,6 @@ impl ObjectImpl for CHandle {
subclass::Property("dpi-y", ..) => Ok(self.dpi.get().y().to_value()),
subclass::Property("base-uri", ..) => Ok(self
- .handle
.base_url
.borrow()
.as_ref()
@@ -382,6 +385,51 @@ impl ObjectImpl for CHandle {
}
}
+impl CHandle {
+ fn set_base_url(&self, url: &str) {
+ // if self.load_state.get() != LoadState::Start {
+ // panic!("Please set the base file or URI before loading any data into RsvgHandle",);
+ // }
+
+ match Url::parse(&url) {
+ Ok(u) => {
+ let url_cstring = CString::new(u.as_str()).unwrap();
+
+ rsvg_log!("setting base_uri to \"{}\"", u.as_str());
+ *self.base_url.borrow_mut() = Some(u);
+ *self.base_url_cstring.borrow_mut() = Some(url_cstring);
+ }
+
+ Err(e) => {
+ rsvg_log!(
+ "not setting base_uri to \"{}\" since it is invalid: {}",
+ url,
+ e
+ );
+ }
+ }
+ }
+
+ pub fn set_base_gfile(&self, file: &gio::File) {
+ if let Some(uri) = file.get_uri() {
+ self.set_base_url(&uri);
+ } else {
+ panic!("file has no URI; will not set the base URI");
+ }
+ }
+
+ pub fn get_base_url_as_ptr(&self) -> *const libc::c_char {
+ match *self.base_url_cstring.borrow() {
+ None => ptr::null(),
+ Some(ref url) => url.as_ptr(),
+ }
+ }
+
+ fn load_options(&self) -> LoadOptions {
+ LoadOptions::new(self.load_flags.get(), self.base_url.borrow().clone())
+ }
+}
+
pub fn get_rust_handle<'a>(handle: *const RsvgHandle) -> &'a CHandle {
let handle = unsafe { &*handle };
handle.get_impl()
@@ -484,7 +532,7 @@ pub unsafe extern "C" fn rsvg_rust_handle_set_base_url(
assert!(!uri.is_null());
let uri: String = from_glib_none(uri);
- rhandle.handle.set_base_url(&uri);
+ rhandle.set_base_url(&uri);
}
#[no_mangle]
@@ -498,7 +546,7 @@ pub unsafe extern "C" fn rsvg_rust_handle_set_base_gfile(
let file: gio::File = from_glib_none(raw_gfile);
- rhandle.handle.set_base_gfile(&file);
+ rhandle.set_base_gfile(&file);
}
#[no_mangle]
@@ -507,7 +555,7 @@ pub unsafe extern "C" fn rsvg_rust_handle_get_base_url(
) -> *const libc::c_char {
let rhandle = get_rust_handle(raw_handle);
- rhandle.handle.get_base_url_as_ptr()
+ rhandle.get_base_url_as_ptr()
}
#[no_mangle]
@@ -600,7 +648,7 @@ pub unsafe extern "C" fn rsvg_rust_handle_read_stream_sync(
match rhandle
.handle
- .read_stream_sync(rhandle.load_flags.get(), &stream, cancellable.as_ref())
+ .read_stream_sync(&rhandle.load_options(), &stream, cancellable.as_ref())
{
Ok(()) => true.to_glib(),
@@ -637,7 +685,7 @@ pub unsafe extern "C" fn rsvg_rust_handle_close(
) -> glib_sys::gboolean {
let rhandle = get_rust_handle(handle);
- match rhandle.handle.close(rhandle.load_flags.get()) {
+ match rhandle.handle.close(&rhandle.load_options()) {
Ok(()) => true.to_glib(),
Err(e) => {
@@ -817,6 +865,8 @@ pub unsafe extern "C" fn rsvg_rust_handle_new_from_gfile_sync(
let rhandle = get_rust_handle(raw_handle);
let file = gio::File::from_glib_none(file);
+ rhandle.set_base_gfile(&file);
+
let cancellable: Option<gio::Cancellable> = from_glib_none(cancellable);
let res = file
@@ -824,9 +874,8 @@ pub unsafe extern "C" fn rsvg_rust_handle_new_from_gfile_sync(
.map_err(|e| LoadingError::from(e))
.and_then(|stream| {
rhandle.handle.construct_read_stream_sync(
- rhandle.load_flags.get(),
+ &rhandle.load_options(),
&stream.upcast(),
- Some(&file),
cancellable.as_ref(),
)
});
@@ -855,13 +904,16 @@ pub unsafe extern "C" fn rsvg_rust_handle_new_from_stream_sync(
let rhandle = get_rust_handle(raw_handle);
let base_file: Option<gio::File> = from_glib_none(base_file);
+ if let Some(base_file) = base_file {
+ rhandle.set_base_gfile(&base_file);
+ }
+
let stream = from_glib_none(input_stream);
let cancellable: Option<gio::Cancellable> = from_glib_none(cancellable);
match rhandle.handle.construct_read_stream_sync(
- rhandle.load_flags.get(),
+ &rhandle.load_options(),
&stream,
- base_file.as_ref(),
cancellable.as_ref(),
) {
Ok(()) => raw_handle,
diff --git a/rsvg_internals/src/handle.rs b/rsvg_internals/src/handle.rs
index 20192e56..d3efb232 100644
--- a/rsvg_internals/src/handle.rs
+++ b/rsvg_internals/src/handle.rs
@@ -1,11 +1,10 @@
use std::cell::{Cell, RefCell};
-use std::ffi::CString;
use std::ptr;
use std::rc::Rc;
use cairo::{self, ImageSurface, Status};
use gdk_pixbuf::Pixbuf;
-use gio::{self, FileExt};
+use gio;
use glib::{self, Bytes, Cast};
use glib_sys;
use libc;
@@ -45,7 +44,7 @@ pub struct LoadOptions {
}
impl LoadOptions {
- fn new(flags: LoadFlags, base_url: Option<Url>) -> LoadOptions {
+ pub fn new(flags: LoadFlags, base_url: Option<Url>) -> LoadOptions {
LoadOptions {
flags,
base_url,
@@ -116,8 +115,6 @@ impl Drop for SizeCallback {
}
pub struct Handle {
- pub base_url: RefCell<Option<Url>>,
- base_url_cstring: RefCell<Option<CString>>, // needed because the C api returns *const char
svg: RefCell<Option<Rc<Svg>>>,
load_state: Cell<LoadState>,
buffer: RefCell<Vec<u8>>, // used by the legacy write() api
@@ -129,8 +126,6 @@ pub struct Handle {
impl Handle {
pub fn new() -> Handle {
Handle {
- base_url: RefCell::new(None),
- base_url_cstring: RefCell::new(None),
svg: RefCell::new(None),
load_state: Cell::new(LoadState::Start),
buffer: RefCell::new(Vec::new()),
@@ -140,46 +135,6 @@ impl Handle {
}
}
- // from the public API
- pub fn set_base_url(&self, url: &str) {
- if self.load_state.get() != LoadState::Start {
- panic!("Please set the base file or URI before loading any data into RsvgHandle",);
- }
-
- match Url::parse(&url) {
- Ok(u) => {
- let url_cstring = CString::new(u.as_str()).unwrap();
-
- rsvg_log!("setting base_uri to \"{}\"", u.as_str());
- *self.base_url.borrow_mut() = Some(u);
- *self.base_url_cstring.borrow_mut() = Some(url_cstring);
- }
-
- Err(e) => {
- rsvg_log!(
- "not setting base_uri to \"{}\" since it is invalid: {}",
- url,
- e
- );
- }
- }
- }
-
- pub fn set_base_gfile(&self, file: &gio::File) {
- if let Some(uri) = file.get_uri() {
- self.set_base_url(&uri);
- } else {
- panic!("file has no URI; will not set the base URI");
- }
- }
-
- pub fn get_base_url_as_ptr(&self) -> *const libc::c_char {
- match *self.base_url_cstring.borrow() {
- None => ptr::null(),
- Some(ref url) => url.as_ptr(),
- }
- }
-
pub fn set_size_callback(
&self,
size_func: RsvgSizeFunc,
@@ -200,17 +155,16 @@ impl Handle {
pub fn read_stream_sync(
&self,
- load_flags: LoadFlags,
+ load_options: &LoadOptions,
stream: &gio::InputStream,
cancellable: Option<&gio::Cancellable>,
) -> Result<(), LoadingError> {
self.load_state.set(LoadState::Loading);
- let svg =
- Svg::load_from_stream(&self.load_options(load_flags), stream, cancellable).map_err(|e| {
- self.load_state.set(LoadState::ClosedError);
- e
- })?;
+ let svg = Svg::load_from_stream(load_options, stream, cancellable).map_err(|e| {
+ self.load_state.set(LoadState::ClosedError);
+ e
+ })?;
*self.svg.borrow_mut() = Some(Rc::new(svg));
self.load_state.set(LoadState::ClosedOk);
@@ -245,13 +199,6 @@ impl Handle {
self.load_state.get()
}
- fn load_options(&self, load_flags: LoadFlags) -> LoadOptions {
- LoadOptions::new(
- load_flags,
- self.base_url.borrow().clone(),
- )
- }
-
pub fn write(&self, buf: &[u8]) {
match self.load_state.get() {
LoadState::Start => self.load_state.set(LoadState::Loading),
@@ -262,7 +209,7 @@ impl Handle {
self.buffer.borrow_mut().extend_from_slice(buf);
}
- pub fn close(&self, load_flags: LoadFlags) -> Result<(), LoadingError> {
+ pub fn close(&self, load_options: &LoadOptions) -> Result<(), LoadingError> {
let res = match self.load_state.get() {
LoadState::Start => {
self.load_state.set(LoadState::ClosedError);
@@ -274,7 +221,7 @@ impl Handle {
let bytes = Bytes::from(&*buffer);
let stream = gio::MemoryInputStream::new_from_bytes(&bytes);
- self.read_stream_sync(load_flags, &stream.upcast(), None)
+ self.read_stream_sync(load_options, &stream.upcast(), None)
}
LoadState::ClosedOk | LoadState::ClosedError => {
@@ -615,16 +562,11 @@ impl Handle {
pub fn construct_read_stream_sync(
&self,
- load_flags: LoadFlags,
+ load_options: &LoadOptions,
stream: &gio::InputStream,
- base_file: Option<&gio::File>,
cancellable: Option<&gio::Cancellable>,
) -> Result<(), LoadingError> {
- if let Some(file) = base_file {
- self.set_base_gfile(file);
- }
-
- self.read_stream_sync(load_flags, stream, cancellable)
+ self.read_stream_sync(load_options, stream, cancellable)
}
pub fn get_intrinsic_dimensions(&self) -> IntrinsicDimensions {
diff --git a/rsvg_internals/src/lib.rs b/rsvg_internals/src/lib.rs
index ff843b70..e5fce48b 100644
--- a/rsvg_internals/src/lib.rs
+++ b/rsvg_internals/src/lib.rs
@@ -60,7 +60,7 @@ pub use crate::error::{
RenderingError,
};
-pub use crate::handle::{Handle, LoadFlags};
+pub use crate::handle::{Handle, LoadFlags, LoadOptions};
pub use crate::length::{Length, LengthUnit};
diff --git a/rsvg_internals/src/pixbuf_utils.rs b/rsvg_internals/src/pixbuf_utils.rs
index 2b03f02f..e4ab045b 100644
--- a/rsvg_internals/src/pixbuf_utils.rs
+++ b/rsvg_internals/src/pixbuf_utils.rs
@@ -10,11 +10,12 @@ use glib::translate::*;
use glib::Cast;
use glib_sys;
use libc;
+use url::Url;
use crate::c_api::RsvgDimensionData;
use crate::dpi::Dpi;
use crate::error::{set_gerror, LoadingError, RenderingError};
-use crate::handle::{Handle, LoadFlags};
+use crate::handle::{Handle, LoadFlags, LoadOptions};
use crate::rect::IRect;
use crate::surface_utils::{
iterators::Pixels, shared_surface::SharedImageSurface, shared_surface::SurfaceType,
@@ -195,6 +196,14 @@ fn get_default_dpi() -> Dpi {
Dpi::new(-1.0, -1.0)
}
+fn url_from_file(file: &gio::File) -> Result<Url, LoadingError> {
+ if let Some(uri) = file.get_uri() {
+ Ok(Url::parse(&uri).map_err(|_| LoadingError::BadUrl)?)
+ } else {
+ Err(LoadingError::BadUrl)
+ }
+}
+
fn pixbuf_from_file_with_size_mode(
filename: *const libc::c_char,
size_mode: &SizeMode,
@@ -206,6 +215,16 @@ fn pixbuf_from_file_with_size_mode(
let path = PathBuf::from_glib_none(filename);
let file = gio::File::new_for_path(path);
+ let base_url = match url_from_file(&file) {
+ Ok(url) => url,
+ Err(e) => {
+ set_gerror(error, 0, &format!("{}", e));
+ return ptr::null_mut();
+ }
+ };
+
+ let load_options = LoadOptions::new(LoadFlags::default(), Some(base_url));
+
let handle = Handle::new();
let cancellable: Option<&gio::Cancellable> = None;
if let Err(e) = file
@@ -213,9 +232,8 @@ fn pixbuf_from_file_with_size_mode(
.map_err(|e| LoadingError::from(e))
.and_then(|stream| {
handle.construct_read_stream_sync(
- LoadFlags::default(),
+ &load_options,
&stream.upcast(),
- Some(&file),
None,
)
})
diff --git a/rsvg_internals/src/svg.rs b/rsvg_internals/src/svg.rs
index e8cba642..79e2840c 100644
--- a/rsvg_internals/src/svg.rs
+++ b/rsvg_internals/src/svg.rs
@@ -54,10 +54,9 @@ impl Svg {
stream: &gio::InputStream,
cancellable: Option<&gio::Cancellable>,
) -> Result<Svg, LoadingError> {
- let load_flags = load_options.flags;
let mut xml = XmlState::new(load_options);
- xml_state_load_from_possibly_compressed_stream(&mut xml, load_flags, stream, cancellable)?;
+ xml_state_load_from_possibly_compressed_stream(&mut xml, stream, cancellable)?;
xml.steal_result()
}
@@ -82,6 +81,7 @@ impl Svg {
}
pub fn lookup_image(&self, href: &str) -> Result<SharedImageSurface, LoadingError> {
+ dbg!(&self.load_options.base_url);
self.images.borrow_mut().lookup(&self.load_options, href)
}
diff --git a/rsvg_internals/src/xml.rs b/rsvg_internals/src/xml.rs
index 1342e291..a0f7315a 100644
--- a/rsvg_internals/src/xml.rs
+++ b/rsvg_internals/src/xml.rs
@@ -75,7 +75,7 @@ pub struct XmlState {
entities: HashMap<String, XmlEntityPtr>,
- load_options: LoadOptions,
+ pub load_options: LoadOptions,
}
/// Errors returned from XmlState::acquire()
@@ -475,10 +475,8 @@ impl XmlState {
_ => AcquireError::ResourceError,
})?;
- let flags = self.load_options.flags;
-
// FIXME: pass a cancellable
- xml_state_parse_from_stream(self, flags, stream, None).map_err(|e| match e {
+ xml_state_parse_from_stream(self, stream, None).map_err(|e| match e {
ParseFromStreamError::CouldNotCreateXmlParser => AcquireError::FatalError,
ParseFromStreamError::IoError(_) => AcquireError::ResourceError,
ParseFromStreamError::XmlParseError(_) => AcquireError::FatalError,
diff --git a/rsvg_internals/src/xml2_load.rs b/rsvg_internals/src/xml2_load.rs
index ba160c9f..0d2edabb 100644
--- a/rsvg_internals/src/xml2_load.rs
+++ b/rsvg_internals/src/xml2_load.rs
@@ -448,21 +448,19 @@ impl From<ParseFromStreamError> for LoadingError {
// for example, when including another XML file via xi:include.
pub fn xml_state_parse_from_stream(
xml: &mut XmlState,
- load_flags: LoadFlags,
stream: gio::InputStream,
cancellable: Option<&gio::Cancellable>,
) -> Result<(), ParseFromStreamError> {
- Xml2Parser::from_stream(xml, load_flags, stream, cancellable).and_then(|parser| parser.parse())
+ Xml2Parser::from_stream(xml, xml.load_options.flags, stream, cancellable).and_then(|parser|
parser.parse())
}
pub fn xml_state_load_from_possibly_compressed_stream(
xml: &mut XmlState,
- load_flags: LoadFlags,
stream: &gio::InputStream,
cancellable: Option<&gio::Cancellable>,
) -> Result<(), ParseFromStreamError> {
let stream = get_input_stream_for_loading(stream, cancellable)
.map_err(|e| ParseFromStreamError::IoError(e))?;
- xml_state_parse_from_stream(xml, load_flags, stream, cancellable)
+ xml_state_parse_from_stream(xml, stream, cancellable)
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]