[gtk+] css: Implement inherit properties



commit b37f9fdf812c20afff559472408e13bbb81fa5f7
Author: Benjamin Otte <otte redhat com>
Date:   Tue May 17 15:01:59 2011 +0200

    css: Implement inherit properties
    
    Huge performance hit (slows down things roughly by a factor of 3), but
    necessary for CSS conformance and for implementing "inherit" and
    percentages.

 gtk/gtkcssprovider.c |   46 ++++++++++++++++++++++++++++------------------
 1 files changed, 28 insertions(+), 18 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index e93c894..5d3cffa 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -1108,38 +1108,48 @@ gtk_css_provider_get_style (GtkStyleProvider *provider,
   GtkCssProvider *css_provider;
   GtkCssProviderPrivate *priv;
   GtkStyleProperties *props;
-  guint i;
+  guint i, l, length;
 
   css_provider = GTK_CSS_PROVIDER (provider);
   priv = css_provider->priv;
+  length = gtk_widget_path_length (path);
   props = gtk_style_properties_new ();
 
   css_provider_dump_symbolic_colors (css_provider, props);
 
-  for (i = 0; i < priv->selectors_info->len; i++)
+  for (l = 1; l <= length; l++)
     {
-      SelectorStyleInfo *info;
-      GHashTableIter iter;
-      gpointer key, value;
+      for (i = 0; i < priv->selectors_info->len; i++)
+        {
+          SelectorStyleInfo *info;
+          GHashTableIter iter;
+          gpointer key, value;
 
-      info = g_ptr_array_index (priv->selectors_info, i);
+          info = g_ptr_array_index (priv->selectors_info, i);
 
-      if (!_gtk_css_selector_matches (info->selector, path, gtk_widget_path_length (path)))
-        continue;
+          if (l < length && _gtk_css_selector_get_state_flags (info->selector))
+            continue;
 
-      g_hash_table_iter_init (&iter, info->style);
+          if (!_gtk_css_selector_matches (info->selector, path, l))
+            continue;
 
-      while (g_hash_table_iter_next (&iter, &key, &value))
-        {
-          GParamSpec *pspec;
+          g_hash_table_iter_init (&iter, info->style);
 
-          if (!gtk_style_properties_lookup_property (key, NULL, &pspec))
-            continue;
+          while (g_hash_table_iter_next (&iter, &key, &value))
+            {
+              GParamSpec *pspec;
 
-          _gtk_style_properties_set_property_by_pspec (props,
-                                                       pspec,
-                                                       _gtk_css_selector_get_state_flags (info->selector),
-                                                       value);
+              if (!gtk_style_properties_lookup_property (key, NULL, &pspec))
+                continue;
+
+              if (l != length && !gtk_style_param_get_inherit (pspec))
+                continue;
+
+              _gtk_style_properties_set_property_by_pspec (props,
+                                                           pspec,
+                                                           _gtk_css_selector_get_state_flags (info->selector),
+                                                           value);
+            }
         }
     }
 



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