diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-01-16 17:50:32 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-01-16 19:11:08 -0500 |
commit | f0c1c3349f4ce90b2a23331003936fe4b33e320b (patch) | |
tree | 87999394741c17629d1754e382504a92a4e6212c | |
parent | 0dba6e5759839a8478fb9fbac707394cd35ed8f0 (diff) | |
download | gtk+-f0c1c3349f4ce90b2a23331003936fe4b33e320b.tar.gz |
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.
-rw-r--r-- | gtk/gtkcssmatcher.c | 57 | ||||
-rw-r--r-- | gtk/gtkcssmatcherprivate.h | 4 | ||||
-rw-r--r-- | 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) |