[gtk+/wip/cssnode3: 61/102] cssnode: Make parent style change part of GtkCssNode



commit bfa8086e9f21e8fe16cd1821f1e69d6f180fdfc6
Author: Benjamin Otte <otte redhat com>
Date:   Wed Feb 18 06:01:41 2015 +0100

    cssnode: Make parent style change part of GtkCssNode

 gtk/gtkcontainer.c       |    3 +--
 gtk/gtkcssnode.c         |   26 ++++++++++++--------------
 gtk/gtkcssnodeprivate.h  |    6 ++----
 gtk/gtkcsstypes.c        |    6 ++++--
 gtk/gtkcsstypesprivate.h |    1 +
 gtk/gtkcsswidgetnode.c   |   13 +++++--------
 gtk/gtkwindow.c          |    3 +--
 7 files changed, 26 insertions(+), 32 deletions(-)
---
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index d681dbd..306ecf4 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -1848,8 +1848,7 @@ gtk_container_idle_sizer (GdkFrameClock *clock,
     {
       container->priv->restyle_pending = FALSE;
       gtk_css_node_validate (gtk_widget_get_css_node (GTK_WIDGET (container)),
-                             gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (GTK_WIDGET 
(container))),
-                             FALSE);
+                             gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (GTK_WIDGET 
(container))));
     }
 
   /* we may be invoked with a container_resize_queue of NULL, because
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c
index de7700e..93d5395 100644
--- a/gtk/gtkcssnode.c
+++ b/gtk/gtkcssnode.c
@@ -25,7 +25,7 @@
 
 /* When these change we do a full restyling. Otherwise we try to figure out
  * if we need to change things. */
-#define GTK_CSS_RADICAL_CHANGE (GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_CLASS | GTK_CSS_CHANGE_SOURCE)
+#define GTK_CSS_RADICAL_CHANGE (GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_CLASS | GTK_CSS_CHANGE_SOURCE | 
GTK_CSS_CHANGE_PARENT_STYLE)
 
 G_DEFINE_TYPE (GtkCssNode, gtk_css_node, G_TYPE_OBJECT)
 
@@ -253,8 +253,7 @@ static GtkCssStyle *
 gtk_css_node_real_validate (GtkCssNode       *cssnode,
                             GtkCssStyle      *current_style,
                             gint64            timestamp,
-                            GtkCssChange      change,
-                            gboolean          parent_changed)
+                            GtkCssChange      change)
 {
   return NULL;
 }
@@ -535,20 +534,20 @@ gtk_css_node_set_style (GtkCssNode  *cssnode,
 }
 
 static void
-gtk_css_node_propagate_pending_changes (GtkCssNode *cssnode)
+gtk_css_node_propagate_pending_changes (GtkCssNode *cssnode,
+                                        gboolean    style_changed)
 {
   GtkCssChange change, child_change;
   GtkCssNode *child;
 
-  if (!cssnode->invalid)
-    return;
-
   change = _gtk_css_change_for_child (cssnode->pending_changes);
   if (cssnode->children_changed)
     {
       change |= GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_ANY_SIBLING;
       cssnode->children_changed = FALSE;
     }
+  if (style_changed)
+    change |= GTK_CSS_CHANGE_PARENT_STYLE;
 
   for (child = gtk_css_node_get_first_child (cssnode);
        child;
@@ -579,7 +578,7 @@ gtk_css_node_ensure_style (GtkCssNode *cssnode)
                                                               cssnode->pending_changes,
                                                               cssnode->style);
 
-  gtk_css_node_propagate_pending_changes (cssnode);
+  gtk_css_node_propagate_pending_changes (cssnode, new_style != NULL);
 
   if (new_style)
     {
@@ -769,8 +768,7 @@ gtk_css_node_invalidate (GtkCssNode   *cssnode,
 
 void
 gtk_css_node_validate (GtkCssNode            *cssnode,
-                       gint64                 timestamp,
-                       gboolean               parent_changed)
+                       gint64                 timestamp)
 {
   GtkCssNode *child;
   GtkCssStyle *new_style;
@@ -791,14 +789,14 @@ gtk_css_node_validate (GtkCssNode            *cssnode,
   if (G_UNLIKELY (gtk_get_debug_flags () & GTK_DEBUG_NO_CSS_CACHE))
     cssnode->pending_changes |= GTK_CSS_CHANGE_ANY;
 
-  if (!cssnode->invalid && cssnode->pending_changes == 0 && !parent_changed)
+  if (!cssnode->invalid && cssnode->pending_changes == 0)
     return;
 
   gtk_css_node_set_invalid (cssnode, FALSE);
 
   cssnode->style_is_invalid = FALSE;
 
-  new_style = GTK_CSS_NODE_GET_CLASS (cssnode)->validate (cssnode, cssnode->style, timestamp, 
cssnode->pending_changes, parent_changed);
+  new_style = GTK_CSS_NODE_GET_CLASS (cssnode)->validate (cssnode, cssnode->style, timestamp, 
cssnode->pending_changes);
   if (new_style)
     {
       gtk_css_node_set_style (cssnode, new_style);
@@ -810,7 +808,7 @@ gtk_css_node_validate (GtkCssNode            *cssnode,
       changed = FALSE;
     }
 
-  gtk_css_node_propagate_pending_changes (cssnode);
+  gtk_css_node_propagate_pending_changes (cssnode, changed);
   cssnode->pending_changes = 0;
 
   for (child = gtk_css_node_get_first_child (cssnode);
@@ -818,7 +816,7 @@ gtk_css_node_validate (GtkCssNode            *cssnode,
        child = gtk_css_node_get_next_sibling (child))
     {
       if (child->visible)
-        gtk_css_node_validate (child, timestamp, changed);
+        gtk_css_node_validate (child, timestamp);
     }
 }
 
diff --git a/gtk/gtkcssnodeprivate.h b/gtk/gtkcssnodeprivate.h
index 7403cd3..944e01f 100644
--- a/gtk/gtkcssnodeprivate.h
+++ b/gtk/gtkcssnodeprivate.h
@@ -79,8 +79,7 @@ struct _GtkCssNodeClass
   GtkCssStyle *         (* validate)                    (GtkCssNode            *cssnode,
                                                          GtkCssStyle           *current_style,
                                                          gint64                 timestamp,
-                                                         GtkCssChange           change,
-                                                         gboolean               parent_changed);
+                                                         GtkCssChange           change);
 };
 
 GType                   gtk_css_node_get_type           (void) G_GNUC_CONST;
@@ -144,8 +143,7 @@ void                    gtk_css_node_invalidate_style_provider
 void                    gtk_css_node_invalidate         (GtkCssNode            *cssnode,
                                                          GtkCssChange           change);
 void                    gtk_css_node_validate           (GtkCssNode            *cssnode,
-                                                         gint64                 timestamp,
-                                                         gboolean               parent_changed);
+                                                         gint64                 timestamp);
 void                    gtk_css_node_set_invalid        (GtkCssNode            *node,
                                                          gboolean               invalid);
 
diff --git a/gtk/gtkcsstypes.c b/gtk/gtkcsstypes.c
index b69b0fe..46e7c1c 100644
--- a/gtk/gtkcsstypes.c
+++ b/gtk/gtkcsstypes.c
@@ -57,7 +57,8 @@ _gtk_css_change_for_sibling (GtkCssChange match)
     { GTK_CSS_CHANGE_POSITION, GTK_CSS_CHANGE_SIBLING_POSITION },
     { GTK_CSS_CHANGE_STATE, GTK_CSS_CHANGE_SIBLING_STATE },
     { GTK_CSS_CHANGE_SOURCE, 0 },
-    { GTK_CSS_CHANGE_ANIMATE, 0 }
+    { GTK_CSS_CHANGE_ANIMATE, 0 },
+    { GTK_CSS_CHANGE_PARENT_STYLE, 0 }
   };
 
   return gtk_css_change_translate (match, table, G_N_ELEMENTS (table)); 
@@ -76,7 +77,8 @@ _gtk_css_change_for_child (GtkCssChange match)
     { GTK_CSS_CHANGE_SIBLING_POSITION, GTK_CSS_CHANGE_PARENT_SIBLING_POSITION },
     { GTK_CSS_CHANGE_SIBLING_STATE, GTK_CSS_CHANGE_PARENT_SIBLING_STATE },
     { GTK_CSS_CHANGE_SOURCE, 0 },
-    { GTK_CSS_CHANGE_ANIMATE, 0 }
+    { GTK_CSS_CHANGE_ANIMATE, 0 },
+    { GTK_CSS_CHANGE_PARENT_STYLE, 0 }
   };
 
   return gtk_css_change_translate (match, table, G_N_ELEMENTS (table)); 
diff --git a/gtk/gtkcsstypesprivate.h b/gtk/gtkcsstypesprivate.h
index 409eb25..d2cd6d3 100644
--- a/gtk/gtkcsstypesprivate.h
+++ b/gtk/gtkcsstypesprivate.h
@@ -52,6 +52,7 @@ typedef enum { /*< skip >*/
   /* add more */
   GTK_CSS_CHANGE_SOURCE                   = (1 << 16),
   GTK_CSS_CHANGE_ANIMATE                  = (1 << 17),
+  GTK_CSS_CHANGE_PARENT_STYLE             = (1 << 18),
 
   GTK_CSS_CHANGE_RESERVED_BIT             = (1 << 31) /* Used internally in gtkcssselector.c */
 } GtkCssChange;
diff --git a/gtk/gtkcsswidgetnode.c b/gtk/gtkcsswidgetnode.c
index 10d0334..d3ec5a2 100644
--- a/gtk/gtkcsswidgetnode.c
+++ b/gtk/gtkcsswidgetnode.c
@@ -29,7 +29,7 @@
 
 /* When these change we do a full restyling. Otherwise we try to figure out
  * if we need to change things. */
-#define GTK_CSS_RADICAL_CHANGE (GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_CLASS | GTK_CSS_CHANGE_SOURCE)
+#define GTK_CSS_RADICAL_CHANGE (GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_CLASS | GTK_CSS_CHANGE_SOURCE | 
GTK_CSS_CHANGE_PARENT_STYLE)
 
 G_DEFINE_TYPE (GtkCssWidgetNode, gtk_css_widget_node, GTK_TYPE_CSS_NODE)
 
@@ -87,11 +87,9 @@ gtk_css_static_style_needs_revalidate (GtkCssStaticStyle  *style,
 static GtkCssStyle *
 validate_static_style (GtkCssNode       *node,
                        GtkCssStyle      *style,
-                       GtkCssChange      change,
-                       gboolean          parent_changed)
+                       GtkCssChange      change)
 {
-  if (gtk_css_static_style_needs_revalidate (GTK_CSS_STATIC_STYLE (style), change) ||
-      parent_changed)
+  if (gtk_css_static_style_needs_revalidate (GTK_CSS_STATIC_STYLE (style), change))
     {
       return gtk_css_node_create_style (node);
     }
@@ -105,8 +103,7 @@ static GtkCssStyle *
 gtk_css_widget_node_validate (GtkCssNode       *node,
                               GtkCssStyle      *style,
                               gint64            timestamp,
-                              GtkCssChange      change,
-                              gboolean          parent_changed)
+                              GtkCssChange      change)
 {
   GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
   GtkStyleContext *context;
@@ -129,7 +126,7 @@ gtk_css_widget_node_validate (GtkCssNode       *node,
       static_style = style;
     }
 
-  new_static_style = validate_static_style (node, static_style, change, parent_changed);
+  new_static_style = validate_static_style (node, static_style, change);
 
   if (new_static_style != static_style)
     {
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index e7bb21e..328f25c 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -5841,8 +5841,7 @@ gtk_window_show (GtkWidget *widget)
   need_resize = _gtk_widget_get_alloc_needed (widget) || !gtk_widget_get_realized (widget);
 
   gtk_css_node_validate (gtk_widget_get_css_node (widget),
-                         g_get_monotonic_time (),
-                         FALSE);
+                         g_get_monotonic_time ());
 
   if (need_resize)
     {


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