Commit d81104d5 authored by Hiroyuki Ikezoe's avatar Hiroyuki Ikezoe Committed by Hiroyuki Ikezoe

support !important directive in style attributes.

parent 991096b7
......@@ -864,20 +864,22 @@ rsvg_parse_style_pairs (RsvgHandle * ctx, RsvgState * state, RsvgPropertyBag * a
}
static gboolean
is_important (const gchar *value)
parse_style_value (const gchar *string, gchar **value, gboolean *important)
{
gchar **strings;
gboolean important = FALSE;
strings = g_strsplit (value, "!", 2);
strings = g_strsplit (string, "!", 2);
if (g_strv_length (strings) == 2 &&
g_str_equal (g_strstrip (strings[1]), "important")) {
important = TRUE;
*important = TRUE;
} else {
*important = FALSE;
}
*value = g_strdup (g_strstrip (strings[0]));
g_strfreev (strings);
return important;
return TRUE;
}
/* Split a CSS2 style into individual style arguments, setting attributes
......@@ -900,10 +902,14 @@ rsvg_parse_style (RsvgHandle * ctx, RsvgState * state, const char *str)
continue;
if (g_strv_length (values) == 2) {
gboolean important;
gchar *style_value = NULL;
parse_style_value (values[1], &style_value, &important);
rsvg_parse_style_pair (ctx, state,
g_strstrip (values[0]),
g_strstrip (values[1]),
is_important (values[1]));
style_value,
important);
g_free (style_value);
}
g_strfreev (values);
}
......
......@@ -10,4 +10,5 @@ rect {fill: white !important;}
<rect class="blue" id="red" x="0" y="0" width="10" height="10"/>
<rect class="blue" id="blue" x="20" y="20" width="10" height="10"/>
<rect id="white" fill="black !important" x="40" y="40" width="10" height="10"/>
<rect id="pink" style="fill: pink !important;" x="60" y="60" width="10" height="10"/>
</svg>
......@@ -102,6 +102,7 @@ static const FixtureData fixtures[] =
{"/styles/!important/#id prior than class", NULL, "styles/important.svg", "#red", "fill", .expected.color = 0xff0000 },
{"/styles/!important/class prior than type", NULL, "styles/important.svg", "#blue", "fill", .expected.color = 0x0000ff },
{"/styles/!important/presentation attribute is invalid", NULL, "styles/important.svg", "#white", "fill", .expected.color = 0xffffff },
{"/styles/!important/style prior than class", NULL, "styles/important.svg", "#pink", "fill", .expected.color = 0xffc0cb },
{"/styles/selectors/descendant", "338160", "styles/bug338160.svg", "#base_shadow", "stroke-width", .expected.length = {2., '\0'}},
};
static const gint n_fixtures = G_N_ELEMENTS (fixtures);
......
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