node_set_atts(): Check here for the property bag being empty

Every ::set_atts() implementation used to check on its own whether the
property bag is empty (common for "plain" SVG elements with no defined
attributes?) before actually querying the property bag.

Now we do that check in a single place, in the toplevel node_set_atts()
helper, instead of having each node type do it on its own.

This means that ::set_atts() implementation which do "validation" work
or any other post-initialization after the attributes have been set,
will have to support their ::set_atts() not being called at all if there
are no attributes in the first place.
parent 997c1a06
......@@ -242,7 +242,9 @@ free_element_name_stack (RsvgHandle *ctx)
static void
node_set_atts (RsvgNode * node, RsvgHandle * ctx, RsvgPropertyBag * atts)
{
node->set_atts (node, ctx, atts);
if (rsvg_property_bag_size (atts) > 0) {
node->set_atts (node, ctx, atts);
}
}
static void
......
This diff is collapsed.
......@@ -201,38 +201,36 @@ rsvg_node_image_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * a
const char *klazz = NULL, *id = NULL, *value;
RsvgNodeImage *image = (RsvgNodeImage *) self;
if (rsvg_property_bag_size (atts)) {
if ((value = rsvg_property_bag_lookup (atts, "x")))
image->x = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
if ((value = rsvg_property_bag_lookup (atts, "y")))
image->y = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
if ((value = rsvg_property_bag_lookup (atts, "width")))
image->w = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
if ((value = rsvg_property_bag_lookup (atts, "height")))
image->h = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
/* path is used by some older adobe illustrator versions */
if ((value = rsvg_property_bag_lookup (atts, "path"))
|| (value = rsvg_property_bag_lookup (atts, "xlink:href"))) {
image->surface = rsvg_cairo_surface_new_from_href (ctx,
value,
NULL);
if (!image->surface) {
if ((value = rsvg_property_bag_lookup (atts, "x")))
image->x = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
if ((value = rsvg_property_bag_lookup (atts, "y")))
image->y = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
if ((value = rsvg_property_bag_lookup (atts, "width")))
image->w = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
if ((value = rsvg_property_bag_lookup (atts, "height")))
image->h = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
/* path is used by some older adobe illustrator versions */
if ((value = rsvg_property_bag_lookup (atts, "path"))
|| (value = rsvg_property_bag_lookup (atts, "xlink:href"))) {
image->surface = rsvg_cairo_surface_new_from_href (ctx,
value,
NULL);
if (!image->surface) {
#ifdef G_ENABLE_DEBUG
g_warning ("Couldn't load image: %s\n", value);
g_warning ("Couldn't load image: %s\n", value);
#endif
}
}
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id")))
id = value;
}
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id")))
id = value;
if ((value = rsvg_property_bag_lookup (atts, "preserveAspectRatio")))
image->preserve_aspect_ratio = rsvg_css_parse_aspect_ratio (value);
if ((value = rsvg_property_bag_lookup (atts, "preserveAspectRatio")))
image->preserve_aspect_ratio = rsvg_css_parse_aspect_ratio (value);
rsvg_parse_style_attrs (ctx, image->super.state, "image", klazz, id, atts);
}
rsvg_parse_style_attrs (ctx, image->super.state, "image", klazz, id, atts);
}
RsvgNode *
......
......@@ -59,37 +59,35 @@ rsvg_node_marker_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag *
RsvgMarker *marker;
marker = (RsvgMarker *) self;
if (rsvg_property_bag_size (atts)) {
if ((value = rsvg_property_bag_lookup (atts, "id")))
id = value;
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "viewBox")))
marker->vbox = rsvg_css_parse_vbox (value);
if ((value = rsvg_property_bag_lookup (atts, "refX")))
marker->refX = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
if ((value = rsvg_property_bag_lookup (atts, "refY")))
marker->refY = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
if ((value = rsvg_property_bag_lookup (atts, "markerWidth")))
marker->width = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
if ((value = rsvg_property_bag_lookup (atts, "markerHeight")))
marker->height = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
if ((value = rsvg_property_bag_lookup (atts, "orient"))) {
if (!strcmp (value, "auto"))
marker->orientAuto = TRUE;
else
marker->orient = rsvg_css_parse_angle (value);
}
if ((value = rsvg_property_bag_lookup (atts, "markerUnits"))) {
if (!strcmp (value, "userSpaceOnUse"))
marker->bbox = FALSE;
if (!strcmp (value, "strokeWidth"))
marker->bbox = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "preserveAspectRatio")))
marker->preserve_aspect_ratio = rsvg_css_parse_aspect_ratio (value);
rsvg_parse_style_attrs (ctx, self->state, "marker", klazz, id, atts);
if ((value = rsvg_property_bag_lookup (atts, "id")))
id = value;
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "viewBox")))
marker->vbox = rsvg_css_parse_vbox (value);
if ((value = rsvg_property_bag_lookup (atts, "refX")))
marker->refX = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
if ((value = rsvg_property_bag_lookup (atts, "refY")))
marker->refY = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
if ((value = rsvg_property_bag_lookup (atts, "markerWidth")))
marker->width = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
if ((value = rsvg_property_bag_lookup (atts, "markerHeight")))
marker->height = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
if ((value = rsvg_property_bag_lookup (atts, "orient"))) {
if (!strcmp (value, "auto"))
marker->orientAuto = TRUE;
else
marker->orient = rsvg_css_parse_angle (value);
}
if ((value = rsvg_property_bag_lookup (atts, "markerUnits"))) {
if (!strcmp (value, "userSpaceOnUse"))
marker->bbox = FALSE;
if (!strcmp (value, "strokeWidth"))
marker->bbox = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "preserveAspectRatio")))
marker->preserve_aspect_ratio = rsvg_css_parse_aspect_ratio (value);
rsvg_parse_style_attrs (ctx, self->state, "marker", klazz, id, atts);
}
RsvgNode *
......
......@@ -36,33 +36,31 @@ rsvg_mask_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts)
RsvgMask *mask;
mask = (RsvgMask *) self;
if (rsvg_property_bag_size (atts)) {
if ((value = rsvg_property_bag_lookup (atts, "maskUnits"))) {
if (!strcmp (value, "userSpaceOnUse"))
mask->maskunits = userSpaceOnUse;
else
mask->maskunits = objectBoundingBox;
}
if ((value = rsvg_property_bag_lookup (atts, "maskContentUnits"))) {
if (!strcmp (value, "objectBoundingBox"))
mask->contentunits = objectBoundingBox;
else
mask->contentunits = userSpaceOnUse;
}
if ((value = rsvg_property_bag_lookup (atts, "x")))
mask->x = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
if ((value = rsvg_property_bag_lookup (atts, "y")))
mask->y = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
if ((value = rsvg_property_bag_lookup (atts, "width")))
mask->width = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
if ((value = rsvg_property_bag_lookup (atts, "height")))
mask->height = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
if ((value = rsvg_property_bag_lookup (atts, "id")))
id = value;
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "maskUnits"))) {
if (!strcmp (value, "userSpaceOnUse"))
mask->maskunits = userSpaceOnUse;
else
mask->maskunits = objectBoundingBox;
}
if ((value = rsvg_property_bag_lookup (atts, "maskContentUnits"))) {
if (!strcmp (value, "objectBoundingBox"))
mask->contentunits = objectBoundingBox;
else
mask->contentunits = userSpaceOnUse;
}
if ((value = rsvg_property_bag_lookup (atts, "x")))
mask->x = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
if ((value = rsvg_property_bag_lookup (atts, "y")))
mask->y = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
if ((value = rsvg_property_bag_lookup (atts, "width")))
mask->width = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
if ((value = rsvg_property_bag_lookup (atts, "height")))
mask->height = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
if ((value = rsvg_property_bag_lookup (atts, "id")))
id = value;
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
rsvg_parse_style_attrs (ctx, mask->super.state, "mask", klazz, id, atts);
}
......@@ -109,19 +107,17 @@ rsvg_clip_path_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * at
clip_path = (RsvgClipPath *) self;
if (rsvg_property_bag_size (atts)) {
if ((value = rsvg_property_bag_lookup (atts, "clipPathUnits"))) {
if (!strcmp (value, "objectBoundingBox"))
clip_path->units = objectBoundingBox;
else
clip_path->units = userSpaceOnUse;
}
if ((value = rsvg_property_bag_lookup (atts, "id")))
id = value;
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "clipPathUnits"))) {
if (!strcmp (value, "objectBoundingBox"))
clip_path->units = objectBoundingBox;
else
clip_path->units = userSpaceOnUse;
}
if ((value = rsvg_property_bag_lookup (atts, "id")))
id = value;
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
rsvg_parse_style_attrs (ctx, clip_path->super.state, "clipPath", klazz, id, atts);
}
......
......@@ -160,44 +160,43 @@ rsvg_stop_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts)
stop = (RsvgGradientStop *) self;
if (rsvg_property_bag_size (atts)) {
if ((value = rsvg_property_bag_lookup (atts, "offset"))) {
/* either a number [0,1] or a percentage */
RsvgLength length = rsvg_length_parse (value, LENGTH_DIR_BOTH);
if (length.unit == LENGTH_UNIT_DEFAULT || length.unit == LENGTH_UNIT_PERCENT) {
double offset;
offset = length.length;
if (offset < 0.0)
offset = 0.0;
else if (offset > 1.0)
offset = 1.0;
stop->offset = offset;
stop->is_valid = TRUE;
} else {
/* Only default and percent values are allowed */
stop->is_valid = FALSE;
}
}
if ((value = rsvg_property_bag_lookup (atts, "style")))
rsvg_parse_style (ctx, self->state, value);
if ((value = rsvg_property_bag_lookup (atts, "offset"))) {
/* either a number [0,1] or a percentage */
RsvgLength length = rsvg_length_parse (value, LENGTH_DIR_BOTH);
if ((value = rsvg_property_bag_lookup (atts, "stop-color"))) {
has_stop_color = TRUE;
if (length.unit == LENGTH_UNIT_DEFAULT || length.unit == LENGTH_UNIT_PERCENT) {
double offset;
if (!strcmp (value, "currentColor"))
is_current_color = TRUE;
}
offset = length.length;
if (offset < 0.0)
offset = 0.0;
else if (offset > 1.0)
offset = 1.0;
if ((value = rsvg_property_bag_lookup (atts, "stop-opacity"))) {
has_stop_opacity = TRUE;
stop->offset = offset;
stop->is_valid = TRUE;
} else {
/* Only default and percent values are allowed */
stop->is_valid = FALSE;
}
}
if ((value = rsvg_property_bag_lookup (atts, "style")))
rsvg_parse_style (ctx, self->state, value);
if ((value = rsvg_property_bag_lookup (atts, "stop-color"))) {
has_stop_color = TRUE;
rsvg_parse_style_pairs (ctx, self->state, atts);
if (!strcmp (value, "currentColor"))
is_current_color = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "stop-opacity"))) {
has_stop_opacity = TRUE;
}
rsvg_parse_style_pairs (ctx, self->state, atts);
self->parent = ctx->priv->currentnode;
state = rsvg_state_new ();
......@@ -242,48 +241,46 @@ rsvg_linear_gradient_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBa
RsvgLinearGradient *grad = (RsvgLinearGradient *) self;
const char *value;
if (rsvg_property_bag_size (atts)) {
if ((value = rsvg_property_bag_lookup (atts, "x1"))) {
grad->x1 = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
grad->hasx1 = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "y1"))) {
grad->y1 = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
grad->hasy1 = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "x2"))) {
grad->x2 = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
grad->hasx2 = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "y2"))) {
grad->y2 = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
grad->hasy2 = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "spreadMethod"))) {
if (!strcmp (value, "pad")) {
grad->spread = CAIRO_EXTEND_PAD;
} else if (!strcmp (value, "reflect")) {
grad->spread = CAIRO_EXTEND_REFLECT;
} else if (!strcmp (value, "repeat")) {
grad->spread = CAIRO_EXTEND_REPEAT;
}
grad->hasspread = TRUE;
}
g_free (grad->fallback);
grad->fallback = g_strdup (rsvg_property_bag_lookup (atts, "xlink:href"));
if ((value = rsvg_property_bag_lookup (atts, "gradientTransform"))) {
rsvg_parse_transform (&grad->affine, value);
grad->hastransform = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "gradientUnits"))) {
if (!strcmp (value, "userSpaceOnUse"))
grad->obj_bbox = FALSE;
else if (!strcmp (value, "objectBoundingBox"))
grad->obj_bbox = TRUE;
grad->hasbbox = TRUE;
}
rsvg_parse_style_attrs (ctx, self->state, "linearGradient", NULL, NULL, atts);
if ((value = rsvg_property_bag_lookup (atts, "x1"))) {
grad->x1 = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
grad->hasx1 = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "y1"))) {
grad->y1 = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
grad->hasy1 = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "x2"))) {
grad->x2 = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
grad->hasx2 = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "y2"))) {
grad->y2 = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
grad->hasy2 = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "spreadMethod"))) {
if (!strcmp (value, "pad")) {
grad->spread = CAIRO_EXTEND_PAD;
} else if (!strcmp (value, "reflect")) {
grad->spread = CAIRO_EXTEND_REFLECT;
} else if (!strcmp (value, "repeat")) {
grad->spread = CAIRO_EXTEND_REPEAT;
}
grad->hasspread = TRUE;
}
g_free (grad->fallback);
grad->fallback = g_strdup (rsvg_property_bag_lookup (atts, "xlink:href"));
if ((value = rsvg_property_bag_lookup (atts, "gradientTransform"))) {
rsvg_parse_transform (&grad->affine, value);
grad->hastransform = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "gradientUnits"))) {
if (!strcmp (value, "userSpaceOnUse"))
grad->obj_bbox = FALSE;
else if (!strcmp (value, "objectBoundingBox"))
grad->obj_bbox = TRUE;
grad->hasbbox = TRUE;
}
rsvg_parse_style_attrs (ctx, self->state, "linearGradient", NULL, NULL, atts);
}
static void
......@@ -320,55 +317,53 @@ rsvg_radial_gradient_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBa
RsvgRadialGradient *grad = (RsvgRadialGradient *) self;
const char *value;
if (rsvg_property_bag_size (atts)) {
if ((value = rsvg_property_bag_lookup (atts, "cx"))) {
grad->cx = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
grad->hascx = TRUE;
if (!grad->hasfx)
grad->fx = grad->cx;
}
if ((value = rsvg_property_bag_lookup (atts, "cy"))) {
grad->cy = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
grad->hascy = TRUE;
if (!grad->hasfy)
grad->fy = grad->cy;
}
if ((value = rsvg_property_bag_lookup (atts, "r"))) {
grad->r = rsvg_length_parse (value, LENGTH_DIR_BOTH);
grad->hasr = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "fx"))) {
grad->fx = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
grad->hasfx = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "fy"))) {
grad->fy = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
grad->hasfy = TRUE;
}
g_free (grad->fallback);
grad->fallback = g_strdup (rsvg_property_bag_lookup (atts, "xlink:href"));
if ((value = rsvg_property_bag_lookup (atts, "gradientTransform"))) {
rsvg_parse_transform (&grad->affine, value);
grad->hastransform = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "spreadMethod"))) {
if (!strcmp (value, "pad"))
grad->spread = CAIRO_EXTEND_PAD;
else if (!strcmp (value, "reflect"))
grad->spread = CAIRO_EXTEND_REFLECT;
else if (!strcmp (value, "repeat"))
grad->spread = CAIRO_EXTEND_REPEAT;
grad->hasspread = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "gradientUnits"))) {
if (!strcmp (value, "userSpaceOnUse"))
grad->obj_bbox = FALSE;
else if (!strcmp (value, "objectBoundingBox"))
grad->obj_bbox = TRUE;
grad->hasbbox = TRUE;
}
rsvg_parse_style_attrs (ctx, self->state, "radialGradient", NULL, NULL, atts);
if ((value = rsvg_property_bag_lookup (atts, "cx"))) {
grad->cx = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
grad->hascx = TRUE;
if (!grad->hasfx)
grad->fx = grad->cx;
}
if ((value = rsvg_property_bag_lookup (atts, "cy"))) {
grad->cy = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
grad->hascy = TRUE;
if (!grad->hasfy)
grad->fy = grad->cy;
}
if ((value = rsvg_property_bag_lookup (atts, "r"))) {
grad->r = rsvg_length_parse (value, LENGTH_DIR_BOTH);
grad->hasr = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "fx"))) {
grad->fx = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
grad->hasfx = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "fy"))) {
grad->fy = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
grad->hasfy = TRUE;
}
g_free (grad->fallback);
grad->fallback = g_strdup (rsvg_property_bag_lookup (atts, "xlink:href"));
if ((value = rsvg_property_bag_lookup (atts, "gradientTransform"))) {
rsvg_parse_transform (&grad->affine, value);
grad->hastransform = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "spreadMethod"))) {
if (!strcmp (value, "pad"))
grad->spread = CAIRO_EXTEND_PAD;
else if (!strcmp (value, "reflect"))
grad->spread = CAIRO_EXTEND_REFLECT;
else if (!strcmp (value, "repeat"))
grad->spread = CAIRO_EXTEND_REPEAT;
grad->hasspread = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "gradientUnits"))) {
if (!strcmp (value, "userSpaceOnUse"))
grad->obj_bbox = FALSE;
else if (!strcmp (value, "objectBoundingBox"))
grad->obj_bbox = TRUE;
grad->hasbbox = TRUE;
}
rsvg_parse_style_attrs (ctx, self->state, "radialGradient", NULL, NULL, atts);
}
static void
......@@ -403,51 +398,49 @@ rsvg_pattern_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts
RsvgPattern *pattern = (RsvgPattern *) self;
const char *value;
if (rsvg_property_bag_size (atts)) {
if ((value = rsvg_property_bag_lookup (atts, "viewBox"))) {
pattern->vbox = rsvg_css_parse_vbox (value);
pattern->hasvbox = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "x"))) {
pattern->x = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
pattern->hasx = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "y"))) {
pattern->y = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
pattern->hasy = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "width"))) {
pattern->width = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
pattern->haswidth = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "height"))) {
pattern->height = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
pattern->hasheight = TRUE;
}
g_free (pattern->fallback);
pattern->fallback = g_strdup (rsvg_property_bag_lookup (atts, "xlink:href"));
if ((value = rsvg_property_bag_lookup (atts, "patternTransform"))) {
rsvg_parse_transform (&pattern->affine, value);
pattern->hastransform = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "patternUnits"))) {
if (!strcmp (value, "userSpaceOnUse"))
pattern->obj_bbox = FALSE;
else if (!strcmp (value, "objectBoundingBox"))
pattern->obj_bbox = TRUE;
pattern->hasbbox = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "patternContentUnits"))) {
if (!strcmp (value, "userSpaceOnUse"))
pattern->obj_cbbox = FALSE;
else if (!strcmp (value, "objectBoundingBox"))
pattern->obj_cbbox = TRUE;
pattern->hascbox = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "preserveAspectRatio"))) {
pattern->preserve_aspect_ratio = rsvg_css_parse_aspect_ratio (value);
pattern->hasaspect = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "viewBox"))) {
pattern->vbox = rsvg_css_parse_vbox (value);
pattern->hasvbox = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "x"))) {
pattern->x = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
pattern->hasx = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "y"))) {
pattern->y = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
pattern->hasy = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "width"))) {
pattern->width = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
pattern->haswidth = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "height"))) {
pattern->height = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
pattern->hasheight = TRUE;
}
g_free (pattern->fallback);
pattern->fallback = g_strdup (rsvg_property_bag_lookup (atts, "xlink:href"));
if ((value = rsvg_property_bag_lookup (atts, "patternTransform"))) {
rsvg_parse_transform (&pattern->affine, value);
pattern->hastransform = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "patternUnits"))) {
if (!strcmp (value, "userSpaceOnUse"))
pattern->obj_bbox = FALSE;
else if (!strcmp (value, "objectBoundingBox"))
pattern->obj_bbox = TRUE;
pattern->hasbbox = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "patternContentUnits"))) {
if (!strcmp (value, "userSpaceOnUse"))
pattern->obj_cbbox = FALSE;
else if (!strcmp (value, "objectBoundingBox"))
pattern->obj_cbbox = TRUE;
pattern->hascbox = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "preserveAspectRatio"))) {
pattern->preserve_aspect_ratio = rsvg_css_parse_aspect_ratio (value);
pattern->hasaspect = TRUE;
}
}
......
......@@ -76,19 +76,17 @@ rsvg_node_path_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * at
const char *klazz = NULL, *id = NULL, *value;
RsvgNodePath *path = (RsvgNodePath *) self;
if (rsvg_property_bag_size (atts)) {
if ((value = rsvg_property_bag_lookup (atts, "d"))) {
if (path->builder)
rsvg_path_builder_destroy (path->builder);
path->builder = rsvg_path_parser_from_str_into_builder (value);
}
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id")))
id = value;
rsvg_parse_style_attrs (ctx, self->state, "path", klazz, id, atts);
if ((value = rsvg_property_bag_lookup (atts, "d"))) {
if (path->builder)
rsvg_path_builder_destroy (path->builder);
path->builder = rsvg_path_parser_from_str_into_builder (value);
}
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id")))
id = value;
rsvg_parse_style_attrs (ctx, self->state, "path", klazz, id, atts);
}
RsvgNode *
......@@ -122,24 +120,22 @@ _rsvg_node_poly_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * a
RsvgNodePoly *poly = (RsvgNodePoly *) self;
const char *klazz = NULL, *id = NULL, *value;
if (rsvg_property_bag_size (atts)) {
/* support for svg < 1.0 which used verts */
if ((value = rsvg_property_bag_lookup (atts, "verts"))
|| (value = rsvg_property_bag_lookup (atts, "points"))) {
if (poly->builder)
rsvg_path_builder_destroy (poly->builder);
poly->builder = _rsvg_node_poly_create_builder (value,
RSVG_NODE_TYPE (self) == RSVG_NODE_TYPE_POLYGON);
}
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id")))
id = value;
rsvg_parse_style_attrs (ctx, self->state,
RSVG_NODE_TYPE (self) == RSVG_NODE_TYPE_POLYLINE ? "polyline" : "polygon",
klazz, id, atts);
/* support for svg < 1.0 which used verts */
if ((value = rsvg_property_bag_lookup (atts, "verts"))
|| (value = rsvg_property_bag_lookup (atts, "points"))) {
if (poly->builder)
rsvg_path_builder_destroy (poly->builder);
poly->builder = _rsvg_node_poly_create_builder (value,
RSVG_NODE_TYPE (self) == RSVG_NODE_TYPE_POLYGON);
}
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id")))
id = value;
rsvg_parse_style_attrs (ctx, self->state,
RSVG_NODE_TYPE (self) == RSVG_NODE_TYPE_POLYLINE ? "polyline" : "polygon",
klazz, id, atts);
}
......@@ -251,22 +247,20 @@ _rsvg_node_line_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * a
const char *klazz = NULL, *id = NULL, *value;
RsvgNodeLine *line = (RsvgNodeLine *) self;
if (rsvg_property_bag_size (atts)) {
if ((value = rsvg_property_bag_lookup (atts, "x1")))
line->x1 = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
if ((value = rsvg_property_bag_lookup (atts, "y1")))
line->y1 = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
if ((value = rsvg_property_bag_lookup (atts, "x2")))
line->x2 = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
if ((value = rsvg_property_bag_lookup (atts, "y2")))
line->y2 = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id")))
id = value;
rsvg_parse_style_attrs (ctx, self->state, "line", klazz, id, atts);
}
if ((value = rsvg_property_bag_lookup (atts, "x1")))
line->x1 = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
if ((value = rsvg_property_bag_lookup (atts, "y1")))
line->y1 = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
if ((value = rsvg_property_bag_lookup (atts, "x2")))
line->x2 = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
if ((value = rsvg_property_bag_lookup (atts, "y2")))
line->y2 = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id")))
id = value;
rsvg_parse_style_attrs (ctx, self->state, "line", klazz, id, atts);
}
static void
......@@ -320,30 +314,28 @@ _rsvg_node_rect_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * a
RsvgNodeRect *rect = (RsvgNodeRect *) self;
/* FIXME: negative w/h/rx/ry is an error, per http://www.w3.org/TR/SVG11/shapes.html#RectElement */
if (rsvg_property_bag_size (atts)) {
if ((value = rsvg_property_bag_lookup (atts, "x")))
rect->x = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
if ((value = rsvg_property_bag_lookup (atts, "y")))
rect->y = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);