Commit bfd1c637 authored by Hiroyuki Ikezoe's avatar Hiroyuki Ikezoe

Handle comma separated CSS selectors without libcroco.

Fix for bug #614643.
parent 1654ddfe
......@@ -1052,6 +1052,8 @@ rsvg_real_parse_cssbuffer (RsvgHandle * ctx, const char *buff, size_t buflen)
size_t loc = 0;
while (loc < buflen) {
gchar **styles;
guint i;
GString *style_name = g_string_new (NULL);
GString *style_props = g_string_new (NULL);
......@@ -1059,11 +1061,10 @@ rsvg_real_parse_cssbuffer (RsvgHandle * ctx, const char *buff, size_t buflen)
while (loc < buflen && g_ascii_isspace (buff[loc]))
loc++;
while (loc < buflen && !g_ascii_isspace (buff[loc]))
g_string_append_c (style_name, buff[loc++]);
/* advance to the first { that defines the style's properties */
while (loc < buflen && buff[loc++] != '{');
while (loc < buflen && buff[loc] != '{')
g_string_append_c (style_name, buff[loc++]);
loc++;
while (loc < buflen && g_ascii_isspace (buff[loc]))
loc++;
......@@ -1085,7 +1086,11 @@ rsvg_real_parse_cssbuffer (RsvgHandle * ctx, const char *buff, size_t buflen)
}
}
rsvg_css_define_style (ctx, style_name->str, style_props->str);
styles = g_strsplit (style_name->str, ",", -1);
for (i = 0; i < g_strv_length (styles); i++)
rsvg_css_define_style (ctx, g_strstrip (styles[i]), style_props->str);
g_strfreev (styles);
g_string_free (style_name, TRUE);
g_string_free (style_props, TRUE);
......
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="5cm" height="2.5cm" viewBox="0 0 1000 500"
xmlns="http://www.w3.org/2000/svg" version="1.1">
<style format="text/css">
rect, path {
fill: red;
stroke: red;
}
</style>
<rect id="red-rect" x="200" y="100" width="600" height="400"/>
<path id="red-path" d="M 50,20 L 20,80 L 80,80 z " />
</svg>
......@@ -85,6 +85,8 @@ static const FixtureData fixtures[] =
{"/styles/selectors/class#id prior than class", NULL, "fixtures/styles/order.svg", "#yellow", "fill", .expected.color = 0xffff00},
{"/styles/selectors/type.class#id prior than class", NULL, "fixtures/styles/order.svg", "#white", "fill", .expected.color = 0xffffff},
{"/styles/selectors/#id prior than type", "418823", "fixtures/styles/bug418823.svg", "#bla", "fill", .expected.color = 0x00ff00},
{"/styles/selectors/comma-separate (fill)", "614643", "fixtures/styles/bug614643.svg", "#red-rect", "fill", .expected.color = 0xff0000},
{"/styles/selectors/comma-separete (stroke)", "614643", "fixtures/styles/bug614643.svg", "#red-path", "stroke", .expected.color = 0xff0000},
{"/styles/override presentation attribute", "614704", "fixtures/styles/bug614704.svg", "#blue-rect", "fill", .expected.color = 0x0000ff},
{"/styles/selectors/2 or more selectors (fill)", "592207", "fixtures/styles/bug592207.svg", "#target", "fill", .expected.color = 0xff0000},
{"/styles/selectors/2 or more selectors (stroke)", "592207", "fixtures/styles/bug592207.svg", "#target", "stroke", .expected.color = 0x0000ff},
......
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