summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2020-01-23 03:34:25 +0100
committerBenjamin Otte <otte@redhat.com>2020-01-23 03:38:38 +0100
commite6b0a34a0416d60827c0984eee556fc39c25b865 (patch)
treeca9badf4cb857024c299ab1f97fec8e3c2058e3e
parent05ca59bfcf261448d0d1de5c11184fef182bc7a2 (diff)
downloadgtk+-e6b0a34a0416d60827c0984eee556fc39c25b865.tar.gz
css: Get rid of GtkCssMatcherotte/for-master
-rw-r--r--gtk/gtkcssmatcher.c190
-rw-r--r--gtk/gtkcssmatcherprivate.h131
-rw-r--r--gtk/gtkcssprovider.c15
-rw-r--r--gtk/gtkcssselector.c203
-rw-r--r--gtk/gtkcssselectorprivate.h10
-rw-r--r--gtk/gtkcsstypesprivate.h1
-rw-r--r--gtk/meson.build1
7 files changed, 139 insertions, 412 deletions
diff --git a/gtk/gtkcssmatcher.c b/gtk/gtkcssmatcher.c
deleted file mode 100644
index 4f85eb1810..0000000000
--- a/gtk/gtkcssmatcher.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/* GTK - The GIMP Toolkit
- * Copyright (C) 2012 Benjamin Otte <otte@gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include "gtkcssmatcherprivate.h"
-
-#include "gtkcssnodedeclarationprivate.h"
-#include "gtkcssnodeprivate.h"
-
-void
-gtk_css_matcher_print (const GtkCssMatcher *matcher,
- GString *string)
-{
- matcher->klass->print (matcher, string);
-}
-
-char *
-gtk_css_matcher_to_string (const GtkCssMatcher *matcher)
-{
- GString *string = g_string_new ("");
- gtk_css_matcher_print (matcher, string);
- return g_string_free (string, FALSE);
-}
-
-/* GTK_CSS_MATCHER_NODE */
-
-static gboolean
-gtk_css_matcher_node_get_parent (GtkCssMatcher *matcher,
- const GtkCssMatcher *child)
-{
- GtkCssNode *node;
-
- node = gtk_css_node_get_parent (child->node.node);
- if (node == NULL)
- return FALSE;
-
- _gtk_css_matcher_node_init (matcher, node);
- return TRUE;
-}
-
-static GtkCssNode *
-get_previous_visible_sibling (GtkCssNode *node)
-{
- do {
- node = gtk_css_node_get_previous_sibling (node);
- } while (node && !gtk_css_node_get_visible (node));
-
- return node;
-}
-
-static GtkCssNode *
-get_next_visible_sibling (GtkCssNode *node)
-{
- do {
- node = gtk_css_node_get_next_sibling (node);
- } while (node && !gtk_css_node_get_visible (node));
-
- return node;
-}
-
-static gboolean
-gtk_css_matcher_node_get_previous (GtkCssMatcher *matcher,
- const GtkCssMatcher *next)
-{
- GtkCssNode *node;
-
- node = get_previous_visible_sibling (next->node.node);
- if (node == NULL)
- return FALSE;
-
- _gtk_css_matcher_node_init (matcher, node);
- return TRUE;
-}
-
-static gboolean
-gtk_css_matcher_node_has_state (const GtkCssMatcher *matcher,
- GtkStateFlags state)
-{
- return (gtk_css_node_get_state (matcher->node.node) & state) == state;
-}
-
-static gboolean
-gtk_css_matcher_node_has_name (const GtkCssMatcher *matcher,
- /*interned*/ const char *name)
-{
- return gtk_css_node_get_name (matcher->node.node) == name;
-}
-
-static gboolean
-gtk_css_matcher_node_has_class (const GtkCssMatcher *matcher,
- GQuark class_name)
-{
- return gtk_css_node_has_class (matcher->node.node, class_name);
-}
-
-static gboolean
-gtk_css_matcher_node_has_id (const GtkCssMatcher *matcher,
- const char *id)
-{
- /* assume all callers pass an interned string */
- return gtk_css_node_get_id (matcher->node.node) == id;
-}
-
-static gboolean
-gtk_css_matcher_node_nth_child (GtkCssNode *node,
- GtkCssNode *(* prev_node_func) (GtkCssNode *),
- int a,
- int b)
-{
- int pos, x;
-
- /* special-case the common "first-child" and "last-child" */
- if (a == 0)
- {
- while (b > 0 && node != NULL)
- {
- b--;
- node = prev_node_func (node);
- }
-
- return b == 0 && node == NULL;
- }
-
- /* count nodes */
- for (pos = 0; node != NULL; pos++)
- node = prev_node_func (node);
-
- /* solve pos = a * X + b
- * and return TRUE if X is integer >= 0 */
- x = pos - b;
-
- if (x % a)
- return FALSE;
-
- return x / a >= 0;
-}
-
-static gboolean
-gtk_css_matcher_node_has_position (const GtkCssMatcher *matcher,
- gboolean forward,
- int a,
- int b)
-{
- return gtk_css_matcher_node_nth_child (matcher->node.node,
- forward ? get_previous_visible_sibling
- : get_next_visible_sibling,
- a, b);
-}
-
-static void
-gtk_css_matcher_node_print (const GtkCssMatcher *matcher,
- GString *string)
-{
- gtk_css_node_print (matcher->node.node, 0, string, 0);
-}
-
-static const GtkCssMatcherClass GTK_CSS_MATCHER_NODE = {
- GTK_CSS_MATCHER_TYPE_NODE,
- gtk_css_matcher_node_get_parent,
- gtk_css_matcher_node_get_previous,
- gtk_css_matcher_node_has_state,
- gtk_css_matcher_node_has_name,
- gtk_css_matcher_node_has_class,
- gtk_css_matcher_node_has_id,
- gtk_css_matcher_node_has_position,
- gtk_css_matcher_node_print
-};
-
-void
-_gtk_css_matcher_node_init (GtkCssMatcher *matcher,
- GtkCssNode *node)
-{
- matcher->node.klass = &GTK_CSS_MATCHER_NODE;
- matcher->node.node = node;
-}
diff --git a/gtk/gtkcssmatcherprivate.h b/gtk/gtkcssmatcherprivate.h
deleted file mode 100644
index c5744dc469..0000000000
--- a/gtk/gtkcssmatcherprivate.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/* GTK - The GIMP Toolkit
- * Copyright (C) 2012 Benjamin Otte <otte@gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __GTK_CSS_MATCHER_PRIVATE_H__
-#define __GTK_CSS_MATCHER_PRIVATE_H__
-
-#include <gtk/gtkenums.h>
-#include <gtk/gtktypes.h>
-#include "gtk/gtkcsstypesprivate.h"
-
-G_BEGIN_DECLS
-
-typedef struct _GtkCssMatcherNode GtkCssMatcherNode;
-typedef struct _GtkCssMatcherSuperset GtkCssMatcherSuperset;
-typedef struct _GtkCssMatcherWidgetPath GtkCssMatcherWidgetPath;
-typedef struct _GtkCssMatcherClass GtkCssMatcherClass;
-
-typedef enum {
- GTK_CSS_MATCHER_TYPE_NODE,
- GTK_CSS_MATCHER_TYPE_WIDGET_PATH
-} GtkCssMatcherType;
-
-struct _GtkCssMatcherClass {
- GtkCssMatcherType type;
- gboolean (* get_parent) (GtkCssMatcher *matcher,
- const GtkCssMatcher *child);
- gboolean (* get_previous) (GtkCssMatcher *matcher,
- const GtkCssMatcher *next);
-
- gboolean (* has_state) (const GtkCssMatcher *matcher,
- GtkStateFlags state);
- gboolean (* has_name) (const GtkCssMatcher *matcher,
- /*interned*/const char*name);
- gboolean (* has_class) (const GtkCssMatcher *matcher,
- GQuark class_name);
- gboolean (* has_id) (const GtkCssMatcher *matcher,
- const char *id);
- gboolean (* has_position) (const GtkCssMatcher *matcher,
- gboolean forward,
- int a,
- int b);
- void (* print) (const GtkCssMatcher *matcher,
- GString *string);
-};
-
-struct _GtkCssMatcherNode {
- const GtkCssMatcherClass *klass;
- GtkCssNode *node;
-};
-
-union _GtkCssMatcher {
- const GtkCssMatcherClass *klass;
- GtkCssMatcherNode node;
-};
-
-void _gtk_css_matcher_node_init (GtkCssMatcher *matcher,
- GtkCssNode *node);
-
-void gtk_css_matcher_print (const GtkCssMatcher *matcher,
- GString *string);
-char * gtk_css_matcher_to_string (const GtkCssMatcher *matcher);
-
-
-static inline gboolean
-_gtk_css_matcher_get_parent (GtkCssMatcher *matcher,
- const GtkCssMatcher *child)
-{
- return child->klass->get_parent (matcher, child);
-}
-
-static inline gboolean
-_gtk_css_matcher_get_previous (GtkCssMatcher *matcher,
- const GtkCssMatcher *next)
-{
- return next->klass->get_previous (matcher, next);
-}
-
-static inline gboolean
-_gtk_css_matcher_has_state (const GtkCssMatcher *matcher,
- GtkStateFlags state)
-{
- return matcher->klass->has_state (matcher, state);
-}
-
-static inline gboolean
-_gtk_css_matcher_has_name (const GtkCssMatcher *matcher,
- /*interned*/ const char *name)
-{
- return matcher->klass->has_name (matcher, name);
-}
-
-static inline gboolean
-_gtk_css_matcher_has_class (const GtkCssMatcher *matcher,
- GQuark class_name)
-{
- return matcher->klass->has_class (matcher, class_name);
-}
-
-static inline gboolean
-_gtk_css_matcher_has_id (const GtkCssMatcher *matcher,
- const char *id)
-{
- return matcher->klass->has_id (matcher, id);
-}
-
-static inline guint
-_gtk_css_matcher_has_position (const GtkCssMatcher *matcher,
- gboolean forward,
- int a,
- int b)
-{
- return matcher->klass->has_position (matcher, forward, a, b);
-}
-
-G_END_DECLS
-
-#endif /* __GTK_CSS_MATCHER_PRIVATE_H__ */
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 510a502ea9..ae9fd672ad 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -389,8 +389,8 @@ gtk_css_provider_init (GtkCssProvider *css_provider)
static void
verify_tree_match_results (GtkCssProvider *provider,
- const GtkCssMatcher *matcher,
- GPtrArray *tree_rules)
+ GtkCssNode *node,
+ GPtrArray *tree_rules)
{
#ifdef VERIFY_TREE
GtkCssProviderPrivate *priv = gtk_css_provider_get_instance_private (provider);
@@ -412,7 +412,7 @@ verify_tree_match_results (GtkCssProvider *provider,
break;
}
}
- should_match = _gtk_css_selector_matches (ruleset->selector, matcher);
+ should_match = _gtk_css_selector_matches (ruleset->selector, node);
if (found != !!should_match)
{
g_error ("expected rule '%s' to %s, but it %s",
@@ -453,7 +453,6 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider,
GtkCssProvider *css_provider = GTK_CSS_PROVIDER (provider);
GtkCssProviderPrivate *priv = gtk_css_provider_get_instance_private (css_provider);
GtkCssRuleset *ruleset;
- GtkCssMatcher matcher;
guint j;
int i;
GPtrArray *tree_rules;
@@ -461,12 +460,10 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider,
if (_gtk_css_selector_tree_is_empty (priv->tree))
return;
- _gtk_css_matcher_node_init (&matcher, node);
-
- tree_rules = _gtk_css_selector_tree_match_all (priv->tree, &matcher);
+ tree_rules = _gtk_css_selector_tree_match_all (priv->tree, node);
if (tree_rules)
{
- verify_tree_match_results (css_provider, &matcher, tree_rules);
+ verify_tree_match_results (css_provider, node, tree_rules);
for (i = tree_rules->len - 1; i >= 0; i--)
{
@@ -497,7 +494,7 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider,
}
if (change)
- *change = _gtk_css_selector_tree_get_change_all (priv->tree, &matcher);
+ *change = _gtk_css_selector_tree_get_change_all (priv->tree, node);
}
static void
diff --git a/gtk/gtkcssselector.c b/gtk/gtkcssselector.c
index 39552dfd0e..998ed78b58 100644
--- a/gtk/gtkcssselector.c
+++ b/gtk/gtkcssselector.c
@@ -49,7 +49,7 @@ typedef enum {
typedef struct _GtkCssSelectorClass GtkCssSelectorClass;
typedef gboolean (* GtkCssSelectorForeachFunc) (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher,
+ GtkCssNode *node,
gpointer data);
struct _GtkCssSelectorClass {
@@ -58,18 +58,18 @@ struct _GtkCssSelectorClass {
void (* print) (const GtkCssSelector *selector,
GString *string);
- /* NULL or an iterator that calls func with each submatcher of @matcher.
- * Potentially no submatcher exists.
+ /* NULL or an iterator that calls func with each subnode of @node.
+ * Potentially no subnode exists.
* If any @invocation of @func returns %TRUE, the function will immediately
* return %TRUE itself. If @func never returns %TRUE (or isn't called at all),
* %FALSE will be returned.
*/
gboolean (* foreach_matcher) (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher,
+ GtkCssNode *node,
GtkCssSelectorForeachFunc func,
gpointer data);
gboolean (* match_one) (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher);
+ GtkCssNode *node);
GtkCssChange (* get_change) (const GtkCssSelector *selector,
GtkCssChange previous_change);
void (* add_specificity) (const GtkCssSelector *selector,
@@ -188,18 +188,18 @@ gtk_css_selector_tree_found_match (const GtkCssSelectorTree *tree,
static inline gboolean
gtk_css_selector_match (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher)
+ GtkCssNode *node)
{
- return selector->class->match_one (selector, matcher);
+ return selector->class->match_one (selector, node);
}
static inline gboolean
gtk_css_selector_foreach (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher,
+ GtkCssNode *node,
GtkCssSelectorForeachFunc func,
gpointer data)
{
- return selector->class->foreach_matcher (selector, matcher, func, data);
+ return selector->class->foreach_matcher (selector, node, func, data);
}
static int
@@ -260,16 +260,16 @@ gtk_css_selector_default_add_specificity (const GtkCssSelector *selector,
static gboolean
gtk_css_selector_default_foreach_matcher (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher,
+ GtkCssNode *node,
GtkCssSelectorForeachFunc func,
gpointer data)
{
- return func (selector, matcher, data);
+ return func (selector, node, data);
}
static gboolean
gtk_css_selector_default_match_one (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher)
+ GtkCssNode *node)
{
return TRUE;
}
@@ -298,17 +298,17 @@ gtk_css_selector_descendant_print (const GtkCssSelector *selector,
static gboolean
gtk_css_selector_descendant_foreach_matcher (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher,
+ GtkCssNode *node,
GtkCssSelectorForeachFunc func,
gpointer data)
{
- GtkCssMatcher ancestor;
+ GtkCssNode *parent;
- while (_gtk_css_matcher_get_parent (&ancestor, matcher))
+ for (parent = gtk_css_node_get_parent (node);
+ parent;
+ parent = gtk_css_node_get_parent (parent))
{
- matcher = &ancestor;
-
- if (func (selector, &ancestor, data))
+ if (func (selector, parent, data))
return TRUE;
}
@@ -344,16 +344,17 @@ gtk_css_selector_child_print (const GtkCssSelector *selector,
static gboolean
gtk_css_selector_child_foreach_matcher (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher,
+ GtkCssNode *node,
GtkCssSelectorForeachFunc func,
gpointer data)
{
- GtkCssMatcher parent;
+ GtkCssNode *parent;
- if (!_gtk_css_matcher_get_parent (&parent, matcher))
+ parent = gtk_css_node_get_parent (node);
+ if (parent == NULL)
return FALSE;
- return func (selector, &parent, data);
+ return func (selector, parent, data);
}
static GtkCssChange
@@ -383,19 +384,39 @@ gtk_css_selector_sibling_print (const GtkCssSelector *selector,
g_string_append (string, " ~ ");
}
+static GtkCssNode *
+get_previous_visible_sibling (GtkCssNode *node)
+{
+ do {
+ node = gtk_css_node_get_previous_sibling (node);
+ } while (node && !gtk_css_node_get_visible (node));
+
+ return node;
+}
+
+static GtkCssNode *
+get_next_visible_sibling (GtkCssNode *node)
+{
+ do {
+ node = gtk_css_node_get_next_sibling (node);
+ } while (node && !gtk_css_node_get_visible (node));
+
+ return node;
+}
+
static gboolean
gtk_css_selector_sibling_foreach_matcher (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher,
+ GtkCssNode *node,
GtkCssSelectorForeachFunc func,
gpointer data)
{
- GtkCssMatcher previous;
+ GtkCssNode *prev;
- while (_gtk_css_matcher_get_previous (&previous, matcher))
+ for (prev = get_previous_visible_sibling (node);
+ prev;
+ prev = get_previous_visible_sibling (prev))
{
- matcher = &previous;
-
- if (func (selector, matcher, data))
+ if (func (selector, prev, data))
return TRUE;
}
@@ -431,16 +452,17 @@ gtk_css_selector_adjacent_print (const GtkCssSelector *selector,
static gboolean
gtk_css_selector_adjacent_foreach_matcher (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher,
+ GtkCssNode *node,
GtkCssSelectorForeachFunc func,
gpointer data)
{
- GtkCssMatcher previous;
+ GtkCssNode *prev;
- if (!_gtk_css_matcher_get_previous (&previous, matcher))
+ prev = get_previous_visible_sibling (node);
+ if (prev == NULL)
return FALSE;
-
- return func (selector, &previous, data);
+
+ return func (selector, prev, data);
}
static GtkCssChange
@@ -491,9 +513,9 @@ gtk_css_selector_not_ ## n ## _print (const GtkCssSelector *selector, \
\
static gboolean \
gtk_css_selector_not_ ## n ## _match_one (const GtkCssSelector *selector, \
- const GtkCssMatcher *matcher) \
+ GtkCssNode *node) \
{ \
- return !match_func (selector, matcher); \
+ return !match_func (selector, node); \
} \
\
static GtkCssChange \
@@ -557,7 +579,7 @@ print_any (const GtkCssSelector *selector,
static gboolean
match_any (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher)
+ GtkCssNode *node)
{
return TRUE;
}
@@ -580,9 +602,9 @@ print_name (const GtkCssSelector *selector,
static gboolean
match_name (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher)
+ GtkCssNode *node)
{
- return _gtk_css_matcher_has_name (matcher, selector->name.name);
+ return gtk_css_node_get_name (node) == selector->name.name;
}
static guint
@@ -613,9 +635,9 @@ print_class (const GtkCssSelector *selector,
static gboolean
match_class (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher)
+ GtkCssNode *node)
{
- return _gtk_css_matcher_has_class (matcher, selector->style_class.style_class);
+ return gtk_css_node_has_class (node, selector->style_class.style_class);
}
static guint
@@ -650,9 +672,9 @@ print_id (const GtkCssSelector *selector,
static gboolean
match_id (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher)
+ GtkCssNode *node)
{
- return _gtk_css_matcher_has_id (matcher, selector->id.name);
+ return gtk_css_node_get_id (node) == selector->id.name;
}
static guint
@@ -716,9 +738,9 @@ print_pseudoclass_state (const GtkCssSelector *selector,
static gboolean
match_pseudoclass_state (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher)
+ GtkCssNode *node)
{
- return _gtk_css_matcher_has_state (matcher, selector->state.state);
+ return (gtk_css_node_get_state (node) & selector->state.state) == selector->state.state;
}
static guint
@@ -840,22 +862,56 @@ print_pseudoclass_position (const GtkCssSelector *selector,
}
static gboolean
+match_position (GtkCssNode *node,
+ GtkCssNode *(* prev_node_func) (GtkCssNode *),
+ int a,
+ int b)
+{
+ int pos, x;
+
+ /* special-case the common "first-child" and "last-child" */
+ if (a == 0)
+ {
+ while (b > 0 && node != NULL)
+ {
+ b--;
+ node = prev_node_func (node);
+ }
+
+ return b == 0 && node == NULL;
+ }
+
+ /* count nodes */
+ for (pos = 0; node != NULL; pos++)
+ node = prev_node_func (node);
+
+ /* solve pos = a * X + b
+ * and return TRUE if X is integer >= 0 */
+ x = pos - b;
+
+ if (x % a)
+ return FALSE;
+
+ return x / a >= 0;
+}
+
+static gboolean
match_pseudoclass_position (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher)
+ GtkCssNode *node)
{
switch (selector->position.type)
{
case POSITION_FORWARD:
- if (!_gtk_css_matcher_has_position (matcher, TRUE, selector->position.a, selector->position.b))
+ if (!match_position (node, get_previous_visible_sibling, selector->position.a, selector->position.b))
return FALSE;
break;
case POSITION_BACKWARD:
- if (!_gtk_css_matcher_has_position (matcher, FALSE, selector->position.a, selector->position.b))
+ if (!match_position (node, get_next_visible_sibling, selector->position.a, selector->position.b))
return FALSE;
break;
case POSITION_ONLY:
- if (!_gtk_css_matcher_has_position (matcher, TRUE, 0, 1) ||
- !_gtk_css_matcher_has_position (matcher, FALSE, 0, 1))
+ if (get_previous_visible_sibling (node) ||
+ get_next_visible_sibling (node))
return FALSE;
break;
default:
@@ -1675,7 +1731,7 @@ _gtk_css_selector_to_string (const GtkCssSelector *selector)
static gboolean
gtk_css_selector_foreach_match (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher,
+ GtkCssNode *node,
gpointer unused)
{
selector = gtk_css_selector_previous (selector);
@@ -1683,38 +1739,33 @@ gtk_css_selector_foreach_match (const GtkCssSelector *selector,
if (selector == NULL)
return TRUE;
- if (!gtk_css_selector_match (selector, matcher))
+ if (!gtk_css_selector_match (selector, node))
return FALSE;
- return gtk_css_selector_foreach (selector, matcher, gtk_css_selector_foreach_match, NULL);
+ return gtk_css_selector_foreach (selector, node, gtk_css_selector_foreach_match, NULL);
}
/**
* _gtk_css_selector_matches:
* @selector: the selector
- * @path: the path to check
- * @state: The state to match
+ * @node: The node to match
*
- * Checks if the @selector matches the given @path. If @length is
- * smaller than the number of elements in @path, it is assumed that
- * only the first @length element of @path are valid and the rest
- * does not exist. This is useful for doing parent matches for the
- * 'inherit' keyword.
+ * Checks if the @selector matches the given @node.
*
- * Returns: %TRUE if the selector matches @path
+ * Returns: %TRUE if the selector matches @node
**/
gboolean
_gtk_css_selector_matches (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher)
+ GtkCssNode *node)
{
g_return_val_if_fail (selector != NULL, FALSE);
- g_return_val_if_fail (matcher != NULL, FALSE);
+ g_return_val_if_fail (node != NULL, FALSE);
- if (!gtk_css_selector_match (selector, matcher))
+ if (!gtk_css_selector_match (selector, node))
return FALSE;
- return gtk_css_selector_foreach (selector, matcher, gtk_css_selector_foreach_match, NULL);
+ return gtk_css_selector_foreach (selector, node, gtk_css_selector_foreach_match, NULL);
}
/* Computes specificity according to CSS 2.1.
@@ -1851,13 +1902,13 @@ gtk_css_selectors_skip_initial_selector (GtkCssSelector *selector, const GtkCssS
static gboolean
gtk_css_selector_tree_match_foreach (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher,
+ GtkCssNode *node,
gpointer res)
{
const GtkCssSelectorTree *tree = (const GtkCssSelectorTree *) selector;
const GtkCssSelectorTree *prev;
- if (!gtk_css_selector_match (selector, matcher))
+ if (!gtk_css_selector_match (selector, node))
return FALSE;
gtk_css_selector_tree_found_match (tree, res);
@@ -1865,20 +1916,20 @@ gtk_css_selector_tree_match_foreach (const GtkCssSelector *selector,
for (prev = gtk_css_selector_tree_get_previous (tree);
prev != NULL;
prev = gtk_css_selector_tree_get_sibling (prev))
- gtk_css_selector_foreach (&prev->selector, matcher, gtk_css_selector_tree_match_foreach, res);
+ gtk_css_selector_foreach (&prev->selector, node, gtk_css_selector_tree_match_foreach, res);
return FALSE;
}
GPtrArray *
_gtk_css_selector_tree_match_all (const GtkCssSelectorTree *tree,
- const GtkCssMatcher *matcher)
+ GtkCssNode *node)
{
GPtrArray *array = NULL;
for (; tree != NULL;
tree = gtk_css_selector_tree_get_sibling (tree))
- gtk_css_selector_foreach (&tree->selector, matcher, gtk_css_selector_tree_match_foreach, &array);
+ gtk_css_selector_foreach (&tree->selector, node, gtk_css_selector_tree_match_foreach, &array);
return array;
}
@@ -1890,12 +1941,12 @@ _gtk_css_selector_tree_match_all (const GtkCssSelectorTree *tree,
static gboolean
gtk_css_selector_match_for_change (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher)
+ GtkCssNode *node)
{
if (selector->class->category != GTK_CSS_SELECTOR_CATEGORY_SIMPLE_RADICAL)
return TRUE;
- return selector->class->match_one (selector, matcher);
+ return selector->class->match_one (selector, node);
}
/* When checking for changes via the tree we need to know if a rule further
@@ -1927,12 +1978,12 @@ gtk_css_selector_tree_collect_change (const GtkCssSelectorTree *tree)
static GtkCssChange
gtk_css_selector_tree_get_change (const GtkCssSelectorTree *tree,
- const GtkCssMatcher *matcher)
+ GtkCssNode *node)
{
GtkCssChange change = 0;
const GtkCssSelectorTree *prev;
- if (!gtk_css_selector_match_for_change (&tree->selector, matcher))
+ if (!gtk_css_selector_match_for_change (&tree->selector, node))
return 0;
if (!gtk_css_selector_is_simple (&tree->selector))
@@ -1941,7 +1992,7 @@ gtk_css_selector_tree_get_change (const GtkCssSelectorTree *tree,
for (prev = gtk_css_selector_tree_get_previous (tree);
prev != NULL;
prev = gtk_css_selector_tree_get_sibling (prev))
- change |= gtk_css_selector_tree_get_change (prev, matcher);
+ change |= gtk_css_selector_tree_get_change (prev, node);
if (change || gtk_css_selector_tree_get_matches (tree))
change = tree->selector.class->get_change (&tree->selector, change & ~GTK_CSS_CHANGE_GOT_MATCH) | GTK_CSS_CHANGE_GOT_MATCH;
@@ -1957,7 +2008,7 @@ _gtk_css_selector_tree_is_empty (const GtkCssSelectorTree *tree)
GtkCssChange
_gtk_css_selector_tree_get_change_all (const GtkCssSelectorTree *tree,
- const GtkCssMatcher *matcher)
+ GtkCssNode *node)
{
GtkCssChange change;
@@ -1966,7 +2017,7 @@ _gtk_css_selector_tree_get_change_all (const GtkCssSelectorTree *tree,
/* no need to foreach here because we abort for non-simple selectors */
for (; tree != NULL;
tree = gtk_css_selector_tree_get_sibling (tree))
- change |= gtk_css_selector_tree_get_change (tree, matcher);
+ change |= gtk_css_selector_tree_get_change (tree, node);
/* Never return reserved bit set */
return change & ~GTK_CSS_CHANGE_RESERVED_BIT;
diff --git a/gtk/gtkcssselectorprivate.h b/gtk/gtkcssselectorprivate.h
index 6f35917c6e..d63504d45f 100644
--- a/gtk/gtkcssselectorprivate.h
+++ b/gtk/gtkcssselectorprivate.h
@@ -18,7 +18,7 @@
#ifndef __GTK_CSS_SELECTOR_PRIVATE_H__
#define __GTK_CSS_SELECTOR_PRIVATE_H__
-#include "gtk/gtkcssmatcherprivate.h"
+#include "gtk/gtkcsstypesprivate.h"
#include "gtk/gtkcssparserprivate.h"
G_BEGIN_DECLS
@@ -35,16 +35,16 @@ void _gtk_css_selector_print (const GtkCssSelector *sel
GString *str);
gboolean _gtk_css_selector_matches (const GtkCssSelector *selector,
- const GtkCssMatcher *matcher);
+ GtkCssNode *node);
GtkCssChange _gtk_css_selector_get_change (const GtkCssSelector *selector);
int _gtk_css_selector_compare (const GtkCssSelector *a,
const GtkCssSelector *b);
void _gtk_css_selector_tree_free (GtkCssSelectorTree *tree);
GPtrArray * _gtk_css_selector_tree_match_all (const GtkCssSelectorTree *tree,
- const GtkCssMatcher *matcher);
+ GtkCssNode *node);
GtkCssChange _gtk_css_selector_tree_get_change_all (const GtkCssSelectorTree *tree,
- const GtkCssMatcher *matcher);
+ GtkCssNode *node);
void _gtk_css_selector_tree_match_print (const GtkCssSelectorTree *tree,
GString *str);
gboolean _gtk_css_selector_tree_is_empty (const GtkCssSelectorTree *tree) G_GNUC_CONST;
@@ -59,6 +59,8 @@ void _gtk_css_selector_tree_builder_add (GtkCssSelectorT
GtkCssSelectorTree * _gtk_css_selector_tree_builder_build (GtkCssSelectorTreeBuilder *builder);
void _gtk_css_selector_tree_builder_free (GtkCssSelectorTreeBuilder *builder);
+#include "gtkenums.h"
+
const char *gtk_css_pseudoclass_name (GtkStateFlags flags);
G_END_DECLS
diff --git a/gtk/gtkcsstypesprivate.h b/gtk/gtkcsstypesprivate.h
index 28ecc7d168..2cd1141008 100644
--- a/gtk/gtkcsstypesprivate.h
+++ b/gtk/gtkcsstypesprivate.h
@@ -23,7 +23,6 @@
G_BEGIN_DECLS
-typedef union _GtkCssMatcher GtkCssMatcher;
typedef struct _GtkCssNode GtkCssNode;
typedef struct _GtkCssNodeDeclaration GtkCssNodeDeclaration;
typedef struct _GtkCssStyle GtkCssStyle;
diff --git a/gtk/meson.build b/gtk/meson.build
index 0d3151296a..75d56a4f0a 100644
--- a/gtk/meson.build
+++ b/gtk/meson.build
@@ -72,7 +72,6 @@ gtk_private_sources = files([
'gtkcssinitialvalue.c',
'gtkcsskeyframes.c',
'gtkcsslookup.c',
- 'gtkcssmatcher.c',
'gtkcssnode.c',
'gtkcssnodedeclaration.c',
'gtkcssnodestylecache.c',