filters/image.rs: Use the fragment directly in the case where it is needed

parent 28d867ec
Pipeline #43263 passed with stages
in 23 minutes and 6 seconds
...@@ -6,7 +6,7 @@ use cairo::{self, ImageSurface, MatrixTrait, PatternTrait}; ...@@ -6,7 +6,7 @@ use cairo::{self, ImageSurface, MatrixTrait, PatternTrait};
use allowed_url::AllowedUrl; use allowed_url::AllowedUrl;
use aspect_ratio::AspectRatio; use aspect_ratio::AspectRatio;
use attributes::Attribute; use attributes::Attribute;
use defs::Href; use defs::{Fragment, Href};
use drawing_ctx::DrawingCtx; use drawing_ctx::DrawingCtx;
use error::RenderingError; use error::RenderingError;
use handle::{self, RsvgHandle}; use handle::{self, RsvgHandle};
...@@ -49,15 +49,10 @@ impl Image { ...@@ -49,15 +49,10 @@ impl Image {
ctx: &FilterContext, ctx: &FilterContext,
draw_ctx: &mut DrawingCtx<'_>, draw_ctx: &mut DrawingCtx<'_>,
bounds: IRect, bounds: IRect,
href: &Href, fragment: &Fragment,
) -> Result<ImageSurface, FilterError> { ) -> Result<ImageSurface, FilterError> {
let url = match *href {
Href::WithFragment(ref f) => format!("{}#{}", f.uri().unwrap_or(""), f.fragment()),
_ => unreachable!(),
};
let acquired_drawable = draw_ctx let acquired_drawable = draw_ctx
.get_acquired_href(&url) .get_acquired_node(fragment)
.ok_or(FilterError::InvalidInput)?; .ok_or(FilterError::InvalidInput)?;
let drawable = acquired_drawable.get(); let drawable = acquired_drawable.get();
...@@ -229,7 +224,7 @@ impl Filter for Image { ...@@ -229,7 +224,7 @@ impl Filter for Image {
Href::PlainUri(_) => { Href::PlainUri(_) => {
self.render_external_image(ctx, draw_ctx, bounds_builder, &href)? self.render_external_image(ctx, draw_ctx, bounds_builder, &href)?
} }
Href::WithFragment(_) => self.render_node(ctx, draw_ctx, bounds, &href)?, Href::WithFragment(frag) => self.render_node(ctx, draw_ctx, bounds, &frag)?,
}; };
Ok(FilterResult { Ok(FilterResult {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment