[gtk/matthiasc/css-change-tracking-3: 3/6] css: Simplify the superset matcher
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/css-change-tracking-3: 3/6] css: Simplify the superset matcher
- Date: Fri, 17 Jan 2020 00:27:27 +0000 (UTC)
commit f0c1c3349f4ce90b2a23331003936fe4b33e320b
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jan 16 17:50:32 2020 -0500
css: Simplify the superset matcher
We use the superset matcher in exactly one place,
so there is no need for the generality of allowing
to ignore different aspects. Just hardcode the one
case we need: ignoring everything except for name,
id and class.
gtk/gtkcssmatcher.c | 57 ++++++++++++++++------------------------------
gtk/gtkcssmatcherprivate.h | 4 +---
gtk/gtkcssprovider.c | 2 +-
3 files changed, 21 insertions(+), 42 deletions(-)
---
diff --git a/gtk/gtkcssmatcher.c b/gtk/gtkcssmatcher.c
index cfcaf25db1..6329029589 100644
--- a/gtk/gtkcssmatcher.c
+++ b/gtk/gtkcssmatcher.c
@@ -471,53 +471,41 @@ gtk_css_matcher_superset_get_state (const GtkCssMatcher *matcher)
{
/* XXX: This gets tricky when we implement :not() */
- if (matcher->superset.relevant & GTK_CSS_CHANGE_STATE)
- return _gtk_css_matcher_get_state (matcher->superset.subset);
- else
- return GTK_STATE_FLAG_ACTIVE |
- GTK_STATE_FLAG_PRELIGHT |
- GTK_STATE_FLAG_SELECTED |
- GTK_STATE_FLAG_INSENSITIVE |
- GTK_STATE_FLAG_INCONSISTENT |
- GTK_STATE_FLAG_FOCUSED |
- GTK_STATE_FLAG_BACKDROP |
- GTK_STATE_FLAG_DIR_LTR |
- GTK_STATE_FLAG_DIR_RTL |
- GTK_STATE_FLAG_LINK |
- GTK_STATE_FLAG_VISITED |
- GTK_STATE_FLAG_CHECKED |
- GTK_STATE_FLAG_DROP_ACTIVE |
- GTK_STATE_FLAG_FOCUS_VISIBLE;
+ return GTK_STATE_FLAG_ACTIVE |
+ GTK_STATE_FLAG_PRELIGHT |
+ GTK_STATE_FLAG_SELECTED |
+ GTK_STATE_FLAG_INSENSITIVE |
+ GTK_STATE_FLAG_INCONSISTENT |
+ GTK_STATE_FLAG_FOCUSED |
+ GTK_STATE_FLAG_BACKDROP |
+ GTK_STATE_FLAG_DIR_LTR |
+ GTK_STATE_FLAG_DIR_RTL |
+ GTK_STATE_FLAG_LINK |
+ GTK_STATE_FLAG_VISITED |
+ GTK_STATE_FLAG_CHECKED |
+ GTK_STATE_FLAG_DROP_ACTIVE |
+ GTK_STATE_FLAG_FOCUS_VISIBLE;
}
static gboolean
gtk_css_matcher_superset_has_name (const GtkCssMatcher *matcher,
/*interned*/ const char *name)
{
- if (matcher->superset.relevant & GTK_CSS_CHANGE_NAME)
- return _gtk_css_matcher_has_name (matcher->superset.subset, name);
- else
- return TRUE;
+ return _gtk_css_matcher_has_name (matcher->superset.subset, name);
}
static gboolean
gtk_css_matcher_superset_has_class (const GtkCssMatcher *matcher,
GQuark class_name)
{
- if (matcher->superset.relevant & GTK_CSS_CHANGE_CLASS)
- return _gtk_css_matcher_has_class (matcher->superset.subset, class_name);
- else
- return TRUE;
+ return _gtk_css_matcher_has_class (matcher->superset.subset, class_name);
}
static gboolean
gtk_css_matcher_superset_has_id (const GtkCssMatcher *matcher,
const char *id)
{
- if (matcher->superset.relevant & GTK_CSS_CHANGE_NAME)
- return _gtk_css_matcher_has_id (matcher->superset.subset, id);
- else
- return TRUE;
+ return _gtk_css_matcher_has_id (matcher->superset.subset, id);
}
static gboolean
@@ -526,10 +514,7 @@ gtk_css_matcher_superset_has_position (const GtkCssMatcher *matcher,
int a,
int b)
{
- if (matcher->superset.relevant & GTK_CSS_CHANGE_POSITION)
- return _gtk_css_matcher_has_position (matcher->superset.subset, forward, a, b);
- else
- return TRUE;
+ return TRUE;
}
static const GtkCssMatcherClass GTK_CSS_MATCHER_SUPERSET = {
@@ -545,14 +530,10 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_SUPERSET = {
void
_gtk_css_matcher_superset_init (GtkCssMatcher *matcher,
- const GtkCssMatcher *subset,
- GtkCssChange relevant)
+ const GtkCssMatcher *subset)
{
g_return_if_fail (subset != NULL);
- g_return_if_fail ((relevant & ~(GTK_CSS_CHANGE_CLASS | GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_POSITION |
GTK_CSS_CHANGE_STATE | GTK_CSS_CHANGE_HOVER | GTK_CSS_CHANGE_DISABLED | GTK_CSS_CHANGE_BACKDROP |
GTK_CSS_CHANGE_SELECTED)) == 0);
matcher->superset.klass = >K_CSS_MATCHER_SUPERSET;
matcher->superset.subset = subset;
- matcher->superset.relevant = relevant;
}
-
diff --git a/gtk/gtkcssmatcherprivate.h b/gtk/gtkcssmatcherprivate.h
index a78f777abb..4be2b3ff64 100644
--- a/gtk/gtkcssmatcherprivate.h
+++ b/gtk/gtkcssmatcherprivate.h
@@ -70,7 +70,6 @@ struct _GtkCssMatcherNode {
struct _GtkCssMatcherSuperset {
const GtkCssMatcherClass *klass;
const GtkCssMatcher *subset;
- GtkCssChange relevant;
};
union _GtkCssMatcher {
@@ -87,8 +86,7 @@ void _gtk_css_matcher_node_init (GtkCssMatcher *match
GtkCssNode *node);
void _gtk_css_matcher_any_init (GtkCssMatcher *matcher);
void _gtk_css_matcher_superset_init (GtkCssMatcher *matcher,
- const GtkCssMatcher *subset,
- GtkCssChange relevant);
+ const GtkCssMatcher *subset);
static inline gboolean
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 59573ebb34..76be1f5eb0 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -440,7 +440,7 @@ compute_change (GtkCssProvider *provider,
int i;
GtkCssMatcher change_matcher;
- _gtk_css_matcher_superset_init (&change_matcher, matcher, GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_CLASS);
+ _gtk_css_matcher_superset_init (&change_matcher, matcher);
tree_rules = _gtk_css_selector_tree_match_all (priv->tree, &change_matcher);
if (tree_rules)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]