[librsvg: 12/17] set_style_pair_from_parsed_property() - rename to set_property_from_declaration()



commit 2542ace342e98f09682166002f2506cce087444b
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu May 2 19:10:19 2019 -0500

    set_style_pair_from_parsed_property() - rename to set_property_from_declaration()
    
    This takes a Declaration now, making it the primary way of
    transferring parsed style properties around.

 rsvg_internals/src/css.rs        |  7 +------
 rsvg_internals/src/properties.rs | 32 ++++++++++++++++----------------
 2 files changed, 17 insertions(+), 22 deletions(-)
---
diff --git a/rsvg_internals/src/css.rs b/rsvg_internals/src/css.rs
index aa461f18..51862162 100644
--- a/rsvg_internals/src/css.rs
+++ b/rsvg_internals/src/css.rs
@@ -132,12 +132,7 @@ impl CssRules {
     ) -> bool {
         if let Some(decl_list) = self.selectors_to_declarations.get(selector) {
             for (_, declaration) in decl_list.iter() {
-                values.set_style_pair_from_parsed_property(
-                    declaration.attribute,
-                    &declaration.property,
-                    declaration.important,
-                    important_styles,
-                );
+                values.set_property_from_declaration(declaration, important_styles);
             }
 
             true
diff --git a/rsvg_internals/src/properties.rs b/rsvg_internals/src/properties.rs
index 2d175de2..28e96a57 100644
--- a/rsvg_internals/src/properties.rs
+++ b/rsvg_internals/src/properties.rs
@@ -600,22 +600,20 @@ impl SpecifiedValues {
         Ok(())
     }
 
-    pub fn set_style_pair_from_parsed_property(
+    pub fn set_property_from_declaration(
         &mut self,
-        attr: Attribute,
-        prop: &ParsedProperty,
-        important: bool,
+        declaration: &Declaration,
         important_styles: &mut HashSet<Attribute>,
     ) {
-        if !important && important_styles.contains(&attr) {
+        if !declaration.important && important_styles.contains(&declaration.attribute) {
             return;
         }
 
-        if important {
-            important_styles.insert(attr);
+        if declaration.important {
+            important_styles.insert(declaration.attribute);
         }
 
-        self.set_parsed_property(prop);
+        self.set_parsed_property(&declaration.property);
     }
 
     pub fn parse_style_declarations(
@@ -652,17 +650,19 @@ impl SpecifiedValues {
                         &value
                     };
 
-                    if let Ok(attr) = Attribute::from_str(prop_name) {
-                        if let Ok(Some(prop)) =
-                            parse_attribute_value_into_parsed_property(attr, value, true)
+                    if let Ok(attribute) = Attribute::from_str(prop_name) {
+                        if let Ok(Some(property)) =
+                            parse_attribute_value_into_parsed_property(attribute, value, true)
                         {
-                            self.set_style_pair_from_parsed_property(
-                                attr,
-                                &prop,
+                            let declaration = Declaration {
+                                attribute,
+                                property,
                                 important,
-                                important_styles,
-                            );
+                            };
+                            
+                            self.set_property_from_declaration(&declaration, important_styles);
                         }
+                        // else unknown property name or invalid value; ignore
                     }
                     // else unknown property name; ignore
                 }


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