Commit 284ccdac authored by Benjamin Otte's avatar Benjamin Otte

cssselector: Use simple class macro for * selector

As a side effect, the :not(*) selector needs to be renamed because the
macro chooses a different name for it.
parent 528691f5
...@@ -890,140 +890,36 @@ static const GtkCssSelectorClass GTK_CSS_SELECTOR_NOT_ ## c = { \ ...@@ -890,140 +890,36 @@ static const GtkCssSelectorClass GTK_CSS_SELECTOR_NOT_ ## c = { \
/* ANY */ /* ANY */
static void static void
gtk_css_selector_any_print (const GtkCssSelector *selector, print_any (const GtkCssSelector *selector,
GString *string) GString *string)
{ {
g_string_append_c (string, '*'); g_string_append_c (string, '*');
} }
static gboolean static gboolean
gtk_css_selector_any_match (const GtkCssSelector *selector, match_any (const GtkCssSelector *selector,
const GtkCssMatcher *matcher) const GtkCssMatcher *matcher)
{
return gtk_css_selector_match (gtk_css_selector_previous (selector), matcher);
}
static void
gtk_css_selector_any_tree_match (const GtkCssSelectorTree *tree,
const GtkCssMatcher *matcher,
GHashTable *res)
{
gtk_css_selector_tree_found_match (tree, res);
gtk_css_selector_tree_match_previous (tree, matcher, res);
}
static GtkCssChange
gtk_css_selector_any_tree_get_change (const GtkCssSelectorTree *tree,
const GtkCssMatcher *matcher)
{
GtkCssChange change, previous_change;
change = 0;
if (tree->matches_offset != GTK_CSS_SELECTOR_TREE_EMPTY_OFFSET)
change |= GTK_CSS_CHANGE_GOT_MATCH;
previous_change = gtk_css_selector_tree_get_previous_change (tree, matcher);
if (previous_change != 0)
change |= previous_change | GTK_CSS_CHANGE_GOT_MATCH;
return change;
}
static GtkCssChange
gtk_css_selector_any_get_change (const GtkCssSelector *selector, GtkCssChange previous_change)
{
return previous_change;
}
static guint
gtk_css_selector_any_hash_one (const GtkCssSelector *a)
{
return 0;
}
static int
gtk_css_selector_any_compare_one (const GtkCssSelector *a,
const GtkCssSelector *b)
{
return 0;
}
static const GtkCssSelectorClass GTK_CSS_SELECTOR_ANY = {
"any",
gtk_css_selector_any_print,
gtk_css_selector_any_match,
gtk_css_selector_any_tree_match,
gtk_css_selector_any_get_change,
gtk_css_selector_any_tree_get_change,
gtk_css_selector_any_hash_one,
gtk_css_selector_any_compare_one,
FALSE, FALSE, FALSE, TRUE, FALSE
};
/* NONE */
static void
gtk_css_selector_none_print (const GtkCssSelector *selector,
GString *string)
{
g_string_append (string, ":not(*)");
}
static gboolean
gtk_css_selector_none_match (const GtkCssSelector *selector,
const GtkCssMatcher *matcher)
{
return FALSE;
}
static void
gtk_css_selector_none_tree_match (const GtkCssSelectorTree *tree,
const GtkCssMatcher *matcher,
GHashTable *res)
{ {
} return TRUE;
static GtkCssChange
gtk_css_selector_none_tree_get_change (const GtkCssSelectorTree *tree,
const GtkCssMatcher *matcher)
{
return 0;
}
static GtkCssChange
gtk_css_selector_none_get_change (const GtkCssSelector *selector, GtkCssChange previous_change)
{
return 0;
} }
static guint static guint
gtk_css_selector_none_hash_one (const GtkCssSelector *a) hash_any (const GtkCssSelector *a)
{ {
return 0; return 0;
} }
static int static int
gtk_css_selector_none_compare_one (const GtkCssSelector *a, comp_any (const GtkCssSelector *a,
const GtkCssSelector *b) const GtkCssSelector *b)
{ {
return 0; return 0;
} }
static const GtkCssSelectorClass GTK_CSS_SELECTOR_NONE = { #undef GTK_CSS_CHANGE_ANY
"none", #define GTK_CSS_CHANGE_ANY 0
gtk_css_selector_none_print, DEFINE_SIMPLE_SELECTOR(any, ANY, print_any, match_any, hash_any, comp_any, FALSE, FALSE, FALSE)
gtk_css_selector_none_match, #undef GTK_CSS_CHANGE_ANY
gtk_css_selector_none_tree_match,
gtk_css_selector_none_get_change,
gtk_css_selector_none_tree_get_change,
gtk_css_selector_none_hash_one,
gtk_css_selector_none_compare_one,
FALSE, FALSE, FALSE, TRUE, FALSE
};
/* NAME */ /* NAME */
...@@ -1840,7 +1736,7 @@ parse_selector_negation (GtkCssParser *parser, ...@@ -1840,7 +1736,7 @@ parse_selector_negation (GtkCssParser *parser,
g_free (name); g_free (name);
} }
else if (_gtk_css_parser_try (parser, "*", FALSE)) else if (_gtk_css_parser_try (parser, "*", FALSE))
selector = gtk_css_selector_new (&GTK_CSS_SELECTOR_NONE, selector); selector = gtk_css_selector_new (&GTK_CSS_SELECTOR_NOT_ANY, selector);
else if (_gtk_css_parser_try (parser, "#", FALSE)) else if (_gtk_css_parser_try (parser, "#", FALSE))
selector = parse_selector_id (parser, selector, TRUE); selector = parse_selector_id (parser, selector, TRUE);
else if (_gtk_css_parser_try (parser, ".", FALSE)) else if (_gtk_css_parser_try (parser, ".", FALSE))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment