GNOME Bugzilla – Bug 764610
API: librsvg should provide a way to list sub element IDs
Last modified: 2017-12-13 18:17:38 UTC
Created attachment 325377 [details] [review] Add rsvg_handle_list() to gather sub element IDs The Rapicorn project has been shipping a modified version of librsvg for a long time. One of the reasons is the lack of an ability to list the sub element IDs of an SVG file to use exiting APIs correctly, like: rsvg_handle_render_cairo_sub() rsvg_handle_get_pixbuf_sub() rsvg_handle_get_dimensions_sub() rsvg_handle_get_position_sub() I'd suggest adding an API like GSList* rsvg_handle_list (RsvgHandle *handle); to fix this situation. An example patch is attached.
How would you use this API? The named elements are not necessarily renderable ones. For example, when filter primitives are referenced, or clip paths, etc.
(In reply to Federico Mena Quintero from comment #1) > How would you use this API? Individual elements in svg files can be referenced with '#element' syntax, e.g. in CSS or in a rendering context: foo.svg#element Here's the code Rapicorn uses: https://github.com/tim-janik/rapicorn/blob/a8a06328b19bec7ce6268e46ebb47acb3b30beee/rcore/svg.cc#L331 It allows rendering requests for "foo.svg#element" and will automatically pick variants thereof if those a are present. Examples for variants could be "foo.svg#element+insensitive" or #element.{small|medium|large}, etc. The way Rapicorn currently copes with the lack of this API is, it scans the SVG for all sorts of potential XML ids and brute force tests their presence with rsvg_handle_has_sub(): https://github.com/tim-janik/rapicorn/blob/a8a06328b19bec7ce6268e46ebb47acb3b30beee/rcore/svg.cc#L295 > The named elements are not necessarily > renderable ones. For example, when filter primitives are referenced, or > clip paths, etc. What elements exactly are referenced is up to the user. Conceivable examples also include path alterations before an SVG is rendered, and for any such actions the elements to be used or altered need to be referenced and depending on the reference scheme used enumeration may be needed.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/librsvg/issues/139.