Refine the selector tree printing
authorMatthias Clasen <mclasen@redhat.com>
Sat, 18 Jan 2020 19:18:47 +0000 (14:18 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 18 Jan 2020 19:32:55 +0000 (14:32 -0500)
Also show which tree nodes have exact matches.

gtk/gtkcssselector.c

index c83f42f4199f0e981c756220b963fdad19b68567..dc35d839dbc71dc7a68794052bfb1b4fb2c73e80 100644 (file)
@@ -1970,6 +1970,7 @@ _gtk_css_selector_tree_print (const GtkCssSelectorTree *tree, GString *str, char
 {
   gboolean first = TRUE;
   int len, i;
+  gpointer *matches;
 
   for (; tree != NULL; tree = gtk_css_selector_tree_get_sibling (tree), first = FALSE)
     {
@@ -1993,6 +1994,16 @@ _gtk_css_selector_tree_print (const GtkCssSelectorTree *tree, GString *str, char
 
       len = str->len;
       tree->selector.class->print (&tree->selector, str);
+      matches = gtk_css_selector_tree_get_matches (tree);
+      if (matches)
+        {
+          int n;
+          for (n = 0; matches[n] != NULL; n++) ;
+          if (n == 1)
+            g_string_append (str, " (1 match)");
+          else
+            g_string_append_printf (str, " (%d matches)", n);
+        }
       len = str->len - len;
 
       if (gtk_css_selector_tree_get_previous (tree))