[librsvg: 5/18] parse_one_presentation_attribute() - renamed from parse_attribute_pair()



commit 92c49be409fbefd36eb1e0ab0ae43957ff31af59
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Dec 6 14:49:48 2019 -0600

    parse_one_presentation_attribute() - renamed from parse_attribute_pair()
    
    Also, remove the accept_shorthands argument from this function, since
    its single caller always passed false (shorthand properties cannot be
    used as presentation attributes).

 rsvg_internals/src/properties.rs | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/rsvg_internals/src/properties.rs b/rsvg_internals/src/properties.rs
index c7764176..1a2f0c57 100644
--- a/rsvg_internals/src/properties.rs
+++ b/rsvg_internals/src/properties.rs
@@ -518,16 +518,18 @@ impl SpecifiedValues {
         }
     }
 
-    fn parse_attribute_pair(
+    fn parse_one_presentation_attribute(
         &mut self,
         attr: QualName,
         value: &str,
-        accept_shorthands: bool,
     ) -> Result<(), NodeError> {
         let mut input = ParserInput::new(value);
         let mut parser = Parser::new(&mut input);
 
-        match parse_property(&attr, &mut parser, accept_shorthands).attribute(attr.clone()) {
+        // Presentation attributes don't accept shorthands, e.g. there is no
+        // attribute like marker="#foo" and it needs to be set in the style attribute
+        // 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),
             Err(e) => {
                 // https://www.w3.org/TR/CSS2/syndata.html#unsupported-values
@@ -557,21 +559,21 @@ impl SpecifiedValues {
             match attr.expanded() {
                 expanded_name!(svg "xml:lang") => {
                     // xml:lang is a non-presentation attribute and as such cannot have the
-                    // "inherit" value.  So, we don't call parse_attribute_pair() for it, but
-                    // rather call its parser directly.
+                    // "inherit" value.  So, we don't call parse_one_presentation_attribute()
+                    // for it, but rather call its parser directly.
                     self.xml_lang =
                         SpecifiedValue::Specified(XmlLang::parse_str(value).attribute(attr)?);
                 }
 
                 expanded_name!(svg "xml:space") => {
                     // xml:space is a non-presentation attribute and as such cannot have the
-                    // "inherit" value.  So, we don't call parse_attribute_pair() for it, but
-                    // rather call its parser directly.
+                    // "inherit" value.  So, we don't call parse_one_presentation_attribute()
+                    // for it, but rather call its parser directly.
                     self.xml_space =
                         SpecifiedValue::Specified(XmlSpace::parse_str(value).attribute(attr)?);
                 }
 
-                _ => self.parse_attribute_pair(attr, value, false)?,
+                _ => self.parse_one_presentation_attribute(attr, value)?,
             }
         }
 


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