[librsvg: 17/95] Process points/verts of NodePoly with the PHF
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 17/95] Process points/verts of NodePoly with the PHF
- Date: Thu, 22 Feb 2018 03:14:34 +0000 (UTC)
commit e2603a3578357b4ccde04918f00294ba16a714b6
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Feb 12 19:25:07 2018 -0600
Process points/verts of NodePoly with the PHF
rsvg-attributes.h | 2 ++
rust/build.rs | 2 ++
rust/src/shapes.rs | 22 ++++++++++++----------
3 files changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/rsvg-attributes.h b/rsvg-attributes.h
index 4ec73e56..a59ee10d 100644
--- a/rsvg-attributes.h
+++ b/rsvg-attributes.h
@@ -72,6 +72,7 @@ typedef enum {
RSVG_ATTRIBUTE_ORDER,
RSVG_ATTRIBUTE_OVERFLOW,
RSVG_ATTRIBUTE_PARSE,
+ RSVG_ATTRIBUTE_POINTS,
RSVG_ATTRIBUTE_POINTS_AT_X,
RSVG_ATTRIBUTE_POINTS_AT_Y,
RSVG_ATTRIBUTE_POINTS_AT_Z,
@@ -112,6 +113,7 @@ typedef enum {
RSVG_ATTRIBUTE_TYPE,
RSVG_ATTRIBUTE_UNICODE_BIDI,
RSVG_ATTRIBUTE_VALUES,
+ RSVG_ATTRIBUTE_VERTS,
RSVG_ATTRIBUTE_VISIBILITY,
RSVG_ATTRIBUTE_WIDTH,
RSVG_ATTRIBUTE_WRITING_MODE,
diff --git a/rust/build.rs b/rust/build.rs
index 8121bfd2..509932b5 100644
--- a/rust/build.rs
+++ b/rust/build.rs
@@ -79,6 +79,7 @@ fn generate_phf_of_svg_attributes() {
( "order", "Order" ),
( "overflow", "Overflow" ),
( "parse", "Parse" ),
+ ( "points", "Points" ),
( "pointsAtX", "PointsAtX" ),
( "pointsAtY", "PointsAtY" ),
( "pointsAtZ", "PointsAtZ" ),
@@ -119,6 +120,7 @@ fn generate_phf_of_svg_attributes() {
( "type", "Type" ),
( "unicode-bidi", "UnicodeBidi" ),
( "values", "Values" ),
+ ( "verts", "Verts" ),
( "visibility", "Visibility" ),
( "width", "Width" ),
( "writing-mode", "WritingMode" ),
diff --git a/rust/src/shapes.rs b/rust/src/shapes.rs
index 0d27bf6c..90874cd0 100644
--- a/rust/src/shapes.rs
+++ b/rust/src/shapes.rs
@@ -143,19 +143,21 @@ impl NodePoly {
impl NodeTrait for NodePoly {
fn set_atts (&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag) -> NodeResult {
- // support for svg < 1.0 which used verts
+ for (key, value) in pbag.iter() {
+ if let Ok(attr) = Attribute::from_str(key) {
+ // support for svg < 1.0 which used verts
- for name in &["verts", "points"] {
- if let Some (value) = pbag.lookup(name) {
- let result = parsers::list_of_points (value.trim ());
+ if attr == Attribute::Points || attr == Attribute::Verts {
+ let result = parsers::list_of_points (value.trim ());
- match result {
- Ok (v) => {
- *self.points.borrow_mut () = Some (v);
- break;
- },
+ match result {
+ Ok (v) => {
+ *self.points.borrow_mut () = Some (v);
+ break;
+ },
- Err (e) => { return Err (NodeError::parse_error (name, e)); }
+ Err (e) => { return Err (NodeError::parse_error (key, e)); }
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]