diff --git a/Cargo.toml b/Cargo.toml
index 4b98ce6..a9e0970 100644
@@ -11,9 +11,9 @@ readme = "README.md"
[dependencies]
# latest
-svgdom = { git = "https://github.com/RazrFalcon/libsvgdom.git" }
+# svgdom = { git = "https://github.com/RazrFalcon/libsvgdom.git" }
# local copy
-# svgdom = { path = "../svgdom" }
+svgdom = { path = "../svgdom" }
# from crates
# svgdom = "0.2.0"
diff --git a/src/cli.rs b/src/cli.rs
index 1b1a31e..3ca2766 100644
@@ -66,6 +66,7 @@ pub enum Key {
PathsToRelative,
RemoveUnusedSegments,
ConvertSegments,
+ ApplyTransformToPaths,
TrimPaths,
JoinArcToFlags,
RemoveDuplCmdInPaths,
@@ -130,6 +131,7 @@ pub static KEYS: &'static KeysData<'static> = &KeysData(&[
"paths-to-relative",
"remove-unused-segments",
"convert-segments",
+ "apply-transform-to-paths",
"trim-paths",
"join-arcto-flags",
"remove-dupl-cmd-in-paths",
@@ -214,6 +216,7 @@ pub fn prepare_app<'a, 'b>() -> App<'a, 'b> {
.arg(gen_flag!(Key::PathsToRelative, "true"))
.arg(gen_flag!(Key::RemoveUnusedSegments, "true"))
.arg(gen_flag!(Key::ConvertSegments, "true"))
+ .arg(gen_flag!(Key::ApplyTransformToPaths, "true"))
.arg(gen_flag!(Key::TrimPaths, "true"))
.arg(gen_flag!(Key::JoinArcToFlags, "false"))
.arg(gen_flag!(Key::RemoveDuplCmdInPaths, "true"))
@@ -308,6 +311,10 @@ pub fn check_values(args: &ArgMatches) -> bool {
return false;
}
+ // if !check_value(args, Key::PathsToRelative, Key::ApplyTransformToPaths) {
+ // return false;
+ // }
+
true
}
diff --git a/src/task/apply_transforms/gradients.rs b/src/task/apply_transforms/gradients.rs
index 0222c4c..ff496a9 100644
@@ -20,10 +20,10 @@
**
****************************************************************************/
-use task::short::{EId, AId, Unit};
+use task::short::{EId, AId};
+use super::utils;
-use svgdom::{Document, Node};
-use svgdom::types::{Length};
+use svgdom::Document;
pub fn apply_transform_to_gradients(doc: &Document) {
let iter = doc.descendants().svg()
@@ -58,73 +58,26 @@ pub fn apply_transform_to_gradients(doc: &Document) {
let ts = *node.attribute_value(AId::GradientTransform).unwrap().as_transform().unwrap();
- // If transform has non-proportional scale - we should skip it,
- // because it can be applied only to a raster.
- if ts.has_scale() && !ts.has_proportional_scale() {
+ if !utils::is_valid_transform(&ts) {
continue;
}
- // If transform has skew part - we should skip it,
- // because it can be applied only to a raster.
- if ts.has_skew() {
+ if !utils::is_valid_coords(&node) {
continue;
}
if node.is_tag_name(EId::LinearGradient) {
- let x1 = get_coord(&node, AId::X1);
- let y1 = get_coord(&node, AId::Y1);
-
- let x2 = get_coord(&node, AId::X2);
- let y2 = get_coord(&node, AId::Y2);
-
- // We can apply transform only to coordinates with px/none units.
- if x1.unit != Unit::None || y1.unit != Unit::None
- || x2.unit != Unit::None || y2.unit != Unit::None {
- continue;
- }
-
- {
- let (x, y) = ts.apply(x1.num, y1.num);
- node.set_attribute(AId::X1, (x, Unit::None));
- node.set_attribute(AId::Y1, (y, Unit::None));
- }
-
- {
- let (x, y) = ts.apply(x2.num, y2.num);
- node.set_attribute(AId::X2, (x, Unit::None));
- node.set_attribute(AId::Y2, (y, Unit::None));
- }
+ let mut attrs = node.attributes_mut();
+ utils::scale_pos_coord(&mut attrs, AId::X1, AId::Y1, &ts);
+ utils::scale_pos_coord(&mut attrs, AId::X2, AId::Y2, &ts);
} else {
- let cx = get_coord(&node, AId::Cx);
- let cy = get_coord(&node, AId::Cy);
-
- let fx = get_coord(&node, AId::Fx);
- let fy = get_coord(&node, AId::Fy);
-
- let r = get_coord(&node, AId::R);
+ let mut attrs = node.attributes_mut();
+ utils::scale_pos_coord(&mut attrs, AId::Cx, AId::Cy, &ts);
+ utils::scale_pos_coord(&mut attrs, AId::Fx, AId::Fy, &ts);
- // We can apply transform only to coordinates with px/none units.
- if cx.unit != Unit::None || cy.unit != Unit::None
- || fx.unit != Unit::None || fy.unit != Unit::None
- || r.unit != Unit::None {
- continue;
- }
-
- {
- let (x, y) = ts.apply(cx.num, cy.num);
- node.set_attribute(AId::Cx, (x, Unit::None));
- node.set_attribute(AId::Cy, (y, Unit::None));
- }
-
- {
- let (x, y) = ts.apply(fx.num, fy.num);
- node.set_attribute(AId::Fx, (x, Unit::None));
- node.set_attribute(AId::Fy, (y, Unit::None));
- }
-
- {
+ if ts.has_scale() {
let (sx, _) = ts.get_scale();
- node.set_attribute(AId::R, (r.num * sx, Unit::None));
+ utils::scale_coord(&mut attrs, AId::R, &sx);
}
}
@@ -132,10 +85,6 @@ pub fn apply_transform_to_gradients(doc: &Document) {
}
}
-fn get_coord(node: &Node, aid: AId) -> Length {
- *node.attribute_value(aid).unwrap().as_length().unwrap()
-}
-
#[cfg(test)]
mod tests {
use super::*;
diff --git a/src/task/apply_transforms/mod.rs b/src/task/apply_transforms/mod.rs
index 6a9d8dd..b157623 100644
@@ -25,3 +25,119 @@ pub use self::shapes::apply_transform_to_shapes;
mod gradients;
mod shapes;
+
+pub mod utils {
+ use task::short::{EId, AId, Unit};
+
+ use svgdom::{Node, Attributes, AttributeValue};
+ use svgdom::types::{Length, Transform};
+
+ // TODO: remove
+ pub fn has_valid_transform(node: &Node) -> bool {
+ if !node.has_attribute(AId::Transform) {
+ return true;
+ }
+
+ let ts = get_ts(node);
+ is_valid_transform(&ts)
+ }
+
+ pub fn is_valid_transform(ts: &Transform) -> bool {
+ // If transform has non-proportional scale - we should skip it,
+ // because it can be applied only to a raster.
+ if ts.has_scale() && !ts.has_proportional_scale() {
+ return false;
+ }
+
+ // TODO: is rotate supported?
+
+ // If transform has skew part - we should skip it,
+ // because it can be applied only to a raster.
+ if ts.has_skew() {
+ return false;
+ }
+
+ return true;
+ }
+
+ // Element shouldn't have any linked elements, because they also must be transformed.
+ // TODO: process 'fill', 'stroke' and 'filter' linked elements only if they
+ // used only by this element.
+ pub fn is_valid_attrs(node: &Node) -> bool {
+ let attrs = node.attributes();
+
+ if let Some(&AttributeValue::FuncLink(_)) = attrs.get_value(AId::Fill) {
+ return false;
+ }
+
+ if let Some(&AttributeValue::FuncLink(_)) = attrs.get_value(AId::Stroke) {
+ return false;
+ }
+
+ if let Some(&AttributeValue::FuncLink(_)) = attrs.get_value(AId::Filter) {
+ return false;
+ }
+
+ if attrs.contains(AId::Mask) || attrs.contains(AId::ClipPath) {
+ return false;
+ }
+
+ return true;
+ }
+
+ // We can process only coordinates without units.
+ pub fn is_valid_coords(node: &Node) -> bool {
+ match node.tag_id().unwrap() {
+ EId::Rect => _is_valid_coords(node, &[AId::X, AId::Y]),
+ EId::Circle => _is_valid_coords(node, &[AId::Cx, AId::Cy]),
+ EId::Ellipse => _is_valid_coords(node, &[AId::Cx, AId::Cy]),
+ EId::Line => _is_valid_coords(node, &[AId::X1, AId::Y1, AId::X2, AId::Y2]),
+ EId::LinearGradient => _is_valid_coords(node, &[AId::X1, AId::Y1, AId::X2, AId::Y2]),
+ EId::RadialGradient => _is_valid_coords(node, &[AId::Cx, AId::Cy, AId::Fx, AId::Fy, AId::R]),
+ _ => false,
+ }
+ }
+
+ fn _is_valid_coords(node: &Node, attr_ids: &[AId]) -> bool {
+ let attrs = node.attributes();
+
+ fn is_valid_coord(attrs: &Attributes, aid: AId) -> bool {
+ if let Some(&AttributeValue::Length(v)) = attrs.get_value(aid) {
+ v.unit == Unit::None
+ } else {
+ true
+ }
+ }
+
+ for id in attr_ids {
+ if !is_valid_coord(&attrs, *id) {
+ return false;
+ }
+ }
+
+ true
+ }
+
+ // TODO: rename to transform_coords
+ pub fn scale_pos_coord(attrs: &mut Attributes, aid_x: AId, aid_y: AId, ts: &Transform) {
+ let x = get_value!(attrs, Length, aid_x, Length::zero());
+ let y = get_value!(attrs, Length, aid_y, Length::zero());
+
+ debug_assert!(x.unit == Unit::None);
+ debug_assert!(y.unit == Unit::None);
+
+ let (nx, ny) = ts.apply(x.num, y.num);
+ attrs.insert_from(aid_x, (nx, Unit::None));
+ attrs.insert_from(aid_y, (ny, Unit::None));
+ }
+
+ pub fn scale_coord(attrs: &mut Attributes, aid: AId, scale_factor: &f64) {
+ if let Some(&mut AttributeValue::Length(ref mut len)) = attrs.get_value_mut(aid) {
+ len.num *= *scale_factor;
+ }
+ }
+
+ pub fn get_ts(node: &Node) -> Transform {
+ *node.attribute_value(AId::Transform).unwrap().as_transform().unwrap()
+ }
+}
diff --git a/src/task/apply_transforms/shapes.rs b/src/task/apply_transforms/shapes.rs
index 0fc5219..43fcc72 100644
@@ -20,10 +20,11 @@
**
****************************************************************************/
-use task::short::{EId, AId, Unit};
+use task::short::{EId, AId};
+use super::utils;
-use svgdom::{Document, Node, Attributes, AttributeValue};
-use svgdom::types::{Length, Transform};
+use svgdom::{Document, Node, Attributes};
+use svgdom::types::{Transform};
pub fn apply_transform_to_shapes(doc: &Document) {
// If group has transform and contains only valid shapes
@@ -35,7 +36,7 @@ pub fn apply_transform_to_shapes(doc: &Document) {
&& n.has_attribute(AId::Transform));
for node in iter {
- if !is_valid_transform(&node) || !is_valid_attrs(&node) {
+ if !utils::has_valid_transform(&node) || !utils::is_valid_attrs(&node) {
continue;
}
@@ -49,16 +50,19 @@ pub fn apply_transform_to_shapes(doc: &Document) {
_ => false,
};
- flag && is_valid_transform(&n) && is_valid_attrs(&n) && is_valid_coords(&n)
+ flag
+ && utils::has_valid_transform(&n)
+ && utils::is_valid_attrs(&n)
+ && utils::is_valid_coords(&n)
}) {
- let ts = get_ts(&node);
+ let ts = utils::get_ts(&node);
// apply group's transform to children
for child in node.children().svg() {
if child.has_attribute(AId::Transform) {
// we should multiply transform matrices
let mut ts1 = ts.clone();
- let ts2 = get_ts(&child);
+ let ts2 = utils::get_ts(&child);
ts1.append(&ts2);
child.set_attribute(AId::Transform, ts1);
} else {
@@ -89,11 +93,13 @@ pub fn apply_transform_to_shapes(doc: &Document) {
fn process<F>(node: &Node, func: F)
where F : Fn(&mut Attributes, &Transform)
{
- if !is_valid_transform(node) || !is_valid_attrs(node) || !is_valid_coords(node) {
+ if !utils::has_valid_transform(node)
+ || !utils::is_valid_attrs(node)
+ || !utils::is_valid_coords(node) {
return;
}
- let ts = get_ts(node);
+ let ts = utils::get_ts(node);
{
let mut attrs = node.attributes_mut();
@@ -110,150 +116,50 @@ fn process<F>(node: &Node, func: F)
fn process_rect(node: &Node) {
process(node, |mut attrs, ts| {
- scale_pos_coord(&mut attrs, AId::X, AId::Y, &ts);
+ utils::scale_pos_coord(&mut attrs, AId::X, AId::Y, &ts);
if ts.has_scale() {
let (sx, _) = ts.get_scale();
- scale_coord(&mut attrs, AId::Width, &sx);
- scale_coord(&mut attrs, AId::Height, &sx);
+ utils::scale_coord(&mut attrs, AId::Width, &sx);
+ utils::scale_coord(&mut attrs, AId::Height, &sx);
- scale_coord(&mut attrs, AId::Rx, &sx);
- scale_coord(&mut attrs, AId::Ry, &sx);
+ utils::scale_coord(&mut attrs, AId::Rx, &sx);
+ utils::scale_coord(&mut attrs, AId::Ry, &sx);
}
});
}
fn process_circle(node: &Node) {
process(node, |mut attrs, ts| {
- scale_pos_coord(&mut attrs, AId::Cx, AId::Cy, &ts);
+ utils::scale_pos_coord(&mut attrs, AId::Cx, AId::Cy, &ts);
if ts.has_scale() {
let (sx, _) = ts.get_scale();
- scale_coord(&mut attrs, AId::R, &sx);
+ utils::scale_coord(&mut attrs, AId::R, &sx);
}
});
}
fn process_ellipse(node: &Node) {
process(node, |mut attrs, ts| {
- scale_pos_coord(&mut attrs, AId::Cx, AId::Cy, &ts);
+ utils::scale_pos_coord(&mut attrs, AId::Cx, AId::Cy, &ts);
if ts.has_scale() {
let (sx, _) = ts.get_scale();
- scale_coord(&mut attrs, AId::Rx, &sx);
- scale_coord(&mut attrs, AId::Ry, &sx);
+ utils::scale_coord(&mut attrs, AId::Rx, &sx);
+ utils::scale_coord(&mut attrs, AId::Ry, &sx);
}
});
}
fn process_line(node: &Node) {
process(node, |mut attrs, ts| {
- scale_pos_coord(&mut attrs, AId::X1, AId::Y1, &ts);
- scale_pos_coord(&mut attrs, AId::X2, AId::Y2, &ts);
+ utils::scale_pos_coord(&mut attrs, AId::X1, AId::Y1, &ts);
+ utils::scale_pos_coord(&mut attrs, AId::X2, AId::Y2, &ts);
});
}
-fn is_valid_transform(node: &Node) -> bool {
- if !node.has_attribute(AId::Transform) {
- return true;
- }
-
- let ts = get_ts(node);
-
- // If transform has non-proportional scale - we should skip it,
- // because it can be applied only to a raster.
- if ts.has_scale() && !ts.has_proportional_scale() {
- return false;
- }
-
- // If transform has skew part - we should skip it,
- // because it can be applied only to a raster.
- if ts.has_skew() {
- return false;
- }
-
- return true;
-}
-
-// Element shouldn't have any linked elements, because they also must be transformed.
-// TODO: process 'fill', 'stroke' and 'filter' linked elements only if they
-// used only by this element.
-fn is_valid_attrs(node: &Node) -> bool {
- let attrs = node.attributes();
-
- if let Some(&AttributeValue::FuncLink(_)) = attrs.get_value(AId::Fill) {
- return false;
- }
-
- if let Some(&AttributeValue::FuncLink(_)) = attrs.get_value(AId::Stroke) {
- return false;
- }
-
- if let Some(&AttributeValue::FuncLink(_)) = attrs.get_value(AId::Filter) {
- return false;
- }
-
- if attrs.contains(AId::Mask) || attrs.contains(AId::ClipPath) {
- return false;
- }
-
- return true;
-}
-
-// We can process only coordinates without units.
-fn is_valid_coords(node: &Node) -> bool {
- match node.tag_id().unwrap() {
- EId::Rect => _is_valid_coords(node, &[AId::X, AId::Y]),
- EId::Circle => _is_valid_coords(node, &[AId::Cx, AId::Cy]),
- EId::Ellipse => _is_valid_coords(node, &[AId::Cx, AId::Cy]),
- EId::Line => _is_valid_coords(node, &[AId::X1, AId::Y1, AId::X2, AId::Y2]),
- _ => false,
- }
-}
-
-fn _is_valid_coords(node: &Node, attr_ids: &[AId]) -> bool {
- let attrs = node.attributes();
-
- fn is_valid_coord(attrs: &Attributes, aid: AId) -> bool {
- if let Some(&AttributeValue::Length(v)) = attrs.get_value(aid) {
- v.unit == Unit::None
- } else {
- true
- }
- }
-
- for id in attr_ids {
- if !is_valid_coord(&attrs, *id) {
- return false;
- }
- }
-
- true
-}
-
-fn scale_pos_coord(attrs: &mut Attributes, aid_x: AId, aid_y: AId, ts: &Transform) {
- let x = get_value!(attrs, Length, aid_x, Length::zero());
- let y = get_value!(attrs, Length, aid_y, Length::zero());
-
- debug_assert!(x.unit == Unit::None);
- debug_assert!(y.unit == Unit::None);
-
- let (nx, ny) = ts.apply(x.num, y.num);
- attrs.insert_from(aid_x, (nx, Unit::None));
- attrs.insert_from(aid_y, (ny, Unit::None));
-}
-
-fn scale_coord(attrs: &mut Attributes, aid: AId, scale_factor: &f64) {
- if let Some(&mut AttributeValue::Length(ref mut len)) = attrs.get_value_mut(aid) {
- len.num *= *scale_factor;
- }
-}
-
-fn get_ts(node: &Node) -> Transform {
- *node.attribute_value(AId::Transform).unwrap().as_transform().unwrap()
-}
-
#[cfg(test)]
mod tests {
use super::*;
diff --git a/src/task/paths/apply_transform.rs b/src/task/paths/apply_transform.rs
index 630792d..384be01 100644
@@ -20,17 +20,80 @@
**
****************************************************************************/
-// use std::cmp::Ordering;
-// use svgdom::types::path::{Path, Segment, SegmentData};
-// use svgdom::types::{FuzzyEq, FuzzyOrd};
+use svgdom::types::path::{Path, SegmentData};
+use svgdom::types::{Transform};
-// use super::utils;
+pub fn apply_transform(path: &mut Path, ts: &Transform) {
+ println!("transform path");
-pub fn apply_transform(path: &mut Path) {
+ let (sx, _) = ts.get_scale();
+ for seg in path.d.iter_mut() {
+ match *seg.data_mut() {
+ SegmentData::MoveTo { ref mut x, ref mut y }
+ | SegmentData::LineTo { ref mut x, ref mut y }
+ | SegmentData::SmoothQuadratic { ref mut x, ref mut y } => {
+ ts.apply_ref(x, y);
+ }
+
+ SegmentData::HorizontalLineTo { ref mut x } => {
+ ts.apply_ref(x, &mut 0.0);
+ }
+
+ SegmentData::VerticalLineTo { ref mut y } => {
+ ts.apply_ref(&mut 0.0, y);
+ }
+
+ SegmentData::CurveTo { ref mut x1, ref mut y1, ref mut x2, ref mut y2, ref mut x, ref mut y } => {
+ ts.apply_ref(x1, y1);
+ ts.apply_ref(x2, y2);
+ ts.apply_ref(x, y);
+ }
+
+ SegmentData::SmoothCurveTo { ref mut x2, ref mut y2, ref mut x, ref mut y } => {
+ ts.apply_ref(x2, y2);
+ ts.apply_ref(x, y);
+ }
+
+ SegmentData::Quadratic { ref mut x1, ref mut y1, ref mut x, ref mut y } => {
+ ts.apply_ref(x1, y1);
+ ts.apply_ref(x, y);
+ }
+
+ SegmentData::EllipticalArc { ref mut rx, ref mut ry, ref mut x, ref mut y, .. } => {
+ *rx *= sx;
+ *ry *= sx;
+
+ ts.apply_ref(x, y);
+ }
+
+ SegmentData::ClosePath => {}
+ }
+ }
}
#[cfg(test)]
mod tests {
use super::*;
+ use svgdom::FromStream;
+ use svgdom::types::path::Path;
+ use svgdom::types::Transform;
+
+ macro_rules! test {
+ ($name:ident, $in_path:expr, $in_ts:expr, $out_text:expr) => (
+ #[test]
+ fn $name() {
+ let mut path = Path::from_data($in_path).unwrap();
+ path.conv_to_absolute();
+
+ let ts = Transform::from_data($in_ts).unwrap();
+
+ apply_transform(&mut path, &ts);
+ assert_eq_text!(path.to_string(), $out_text);
+ }
+ )
+ }
+
+ test!(apply_1, b"M 10 20 L 30 40", b"translate(10 20)",
+ "M 20 40 L 40 60");
}
diff --git a/src/task/paths/mod.rs b/src/task/paths/mod.rs
index e1a55db..baef1f3 100644
@@ -24,11 +24,14 @@ use clap::ArgMatches;
use svgdom::{Document, AttributeValue};
use svgdom::types::path::Path;
+use svgdom::types::{Transform};
use task::short::{EId, AId};
+use task::apply_transforms::utils as ts_utils;
use cli;
use cli::{Key};
+mod apply_transform;
mod conv_segments;
mod rm_unused;
@@ -40,14 +43,37 @@ pub fn process_paths(doc: &Document, args: &ArgMatches) {
let has_marker = node.has_attributes(&[AId::Marker, AId::MarkerStart,
AId::MarkerMid, AId::MarkerEnd]);
+
+ let mut ts = None;
+ // if cli::get_flag(args, Key::ApplyTransformToPaths) {
+ // if node.has_attribute(AId::Transform) {
+ // let tsl = ts_utils::get_ts(&node);
+
+ // if ts_utils::is_valid_transform(&tsl)
+ // && ts_utils::is_valid_attrs(&node) {
+ // ts = Some(tsl);
+
+ // println!("{:?}", node);
+
+ // node.remove_attribute(AId::Transform);
+
+ // if tsl.has_scale() {
+ // // we must update 'stroke-width' if transform had scale part in it
+ // let (sx, _) = tsl.get_scale();
+ // ::task::utils::recalc_stroke_width(&node, sx);
+ // }
+ // }
+ // }
+ // }
+
let mut attrs = node.attributes_mut();
if let Some(&mut AttributeValue::Path(ref mut path)) = attrs.get_value_mut(AId::D) {
- process_path(path, has_marker, args);
+ process_path(path, has_marker, ts, args);
}
}
}
-fn process_path(path: &mut Path, has_marker: bool, args: &ArgMatches) {
+fn process_path(path: &mut Path, has_marker: bool, ts: Option<Transform>, args: &ArgMatches) {
path.conv_to_absolute();
if cli::get_flag(args, Key::ConvertSegments) {
@@ -58,6 +84,10 @@ fn process_path(path: &mut Path, has_marker: bool, args: &ArgMatches) {
rm_unused::remove_unused_segments(path);
}
+ // if let Some(ref ts) = ts {
+ // apply_transform::apply_transform(path, ts);
+ // }
+
path.conv_to_relative();
// TODO: estimate path length
@@ -73,6 +103,7 @@ fn process_path(path: &mut Path, has_marker: bool, args: &ArgMatches) {
mod utils {
use svgdom::types::path::{Path};
+ // TODO: replace with macro
pub fn resolve_x(path: &Path, start: usize) -> f64 {
// VerticalLineTo does not have `x` coordinate, so we have to find it in previous segments
let mut i = start;
diff --git a/src/task/resolve_use.rs b/src/task/resolve_use.rs
index a158294..f8bd26b 100644
@@ -78,9 +78,10 @@ pub fn resolve_use(doc: &Document) {
continue;
}
- let ts = get_value!(attrs, Transform, AId::Transform, Transform::default());
+ let mut ts = get_value!(attrs, Transform, AId::Transform, Transform::default());
+ ts.translate(x.num, y.num);
- attrs.insert_from(AId::Transform, ts.translate(x.num, y.num));
+ attrs.insert_from(AId::Transform, ts);
attrs.remove(AId::X);
attrs.remove(AId::Y);
}
diff --git a/src/task/rm_elems.rs b/src/task/rm_elems.rs
index e67c6ae..08467ed 100644
@@ -24,6 +24,7 @@ use super::short::EId;
use svgdom::Document;
+// TODO: to mod::utils
pub fn remove_element(doc: &Document, id: EId) {
doc.drain(|n| n.is_tag_name(id));
}
@@ -44,6 +45,8 @@ mod tests {
)
}
+ // TODO: this tests should be in svgdom
+
test!(rm_1, ElementId::Title,
b"<svg>
<title/>
diff --git a/tools/files-testing/data/oxygen.json b/tools/files-testing/data/oxygen.json
index 59fa823..7fc5dfb 100644
@@ -37,18 +37,10 @@
"valid_ae": 1941
},
{
- "name": "actions/small/48x48/view-bank-account.svg",
- "valid_ae": 1661
- },
- {
"name": "actions/small/48x48/view-loan.svg",
"valid_ae": 1925
},
{
- "name": "actions/small/48x48/view-bank-account-checking.svg",
- "valid_ae": 1536
- },
- {
"name": "devices/small/16x16/camera-photo.svg",
"valid_ae": 1379
},
@@ -129,10 +121,6 @@
"valid_ae": 1860
},
{
- "name": "status/user-busy.svg",
- "valid_ae": 1083
- },
- {
"name": "status/user-away-extended.svg",
"valid_ae": 1860
},
@@ -141,14 +129,6 @@
"valid_ae": 1091
},
{
- "name": "status/user-offline.svg",
- "valid_ae": 1083
- },
- {
- "name": "status/user-online.svg",
- "valid_ae": 1221
- },
- {
"name": "categories/applications-toys.svg",
"valid_ae": 1153
},
@@ -189,10 +169,6 @@
"valid_ae": 1336
},
{
- "name": "actions/small/22x22/edit-image-face-recognize.svg",
- "valid_ae": 1162
- },
- {
"name": "actions/small/22x22/edit-image-face-add.svg",
"valid_ae": 1152
},
@@ -544,6 +520,158 @@
{
"name": "mimetypes/small/48x48/image-svg+xml-compressed.svg",
"valid_ae": 170179
+ },
+ {
+ "name": "status/user-busy.svg",
+ "valid_ae": 1345
+ },
+ {
+ "name": "status/user-offline.svg",
+ "valid_ae": 1345
+ },
+ {
+ "name": "status/user-online.svg",
+ "valid_ae": 1483
+ },
+ {
+ "name": "categories/small/22x22/preferences-desktop-personal.svg",
+ "valid_ae": 570
+ },
+ {
+ "name": "actions/small/22x22/edit-image-face-recognize.svg",
+ "valid_ae": 1235
+ },
+ {
+ "name": "actions/small/48x48/view-bank-account.svg",
+ "valid_ae": 1662
+ },
+ {
+ "name": "actions/small/48x48/view-bank-account-checking.svg",
+ "valid_ae": 1537
+ },
+ {
+ "name": "actions/edit-bomb.svg",
+ "valid_ae": 1366
+ },
+ {
+ "name": "devices/secure-card.svg",
+ "valid_ae": 420
+ },
+ {
+ "name": "devices/small/32x32/secure-card.svg",
+ "valid_ae": 677
+ },
+ {
+ "name": "devices/small/48x48/secure-card.svg",
+ "valid_ae": 611
+ },
+ {
+ "name": "emotes/face-uncertain.svg",
+ "valid_ae": 13921
+ },
+ {
+ "name": "emotes/face-surprise.svg",
+ "valid_ae": 13921
+ },
+ {
+ "name": "emotes/face-wink.svg",
+ "valid_ae": 13921
+ },
+ {
+ "name": "emotes/face-smile-big.svg",
+ "valid_ae": 13393
+ },
+ {
+ "name": "emotes/face-sad.svg",
+ "valid_ae": 13921
+ },
+ {
+ "name": "emotes/face-plain.svg",
+ "valid_ae": 13921
+ },
+ {
+ "name": "emotes/small/16x16/face-uncertain.svg",
+ "valid_ae": 13921
+ },
+ {
+ "name": "emotes/small/16x16/face-smile-big.svg",
+ "valid_ae": 13921
+ },
+ {
+ "name": "emotes/small/16x16/face-sad.svg",
+ "valid_ae": 13921
+ },
+ {
+ "name": "emotes/small/16x16/face-kiss.svg",
+ "valid_ae": 13921
+ },
+ {
+ "name": "emotes/small/16x16/face-angel.svg",
+ "valid_ae": 13921
+ },
+ {
+ "name": "emotes/small/16x16/face-raspberry.svg",
+ "valid_ae": 13187
+ },
+ {
+ "name": "emotes/small/16x16/face-laugh.svg",
+ "valid_ae": 13452
+ },
+ {
+ "name": "emotes/small/22x22/face-uncertain.svg",
+ "valid_ae": 13921
+ },
+ {
+ "name": "emotes/small/22x22/face-smile-big.svg",
+ "valid_ae": 13833
+ },
+ {
+ "name": "emotes/small/22x22/face-sad.svg",
+ "valid_ae": 13921
+ },
+ {
+ "name": "emotes/small/22x22/face-kiss.svg",
+ "valid_ae": 13921
+ },
+ {
+ "name": "emotes/small/22x22/face-angel.svg",
+ "valid_ae": 13921
+ },
+ {
+ "name": "emotes/small/22x22/face-raspberry.svg",
+ "valid_ae": 13356
+ },
+ {
+ "name": "emotes/small/22x22/face-laugh.svg",
+ "valid_ae": 13510
+ },
+ {
+ "name": "emotes/face-smile.svg",
+ "valid_ae": 13921
+ },
+ {
+ "name": "emotes/face-kiss.svg",
+ "valid_ae": 13921
+ },
+ {
+ "name": "emotes/face-angel.svg",
+ "valid_ae": 13921
+ },
+ {
+ "name": "emotes/face-embarrassed.svg",
+ "valid_ae": 14450
+ },
+ {
+ "name": "emotes/face-raspberry.svg",
+ "valid_ae": 13921
+ },
+ {
+ "name": "emotes/face-laugh.svg",
+ "valid_ae": 12892
+ },
+ {
+ "name": "mimetypes/small/16x16/text-x-hex.svg",
+ "valid_ae": 901
}
],
"ignore": [
diff --git a/tools/stats/src/main.rs b/tools/stats/src/main.rs
index c8f6e88..179ed4e 100644
@@ -329,6 +329,7 @@ fn clean_with_new_cleaner(exe_path: &str, in_path: &str, out_path: &str) -> bool
.arg(in_path)
.arg(out_path)
.arg("--copy-on-error=true")
+ // .arg("--apply-transform-to-paths=false")
.arg("--quiet=true")
.output();