Commit cf2e610b authored by Caleb Michael Moore's avatar Caleb Michael Moore

more DOM stuff

parent e3a24a0f
2005-05-16 Caleb Moore <c.moore@student.unsw.edu.au>
* rsvg-filter.c, rsvg-structure.c, rsvg-mask.c, rsvg.c: more DOM stuff. Now orthodox nodes are created, then attributes are assigned then are packed onto the top of the tree. I have moved all conforming node creation bits to rsvg-filter-handler-start so I remember what's left to convert. Probably opened a few bugs, you know how it is. Theoretically, it is now possible to implement external DOM interfaces to create new nodes and add nodes to other nodes. Attributes can be edited as much as the user wants for many elements now.
2005-05-14 Dom Lachowicz <cinamod@hotmail.com>
* rsvg-filter.c: Bug 302905
......
......@@ -106,14 +106,14 @@ ArtSVP *
rsvg_art_clip_path_render (RsvgClipPath * self, RsvgDrawingCtx *ctx)
{
RsvgState *state = rsvg_state_current (ctx);
RsvgNodeGroup *group = (RsvgNodeGroup*)self;
RsvgClipPath *group = (RsvgClipPath*)self;
guint i;
ArtSVP *svp;
RsvgArtSVPRender * asvpr;
RsvgRender * save;
rsvg_state_reinherit_top(ctx, self->super.super.state, 0);
rsvg_state_reinherit_top(ctx, self->super.state, 0);
if (self->units == objectBoundingBox)
{
......@@ -154,9 +154,6 @@ rsvg_art_mask_render (RsvgMask *self, GdkPixbuf *tos, GdkPixbuf *nos, RsvgDrawin
int x, y;
GdkPixbuf *save, *mask;
RsvgNode *drawable;
drawable = (RsvgNode*)self;
mask = _rsvg_pixbuf_new_cleared(GDK_COLORSPACE_RGB, 1, 8,
gdk_pixbuf_get_width(tos),
......@@ -166,7 +163,7 @@ rsvg_art_mask_render (RsvgMask *self, GdkPixbuf *tos, GdkPixbuf *nos, RsvgDrawin
((RsvgArtRender *)ctx->render)->pixbuf = mask;
rsvg_state_push(ctx);
rsvg_node_draw (drawable, ctx, 0);
rsvg_node_mask_draw (self, ctx, 0);
rsvg_state_pop(ctx);
((RsvgArtRender *)ctx->render)->pixbuf = save;
......
This diff is collapsed.
......@@ -46,7 +46,7 @@ void
rsvg_filter_render (RsvgFilter *self, GdkPixbuf *source, GdkPixbuf *output, GdkPixbuf *bg, RsvgDrawingCtx *context);
RsvgNode *
rsvg_start_filter (RsvgHandle *ctx, RsvgPropertyBag *atts);
rsvg_new_filter (void);
void
rsvg_end_filter (RsvgHandle *ctx);
......@@ -55,66 +55,63 @@ RsvgFilter *
rsvg_filter_parse (const RsvgDefs *defs, const char *str);
RsvgNode *
rsvg_start_filter_primitive_blend (RsvgHandle *ctx, RsvgPropertyBag *atts);
rsvg_new_filter_primitive_blend (void);
RsvgNode *
rsvg_start_filter_primitive_convolve_matrix (RsvgHandle *ctx, RsvgPropertyBag *atts);
rsvg_new_filter_primitive_convolve_matrix (void);
RsvgNode *
rsvg_start_filter_primitive_gaussian_blur (RsvgHandle *ctx, RsvgPropertyBag *atts);
rsvg_new_filter_primitive_gaussian_blur (void);
RsvgNode *
rsvg_start_filter_primitive_offset (RsvgHandle *ctx, RsvgPropertyBag *atts);
rsvg_new_filter_primitive_offset (void);
RsvgNode *
rsvg_start_filter_primitive_merge (RsvgHandle *ctx, RsvgPropertyBag *atts);
rsvg_new_filter_primitive_merge (void);
void
rsvg_start_filter_primitive_merge_node (RsvgHandle *ctx, RsvgPropertyBag *atts);
RsvgNode *
rsvg_start_filter_primitive_colour_matrix (RsvgHandle *ctx, RsvgPropertyBag *atts);
rsvg_new_filter_primitive_colour_matrix (void);
RsvgNode *
rsvg_start_filter_primitive_component_transfer (RsvgHandle * ctx,
RsvgPropertyBag * atts);
rsvg_new_filter_primitive_component_transfer (void);
void
rsvg_start_filter_primitive_component_transfer_function (RsvgHandle * ctx,
RsvgPropertyBag * atts, char channel);
RsvgNode *
rsvg_start_filter_primitive_erode (RsvgHandle * ctx,
RsvgPropertyBag * atts);
rsvg_new_filter_primitive_erode (void);
RsvgNode *
rsvg_start_filter_primitive_composite (RsvgHandle * ctx, RsvgPropertyBag * atts);
rsvg_new_filter_primitive_composite (void);
RsvgNode *
rsvg_start_filter_primitive_flood (RsvgHandle * ctx,
RsvgPropertyBag * atts);
rsvg_new_filter_primitive_flood (void);
RsvgNode *
rsvg_start_filter_primitive_displacement_map (RsvgHandle * ctx, RsvgPropertyBag * atts);
rsvg_new_filter_primitive_displacement_map (void);
RsvgNode *
rsvg_start_filter_primitive_turbulence (RsvgHandle * ctx, RsvgPropertyBag * atts);
rsvg_new_filter_primitive_turbulence (void);
RsvgNode *
rsvg_start_filter_primitive_image (RsvgHandle * ctx, RsvgPropertyBag * atts);
rsvg_new_filter_primitive_image (void);
RsvgNode *
rsvg_start_filter_primitive_diffuse_lighting (RsvgHandle * ctx, RsvgPropertyBag * atts);
rsvg_new_filter_primitive_diffuse_lighting (void);
void
rsvg_start_filter_primitive_light_source (RsvgHandle * ctx,
RsvgPropertyBag * atts, char type);
RsvgNode *
rsvg_start_filter_primitive_specular_lighting (RsvgHandle * ctx, RsvgPropertyBag * atts);
rsvg_new_filter_primitive_specular_lighting (void);
RsvgNode *
rsvg_start_filter_primitive_tile (RsvgHandle * ctx, RsvgPropertyBag * atts);
rsvg_new_filter_primitive_tile (void);
void
rsvg_filter_adobe_blend(gint modenum, GdkPixbuf *in, GdkPixbuf *bg, GdkPixbuf *output,
......
......@@ -32,20 +32,19 @@ static void
rsvg_mask_free (RsvgNode * self)
{
RsvgMask *z = (RsvgMask *)self;
g_ptr_array_free(z->super.children, TRUE);
rsvg_state_finalize (z->super.super.state);
g_free(z->super.super.state);
g_ptr_array_free(z->children, TRUE);
rsvg_state_finalize (z->super.state);
g_free(z->super.state);
g_free (z);
}
static void
rsvg_node_mask_draw (RsvgNode * self, RsvgDrawingCtx *ctx,
int dominate)
void
rsvg_node_mask_draw (RsvgMask *group, RsvgDrawingCtx *ctx,
int dominate)
{
RsvgNodeGroup *group = (RsvgNodeGroup*)self;
guint i;
rsvg_state_reinherit_top(ctx, self->state, 0);
rsvg_state_reinherit_top(ctx, group->super.state, 0);
rsvg_push_discrete_layer (ctx);
......@@ -53,8 +52,7 @@ rsvg_node_mask_draw (RsvgNode * self, RsvgDrawingCtx *ctx,
{
rsvg_state_push(ctx);
rsvg_node_draw (g_ptr_array_index(group->children, i),
ctx, 0);
rsvg_node_draw (g_ptr_array_index(group->children, i), ctx, 0);
rsvg_state_pop(ctx);
}
......@@ -62,37 +60,15 @@ rsvg_node_mask_draw (RsvgNode * self, RsvgDrawingCtx *ctx,
rsvg_pop_discrete_layer (ctx);
}
static RsvgMask *
rsvg_new_mask (void)
{
RsvgMask *mask;
mask = g_new (RsvgMask, 1);
mask->maskunits = objectBoundingBox;
mask->contentunits = userSpaceOnUse;
mask->x = 0;
mask->y = 0;
mask->width = 1;
mask->height = 1;
mask->super.super.state = g_new(RsvgState, 1);
mask->super.children = g_ptr_array_new ();
mask->super.super.type = RSVG_NODE_MASK;
mask->super.super.free = rsvg_mask_free;
mask->super.super.draw = rsvg_node_mask_draw;
mask->super.super.add_child = rsvg_node_group_add_child;
return mask;
}
void
rsvg_start_mask (RsvgHandle *ctx, RsvgPropertyBag *atts)
static void
rsvg_mask_set_atts (RsvgNode * self, RsvgHandle *ctx, RsvgPropertyBag *atts)
{
const char *id = NULL, *klazz = NULL, *value;
RsvgMask *mask;
double font_size;
font_size = rsvg_state_current_font_size (ctx);
mask = rsvg_new_mask ();
mask = (RsvgMask *)self;
if (rsvg_property_bag_size (atts))
{
......@@ -133,22 +109,55 @@ rsvg_start_mask (RsvgHandle *ctx, RsvgPropertyBag *atts)
rsvg_css_parse_normalized_length (value,
ctx->dpi_y,
1,
font_size);
font_size);
if ((value = rsvg_property_bag_lookup (atts, "id")))
id = value;
{
id = value;
rsvg_defs_register_name(ctx->defs, id, &mask->super);
}
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
}
rsvg_parse_style_attrs (ctx, mask->super.state, "mask", klazz, id, atts);
}
rsvg_state_init(mask->super.super.state);
rsvg_parse_style_attrs (ctx, mask->super.super.state, "mask", klazz, id, atts);
mask->super.super.parent = (RsvgNode *)ctx->currentnode;
static void
rsvg_mask_add_child (RsvgNode *overself, RsvgNode *child)
{
RsvgMask *self = (RsvgMask *)overself;
if (self == NULL)
return;
g_ptr_array_add(self->children, child);
}
ctx->currentnode = &mask->super.super;
static void
rsvg_draw_nothing (RsvgNode * self, RsvgDrawingCtx *ctx,
int dominate)
{
}
rsvg_defs_set (ctx->defs, id, &mask->super.super);
RsvgNode *
rsvg_new_mask (void)
{
RsvgMask *mask;
mask = g_new (RsvgMask, 1);
mask->maskunits = objectBoundingBox;
mask->contentunits = userSpaceOnUse;
mask->x = 0;
mask->y = 0;
mask->width = 1;
mask->height = 1;
mask->super.state = g_new(RsvgState, 1);
rsvg_state_init(mask->super.state);
mask->children = g_ptr_array_new ();
mask->super.type = RSVG_NODE_MASK;
mask->super.free = rsvg_mask_free;
mask->super.draw = rsvg_draw_nothing;
mask->super.add_child = rsvg_mask_add_child;
mask->super.set_atts = rsvg_mask_set_atts;
return &mask->super;
}
void
......@@ -191,36 +200,21 @@ static void
rsvg_clip_path_free (RsvgNode * self)
{
RsvgClipPath *z = (RsvgClipPath *)self;
g_ptr_array_free(z->super.children, TRUE);
rsvg_state_finalize (z->super.super.state);
g_free(z->super.super.state);
g_ptr_array_free(z->children, TRUE);
rsvg_state_finalize (z->super.state);
g_free(z->super.state);
g_free (z);
}
static RsvgClipPath *
rsvg_new_clip_path (void)
{
RsvgClipPath *clip_path;
clip_path = g_new (RsvgClipPath, 1);
clip_path->super.children = g_ptr_array_new ();
clip_path->units = userSpaceOnUse;
clip_path->super.super.state = g_new(RsvgState, 1);
clip_path->super.super.type = RSVG_NODE_CLIP_PATH;
clip_path->super.super.free = rsvg_clip_path_free;
clip_path->super.super.add_child = rsvg_node_group_add_child;
return clip_path;
}
void
rsvg_start_clip_path (RsvgHandle *ctx, RsvgPropertyBag *atts)
static void
rsvg_clip_path_set_atts (RsvgNode * self, RsvgHandle *ctx, RsvgPropertyBag *atts)
{
const char *id = NULL, *klazz = NULL, *value = NULL;
RsvgClipPath *clip_path;
double font_size;
font_size = rsvg_state_current_font_size (ctx);
clip_path = rsvg_new_clip_path ();
clip_path = (RsvgClipPath *)self;
if (rsvg_property_bag_size (atts))
{
......@@ -232,21 +226,43 @@ rsvg_start_clip_path (RsvgHandle *ctx, RsvgPropertyBag *atts)
clip_path->units = userSpaceOnUse;
}
if ((value = rsvg_property_bag_lookup (atts, "id")))
id = value;
{
id = value;
rsvg_defs_register_name(ctx->defs, id, &clip_path->super);
}
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
}
rsvg_state_init (clip_path->super.super.state);
rsvg_state_init (clip_path->super.state);
rsvg_parse_style_attrs (ctx, clip_path->super.super.state, "clipPath", klazz, id, atts);
rsvg_parse_style_attrs (ctx, clip_path->super.state, "clipPath", klazz, id, atts);
}
clip_path->super.super.parent = (RsvgNode *)ctx->currentnode;
static void
rsvg_clip_path_add_child (RsvgNode *overself, RsvgNode *child)
{
RsvgClipPath *self = (RsvgClipPath *)overself;
if (self == NULL)
return;
g_ptr_array_add(self->children, child);
}
ctx->currentnode = &clip_path->super.super;
RsvgNode *
rsvg_new_clip_path (void)
{
RsvgClipPath *clip_path;
/* set up the defval stuff */
rsvg_defs_set (ctx->defs, id, &clip_path->super.super);
clip_path = g_new (RsvgClipPath, 1);
clip_path->children = g_ptr_array_new ();
clip_path->units = userSpaceOnUse;
clip_path->super.state = g_new(RsvgState, 1);
clip_path->super.type = RSVG_NODE_CLIP_PATH;
clip_path->super.free = rsvg_clip_path_free;
clip_path->super.add_child = rsvg_clip_path_add_child;
clip_path->super.draw = rsvg_draw_nothing;
clip_path->super.set_atts = rsvg_clip_path_set_atts;
return &clip_path->super;
}
void
......
......@@ -38,14 +38,15 @@ typedef RsvgCoordUnits RsvgMaskUnits;
typedef struct _RsvgMask RsvgMask;
struct _RsvgMask {
RsvgNodeGroup super;
RsvgNode super;
GPtrArray *children;
double x, y, width, height;
RsvgMaskUnits maskunits;
RsvgMaskUnits contentunits;
};
void
rsvg_start_mask (RsvgHandle *ctx, RsvgPropertyBag *atts);
RsvgNode *
rsvg_new_mask (void);
void
rsvg_end_mask (RsvgHandle *ctx);
......@@ -56,12 +57,13 @@ rsvg_mask_parse (const RsvgDefs * defs, const char *str);
typedef struct _RsvgClipPath RsvgClipPath;
struct _RsvgClipPath {
RsvgNodeGroup super;
RsvgNode super;
RsvgCoordUnits units;
GPtrArray *children;
};
void
rsvg_start_clip_path (RsvgHandle *ctx, RsvgPropertyBag *atts);
RsvgNode *
rsvg_new_clip_path (void);
void
rsvg_end_clip_path (RsvgHandle *ctx);
......@@ -69,6 +71,8 @@ rsvg_end_clip_path (RsvgHandle *ctx);
RsvgNode *
rsvg_clip_path_parse (const RsvgDefs * defs, const char *str);
void
rsvg_node_mask_draw (RsvgMask *group, RsvgDrawingCtx *ctx, int dominate);
G_END_DECLS
......
......@@ -202,6 +202,7 @@ struct _RsvgNode {
void (*add_child) (RsvgNode *self, RsvgNode *child);
void (*free) (RsvgNode *self);
void (*draw) (RsvgNode * self, RsvgDrawingCtx *ctx, int dominate);
void (*set_atts) (RsvgNode * self, RsvgHandle *ctx, RsvgPropertyBag*);
};
typedef void (*RsvgPropertyBagEnumFunc) (const char * key,
......@@ -303,6 +304,9 @@ _rsvg_affine_rectilinear (const double src[6]);
int
_rsvg_affine_equal (double matrix1[6], double matrix2[6]);
void
rsvg_node_set_atts(RsvgNode * node, RsvgHandle * ctx, RsvgPropertyBag * atts);
G_END_DECLS
#endif
......@@ -46,24 +46,23 @@ rsvg_node_draw (RsvgNode * self, RsvgDrawingCtx *ctx,
self->draw(self, ctx, dominate);
}
void
rsvg_start_g (RsvgHandle *ctx, RsvgPropertyBag *atts)
static void
rsvg_node_group_set_atts (RsvgNode * self, RsvgHandle *ctx, RsvgPropertyBag *atts)
{
RsvgState state;
const char * klazz = NULL, * id = NULL, *value;
rsvg_state_init(&state);
if (rsvg_property_bag_size (atts))
{
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id")))
id = value;
{
id = value;
rsvg_defs_register_name (ctx->defs, value, self);
}
rsvg_parse_style_attrs (ctx, &state, "g", klazz, id, atts);
rsvg_parse_style_attrs (ctx, self->state, "g", klazz, id, atts);
}
rsvg_push_def_group (ctx, id, &state);
}
void
......@@ -116,32 +115,19 @@ rsvg_node_group_add_child (RsvgNode *overself, RsvgNode *child)
g_ptr_array_add(self->children, child);
}
RsvgNode *
rsvg_push_def_group (RsvgHandle *ctx, const char * id,
RsvgState *state)
RsvgNode *
rsvg_new_group (void)
{
RsvgNodeGroup *group;
group = g_new (RsvgNodeGroup, 1);
group->children = g_ptr_array_new();
group->super.state = g_new(RsvgState, 1);
*group->super.state = *state;
rsvg_state_init(group->super.state);
group->super.type = RSVG_NODE_PATH;
group->super.free = rsvg_node_group_free;
group->super.add_child = rsvg_node_group_add_child;
group->super.draw = rsvg_node_group_draw;
rsvg_defs_set (ctx->defs, id, &group->super);
group->super.parent = (RsvgNode *)ctx->currentnode;
ctx->currentnode = &group->super;
if (group->super.parent != NULL)
rsvg_node_group_pack(group->super.parent,
&group->super);
group->super.set_atts = rsvg_node_group_set_atts;
return &group->super;
}
......@@ -173,13 +159,8 @@ rsvg_push_part_def_group (RsvgHandle *ctx, const char * id,
void
rsvg_pop_def_group (RsvgHandle *ctx)
{
RsvgNodeGroup * group;
group = (RsvgNodeGroup *)ctx->currentnode;
if (group == NULL)
return;
ctx->currentnode = group->super.parent;
if (ctx->currentnode != NULL)
ctx->currentnode = ctx->currentnode->parent;
}
void
......@@ -253,6 +234,9 @@ rsvg_node_use_draw (RsvgNode * self, RsvgDrawingCtx *ctx,
RsvgNodeUse *use = (RsvgNodeUse*)self;
RsvgNode * child;
if (use->w <= 0 || use->h <= 0)
return;
rsvg_state_reinherit_top(ctx, self->state, dominate);
child = rsvg_node_use_resolve(use, ctx, rsvg_state_current(ctx)->affine);
......@@ -288,7 +272,6 @@ rsvg_node_svg_draw (RsvgNode * self, RsvgDrawingCtx *ctx,
RsvgNodeSvg * sself;
RsvgState *state;
gdouble affine[6];
RsvgNodeGroup *group = (RsvgNodeGroup*)self;
guint i;
sself = (RsvgNodeSvg *)self;
......@@ -324,11 +307,11 @@ rsvg_node_svg_draw (RsvgNode * self, RsvgDrawingCtx *ctx,
state->affine);
}
for (i = 0; i < group->children->len; i++)
for (i = 0; i < sself->children->len; i++)
{
rsvg_state_push(ctx);
rsvg_node_draw (g_ptr_array_index(group->children, i),
rsvg_node_draw (g_ptr_array_index(sself->children, i),
ctx, 0);
rsvg_state_pop(ctx);
......@@ -340,95 +323,88 @@ rsvg_node_svg_draw (RsvgNode * self, RsvgDrawingCtx *ctx,
static void
rsvg_node_svg_free (RsvgNode *self)
{
RsvgNodeGroup *z = (RsvgNodeGroup *)self;
rsvg_state_finalize (z->super.state);
g_free (z->super.state);
RsvgNodeSvg *z = (RsvgNodeSvg *)self;
rsvg_state_finalize (self->state);
g_free (self->state);
g_ptr_array_free(z->children, TRUE);
g_free (z);
}
void
rsvg_start_svg (RsvgHandle *ctx, RsvgPropertyBag *atts)
static void
rsvg_node_svg_add_child (RsvgNode *overself, RsvgNode *child)
{
RsvgNodeSvg *self = (RsvgNodeSvg *)overself;
g_ptr_array_add(self->children, child);
}
static void
rsvg_node_svg_set_atts (RsvgNode * self, RsvgHandle *ctx, RsvgPropertyBag *atts)
{
int width = -1, height = -1, x = 0, y = 0;
const char * id, *value;
double vbox_x = 0, vbox_y = 0, vbox_w = 0, vbox_h = 0;
gboolean has_vbox = FALSE, overflow = 0;
RsvgNodeSvg * svg;
RsvgNodeGroup * group;
RsvgState state;
RsvgNodeSvg * svg = (RsvgNodeSvg *)self;
id = NULL;
rsvg_state_init(&state);
if (rsvg_property_bag_size (atts))
{
if ((value = rsvg_property_bag_lookup (atts, "viewBox")))
{
has_vbox = rsvg_css_parse_vbox (value, &vbox_x, &vbox_y,
&vbox_w, &vbox_h);
/*we need to set width and height so we can use percentages for the size*/
ctx->width = vbox_w;
ctx->height = vbox_h;
svg->has_vbox = rsvg_css_parse_vbox (value,
&svg->vbx,
&svg->vby,
&svg->vbw,
&svg->vbh);
if (svg->has_vbox)
{
ctx->width = svg->vbw;
ctx->height = svg->vbh;
}
}
if ((value = rsvg_property_bag_lookup (atts, "width")))
width = rsvg_css_parse_normalized_length (value, ctx->dpi_x, ctx->width, 1);
{
svg->w = rsvg_css_parse_normalized_length (value, ctx->dpi_x, ctx->width, 1);
if (!svg->has_vbox)
ctx->width = svg->w;
}
if ((value = rsvg_property_bag_lookup (atts, "height")))
height = rsvg_css_parse_normalized_length (value, ctx->dpi_y, ctx->height, 1);
{
svg->h = rsvg_css_parse_normalized_length (value, ctx->dpi_y, ctx->height, 1);
if (!svg->has_vbox)
ctx->height = svg->h;
}
if ((value = rsvg_property_bag_lookup (atts, "x")))
x = rsvg_css_parse_normalized_length (value, ctx->dpi_x, ctx->width, 1);
svg->x = rsvg_css_parse_normalized_length (value, ctx->dpi_x, ctx->width, 1);
if ((value = rsvg_property_bag_lookup (atts, "y")))
y = rsvg_css_parse_normalized_length (value, ctx->dpi_y, ctx->height, 1);
svg->y = rsvg_css_parse_normalized_length (value, ctx->dpi_y, ctx->height, 1);
if ((value = rsvg_property_bag_lookup (atts, "id")))
id = value;
{
id = value;
rsvg_defs_register_name (ctx->defs, value, &svg->super);
}
if ((value = rsvg_property_bag_lookup (atts, "overflow")))
overflow = rsvg_css_parse_overflow(value);
svg->overflow = rsvg_css_parse_overflow(value);
}
}
RsvgNode *
rsvg_new_svg (void)
{
RsvgNodeSvg * svg;
svg = g_new (RsvgNodeSvg, 1);
group = &svg->super;
svg->has_vbox = has_vbox;
svg->has_vbox = FALSE;
svg->preserve_aspect_ratio = RSVG_ASPECT_RATIO_XMID_YMID;
svg->x = x; svg->y = y; svg->w = width; svg->h = height;
svg->vbx = vbox_x; svg->vby = vbox_y; svg->vbw = vbox_w; svg->vbh = vbox_h;
if (ctx->nest_level)
svg->overflow = overflow;
else
svg->overflow = 1;
if (has_vbox)
{
ctx->width = vbox_w;
ctx->height = vbox_h;
}
else
{
ctx->width = width;
ctx->height = height;
}
group->children = g_ptr_array_new();
group->super.state = g_new(RsvgState, 1);
*group->super.state = state;
group->super.type = RSVG_NODE_PATH;
group->super.free = rsvg_node_svg_free;
group->super.draw = rsvg_node_svg_draw;
group->super.add_child = rsvg_node_group_add_child;
rsvg_defs_set (ctx->defs, id, &group->super);
group->super.parent = (RsvgNode *)ctx->currentnode;
ctx->currentnode = &group->super;
if (group->super.parent != NULL)
rsvg_node_group_pack(group->super.parent, &group->super);
if (!ctx->nest_level)
ctx->treebase = group;
ctx->nest_level++;
svg->x = 0; svg->y = 0; svg->w = -1; svg->h = -1;
svg->vbx = 0; svg->vby = 0; svg->vbw = 0; svg->vbh = 0;
svg->children = g_ptr_array_new();
svg->super.state = g_new(RsvgState, 1);
rsvg_state_init(svg->super.state);
svg->super.type = RSVG_NODE_PATH;
svg->super.free = rsvg_node_svg_free;
svg->super.draw = rsvg_node_svg_draw;
svg->super.add_child = rsvg_node_svg_add_child;
svg->super.set_atts = rsvg_node_svg_set_atts;
svg->overflow = FALSE;
return &svg->super;
}
void
......@@ -438,73 +414,70 @@ rsvg_end_svg(RsvgHandle *ctx)
rsvg_pop_def_group (ctx);
}
void
rsvg_start_use (RsvgHandle *ctx, RsvgPropertyBag *atts)
static void
rsvg_node_use_set_atts (RsvgNode * self, RsvgHandle *ctx, RsvgPropertyBag *atts)
{
const char * klazz = NULL, *id = NULL, *xlink_href = NULL, *value;
double x = 0, y = 0, width = 0, height = 0, font_size;
const char *value = NULL, *klazz = NULL, *id = NULL;
double font_size;
gboolean got_width = FALSE, got_height = FALSE;
RsvgState state;
rsvg_state_init(&state);
font_size = rsvg_state_current_font_size(ctx);
RsvgNodeUse * use;
use = (RsvgNodeUse *)self;
if (rsvg_property_bag_size(atts))
{
if ((value = rsvg_property_bag_lookup (atts, "x")))
x = rsvg_css_parse_normalized_length (value, ctx->dpi_x, (gdouble)ctx->width, font_size);
use->x = rsvg_css_parse_normalized_length (value, ctx->dpi_x, (gdouble)ctx->width, font_size);
if ((value = rsvg_property_bag_lookup (atts, "y")))
y = rsvg_css_parse_normalized_length (value, ctx->dpi_y, (gdouble)ctx->height, font_size);