} else if (!strcmp(key, "preserveAspectRatio")) {
if (!strcmp(value, "none")) doc->preserveAspect = false;
} else if (!strcmp(key, "style")) {
- return simpleXmlParseW3CAttribute(value, 0, _parseStyleAttr, loader);
+ return simpleXmlParseW3CAttribute(value, strlen(value), _parseStyleAttr, loader);
}
#ifdef THORVG_LOG_ENABLED
else if ((!strcmp(key, "x") || !strcmp(key, "y")) && fabsf(svgUtilStrtof(value, nullptr)) > FLT_EPSILON) {
}
-static SvgNode* _findCssStyleNode(const SvgNode* cssStyle, const char* title)
+static SvgNode* _findCssStyleNode(const SvgNode* cssStyle, const char* title, SvgNodeType type)
{
if (!cssStyle) return nullptr;
auto child = cssStyle->child.data;
for (uint32_t i = 0; i < cssStyle->child.count; ++i, ++child) {
- if (((*child)->id) && !strcmp((*child)->id, title)) return (*child);
+ if ((*child)->type == type && ((*child)->id) && !strcmp((*child)->id, title)) return (*child);
}
return nullptr;
*cssClass = _copyId(value);
//TODO: works only if style was defined before it is used
- if (auto cssNode = _findCssStyleNode(loader->cssStyle, *cssClass)) {
- //TODO: check SVG2 stndard - should the geometric properties be copied?
+ if (auto cssNode = _findCssStyleNode(loader->cssStyle, *cssClass, node->type)) {
+ //TODO: check SVG2 standard - should the geometric properties be copied?
_copyAttr(node, cssNode, false);
}
}
SvgNode* node = loader->svgParse->node;
if (!strcmp(key, "style")) {
- return simpleXmlParseW3CAttribute(value, 0, _parseStyleAttr, loader);
+ return simpleXmlParseW3CAttribute(value, strlen(value), _parseStyleAttr, loader);
} else if (!strcmp(key, "transform")) {
node->transform = _parseTransformationMatrix(value);
} else if (!strcmp(key, "id")) {
SvgClipNode* clip = &(node->node.clip);
if (!strcmp(key, "style")) {
- return simpleXmlParseW3CAttribute(value, 0, _parseStyleAttr, loader);
+ return simpleXmlParseW3CAttribute(value, strlen(value), _parseStyleAttr, loader);
} else if (!strcmp(key, "transform")) {
node->transform = _parseTransformationMatrix(value);
} else if (!strcmp(key, "id")) {
SvgMaskNode* mask = &(node->node.mask);
if (!strcmp(key, "style")) {
- return simpleXmlParseW3CAttribute(value, 0, _parseStyleAttr, loader);
+ return simpleXmlParseW3CAttribute(value, strlen(value), _parseStyleAttr, loader);
} else if (!strcmp(key, "transform")) {
node->transform = _parseTransformationMatrix(value);
} else if (!strcmp(key, "id")) {
//Temporary: need to copy
path->path = _copyId(value);
} else if (!strcmp(key, "style")) {
- return simpleXmlParseW3CAttribute(value, 0, _parseStyleAttr, loader);
+ return simpleXmlParseW3CAttribute(value, strlen(value), _parseStyleAttr, loader);
} else if (!strcmp(key, "clip-path")) {
_handleClipPathAttr(loader, node, value);
} else if (!strcmp(key, "mask")) {
}
if (!strcmp(key, "style")) {
- return simpleXmlParseW3CAttribute(value, 0, _parseStyleAttr, loader);
+ return simpleXmlParseW3CAttribute(value, strlen(value), _parseStyleAttr, loader);
} else if (!strcmp(key, "clip-path")) {
_handleClipPathAttr(loader, node, value);
} else if (!strcmp(key, "mask")) {
} else if (!strcmp(key, "class")) {
_handleCssClassAttr(loader, node, value);
} else if (!strcmp(key, "style")) {
- return simpleXmlParseW3CAttribute(value, 0, _parseStyleAttr, loader);
+ return simpleXmlParseW3CAttribute(value, strlen(value), _parseStyleAttr, loader);
} else if (!strcmp(key, "clip-path")) {
_handleClipPathAttr(loader, node, value);
} else if (!strcmp(key, "mask")) {
if (!strcmp(key, "points")) {
return _attrParsePolygonPoints(value, &polygon->points, &polygon->pointsCount);
} else if (!strcmp(key, "style")) {
- return simpleXmlParseW3CAttribute(value, 0, _parseStyleAttr, loader);
+ return simpleXmlParseW3CAttribute(value, strlen(value), _parseStyleAttr, loader);
} else if (!strcmp(key, "clip-path")) {
_handleClipPathAttr(loader, node, value);
} else if (!strcmp(key, "mask")) {
} else if (!strcmp(key, "class")) {
_handleCssClassAttr(loader, node, value);
} else if (!strcmp(key, "style")) {
- ret = simpleXmlParseW3CAttribute(value, 0, _parseStyleAttr, loader);
+ ret = simpleXmlParseW3CAttribute(value, strlen(value), _parseStyleAttr, loader);
} else if (!strcmp(key, "clip-path")) {
_handleClipPathAttr(loader, node, value);
} else if (!strcmp(key, "mask")) {
} else if (!strcmp(key, "class")) {
_handleCssClassAttr(loader, node, value);
} else if (!strcmp(key, "style")) {
- return simpleXmlParseW3CAttribute(value, 0, _parseStyleAttr, loader);
+ return simpleXmlParseW3CAttribute(value, strlen(value), _parseStyleAttr, loader);
} else if (!strcmp(key, "clip-path")) {
_handleClipPathAttr(loader, node, value);
} else if (!strcmp(key, "mask")) {
} else if (!strcmp(key, "class")) {
_handleCssClassAttr(loader, node, value);
} else if (!strcmp(key, "style")) {
- return simpleXmlParseW3CAttribute(value, 0, _parseStyleAttr, loader);
+ return simpleXmlParseW3CAttribute(value, strlen(value), _parseStyleAttr, loader);
} else if (!strcmp(key, "clip-path")) {
_handleClipPathAttr(loader, node, value);
} else if (!strcmp(key, "mask")) {
_toColor(value, &stop->r, &stop->g, &stop->b, nullptr);
}
} else if (!strcmp(key, "style")) {
- simpleXmlParseW3CAttribute(value, 0, _attrParseStopsStyle, data);
+ simpleXmlParseW3CAttribute(value, strlen(value), _attrParseStopsStyle, data);
} else {
return false;
}
buflen -= next - buf;
buf = next;
+
free(tag);
free(name);
}