Add node iteration API for the C code
#229 (closed) added a Node.children()
which returns an iterator over the node's children, which works very well for the Rust code.
However, we still keep Node.foreach_child()
around, so that rsvg_node_foreach_child()
can use it and be exported to the C code. This is a very clunky API:
-
The call in rsvg-base.c is to find a
NodeChars
that we can use to append character data from the XML stream. See the comment infind_last_chars_node_foreach()
for how it operates: it needs to find the lastNodeChars
among the children, unless there is atspan
after it. This is easy to translate to iteration, and would be even easier if we could iterate backwards from the last child. -
There are various uses in
rsvg-filter.c
. The one used to find a light source needs to find the last node that is in fact a light source.
Etc. The other uses are either simple (the callback always returns true
= "keep looking"), or could equally be done more simply with iteration.
We already export an iteration API for C in property-bag.rs
- example use.
It would be nice to have these
-
rsvg_node_children_iter_begin()
/next() -> gboolean
/end()
-
Replace all uses rsvg_node_foreach_child()
-
Remove Node.foreach_child()
completely.