[librsvg: 4/5] (#560): Ignore missing filter definitions instead of not rendering the filtered object
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 4/5] (#560): Ignore missing filter definitions instead of not rendering the filtered object
- Date: Thu, 20 Aug 2020 03:00:10 +0000 (UTC)
commit d05fc806d152525c8611042a224e683ae4a97aad
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Aug 19 20:06:02 2020 -0500
(#560): Ignore missing filter definitions instead of not rendering the filtered object
This is a change from the behavior we had for SVG 1.1.
SVG1.1 doesn't mention what to do when there is an element with a
filter="url(#nonexistent)" attribute, i.e. when it points to a
nonexistent element or when the element is not a <filter> element.
However, the SVG1.1 test suite implies (in the files removed by this
commit) that the object being filtered should not be rendered at all.
However, SVG2 *does* mention what to do in
https://www.w3.org/TR/filter-effects/#FilterProperty - the object
being filtered should get no filter applied, i.e. render it as if it
had no filter.
Fixes https://gitlab.gnome.org/GNOME/librsvg/-/issues/560
librsvg_crate/tests/bugs.rs | 44 +++++++++++++++++++++++++++++++++++++++
rsvg_internals/src/drawing_ctx.rs | 10 +++------
2 files changed, 47 insertions(+), 7 deletions(-)
---
diff --git a/librsvg_crate/tests/bugs.rs b/librsvg_crate/tests/bugs.rs
index 33aa96602..2b1856ff4 100644
--- a/librsvg_crate/tests/bugs.rs
+++ b/librsvg_crate/tests/bugs.rs
@@ -127,3 +127,47 @@ fn href_attribute_overrides_xlink_href() {
"href_attribute_overrides_xlink_href",
);
}
+
+// https://gitlab.gnome.org/GNOME/librsvg/-/issues/560
+#[test]
+fn nonexistent_filter_leaves_object_unfiltered() {
+ let svg = load_svg(
+ br##"<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg"
+ width="500" height="500">
+ <rect x="100" y="100" width="100" height="100" fill="lime" filter="url(#nonexistent)"/>
+</svg>
+"##,
+ );
+
+ let output_surf = render_document(
+ &svg,
+ SurfaceSize(500, 500),
+ |_| (),
+ cairo::Rectangle {
+ x: 0.0,
+ y: 0.0,
+ width: 500.0,
+ height: 500.0,
+ },
+ )
+ .unwrap();
+
+ let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 500, 500).unwrap();
+
+ {
+ let cr = cairo::Context::new(&reference_surf);
+
+ cr.rectangle(100.0, 100.0, 100.0, 100.0);
+ cr.set_source_rgba(0.0, 1.0, 0.0, 1.0);
+ cr.fill();
+ }
+
+ let reference_surf = SharedImageSurface::wrap(reference_surf, SurfaceType::SRgb).unwrap();
+
+ compare_to_surface(
+ &output_surf,
+ &reference_surf,
+ "nonexistent_filter_leaves_object_unfiltered",
+ );
+}
diff --git a/rsvg_internals/src/drawing_ctx.rs b/rsvg_internals/src/drawing_ctx.rs
index d22633372..b98f7c741 100644
--- a/rsvg_internals/src/drawing_ctx.rs
+++ b/rsvg_internals/src/drawing_ctx.rs
@@ -783,7 +783,7 @@ impl DrawingCtx {
}
_ => {
rsvg_log!(
- "element {} will not be rendered since \"{}\" is not a filter",
+ "element {} will not be filtered since \"{}\" is not a filter",
node,
filter_uri,
);
@@ -792,7 +792,7 @@ impl DrawingCtx {
}
_ => {
rsvg_log!(
- "element {} will not be rendered since its filter \"{}\" was not found",
+ "element {} will not be filtered since its filter \"{}\" was not found",
node,
filter_uri,
);
@@ -800,11 +800,7 @@ impl DrawingCtx {
}
// Non-existing filters must act as null filters (an empty surface is returned).
- Ok(SharedImageSurface::empty(
- child_surface.width(),
- child_surface.height(),
- child_surface.surface_type(),
- )?)
+ Ok(child_surface.clone())
}
fn set_color(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]