[librsvg: 12/19] Fix the translate transform cases that I had missed
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 12/19] Fix the translate transform cases that I had missed
- Date: Mon, 22 Jan 2018 19:28:57 +0000 (UTC)
commit 4c27a5f537b8bfcaeefaffb6dd08cf1647e05ede
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Jan 22 12:28:12 2018 -0600
Fix the translate transform cases that I had missed
rust/src/transform.rs | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/rust/src/transform.rs b/rust/src/transform.rs
index 57518a9..3db0670 100644
--- a/rust/src/transform.rs
+++ b/rust/src/transform.rs
@@ -104,9 +104,10 @@ fn parse_translate_args(parser: &mut Parser) -> Result<cairo::Matrix, AttributeE
parser.parse_nested_block(|p| {
let tx = p.expect_number()?;
- optional_comma(p);
-
- let ty = p.expect_number()?;
+ let ty = p.try(|p| -> Result<f32, CssParseError<()>> {
+ optional_comma(p);
+ Ok(p.expect_number()?)
+ }).unwrap_or(0.0);
Ok(cairo::Matrix::new(1.0, 0.0, 0.0, 1.0, tx as f64, ty as f64))
}).map_err(CssParseError::<()>::basic)
@@ -297,11 +298,11 @@ mod parser_tests {
assert_eq! (parse_transform ("translate(-1 -2)").unwrap (),
cairo::Matrix::new (1.0, 0.0, 0.0, 1.0, -1.0, -2.0));
- // assert_eq! (parse_transform ("translate(-1, -2)").unwrap (),
- // cairo::Matrix::new (1.0, 0.0, 0.0, 1.0, -1.0, -2.0));
+ assert_eq! (parse_transform ("translate(-1, -2)").unwrap (),
+ cairo::Matrix::new (1.0, 0.0, 0.0, 1.0, -1.0, -2.0));
- // assert_eq! (parse_transform ("translate(-1)").unwrap (),
- // cairo::Matrix::new (1.0, 0.0, 0.0, 1.0, -1.0, 0.0));
+ assert_eq! (parse_transform ("translate(-1)").unwrap (),
+ cairo::Matrix::new (1.0, 0.0, 0.0, 1.0, -1.0, 0.0));
}
#[test]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]