[gtk+] cssnode: Change style-changed signal



commit 971a277419800fbcaa9dafa8bb68fdb19d866aee
Author: Benjamin Otte <otte redhat com>
Date:   Sat Dec 12 02:02:04 2015 +0100

    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.

 gtk/Makefile.am                     |    2 +
 gtk/gtkaccellabel.c                 |   20 ++------
 gtk/gtkcheckbutton.c                |   20 ++------
 gtk/gtkcheckmenuitem.c              |   20 ++------
 gtk/gtkcssnode.c                    |   31 +++++++----
 gtk/gtkcssnodeprivate.h             |    6 +-
 gtk/gtkcssstylechange.c             |   97 +++++++++++++++++++++++++++++++++++
 gtk/gtkcssstylechangeprivate.h      |   51 ++++++++++++++++++
 gtk/gtkcsswidgetnode.c              |   11 ++--
 gtk/gtkexpander.c                   |   20 ++------
 gtk/gtklevelbar.c                   |   20 ++------
 gtk/gtkmenu.c                       |   20 ++------
 gtk/gtkmenuitem.c                   |   20 ++------
 gtk/gtkmodelbutton.c                |   20 ++------
 gtk/gtknotebook.c                   |   20 ++------
 gtk/gtkpaned.c                      |   20 ++------
 gtk/gtkprogressbar.c                |   20 ++------
 gtk/gtkrange.c                      |   20 ++------
 gtk/gtkspinbutton.c                 |   20 ++------
 gtk/gtkswitch.c                     |   20 ++------
 gtk/gtktextview.c                   |   20 ++------
 gtk/gtkwindow.c                     |   20 ++------
 gtk/inspector/css-node-tree.c       |   16 ++++--
 gtk/inspector/gtktreemodelcssnode.c |    3 +-
 24 files changed, 256 insertions(+), 281 deletions(-)
---
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 9659e98..6de7f4a 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 e4bbdd0..bd2a180 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 0b4ed9a..c0eed72 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 f1aa0a7..d8654a9 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 be4b9d1..9df217a 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 7577d48..8624a51 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 0000000..49cbc1c
--- /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 0000000..2fb2aa3
--- /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 63c4b5b..e6dc701 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 c75aafd..6898888 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 a5374ed..2477d12 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 771362d..59dfb4a 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 b36bc1b..252b93c 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 3958345..e9f3132 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 91af61b..bb50c0b 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 246d6cc..f7c8da8 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 2b325e1..0a845a0 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 6e225bd..e177ac7 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 27f60d3..35a59cc 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 7648209..f4e5e04 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 eb43db5..d6c4aa1 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 b8476c0..97c6e1f 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 bd0ec29..8812398 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 ee55211..0af42b1 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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]