svg_loader: the color attribute properly inherited 23/288823/1
authorMira Grudzinska <m.grudzinska@samsung.com>
Fri, 7 Jan 2022 21:42:00 +0000 (22:42 +0100)
committerMichal Szczecinski <mihashco89@gmail.com>
Thu, 23 Feb 2023 09:47:00 +0000 (10:47 +0100)
The color attribute hat to be inherited regardles whether it is used
in the child node or not - it may be used i.e. in the grandchild node.

Change-Id: If2895ec64c9ed7f7e176cb32cb4adc8a61f63551

src/loaders/svg/tvgSvgLoader.cpp

index e40be9a..e4f0f50 100644 (file)
@@ -2512,14 +2512,16 @@ static void _styleInherit(SvgStyleProperty* child, const SvgStyleProperty* paren
 {
     if (parent == nullptr) return;
     //Inherit the property of parent if not present in child.
+    if (!child->curColorSet) {
+        child->color = parent->color;
+        child->curColorSet = parent->curColorSet;
+    }
     //Fill
     if (!((int)child->fill.flags & (int)SvgFillFlags::Paint)) {
         child->fill.paint.color = parent->fill.paint.color;
         child->fill.paint.none = parent->fill.paint.none;
         child->fill.paint.curColor = parent->fill.paint.curColor;
         if (parent->fill.paint.url) child->fill.paint.url = _copyId(parent->fill.paint.url);
-    } else if (child->fill.paint.curColor && !child->curColorSet) {
-        child->color = parent->color;
     }
     if (!((int)child->fill.flags & (int)SvgFillFlags::Opacity)) {
         child->fill.opacity = parent->fill.opacity;
@@ -2533,8 +2535,6 @@ static void _styleInherit(SvgStyleProperty* child, const SvgStyleProperty* paren
         child->stroke.paint.none = parent->stroke.paint.none;
         child->stroke.paint.curColor = parent->stroke.paint.curColor;
         child->stroke.paint.url = parent->stroke.paint.url ? _copyId(parent->stroke.paint.url) : nullptr;
-    } else if (child->stroke.paint.curColor && !child->curColorSet) {
-        child->color = parent->color;
     }
     if (!((int)child->stroke.flags & (int)SvgStrokeFlags::Opacity)) {
         child->stroke.opacity = parent->stroke.opacity;