[gtk+] css: Add _gtk_css_matcher_matches_any()



commit 16f2b20f9610d7d6658c6b14c9e95f0bf6384fd9
Author: Alexander Larsson <alexl redhat com>
Date:   Wed Nov 28 11:07:52 2012 +0100

    css: Add _gtk_css_matcher_matches_any()
    
    This returns true if the matcher matches *anything*. We need
    to check this later, because such matchers are dangerous in loops
    that iterate over all parents/siblings since such loops would not
    terminate.

 gtk/gtkcssmatcher.c        |    3 +++
 gtk/gtkcssmatcherprivate.h |    7 +++++++
 2 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssmatcher.c b/gtk/gtkcssmatcher.c
index c656ef4..6820738 100644
--- a/gtk/gtkcssmatcher.c
+++ b/gtk/gtkcssmatcher.c
@@ -185,6 +185,7 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_WIDGET_PATH = {
   gtk_css_matcher_widget_path_has_regions,
   gtk_css_matcher_widget_path_has_region,
   gtk_css_matcher_widget_path_has_position,
+  FALSE
 };
 
 gboolean
@@ -288,6 +289,7 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_ANY = {
   gtk_css_matcher_any_has_regions,
   gtk_css_matcher_any_has_region,
   gtk_css_matcher_any_has_position,
+  TRUE
 };
 
 void
@@ -406,6 +408,7 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_SUPERSET = {
   gtk_css_matcher_superset_has_regions,
   gtk_css_matcher_superset_has_region,
   gtk_css_matcher_superset_has_position,
+  FALSE
 };
 
 void
diff --git a/gtk/gtkcssmatcherprivate.h b/gtk/gtkcssmatcherprivate.h
index 1b4c632..28810b2 100644
--- a/gtk/gtkcssmatcherprivate.h
+++ b/gtk/gtkcssmatcherprivate.h
@@ -50,6 +50,7 @@ struct _GtkCssMatcherClass {
                                                    gboolean               forward,
                                                    int                    a,
                                                    int                    b);
+  gboolean is_any;
 };
 
 struct _GtkCssMatcherWidgetPath {
@@ -146,6 +147,12 @@ _gtk_css_matcher_has_position (const GtkCssMatcher *matcher,
   return matcher->klass->has_position (matcher, forward, a, b);
 }
 
+static inline gboolean
+_gtk_css_matcher_matches_any (const GtkCssMatcher *matcher)
+{
+  return matcher->klass->is_any;
+}
+
 
 G_END_DECLS
 



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