diff options
author | Ivan Molodetskikh <yalterz@gmail.com> | 2018-06-13 11:06:44 +0300 |
---|---|---|
committer | Ivan Molodetskikh <yalterz@gmail.com> | 2018-06-13 11:06:44 +0300 |
commit | 62de56f91a43bad1f8e79169709aae373b294f72 (patch) | |
tree | 963aa6276e219bafc1ae37cb9e53c4aebeb2b56b | |
parent | affd9d5966a33b7dd71ea649a1fd8cf68c2cd21d (diff) | |
download | librsvg-62de56f91a43bad1f8e79169709aae373b294f72.tar.gz |
Use correct CSS values in compute_effects_region()
-rw-r--r-- | rsvg_internals/src/filters/context.rs | 7 | ||||
-rw-r--r-- | tests/fixtures/reftests/test-filter-effects-region-ref.png | bin | 1598 -> 1624 bytes | |||
-rw-r--r-- | tests/fixtures/reftests/test-filter-effects-region.svg | 14 |
3 files changed, 18 insertions, 3 deletions
diff --git a/rsvg_internals/src/filters/context.rs b/rsvg_internals/src/filters/context.rs index ef6eaf1e..f7335fc1 100644 --- a/rsvg_internals/src/filters/context.rs +++ b/rsvg_internals/src/filters/context.rs @@ -142,14 +142,14 @@ fn extract_alpha( /// Computes and returns the filter effects region. fn compute_effects_region( filter_node: &RsvgNode, + target_node: &RsvgNode, drawing_ctx: *mut RsvgDrawingCtx, affine: cairo::Matrix, width: f64, height: f64, ) -> BoundingBox { - // TODO: shouldn't the values be from the target node rather than from the filter node - // itself? - let cascaded = filter_node.get_cascaded_values(); + // Filters use the properties of the target node. + let cascaded = target_node.get_cascaded_values(); let values = cascaded.get(); let filter = filter_node.get_impl::<NodeFilter>().unwrap(); @@ -282,6 +282,7 @@ impl FilterContext { drawing_ctx: draw_ctx, effects_region: compute_effects_region( filter_node, + node_being_filtered, draw_ctx, affine, f64::from(width), diff --git a/tests/fixtures/reftests/test-filter-effects-region-ref.png b/tests/fixtures/reftests/test-filter-effects-region-ref.png Binary files differindex ee12536f..9193d442 100644 --- a/tests/fixtures/reftests/test-filter-effects-region-ref.png +++ b/tests/fixtures/reftests/test-filter-effects-region-ref.png diff --git a/tests/fixtures/reftests/test-filter-effects-region.svg b/tests/fixtures/reftests/test-filter-effects-region.svg index 480a4d28..6e11828e 100644 --- a/tests/fixtures/reftests/test-filter-effects-region.svg +++ b/tests/fixtures/reftests/test-filter-effects-region.svg @@ -20,6 +20,14 @@ <feFlood flood-color="green"/> </filter> + <!-- According to the spec, the "em" here should use the coordinate system + of the referencing node. Firefox follows this. Chromium uses the filter node's + coordinate system instead. --> + <filter id="cascading" filterUnits="userSpaceOnUse" style="font-size: 30pt" + x="1em" y="1em" width="50" height="50"> + <feFlood flood-color="green"/> + </filter> + <g transform="translate(30 20)"> <rect fill="red" x="1" y="1" width="50" height="50"/> <rect fill="red" x="1" y="1" width="50" height="50" filter="url(#defaults)"/> @@ -32,6 +40,12 @@ <rect fill="red" x="1" y="100" width="50" height="50"/> </g> + <g transform="translate(170 20)" style="font-size: 7pt"> + <rect fill="red" x="1" y="1" width="50" height="50"/> + <rect fill="red" x="1" y="1" width="50" height="50" filter="url(#cascading)"/> + <rect fill="red" x="1" y="100" width="50" height="50"/> + </g> + <g transform="translate(300 20)"> <rect fill="red" x="1" y="1" width="50" height="50"/> <rect fill="red" x="1" y="1" width="50" height="50" filter="url(#usou-defaults)"/> |