[gtk/matthiasc/css-change-tracking-4: 10/11] Make superset matcher more precise



commit 68b1e62c088484aef41e9305aaf67d38ea838ff8
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jan 17 00:11:24 2020 -0500

    Make superset matcher more precise
    
    Make the superset matcher return a superset matcher on the parent
    matcher of the subset. This makes the matcher not consider selectors
    that are impossible, or at least impossible for the current nodes to
    match, unless you change the names, ids or classes of the node or any
    of its ancestors. For example, this makes us not add a parent-hover
    change flak to a label just because there is a "label:hover label"
    selector in the theme.
    
    The argument for why this is correct is that a name or class change
    on an ancestor would be a 'radical change' for that now, causing
    it to recompute its style, which would in turn be propagated as
    parent-style change to the node in question, causing a 'radical
    change' tehre as well.

 gtk/gtkcssmatcher.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkcssmatcher.c b/gtk/gtkcssmatcher.c
index a7f973450f..d96b942af0 100644
--- a/gtk/gtkcssmatcher.c
+++ b/gtk/gtkcssmatcher.c
@@ -503,7 +503,12 @@ static gboolean
 gtk_css_matcher_superset_get_parent (GtkCssMatcher       *matcher,
                                      const GtkCssMatcher *child)
 {
-  _gtk_css_matcher_any_init (matcher);
+  GtkCssMatcher parent;
+
+  if (!_gtk_css_matcher_get_parent (&parent, (GtkCssMatcher *)&child->superset.subset))
+    return FALSE;
+
+  _gtk_css_matcher_superset_init (matcher, &parent);
 
   return TRUE;
 }


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