svg_loader: styling++ (no logical changes) 32/289032/1
authorMira Grudzinska <m.grudzinska@samsung.com>
Fri, 28 Jan 2022 00:42:02 +0000 (01:42 +0100)
committerMichal Szczecinski <mihashco89@gmail.com>
Mon, 27 Feb 2023 09:57:57 +0000 (10:57 +0100)
Change-Id: I8cde1a51aaf567aa65b9cb838bd39242a8e4d61f

src/loaders/svg/tvgSvgLoader.cpp
src/loaders/svg/tvgSvgLoaderCommon.h
src/loaders/svg/tvgXmlParser.cpp
src/loaders/svg/tvgXmlParser.h

index 351d872..e68b776 100644 (file)
 #define PX_PER_MM 3.779528f //1 in = 25.4 mm -> PX_PER_IN/25.4
 #define PX_PER_CM 37.79528f //1 in = 2.54 cm -> PX_PER_IN/2.54
 
-
-typedef bool (*parseAttributes)(const char*, unsigned, simpleXMLAttributeCb, const void*);
+typedef bool (*parseAttributes)(const char* buf, unsigned bufLength, simpleXMLAttributeCb func, const void* data);
 typedef SvgNode* (*FactoryMethod)(SvgLoaderData* loader, SvgNode* parent, const char* buf, unsigned bufLength, parseAttributes func);
 typedef SvgStyleGradient* (*GradientFactoryMethod)(SvgLoaderData* loader, const char* buf, unsigned bufLength);
 
 static void _postponeCloneNode(Array<SvgNodeIdPair>* nodes, SvgNode *node, char* id);
 
+
 static char* _skipSpace(const char* str, const char* end)
 {
     while (((end && str < end) || (!end && *str != '\0')) && isspace(*str)) {
@@ -1055,7 +1055,6 @@ static void _cssStyleCopy(SvgStyleProperty* to, const SvgStyleProperty* from)
 }
 
 
-//TODO: check SVG2 standard - should the geometric properties be copied?
 static void _copyCssStyleAttr(SvgNode* to, const SvgNode* from)
 {
     //Copy matrix attribute
@@ -2812,20 +2811,17 @@ static void _svgLoaderParserXmlCssStyle(SvgLoaderData* loader, const char* conte
 
     while (auto next = simpleXmlParseCSSAttribute(content, length, &tag, &name, &attrs, &attrsLength)) {
         if ((method = _findGroupFactory(tag))) {
-            //TODO - node->id ??? add additional var for svgnode?
-            if ((node = method(loader, loader->cssStyle, attrs, attrsLength, simpleXmlParseW3CAttribute))) node->id = _copyId(name);
+            TVGLOG("SVG", "Unsupported elements used in the internal CSS style sheets [Elements: %s]", tag);
         } else if ((method = _findGraphicsFactory(tag))) {
             if ((node = method(loader, loader->cssStyle, attrs, attrsLength, simpleXmlParseW3CAttribute))) node->id = _copyId(name);
-            //TODO - implement
         } else if ((gradientMethod = _findGradientFactory(tag))) {
-            //TODO - implement
-            //SvgStyleGradient* gradient = gradientMethod(loader, attrs, attrsLength);
+            TVGLOG("SVG", "Unsupported elements used in the internal CSS style sheets [Elements: %s]", tag);
         } else if (!strcmp(tag, "stop")) {
-            //TODO - implement
+            TVGLOG("SVG", "Unsupported elements used in the internal CSS style sheets [Elements: %s]", tag);
         } else if (!strcmp(tag, "all")) {
             if ((node = _createCssStyleNode(loader, loader->cssStyle, attrs, attrsLength, simpleXmlParseW3CAttribute))) node->id = _copyId(name);
         } else if (!isIgnoreUnsupportedLogElements(tag)) {
-            TVGLOG("SVG", "Unsupported elements used [Elements: %s]", tag);
+            TVGLOG("SVG", "Unsupported elements used in the internal CSS style sheets [Elements: %s]", tag);
         }
 
         length -= next - content;
@@ -3215,7 +3211,6 @@ void SvgLoader::run(unsigned tid)
         if (defs) _updateGradient(loaderData.doc, &defs->node.defs.gradients);
 
         if (loaderData.nodesToStyle.count > 0) _stylePostponedNodes(&loaderData.nodesToStyle, loaderData.cssStyle);
-        //TODO: defs should be updated as well?
         if (loaderData.cssStyle) _updateCssStyle(loaderData.doc, loaderData.cssStyle);
     }
     root = svgSceneBuild(loaderData.doc, vx, vy, vw, vh, w, h, preserveAspect, svgPath);
index 1453b6d..364ec15 100644 (file)
@@ -416,7 +416,7 @@ struct SvgLoaderData
     Array<SvgNodeIdPair> nodesToStyle;
     int level = 0;
     bool result = false;
-    bool style = false; //TODO: find a better sollution?
+    bool style = false;
 };
 
 /*
index 7e8fdae..aa93870 100644 (file)
@@ -458,7 +458,7 @@ bool simpleXmlParse(const char* buf, unsigned bufLength, bool strip, simpleXMLCb
 }
 
 
-bool simpleXmlParseW3CAttribute(const char* buf, unsigned buflen, simpleXMLAttributeCb func, const void* data)
+bool simpleXmlParseW3CAttribute(const char* buf, unsigned bufLength, simpleXMLAttributeCb func, const void* data)
 {
     const char* end;
     char* key;
@@ -467,7 +467,7 @@ bool simpleXmlParseW3CAttribute(const char* buf, unsigned buflen, simpleXMLAttri
 
     if (!buf) return false;
 
-    end = buf + buflen;
+    end = buf + bufLength;
     key = (char*)alloca(end - buf + 1);
     val = (char*)alloca(end - buf + 1);
 
index 2ce7179..e2761ca 100644 (file)
@@ -47,11 +47,11 @@ enum class SimpleXMLType
 typedef bool (*simpleXMLCb)(void* data, SimpleXMLType type, const char* content, unsigned int length);
 typedef bool (*simpleXMLAttributeCb)(void* data, const char* key, const char* value);
 
-bool simpleXmlParseAttributes(const char* buf, unsigned buflen, simpleXMLAttributeCb func, const void* data);
-bool simpleXmlParse(const char* buf, unsigned buflen, bool strip, simpleXMLCb func, const void* data);
-bool simpleXmlParseW3CAttribute(const char* buf, unsigned buflen, simpleXMLAttributeCb func, const void* data);
+bool simpleXmlParseAttributes(const char* buf, unsigned bufLength, simpleXMLAttributeCb func, const void* data);
+bool simpleXmlParse(const char* buf, unsigned bufLength, bool strip, simpleXMLCb func, const void* data);
+bool simpleXmlParseW3CAttribute(const char* buf, unsigned bufLength, simpleXMLAttributeCb func, const void* data);
 const char* simpleXmlParseCSSAttribute(const char* buf, unsigned bufLength, char** tag, char** name, const char** attrs, unsigned* attrsLength);
-const char* simpleXmlFindAttributesTag(const char* buf, unsigned buflen);
+const char* simpleXmlFindAttributesTag(const char* buf, unsigned bufLength);
 bool isIgnoreUnsupportedLogElements(const char* tagName);
 const char* simpleXmlNodeTypeToString(SvgNodeType type);