Commit 730f4291 authored by Benjamin Otte's avatar Benjamin Otte

cssstaticstyle: Handle relevant change

Relevant change is returned from style lookups, so keep is with the
object that holds those values.
parent ad199e4c
......@@ -184,11 +184,11 @@ GtkCssStyle *
gtk_css_static_style_new_compute (GtkStyleProviderPrivate *provider,
const GtkCssMatcher *matcher,
int scale,
GtkCssStyle *parent,
GtkCssChange *out_change)
GtkCssStyle *parent)
{
GtkCssStaticStyle *result;
GtkCssLookup *lookup;
GtkCssChange change = GTK_CSS_CHANGE_ANY_SELF | GTK_CSS_CHANGE_ANY_SIBLING | GTK_CSS_CHANGE_ANY_PARENT;
lookup = _gtk_css_lookup_new (NULL);
......@@ -196,10 +196,12 @@ gtk_css_static_style_new_compute (GtkStyleProviderPrivate *provider,
_gtk_style_provider_private_lookup (provider,
matcher,
lookup,
out_change);
&change);
result = g_object_new (GTK_TYPE_CSS_STATIC_STYLE, NULL);
result->change = change;
_gtk_css_lookup_resolve (lookup,
provider,
scale,
......@@ -238,6 +240,7 @@ gtk_css_static_style_new_update (GtkCssStaticStyle *style,
result = g_object_new (GTK_TYPE_CSS_STATIC_STYLE, NULL);
result->change = style->change;
result->depends_on_parent = _gtk_bitmask_subtract (_gtk_bitmask_union (result->depends_on_parent, style->depends_on_parent),
changes);
result->equals_parent = _gtk_bitmask_subtract (_gtk_bitmask_union (result->equals_parent, style->equals_parent),
......@@ -327,3 +330,10 @@ gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
_gtk_css_value_unref (specified);
}
GtkCssChange
gtk_css_static_style_get_change (GtkCssStaticStyle *style)
{
g_return_val_if_fail (GTK_IS_CSS_STATIC_STYLE (style), GTK_CSS_CHANGE_ANY);
return style->change;
}
......@@ -46,6 +46,8 @@ struct _GtkCssStaticStyle
GtkBitmask *equals_parent; /* values that equal their parent values */
GtkBitmask *depends_on_color; /* values that depend on the color property */
GtkBitmask *depends_on_font_size; /* values that depend on the font-size property */
GtkCssChange change; /* change as returned by value lookup */
};
struct _GtkCssStaticStyleClass
......@@ -58,8 +60,7 @@ GType gtk_css_static_style_get_type (void) G_GNUC_CO
GtkCssStyle * gtk_css_static_style_new_compute (GtkStyleProviderPrivate *provider,
const GtkCssMatcher *matcher,
int scale,
GtkCssStyle *parent,
GtkCssChange *out_change);
GtkCssStyle *parent);
GtkCssStyle * gtk_css_static_style_new_update (GtkCssStaticStyle *style,
const GtkBitmask *parent_changes,
GtkStyleProviderPrivate *provider,
......@@ -75,6 +76,8 @@ void gtk_css_static_style_compute_value (GtkCssStaticSty
GtkCssValue *specified,
GtkCssSection *section);
GtkCssChange gtk_css_static_style_get_change (GtkCssStaticStyle *style);
G_END_DECLS
#endif /* __GTK_CSS_STATIC_STYLE_PRIVATE_H__ */
......@@ -167,7 +167,6 @@ struct _GtkStyleContextPrivate
guint frame_clock_update_id;
GdkFrameClock *frame_clock;
GtkCssChange relevant_changes;
GtkCssChange pending_changes;
const GtkBitmask *invalidating_context;
......@@ -407,7 +406,6 @@ gtk_style_context_init (GtkStyleContext *style_context)
g_object_unref);
priv->screen = gdk_screen_get_default ();
priv->relevant_changes = GTK_CSS_CHANGE_ANY;
/* Create default info store */
priv->info = style_info_new ();
......@@ -718,8 +716,7 @@ update_properties (GtkStyleContext *context,
static GtkCssStyle *
build_properties (GtkStyleContext *context,
const GtkCssNodeDeclaration *decl,
GtkCssChange *out_change)
const GtkCssNodeDeclaration *decl)
{
GtkStyleContextPrivate *priv;
GtkCssMatcher matcher;
......@@ -734,14 +731,12 @@ build_properties (GtkStyleContext *context,
style = gtk_css_static_style_new_compute (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
&matcher,
priv->scale,
parent,
out_change);
parent);
else
style = gtk_css_static_style_new_compute (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
NULL,
priv->scale,
parent,
out_change);
parent);
gtk_widget_path_free (path);
......@@ -773,7 +768,7 @@ style_values_lookup (GtkStyleContext *context)
return values;
}
values = build_properties (context, info->decl, NULL);
values = build_properties (context, info->decl);
g_hash_table_insert (priv->style_values,
gtk_css_node_declaration_ref (info->decl),
g_object_ref (values));
......@@ -781,9 +776,7 @@ style_values_lookup (GtkStyleContext *context)
}
else
{
values = build_properties (context, info->decl, &priv->relevant_changes);
/* These flags are always relevant */
priv->relevant_changes |= GTK_CSS_CHANGE_SOURCE;
values = build_properties (context, info->decl);
}
style_info_set_values (info, values);
......@@ -807,7 +800,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 = build_properties (context, decl, NULL);
values = build_properties (context, decl);
gtk_css_node_declaration_unref (decl);
return values;
......@@ -2733,16 +2726,17 @@ gtk_style_context_do_invalidate (GtkStyleContext *context,
}
static gboolean
gtk_style_context_needs_full_revalidate (GtkStyleContext *context,
GtkCssChange change)
gtk_style_context_style_needs_full_revalidate (GtkCssStyle *style,
GtkCssChange change)
{
GtkStyleContextPrivate *priv = context->priv;
/* Try to avoid invalidating if we can */
if (change & GTK_STYLE_CONTEXT_RADICAL_CHANGE)
return TRUE;
if (priv->relevant_changes & change)
if (GTK_IS_CSS_ANIMATED_STYLE (style))
style = GTK_CSS_ANIMATED_STYLE (style)->style;
if (gtk_css_static_style_get_change (GTK_CSS_STATIC_STYLE (style)) & change)
return TRUE;
else
return FALSE;
......@@ -2818,18 +2812,11 @@ _gtk_style_context_validate (GtkStyleContext *context,
/* Try to avoid invalidating if we can */
if (current == NULL ||
gtk_style_context_needs_full_revalidate (context, change))
gtk_style_context_style_needs_full_revalidate (current, change))
{
GtkCssStyle *values;
if ((priv->relevant_changes & change) & ~GTK_STYLE_CONTEXT_CACHED_CHANGE)
{
gtk_style_context_clear_cache (context);
}
else
{
gtk_style_context_update_cache (context, parent_changes);
}
gtk_style_context_clear_cache (context);
style_info_set_values (info, NULL);
values = style_values_lookup (context);
......
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