diff --git a/crates/usvg-tree/src/lib.rs b/crates/usvg-tree/src/lib.rs index 230d0c259..d162e4980 100644 --- a/crates/usvg-tree/src/lib.rs +++ b/crates/usvg-tree/src/lib.rs @@ -732,16 +732,6 @@ impl NodeKind { NodeKind::Text(ref e) => e.id.as_str(), } } - - /// Returns node's transform. - pub fn transform(&self) -> Transform { - match self { - NodeKind::Group(ref e) => e.transform, - NodeKind::Path(_) => Transform::default(), - NodeKind::Image(_) => Transform::default(), - NodeKind::Text(_) => Transform::default(), - } - } } /// A group container. @@ -1209,12 +1199,6 @@ pub trait NodeExt { /// will be returned. fn id(&self) -> std::cell::Ref; - /// Returns node's transform. - /// - /// If a current node doesn't support transformation - a default - /// transform will be returned. - fn transform(&self) -> Transform; - /// Returns node's absolute transform. /// /// If a current node doesn't support transformation - a default @@ -1263,15 +1247,12 @@ impl NodeExt for Node { std::cell::Ref::map(self.borrow(), |v| v.id()) } - #[inline] - fn transform(&self) -> Transform { - self.borrow().transform() - } - fn abs_transform(&self) -> Transform { let mut ts_list = Vec::new(); for p in self.ancestors() { - ts_list.push(p.transform()); + if let NodeKind::Group(ref group) = *p.borrow() { + ts_list.push(group.transform); + } } let mut abs_ts = Transform::default(); @@ -1307,7 +1288,11 @@ fn calc_node_bbox(node: &Node, ts: Transform) -> Option { let mut bbox = BBox::default(); for child in node.children() { - let child_transform = ts.pre_concat(child.transform()); + let child_transform = if let NodeKind::Group(ref group) = *child.borrow() { + ts.pre_concat(group.transform) + } else { + ts + }; if let Some(c_bbox) = calc_node_bbox(&child, child_transform) { bbox = bbox.expand(c_bbox); }