From c4b77a5945dd941a288401ef9677ceca900aade8 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 13 Jan 2020 20:13:13 -0500 Subject: [PATCH] cssstyle: Try harder to skip initial values Compare values against the computed value of their properties initial value. This works for fine for all expect the border-width properties, whose special handling defeats this. --- gtk/gtkcssstyle.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/gtk/gtkcssstyle.c b/gtk/gtkcssstyle.c index 53561657cb..d6ff5cbb84 100644 --- a/gtk/gtkcssstyle.c +++ b/gtk/gtkcssstyle.c @@ -37,6 +37,7 @@ #include "gtkstyleanimationprivate.h" #include "gtkstylepropertyprivate.h" #include "gtkstyleproviderprivate.h" +#include "gtksettings.h" G_DEFINE_ABSTRACT_TYPE (GtkCssStyle, gtk_css_style, G_TYPE_OBJECT) @@ -137,13 +138,24 @@ gtk_css_style_print (GtkCssStyle *style, GtkCssValue *value; const char *name; - section = gtk_css_style_get_section (style, i); - if (!section && skip_initial) - continue; - - prop = _gtk_css_style_property_lookup_by_id (i); - name = _gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop)); value = gtk_css_style_get_value (style, i); + prop = _gtk_css_style_property_lookup_by_id (i); + if (skip_initial) + { + GtkCssValue *initial = _gtk_css_style_property_get_initial_value (prop); + GtkCssStyle *default_style = gtk_css_static_style_get_default (); + GtkCssValue *computed = _gtk_css_value_compute (initial, i, + GTK_STYLE_PROVIDER (gtk_settings_get_default ()), + default_style, + default_style); + gboolean is_initial = _gtk_css_value_equal (value, computed); + gtk_css_value_unref (computed); + if (is_initial) + continue; + } + + section = gtk_css_style_get_section (style, i); + name = _gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop)); g_string_append_printf (string, "%*s%s: ", indent, "", name); _gtk_css_value_print (value, string);