[librsvg: 26/95] NodeUse: parse attributes with the PHF
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 26/95] NodeUse: parse attributes with the PHF
- Date: Thu, 22 Feb 2018 03:15:19 +0000 (UTC)
commit 92ebc4ff51af1dfd54c7c2447085c6d92f1b45eb
Author: Federico Mena Quintero <federico gnome org>
Date: Fri Feb 16 10:34:51 2018 -0600
NodeUse: parse attributes with the PHF
rust/src/structure.rs | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
---
diff --git a/rust/src/structure.rs b/rust/src/structure.rs
index 85969d79..b92ff700 100644
--- a/rust/src/structure.rs
+++ b/rust/src/structure.rs
@@ -231,16 +231,25 @@ impl NodeUse {
impl NodeTrait for NodeUse {
fn set_atts (&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag) -> NodeResult {
- *self.link.borrow_mut () = pbag.lookup("xlink:href").map(|s| s.to_owned());
+ for (key, value) in pbag.iter() {
+ if let Ok(attr) = Attribute::from_str(key) {
+ match attr {
+ Attribute::XlinkHref => *self.link.borrow_mut() = Some(value.to_owned()),
- self.x.set (property_bag::parse_or_default (pbag, "x", LengthDir::Horizontal, None)?);
- self.y.set (property_bag::parse_or_default (pbag, "y", LengthDir::Vertical, None)?);
+ Attribute::X => self.x.set(parse("x", value, LengthDir::Horizontal, None)?),
+ Attribute::Y => self.y.set(parse("y", value, LengthDir::Vertical, None)?),
- self.w.set (property_bag::parse_or_none (pbag, "width", LengthDir::Horizontal,
- Some(RsvgLength::check_nonnegative))?);
+ Attribute::Width => self.w.set(parse("width", value, LengthDir::Horizontal,
+ Some(RsvgLength::check_nonnegative))
+ .map(Some)?),
+ Attribute::Height => self.h.set(parse("height", value, LengthDir::Vertical,
+ Some(RsvgLength::check_nonnegative))
+ .map(Some)?),
- self.h.set (property_bag::parse_or_none (pbag, "height", LengthDir::Vertical,
- Some(RsvgLength::check_nonnegative))?);
+ _ => (),
+ }
+ }
+ }
Ok (())
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]