[librsvg: 23/95] NodeEllipse: parse attibutes with the PHF



commit 79cef1df7ac7194456e145144829036971acf8df
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Feb 16 09:25:20 2018 -0600

    NodeEllipse: parse attibutes with the PHF

 rust/src/shapes.rs | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/rust/src/shapes.rs b/rust/src/shapes.rs
index a91b01aa..4a001b54 100644
--- a/rust/src/shapes.rs
+++ b/rust/src/shapes.rs
@@ -15,7 +15,7 @@ use node::*;
 use parsers::{self, parse};
 use path_builder::*;
 use path_parser;
-use property_bag::{self, PropertyBag};
+use property_bag::PropertyBag;
 use state::RsvgState;
 
 fn render_path_builder (builder:  &RsvgPathBuilder,
@@ -516,14 +516,21 @@ impl NodeEllipse {
 
 impl NodeTrait for NodeEllipse {
     fn set_atts (&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag) -> NodeResult {
-        self.cx.set (property_bag::parse_or_default (pbag, "cx", LengthDir::Horizontal, None)?);
-        self.cy.set (property_bag::parse_or_default (pbag, "cy", LengthDir::Vertical, None)?);
+        for (key, value) in pbag.iter() {
+            if let Ok(attr) = Attribute::from_str(key) {
+                match attr {
+                    Attribute::Cx => self.cx.set(parse("cx", value, LengthDir::Horizontal, None)?),
+                    Attribute::Cy => self.cy.set(parse("cy", value, LengthDir::Vertical, None)?),
 
-        self.rx.set (property_bag::parse_or_default (pbag, "rx", LengthDir::Horizontal,
-                                                     Some(RsvgLength::check_nonnegative))?);
+                    Attribute::Rx => self.rx.set(parse("rx", value, LengthDir::Horizontal,
+                                                       Some(RsvgLength::check_nonnegative))?),
+                    Attribute::Ry => self.ry.set(parse("ry", value, LengthDir::Vertical,
+                                                       Some(RsvgLength::check_nonnegative))?),
 
-        self.ry.set (property_bag::parse_or_default (pbag, "ry", LengthDir::Vertical,
-                                                     Some(RsvgLength::check_nonnegative))?);
+                    _ => (),
+                }
+            }
+        }
 
         Ok (())
     }


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