summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2015-12-12 02:02:04 +0100
committerBenjamin Otte <otte@redhat.com>2015-12-12 02:16:04 +0100
commit971a277419800fbcaa9dafa8bb68fdb19d866aee (patch)
tree0ce504568b8718d82d87da6045a39ea0a497be1a
parent0ad259a178f5172364c3acce41f8d5cde0f571c6 (diff)
downloadgtk+-971a277419800fbcaa9dafa8bb68fdb19d866aee.tar.gz
cssnode: Change style-changed signal
Instead of having old and new style, now have a GtkCssStyleChange opaque object that will compute the changes you are interested in for you. This simplifies change signal handlers quite a bit and avoids lots of repeated computation in every signal handler.
-rw-r--r--gtk/Makefile.am2
-rw-r--r--gtk/gtkaccellabel.c20
-rw-r--r--gtk/gtkcheckbutton.c20
-rw-r--r--gtk/gtkcheckmenuitem.c20
-rw-r--r--gtk/gtkcssnode.c31
-rw-r--r--gtk/gtkcssnodeprivate.h6
-rw-r--r--gtk/gtkcssstylechange.c97
-rw-r--r--gtk/gtkcssstylechangeprivate.h51
-rw-r--r--gtk/gtkcsswidgetnode.c11
-rw-r--r--gtk/gtkexpander.c20
-rw-r--r--gtk/gtklevelbar.c20
-rw-r--r--gtk/gtkmenu.c20
-rw-r--r--gtk/gtkmenuitem.c20
-rw-r--r--gtk/gtkmodelbutton.c20
-rw-r--r--gtk/gtknotebook.c20
-rw-r--r--gtk/gtkpaned.c20
-rw-r--r--gtk/gtkprogressbar.c20
-rw-r--r--gtk/gtkrange.c20
-rw-r--r--gtk/gtkspinbutton.c20
-rw-r--r--gtk/gtkswitch.c20
-rw-r--r--gtk/gtktextview.c20
-rw-r--r--gtk/gtkwindow.c20
-rw-r--r--gtk/inspector/css-node-tree.c16
-rw-r--r--gtk/inspector/gtktreemodelcssnode.c3
24 files changed, 256 insertions, 281 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 9659e98340..6de7f4a3c5 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -425,6 +425,7 @@ gtk_private_h_sources = \
gtkcssstaticstyleprivate.h \
gtkcssstringvalueprivate.h \
gtkcssstylefuncsprivate.h \
+ gtkcssstylechangeprivate.h \
gtkcssstyleprivate.h \
gtkcssstylepropertyprivate.h \
gtkcsstransformvalueprivate.h \
@@ -673,6 +674,7 @@ gtk_base_c_sources = \
gtkcssselector.c \
gtkcssstringvalue.c \
gtkcssstyle.c \
+ gtkcssstylechange.c \
gtkcssshadowsvalue.c \
gtkcssshadowvalue.c \
gtkcssshorthandproperty.c \
diff --git a/gtk/gtkaccellabel.c b/gtk/gtkaccellabel.c
index e4bbdd0efb..bd2a180662 100644
--- a/gtk/gtkaccellabel.c
+++ b/gtk/gtkaccellabel.c
@@ -268,26 +268,14 @@ gtk_accel_label_get_property (GObject *object,
}
static void
-node_style_changed_cb (GtkCssNode *node,
- GtkCssStyle *old_style,
- GtkCssStyle *new_style,
- GtkWidget *widget)
+node_style_changed_cb (GtkCssNode *node,
+ GtkCssStyleChange *change,
+ GtkWidget *widget)
{
- GtkBitmask *changes;
- static GtkBitmask *affects_size = NULL;
-
- if (G_UNLIKELY (affects_size == NULL))
- affects_size = _gtk_css_style_property_get_mask_affecting (GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP);
-
- changes = _gtk_bitmask_new ();
- changes = gtk_css_style_add_difference (changes, old_style, new_style);
-
- if (_gtk_bitmask_intersects (changes, affects_size))
+ if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP))
gtk_widget_queue_resize (widget);
else
gtk_widget_queue_draw (widget);
-
- _gtk_bitmask_free (changes);
}
static void
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c
index 0b4ed9a64b..c0eed7257f 100644
--- a/gtk/gtkcheckbutton.c
+++ b/gtk/gtkcheckbutton.c
@@ -209,26 +209,14 @@ G_GNUC_END_IGNORE_DEPRECATIONS
}
static void
-node_style_changed_cb (GtkCssNode *node,
- GtkCssStyle *old_style,
- GtkCssStyle *new_style,
- GtkWidget *widget)
+node_style_changed_cb (GtkCssNode *node,
+ GtkCssStyleChange *change,
+ GtkWidget *widget)
{
- GtkBitmask *changes;
- static GtkBitmask *affects_size = NULL;
-
- if (G_UNLIKELY (affects_size == NULL))
- affects_size = _gtk_css_style_property_get_mask_affecting (GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP);
-
- changes = _gtk_bitmask_new ();
- changes = gtk_css_style_add_difference (changes, old_style, new_style);
-
- if (_gtk_bitmask_intersects (changes, affects_size))
+ if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP))
gtk_widget_queue_resize (widget);
else
gtk_widget_queue_draw (widget);
-
- _gtk_bitmask_free (changes);
}
static void
diff --git a/gtk/gtkcheckmenuitem.c b/gtk/gtkcheckmenuitem.c
index f1aa0a7f87..d8654a9d8e 100644
--- a/gtk/gtkcheckmenuitem.c
+++ b/gtk/gtkcheckmenuitem.c
@@ -525,26 +525,14 @@ gtk_check_menu_item_get_draw_as_radio (GtkCheckMenuItem *check_menu_item)
}
static void
-node_style_changed_cb (GtkCssNode *node,
- GtkCssStyle *old_style,
- GtkCssStyle *new_style,
- GtkWidget *widget)
+node_style_changed_cb (GtkCssNode *node,
+ GtkCssStyleChange *change,
+ GtkWidget *widget)
{
- GtkBitmask *changes;
- static GtkBitmask *affects_size = NULL;
-
- if (G_UNLIKELY (affects_size == NULL))
- affects_size = _gtk_css_style_property_get_mask_affecting (GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP);
-
- changes = _gtk_bitmask_new ();
- changes = gtk_css_style_add_difference (changes, old_style, new_style);
-
- if (_gtk_bitmask_intersects (changes, affects_size))
+ if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP))
gtk_widget_queue_resize (widget);
else
gtk_widget_queue_draw (widget);
-
- _gtk_bitmask_free (changes);
}
static void
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c
index be4b9d1fd4..9df217abe8 100644
--- a/gtk/gtkcssnode.c
+++ b/gtk/gtkcssnode.c
@@ -106,6 +106,11 @@ enum {
NUM_PROPERTIES
};
+struct _GtkCssNodeStyleChange {
+ GtkCssStyle *old_style;
+ GtkCssStyle *new_style;
+};
+
static guint cssnode_signals[LAST_SIGNAL] = { 0 };
static GParamSpec *cssnode_properties[NUM_PROPERTIES];
@@ -577,14 +582,11 @@ gtk_css_node_real_node_added (GtkCssNode *parent,
}
static void
-gtk_css_node_real_style_changed (GtkCssNode *cssnode,
- GtkCssStyle *old_style,
- GtkCssStyle *new_style)
+gtk_css_node_real_style_changed (GtkCssNode *cssnode,
+ GtkCssStyleChange *change)
{
- g_object_ref (new_style);
- g_object_unref (old_style);
-
- cssnode->style = new_style;
+ g_object_unref (cssnode->style);
+ cssnode->style = g_object_ref (gtk_css_style_change_get_new_style (change));
}
static void
@@ -638,9 +640,9 @@ gtk_css_node_class_init (GtkCssNodeClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkCssNodeClass, style_changed),
NULL, NULL,
- _gtk_marshal_VOID__OBJECT_OBJECT,
- G_TYPE_NONE, 2,
- GTK_TYPE_CSS_STYLE, GTK_TYPE_CSS_STYLE);
+ _gtk_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1,
+ G_TYPE_POINTER);
cssnode_properties[PROP_CLASSES] =
g_param_spec_boxed ("classes", "Classes",
@@ -947,10 +949,17 @@ static gboolean
gtk_css_node_set_style (GtkCssNode *cssnode,
GtkCssStyle *style)
{
+ GtkCssStyleChange change;
+
if (cssnode->style == style)
return FALSE;
- g_signal_emit (cssnode, cssnode_signals[STYLE_CHANGED], 0, cssnode->style, style);
+ gtk_css_style_change_init (&change, cssnode->style, style);
+
+ g_signal_emit (cssnode, cssnode_signals[STYLE_CHANGED], 0, &change);
+
+ gtk_css_style_change_finish (&change);
+
return TRUE;
}
diff --git a/gtk/gtkcssnodeprivate.h b/gtk/gtkcssnodeprivate.h
index 7577d4808a..8624a51678 100644
--- a/gtk/gtkcssnodeprivate.h
+++ b/gtk/gtkcssnodeprivate.h
@@ -19,6 +19,7 @@
#define __GTK_CSS_NODE_PRIVATE_H__
#include "gtkcssnodedeclarationprivate.h"
+#include "gtkcssstylechangeprivate.h"
#include "gtkbitmaskprivate.h"
#include "gtkcsstypesprivate.h"
@@ -31,7 +32,7 @@ G_BEGIN_DECLS
#define GTK_IS_CSS_NODE_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_CSS_NODE))
#define GTK_CSS_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CSS_NODE, GtkCssNodeClass))
-typedef struct _GtkCssNodeClass GtkCssNodeClass;
+typedef struct _GtkCssNodeClass GtkCssNodeClass;
struct _GtkCssNode
{
@@ -70,8 +71,7 @@ struct _GtkCssNodeClass
GtkCssNode *child,
GtkCssNode *previous);
void (* style_changed) (GtkCssNode *cssnode,
- GtkCssStyle *old_style,
- GtkCssStyle *new_style);
+ GtkCssStyleChange *style_change);
gboolean (* init_matcher) (GtkCssNode *cssnode,
GtkCssMatcher *matcher);
diff --git a/gtk/gtkcssstylechange.c b/gtk/gtkcssstylechange.c
new file mode 100644
index 0000000000..49cbc1cf13
--- /dev/null
+++ b/gtk/gtkcssstylechange.c
@@ -0,0 +1,97 @@
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2015 Benjamin Otte <otte@gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gtkcssstylechangeprivate.h"
+
+#include "gtkcssstylepropertyprivate.h"
+
+void
+gtk_css_style_change_init (GtkCssStyleChange *change,
+ GtkCssStyle *old_style,
+ GtkCssStyle *new_style)
+{
+ change->old_style = g_object_ref (old_style);
+ change->new_style = g_object_ref (new_style);
+
+ change->n_compared = 0;
+
+ change->affects = 0;
+ change->has_change = FALSE;
+}
+
+void
+gtk_css_style_change_finish (GtkCssStyleChange *change)
+{
+ g_object_unref (change->old_style);
+ g_object_unref (change->new_style);
+}
+
+GtkCssStyle *
+gtk_css_style_change_get_old_style (GtkCssStyleChange *change)
+{
+ return change->old_style;
+}
+
+GtkCssStyle *
+gtk_css_style_change_get_new_style (GtkCssStyleChange *change)
+{
+ return change->new_style;
+}
+
+static gboolean
+gtk_css_style_compare_next_value (GtkCssStyleChange *change)
+{
+ if (change->n_compared == GTK_CSS_PROPERTY_N_PROPERTIES)
+ return FALSE;
+
+ if (!_gtk_css_value_equal (gtk_css_style_get_value (change->old_style, change->n_compared),
+ gtk_css_style_get_value (change->new_style, change->n_compared)))
+ {
+ change->has_change = TRUE;
+ change->affects |= _gtk_css_style_property_get_affects (_gtk_css_style_property_lookup_by_id (change->n_compared));
+ }
+
+ change->n_compared++;
+
+ return TRUE;
+}
+
+gboolean
+gtk_css_style_change_has_change (GtkCssStyleChange *change)
+{
+ do {
+ if (change->has_change)
+ return TRUE;
+ } while (gtk_css_style_compare_next_value (change));
+
+ return FALSE;
+}
+
+gboolean
+gtk_css_style_change_affects (GtkCssStyleChange *change,
+ GtkCssAffects affects)
+{
+ do {
+ if (change->affects & affects)
+ return TRUE;
+ } while (gtk_css_style_compare_next_value (change));
+
+ return FALSE;
+}
+
diff --git a/gtk/gtkcssstylechangeprivate.h b/gtk/gtkcssstylechangeprivate.h
new file mode 100644
index 0000000000..2fb2aa3c70
--- /dev/null
+++ b/gtk/gtkcssstylechangeprivate.h
@@ -0,0 +1,51 @@
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2015 Benjamin Otte <otte@gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTK_CSS_STYLE_CHANGE_PRIVATE_H__
+#define __GTK_CSS_STYLE_CHANGE_PRIVATE_H__
+
+#include "gtkcssstyleprivate.h"
+
+G_BEGIN_DECLS
+
+typedef struct _GtkCssStyleChange GtkCssStyleChange;
+
+struct _GtkCssStyleChange {
+ GtkCssStyle *old_style;
+ GtkCssStyle *new_style;
+
+ guint n_compared;
+
+ GtkCssAffects affects;
+ guint has_change :1;
+};
+
+void gtk_css_style_change_init (GtkCssStyleChange *change,
+ GtkCssStyle *old_style,
+ GtkCssStyle *new_style);
+void gtk_css_style_change_finish (GtkCssStyleChange *change);
+
+GtkCssStyle * gtk_css_style_change_get_old_style (GtkCssStyleChange *change);
+GtkCssStyle * gtk_css_style_change_get_new_style (GtkCssStyleChange *change);
+
+gboolean gtk_css_style_change_has_change (GtkCssStyleChange *change);
+gboolean gtk_css_style_change_affects (GtkCssStyleChange *change,
+ GtkCssAffects affects);
+
+G_END_DECLS
+
+#endif /* __GTK_CSS_STYLE_CHANGE_PRIVATE_H__ */
diff --git a/gtk/gtkcsswidgetnode.c b/gtk/gtkcsswidgetnode.c
index 63c4b5bd1e..e6dc7019a6 100644
--- a/gtk/gtkcsswidgetnode.c
+++ b/gtk/gtkcsswidgetnode.c
@@ -45,9 +45,8 @@ gtk_css_widget_node_finalize (GObject *object)
}
static void
-gtk_css_widget_node_style_changed (GtkCssNode *cssnode,
- GtkCssStyle *old_style,
- GtkCssStyle *new_style)
+gtk_css_widget_node_style_changed (GtkCssNode *cssnode,
+ GtkCssStyleChange *change)
{
GtkCssWidgetNode *node;
@@ -56,9 +55,11 @@ gtk_css_widget_node_style_changed (GtkCssNode *cssnode,
if (node->widget)
gtk_widget_clear_path (node->widget);
- GTK_CSS_NODE_CLASS (gtk_css_widget_node_parent_class)->style_changed (cssnode, old_style, new_style);
+ GTK_CSS_NODE_CLASS (gtk_css_widget_node_parent_class)->style_changed (cssnode, change);
- node->accumulated_changes = gtk_css_style_add_difference (node->accumulated_changes, new_style, old_style);
+ node->accumulated_changes = gtk_css_style_add_difference (node->accumulated_changes,
+ gtk_css_style_change_get_new_style (change),
+ gtk_css_style_change_get_old_style (change));
}
static gboolean
diff --git a/gtk/gtkexpander.c b/gtk/gtkexpander.c
index c75aafd202..68988881ce 100644
--- a/gtk/gtkexpander.c
+++ b/gtk/gtkexpander.c
@@ -383,26 +383,14 @@ gtk_expander_class_init (GtkExpanderClass *klass)
}
static void
-node_style_changed_cb (GtkCssNode *node,
- GtkCssStyle *old_style,
- GtkCssStyle *new_style,
- GtkWidget *widget)
+node_style_changed_cb (GtkCssNode *node,
+ GtkCssStyleChange *change,
+ GtkWidget *widget)
{
- GtkBitmask *changes;
- static GtkBitmask *affects_size = NULL;
-
- if (G_UNLIKELY (affects_size == NULL))
- affects_size = _gtk_css_style_property_get_mask_affecting (GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP);
-
- changes = _gtk_bitmask_new ();
- changes = gtk_css_style_add_difference (changes, old_style, new_style);
-
- if (_gtk_bitmask_intersects (changes, affects_size))
+ if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP))
gtk_widget_queue_resize (widget);
else
gtk_widget_queue_draw (widget);
-
- _gtk_bitmask_free (changes);
}
static void
diff --git a/gtk/gtklevelbar.c b/gtk/gtklevelbar.c
index a5374edd63..2477d12ba6 100644
--- a/gtk/gtklevelbar.c
+++ b/gtk/gtklevelbar.c
@@ -574,26 +574,14 @@ gtk_level_bar_size_allocate (GtkWidget *widget,
}
static void
-node_style_changed_cb (GtkCssNode *node,
- GtkCssStyle *old_style,
- GtkCssStyle *new_style,
- GtkWidget *widget)
+node_style_changed_cb (GtkCssNode *node,
+ GtkCssStyleChange *change,
+ GtkWidget *widget)
{
- GtkBitmask *changes;
- static GtkBitmask *affects_size = NULL;
-
- if (G_UNLIKELY (affects_size == NULL))
- affects_size = _gtk_css_style_property_get_mask_affecting (GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP);
-
- changes = _gtk_bitmask_new ();
- changes = gtk_css_style_add_difference (changes, old_style, new_style);
-
- if (_gtk_bitmask_intersects (changes, affects_size))
+ if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP))
gtk_widget_queue_resize (widget);
else
gtk_widget_queue_draw (widget);
-
- _gtk_bitmask_free (changes);
}
static void
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index 771362dcd3..59dfb4aaad 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -1095,26 +1095,14 @@ gtk_menu_window_event (GtkWidget *window,
}
static void
-node_style_changed_cb (GtkCssNode *node,
- GtkCssStyle *old_style,
- GtkCssStyle *new_style,
- GtkWidget *widget)
+node_style_changed_cb (GtkCssNode *node,
+ GtkCssStyleChange *change,
+ GtkWidget *widget)
{
- GtkBitmask *changes;
- static GtkBitmask *affects_size = NULL;
-
- if (G_UNLIKELY (affects_size == NULL))
- affects_size = _gtk_css_style_property_get_mask_affecting (GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP);
-
- changes = _gtk_bitmask_new ();
- changes = gtk_css_style_add_difference (changes, old_style, new_style);
-
- if (_gtk_bitmask_intersects (changes, affects_size))
+ if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP))
gtk_widget_queue_resize (widget);
else
gtk_widget_queue_draw (widget);
-
- _gtk_bitmask_free (changes);
}
static void
diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c
index b36bc1b048..252b93ca8d 100644
--- a/gtk/gtkmenuitem.c
+++ b/gtk/gtkmenuitem.c
@@ -1328,26 +1328,14 @@ gtk_menu_item_set_use_action_appearance (GtkMenuItem *menu_item,
}
static void
-node_style_changed_cb (GtkCssNode *node,
- GtkCssStyle *old_style,
- GtkCssStyle *new_style,
- GtkWidget *widget)
+node_style_changed_cb (GtkCssNode *node,
+ GtkCssStyleChange *change,
+ GtkWidget *widget)
{
- GtkBitmask *changes;
- static GtkBitmask *affects_size = NULL;
-
- if (G_UNLIKELY (affects_size == NULL))
- affects_size = _gtk_css_style_property_get_mask_affecting (GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP);
-
- changes = _gtk_bitmask_new ();
- changes = gtk_css_style_add_difference (changes, old_style, new_style);
-
- if (_gtk_bitmask_intersects (changes, affects_size))
+ if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP))
gtk_widget_queue_resize (widget);
else
gtk_widget_queue_draw (widget);
-
- _gtk_bitmask_free (changes);
}
static void
diff --git a/gtk/gtkmodelbutton.c b/gtk/gtkmodelbutton.c
index 3958345260..e9f3132eeb 100644
--- a/gtk/gtkmodelbutton.c
+++ b/gtk/gtkmodelbutton.c
@@ -1086,26 +1086,14 @@ gtk_model_button_class_init (GtkModelButtonClass *class)
}
static void
-node_style_changed_cb (GtkCssNode *node,
- GtkCssStyle *old_style,
- GtkCssStyle *new_style,
- GtkWidget *widget)
+node_style_changed_cb (GtkCssNode *node,
+ GtkCssStyleChange *change,
+ GtkWidget *widget)
{
- GtkBitmask *changes;
- static GtkBitmask *affects_size = NULL;
-
- if (G_UNLIKELY (affects_size == NULL))
- affects_size = _gtk_css_style_property_get_mask_affecting (GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP);
-
- changes = _gtk_bitmask_new ();
- changes = gtk_css_style_add_difference (changes, old_style, new_style);
-
- if (_gtk_bitmask_intersects (changes, affects_size))
+ if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP))
gtk_widget_queue_resize (widget);
else
gtk_widget_queue_draw (widget);
-
- _gtk_bitmask_free (changes);
}
static void
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 91af61ba37..bb50c0bab1 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -1210,26 +1210,14 @@ gtk_notebook_class_init (GtkNotebookClass *class)
}
static void
-node_style_changed_cb (GtkCssNode *node,
- GtkCssStyle *old_style,
- GtkCssStyle *new_style,
- GtkWidget *widget)
+node_style_changed_cb (GtkCssNode *node,
+ GtkCssStyleChange *change,
+ GtkWidget *widget)
{
- GtkBitmask *changes;
- static GtkBitmask *affects_size = NULL;
-
- if (G_UNLIKELY (affects_size == NULL))
- affects_size = _gtk_css_style_property_get_mask_affecting (GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP);
-
- changes = _gtk_bitmask_new ();
- changes = gtk_css_style_add_difference (changes, old_style, new_style);
-
- if (_gtk_bitmask_intersects (changes, affects_size))
+ if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP))
gtk_widget_queue_resize (widget);
else
gtk_widget_queue_draw (widget);
-
- _gtk_bitmask_free (changes);
}
static void
diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c
index 246d6cc34b..f7c8da83a3 100644
--- a/gtk/gtkpaned.c
+++ b/gtk/gtkpaned.c
@@ -785,26 +785,14 @@ pan_gesture_drag_end_cb (GtkGestureDrag *gesture,
}
static void
-node_style_changed_cb (GtkCssNode *node,
- GtkCssStyle *old_style,
- GtkCssStyle *new_style,
- GtkWidget *widget)
+node_style_changed_cb (GtkCssNode *node,
+ GtkCssStyleChange *change,
+ GtkWidget *widget)
{
- GtkBitmask *changes;
- static GtkBitmask *affects_size = NULL;
-
- if (G_UNLIKELY (affects_size == NULL))
- affects_size = _gtk_css_style_property_get_mask_affecting (GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP);
-
- changes = _gtk_bitmask_new ();
- changes = gtk_css_style_add_difference (changes, old_style, new_style);
-
- if (_gtk_bitmask_intersects (changes, affects_size))
+ if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP))
gtk_widget_queue_resize (widget);
else
gtk_widget_queue_draw (widget);
-
- _gtk_bitmask_free (changes);
}
static void
diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c
index 2b325e1b6e..0a845a0148 100644
--- a/gtk/gtkprogressbar.c
+++ b/gtk/gtkprogressbar.c
@@ -345,26 +345,14 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class)
}
static void
-node_style_changed_cb (GtkCssNode *node,
- GtkCssStyle *old_style,
- GtkCssStyle *new_style,
- GtkWidget *widget)
+node_style_changed_cb (GtkCssNode *node,
+ GtkCssStyleChange *change,
+ GtkWidget *widget)
{
- GtkBitmask *changes;
- static GtkBitmask *affects_size = NULL;
-
- if (G_UNLIKELY (affects_size == NULL))
- affects_size = _gtk_css_style_property_get_mask_affecting (GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP);
-
- changes = _gtk_bitmask_new ();
- changes = gtk_css_style_add_difference (changes, old_style, new_style);
-
- if (_gtk_bitmask_intersects (changes, affects_size))
+ if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP))
gtk_widget_queue_resize (widget);
else
gtk_widget_queue_draw (widget);
-
- _gtk_bitmask_free (changes);
}
static void
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 6e225bd0f0..e177ac79af 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -730,26 +730,14 @@ gtk_range_get_property (GObject *object,
}
static void
-node_style_changed_cb (GtkCssNode *node,
- GtkCssStyle *old_style,
- GtkCssStyle *new_style,
- GtkWidget *widget)
+node_style_changed_cb (GtkCssNode *node,
+ GtkCssStyleChange *change,
+ GtkWidget *widget)
{
- GtkBitmask *changes;
- static GtkBitmask *affects_size = NULL;
-
- if (G_UNLIKELY (affects_size == NULL))
- affects_size = _gtk_css_style_property_get_mask_affecting (GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP);
-
- changes = _gtk_bitmask_new ();
- changes = gtk_css_style_add_difference (changes, old_style, new_style);
-
- if (_gtk_bitmask_intersects (changes, affects_size))
+ if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP))
gtk_widget_queue_resize (widget);
else
gtk_widget_queue_draw (widget);
-
- _gtk_bitmask_free (changes);
}
static void
diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c
index 27f60d3b6a..35a59ccb49 100644
--- a/gtk/gtkspinbutton.c
+++ b/gtk/gtkspinbutton.c
@@ -726,26 +726,14 @@ swipe_gesture_update (GtkGesture *gesture,
}
static void
-node_style_changed_cb (GtkCssNode *node,
- GtkCssStyle *old_style,
- GtkCssStyle *new_style,
- GtkWidget *widget)
+node_style_changed_cb (GtkCssNode *node,
+ GtkCssStyleChange *change,
+ GtkWidget *widget)
{
- GtkBitmask *changes;
- static GtkBitmask *affects_size = NULL;
-
- if (G_UNLIKELY (affects_size == NULL))
- affects_size = _gtk_css_style_property_get_mask_affecting (GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP);
-
- changes = _gtk_bitmask_new ();
- changes = gtk_css_style_add_difference (changes, old_style, new_style);
-
- if (_gtk_bitmask_intersects (changes, affects_size))
+ if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP))
gtk_widget_queue_resize (widget);
else
gtk_widget_queue_draw (widget);
-
- _gtk_bitmask_free (changes);
}
static void
diff --git a/gtk/gtkswitch.c b/gtk/gtkswitch.c
index 764820924d..f4e5e04c73 100644
--- a/gtk/gtkswitch.c
+++ b/gtk/gtkswitch.c
@@ -870,26 +870,14 @@ state_set (GtkSwitch *sw, gboolean state)
}
static void
-node_style_changed_cb (GtkCssNode *node,
- GtkCssStyle *old_style,
- GtkCssStyle *new_style,
- GtkWidget *widget)
+node_style_changed_cb (GtkCssNode *node,
+ GtkCssStyleChange *change,
+ GtkWidget *widget)
{
- GtkBitmask *changes;
- static GtkBitmask *affects_size = NULL;
-
- if (G_UNLIKELY (affects_size == NULL))
- affects_size = _gtk_css_style_property_get_mask_affecting (GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP);
-
- changes = _gtk_bitmask_new ();
- changes = gtk_css_style_add_difference (changes, old_style, new_style);
-
- if (_gtk_bitmask_intersects (changes, affects_size))
+ if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP))
gtk_widget_queue_resize (widget);
else
gtk_widget_queue_draw (widget);
-
- _gtk_bitmask_free (changes);
}
static void
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index eb43db5f91..d6c4aa1c57 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -9741,26 +9741,14 @@ gtk_text_view_selection_bubble_popup_set (GtkTextView *text_view)
/* Child GdkWindows */
static void
-node_style_changed_cb (GtkCssNode *node,
- GtkCssStyle *old_style,
- GtkCssStyle *new_style,
- GtkWidget *widget)
+node_style_changed_cb (GtkCssNode *node,
+ GtkCssStyleChange *change,
+ GtkWidget *widget)
{
- GtkBitmask *changes;
- static GtkBitmask *affects_size = NULL;
-
- if (G_UNLIKELY (affects_size == NULL))
- affects_size = _gtk_css_style_property_get_mask_affecting (GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP);
-
- changes = _gtk_bitmask_new ();
- changes = gtk_css_style_add_difference (changes, old_style, new_style);
-
- if (_gtk_bitmask_intersects (changes, affects_size))
+ if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP))
gtk_widget_queue_resize (widget);
else
gtk_widget_queue_draw (widget);
-
- _gtk_bitmask_free (changes);
}
static void
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index b8476c0b47..97c6e1f0c3 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1597,26 +1597,14 @@ drag_gesture_update_cb (GtkGestureDrag *gesture,
}
static void
-node_style_changed_cb (GtkCssNode *node,
- GtkCssStyle *old_style,
- GtkCssStyle *new_style,
- GtkWidget *widget)
+node_style_changed_cb (GtkCssNode *node,
+ GtkCssStyleChange *change,
+ GtkWidget *widget)
{
- GtkBitmask *changes;
- static GtkBitmask *affects_size = NULL;
-
- if (G_UNLIKELY (affects_size == NULL))
- affects_size = _gtk_css_style_property_get_mask_affecting (GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP);
-
- changes = _gtk_bitmask_new ();
- changes = gtk_css_style_add_difference (changes, old_style, new_style);
-
- if (_gtk_bitmask_intersects (changes, affects_size))
+ if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP))
gtk_widget_queue_resize (widget);
else
gtk_widget_queue_draw (widget);
-
- _gtk_bitmask_free (changes);
}
static void
diff --git a/gtk/inspector/css-node-tree.c b/gtk/inspector/css-node-tree.c
index bd0ec29ca5..8812398d3b 100644
--- a/gtk/inspector/css-node-tree.c
+++ b/gtk/inspector/css-node-tree.c
@@ -533,13 +533,15 @@ gtk_inspector_css_node_tree_set_object (GtkInspectorCssNodeTree *cnt,
static void
gtk_inspector_css_node_tree_update_style (GtkCssNode *node,
- GtkCssStyle *old_style,
- GtkCssStyle *new_style,
+ GtkCssStyleChange *change,
GtkInspectorCssNodeTree *cnt)
{
GtkInspectorCssNodeTreePrivate *priv = cnt->priv;
+ GtkCssStyle *new_style;
gint i;
+ new_style = gtk_css_style_change_get_new_style (change);
+
for (i = 0; i < _gtk_css_style_property_get_n_properties (); i++)
{
GtkCssStyleProperty *prop;
@@ -586,6 +588,7 @@ gtk_inspector_css_node_tree_set_node (GtkInspectorCssNodeTree *cnt,
GtkCssNode *node)
{
GtkInspectorCssNodeTreePrivate *priv = cnt->priv;
+ GtkCssStyleChange change;
GString *s;
GType type;
const gchar *name;
@@ -598,11 +601,16 @@ gtk_inspector_css_node_tree_set_node (GtkInspectorCssNodeTree *cnt,
if (node)
g_object_ref (node);
+ gtk_css_style_change_init (&change,
+ node ? gtk_css_node_get_style (node) : NULL,
+ priv->node ? gtk_css_node_get_style (priv->node) : NULL);
+
gtk_inspector_css_node_tree_update_style (node,
- node ? gtk_css_node_get_style (node) : NULL,
- priv->node ? gtk_css_node_get_style (priv->node) : NULL,
+ &change,
cnt);
+ gtk_css_style_change_finish (&change);
+
gtk_inspector_css_node_tree_unset_node (cnt);
priv->node = node;
diff --git a/gtk/inspector/gtktreemodelcssnode.c b/gtk/inspector/gtktreemodelcssnode.c
index ee55211d0b..0af42b167f 100644
--- a/gtk/inspector/gtktreemodelcssnode.c
+++ b/gtk/inspector/gtktreemodelcssnode.c
@@ -450,8 +450,7 @@ notify_cb (GtkCssNode *node,
static void
style_changed_cb (GtkCssNode *node,
- GtkCssStyle *old_style,
- GtkCssStyle *new_style,
+ GtkCssStyleChange *change,
GtkTreeModelCssNode *model)
{
GtkTreeIter iter;