mirror of
https://github.com/thorvg/thorvg.git
synced 2025-07-28 17:15:57 +00:00
svg_loader: fixing css style for group selectors, clips/masks
The css styling has to be applied as the first step of the node updates. Whereas the updateStyle function should be called as the last step, after all other node updates are made.
This commit is contained in:
parent
ada4d5e261
commit
1aaf222b62
2 changed files with 6 additions and 6 deletions
|
@ -101,7 +101,6 @@ static void _cssStyleCopy(SvgStyleProperty* to, const SvgStyleProperty* from)
|
||||||
to->opacity = from->opacity;
|
to->opacity = from->opacity;
|
||||||
to->flags = (SvgStyleFlags)((int)to->flags | (int)SvgStyleFlags::Opacity);
|
to->flags = (SvgStyleFlags)((int)to->flags | (int)SvgStyleFlags::Opacity);
|
||||||
}
|
}
|
||||||
//TODO: support clip-path, mask, mask-type, display
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -121,7 +120,7 @@ void copyCssStyleAttr(SvgNode* to, const SvgNode* from)
|
||||||
}
|
}
|
||||||
//Copy style attribute
|
//Copy style attribute
|
||||||
_cssStyleCopy(to->style, from->style);
|
_cssStyleCopy(to->style, from->style);
|
||||||
//TODO: clips and masks are not supported yet in css style
|
|
||||||
if (from->style->clipPath.url) to->style->clipPath.url = strdup(from->style->clipPath.url);
|
if (from->style->clipPath.url) to->style->clipPath.url = strdup(from->style->clipPath.url);
|
||||||
if (from->style->mask.url) to->style->mask.url = strdup(from->style->mask.url);
|
if (from->style->mask.url) to->style->mask.url = strdup(from->style->mask.url);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2690,7 +2690,7 @@ static void _svgLoaderParserXmlCssStyle(SvgLoaderData* loader, const char* conte
|
||||||
|
|
||||||
while (auto next = simpleXmlParseCSSAttribute(content, length, &tag, &name, &attrs, &attrsLength)) {
|
while (auto next = simpleXmlParseCSSAttribute(content, length, &tag, &name, &attrs, &attrsLength)) {
|
||||||
if ((method = _findGroupFactory(tag))) {
|
if ((method = _findGroupFactory(tag))) {
|
||||||
TVGLOG("SVG", "Unsupported elements used in the internal CSS style sheets [Elements: %s]", tag);
|
if ((node = method(loader, loader->cssStyle, attrs, attrsLength, simpleXmlParseW3CAttribute))) node->id = _copyId(name);
|
||||||
} else if ((method = _findGraphicsFactory(tag))) {
|
} else if ((method = _findGraphicsFactory(tag))) {
|
||||||
if ((node = method(loader, loader->cssStyle, attrs, attrsLength, simpleXmlParseW3CAttribute))) node->id = _copyId(name);
|
if ((node = method(loader, loader->cssStyle, attrs, attrsLength, simpleXmlParseW3CAttribute))) node->id = _copyId(name);
|
||||||
} else if ((gradientMethod = _findGradientFactory(tag))) {
|
} else if ((gradientMethod = _findGradientFactory(tag))) {
|
||||||
|
@ -3045,9 +3045,11 @@ void SvgLoader::run(unsigned tid)
|
||||||
if (!simpleXmlParse(content, size, true, _svgLoaderParser, &(loaderData))) return;
|
if (!simpleXmlParse(content, size, true, _svgLoaderParser, &(loaderData))) return;
|
||||||
|
|
||||||
if (loaderData.doc) {
|
if (loaderData.doc) {
|
||||||
_updateStyle(loaderData.doc, nullptr);
|
|
||||||
auto defs = loaderData.doc->node.doc.defs;
|
auto defs = loaderData.doc->node.doc.defs;
|
||||||
|
|
||||||
|
if (loaderData.nodesToStyle.count > 0) stylePostponedNodes(&loaderData.nodesToStyle, loaderData.cssStyle);
|
||||||
|
if (loaderData.cssStyle) updateCssStyle(loaderData.doc, loaderData.cssStyle);
|
||||||
|
|
||||||
_updateComposite(loaderData.doc, loaderData.doc);
|
_updateComposite(loaderData.doc, loaderData.doc);
|
||||||
if (defs) _updateComposite(loaderData.doc, defs);
|
if (defs) _updateComposite(loaderData.doc, defs);
|
||||||
|
|
||||||
|
@ -3056,8 +3058,7 @@ void SvgLoader::run(unsigned tid)
|
||||||
if (loaderData.gradients.count > 0) _updateGradient(loaderData.doc, &loaderData.gradients);
|
if (loaderData.gradients.count > 0) _updateGradient(loaderData.doc, &loaderData.gradients);
|
||||||
if (defs) _updateGradient(loaderData.doc, &defs->node.defs.gradients);
|
if (defs) _updateGradient(loaderData.doc, &defs->node.defs.gradients);
|
||||||
|
|
||||||
if (loaderData.nodesToStyle.count > 0) stylePostponedNodes(&loaderData.nodesToStyle, loaderData.cssStyle);
|
_updateStyle(loaderData.doc, nullptr);
|
||||||
if (loaderData.cssStyle) updateCssStyle(loaderData.doc, loaderData.cssStyle);
|
|
||||||
}
|
}
|
||||||
root = svgSceneBuild(loaderData.doc, vx, vy, vw, vh, w, h, preserveAspect, svgPath);
|
root = svgSceneBuild(loaderData.doc, vx, vy, vw, vh, w, h, preserveAspect, svgPath);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue