style cascade: Propagate errors

When we compute values, the provider we use ends up being the
style cascade. If we hit a parser error when parsing variable-bearing
property values at compute time, we emit the error on that provider.

By making the cascade propagate the error back to the proper css
provider that contains the section in question, we get it reported
back to the css editor in the inspector.
This commit is contained in:
Matthias Clasen 2024-05-08 16:03:21 -04:00 committed by Alice Mikhaylenko
parent b2fb624496
commit 496aee5b02

View File

@ -208,6 +208,29 @@ gtk_style_cascade_lookup (GtkStyleProvider *provider,
gtk_style_cascade_iter_clear (&iter);
}
static void
gtk_style_cascade_emit_error (GtkStyleProvider *provider,
GtkCssSection *section,
const GError *error)
{
GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
GtkStyleCascadeIter iter;
GtkStyleProvider *item;
for (item = gtk_style_cascade_iter_init (cascade, &iter);
item;
item = gtk_style_cascade_iter_next (cascade, &iter))
{
if (gtk_style_provider_has_section (item, section))
{
gtk_style_provider_emit_error (item, section, (GError *) error);
break;
}
}
gtk_style_cascade_iter_clear (&iter);
}
static void
gtk_style_cascade_provider_iface_init (GtkStyleProviderInterface *iface)
{
@ -216,6 +239,7 @@ gtk_style_cascade_provider_iface_init (GtkStyleProviderInterface *iface)
iface->get_scale = gtk_style_cascade_get_scale;
iface->get_keyframes = gtk_style_cascade_get_keyframes;
iface->lookup = gtk_style_cascade_lookup;
iface->emit_error = gtk_style_cascade_emit_error;
}
G_DEFINE_TYPE_EXTENDED (GtkStyleCascade, _gtk_style_cascade, G_TYPE_OBJECT, 0,