[gtk+] css: Fix * selector to also match regions



commit bea4ee0a2ceb3e6e81cd31cc1eab75d52bb825a3
Author: Benjamin Otte <otte redhat com>
Date:   Wed Mar 7 03:47:19 2012 +0100

    css: Fix * selector to also match regions
    
    Fixes css-match-region-matches-star.ui reftest.

 gtk/gtkcssselector.c |   64 +++++++++++++++++++++++++++++--------------------
 1 files changed, 38 insertions(+), 26 deletions(-)
---
diff --git a/gtk/gtkcssselector.c b/gtk/gtkcssselector.c
index b15bb77..af68083 100644
--- a/gtk/gtkcssselector.c
+++ b/gtk/gtkcssselector.c
@@ -71,32 +71,6 @@ gtk_css_selector_previous (const GtkCssSelector *selector)
   return selector->class ? selector : NULL;
 }
 
-/* ANY */
-
-static void
-gtk_css_selector_any_print (const GtkCssSelector *selector,
-                            GString              *string)
-{
-  g_string_append_c (string, '*');
-}
-
-static gboolean
-gtk_css_selector_any_match (const GtkCssSelector *selector,
-                            GtkStateFlags         state,
-                            const GtkWidgetPath  *path,
-                            guint                 id,
-                            guint                 sibling)
-{
-  return gtk_css_selector_match (gtk_css_selector_previous (selector), state, path, id, sibling);
-}
-
-static const GtkCssSelectorClass GTK_CSS_SELECTOR_ANY = {
-  "any",
-  gtk_css_selector_any_print,
-  gtk_css_selector_any_match,
-  FALSE, FALSE, FALSE
-};
-
 /* DESCENDANT */
 
 static void
@@ -235,6 +209,44 @@ static const GtkCssSelectorClass GTK_CSS_SELECTOR_ADJACENT = {
   FALSE, FALSE, FALSE
 };
 
+/* ANY */
+
+static void
+gtk_css_selector_any_print (const GtkCssSelector *selector,
+                            GString              *string)
+{
+  g_string_append_c (string, '*');
+}
+
+static gboolean
+gtk_css_selector_any_match (const GtkCssSelector *selector,
+                            GtkStateFlags         state,
+                            const GtkWidgetPath  *path,
+                            guint                 id,
+                            guint                 sibling)
+{
+  const GtkCssSelector *previous = gtk_css_selector_previous (selector);
+  GSList *regions;
+  
+  if (previous &&
+      previous->class == &GTK_CSS_SELECTOR_DESCENDANT &&
+      (regions = gtk_widget_path_iter_list_regions (path, id)) != NULL)
+    {
+      g_slist_free (regions);
+      if (gtk_css_selector_match (gtk_css_selector_previous (previous), state, path, id, sibling))
+        return TRUE;
+    }
+  
+  return gtk_css_selector_match (previous, state, path, id, sibling);
+}
+
+static const GtkCssSelectorClass GTK_CSS_SELECTOR_ANY = {
+  "any",
+  gtk_css_selector_any_print,
+  gtk_css_selector_any_match,
+  FALSE, FALSE, FALSE
+};
+
 /* NAME */
 
 static void



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