[gtk/matthiasc/css-change-tracking-4: 1/5] Go back to the tree for computing change



commit 2f249c6a4682ddba2b8f571651e6ebf70e268095
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jan 17 11:11:55 2020 -0500

    Go back to the tree for computing change

 gtk/gtkcssprovider.c | 37 +------------------------------------
 gtk/gtkcssselector.c | 25 +++++++++++++++----------
 2 files changed, 16 insertions(+), 46 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 76be1f5eb0..ee5085dd3f 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -425,41 +425,6 @@ verify_tree_match_results (GtkCssProvider *provider,
 #endif
 }
 
-/* Compute the change flags for a given matcher.
- * We assume that name, id and classes stay unchanged, and look for all rules
- * that can be matched if anything else changes. We collect the change masks
- * from the selectors of these rules.
- */
-static GtkCssChange
-compute_change (GtkCssProvider      *provider,
-                const GtkCssMatcher *matcher)
-{
-  GtkCssProviderPrivate *priv = gtk_css_provider_get_instance_private (provider);
-  GtkCssChange change = 0;
-  GPtrArray *tree_rules;
-  int i;
-  GtkCssMatcher change_matcher;
-
-  _gtk_css_matcher_superset_init (&change_matcher, matcher);
-
-  tree_rules = _gtk_css_selector_tree_match_all (priv->tree, &change_matcher);
-  if (tree_rules)
-    {
-      for (i = tree_rules->len - 1; i >= 0; i--)
-        {
-         GtkCssRuleset *ruleset;
-
-          ruleset = tree_rules->pdata[i];
-
-          change |= _gtk_css_selector_get_change (ruleset->selector);
-        }
-
-      g_ptr_array_free (tree_rules, TRUE);
-   }
-
-  return change;
-}
-
 static GtkCssValue *
 gtk_css_style_provider_get_color (GtkStyleProvider *provider,
                                   const char       *name)
@@ -530,7 +495,7 @@ gtk_css_style_provider_lookup (GtkStyleProvider    *provider,
     }
 
   if (change)
-    *change = compute_change (css_provider, matcher);
+    *change = _gtk_css_selector_tree_get_change_all (priv->tree, matcher);
 }
 
 static void
diff --git a/gtk/gtkcssselector.c b/gtk/gtkcssselector.c
index 6909d86f6d..9632797ee3 100644
--- a/gtk/gtkcssselector.c
+++ b/gtk/gtkcssselector.c
@@ -1736,16 +1736,6 @@ _gtk_css_selector_matches (const GtkCssSelector *selector,
   return gtk_css_selector_foreach (selector, matcher, gtk_css_selector_foreach_match, NULL);
 }
 
-static gboolean
-gtk_css_selector_match_for_change (const GtkCssSelector *selector,
-                                   const GtkCssMatcher  *matcher)
-{
-  if (selector->class->ignore_for_change)
-    return TRUE;
-
-  return selector->class->match_one (selector, matcher);
-}
-
 /* Computes specificity according to CSS 2.1.
  * The arguments must be initialized to 0 */
 static void
@@ -1895,6 +1885,21 @@ _gtk_css_selector_tree_match_all (const GtkCssSelectorTree *tree,
   return array;
 }
 
+/* The code for collecting matches assumes that the name, id and classes
+ * of a node remain unchanged, and anything else can change. This needs to
+ * be kept in sync with the definition of 'radical change' in gtkcssnode.c.
+ */
+
+static gboolean
+gtk_css_selector_match_for_change (const GtkCssSelector *selector,
+                                   const GtkCssMatcher  *matcher)
+{
+  if (selector->class->ignore_for_change)
+    return TRUE;
+
+  return selector->class->match_one (selector, matcher);
+}
+
 /* When checking for changes via the tree we need to know if a rule further
    down the tree matched, because if so we need to add "our bit" to the
    Change. For instance in a match like *.class:active we'll


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