[librsvg: 3/27] Just pass the node name to FilterValueList.is_applicable instead of the whole node




commit c89df3a5438c846083196d9e114b4ef3acbe246b
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Mar 4 18:25:09 2021 -0600

    Just pass the node name to FilterValueList.is_applicable instead of the whole node
    
    That's just needed for a log message.

 src/drawing_ctx.rs |  4 +++-
 src/filter.rs      | 12 ++++++++----
 2 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index d591407c..a72e0155 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -887,7 +887,9 @@ impl DrawingCtx {
         let surface = match filters {
             Filter::None => self.cr.get_target(),
             Filter::List(filter_list) => {
-                if filter_list.is_applicable(node, acquired_nodes) {
+                let node_name = format!("{}", node);
+
+                if filter_list.is_applicable(&node_name, acquired_nodes) {
                     // The target surface has multiple references.
                     // We need to copy it to a new surface to have a unique
                     // reference to be able to safely access the pixel data.
diff --git a/src/filter.rs b/src/filter.rs
index 6c2a6c9b..6da09dd0 100644
--- a/src/filter.rs
+++ b/src/filter.rs
@@ -10,7 +10,7 @@ use crate::drawing_ctx::ViewParams;
 use crate::element::{Draw, Element, ElementResult, SetAttributes};
 use crate::error::{ElementError, ValueErrorKind};
 use crate::length::*;
-use crate::node::{Node, NodeBorrow};
+use crate::node::NodeBorrow;
 use crate::parsers::{Parse, ParseValue};
 use crate::properties::ComputedValues;
 use crate::rect::Rect;
@@ -166,7 +166,11 @@ impl FilterValueList {
 
     /// Check that at least one filter URI exists and that all contained
     /// URIs reference existing <filter> elements.
-    pub fn is_applicable(&self, node: &Node, acquired_nodes: &mut AcquiredNodes<'_>) -> bool {
+    ///
+    /// The `node_name` refers to the node being filtered; it is just
+    /// to log an error in case the filter value list is not
+    /// applicable.
+    pub fn is_applicable(&self, node_name: &str, acquired_nodes: &mut AcquiredNodes<'_>) -> bool {
         if self.is_empty() {
             return false;
         }
@@ -184,7 +188,7 @@ impl FilterValueList {
                         _ => {
                             rsvg_log!(
                                 "element {} will not be filtered since \"{}\" is not a filter",
-                                node,
+                                node_name,
                                 v,
                             );
                             false
@@ -194,7 +198,7 @@ impl FilterValueList {
                 _ => {
                     rsvg_log!(
                         "element {} will not be filtered since its filter \"{}\" was not found",
-                        node,
+                        node_name,
                         v,
                     );
                     false


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]