[gtk/redo-superset] Move change computation back to the tree
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/redo-superset] Move change computation back to the tree
- Date: Fri, 17 Jan 2020 16:04:32 +0000 (UTC)
commit 2cc18805f5e4298deed1a0ae32bdfe31f2a5f207
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jan 17 11:02:40 2020 -0500
Move change computation back to the tree
This avoids checking all the rules, by reusing
the tree, like we did before. The change is that
we now pass the actual selector, and call
gtk_css_selector_match_for_change instead of
gtk_css_selector_match.
gtk/gtkcssprovider.c | 26 +-------------------------
gtk/gtkcssselector.c | 35 +----------------------------------
gtk/gtkcssselectorprivate.h | 2 --
3 files changed, 2 insertions(+), 61 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 0e6668609a..ee5085dd3f 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -425,30 +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;
- int i;
-
- for (i = 0; i < priv->rulesets->len; i++)
- {
- GtkCssRuleset *ruleset = &g_array_index (priv->rulesets, GtkCssRuleset, i);
-
- if (_gtk_css_selector_matches_for_change (ruleset->selector, matcher))
- change |= _gtk_css_selector_get_change (ruleset->selector);
- }
-
- return change;
-}
-
static GtkCssValue *
gtk_css_style_provider_get_color (GtkStyleProvider *provider,
const char *name)
@@ -519,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 16caf0f85e..bfc0dfe58b 100644
--- a/gtk/gtkcssselector.c
+++ b/gtk/gtkcssselector.c
@@ -1736,39 +1736,6 @@ gtk_css_selector_match_for_change (const GtkCssSelector *selector,
return selector->class->match_one (selector, matcher);
}
-static gboolean
-gtk_css_selector_foreach_match_for_change (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher,
- gpointer unused)
-{
- selector = gtk_css_selector_previous (selector);
-
- if (selector == NULL)
- return TRUE;
-
- if (!selector->class->is_simple)
- return TRUE;
-
- if (!gtk_css_selector_match_for_change (selector, matcher))
- return FALSE;
-
- return gtk_css_selector_foreach (selector, matcher, gtk_css_selector_foreach_match_for_change, NULL);
-}
-
-gboolean
-_gtk_css_selector_matches_for_change (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher)
-{
-
- g_return_val_if_fail (selector != NULL, FALSE);
- g_return_val_if_fail (matcher != NULL, FALSE);
-
- if (!gtk_css_selector_match_for_change (selector, matcher))
- return FALSE;
-
- return gtk_css_selector_foreach (selector, matcher, gtk_css_selector_foreach_match_for_change, NULL);
-}
-
/* Computes specificity according to CSS 2.1.
* The arguments must be initialized to 0 */
static void
@@ -1952,7 +1919,7 @@ gtk_css_selector_tree_get_change (const GtkCssSelectorTree *tree,
GtkCssChange change = 0;
const GtkCssSelectorTree *prev;
- if (!gtk_css_selector_match (&tree->selector, matcher))
+ if (!gtk_css_selector_match_for_change (&tree->selector, matcher))
return 0;
if (!tree->selector.class->is_simple)
diff --git a/gtk/gtkcssselectorprivate.h b/gtk/gtkcssselectorprivate.h
index d26441abc5..6f35917c6e 100644
--- a/gtk/gtkcssselectorprivate.h
+++ b/gtk/gtkcssselectorprivate.h
@@ -36,8 +36,6 @@ void _gtk_css_selector_print (const GtkCssSelector *sel
gboolean _gtk_css_selector_matches (const GtkCssSelector *selector,
const GtkCssMatcher *matcher);
-gboolean _gtk_css_selector_matches_for_change (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher);
GtkCssChange _gtk_css_selector_get_change (const GtkCssSelector *selector);
int _gtk_css_selector_compare (const GtkCssSelector *a,
const GtkCssSelector *b);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]