forked from AuroraMiddleware/gtk
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.
This commit is contained in:
parent
be09e0ed4a
commit
19eb1614de
@ -32,7 +32,6 @@ gtk_css_matcher_widget_path_get_parent (GtkCssMatcher *matcher,
|
|||||||
|
|
||||||
matcher->path.klass = child->path.klass;
|
matcher->path.klass = child->path.klass;
|
||||||
matcher->path.path = child->path.path;
|
matcher->path.path = child->path.path;
|
||||||
matcher->path.state_flags = 0;
|
|
||||||
matcher->path.index = child->path.index - 1;
|
matcher->path.index = child->path.index - 1;
|
||||||
matcher->path.sibling_index = gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index);
|
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.klass = next->path.klass;
|
||||||
matcher->path.path = next->path.path;
|
matcher->path.path = next->path.path;
|
||||||
matcher->path.state_flags = 0;
|
|
||||||
matcher->path.index = next->path.index;
|
matcher->path.index = next->path.index;
|
||||||
matcher->path.sibling_index = next->path.sibling_index - 1;
|
matcher->path.sibling_index = next->path.sibling_index - 1;
|
||||||
|
|
||||||
@ -58,7 +56,7 @@ gtk_css_matcher_widget_path_get_previous (GtkCssMatcher *matcher,
|
|||||||
static GtkStateFlags
|
static GtkStateFlags
|
||||||
gtk_css_matcher_widget_path_get_state (const GtkCssMatcher *matcher)
|
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
|
static gboolean
|
||||||
@ -192,15 +190,13 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_WIDGET_PATH = {
|
|||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
_gtk_css_matcher_init (GtkCssMatcher *matcher,
|
_gtk_css_matcher_init (GtkCssMatcher *matcher,
|
||||||
const GtkWidgetPath *path,
|
const GtkWidgetPath *path)
|
||||||
GtkStateFlags state)
|
|
||||||
{
|
{
|
||||||
if (gtk_widget_path_length (path) == 0)
|
if (gtk_widget_path_length (path) == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
matcher->path.klass = >K_CSS_MATCHER_WIDGET_PATH;
|
matcher->path.klass = >K_CSS_MATCHER_WIDGET_PATH;
|
||||||
matcher->path.path = path;
|
matcher->path.path = path;
|
||||||
matcher->path.state_flags = state;
|
|
||||||
matcher->path.index = gtk_widget_path_length (path) - 1;
|
matcher->path.index = gtk_widget_path_length (path) - 1;
|
||||||
matcher->path.sibling_index = gtk_widget_path_iter_get_sibling_index (path, matcher->path.index);
|
matcher->path.sibling_index = gtk_widget_path_iter_get_sibling_index (path, matcher->path.index);
|
||||||
|
|
||||||
|
@ -56,7 +56,6 @@ struct _GtkCssMatcherClass {
|
|||||||
struct _GtkCssMatcherWidgetPath {
|
struct _GtkCssMatcherWidgetPath {
|
||||||
const GtkCssMatcherClass *klass;
|
const GtkCssMatcherClass *klass;
|
||||||
const GtkWidgetPath *path;
|
const GtkWidgetPath *path;
|
||||||
GtkStateFlags state_flags;
|
|
||||||
guint index;
|
guint index;
|
||||||
guint sibling_index;
|
guint sibling_index;
|
||||||
};
|
};
|
||||||
@ -74,8 +73,7 @@ union _GtkCssMatcher {
|
|||||||
};
|
};
|
||||||
|
|
||||||
gboolean _gtk_css_matcher_init (GtkCssMatcher *matcher,
|
gboolean _gtk_css_matcher_init (GtkCssMatcher *matcher,
|
||||||
const GtkWidgetPath *path,
|
const GtkWidgetPath *path) G_GNUC_WARN_UNUSED_RESULT;
|
||||||
GtkStateFlags state) G_GNUC_WARN_UNUSED_RESULT;
|
|
||||||
void _gtk_css_matcher_any_init (GtkCssMatcher *matcher);
|
void _gtk_css_matcher_any_init (GtkCssMatcher *matcher);
|
||||||
void _gtk_css_matcher_superset_init (GtkCssMatcher *matcher,
|
void _gtk_css_matcher_superset_init (GtkCssMatcher *matcher,
|
||||||
const GtkCssMatcher *subset,
|
const GtkCssMatcher *subset,
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include "gtkstylepropertiesprivate.h"
|
#include "gtkstylepropertiesprivate.h"
|
||||||
#include "gtkstylepropertyprivate.h"
|
#include "gtkstylepropertyprivate.h"
|
||||||
#include "gtkstyleproviderprivate.h"
|
#include "gtkstyleproviderprivate.h"
|
||||||
|
#include "gtkwidgetpath.h"
|
||||||
#include "gtkbindings.h"
|
#include "gtkbindings.h"
|
||||||
#include "gtkmarshalers.h"
|
#include "gtkmarshalers.h"
|
||||||
#include "gtkprivate.h"
|
#include "gtkprivate.h"
|
||||||
@ -1668,8 +1669,21 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider,
|
|||||||
gchar *prop_name;
|
gchar *prop_name;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
if (!_gtk_css_matcher_init (&matcher, path, state))
|
if (state == gtk_widget_path_iter_get_state (path, -1))
|
||||||
return FALSE;
|
{
|
||||||
|
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);
|
tree_rules = _gtk_css_selector_tree_match_all (priv->tree, &matcher);
|
||||||
verify_tree_match_results (css_provider, &matcher, tree_rules);
|
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_free (prop_name);
|
||||||
g_ptr_array_free (tree_rules, TRUE);
|
g_ptr_array_free (tree_rules, TRUE);
|
||||||
|
gtk_widget_path_unref (path);
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
@ -748,8 +748,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set widget state */
|
/* Set widget state */
|
||||||
gtk_widget_path_iter_set_state (path, pos,
|
gtk_widget_path_iter_set_state (path, pos, info->state_flags);
|
||||||
gtk_widget_path_iter_get_state (path, pos) | info->state_flags);
|
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
@ -770,7 +769,7 @@ build_properties (GtkStyleContext *context,
|
|||||||
path = create_query_path (context, info);
|
path = create_query_path (context, info);
|
||||||
lookup = _gtk_css_lookup_new (relevant_changes);
|
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),
|
_gtk_style_provider_private_lookup (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
|
||||||
&matcher,
|
&matcher,
|
||||||
lookup);
|
lookup);
|
||||||
@ -2957,7 +2956,7 @@ gtk_style_context_needs_full_revalidate (GtkStyleContext *context,
|
|||||||
GtkCssMatcher matcher, superset;
|
GtkCssMatcher matcher, superset;
|
||||||
|
|
||||||
path = create_query_path (context, priv->info);
|
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);
|
_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),
|
priv->relevant_changes = _gtk_style_provider_private_get_change (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
|
||||||
|
Loading…
Reference in New Issue
Block a user