Commit bc2c319c authored by Dom Lachowicz's avatar Dom Lachowicz

set up framework for currentColor and inherit colors

parent fde8fee2
2004-03-20 Dom Lachowicz <cinamod@hotmail.com>
* *: Set up framework for the "currentColor" and "inherit" colors
2004-03-20 Dom Lachowicz <cinamod@hotmail.com>
* rsvg-css.c: Fix rgb percent handling for
......
......@@ -230,7 +230,7 @@ rsvg_css_color_compare (const void * a, const void * b)
* Parse a CSS2 color specifier, return RGB value
*/
guint32
rsvg_css_parse_color (const char *str)
rsvg_css_parse_color (const char *str, guint32 inherit)
{
gint val = 0;
......@@ -305,7 +305,9 @@ rsvg_css_parse_color (const char *str)
val = PACK_RGB (r,g,b);
}
else
else if (!strcmp (str, "inherit"))
val = inherit;
else
{
const static ColorPair color_list [] =
{
......
......@@ -45,7 +45,7 @@ int
rsvg_css_param_arg_offset (const char *str);
guint32
rsvg_css_parse_color (const char *str);
rsvg_css_parse_color (const char *str, guint32 inherit);
guint
rsvg_css_parse_opacity (const char *str);
......
......@@ -3126,7 +3126,7 @@ rsvg_start_filter_primitive_flood (RsvgHandle * ctx,
}
if ((value = rsvg_property_bag_lookup (atts, "flood-color")))
{
filter->colour = rsvg_css_parse_color (value);
filter->colour = rsvg_css_parse_color (value, 0);
}
if ((value = rsvg_property_bag_lookup (atts, "flood-opacity")))
{
......@@ -4529,7 +4529,7 @@ rsvg_start_filter_primitive_diffuse_lighting (RsvgHandle * ctx, RsvgPropertyBag
rsvg_css_parse_number_optional_number (value,
&filter->dx, &filter->dy);
if ((value = rsvg_property_bag_lookup (atts, "lighting-color")))
filter->lightingcolour = rsvg_css_parse_color (value);
filter->lightingcolour = rsvg_css_parse_color (value, 0);
if ((value = rsvg_property_bag_lookup (atts, "diffuseConstant")))
filter->diffuseConstant =
g_ascii_strtod(value, NULL);
......@@ -4726,7 +4726,7 @@ rsvg_start_filter_primitive_specular_lighting (RsvgHandle * ctx, RsvgPropertyBag
filter->super.sizedefaults = 0;
}
if ((value = rsvg_property_bag_lookup (atts, "lighting-color")))
filter->lightingcolour = rsvg_css_parse_color (value);
filter->lightingcolour = rsvg_css_parse_color (value, 0);
if ((value = rsvg_property_bag_lookup (atts, "specularConstant")))
filter->specularConstant =
g_ascii_strtod(value, NULL);
......
......@@ -307,12 +307,13 @@ rsvg_paint_server_rad_grad (RsvgRadialGradient *gradient)
* Return value: The newly created paint server, or NULL on error.
**/
RsvgPaintServer *
rsvg_paint_server_parse (const RsvgDefs *defs, const char *str)
rsvg_paint_server_parse (RsvgPaintServer * current, const RsvgDefs *defs, const char *str)
{
guint32 rgb;
if (!strcmp (str, "none"))
return NULL;
if (!strncmp (str, "url(", 4))
{
const char *p = str + 4;
......@@ -343,9 +344,14 @@ rsvg_paint_server_parse (const RsvgDefs *defs, const char *str)
return NULL;
}
}
else
else if (current && (!strcmp (str, "currentColor") || !strcmp (str, "inherit")))
{
rsvg_paint_server_ref (current);
return current;
}
else
{
rgb = rsvg_css_parse_color (str);
rgb = rsvg_css_parse_color (str, 0);
return rsvg_paint_server_solid (rgb);
}
}
......
......@@ -95,7 +95,7 @@ struct _RsvgRadialGradient {
/* Create a new paint server based on a specification string. */
RsvgPaintServer *
rsvg_paint_server_parse (const RsvgDefs *defs, const char *str);
rsvg_paint_server_parse (RsvgPaintServer * current, const RsvgDefs *defs, const char *str);
void
rsvg_render_paint_server (ArtRender *ar, RsvgPaintServer *ps,
......
......@@ -50,7 +50,7 @@ rsvg_state_init (RsvgState *state)
art_affine_identity (state->personal_affine);
state->mask = NULL;
state->opacity = 0xff;
state->fill = rsvg_paint_server_parse (NULL, "#000");
state->fill = rsvg_paint_server_parse (NULL, NULL, "#000");
state->fill_opacity = 0xff;
state->stroke_opacity = 0xff;
state->stroke_width = 1;
......@@ -331,9 +331,12 @@ rsvg_parse_style_arg (RsvgHandle *ctx, RsvgState *state, const char *str)
}
else if (rsvg_css_param_match (str, "fill"))
{
rsvg_paint_server_unref (state->fill);
state->fill = rsvg_paint_server_parse (ctx->defs, str + arg_off);
RsvgPaintServer * fill = state->fill;
state->fill = rsvg_paint_server_parse (parent_state->fill, ctx->defs, str + arg_off);
state->has_fill_server = TRUE;
rsvg_paint_server_unref (fill);
}
else if (rsvg_css_param_match (str, "fill-opacity"))
{
......@@ -352,9 +355,12 @@ rsvg_parse_style_arg (RsvgHandle *ctx, RsvgState *state, const char *str)
}
else if (rsvg_css_param_match (str, "stroke"))
{
rsvg_paint_server_unref (state->stroke);
state->stroke = rsvg_paint_server_parse (ctx->defs, str + arg_off);
RsvgPaintServer * stroke = state->stroke;
state->stroke = rsvg_paint_server_parse (parent_state->stroke, ctx->defs, str + arg_off);
state->has_stroke_server = TRUE;
rsvg_paint_server_unref (stroke);
}
else if (rsvg_css_param_match (str, "stroke-width"))
{
......@@ -490,7 +496,7 @@ rsvg_parse_style_arg (RsvgHandle *ctx, RsvgState *state, const char *str)
else if (rsvg_css_param_match (str, "stop-color"))
{
state->has_stop_color = TRUE;
state->stop_color = rsvg_css_parse_color (str + arg_off);
state->stop_color = rsvg_css_parse_color (str + arg_off, parent_state->stop_color);
}
else if (rsvg_css_param_match (str, "stop-opacity"))
{
......
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