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.
This commit is contained in:
Matthias Clasen
2020-01-13 20:13:13 -05:00
parent 371625e7f2
commit c4b77a5945

View File

@@ -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);