summaryrefslogtreecommitdiff
path: root/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c
diff options
context:
space:
mode:
authorJunsuChoi <jsuya.choi@samsung.com>2020-09-04 11:10:23 +0900
committerHermet Park <chuneon.park@samsung.com>2020-09-04 11:10:25 +0900
commit725ca79ba13ccebc9af7b801c12de5f1a9582568 (patch)
tree82a6afb82c108a92750e0c81b18264b2a7224c40 /src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c
parent9613c584c11a5dd6a66baa1f260025304bbc6648 (diff)
vg_load_svg: Fix pointing to wrong parent
Summary: If defs type is open empty style, it is not included in stack. Because the current logic is weak to group tags in sibling relationships. If defs of open-empty type is placed before the group tag, the group tag refers to the wrong parent. This patch prevents it. This change is the same concept as the D12127, which was reverted to 5065c9d0c2. Test Plan: N/A Reviewers: Hermet, smohanty Subscribers: cedric, herb, kimcinoo, #committers, #reviewers Tags: #efl Differential Revision: https://phab.enlightenment.org/D12129
Diffstat (limited to '')
-rw-r--r--src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c b/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c
index cefdc3304f..6498f1ab10 100644
--- a/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c
+++ b/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c
@@ -2112,9 +2112,18 @@ _find_gradient_factory(const char *name)
2112 return NULL; 2112 return NULL;
2113} 2113}
2114 2114
2115static Svg_Node*
2116_get_parent_node_from_loader(Evas_SVG_Loader *loader)
2117{
2118 if (eina_array_count(loader->stack) > 0)
2119 return eina_array_data_get(loader->stack, eina_array_count(loader->stack) - 1);
2120 else
2121 return loader->doc;
2122}
2123
2115static void 2124static void
2116_evas_svg_loader_xml_open_parser(Evas_SVG_Loader *loader, 2125_evas_svg_loader_xml_open_parser(Evas_SVG_Loader *loader,
2117 const char *content, unsigned int length) 2126 const char *content, unsigned int length, Eina_Bool empty)
2118{ 2127{
2119 const char *attrs = NULL; 2128 const char *attrs = NULL;
2120 int attrs_length = 0; 2129 int attrs_length = 0;
@@ -2157,20 +2166,21 @@ _evas_svg_loader_xml_open_parser(Evas_SVG_Loader *loader,
2157 } 2166 }
2158 else 2167 else
2159 { 2168 {
2160 parent = eina_array_data_get(loader->stack, eina_array_count(loader->stack) - 1); 2169 parent = _get_parent_node_from_loader(loader);
2161 node = method(loader, parent, attrs, attrs_length); 2170 node = method(loader, parent, attrs, attrs_length);
2162 } 2171 }
2163 eina_array_push(loader->stack, node);
2164 2172
2165 if (node->type == SVG_NODE_DEFS) 2173 if (node->type == SVG_NODE_DEFS)
2166 { 2174 {
2167 loader->doc->node.doc.defs = node; 2175 loader->doc->node.doc.defs = node;
2168 loader->def = node; 2176 loader->def = node;
2169 } 2177 if (!empty) eina_array_push(loader->stack, node);
2178 }
2179 else eina_array_push(loader->stack, node);
2170 } 2180 }
2171 else if ((method = _find_graphics_factory(tag_name))) 2181 else if ((method = _find_graphics_factory(tag_name)))
2172 { 2182 {
2173 parent = eina_array_data_get(loader->stack, eina_array_count(loader->stack) - 1); 2183 parent = _get_parent_node_from_loader(loader);
2174 node = method(loader, parent, attrs, attrs_length); 2184 node = method(loader, parent, attrs, attrs_length);
2175 } 2185 }
2176 else if ((gradient_method = _find_gradient_factory(tag_name))) 2186 else if ((gradient_method = _find_gradient_factory(tag_name)))
@@ -2250,10 +2260,10 @@ _evas_svg_loader_parser(void *data, Eina_Simple_XML_Type type,
2250 switch (type) 2260 switch (type)
2251 { 2261 {
2252 case EINA_SIMPLE_XML_OPEN: 2262 case EINA_SIMPLE_XML_OPEN:
2253 _evas_svg_loader_xml_open_parser(loader, content, length); 2263 _evas_svg_loader_xml_open_parser(loader, content, length, EINA_FALSE);
2254 break; 2264 break;
2255 case EINA_SIMPLE_XML_OPEN_EMPTY: 2265 case EINA_SIMPLE_XML_OPEN_EMPTY:
2256 _evas_svg_loader_xml_open_parser(loader, content, length); 2266 _evas_svg_loader_xml_open_parser(loader, content, length, EINA_TRUE);
2257 break; 2267 break;
2258 case EINA_SIMPLE_XML_CLOSE: 2268 case EINA_SIMPLE_XML_CLOSE:
2259 _evas_svg_loader_xml_close_parser(loader, content, length); 2269 _evas_svg_loader_xml_close_parser(loader, content, length);