1
1
mirror of https://github.com/exyte/Macaw.git synced 2024-11-11 01:42:35 +03:00

Fix #313: Gradients not parsing when they are not in <defs> group

This commit is contained in:
Sroik 2018-04-12 22:45:47 +03:00 committed by Alisa Mylnikova
parent 910845f975
commit f5ee8e43c8

View File

@ -171,6 +171,8 @@ open class SVGParser {
if let id = element.allAttributes["id"]?.text, let clip = parseClip(node) {
self.defClip[id] = clip
}
case "linearGradient", "radialGradient":
parseDefinition(node)
case "style", "defs":
// do nothing - it was parsed on first iteration
return .none
@ -205,32 +207,32 @@ open class SVGParser {
}
fileprivate func parseDefinitions(_ defs: XMLIndexer, groupStyle: [String: String] = [:]) {
for child in defs.children {
defs.children.forEach(parseDefinition(_:))
}
private func parseDefinition(_ child: XMLIndexer) {
guard let id = child.element?.allAttributes["id"]?.text else {
continue
return
}
if let fill = parseFill(child) {
self.defFills[id] = fill
continue
defFills[id] = fill
}
if let _ = parseNode(child) {
else if let _ = parseNode(child) {
// TODO we don't really need to parse node
self.defNodes[id] = child
continue
defNodes[id] = child
}
if let mask = parseMask(child) {
self.defMasks[id] = mask
continue
else if let mask = parseMask(child) {
defMasks[id] = mask
}
if let clip = parseClip(child) {
self.defClip[id] = clip
}
else if let clip = parseClip(child) {
defClip[id] = clip
}
}
fileprivate func parseElement(_ node: XMLIndexer, groupStyle: [String: String] = [:]) -> Node? {
guard let element = node.element else { return .none }