styleprovider: Fold get_change() vfunc into lookup()
This commit is contained in:
@ -300,7 +300,8 @@ gtk_style_properties_provider_get_color (GtkStyleProviderPrivate *provider,
|
||||
static void
|
||||
gtk_style_properties_provider_lookup (GtkStyleProviderPrivate *provider,
|
||||
const GtkCssMatcher *matcher,
|
||||
GtkCssLookup *lookup)
|
||||
GtkCssLookup *lookup,
|
||||
GtkCssChange *change)
|
||||
{
|
||||
GtkStyleProperties *props;
|
||||
GtkStylePropertiesPrivate *priv;
|
||||
@ -331,13 +332,9 @@ gtk_style_properties_provider_lookup (GtkStyleProviderPrivate *provider,
|
||||
|
||||
_gtk_css_lookup_set (lookup, id, NULL, value);
|
||||
}
|
||||
}
|
||||
|
||||
static GtkCssChange
|
||||
gtk_style_properties_provider_get_change (GtkStyleProviderPrivate *provider,
|
||||
const GtkCssMatcher *matcher)
|
||||
{
|
||||
return GTK_CSS_CHANGE_STATE;
|
||||
if (change)
|
||||
*change = GTK_CSS_CHANGE_STATE;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -345,7 +342,6 @@ gtk_style_properties_provider_private_init (GtkStyleProviderPrivateInterface *if
|
||||
{
|
||||
iface->get_color = gtk_style_properties_provider_get_color;
|
||||
iface->lookup = gtk_style_properties_provider_lookup;
|
||||
iface->get_change = gtk_style_properties_provider_get_change;
|
||||
}
|
||||
|
||||
/* GtkStyleProperties methods */
|
||||
|
@ -1774,7 +1774,8 @@ gtk_css_style_provider_get_keyframes (GtkStyleProviderPrivate *provider,
|
||||
static void
|
||||
gtk_css_style_provider_lookup (GtkStyleProviderPrivate *provider,
|
||||
const GtkCssMatcher *matcher,
|
||||
GtkCssLookup *lookup)
|
||||
GtkCssLookup *lookup,
|
||||
GtkCssChange *change)
|
||||
{
|
||||
GtkCssProvider *css_provider;
|
||||
GtkCssProviderPrivate *priv;
|
||||
@ -1819,24 +1820,16 @@ gtk_css_style_provider_lookup (GtkStyleProviderPrivate *provider,
|
||||
}
|
||||
|
||||
g_ptr_array_free (tree_rules, TRUE);
|
||||
}
|
||||
|
||||
static GtkCssChange
|
||||
gtk_css_style_provider_get_change (GtkStyleProviderPrivate *provider,
|
||||
const GtkCssMatcher *matcher)
|
||||
{
|
||||
GtkCssProvider *css_provider;
|
||||
GtkCssProviderPrivate *priv;
|
||||
GtkCssChange change;
|
||||
if (change)
|
||||
{
|
||||
GtkCssMatcher change_matcher;
|
||||
|
||||
css_provider = GTK_CSS_PROVIDER (provider);
|
||||
priv = css_provider->priv;
|
||||
_gtk_css_matcher_superset_init (&change_matcher, matcher, GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_CLASS);
|
||||
|
||||
change = _gtk_css_selector_tree_get_change_all (priv->tree, matcher);
|
||||
|
||||
verify_tree_get_change_results (css_provider, matcher, change);
|
||||
|
||||
return change;
|
||||
*change = _gtk_css_selector_tree_get_change_all (priv->tree, &change_matcher);
|
||||
verify_tree_get_change_results (css_provider, &change_matcher, *change);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1845,7 +1838,6 @@ gtk_css_style_provider_private_iface_init (GtkStyleProviderPrivateInterface *ifa
|
||||
iface->get_color = gtk_css_style_provider_get_color;
|
||||
iface->get_keyframes = gtk_css_style_provider_get_keyframes;
|
||||
iface->lookup = gtk_css_style_provider_lookup;
|
||||
iface->get_change = gtk_css_style_provider_get_change;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -118,23 +118,15 @@ gtk_modifier_style_provider_get_color (GtkStyleProviderPrivate *provider,
|
||||
static void
|
||||
gtk_modifier_style_provider_lookup (GtkStyleProviderPrivate *provider,
|
||||
const GtkCssMatcher *matcher,
|
||||
GtkCssLookup *lookup)
|
||||
GtkCssLookup *lookup,
|
||||
GtkCssChange *change)
|
||||
{
|
||||
GtkModifierStyle *style = GTK_MODIFIER_STYLE (provider);
|
||||
|
||||
_gtk_style_provider_private_lookup (GTK_STYLE_PROVIDER_PRIVATE (style->priv->style),
|
||||
matcher,
|
||||
lookup);
|
||||
}
|
||||
|
||||
static GtkCssChange
|
||||
gtk_modifier_style_provider_get_change (GtkStyleProviderPrivate *provider,
|
||||
const GtkCssMatcher *matcher)
|
||||
{
|
||||
GtkModifierStyle *style = GTK_MODIFIER_STYLE (provider);
|
||||
|
||||
return _gtk_style_provider_private_get_change (GTK_STYLE_PROVIDER_PRIVATE (style->priv->style),
|
||||
matcher);
|
||||
lookup,
|
||||
change);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -142,7 +134,6 @@ gtk_modifier_style_provider_private_init (GtkStyleProviderPrivateInterface *ifac
|
||||
{
|
||||
iface->get_color = gtk_modifier_style_provider_get_color;
|
||||
iface->lookup = gtk_modifier_style_provider_lookup;
|
||||
iface->get_change = gtk_modifier_style_provider_get_change;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1716,14 +1716,6 @@ gtk_settings_provider_iface_init (GtkStyleProviderIface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
static GtkCssChange
|
||||
gtk_settings_style_provider_get_change (GtkStyleProviderPrivate *provider,
|
||||
const GtkCssMatcher *matcher)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static GtkSettings *
|
||||
gtk_settings_style_provider_get_settings (GtkStyleProviderPrivate *provider)
|
||||
{
|
||||
@ -1734,7 +1726,6 @@ static void
|
||||
gtk_settings_provider_private_init (GtkStyleProviderPrivateInterface *iface)
|
||||
{
|
||||
iface->get_settings = gtk_settings_style_provider_get_settings;
|
||||
iface->get_change = gtk_settings_style_provider_get_change;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -201,11 +201,13 @@ gtk_style_cascade_get_keyframes (GtkStyleProviderPrivate *provider,
|
||||
static void
|
||||
gtk_style_cascade_lookup (GtkStyleProviderPrivate *provider,
|
||||
const GtkCssMatcher *matcher,
|
||||
GtkCssLookup *lookup)
|
||||
GtkCssLookup *lookup,
|
||||
GtkCssChange *change)
|
||||
{
|
||||
GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
|
||||
GtkStyleCascadeIter iter;
|
||||
GtkStyleProvider *item;
|
||||
GtkCssChange iter_change;
|
||||
|
||||
for (item = gtk_style_cascade_iter_init (cascade, &iter);
|
||||
item;
|
||||
@ -215,7 +217,10 @@ gtk_style_cascade_lookup (GtkStyleProviderPrivate *provider,
|
||||
{
|
||||
_gtk_style_provider_private_lookup (GTK_STYLE_PROVIDER_PRIVATE (item),
|
||||
matcher,
|
||||
lookup);
|
||||
lookup,
|
||||
change ? &iter_change : NULL);
|
||||
if (change)
|
||||
*change |= iter_change;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -225,33 +230,6 @@ gtk_style_cascade_lookup (GtkStyleProviderPrivate *provider,
|
||||
}
|
||||
}
|
||||
|
||||
static GtkCssChange
|
||||
gtk_style_cascade_get_change (GtkStyleProviderPrivate *provider,
|
||||
const GtkCssMatcher *matcher)
|
||||
{
|
||||
GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
|
||||
GtkStyleCascadeIter iter;
|
||||
GtkStyleProvider *item;
|
||||
GtkCssChange change = 0;
|
||||
|
||||
for (item = gtk_style_cascade_iter_init (cascade, &iter);
|
||||
item;
|
||||
item = gtk_style_cascade_iter_next (cascade, &iter))
|
||||
{
|
||||
if (GTK_IS_STYLE_PROVIDER_PRIVATE (item))
|
||||
{
|
||||
change |= _gtk_style_provider_private_get_change (GTK_STYLE_PROVIDER_PRIVATE (item),
|
||||
matcher);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_return_val_if_reached (GTK_CSS_CHANGE_ANY);
|
||||
}
|
||||
}
|
||||
|
||||
return change;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_style_cascade_provider_private_iface_init (GtkStyleProviderPrivateInterface *iface)
|
||||
{
|
||||
@ -259,7 +237,6 @@ gtk_style_cascade_provider_private_iface_init (GtkStyleProviderPrivateInterface
|
||||
iface->get_settings = gtk_style_cascade_get_settings;
|
||||
iface->get_keyframes = gtk_style_cascade_get_keyframes;
|
||||
iface->lookup = gtk_style_cascade_lookup;
|
||||
iface->get_change = gtk_style_cascade_get_change;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE_EXTENDED (GtkStyleCascade, _gtk_style_cascade, G_TYPE_OBJECT, 0,
|
||||
|
@ -670,7 +670,8 @@ static void
|
||||
build_properties (GtkStyleContext *context,
|
||||
GtkCssComputedValues *values,
|
||||
const GtkCssNodeDeclaration *decl,
|
||||
const GtkBitmask *relevant_changes)
|
||||
const GtkBitmask *relevant_changes,
|
||||
GtkCssChange *out_change)
|
||||
{
|
||||
GtkStyleContextPrivate *priv;
|
||||
GtkCssMatcher matcher;
|
||||
@ -685,7 +686,8 @@ build_properties (GtkStyleContext *context,
|
||||
if (_gtk_css_matcher_init (&matcher, path))
|
||||
_gtk_style_provider_private_lookup (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
|
||||
&matcher,
|
||||
lookup);
|
||||
lookup,
|
||||
out_change);
|
||||
|
||||
_gtk_css_lookup_resolve (lookup,
|
||||
GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
|
||||
@ -724,11 +726,17 @@ style_values_lookup (GtkStyleContext *context)
|
||||
|
||||
style_info_set_values (info, values);
|
||||
if (gtk_style_context_is_saved (context))
|
||||
g_hash_table_insert (priv->style_values,
|
||||
gtk_css_node_declaration_ref (info->decl),
|
||||
g_object_ref (values));
|
||||
{
|
||||
g_hash_table_insert (priv->style_values,
|
||||
gtk_css_node_declaration_ref (info->decl),
|
||||
g_object_ref (values));
|
||||
|
||||
build_properties (context, values, info->decl, NULL);
|
||||
build_properties (context, values, info->decl, NULL, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
build_properties (context, values, info->decl, NULL, &priv->relevant_changes);
|
||||
}
|
||||
|
||||
g_object_unref (values);
|
||||
|
||||
@ -751,7 +759,7 @@ style_values_lookup_for_state (GtkStyleContext *context,
|
||||
decl = gtk_css_node_declaration_ref (context->priv->info->decl);
|
||||
gtk_css_node_declaration_set_state (&decl, state);
|
||||
values = _gtk_css_computed_values_new ();
|
||||
build_properties (context, values, decl, NULL);
|
||||
build_properties (context, values, decl, NULL, NULL);
|
||||
gtk_css_node_declaration_unref (decl);
|
||||
|
||||
return values;
|
||||
@ -2638,7 +2646,7 @@ gtk_style_context_update_cache (GtkStyleContext *context,
|
||||
changes = _gtk_css_computed_values_compute_dependencies (values, parent_changes);
|
||||
|
||||
if (!_gtk_bitmask_is_empty (changes))
|
||||
build_properties (context, values, decl, changes);
|
||||
build_properties (context, values, decl, changes, NULL);
|
||||
|
||||
_gtk_bitmask_free (changes);
|
||||
}
|
||||
@ -2694,31 +2702,7 @@ gtk_style_context_needs_full_revalidate (GtkStyleContext *context,
|
||||
|
||||
/* Try to avoid invalidating if we can */
|
||||
if (change & GTK_STYLE_CONTEXT_RADICAL_CHANGE)
|
||||
{
|
||||
priv->relevant_changes = GTK_CSS_CHANGE_ANY;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (priv->relevant_changes == GTK_CSS_CHANGE_ANY)
|
||||
{
|
||||
GtkWidgetPath *path;
|
||||
GtkCssMatcher matcher, superset;
|
||||
|
||||
path = create_query_path (context, priv->info->decl);
|
||||
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),
|
||||
&superset);
|
||||
}
|
||||
else
|
||||
priv->relevant_changes = 0;
|
||||
|
||||
priv->relevant_changes &= ~GTK_STYLE_CONTEXT_RADICAL_CHANGE;
|
||||
|
||||
gtk_widget_path_unref (path);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
if (priv->relevant_changes & change)
|
||||
return TRUE;
|
||||
@ -2837,7 +2821,7 @@ _gtk_style_context_validate (GtkStyleContext *context,
|
||||
{
|
||||
changes = _gtk_css_computed_values_compute_dependencies (current, parent_changes);
|
||||
if (!_gtk_bitmask_is_empty (changes))
|
||||
build_properties (context, current, info->decl, changes);
|
||||
build_properties (context, current, info->decl, changes, NULL);
|
||||
|
||||
gtk_style_context_update_cache (context, parent_changes);
|
||||
}
|
||||
|
@ -84,7 +84,8 @@ _gtk_style_provider_private_get_keyframes (GtkStyleProviderPrivate *provider,
|
||||
void
|
||||
_gtk_style_provider_private_lookup (GtkStyleProviderPrivate *provider,
|
||||
const GtkCssMatcher *matcher,
|
||||
GtkCssLookup *lookup)
|
||||
GtkCssLookup *lookup,
|
||||
GtkCssChange *out_change)
|
||||
{
|
||||
GtkStyleProviderPrivateInterface *iface;
|
||||
|
||||
@ -92,29 +93,15 @@ _gtk_style_provider_private_lookup (GtkStyleProviderPrivate *provider,
|
||||
g_return_if_fail (matcher != NULL);
|
||||
g_return_if_fail (lookup != NULL);
|
||||
|
||||
if (out_change)
|
||||
*out_change = 0;
|
||||
|
||||
iface = GTK_STYLE_PROVIDER_PRIVATE_GET_INTERFACE (provider);
|
||||
|
||||
if (!iface->lookup)
|
||||
return;
|
||||
|
||||
iface->lookup (provider, matcher, lookup);
|
||||
}
|
||||
|
||||
GtkCssChange
|
||||
_gtk_style_provider_private_get_change (GtkStyleProviderPrivate *provider,
|
||||
const GtkCssMatcher *matcher)
|
||||
{
|
||||
GtkStyleProviderPrivateInterface *iface;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider), GTK_CSS_CHANGE_ANY);
|
||||
g_return_val_if_fail (matcher != NULL, GTK_CSS_CHANGE_ANY);
|
||||
|
||||
iface = GTK_STYLE_PROVIDER_PRIVATE_GET_INTERFACE (provider);
|
||||
|
||||
if (!iface->get_change)
|
||||
return GTK_CSS_CHANGE_ANY;
|
||||
|
||||
return iface->get_change (provider, matcher);
|
||||
iface->lookup (provider, matcher, lookup, out_change);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -46,9 +46,8 @@ struct _GtkStyleProviderPrivateInterface
|
||||
const char *name);
|
||||
void (* lookup) (GtkStyleProviderPrivate *provider,
|
||||
const GtkCssMatcher *matcher,
|
||||
GtkCssLookup *lookup);
|
||||
GtkCssChange (* get_change) (GtkStyleProviderPrivate *provider,
|
||||
const GtkCssMatcher *matcher);
|
||||
GtkCssLookup *lookup,
|
||||
GtkCssChange *out_change);
|
||||
|
||||
/* signal */
|
||||
void (* changed) (GtkStyleProviderPrivate *provider);
|
||||
@ -63,9 +62,8 @@ GtkCssKeyframes * _gtk_style_provider_private_get_keyframes(GtkStyleProvid
|
||||
const char *name);
|
||||
void _gtk_style_provider_private_lookup (GtkStyleProviderPrivate *provider,
|
||||
const GtkCssMatcher *matcher,
|
||||
GtkCssLookup *lookup);
|
||||
GtkCssChange _gtk_style_provider_private_get_change (GtkStyleProviderPrivate *provider,
|
||||
const GtkCssMatcher *matcher);
|
||||
GtkCssLookup *lookup,
|
||||
GtkCssChange *out_change);
|
||||
|
||||
void _gtk_style_provider_private_changed (GtkStyleProviderPrivate *provider);
|
||||
|
||||
|
Reference in New Issue
Block a user