[gtk+/wip/cssnode3: 12/91] stylecontext: Move relevant_changes tracking to GtkCssWidgetNode



commit 5d3162f2739289dd410d126ed637e95d11d62559
Author: Benjamin Otte <otte redhat com>
Date:   Sun Jan 25 06:14:48 2015 +0100

    stylecontext: Move relevant_changes tracking to GtkCssWidgetNode

 gtk/gtkcsswidgetnode.c        |   18 +++++++++++++-
 gtk/gtkcsswidgetnodeprivate.h |   12 ++++++---
 gtk/gtkstylecontext.c         |   52 +++++++++++++++-------------------------
 gtk/gtkstylecontextprivate.h  |    4 +-
 4 files changed, 47 insertions(+), 39 deletions(-)
---
diff --git a/gtk/gtkcsswidgetnode.c b/gtk/gtkcsswidgetnode.c
index 0a4b17b..dd0a105 100644
--- a/gtk/gtkcsswidgetnode.c
+++ b/gtk/gtkcsswidgetnode.c
@@ -31,11 +31,13 @@ gtk_css_widget_node_invalidate (GtkCssNode   *node,
   GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
   GtkStyleContext *context;
 
+  widget_node->pending_changes |= change;
+
   if (widget_node->widget == NULL)
     return;
 
   context = gtk_widget_get_style_context (widget_node->widget);
-  _gtk_style_context_invalidate_root_node (context, change);
+  gtk_style_context_set_invalid (context, TRUE);
 }
 
 static GtkWidgetPath *
@@ -119,3 +121,17 @@ gtk_css_widget_node_get_widget (GtkCssWidgetNode *node)
 
   return node->widget;
 }
+
+GtkCssChange
+gtk_css_widget_node_reset_change (GtkCssWidgetNode *node)
+{
+  GtkCssChange result;
+
+  gtk_internal_return_val_if_fail (GTK_IS_CSS_WIDGET_NODE (node), 0);
+
+  result = node->pending_changes;
+  node->pending_changes = 0;
+
+  return result;
+}
+
diff --git a/gtk/gtkcsswidgetnodeprivate.h b/gtk/gtkcsswidgetnodeprivate.h
index 78c4337..2928653 100644
--- a/gtk/gtkcsswidgetnodeprivate.h
+++ b/gtk/gtkcsswidgetnodeprivate.h
@@ -38,6 +38,8 @@ struct _GtkCssWidgetNode
   GtkCssNode node;
 
   GtkWidget *widget;
+
+  GtkCssChange pending_changes;
 };
 
 struct _GtkCssWidgetNodeClass
@@ -45,13 +47,15 @@ struct _GtkCssWidgetNodeClass
   GtkCssNodeClass node_class;
 };
 
-GType                   gtk_css_widget_node_get_type         (void) G_GNUC_CONST;
+GType                   gtk_css_widget_node_get_type            (void) G_GNUC_CONST;
+
+GtkCssNode *            gtk_css_widget_node_new                 (GtkWidget              *widget);
 
-GtkCssNode *            gtk_css_widget_node_new              (GtkWidget         *widget);
+void                    gtk_css_widget_node_widget_destroyed    (GtkCssWidgetNode       *node);
 
-void                    gtk_css_widget_node_widget_destroyed (GtkCssWidgetNode  *node);
+GtkWidget *             gtk_css_widget_node_get_widget          (GtkCssWidgetNode       *node);
 
-GtkWidget *             gtk_css_widget_node_get_widget       (GtkCssWidgetNode  *node);
+GtkCssChange            gtk_css_widget_node_reset_change        (GtkCssWidgetNode       *node);
 
 G_END_DECLS
 
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index c818865..c8e3912 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -161,8 +161,6 @@ struct _GtkStyleContextPrivate
   guint frame_clock_update_id;
   GdkFrameClock *frame_clock;
 
-  GtkCssChange pending_changes;
-
   const GtkBitmask *invalidating_context;
   guint animating : 1;
   guint invalid : 1;
@@ -846,7 +844,7 @@ gtk_style_context_lookup_style_for_state (GtkStyleContext *context,
   return values;
 }
 
-static void
+void
 gtk_style_context_set_invalid (GtkStyleContext *context,
                                gboolean         invalid)
 {
@@ -2850,7 +2848,25 @@ _gtk_style_context_validate (GtkStyleContext  *context,
 
   priv = context->priv;
 
-  change |= priv->pending_changes;
+  if (G_UNLIKELY (gtk_style_context_is_saved (context)))
+    {
+      cssnode = gtk_style_context_get_root (context);
+      if (GTK_IS_CSS_WIDGET_NODE (cssnode))
+        {
+          GtkWidget *widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (cssnode));
+          g_warning ("unmatched gtk_style_context_save/restore() detected while validating context for %s 
%p",
+                     gtk_widget_get_name (widget), widget);
+        }
+      else
+        {
+          g_warning ("unmatched gtk_style_context_save/restore() detected while validating context");
+        }
+    }
+  else
+    cssnode = priv->cssnode;
+
+  if (GTK_IS_CSS_WIDGET_NODE (cssnode))
+    change |= gtk_css_widget_node_reset_change (GTK_CSS_WIDGET_NODE (cssnode));
   
   /* If you run your application with
    *   GTK_DEBUG=no-css-cache
@@ -2870,24 +2886,6 @@ _gtk_style_context_validate (GtkStyleContext  *context,
   if (!priv->invalid && change == 0 && _gtk_bitmask_is_empty (parent_changes))
     return;
 
-  if (G_UNLIKELY (gtk_style_context_is_saved (context)))
-    {
-      cssnode = gtk_style_context_get_root (context);
-      if (GTK_IS_CSS_WIDGET_NODE (cssnode))
-        {
-          GtkWidget *widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (cssnode));
-          g_warning ("unmatched gtk_style_context_save/restore() detected while validating context for %s 
%p",
-                     gtk_widget_get_name (widget), widget);
-        }
-      else
-        {
-          g_warning ("unmatched gtk_style_context_save/restore() detected while validating context");
-        }
-    }
-  else
-    cssnode = priv->cssnode;
-
-  priv->pending_changes = 0;
   gtk_style_context_set_invalid (context, FALSE);
 
   current = gtk_css_node_get_style (cssnode);
@@ -2978,16 +2976,6 @@ _gtk_style_context_validate (GtkStyleContext  *context,
 }
 
 void
-_gtk_style_context_invalidate_root_node (GtkStyleContext *context,
-                                         GtkCssChange     change)
-{
-  GtkStyleContextPrivate *priv = context->priv;
-
-  priv->pending_changes |= change;
-  gtk_style_context_set_invalid (context, TRUE);
-}
-
-void
 _gtk_style_context_queue_invalidate (GtkStyleContext *context,
                                      GtkCssChange     change)
 {
diff --git a/gtk/gtkstylecontextprivate.h b/gtk/gtkstylecontextprivate.h
index 1db9cbd..0a0c31f 100644
--- a/gtk/gtkstylecontextprivate.h
+++ b/gtk/gtkstylecontextprivate.h
@@ -48,8 +48,8 @@ void           _gtk_style_context_validate                   (GtkStyleContext *c
                                                               const GtkBitmask*parent_changes);
 void           _gtk_style_context_queue_invalidate           (GtkStyleContext *context,
                                                               GtkCssChange     change);
-void           _gtk_style_context_invalidate_root_node       (GtkStyleContext *context,
-                                                              GtkCssChange     change);
+void           gtk_style_context_set_invalid                 (GtkStyleContext *context,
+                                                              gboolean         invalid);
 gboolean       _gtk_style_context_check_region_name          (const gchar     *str);
 
 gboolean       _gtk_style_context_resolve_color              (GtkStyleContext    *context,


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