CSS pseudo-classes ignored if another style sheet contains overlapping rule
When looking up CSS properties, pseudo-classes are ignored if another style sheet contains an overlapping rule.
Steps to reproduce
#include <gtk/gtk.h>
static void add(const char* data)
{
GtkCssProvider* provider = gtk_css_provider_new();
gtk_css_provider_load_from_data(provider, data, -1, NULL);
gtk_style_context_add_provider_for_screen(
gdk_screen_get_default(),
GTK_STYLE_PROVIDER(provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
int main()
{
gtk_init(0, NULL);
add(".test { color: red }"
".test:active { color: green }");
add(".test { color: blue }");
GtkWidget* w = gtk_invisible_new();
GtkStyleContext* ctx = gtk_widget_get_style_context(w);
gtk_style_context_add_class(ctx, "test");
GdkRGBA fg;
gtk_style_context_get_color(ctx, GTK_STATE_FLAG_NORMAL, &fg);
GdkRGBA fgs;
gtk_style_context_get_color(ctx, GTK_STATE_FLAG_ACTIVE, &fgs);
g_print(
"fg=%s fgs=%s\n",
gdk_rgba_to_string(&fg),
gdk_rgba_to_string(&fgs));
}
Current behavior
Currently, only the color from the second sheet is being used.
fg=rgb(0,0,255) fgs=rgb(0,0,255)
Expected outcome
It should pull the inactive color from the second stylesheet and the :active color from the first.
fg=rgb(0,0,255) fgs=rgb(0,128,0)
Version information
GTK: 3.24.14
OS: Debian/testing
Additional information
In a browser, if you run the following and click on "test", you'll see that it turns green, as expected.
<style>
.test {
color: red;
}
.test:active {
color: green;
}
.test {
color: blue;
font-size: 25px;
}
</style>
<div class="test">
test
</div>