[gtk+] styleprovider: Fold get_change() vfunc into lookup()



commit b49c7c34214da2d8d5e6dae2e8d0b0fe1b23f68e
Author: Benjamin Otte <otte redhat com>
Date:   Tue Dec 9 19:31:17 2014 +0100

    styleprovider: Fold get_change() vfunc into lookup()

 gtk/deprecated/gtkstyleproperties.c |   12 ++-----
 gtk/gtkcssprovider.c                |   26 ++++++-----------
 gtk/gtkmodifierstyle.c              |   17 ++--------
 gtk/gtksettings.c                   |    9 ------
 gtk/gtkstylecascade.c               |   37 ++++-------------------
 gtk/gtkstylecontext.c               |   54 ++++++++++++----------------------
 gtk/gtkstyleproviderprivate.c       |   25 ++++------------
 gtk/gtkstyleproviderprivate.h       |   10 ++----
 8 files changed, 53 insertions(+), 137 deletions(-)
---
diff --git a/gtk/deprecated/gtkstyleproperties.c b/gtk/deprecated/gtkstyleproperties.c
index f61f7a2..9cf2975 100644
--- a/gtk/deprecated/gtkstyleproperties.c
+++ b/gtk/deprecated/gtkstyleproperties.c
@@ -300,7 +300,8 @@ gtk_style_properties_provider_get_color (GtkStyleProviderPrivate *provider,
 static void
 gtk_style_properties_provider_lookup (GtkStyleProviderPrivate *provider,
                                       const GtkCssMatcher     *matcher,
-                                      GtkCssLookup            *lookup)
+                                      GtkCssLookup            *lookup,
+                                      GtkCssChange            *change)
 {
   GtkStyleProperties *props;
   GtkStylePropertiesPrivate *priv;
@@ -331,13 +332,9 @@ gtk_style_properties_provider_lookup (GtkStyleProviderPrivate *provider,
 
       _gtk_css_lookup_set (lookup, id, NULL, value);
     }
-}
 
-static GtkCssChange
-gtk_style_properties_provider_get_change (GtkStyleProviderPrivate *provider,
-                                          const GtkCssMatcher     *matcher)
-{
-  return GTK_CSS_CHANGE_STATE;
+  if (change)
+    *change = GTK_CSS_CHANGE_STATE;
 }
 
 static void
@@ -345,7 +342,6 @@ gtk_style_properties_provider_private_init (GtkStyleProviderPrivateInterface *if
 {
   iface->get_color = gtk_style_properties_provider_get_color;
   iface->lookup = gtk_style_properties_provider_lookup;
-  iface->get_change = gtk_style_properties_provider_get_change;
 }
 
 /* GtkStyleProperties methods */
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 6b02bef..0675503 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -1774,7 +1774,8 @@ gtk_css_style_provider_get_keyframes (GtkStyleProviderPrivate *provider,
 static void
 gtk_css_style_provider_lookup (GtkStyleProviderPrivate *provider,
                                const GtkCssMatcher     *matcher,
-                               GtkCssLookup            *lookup)
+                               GtkCssLookup            *lookup,
+                               GtkCssChange            *change)
 {
   GtkCssProvider *css_provider;
   GtkCssProviderPrivate *priv;
@@ -1819,24 +1820,16 @@ gtk_css_style_provider_lookup (GtkStyleProviderPrivate *provider,
     }
 
   g_ptr_array_free (tree_rules, TRUE);
-}
-
-static GtkCssChange
-gtk_css_style_provider_get_change (GtkStyleProviderPrivate *provider,
-                                   const GtkCssMatcher     *matcher)
-{
-  GtkCssProvider *css_provider;
-  GtkCssProviderPrivate *priv;
-  GtkCssChange change;
 
-  css_provider = GTK_CSS_PROVIDER (provider);
-  priv = css_provider->priv;
-
-  change = _gtk_css_selector_tree_get_change_all (priv->tree, matcher);
+  if (change)
+    {
+      GtkCssMatcher change_matcher;
 
-  verify_tree_get_change_results (css_provider, matcher, change);
+      _gtk_css_matcher_superset_init (&change_matcher, matcher, GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_CLASS);
 
-  return change;
+      *change = _gtk_css_selector_tree_get_change_all (priv->tree, &change_matcher);
+      verify_tree_get_change_results (css_provider, &change_matcher, *change);
+    }
 }
 
 static void
@@ -1845,7 +1838,6 @@ gtk_css_style_provider_private_iface_init (GtkStyleProviderPrivateInterface *ifa
   iface->get_color = gtk_css_style_provider_get_color;
   iface->get_keyframes = gtk_css_style_provider_get_keyframes;
   iface->lookup = gtk_css_style_provider_lookup;
-  iface->get_change = gtk_css_style_provider_get_change;
 }
 
 static void
diff --git a/gtk/gtkmodifierstyle.c b/gtk/gtkmodifierstyle.c
index e09f671..1ea54d1 100644
--- a/gtk/gtkmodifierstyle.c
+++ b/gtk/gtkmodifierstyle.c
@@ -118,23 +118,15 @@ gtk_modifier_style_provider_get_color (GtkStyleProviderPrivate *provider,
 static void
 gtk_modifier_style_provider_lookup (GtkStyleProviderPrivate *provider,
                                     const GtkCssMatcher     *matcher,
-                                    GtkCssLookup            *lookup)
+                                    GtkCssLookup            *lookup,
+                                    GtkCssChange            *change)
 {
   GtkModifierStyle *style = GTK_MODIFIER_STYLE (provider);
 
   _gtk_style_provider_private_lookup (GTK_STYLE_PROVIDER_PRIVATE (style->priv->style),
                                       matcher,
-                                      lookup);
-}
-
-static GtkCssChange
-gtk_modifier_style_provider_get_change (GtkStyleProviderPrivate *provider,
-                                        const GtkCssMatcher     *matcher)
-{
-  GtkModifierStyle *style = GTK_MODIFIER_STYLE (provider);
-
-  return _gtk_style_provider_private_get_change (GTK_STYLE_PROVIDER_PRIVATE (style->priv->style),
-                                                 matcher);
+                                      lookup,
+                                      change);
 }
 
 static void
@@ -142,7 +134,6 @@ gtk_modifier_style_provider_private_init (GtkStyleProviderPrivateInterface *ifac
 {
   iface->get_color = gtk_modifier_style_provider_get_color;
   iface->lookup = gtk_modifier_style_provider_lookup;
-  iface->get_change = gtk_modifier_style_provider_get_change;
 }
 
 static void
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index 180b42e..f06f78a 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -1716,14 +1716,6 @@ gtk_settings_provider_iface_init (GtkStyleProviderIface *iface)
 {
 }
 
-static GtkCssChange
-gtk_settings_style_provider_get_change (GtkStyleProviderPrivate *provider,
-                                       const GtkCssMatcher *matcher)
-{
-  return 0;
-}
-
-
 static GtkSettings *
 gtk_settings_style_provider_get_settings (GtkStyleProviderPrivate *provider)
 {
@@ -1734,7 +1726,6 @@ static void
 gtk_settings_provider_private_init (GtkStyleProviderPrivateInterface *iface)
 {
   iface->get_settings = gtk_settings_style_provider_get_settings;
-  iface->get_change = gtk_settings_style_provider_get_change;
 }
 
 static void
diff --git a/gtk/gtkstylecascade.c b/gtk/gtkstylecascade.c
index d4216f1..dd34aa1 100644
--- a/gtk/gtkstylecascade.c
+++ b/gtk/gtkstylecascade.c
@@ -201,11 +201,13 @@ gtk_style_cascade_get_keyframes (GtkStyleProviderPrivate *provider,
 static void
 gtk_style_cascade_lookup (GtkStyleProviderPrivate *provider,
                           const GtkCssMatcher     *matcher,
-                          GtkCssLookup            *lookup)
+                          GtkCssLookup            *lookup,
+                          GtkCssChange            *change)
 {
   GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
   GtkStyleCascadeIter iter;
   GtkStyleProvider *item;
+  GtkCssChange iter_change;
 
   for (item = gtk_style_cascade_iter_init (cascade, &iter);
        item;
@@ -215,7 +217,10 @@ gtk_style_cascade_lookup (GtkStyleProviderPrivate *provider,
         {
           _gtk_style_provider_private_lookup (GTK_STYLE_PROVIDER_PRIVATE (item),
                                               matcher,
-                                              lookup);
+                                              lookup,
+                                              change ? &iter_change : NULL);
+          if (change)
+            *change |= iter_change;
         }
       else
         {
@@ -225,33 +230,6 @@ gtk_style_cascade_lookup (GtkStyleProviderPrivate *provider,
     }
 }
 
-static GtkCssChange
-gtk_style_cascade_get_change (GtkStyleProviderPrivate *provider,
-                              const GtkCssMatcher     *matcher)
-{
-  GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
-  GtkStyleCascadeIter iter;
-  GtkStyleProvider *item;
-  GtkCssChange change = 0;
-
-  for (item = gtk_style_cascade_iter_init (cascade, &iter);
-       item;
-       item = gtk_style_cascade_iter_next (cascade, &iter))
-    {
-      if (GTK_IS_STYLE_PROVIDER_PRIVATE (item))
-        {
-          change |= _gtk_style_provider_private_get_change (GTK_STYLE_PROVIDER_PRIVATE (item),
-                                                            matcher);
-        }
-      else
-        {
-          g_return_val_if_reached (GTK_CSS_CHANGE_ANY);
-        }
-    }
-
-  return change;
-}
-
 static void
 gtk_style_cascade_provider_private_iface_init (GtkStyleProviderPrivateInterface *iface)
 {
@@ -259,7 +237,6 @@ gtk_style_cascade_provider_private_iface_init (GtkStyleProviderPrivateInterface
   iface->get_settings = gtk_style_cascade_get_settings;
   iface->get_keyframes = gtk_style_cascade_get_keyframes;
   iface->lookup = gtk_style_cascade_lookup;
-  iface->get_change = gtk_style_cascade_get_change;
 }
 
 G_DEFINE_TYPE_EXTENDED (GtkStyleCascade, _gtk_style_cascade, G_TYPE_OBJECT, 0,
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 8205ec8..6bd35c7 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -670,7 +670,8 @@ static void
 build_properties (GtkStyleContext             *context,
                   GtkCssComputedValues        *values,
                   const GtkCssNodeDeclaration *decl,
-                  const GtkBitmask            *relevant_changes)
+                  const GtkBitmask            *relevant_changes,
+                  GtkCssChange                *out_change)
 {
   GtkStyleContextPrivate *priv;
   GtkCssMatcher matcher;
@@ -685,7 +686,8 @@ build_properties (GtkStyleContext             *context,
   if (_gtk_css_matcher_init (&matcher, path))
     _gtk_style_provider_private_lookup (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
                                         &matcher,
-                                        lookup);
+                                        lookup,
+                                        out_change);
 
   _gtk_css_lookup_resolve (lookup, 
                            GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
@@ -724,11 +726,17 @@ style_values_lookup (GtkStyleContext *context)
 
   style_info_set_values (info, values);
   if (gtk_style_context_is_saved (context))
-    g_hash_table_insert (priv->style_values,
-                         gtk_css_node_declaration_ref (info->decl),
-                         g_object_ref (values));
-  
-  build_properties (context, values, info->decl, NULL);
+    {
+      g_hash_table_insert (priv->style_values,
+                           gtk_css_node_declaration_ref (info->decl),
+                           g_object_ref (values));
+    
+      build_properties (context, values, info->decl, NULL, NULL);
+    }
+  else
+    {
+      build_properties (context, values, info->decl, NULL, &priv->relevant_changes);
+    }
 
   g_object_unref (values);
 
@@ -751,7 +759,7 @@ style_values_lookup_for_state (GtkStyleContext *context,
   decl = gtk_css_node_declaration_ref (context->priv->info->decl);
   gtk_css_node_declaration_set_state (&decl, state);
   values = _gtk_css_computed_values_new ();
-  build_properties (context, values, decl, NULL);
+  build_properties (context, values, decl, NULL, NULL);
   gtk_css_node_declaration_unref (decl);
 
   return values;
@@ -2638,7 +2646,7 @@ gtk_style_context_update_cache (GtkStyleContext  *context,
       changes = _gtk_css_computed_values_compute_dependencies (values, parent_changes);
 
       if (!_gtk_bitmask_is_empty (changes))
-       build_properties (context, values, decl, changes);
+       build_properties (context, values, decl, changes, NULL);
 
       _gtk_bitmask_free (changes);
     }
@@ -2694,31 +2702,7 @@ gtk_style_context_needs_full_revalidate (GtkStyleContext  *context,
 
   /* Try to avoid invalidating if we can */
   if (change & GTK_STYLE_CONTEXT_RADICAL_CHANGE)
-    {
-      priv->relevant_changes = GTK_CSS_CHANGE_ANY;
-    }
-  else
-    {
-      if (priv->relevant_changes == GTK_CSS_CHANGE_ANY)
-        {
-          GtkWidgetPath *path;
-          GtkCssMatcher matcher, superset;
-
-          path = create_query_path (context, priv->info->decl);
-          if (_gtk_css_matcher_init (&matcher, path))
-            {
-              _gtk_css_matcher_superset_init (&superset, &matcher, GTK_STYLE_CONTEXT_RADICAL_CHANGE & 
~GTK_CSS_CHANGE_SOURCE);
-              priv->relevant_changes = _gtk_style_provider_private_get_change (GTK_STYLE_PROVIDER_PRIVATE 
(priv->cascade),
-                                                                               &superset);
-            }
-          else
-            priv->relevant_changes = 0;
-
-          priv->relevant_changes &= ~GTK_STYLE_CONTEXT_RADICAL_CHANGE;
-
-          gtk_widget_path_unref (path);
-        }
-    }
+    return TRUE;
 
   if (priv->relevant_changes & change)
     return TRUE;
@@ -2837,7 +2821,7 @@ _gtk_style_context_validate (GtkStyleContext  *context,
     {
       changes = _gtk_css_computed_values_compute_dependencies (current, parent_changes);
       if (!_gtk_bitmask_is_empty (changes))
-       build_properties (context, current, info->decl, changes);
+       build_properties (context, current, info->decl, changes, NULL);
 
       gtk_style_context_update_cache (context, parent_changes);
     }
diff --git a/gtk/gtkstyleproviderprivate.c b/gtk/gtkstyleproviderprivate.c
index 1f62b88..35a6f6e 100644
--- a/gtk/gtkstyleproviderprivate.c
+++ b/gtk/gtkstyleproviderprivate.c
@@ -84,7 +84,8 @@ _gtk_style_provider_private_get_keyframes (GtkStyleProviderPrivate *provider,
 void
 _gtk_style_provider_private_lookup (GtkStyleProviderPrivate *provider,
                                     const GtkCssMatcher     *matcher,
-                                    GtkCssLookup            *lookup)
+                                    GtkCssLookup            *lookup,
+                                    GtkCssChange            *out_change)
 {
   GtkStyleProviderPrivateInterface *iface;
 
@@ -92,29 +93,15 @@ _gtk_style_provider_private_lookup (GtkStyleProviderPrivate *provider,
   g_return_if_fail (matcher != NULL);
   g_return_if_fail (lookup != NULL);
 
+  if (out_change)
+    *out_change = 0;
+
   iface = GTK_STYLE_PROVIDER_PRIVATE_GET_INTERFACE (provider);
 
   if (!iface->lookup)
     return;
 
-  iface->lookup (provider, matcher, lookup);
-}
-
-GtkCssChange
-_gtk_style_provider_private_get_change (GtkStyleProviderPrivate *provider,
-                                        const GtkCssMatcher     *matcher)
-{
-  GtkStyleProviderPrivateInterface *iface;
-
-  g_return_val_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider), GTK_CSS_CHANGE_ANY);
-  g_return_val_if_fail (matcher != NULL, GTK_CSS_CHANGE_ANY);
-
-  iface = GTK_STYLE_PROVIDER_PRIVATE_GET_INTERFACE (provider);
-
-  if (!iface->get_change)
-    return GTK_CSS_CHANGE_ANY;
-
-  return iface->get_change (provider, matcher);
+  iface->lookup (provider, matcher, lookup, out_change);
 }
 
 void
diff --git a/gtk/gtkstyleproviderprivate.h b/gtk/gtkstyleproviderprivate.h
index c619d8d..a66e186 100644
--- a/gtk/gtkstyleproviderprivate.h
+++ b/gtk/gtkstyleproviderprivate.h
@@ -46,9 +46,8 @@ struct _GtkStyleProviderPrivateInterface
                                                  const char              *name);
   void                  (* lookup)              (GtkStyleProviderPrivate *provider,
                                                  const GtkCssMatcher     *matcher,
-                                                 GtkCssLookup            *lookup);
-  GtkCssChange          (* get_change)          (GtkStyleProviderPrivate *provider,
-                                                 const GtkCssMatcher     *matcher);
+                                                 GtkCssLookup            *lookup,
+                                                 GtkCssChange            *out_change);
 
   /* signal */
   void                  (* changed)             (GtkStyleProviderPrivate *provider);
@@ -63,9 +62,8 @@ GtkCssKeyframes *       _gtk_style_provider_private_get_keyframes(GtkStyleProvid
                                                                   const char              *name);
 void                    _gtk_style_provider_private_lookup       (GtkStyleProviderPrivate *provider,
                                                                   const GtkCssMatcher     *matcher,
-                                                                  GtkCssLookup            *lookup);
-GtkCssChange            _gtk_style_provider_private_get_change   (GtkStyleProviderPrivate *provider,
-                                                                  const GtkCssMatcher     *matcher);
+                                                                  GtkCssLookup            *lookup,
+                                                                  GtkCssChange            *out_change);
 
 void                    _gtk_style_provider_private_changed      (GtkStyleProviderPrivate *provider);
 


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