[gtk/wip/matthiasc/css-values: 20/23] Make the superset matcher more exact



commit 3d4ac2147ef2d1b77b36fa1edb5f585d7af2e7f3
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Jan 15 02:03:59 2020 -0500

    Make the superset matcher more exact
    
    When the superset matcher is built from a node matcher,
    we can make the parent or previous matchers be superset
    matchers for the corresponding node, with the same
    relevant parts. This is more precise than the any matcher
    that we were returning previously.

 gtk/gtkcssmatcher.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkcssmatcher.c b/gtk/gtkcssmatcher.c
index b12105f406..9f73bd65e8 100644
--- a/gtk/gtkcssmatcher.c
+++ b/gtk/gtkcssmatcher.c
@@ -469,18 +469,34 @@ static gboolean
 gtk_css_matcher_superset_get_parent (GtkCssMatcher       *matcher,
                                      const GtkCssMatcher *child)
 {
-  _gtk_css_matcher_any_init (matcher);
+  gboolean ret = TRUE;
 
-  return TRUE;
+  if (child->klass->type == GTK_CSS_MATCHER_TYPE_NODE)
+    {
+      ret = gtk_css_matcher_node_get_parent (matcher, child);
+      matcher->klass = child->klass;
+     }
+  else
+    _gtk_css_matcher_any_init (matcher);
+
+  return ret;
 }
 
 static gboolean
 gtk_css_matcher_superset_get_previous (GtkCssMatcher       *matcher,
                                        const GtkCssMatcher *next)
 {
-  _gtk_css_matcher_any_init (matcher);
+  gboolean ret = TRUE;
 
-  return TRUE;
+  if (matcher->klass->type == GTK_CSS_MATCHER_TYPE_NODE)
+    {
+      ret = gtk_css_matcher_node_get_previous (matcher, next);
+      matcher->klass = next->klass;
+     }
+  else
+    _gtk_css_matcher_any_init (matcher);
+
+  return ret;
 }
 
 static GtkStateFlags


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