diff options
author | Benjamin Otte <otte@redhat.com> | 2014-07-19 23:26:12 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2014-07-19 23:42:39 +0200 |
commit | 19eb1614de30042ae39ca95c854803e03f3a6bae (patch) | |
tree | f8ede6598c4997902c4e28d04d1ac7cc2601f548 /gtk | |
parent | be09e0ed4ac3c98d2973f98e10d96f86832fb49f (diff) | |
download | gtk+-19eb1614de30042ae39ca95c854803e03f3a6bae.tar.gz |
cssmatcher: Use widget path's state
Don't take a state when constructing the CSS matcher. Instead, rely on
the newly introduced state in the widget path.
This way, the state can be queried not only on the first element, but on
all elements of the widget path.
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkcssmatcher.c | 8 | ||||
-rw-r--r-- | gtk/gtkcssmatcherprivate.h | 4 | ||||
-rw-r--r-- | gtk/gtkcssprovider.c | 19 | ||||
-rw-r--r-- | gtk/gtkstylecontext.c | 7 |
4 files changed, 23 insertions, 15 deletions
diff --git a/gtk/gtkcssmatcher.c b/gtk/gtkcssmatcher.c index 04d4571ce1..d169c274cf 100644 --- a/gtk/gtkcssmatcher.c +++ b/gtk/gtkcssmatcher.c @@ -32,7 +32,6 @@ gtk_css_matcher_widget_path_get_parent (GtkCssMatcher *matcher, matcher->path.klass = child->path.klass; matcher->path.path = child->path.path; - matcher->path.state_flags = 0; matcher->path.index = child->path.index - 1; matcher->path.sibling_index = gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index); @@ -48,7 +47,6 @@ gtk_css_matcher_widget_path_get_previous (GtkCssMatcher *matcher, matcher->path.klass = next->path.klass; matcher->path.path = next->path.path; - matcher->path.state_flags = 0; matcher->path.index = next->path.index; matcher->path.sibling_index = next->path.sibling_index - 1; @@ -58,7 +56,7 @@ gtk_css_matcher_widget_path_get_previous (GtkCssMatcher *matcher, static GtkStateFlags gtk_css_matcher_widget_path_get_state (const GtkCssMatcher *matcher) { - return matcher->path.state_flags; + return gtk_widget_path_iter_get_state (matcher->path.path, matcher->path.index); } static gboolean @@ -192,15 +190,13 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_WIDGET_PATH = { gboolean _gtk_css_matcher_init (GtkCssMatcher *matcher, - const GtkWidgetPath *path, - GtkStateFlags state) + const GtkWidgetPath *path) { if (gtk_widget_path_length (path) == 0) return FALSE; matcher->path.klass = >K_CSS_MATCHER_WIDGET_PATH; matcher->path.path = path; - matcher->path.state_flags = state; matcher->path.index = gtk_widget_path_length (path) - 1; matcher->path.sibling_index = gtk_widget_path_iter_get_sibling_index (path, matcher->path.index); diff --git a/gtk/gtkcssmatcherprivate.h b/gtk/gtkcssmatcherprivate.h index 1b2108c387..a98807180a 100644 --- a/gtk/gtkcssmatcherprivate.h +++ b/gtk/gtkcssmatcherprivate.h @@ -56,7 +56,6 @@ struct _GtkCssMatcherClass { struct _GtkCssMatcherWidgetPath { const GtkCssMatcherClass *klass; const GtkWidgetPath *path; - GtkStateFlags state_flags; guint index; guint sibling_index; }; @@ -74,8 +73,7 @@ union _GtkCssMatcher { }; gboolean _gtk_css_matcher_init (GtkCssMatcher *matcher, - const GtkWidgetPath *path, - GtkStateFlags state) G_GNUC_WARN_UNUSED_RESULT; + const GtkWidgetPath *path) G_GNUC_WARN_UNUSED_RESULT; void _gtk_css_matcher_any_init (GtkCssMatcher *matcher); void _gtk_css_matcher_superset_init (GtkCssMatcher *matcher, const GtkCssMatcher *subset, diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index c8e76ff74b..429713b363 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -40,6 +40,7 @@ #include "gtkstylepropertiesprivate.h" #include "gtkstylepropertyprivate.h" #include "gtkstyleproviderprivate.h" +#include "gtkwidgetpath.h" #include "gtkbindings.h" #include "gtkmarshalers.h" #include "gtkprivate.h" @@ -1668,8 +1669,21 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider, gchar *prop_name; gint i; - if (!_gtk_css_matcher_init (&matcher, path, state)) - return FALSE; + if (state == gtk_widget_path_iter_get_state (path, -1)) + { + gtk_widget_path_ref (path); + } + else + { + path = gtk_widget_path_copy (path); + gtk_widget_path_iter_set_state (path, -1, state); + } + + if (!_gtk_css_matcher_init (&matcher, path)) + { + gtk_widget_path_unref (path); + return FALSE; + } tree_rules = _gtk_css_selector_tree_match_all (priv->tree, &matcher); verify_tree_match_results (css_provider, &matcher, tree_rules); @@ -1712,6 +1726,7 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider, g_free (prop_name); g_ptr_array_free (tree_rules, TRUE); + gtk_widget_path_unref (path); return found; } diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 3d1e78876e..cc04eea70f 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -748,8 +748,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS } /* Set widget state */ - gtk_widget_path_iter_set_state (path, pos, - gtk_widget_path_iter_get_state (path, pos) | info->state_flags); + gtk_widget_path_iter_set_state (path, pos, info->state_flags); return path; } @@ -770,7 +769,7 @@ build_properties (GtkStyleContext *context, path = create_query_path (context, info); lookup = _gtk_css_lookup_new (relevant_changes); - if (_gtk_css_matcher_init (&matcher, path, info->state_flags)) + if (_gtk_css_matcher_init (&matcher, path)) _gtk_style_provider_private_lookup (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade), &matcher, lookup); @@ -2957,7 +2956,7 @@ gtk_style_context_needs_full_revalidate (GtkStyleContext *context, GtkCssMatcher matcher, superset; path = create_query_path (context, priv->info); - if (_gtk_css_matcher_init (&matcher, path, priv->info->state_flags)) + if (_gtk_css_matcher_init (&matcher, path)) { _gtk_css_matcher_superset_init (&superset, &matcher, GTK_STYLE_CONTEXT_RADICAL_CHANGE & ~GTK_CSS_CHANGE_SOURCE); priv->relevant_changes = _gtk_style_provider_private_get_change (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade), |