[librsvg: 6/18] Don't log non-presentation attributes as unknown properties



commit 9c404a736677a639b5eb5c7579312d3cafac73b4
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Dec 6 15:04:44 2019 -0600

    Don't log non-presentation attributes as unknown properties
    
    For every non-presentation attribute, i.e. the "x/y/width/height" in
    
      <rect x="0" y="0" width="1" height="1" fill="green"/>
    
    we would emit a log message.  This is just noise, so we skip
    UnknownProperty errors when parsing presentation attributes.

 rsvg_internals/src/error.rs      | 4 ++--
 rsvg_internals/src/properties.rs | 9 +++++----
 2 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/rsvg_internals/src/error.rs b/rsvg_internals/src/error.rs
index a27170c9..c414c1e3 100644
--- a/rsvg_internals/src/error.rs
+++ b/rsvg_internals/src/error.rs
@@ -26,8 +26,8 @@ pub enum ValueErrorKind {
 /// A complete error for an attribute and its erroneous value
 #[derive(Debug, Clone, PartialEq)]
 pub struct NodeError {
-    attr: QualName,
-    err: ValueErrorKind,
+    pub attr: QualName,
+    pub err: ValueErrorKind,
 }
 
 impl NodeError {
diff --git a/rsvg_internals/src/properties.rs b/rsvg_internals/src/properties.rs
index 1a2f0c57..e27186a8 100644
--- a/rsvg_internals/src/properties.rs
+++ b/rsvg_internals/src/properties.rs
@@ -531,10 +531,13 @@ impl SpecifiedValues {
         // like style="marker: #foo;".  So, pass false for accept_shorthands here.
         match parse_property(&attr, &mut parser, false).attribute(attr.clone()) {
             Ok(prop) => self.set_parsed_property(&prop),
+
+            // not a presentation attribute
+            Err(NodeError { err: ValueErrorKind::UnknownProperty, .. }) => (),
+
             Err(e) => {
                 // https://www.w3.org/TR/CSS2/syndata.html#unsupported-values
-                // Ignore unsupported / illegal values; don't set the whole
-                // node to be in error in that case.
+                // Ignore illegal values; don't set the whole node to be in error in that case.
 
                 rsvg_log!(
                     "(style property error for attribute {:?}\n    value=\"{}\"\n    {}\n    \
@@ -546,8 +549,6 @@ impl SpecifiedValues {
             }
         }
 
-        // If we didn't ignore property errors, we could just return this:
-        // ParsedProperty::parse().attribute(attr)
         Ok(())
     }
 


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