Rename function to rsvg_defs_register_node_by_id()

To make it more clear that the "id" is the XML's id="foo" attribute.

Also, instead of the &something->super.super nonsense, use "self" or
simply "node" where available.
parent 28d00ade
......@@ -123,12 +123,16 @@ rsvg_defs_lookup (const RsvgDefs * defs, const char *name)
}
void
rsvg_defs_register_name (RsvgDefs * defs, const char *name, RsvgNode * val)
rsvg_defs_register_node_by_id (RsvgDefs *defs, const char *id, RsvgNode *node)
{
if (g_hash_table_lookup (defs->hash, name))
g_assert (defs != NULL);
g_assert (id != NULL);
g_assert (node != NULL);
if (g_hash_table_lookup (defs->hash, id))
return;
g_hash_table_insert (defs->hash, g_strdup (name), val);
g_hash_table_insert (defs->hash, g_strdup (id), node);
}
void
......
......@@ -42,7 +42,7 @@ RsvgNode *rsvg_defs_lookup (const RsvgDefs * defs, const char *name);
G_GNUC_INTERNAL
void rsvg_defs_free (RsvgDefs * defs);
G_GNUC_INTERNAL
void rsvg_defs_register_name (RsvgDefs * defs, const char *name, RsvgNode * val);
void rsvg_defs_register_node_by_id (RsvgDefs *defs, const char *id, RsvgNode *node);
G_GNUC_INTERNAL
void rsvg_defs_register_memory (RsvgDefs * defs, RsvgNode * val);
......
......@@ -799,7 +799,7 @@ rsvg_filter_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts)
if ((value = rsvg_property_bag_lookup (atts, "height")))
filter->height = _rsvg_css_parse_length (value, LENGTH_DIR_VERTICAL);
if ((value = rsvg_property_bag_lookup (atts, "id")))
rsvg_defs_register_name (ctx->priv->defs, value, &filter->super);
rsvg_defs_register_node_by_id (ctx->priv->defs, value, self);
}
}
......@@ -1041,7 +1041,7 @@ rsvg_filter_primitive_blend_set_atts (RsvgNode * node, RsvgHandle * ctx, RsvgPro
filter_primitive_set_x_y_width_height_atts ((RsvgFilterPrimitive *) filter, atts);
if ((value = rsvg_property_bag_lookup (atts, "id")))
rsvg_defs_register_name (ctx->priv->defs, value, &filter->super.super);
rsvg_defs_register_node_by_id (ctx->priv->defs, value, node);
}
}
......@@ -1277,7 +1277,7 @@ rsvg_filter_primitive_convolve_matrix_set_atts (RsvgNode * self,
filter->edgemode = 0;
}
if ((value = rsvg_property_bag_lookup (atts, "id")))
rsvg_defs_register_name (ctx->priv->defs, value, &filter->super.super);
rsvg_defs_register_node_by_id (ctx->priv->defs, value, self);
}
if ((gint64) listlen != (gint64) filter->orderx * filter->ordery)
......@@ -1946,7 +1946,7 @@ rsvg_filter_primitive_gaussian_blur_set_atts (RsvgNode * self,
if ((value = rsvg_property_bag_lookup (atts, "stdDeviation")))
rsvg_css_parse_number_optional_number (value, &filter->sdx, &filter->sdy);
if ((value = rsvg_property_bag_lookup (atts, "id")))
rsvg_defs_register_name (ctx->priv->defs, value, &filter->super.super);
rsvg_defs_register_node_by_id (ctx->priv->defs, value, self);
}
}
......@@ -2070,7 +2070,7 @@ rsvg_filter_primitive_offset_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPr
if ((value = rsvg_property_bag_lookup (atts, "dy")))
filter->dy = _rsvg_css_parse_length (value, LENGTH_DIR_VERTICAL);
if ((value = rsvg_property_bag_lookup (atts, "id")))
rsvg_defs_register_name (ctx->priv->defs, value, &filter->super.super);
rsvg_defs_register_node_by_id (ctx->priv->defs, value, self);
}
}
......@@ -2162,7 +2162,7 @@ rsvg_filter_primitive_merge_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPro
filter_primitive_set_x_y_width_height_atts ((RsvgFilterPrimitive *) filter, atts);
if ((value = rsvg_property_bag_lookup (atts, "id")))
rsvg_defs_register_name (ctx->priv->defs, value, &filter->super.super);
rsvg_defs_register_node_by_id (ctx->priv->defs, value, self);
}
}
......@@ -2381,7 +2381,7 @@ rsvg_filter_primitive_color_matrix_set_atts (RsvgNode * self, RsvgHandle * ctx,
type = 0;
}
if ((value = rsvg_property_bag_lookup (atts, "id")))
rsvg_defs_register_name (ctx->priv->defs, value, &filter->super.super);
rsvg_defs_register_node_by_id (ctx->priv->defs, value, self);
}
if (type == 0) {
......@@ -2670,7 +2670,7 @@ rsvg_filter_primitive_component_transfer_set_atts (RsvgNode * self, RsvgHandle *
filter_primitive_set_x_y_width_height_atts ((RsvgFilterPrimitive *) filter, atts);
if ((value = rsvg_property_bag_lookup (atts, "id")))
rsvg_defs_register_name (ctx->priv->defs, value, &filter->super.super);
rsvg_defs_register_node_by_id (ctx->priv->defs, value, self);
}
}
......@@ -2880,7 +2880,7 @@ rsvg_filter_primitive_erode_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPro
filter->mode = 1;
}
if ((value = rsvg_property_bag_lookup (atts, "id")))
rsvg_defs_register_name (ctx->priv->defs, value, &filter->super.super);
rsvg_defs_register_node_by_id (ctx->priv->defs, value, self);
}
}
......@@ -3115,7 +3115,7 @@ rsvg_filter_primitive_composite_set_atts (RsvgNode * self, RsvgHandle * ctx, Rsv
if ((value = rsvg_property_bag_lookup (atts, "k4")))
filter->k4 = g_ascii_strtod (value, NULL) * 255.;
if ((value = rsvg_property_bag_lookup (atts, "id")))
rsvg_defs_register_name (ctx->priv->defs, value, &filter->super.super);
rsvg_defs_register_node_by_id (ctx->priv->defs, value, self);
}
}
......@@ -3201,8 +3201,10 @@ rsvg_filter_primitive_flood_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPro
filter_primitive_set_x_y_width_height_atts ((RsvgFilterPrimitive *) filter, atts);
if ((value = rsvg_property_bag_lookup (atts, "id")))
rsvg_defs_register_name (ctx->priv->defs, id = value, &filter->super);
if ((value = rsvg_property_bag_lookup (atts, "id"))) {
id = value;
rsvg_defs_register_node_by_id (ctx->priv->defs, value, self);
}
rsvg_parse_style_attrs (ctx, self->state, "feFlood", NULL, id, atts);
}
}
......@@ -3390,7 +3392,7 @@ rsvg_filter_primitive_displacement_map_set_atts (RsvgNode * self, RsvgHandle * c
if ((value = rsvg_property_bag_lookup (atts, "scale")))
filter->scale = g_ascii_strtod (value, NULL);
if ((value = rsvg_property_bag_lookup (atts, "id")))
rsvg_defs_register_name (ctx->priv->defs, value, &filter->super.super);
rsvg_defs_register_node_by_id (ctx->priv->defs, value, self);
}
}
......@@ -3756,7 +3758,7 @@ rsvg_filter_primitive_turbulence_set_atts (RsvgNode * self, RsvgHandle * ctx,
if ((value = rsvg_property_bag_lookup (atts, "type")))
filter->bFractalSum = (!strcmp (value, "fractalNoise"));
if ((value = rsvg_property_bag_lookup (atts, "id")))
rsvg_defs_register_name (ctx->priv->defs, value, &filter->super.super);
rsvg_defs_register_node_by_id (ctx->priv->defs, value, self);
}
}
......@@ -3978,7 +3980,7 @@ rsvg_filter_primitive_image_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPro
filter_primitive_set_x_y_width_height_atts ((RsvgFilterPrimitive *) filter, atts);
if ((value = rsvg_property_bag_lookup (atts, "id")))
rsvg_defs_register_name (ctx->priv->defs, value, &filter->super.super);
rsvg_defs_register_node_by_id (ctx->priv->defs, value, self);
}
}
......@@ -4545,7 +4547,7 @@ rsvg_filter_primitive_diffuse_lighting_set_atts (RsvgNode * self, RsvgHandle * c
if ((value = rsvg_property_bag_lookup (atts, "surfaceScale")))
filter->surfaceScale = g_ascii_strtod (value, NULL);
if ((value = rsvg_property_bag_lookup (atts, "id")))
rsvg_defs_register_name (ctx->priv->defs, value, &filter->super.super);
rsvg_defs_register_node_by_id (ctx->priv->defs, value, self);
}
}
......@@ -4717,7 +4719,7 @@ rsvg_filter_primitive_specular_lighting_set_atts (RsvgNode * self, RsvgHandle *
if ((value = rsvg_property_bag_lookup (atts, "surfaceScale")))
filter->surfaceScale = g_ascii_strtod (value, NULL);
if ((value = rsvg_property_bag_lookup (atts, "id")))
rsvg_defs_register_name (ctx->priv->defs, value, &filter->super.super);
rsvg_defs_register_node_by_id (ctx->priv->defs, value, self);
}
}
......@@ -4827,7 +4829,7 @@ rsvg_filter_primitive_tile_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgProp
filter_primitive_set_x_y_width_height_atts ((RsvgFilterPrimitive *) filter, atts);
if ((value = rsvg_property_bag_lookup (atts, "id")))
rsvg_defs_register_name (ctx->priv->defs, value, &filter->super.super);
rsvg_defs_register_node_by_id (ctx->priv->defs, value, self);
}
}
......
......@@ -229,7 +229,7 @@ rsvg_node_image_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * a
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id"))) {
id = value;
rsvg_defs_register_name (ctx->priv->defs, id, &image->super);
rsvg_defs_register_node_by_id (ctx->priv->defs, id, self);
}
if ((value = rsvg_property_bag_lookup (atts, "preserveAspectRatio")))
image->preserve_aspect_ratio = rsvg_css_parse_aspect_ratio (value);
......
......@@ -62,7 +62,7 @@ rsvg_node_marker_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag *
if (rsvg_property_bag_size (atts)) {
if ((value = rsvg_property_bag_lookup (atts, "id"))) {
id = value;
rsvg_defs_register_name (ctx->priv->defs, id, &marker->super);
rsvg_defs_register_node_by_id (ctx->priv->defs, id, self);
}
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
......
......@@ -59,7 +59,7 @@ rsvg_mask_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts)
mask->height = _rsvg_css_parse_length (value, LENGTH_DIR_VERTICAL);
if ((value = rsvg_property_bag_lookup (atts, "id"))) {
id = value;
rsvg_defs_register_name (ctx->priv->defs, id, &mask->super);
rsvg_defs_register_node_by_id (ctx->priv->defs, id, self);
}
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
......@@ -119,7 +119,7 @@ rsvg_clip_path_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * at
}
if ((value = rsvg_property_bag_lookup (atts, "id"))) {
id = value;
rsvg_defs_register_name (ctx->priv->defs, id, &clip_path->super);
rsvg_defs_register_node_by_id (ctx->priv->defs, id, self);
}
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
......
......@@ -206,7 +206,7 @@ rsvg_linear_gradient_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBa
if (rsvg_property_bag_size (atts)) {
if ((value = rsvg_property_bag_lookup (atts, "id")))
rsvg_defs_register_name (ctx->priv->defs, value, self);
rsvg_defs_register_node_by_id (ctx->priv->defs, value, self);
if ((value = rsvg_property_bag_lookup (atts, "x1"))) {
grad->x1 = _rsvg_css_parse_length (value, LENGTH_DIR_HORIZONTAL);
grad->hasx1 = TRUE;
......@@ -289,7 +289,7 @@ rsvg_radial_gradient_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBa
if (rsvg_property_bag_size (atts)) {
if ((value = rsvg_property_bag_lookup (atts, "id")))
rsvg_defs_register_name (ctx->priv->defs, value, self);
rsvg_defs_register_node_by_id (ctx->priv->defs, value, self);
if ((value = rsvg_property_bag_lookup (atts, "cx"))) {
grad->cx = _rsvg_css_parse_length (value, LENGTH_DIR_HORIZONTAL);
grad->hascx = TRUE;
......@@ -378,7 +378,7 @@ rsvg_pattern_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts
if (rsvg_property_bag_size (atts)) {
if ((value = rsvg_property_bag_lookup (atts, "id")))
rsvg_defs_register_name (ctx->priv->defs, value, self);
rsvg_defs_register_node_by_id (ctx->priv->defs, value, self);
if ((value = rsvg_property_bag_lookup (atts, "viewBox"))) {
pattern->vbox = rsvg_css_parse_vbox (value);
pattern->hasvbox = TRUE;
......
......@@ -86,7 +86,7 @@ rsvg_node_path_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * at
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id"))) {
id = value;
rsvg_defs_register_name (ctx->priv->defs, value, self);
rsvg_defs_register_node_by_id (ctx->priv->defs, value, self);
}
rsvg_parse_style_attrs (ctx, self->state, "path", klazz, id, atts);
......@@ -137,7 +137,7 @@ _rsvg_node_poly_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * a
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id"))) {
id = value;
rsvg_defs_register_name (ctx->priv->defs, value, self);
rsvg_defs_register_node_by_id (ctx->priv->defs, id, self);
}
rsvg_parse_style_attrs (ctx, self->state,
......@@ -268,7 +268,7 @@ _rsvg_node_line_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * a
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id"))) {
id = value;
rsvg_defs_register_name (ctx->priv->defs, value, self);
rsvg_defs_register_node_by_id (ctx->priv->defs, id, self);
}
rsvg_parse_style_attrs (ctx, self->state, "line", klazz, id, atts);
......@@ -347,7 +347,7 @@ _rsvg_node_rect_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * a
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id"))) {
id = value;
rsvg_defs_register_name (ctx->priv->defs, value, self);
rsvg_defs_register_node_by_id (ctx->priv->defs, id, self);
}
rsvg_parse_style_attrs (ctx, self->state, "rect", klazz, id, atts);
......@@ -530,7 +530,7 @@ _rsvg_node_circle_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag *
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id"))) {
id = value;
rsvg_defs_register_name (ctx->priv->defs, value, self);
rsvg_defs_register_node_by_id (ctx->priv->defs, id, self);
}
rsvg_parse_style_attrs (ctx, self->state, "circle", klazz, id, atts);
......@@ -624,7 +624,7 @@ _rsvg_node_ellipse_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id"))) {
id = value;
rsvg_defs_register_name (ctx->priv->defs, value, self);
rsvg_defs_register_node_by_id (ctx->priv->defs, id, self);
}
rsvg_parse_style_attrs (ctx, self->state, "ellipse", klazz, id, atts);
......
......@@ -127,7 +127,7 @@ rsvg_node_group_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * a
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id"))) {
id = value;
rsvg_defs_register_name (ctx->priv->defs, value, self);
rsvg_defs_register_node_by_id (ctx->priv->defs, id, self);
}
rsvg_parse_style_attrs (ctx, self->state, "g", klazz, id, atts);
......@@ -332,7 +332,7 @@ rsvg_node_svg_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * att
if (self->parent && (value = rsvg_property_bag_lookup (atts, "y")))
svg->y = _rsvg_css_parse_length (value, LENGTH_DIR_VERTICAL);
if ((value = rsvg_property_bag_lookup (atts, "id"))) {
rsvg_defs_register_name (ctx->priv->defs, value, &svg->super);
rsvg_defs_register_node_by_id (ctx->priv->defs, value, self);
}
/*
* style element is not loaded yet here, so we need to store those attribues
......@@ -415,7 +415,7 @@ rsvg_node_use_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * att
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id"))) {
id = value;
rsvg_defs_register_name (ctx->priv->defs, value, &use->super);
rsvg_defs_register_node_by_id (ctx->priv->defs, id, self);
}
if ((value = rsvg_property_bag_lookup (atts, "xlink:href"))) {
g_free (use->link);
......@@ -455,7 +455,7 @@ rsvg_node_symbol_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag *
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id"))) {
id = value;
rsvg_defs_register_name (ctx->priv->defs, value, &symbol->super);
rsvg_defs_register_node_by_id (ctx->priv->defs, id, self);
}
if ((value = rsvg_property_bag_lookup (atts, "viewBox")))
symbol->vbox = rsvg_css_parse_vbox (value);
......
......@@ -158,7 +158,7 @@ _rsvg_node_text_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * a
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id"))) {
id = value;
rsvg_defs_register_name (ctx->priv->defs, value, self);
rsvg_defs_register_node_by_id (ctx->priv->defs, id, self);
}
rsvg_parse_style_attrs (ctx, self->state, "text", klazz, id, atts);
......@@ -402,7 +402,7 @@ _rsvg_node_tspan_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag *
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id"))) {
id = value;
rsvg_defs_register_name (ctx->priv->defs, value, self);
rsvg_defs_register_node_by_id (ctx->priv->defs, id, self);
}
rsvg_parse_style_attrs (ctx, self->state, "tspan", klazz, id, atts);
......@@ -479,7 +479,7 @@ _rsvg_node_tref_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * a
text->link = g_strdup (value);
}
if ((value = rsvg_property_bag_lookup (atts, "id")))
rsvg_defs_register_name (ctx->priv->defs, value, self);
rsvg_defs_register_node_by_id (ctx->priv->defs, value, self);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment