[gtk/wip/matthiasc/css-change: 13/27] cssstyle: Try harder to skip initial values
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/css-change: 13/27] cssstyle: Try harder to skip initial values
- Date: Wed, 15 Jan 2020 20:58:52 +0000 (UTC)
commit 791a81f092dfdc9f2da70305779f7728693d0b42
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jan 13 20:13:13 2020 -0500
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 | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 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;
-
+ 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));
- value = gtk_css_style_get_value (style, i);
g_string_append_printf (string, "%*s%s: ", indent, "", name);
_gtk_css_value_print (value, string);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]