[librsvg] gradient.rs: Use Fragment instead of String for the fallback name
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] gradient.rs: Use Fragment instead of String for the fallback name
- Date: Fri, 30 Nov 2018 00:32:01 +0000 (UTC)
commit f0e7f42d43dc99ca3ef0485263844c26d1e8913c
Author: Federico Mena Quintero <federico gnome org>
Date: Thu Nov 29 17:59:41 2018 -0600
gradient.rs: Use Fragment instead of String for the fallback name
rsvg_internals/src/gradient.rs | 15 +++++++++------
rsvg_internals/src/util.rs | 11 -----------
2 files changed, 9 insertions(+), 17 deletions(-)
---
diff --git a/rsvg_internals/src/gradient.rs b/rsvg_internals/src/gradient.rs
index a4533039..eb6846e3 100644
--- a/rsvg_internals/src/gradient.rs
+++ b/rsvg_internals/src/gradient.rs
@@ -6,6 +6,7 @@ use std::cell::RefCell;
use attributes::Attribute;
use bbox::*;
use coord_units::CoordUnits;
+use defs::Fragment;
use drawing_ctx::{AcquiredNode, DrawingCtx};
use error::*;
use handle::RsvgHandle;
@@ -18,7 +19,6 @@ use rect::RectangleExt;
use state::{ComputedValues, StopColor};
use stop::*;
use unitinterval::UnitInterval;
-use util::clone_fallback_name;
#[derive(Copy, Clone)]
pub struct ColorStop {
@@ -85,7 +85,7 @@ pub struct GradientCommon {
pub units: Option<GradientUnits>,
pub affine: Option<cairo::Matrix>,
pub spread: Option<SpreadMethod>,
- pub fallback: Option<String>,
+ pub fallback: Option<Fragment>,
pub stops: Option<Vec<ColorStop>>,
}
@@ -184,7 +184,7 @@ impl GradientCommon {
fallback_to!(self.spread, fallback.spread);
fallback_to!(self.stops, fallback.clone_stops());
- self.fallback = clone_fallback_name(&fallback.fallback);
+ self.fallback = fallback.fallback.clone();
}
fn add_color_stop(&mut self, mut offset: f64, rgba: cssparser::RGBA, opacity: UnitInterval) {
@@ -430,8 +430,8 @@ impl Gradient {
}
}
-fn acquire_gradient<'a>(draw_ctx: &'a mut DrawingCtx<'_>, name: &str) -> Option<AcquiredNode> {
- if let Some(acquired) = draw_ctx.get_acquired_href(name) {
+fn acquire_gradient<'a>(draw_ctx: &'a mut DrawingCtx<'_>, name: &Fragment) -> Option<AcquiredNode> {
+ if let Some(acquired) = draw_ctx.get_acquired_node(name) {
let node_type = acquired.get().get_type();
if node_type == NodeType::LinearGradient || node_type == NodeType::RadialGradient {
@@ -671,7 +671,10 @@ impl NodeTrait for NodeGradient {
g.common.spread = Some(parse("spreadMethod", value, ())?)
}
- Attribute::XlinkHref => g.common.fallback = Some(value.to_owned()),
+ Attribute::XlinkHref => {
+ g.common.fallback =
+ Some(Fragment::parse(value).attribute(Attribute::XlinkHref)?)
+ }
// Attributes specific to each gradient type. The defaults mandated by the spec
// are in GradientVariant::resolve_from_defaults()
diff --git a/rsvg_internals/src/util.rs b/rsvg_internals/src/util.rs
index ab5cd5be..3a7c7cac 100644
--- a/rsvg_internals/src/util.rs
+++ b/rsvg_internals/src/util.rs
@@ -5,17 +5,6 @@ use std::str;
use glib::translate::*;
-// In paint servers (patterns, gradients, etc.), we have an
-// Option<String> for fallback names. This is a utility function to
-// clone one of those.
-pub fn clone_fallback_name(fallback: &Option<String>) -> Option<String> {
- if let Some(ref fallback_name) = *fallback {
- Some(fallback_name.clone())
- } else {
- None
- }
-}
-
/// Converts a `char *` which is known to be valid UTF-8 into a `&str`
///
/// The usual `from_glib_none(s)` allocates an owned String. The
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]