Node: store the element's id, or None.

We pass it everywhere to the construction functions now.

We'll use this for several things:  debugging, CSS cascading, etc.
parent a9f76253
......@@ -264,7 +264,7 @@ rsvg_filter_primitive_blend_set_atts (RsvgNode *node, gpointer impl, RsvgHandle
}
RsvgNode *
rsvg_new_filter_primitive_blend (const char *element_name, RsvgNode *parent)
rsvg_new_filter_primitive_blend (const char *element_name, RsvgNode *parent, const char *id)
{
RsvgFilterPrimitiveBlend *filter;
......@@ -277,6 +277,7 @@ rsvg_new_filter_primitive_blend (const char *element_name, RsvgNode *parent)
return rsvg_rust_cnode_new (RSVG_NODE_TYPE_FILTER_PRIMITIVE_BLEND,
parent,
id,
filter,
rsvg_filter_primitive_blend_set_atts,
rsvg_filter_primitive_blend_free);
......
......@@ -279,7 +279,7 @@ out:
}
RsvgNode *
rsvg_new_filter_primitive_color_matrix (const char *element_name, RsvgNode *parent)
rsvg_new_filter_primitive_color_matrix (const char *element_name, RsvgNode *parent, const char *id)
{
RsvgFilterPrimitiveColorMatrix *filter;
......@@ -291,6 +291,7 @@ rsvg_new_filter_primitive_color_matrix (const char *element_name, RsvgNode *pare
return rsvg_rust_cnode_new (RSVG_NODE_TYPE_FILTER_PRIMITIVE_COLOR_MATRIX,
parent,
id,
filter,
rsvg_filter_primitive_color_matrix_set_atts,
rsvg_filter_primitive_color_matrix_free);
......
......@@ -278,7 +278,7 @@ rsvg_filter_primitive_component_transfer_set_atts (RsvgNode *node, gpointer impl
}
RsvgNode *
rsvg_new_filter_primitive_component_transfer (const char *element_name, RsvgNode *parent)
rsvg_new_filter_primitive_component_transfer (const char *element_name, RsvgNode *parent, const char *id)
{
RsvgFilterPrimitiveComponentTransfer *filter;
......@@ -289,6 +289,7 @@ rsvg_new_filter_primitive_component_transfer (const char *element_name, RsvgNode
return rsvg_rust_cnode_new (RSVG_NODE_TYPE_FILTER_PRIMITIVE_COMPONENT_TRANSFER,
parent,
id,
filter,
rsvg_filter_primitive_component_transfer_set_atts,
rsvg_filter_primitive_free);
......@@ -380,7 +381,7 @@ rsvg_node_component_transfer_function_free (gpointer impl)
}
RsvgNode *
rsvg_new_node_component_transfer_function (const char *element_name, RsvgNode *parent)
rsvg_new_node_component_transfer_function (const char *element_name, RsvgNode *parent, const char *id)
{
RsvgNodeComponentTransferFunc *filter;
......@@ -406,6 +407,7 @@ rsvg_new_node_component_transfer_function (const char *element_name, RsvgNode *p
return rsvg_rust_cnode_new (RSVG_NODE_TYPE_COMPONENT_TRANFER_FUNCTION,
parent,
id,
filter,
rsvg_node_component_transfer_function_set_atts,
rsvg_node_component_transfer_function_free);
......
......@@ -343,7 +343,7 @@ out:
}
RsvgNode *
rsvg_new_filter_primitive_convolve_matrix (const char *element_name, RsvgNode *parent)
rsvg_new_filter_primitive_convolve_matrix (const char *element_name, RsvgNode *parent, const char *id)
{
RsvgFilterPrimitiveConvolveMatrix *filter;
......@@ -363,6 +363,7 @@ rsvg_new_filter_primitive_convolve_matrix (const char *element_name, RsvgNode *p
return rsvg_rust_cnode_new (RSVG_NODE_TYPE_FILTER_PRIMITIVE_CONVOLVE_MATRIX,
parent,
id,
filter,
rsvg_filter_primitive_convolve_matrix_set_atts,
rsvg_filter_primitive_convolve_matrix_free);
......
......@@ -196,7 +196,7 @@ rsvg_filter_primitive_diffuse_lighting_set_atts (RsvgNode *node, gpointer impl,
}
RsvgNode *
rsvg_new_filter_primitive_diffuse_lighting (const char *element_name, RsvgNode *parent)
rsvg_new_filter_primitive_diffuse_lighting (const char *element_name, RsvgNode *parent, const char *id)
{
RsvgFilterPrimitiveDiffuseLighting *filter;
......@@ -211,6 +211,7 @@ rsvg_new_filter_primitive_diffuse_lighting (const char *element_name, RsvgNode *
return rsvg_rust_cnode_new (RSVG_NODE_TYPE_FILTER_PRIMITIVE_DIFFUSE_LIGHTING,
parent,
id,
filter,
rsvg_filter_primitive_diffuse_lighting_set_atts,
rsvg_filter_primitive_free);
......
......@@ -223,7 +223,7 @@ rsvg_filter_primitive_displacement_map_set_atts (RsvgNode *node, gpointer impl,
}
RsvgNode *
rsvg_new_filter_primitive_displacement_map (const char *element_name, RsvgNode *parent)
rsvg_new_filter_primitive_displacement_map (const char *element_name, RsvgNode *parent, const char *id)
{
RsvgFilterPrimitiveDisplacementMap *filter;
......@@ -238,6 +238,7 @@ rsvg_new_filter_primitive_displacement_map (const char *element_name, RsvgNode *
return rsvg_rust_cnode_new (RSVG_NODE_TYPE_FILTER_PRIMITIVE_DISPLACEMENT_MAP,
parent,
id,
filter,
rsvg_filter_primitive_displacement_map_set_atts,
rsvg_filter_primitive_displacement_map_free);
......
......@@ -173,7 +173,7 @@ out:
}
RsvgNode *
rsvg_new_filter_primitive_erode (const char *element_name, RsvgNode *parent)
rsvg_new_filter_primitive_erode (const char *element_name, RsvgNode *parent, const char *id)
{
RsvgFilterPrimitiveErode *filter;
......@@ -187,6 +187,7 @@ rsvg_new_filter_primitive_erode (const char *element_name, RsvgNode *parent)
return rsvg_rust_cnode_new (RSVG_NODE_TYPE_FILTER_PRIMITIVE_ERODE,
parent,
id,
filter,
rsvg_filter_primitive_erode_set_atts,
rsvg_filter_primitive_free);
......
......@@ -108,7 +108,7 @@ rsvg_filter_primitive_flood_set_atts (RsvgNode *node, gpointer impl, RsvgHandle
}
RsvgNode *
rsvg_new_filter_primitive_flood (const char *element_name, RsvgNode *parent)
rsvg_new_filter_primitive_flood (const char *element_name, RsvgNode *parent, const char *id)
{
RsvgFilterPrimitive *filter;
......@@ -119,6 +119,7 @@ rsvg_new_filter_primitive_flood (const char *element_name, RsvgNode *parent)
return rsvg_rust_cnode_new (RSVG_NODE_TYPE_FILTER_PRIMITIVE_FLOOD,
parent,
id,
filter,
rsvg_filter_primitive_flood_set_atts,
rsvg_filter_primitive_free);
......
......@@ -681,7 +681,7 @@ out:
}
RsvgNode *
rsvg_new_filter_primitive_gaussian_blur (const char *element_name, RsvgNode *parent)
rsvg_new_filter_primitive_gaussian_blur (const char *element_name, RsvgNode *parent, const char *id)
{
RsvgFilterPrimitiveGaussianBlur *filter;
......@@ -694,6 +694,7 @@ rsvg_new_filter_primitive_gaussian_blur (const char *element_name, RsvgNode *par
return rsvg_rust_cnode_new (RSVG_NODE_TYPE_FILTER_PRIMITIVE_GAUSSIAN_BLUR,
parent,
id,
filter,
rsvg_filter_primitive_gaussian_blur_set_atts,
rsvg_filter_primitive_free);
......
......@@ -247,7 +247,7 @@ rsvg_filter_primitive_image_set_atts (RsvgNode *node, gpointer impl, RsvgHandle
}
RsvgNode *
rsvg_new_filter_primitive_image (const char *element_name, RsvgNode *parent)
rsvg_new_filter_primitive_image (const char *element_name, RsvgNode *parent, const char *id)
{
RsvgFilterPrimitiveImage *filter;
......@@ -259,6 +259,7 @@ rsvg_new_filter_primitive_image (const char *element_name, RsvgNode *parent)
return rsvg_rust_cnode_new (RSVG_NODE_TYPE_FILTER_PRIMITIVE_IMAGE,
parent,
id,
filter,
rsvg_filter_primitive_image_set_atts,
rsvg_filter_primitive_image_free);
......
......@@ -446,7 +446,7 @@ find_light_source_in_children (RsvgNode *node)
}
RsvgNode *
rsvg_new_node_light_source (const char *element_name, RsvgNode *parent)
rsvg_new_node_light_source (const char *element_name, RsvgNode *parent, const char *id)
{
RsvgNodeLightSource *data;
......@@ -467,6 +467,7 @@ rsvg_new_node_light_source (const char *element_name, RsvgNode *parent)
return rsvg_rust_cnode_new (RSVG_NODE_TYPE_LIGHT_SOURCE,
parent,
id,
data,
rsvg_node_light_source_set_atts,
g_free);
......
......@@ -128,7 +128,7 @@ rsvg_filter_primitive_merge_set_atts (RsvgNode *node, gpointer impl, RsvgHandle
}
RsvgNode *
rsvg_new_filter_primitive_merge (const char *element_name, RsvgNode *parent)
rsvg_new_filter_primitive_merge (const char *element_name, RsvgNode *parent, const char *id)
{
RsvgFilterPrimitiveMerge *filter;
......@@ -138,6 +138,7 @@ rsvg_new_filter_primitive_merge (const char *element_name, RsvgNode *parent)
return rsvg_rust_cnode_new (RSVG_NODE_TYPE_FILTER_PRIMITIVE_MERGE,
parent,
id,
filter,
rsvg_filter_primitive_merge_set_atts,
rsvg_filter_primitive_free);
......@@ -176,7 +177,7 @@ rsvg_filter_primitive_merge_node_render (RsvgNode *node, RsvgComputedValues *val
}
RsvgNode *
rsvg_new_filter_primitive_merge_node (const char *element_name, RsvgNode *parent)
rsvg_new_filter_primitive_merge_node (const char *element_name, RsvgNode *parent, const char *id)
{
RsvgFilterPrimitive *filter;
......@@ -186,6 +187,7 @@ rsvg_new_filter_primitive_merge_node (const char *element_name, RsvgNode *parent
return rsvg_rust_cnode_new (RSVG_NODE_TYPE_FILTER_PRIMITIVE_MERGE_NODE,
parent,
id,
filter,
rsvg_filter_primitive_merge_node_set_atts,
rsvg_filter_primitive_free);
......
......@@ -199,7 +199,7 @@ rsvg_filter_primitive_specular_lighting_set_atts (RsvgNode *node, gpointer impl,
}
RsvgNode *
rsvg_new_filter_primitive_specular_lighting (const char *element_name, RsvgNode *parent)
rsvg_new_filter_primitive_specular_lighting (const char *element_name, RsvgNode *parent, const char *id)
{
RsvgFilterPrimitiveSpecularLighting *filter;
......@@ -213,6 +213,7 @@ rsvg_new_filter_primitive_specular_lighting (const char *element_name, RsvgNode
return rsvg_rust_cnode_new (RSVG_NODE_TYPE_FILTER_PRIMITIVE_SPECULAR_LIGHTING,
parent,
id,
filter,
rsvg_filter_primitive_specular_lighting_set_atts,
rsvg_filter_primitive_free);
......
......@@ -142,7 +142,7 @@ rsvg_filter_primitive_tile_set_atts (RsvgNode *node, gpointer impl, RsvgHandle *
}
RsvgNode *
rsvg_new_filter_primitive_tile (const char *element_name, RsvgNode *parent)
rsvg_new_filter_primitive_tile (const char *element_name, RsvgNode *parent, const char *id)
{
RsvgFilterPrimitiveTile *filter;
......@@ -153,6 +153,7 @@ rsvg_new_filter_primitive_tile (const char *element_name, RsvgNode *parent)
return rsvg_rust_cnode_new (RSVG_NODE_TYPE_FILTER_PRIMITIVE_TILE,
parent,
id,
filter,
rsvg_filter_primitive_tile_set_atts,
rsvg_filter_primitive_free);
......
......@@ -407,7 +407,7 @@ out:
}
RsvgNode *
rsvg_new_filter_primitive_turbulence (const char *element_name, RsvgNode *parent)
rsvg_new_filter_primitive_turbulence (const char *element_name, RsvgNode *parent, const char *id)
{
RsvgFilterPrimitiveTurbulence *filter;
......@@ -427,6 +427,7 @@ rsvg_new_filter_primitive_turbulence (const char *element_name, RsvgNode *parent
return rsvg_rust_cnode_new (RSVG_NODE_TYPE_FILTER_PRIMITIVE_TURBULENCE,
parent,
id,
filter,
rsvg_filter_primitive_turbulence_set_atts,
rsvg_filter_primitive_free);
......
......@@ -66,47 +66,47 @@ G_GNUC_INTERNAL
RsvgNode *rsvg_new_filter (const char *element_name, RsvgNode *parent);
G_GNUC_INTERNAL
RsvgNode *rsvg_new_filter_primitive_blend (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_new_filter_primitive_blend (const char *element_name, RsvgNode *parent, const char *id);
G_GNUC_INTERNAL
RsvgNode *rsvg_new_filter_primitive_convolve_matrix (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_new_filter_primitive_convolve_matrix (const char *element_name, RsvgNode *parent, const char *id);
G_GNUC_INTERNAL
RsvgNode *rsvg_new_filter_primitive_gaussian_blur (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_new_filter_primitive_gaussian_blur (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/filters/offset.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_new_filter_primitive_offset (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_new_filter_primitive_offset (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/filters/composite.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_new_filter_primitive_composite (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_new_filter_primitive_composite (const char *element_name, RsvgNode *parent, const char *id);
G_GNUC_INTERNAL
RsvgNode *rsvg_new_filter_primitive_merge (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_new_filter_primitive_merge (const char *element_name, RsvgNode *parent, const char *id);
G_GNUC_INTERNAL
RsvgNode *rsvg_new_filter_primitive_merge_node (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_new_filter_primitive_merge_node (const char *element_name, RsvgNode *parent, const char *id);
G_GNUC_INTERNAL
RsvgNode *rsvg_new_filter_primitive_color_matrix (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_new_filter_primitive_color_matrix (const char *element_name, RsvgNode *parent, const char *id);
G_GNUC_INTERNAL
RsvgNode *rsvg_new_filter_primitive_component_transfer (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_new_filter_primitive_component_transfer (const char *element_name, RsvgNode *parent, const char *id);
G_GNUC_INTERNAL
RsvgNode *rsvg_new_node_component_transfer_function (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_new_node_component_transfer_function (const char *element_name, RsvgNode *parent, const char *id);
G_GNUC_INTERNAL
RsvgNode *rsvg_new_filter_primitive_erode (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_new_filter_primitive_erode (const char *element_name, RsvgNode *parent, const char *id);
G_GNUC_INTERNAL
RsvgNode *rsvg_new_filter_primitive_flood (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_new_filter_primitive_flood (const char *element_name, RsvgNode *parent, const char *id);
G_GNUC_INTERNAL
RsvgNode *rsvg_new_filter_primitive_displacement_map (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_new_filter_primitive_displacement_map (const char *element_name, RsvgNode *parent, const char *id);
G_GNUC_INTERNAL
RsvgNode *rsvg_new_filter_primitive_turbulence (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_new_filter_primitive_turbulence (const char *element_name, RsvgNode *parent, const char *id);
G_GNUC_INTERNAL
RsvgNode *rsvg_new_filter_primitive_image (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_new_filter_primitive_image (const char *element_name, RsvgNode *parent, const char *id);
G_GNUC_INTERNAL
RsvgNode *rsvg_new_filter_primitive_diffuse_lighting (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_new_filter_primitive_diffuse_lighting (const char *element_name, RsvgNode *parent, const char *id);
G_GNUC_INTERNAL
RsvgNode *rsvg_new_node_light_source (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_new_node_light_source (const char *element_name, RsvgNode *parent, const char *id);
G_GNUC_INTERNAL
RsvgNode *rsvg_new_filter_primitive_specular_lighting (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_new_filter_primitive_specular_lighting (const char *element_name, RsvgNode *parent, const char *id);
G_GNUC_INTERNAL
RsvgNode *rsvg_new_filter_primitive_tile (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_new_filter_primitive_tile (const char *element_name, RsvgNode *parent, const char *id);
G_END_DECLS
......
......@@ -292,33 +292,31 @@ free_element_name_stack (RsvgLoad *load)
}
static void
node_set_atts (RsvgNode *node,
RsvgHandle *handle,
const char *element_name,
gboolean supports_class_attribute,
RsvgPropertyBag atts)
get_id_and_class (RsvgPropertyBag atts,
const char **out_id,
const char **out_class)
{
RsvgPropertyBagIter *iter;
const char *key;
RsvgAttribute attr;
const char *value;
g_assert (out_id != NULL);
g_assert (out_class != NULL);
const char *id = NULL;
const char *klazz = NULL;
*out_id = NULL;
*out_class = NULL;
iter = rsvg_property_bag_iter_begin (atts);
while (rsvg_property_bag_iter_next (iter, &key, &attr, &value)) {
switch (attr) {
case RSVG_ATTRIBUTE_ID:
id = value;
rsvg_defs_register_node_by_id (handle->priv->defs, id, node);
*out_id = value;
break;
case RSVG_ATTRIBUTE_CLASS:
if (supports_class_attribute) {
klazz = value;
}
*out_class = value;
break;
default:
......@@ -327,6 +325,18 @@ node_set_atts (RsvgNode *node,
}
rsvg_property_bag_iter_end (iter);
}
static void
node_set_atts (RsvgNode *node,
RsvgHandle *handle,
const char *element_name,
const char *node_id,
const char *node_class,
RsvgPropertyBag atts)
{
if (node_id != NULL)
rsvg_defs_register_node_by_id (handle->priv->defs, node_id, node);
rsvg_node_set_atts (node, handle, atts);
......@@ -335,7 +345,7 @@ node_set_atts (RsvgNode *node,
* rsvg_node_svg_apply_atts()
*/
if (rsvg_node_get_type (node) != RSVG_NODE_TYPE_SVG) {
rsvg_parse_style_attrs (handle, node, element_name, klazz, id, atts);
rsvg_parse_style_attrs (handle, node, element_name, node_class, node_id, atts);
}
rsvg_node_set_overriden_properties (node);
......@@ -344,10 +354,14 @@ node_set_atts (RsvgNode *node,
static void
standard_element_start (RsvgLoad *load, const char *name, RsvgPropertyBag * atts)
{
gboolean supports_class_attribute;
RsvgNode *newnode;
newnode = rsvg_load_new_node(name, load->currentnode, &supports_class_attribute);
const char *node_id;
const char *node_class;
gboolean supports_class_attribute;
get_id_and_class (atts, &node_id, &node_class);
newnode = rsvg_load_new_node(name, load->currentnode, node_id, &supports_class_attribute);
g_assert (newnode != NULL);
g_assert (rsvg_node_get_type (newnode) != RSVG_NODE_TYPE_INVALID);
......@@ -365,7 +379,11 @@ standard_element_start (RsvgLoad *load, const char *name, RsvgPropertyBag * atts
load->currentnode = rsvg_node_ref (newnode);
node_set_atts (newnode, load->handle, name, supports_class_attribute, atts);
if (!supports_class_attribute) {
node_class = NULL;
}
node_set_atts (newnode, load->handle, name, node_id, node_class, atts);
newnode = rsvg_node_unref (newnode);
}
......
......@@ -281,6 +281,7 @@ typedef void (* CNodeFree) (gpointer impl);
G_GNUC_INTERNAL
RsvgNode *rsvg_rust_cnode_new (RsvgNodeType node_type,
RsvgNode *parent,
const char *id,
gpointer impl,
CNodeSetAtts set_atts_fn,
CNodeFree free_fn) G_GNUC_WARN_UNUSED_RESULT;
......
......@@ -36,39 +36,39 @@ G_BEGIN_DECLS
/* Implemented in rust/src/load.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_load_new_node (const char *element_name, RsvgNode *parent, gboolean *supports_class_attribute);
RsvgNode *rsvg_load_new_node (const char *element_name, RsvgNode *parent, const char *id, gboolean *supports_class_attribute);
/* Implemented in rust/src/structure.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_group_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_group_new (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/link.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_link_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_link_new (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/structure.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_defs_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_defs_new (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/structure.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_switch_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_switch_new (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/structure.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_svg_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_svg_new (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/structure.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_use_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_use_new (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/structure.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_symbol_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_symbol_new (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/image.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_image_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_image_new (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/structure.rs */
G_GNUC_INTERNAL
......@@ -84,71 +84,71 @@ void rsvg_node_svg_apply_atts (RsvgNode *node, RsvgHandle *handle);
/* Implemented in rust/src/text.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_text_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_text_new (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/text.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_tref_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_tref_new (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/text.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_tspan_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_tspan_new (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/marker.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_marker_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_marker_new (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/gradient.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_linear_gradient_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_linear_gradient_new (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/gradient.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_radial_gradient_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_radial_gradient_new (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/pattern.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_pattern_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_pattern_new (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/stop.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_stop_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_stop_new (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/mask.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_mask_new (const char *element_name, RsvgNode *node);
RsvgNode *rsvg_node_mask_new (const char *element_name, RsvgNode *node, const char *id);
/* Implemented in rust/src/clip_path.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_clip_path_new (const char *element_name, RsvgNode *node);
RsvgNode *rsvg_node_clip_path_new (const char *element_name, RsvgNode *node, const char *id);
/* Implemented in rust/src/shapes.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_path_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_path_new (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/shapes.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_polygon_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_polygon_new (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/shapes.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_polyline_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_polyline_new (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/shapes.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_line_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_line_new (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/shapes.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_rect_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_rect_new (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/shapes.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_circle_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_circle_new (const char *element_name, RsvgNode *parent, const char *id);
/* Implemented in rust/src/shapes.rs */
G_GNUC_INTERNAL
RsvgNode *rsvg_node_ellipse_new (const char *element_name, RsvgNode *parent);
RsvgNode *rsvg_node_ellipse_new (const char *element_name, RsvgNode *parent, const char *id);
G_END_DECLS
......
......@@ -10,6 +10,7 @@ use handle::RsvgHandle;
use node::{boxed_node_new, NodeResult, NodeTrait, NodeType, RsvgNode};
use parsers::parse;
use property_bag::PropertyBag;
use util::utf8_cstr_opt;
coord_units!(ClipPathUnits, CoordUnits::UserSpaceOnUse);
......@@ -89,10 +90,12 @@ impl NodeTrait for NodeClipPath {
pub extern "C" fn rsvg_node_clip_path_new(
_: *const libc::c_char,
raw_parent: *const RsvgNode,
id: *const libc::c_char,
) -> *const RsvgNode {
boxed_node_new(
NodeType::ClipPath,
raw_parent,
unsafe { utf8_cstr_opt(id) },
Box::new(NodeClipPath::new()),
)
}
use libc;
use std::rc::*;
use handle::*;
use node::*;
use property_bag::PropertyBag;
use state::rsvg_state_new;
use std::rc::*;
use util::utf8_cstr_opt;
type CNodeSetAtts = unsafe extern "C" fn(
node: *const RsvgNode,
......@@ -56,6 +59,7 @@ impl Drop for CNode {
pub extern "C" fn rsvg_rust_cnode_new(
node_type: NodeType,
raw_parent: *const RsvgNode,
id: *const libc::c_char,
c_node_impl: *const RsvgCNodeImpl,
set_atts_fn: CNodeSetAtts,
free_fn: CNodeFree,
......@@ -71,6 +75,7 @@ pub extern "C" fn rsvg_rust_cnode_new(
box_node(Rc::new(Node::new(
node_type,
node_ptr_to_weak(raw_parent),
unsafe { utf8_cstr_opt(id) },
rsvg_state_new(),
Box::new(cnode),
)))
......
use std::cell::{Cell, RefCell};
use cairo::{self, ImageSurface};
use libc::c_char;
use libc::{self, c_char};
use attributes::Attribute;
use error::{AttributeError, NodeError};
......@@ -10,7 +10,7 @@ use node::{boxed_node_new, NodeResult, NodeTrait, NodeType, RsvgCNodeImpl, RsvgN
use parsers::{self, parse, Parse};
use property_bag::PropertyBag;
use srgb::{linearize_surface, unlinearize_surface};
use util::clamp;
use util::{clamp, utf8_cstr_opt};
use super::context::{FilterContext, FilterOutput, FilterResult};
use super::input::Input;
......@@ -233,7 +233,13 @@ impl From<Operator> for cairo::Operator {
pub unsafe extern "C" fn rsvg_new_filter_primitive_composite(
_element_name: *const c_char,
parent: *mut RsvgNode,
id: *const libc::c_char,
) -> *mut RsvgNode {
let filter = Composite::new();
boxed_node_new(NodeType::FilterPrimitiveComposite, parent, Box::new(filter))
boxed_node_new(
NodeType::FilterPrimitiveComposite,
parent,
utf8_cstr_opt(id),
Box::new(filter),
)
}
......@@ -10,6 +10,7 @@ use length::{LengthDir, RsvgLength};
use node::{boxed_node_new, NodeResult, NodeTrait, NodeType, RsvgNode};
use parsers::{parse, Parse};
use property_bag::PropertyBag;
use util::utf8_cstr_opt;
/// The <filter> node.
pub struct NodeFilter {
......@@ -74,6 +75,12 @@ impl NodeTrait for NodeFilter {
pub extern "C" fn rsvg_new_filter(
_: *const libc::c_char,
raw_parent: *const RsvgNode,
id: *const libc::c_char,
) -> *const RsvgNode {
boxed_node_new(NodeType::Filter, raw_parent, Box::new(NodeFilter::new()))
boxed_node_new(
NodeType::Filter,
raw_parent,
unsafe { utf8_cstr_opt(id) },