cssmatcher: Handle case of empty widget path
This is tested by the stylecontext test, but doesn't appear in practice.
This commit is contained in:
@ -187,16 +187,21 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_WIDGET_PATH = {
|
||||
gtk_css_matcher_widget_path_has_position,
|
||||
};
|
||||
|
||||
void
|
||||
gboolean
|
||||
_gtk_css_matcher_init (GtkCssMatcher *matcher,
|
||||
const GtkWidgetPath *path,
|
||||
GtkStateFlags state)
|
||||
{
|
||||
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);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* GTK_CSS_MATCHER_WIDGET_ANY */
|
||||
|
@ -72,9 +72,9 @@ union _GtkCssMatcher {
|
||||
GtkCssMatcherSuperset superset;
|
||||
};
|
||||
|
||||
void _gtk_css_matcher_init (GtkCssMatcher *matcher,
|
||||
gboolean _gtk_css_matcher_init (GtkCssMatcher *matcher,
|
||||
const GtkWidgetPath *path,
|
||||
GtkStateFlags state);
|
||||
GtkStateFlags state) G_GNUC_WARN_UNUSED_RESULT;
|
||||
void _gtk_css_matcher_any_init (GtkCssMatcher *matcher);
|
||||
void _gtk_css_matcher_superset_init (GtkCssMatcher *matcher,
|
||||
const GtkCssMatcher *subset,
|
||||
|
@ -1485,25 +1485,26 @@ gtk_css_provider_get_style (GtkStyleProvider *provider,
|
||||
props = gtk_style_properties_new ();
|
||||
|
||||
css_provider_dump_symbolic_colors (css_provider, props);
|
||||
_gtk_css_matcher_init (&matcher, path, 0);
|
||||
|
||||
for (i = 0; i < priv->rulesets->len; i++)
|
||||
if (_gtk_css_matcher_init (&matcher, path, 0))
|
||||
{
|
||||
GtkCssRuleset *ruleset;
|
||||
for (i = 0; i < priv->rulesets->len; i++)
|
||||
{
|
||||
GtkCssRuleset *ruleset;
|
||||
|
||||
ruleset = &g_array_index (priv->rulesets, GtkCssRuleset, i);
|
||||
ruleset = &g_array_index (priv->rulesets, GtkCssRuleset, i);
|
||||
|
||||
if (ruleset->styles == NULL)
|
||||
continue;
|
||||
if (ruleset->styles == NULL)
|
||||
continue;
|
||||
|
||||
if (!gtk_css_ruleset_matches (ruleset, &matcher))
|
||||
continue;
|
||||
if (!gtk_css_ruleset_matches (ruleset, &matcher))
|
||||
continue;
|
||||
|
||||
for (j = 0; j < ruleset->n_styles; j++)
|
||||
_gtk_style_properties_set_property_by_property (props,
|
||||
GTK_CSS_STYLE_PROPERTY (ruleset->styles[i].property),
|
||||
_gtk_css_selector_get_state_flags (ruleset->selector),
|
||||
ruleset->styles[i].value);
|
||||
for (j = 0; j < ruleset->n_styles; j++)
|
||||
_gtk_style_properties_set_property_by_property (props,
|
||||
GTK_CSS_STYLE_PROPERTY (ruleset->styles[i].property),
|
||||
_gtk_css_selector_get_state_flags (ruleset->selector),
|
||||
ruleset->styles[i].value);
|
||||
}
|
||||
}
|
||||
|
||||
return props;
|
||||
@ -1524,10 +1525,12 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider,
|
||||
gchar *prop_name;
|
||||
gint i;
|
||||
|
||||
if (!_gtk_css_matcher_init (&matcher, path, state))
|
||||
return FALSE;
|
||||
|
||||
prop_name = g_strdup_printf ("-%s-%s",
|
||||
g_type_name (pspec->owner_type),
|
||||
pspec->name);
|
||||
_gtk_css_matcher_init (&matcher, path, state);
|
||||
|
||||
for (i = priv->rulesets->len - 1; i >= 0; i--)
|
||||
{
|
||||
|
@ -905,12 +905,12 @@ build_properties (GtkStyleContext *context,
|
||||
|
||||
priv = context->priv;
|
||||
|
||||
_gtk_css_matcher_init (&matcher, path, state);
|
||||
lookup = _gtk_css_lookup_new ();
|
||||
|
||||
_gtk_style_provider_private_lookup (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
|
||||
&matcher,
|
||||
lookup);
|
||||
if (_gtk_css_matcher_init (&matcher, path, state))
|
||||
_gtk_style_provider_private_lookup (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
|
||||
&matcher,
|
||||
lookup);
|
||||
|
||||
style_data->store = _gtk_css_computed_values_new ();
|
||||
_gtk_css_lookup_resolve (lookup, context, style_data->store);
|
||||
@ -3061,10 +3061,12 @@ _gtk_style_context_validate (GtkStyleContext *context,
|
||||
GtkCssMatcher matcher;
|
||||
|
||||
path = create_query_path (context);
|
||||
_gtk_css_matcher_init (&matcher, path, priv->info->state_flags);
|
||||
if (_gtk_css_matcher_init (&matcher, path, priv->info->state_flags))
|
||||
priv->relevant_changes = _gtk_style_provider_private_get_change (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
|
||||
&matcher);
|
||||
else
|
||||
priv->relevant_changes = 0;
|
||||
|
||||
priv->relevant_changes = _gtk_style_provider_private_get_change (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
|
||||
&matcher);
|
||||
priv->relevant_changes &= ~GTK_STYLE_CONTEXT_RADICAL_CHANGE;
|
||||
|
||||
gtk_widget_path_unref (path);
|
||||
|
Reference in New Issue
Block a user