[gtk/matthiasc/css-change: 6/11] Make the superset matcher more exact



commit 3d5a7685fe7cefe11e6d82bfe6f4c78962125a6b
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 matcher be a 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 | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkcssmatcher.c b/gtk/gtkcssmatcher.c
index b12105f406..86448d4618 100644
--- a/gtk/gtkcssmatcher.c
+++ b/gtk/gtkcssmatcher.c
@@ -469,9 +469,17 @@ 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
@@ -571,6 +579,7 @@ _gtk_css_matcher_superset_init (GtkCssMatcher       *matcher,
     }
 
   *klass = GTK_CSS_MATCHER_SUPERSET;
+  klass->type = subset->klass->type;
 
   if (relevant & GTK_CSS_CHANGE_CLASS)
     klass->has_class = subset->klass->has_class;


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