Commit abe1eb66 authored by RazrFalcon's avatar RazrFalcon

(usvg) Fixed groups regrouping.

parent d19573d4
......@@ -22,6 +22,8 @@ This changelog also contains important changes in dependencies.
- (usvg) Paths without stroke and fill will no longer be removed.
Required for a proper bbox resolving.
- (usvg) Coordinates resolving when units are `userSpaceOnUse`.
- (usvg) Groups regrouping. Caused an incorrect rendering of `clipPath`
that had `filter` on a child.
- (qt-backend) Stroking of LineTo specified as CurveTo.
- (svgdom) `stroke-miterlimit` attribute parsing.
- (svgdom) `length` and `number` attribute types parsing.
......
a-stroke-018.svg
e-clipPath-039.svg
e-clipPath-040.svg
......@@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- `rotate` attribute resolving.
- `color` on `use` resolving.
- Coordinates resolving when units are `userSpaceOnUse`.
- Groups regrouping.
### Removed
- `Rect::transform`.
......
......@@ -24,7 +24,7 @@ pub fn convert(
let attrs = node.attributes();
let mut clip_path = None;
if let Some(&AValue::FuncLink(ref link)) = attrs.get_type(AId::ClipPath) {
if let Some(&AValue::FuncLink(ref link)) = attrs.get_value(AId::ClipPath) {
if link.is_tag_name(EId::ClipPath) {
clip_path = Some(link.id().to_string());
}
......
......@@ -44,7 +44,7 @@ pub fn resolve_paint(
aid: AId,
has_bbox: bool,
) -> Option<tree::Paint> {
match attrs.get_type(aid) {
match attrs.get_value(aid) {
Some(&AValue::Color(c)) => {
Some(tree::Paint::Color(c))
}
......
......@@ -23,7 +23,7 @@ pub fn convert(
}
let mut mask = None;
if let Some(&AValue::FuncLink(ref link)) = attrs.get_type(AId::Mask) {
if let Some(&AValue::FuncLink(ref link)) = attrs.get_value(AId::Mask) {
if link.is_tag_name(EId::Mask) {
mask = Some(link.id().to_string());
}
......
......@@ -345,7 +345,7 @@ enum IriResolveResult {
fn resolve_iri(node: &svgdom::Node, eid: EId, aid: AId, tree: &tree::Tree) -> IriResolveResult {
let attrs = node.attributes();
if let Some(&AValue::FuncLink(ref link)) = attrs.get_type(aid) {
if let Some(&AValue::FuncLink(ref link)) = attrs.get_value(aid) {
if link.is_tag_name(eid) {
if let Some(node) = tree.defs_by_id(&link.id()) {
return IriResolveResult::Id(node.id().to_string());
......
......@@ -316,7 +316,7 @@ fn conv_marker(
tree: &tree::Tree,
) -> Option<String> {
let attrs = node.attributes();
if let Some(&AValue::FuncLink(ref link)) = attrs.get_type(aid) {
if let Some(&AValue::FuncLink(ref link)) = attrs.get_value(aid) {
if link.is_tag_name(EId::Marker) {
if let Some(node) = tree.defs_by_id(&link.id()) {
return Some(node.id().to_string());
......
......@@ -204,4 +204,6 @@ pub fn prepare_doc(doc: &mut svgdom::Document, opt: &Options) {
prepare_text_nodes(doc);
remove_invalid_font_size(doc, opt);
remove_unused_defs(doc);
}
......@@ -24,12 +24,13 @@ pub fn resolve_clip_path_attributes(doc: &Document) {
/// with a black fill and without a stroke.
pub fn prepare_clip_path_children(doc: &Document) {
for node in doc.root().descendants().filter(|n| n.is_tag_name(EId::ClipPath)) {
for (_, mut child) in node.descendants().svg() {
for (_, mut child) in node.descendants().svg().skip(1) {
// Set fill to black.
child.set_attribute((AId::Fill, Color::black()));
// Remove stroke.
child.set_attribute((AId::Stroke, AValue::None));
child.set_attribute((AId::Mask, AValue::None));
child.set_attribute((AId::Filter, AValue::None));
// Disable opacity.
child.set_attribute((AId::Opacity, 1.0));
......
......@@ -27,11 +27,7 @@ pub fn regroup_elements(doc: &mut Document, parent: &Node) {
}
let opacity = node.attributes().get_number_or(AId::Opacity, 1.0);
if opacity.fuzzy_eq(&1.0)
&& !node.has_attribute(AId::ClipPath)
&& !node.has_attribute(AId::Mask)
&& !node.has_attribute(AId::Filter)
{
if opacity.fuzzy_eq(&1.0) && !has_links(&node) {
continue;
}
......@@ -65,3 +61,19 @@ pub fn regroup_elements(doc: &mut Document, parent: &Node) {
g_node.append(node.clone());
}
}
fn has_links(node: &Node) -> bool {
if let Some(&AValue::FuncLink(_)) = node.attributes().get_value(AId::ClipPath) {
return true;
}
if let Some(&AValue::FuncLink(_)) = node.attributes().get_value(AId::Mask) {
return true;
}
if let Some(&AValue::FuncLink(_)) = node.attributes().get_value(AId::Filter) {
return true;
}
false
}
......@@ -37,7 +37,7 @@ fn _ungroup_groups(parent: &Node, opt: &Options, groups: &mut Vec<Node>) {
// <feFlood flood-color="green"/>
// </filter>
// <g filter="url(#filter1)"/>
if let Some(&AValue::FuncLink(_)) = node.attributes().get_type(AId::Filter) {
if let Some(&AValue::FuncLink(_)) = node.attributes().get_value(AId::Filter) {
continue;
}
......@@ -59,17 +59,17 @@ fn _ungroup_groups(parent: &Node, opt: &Options, groups: &mut Vec<Node>) {
}
// Groups with a `clip-path` attribute can't be ungroupped.
if let Some(&AValue::FuncLink(_)) = node.attributes().get_type(AId::ClipPath) {
if let Some(&AValue::FuncLink(_)) = node.attributes().get_value(AId::ClipPath) {
continue;
}
// Groups with a `mask` attribute can't be ungroupped.
if let Some(&AValue::FuncLink(_)) = node.attributes().get_type(AId::Mask) {
if let Some(&AValue::FuncLink(_)) = node.attributes().get_value(AId::Mask) {
continue;
}
// Groups with a `filter` attribute can't be ungroupped.
if let Some(&AValue::FuncLink(_)) = node.attributes().get_type(AId::Filter) {
if let Some(&AValue::FuncLink(_)) = node.attributes().get_value(AId::Filter) {
continue;
}
......
......@@ -68,6 +68,8 @@ e-clipPath-034,114
e-clipPath-035,50
e-clipPath-036,97
e-clipPath-037,66
e-clipPath-039,948,chrome bug
e-clipPath-040,6059,chrome bug
e-ellipse-001,464
e-ellipse-002,11499,chrome bug
e-ellipse-003,20329,chrome bug
......
......@@ -373,9 +373,9 @@ e-filter-013,0f2bed4e
e-filter-014,ce10e583
e-filter-015,fe0b6c8e
e-filter-016,ed25aa75
e-filter-017,569f389e
e-filter-018,5acaf334
e-filter-019,1d693821
e-filter-017,afb350e5
e-filter-018,afb350e5
e-filter-019,1ccc7020
e-filter-020,80702f65
e-filter-021,3739f310
e-filter-022,80702f65
......@@ -462,14 +462,14 @@ e-linearGradient-003,b090e2e6
e-linearGradient-004,6153c036
e-linearGradient-005,f333c639
e-linearGradient-006,5733e899
e-linearGradient-007,b4355cce
e-linearGradient-008,d4f15dbe
e-linearGradient-007,1ea89a21
e-linearGradient-008,3fd79268
e-linearGradient-009,669371f5
e-linearGradient-010,180df13b
e-linearGradient-011,dbc45035
e-linearGradient-010,e9b845ac
e-linearGradient-011,a9ea0d0a
e-linearGradient-012,4800315f
e-linearGradient-013,a7e9ef6d
e-linearGradient-014,a9d2e4e8
e-linearGradient-014,6ea6732c
e-linearGradient-015,ebb0e049
e-linearGradient-016,1ea89a21
e-linearGradient-017,658bf1f5
......@@ -483,7 +483,7 @@ e-linearGradient-024,669371f5
e-linearGradient-025,3f79d317
e-linearGradient-026,d35ddf9b
e-linearGradient-027,14d5b02d
e-linearGradient-028,2c0481ec
e-linearGradient-028,21b3436f
e-linearGradient-029,1abb06ee
e-linearGradient-030,10fb99ae
e-mask-001,07db0d65
......@@ -599,12 +599,12 @@ e-radialGradient-003,13efda6a
e-radialGradient-004,b4a20272
e-radialGradient-005,9728d6a9
e-radialGradient-006,41752492
e-radialGradient-007,10b899b4
e-radialGradient-008,1659756f
e-radialGradient-009,dd98bb2c
e-radialGradient-007,8af1dd66
e-radialGradient-008,70e69555
e-radialGradient-009,f0ad4b80
e-radialGradient-010,669371f5
e-radialGradient-011,d4f923fc
e-radialGradient-012,ada6a13c
e-radialGradient-011,e86b9eab
e-radialGradient-012,e86b9eab
e-radialGradient-013,6dc53888
e-radialGradient-014,b265b08c
e-radialGradient-015,f0ad4b80
......@@ -870,7 +870,7 @@ a-marker-start-001,d70d94a9
a-overflow-001,682a7e64
a-overflow-002,c65c355d
a-overflow-003,db5c571f
e-clipPath-038,ec570dab
e-clipPath-038,ab281e7d
e-marker-001,3972f821
e-marker-002,01763f29
e-marker-003,89500771
......@@ -885,9 +885,9 @@ e-marker-011,125714e0
e-marker-012,91674d55
e-marker-013,51ef7db1
e-marker-014,d5bf0c70
e-marker-015,1d5af3a4
e-marker-016,9e9bc5d6
e-marker-017,7501c7c1
e-marker-015,d0c0aaeb
e-marker-016,6f762530
e-marker-017,1dd8893f
e-marker-018,02efa925
e-marker-019,9f8a2bf3
e-marker-020,a285ba7d
......@@ -940,3 +940,5 @@ a-stroke-019,5a6c1265
e-stop-028,d17c95f8
e-stop-029,219b53c7
e-stop-030,99767fc0
e-clipPath-039,5f852d84
e-clipPath-040,5f852d84
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment