mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-13 11:36:25 +00:00
svg_loader: allow multiple defs tags
If svg contained multiple defs tags only the first one was handled correctly. Every next 'defs' tag was skipped and its inner elements parsed as it was outside the defs.
This commit is contained in:
parent
02081d8cdc
commit
eb810a92f2
1 changed files with 6 additions and 7 deletions
|
@ -1087,8 +1087,11 @@ static SvgNode* _createNode(SvgNode* parent, SvgNodeType type)
|
|||
|
||||
static SvgNode* _createDefsNode(TVG_UNUSED SvgLoaderData* loader, TVG_UNUSED SvgNode* parent, const char* buf, unsigned bufLength)
|
||||
{
|
||||
if (loader->def && loader->doc->node.doc.defs) return nullptr;
|
||||
if (loader->def && loader->doc->node.doc.defs) return loader->def;
|
||||
SvgNode* node = _createNode(nullptr, SvgNodeType::Defs);
|
||||
|
||||
loader->def = node;
|
||||
loader->doc->node.doc.defs = node;
|
||||
return node;
|
||||
}
|
||||
|
||||
|
@ -2342,18 +2345,14 @@ static void _svgLoaderParserXmlOpen(SvgLoaderData* loader, const char* content,
|
|||
node = method(loader, nullptr, attrs, attrsLength);
|
||||
loader->doc = node;
|
||||
} else {
|
||||
if (!strcmp(tagName, "svg")) return; //Already loadded <svg>(SvgNodeType::Doc) tag
|
||||
if (!strcmp(tagName, "svg")) return; //Already loaded <svg>(SvgNodeType::Doc) tag
|
||||
if (loader->stack.count > 0) parent = loader->stack.data[loader->stack.count - 1];
|
||||
else parent = loader->doc;
|
||||
node = method(loader, parent, attrs, attrsLength);
|
||||
}
|
||||
|
||||
if (!node) return;
|
||||
if (node->type == SvgNodeType::Defs) {
|
||||
loader->doc->node.doc.defs = node;
|
||||
loader->def = node;
|
||||
if (!empty) loader->stack.push(node);
|
||||
} else {
|
||||
if (node->type != SvgNodeType::Defs || !empty) {
|
||||
loader->stack.push(node);
|
||||
}
|
||||
} else if ((method = _findGraphicsFactory(tagName))) {
|
||||
|
|
Loading…
Add table
Reference in a new issue