Commit graph

293 commits

Author SHA1 Message Date
Mira Grudzinska
e36368c40c svg_loader: only the first css style node is interpreted
Since the css id selector is not supported in TVG, only the first
style node is taken into account.
2022-08-29 11:59:32 +09:00
mgrudzinska
0da0f5fa46 svg_loader: clearing the parser stop flags 2022-04-05 20:07:33 +09:00
mgrudzinska
eb7b281898 svg_loader: fixing color parsing
Color given in percentages, ex."rgb(10%,20%,30%)", was incorrectly parsed.
2022-04-05 19:36:15 +09:00
mgrudzinska
470b885e65 svg_loader: fixing segf when passing a nullptr to strcmp
This occurred when a gradient has no 'id' attribute.
2022-04-03 22:42:26 +02:00
mgrudzinska
1e8b8cbb53 svg_loader: symbol node without any viewbox/width/height info handled properly 2022-03-21 18:38:10 +09:00
Mira Grudzinska
2ee25ea11d
svg_loader: width and height attribs of the use element applied 2022-03-07 11:32:02 +09:00
Hermet Park
bdda2586e9 svg_loader: handle the exception properly.
viewBox doesn't expect the missing attributes,
it won't have any default values.

So we can decide the fault when the values are missed.
2022-02-23 15:02:17 +09:00
Mira Grudzinska
72ab9268e3 svg_loader: symbol++
- The initial value of the overflow attribute was missing
- overflow="visible" was missing scaling
2022-02-21 11:21:22 +09:00
Mira Grudzinska
70ed0653f1 svg_loader: symbol tag implemented
The 'symbol' tag introduced. It can be used to define graphical
template objects which can be instantiated by a 'use' tag.
2022-02-21 11:21:22 +09:00
Mira Grudzinska
23ea4ed9f1 svg_loader: fixing memory leak
The css style node was improperly freed.
2022-02-14 14:35:09 +09:00
Mira Grudzinska
87832a9236 svg_loader: preventing invalid log msg 2022-02-09 19:52:35 +01:00
Mira Grudzinska
6a589777b0 svg_loader: proper image transformation
One of the image's attributes can be a transformation matrix.
Now it's applied.
2022-02-08 19:49:39 +09:00
Hermet Park
ff3ebd9abd svg_loader: code refactoring.
follow strict coding-style.

no logic changes.
2022-02-08 18:57:11 +09:00
Mira Grudzinska
1aaf222b62 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.
2022-02-08 17:58:53 +09:00
Mira Grudzinska
ada4d5e261 svg_loader: a css style node shouldn't have a parent
This node is supposed to be separeted from the main tree nodes.
2022-02-08 17:58:53 +09:00
Mira Grudzinska
5aab26302a svg_loader: css style functions moved to a separate file 2022-02-08 17:58:53 +09:00
Mira Grudzinska
863a98870f svg_loader: styling++ (no logical changes) 2022-02-08 17:58:53 +09:00
Mira Grudzinska
4a7310756d svg_loader: fixing cdata block reading
The CData block is read if it's inside the style tag.
In a case when the CData block was just after the style
block, the data was still read, although it shouldn't be.
Fixed.
2022-02-08 17:58:53 +09:00
Mira Grudzinska
dc518a83c8 svg_loader: some names changed, no logical changes 2022-02-08 17:58:53 +09:00
Mira Grudzinska
a5e5e48de4 svg_loader: restoring changes from ed3b17b228
(preventing memcpy from a nullptr)
2022-02-08 17:58:53 +09:00
Mira Grudzinska
b535803136 svg_loader: css styling supported also when defs were postponed
Defs can be defined at the end of the file. In such a case each
node with a defined class attribute has to be marked and checked
at the final stage of processing - the proper style node has to be found
and its style has to be applied.
2022-02-08 17:58:53 +09:00
Mira Grudzinska
85f23d7f6c svg_loader: supporting different target formats in css
Css styling supports now targets defined only by tag or only by name
(tag.name was already supported before).
Also proper precedence of a styling is fixed - flags were not set.
2022-02-08 17:58:53 +09:00
Mira Grudzinska
abd959bb54 svg_loader: proper precedence of a styling
The attribute values should be copied from a style node only if they
were set in the destination node using the attributes (in opocity to
a style attribute). A proper copyCssStyleAttr() function is introduced.
2022-02-08 17:58:53 +09:00
Mira Grudzinska
1799cd9a78 svg_loader: remove unnecessary variables 2022-02-08 17:58:53 +09:00
Mira Grudzinska
482add35e9 svg_loader: buflen arg used in the simpleXmlParseW3CAttribute()
While parsing the css internal style sheets the buflen has to be passed.
2022-02-08 17:58:53 +09:00
Mira Grudzinska
024594f3bb svg_loader: additional arg added into create...Node() functions
A function pointer added as an additional arg in order to make it
possible to use these functions to create a normal nodes and also
nodes defined inside a style tag. These two cases need to be parsed
using different functions: simpleXmlParseAttributes() and
simpleXmlParseW3CAttribute().
2022-02-08 17:58:53 +09:00
Mira Grudzinska
c3ed02fd22 svg_loader: intro to the implementation of the css internal style sheets parsing
Function simpleXmlParseCSSAttribute() used to parse the data inside the style tag.
For now the supported formats are: tag {}, .name {}, tag.name{}

_svgLoaderParserXmlStyle() used to deal with the results of the above - to create
the proper nodes. Will work after create...Node() are changed.

Note:
The geometric attributes are not copied from the node defining the style
to the node using it. The SVG2 standard has to be checked to decide
whether it should be supported.
2022-02-08 17:58:53 +09:00
Mira Grudzinska
0f51d798ce svg_loader: css style node introduced
For now it is assumed that only one style element is defined
in an svg file, although it can be easily changed if needed.
The style node will be used to define the style applied to a node
of a given type or in a case when a class attrib was used.
2022-02-08 17:58:53 +09:00
Mira Grudzinska
828a15cfdb svg_loader: class attribute added
It's the first step in introducing the css inline style sheets into tvg.
For now the class attribute is set only for SvgNodes (not for grads),
it's not used yet.
2022-02-08 17:58:53 +09:00
Hermet Park
0f87685c85 svg_loader: ++robustness
Prevent recursive calls by counting just in case.

The size is arbitrary value, we can adjust it experimentally.

@Issue: https://github.com/Samsung/thorvg/issues/1161
2022-01-20 19:18:22 +09:00
Mira Grudzinska
922e3e10c0 svg_loader: group tags misinterpreted as parent nodes
Group tags in a format <tag .../> finds no application
to the rest of the svg file and should be skipped.
2022-01-19 16:42:06 +09:00
Rémi Verschelde
0c6c37b616 build: Add missing <cstring> includes for MinGW compatibility 2022-01-19 16:40:30 +09:00
Mira Grudzinska
99da490ef7 svg_loader: memleak prevention
If image href set more than once, the memory was not freed.
2022-01-18 18:22:01 +01:00
Mira Grudzinska
ed3b17b228 svg_loader: preventing memcpy from a nullptr
In a case when a polygon/polyline had no points, there is nothing
to be copied.
2022-01-17 12:05:34 +09:00
Mira Grudzinska
04d3bb0ec0 svg_loader: fixing cyclic cloning of nodes
The reference node doesn't have to be placed inside the defs block,
so when refering to it, it is necessary to search the entire node tree.
In case of invalid svg file this can lead to circular references.
Added prevention against such a sutuation.
2022-01-17 12:03:57 +09:00
Mira Grudzinska
43e5644e8b svg_loader: fixing memleak
Memory was not freed before reallocation (grad->ref can be overwritten
without freeing memory first) - fixed.
2022-01-15 17:26:20 +01:00
Mira Grudzinska
6fb0984b49 svg_loader: postponed nodes properly cloned
In case when no defs tag was used, no child node was found.
Also the node attributes should not override those set in the ancestor.
2022-01-12 09:54:57 +01:00
Hermet Park
f0141e63de updated copyright date. 2022-01-12 14:08:48 +09:00
Mira Grudzinska
baf45823cb svg_loader: the color attribute properly inherited
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.
2022-01-11 14:04:39 +09:00
Mira Grudzinska
4b0037fe6a svg_loader: removing repeated lines
The clip-path and the mask attributes are both parsed in _attrParseGNode
function, which is called in th _attrParseUseNode.
2022-01-11 14:03:33 +09:00
Mira Grudzinska
333ff25c7e svg_loader: fix grad update
The grad update should be handled after the postponed nodes are cloned.
2022-01-11 13:56:14 +09:00
Mira Grudzinska
1f6c236fa3 svg_loader: preventing memory leak
A memory leak occured when the 'id' attribute was given multiple times
for a given gradient element. Fixed.
2022-01-11 13:55:21 +09:00
Mira Grudzinska
d3053777a8 svg_loader: typo fixed
_svgLoaderParerXmlClose -> _svgLoaderParserXmlClose
2022-01-08 00:39:21 +01:00
Mira Grudzinska
2f7e7e9923 svg_loader: mask-type attribute introduced
In an svg file the mask-type attribute can be specified.
It takes one of the two values: Luminosity or Alpha.
After the LumaMask is introduced into TVG, this attribute can be
properly read by the svg loader.
2022-01-07 12:45:34 +09:00
Hermet Park
1f5b66c256 svg_loader: ++robustness
prevent a crash with an exceptional handling.

@Issue: https://github.com/Samsung/thorvg/issues/1131
2022-01-06 13:40:00 +09:00
Mira Grudzinska
a6781734dc svg_loader: composite node splitted on mask and clip nodes
The SvgCompositeNode is replaced by the SvgMaskNode and SvgClipNode.
This is needed for using Luma/AlphaMask in the svg loader and in the future,
when we introduce other mask's features.
2022-01-03 12:30:01 +09:00
jykeon
bfaf26d99e svg_loader: Add nullptr check.
Signed-off-by: jykeon <jykeon@samsung.com>
2021-11-19 17:37:45 +09:00
Hermet Park
0fcdba8a4b common math: code refactoring
introduced mathZero(), mathEqual() for floating variables.
2021-11-15 17:10:54 +09:00
Mira Grudzinska
ed640630c1 svg_loader: mem properly freed
delete -> free
2021-11-12 10:46:53 +09:00
Mira Grudzinska
f3450e1760 svg_loader: memory properly released
delete->free
2021-11-11 21:49:13 +09:00