[librsvg] Handle comma separated CSS selectors without libcroco.
- From: Hiroyuki Ikezoe <hiikezoe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Handle comma separated CSS selectors without libcroco.
- Date: Sat, 24 Apr 2010 07:31:55 +0000 (UTC)
commit bfd1c637d810a53908f602f6d6d3861e08ec59de
Author: Hiroyuki Ikezoe <hiikezoe gnome org>
Date: Sat Apr 24 16:31:00 2010 +0900
Handle comma separated CSS selectors without libcroco.
Fix for bug #614643.
rsvg-styles.c | 15 ++++++++++-----
tests/fixtures/styles/bug614643.svg | 15 +++++++++++++++
tests/styles.c | 2 ++
3 files changed, 27 insertions(+), 5 deletions(-)
---
diff --git a/rsvg-styles.c b/rsvg-styles.c
index 61d3a1f..e32fc69 100644
--- a/rsvg-styles.c
+++ b/rsvg-styles.c
@@ -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);
diff --git a/tests/fixtures/styles/bug614643.svg b/tests/fixtures/styles/bug614643.svg
new file mode 100644
index 0000000..1916bdc
--- /dev/null
+++ b/tests/fixtures/styles/bug614643.svg
@@ -0,0 +1,15 @@
+<?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>
+
diff --git a/tests/styles.c b/tests/styles.c
index b7380ac..d3db402 100644
--- a/tests/styles.c
+++ b/tests/styles.c
@@ -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},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]