mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
cssomputedvalues: Track dependencies
We now track what values have dependencies on what other values so that we could in theory recompute them when we need to.
This commit is contained in:
parent
2cb9dac14c
commit
9b228c59d5
@ -254,6 +254,15 @@ _gtk_css_animated_values_new (GtkCssComputedValues *computed,
|
||||
_gtk_css_computed_values_get_section (computed, i));
|
||||
}
|
||||
|
||||
_gtk_bitmask_free (GTK_CSS_COMPUTED_VALUES (values)->depends_on_parent);
|
||||
_gtk_bitmask_free (GTK_CSS_COMPUTED_VALUES (values)->equals_parent);
|
||||
_gtk_bitmask_free (GTK_CSS_COMPUTED_VALUES (values)->depends_on_color);
|
||||
_gtk_bitmask_free (GTK_CSS_COMPUTED_VALUES (values)->depends_on_font_size);
|
||||
GTK_CSS_COMPUTED_VALUES (values)->depends_on_parent = _gtk_bitmask_copy (computed->depends_on_parent);
|
||||
GTK_CSS_COMPUTED_VALUES (values)->equals_parent = _gtk_bitmask_copy (computed->equals_parent);
|
||||
GTK_CSS_COMPUTED_VALUES (values)->depends_on_color = _gtk_bitmask_copy (computed->depends_on_color);
|
||||
GTK_CSS_COMPUTED_VALUES (values)->depends_on_font_size = _gtk_bitmask_copy (computed->depends_on_font_size);
|
||||
|
||||
gtk_css_animated_values_start_animations (values, timestamp, source);
|
||||
|
||||
ignore = _gtk_css_animated_values_advance (values, timestamp);
|
||||
|
@ -46,18 +46,35 @@ gtk_css_computed_values_dispose (GObject *object)
|
||||
G_OBJECT_CLASS (_gtk_css_computed_values_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_computed_values_finalize (GObject *object)
|
||||
{
|
||||
GtkCssComputedValues *values = GTK_CSS_COMPUTED_VALUES (object);
|
||||
|
||||
_gtk_bitmask_free (values->depends_on_parent);
|
||||
_gtk_bitmask_free (values->equals_parent);
|
||||
_gtk_bitmask_free (values->depends_on_color);
|
||||
_gtk_bitmask_free (values->depends_on_font_size);
|
||||
|
||||
G_OBJECT_CLASS (_gtk_css_computed_values_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_css_computed_values_class_init (GtkCssComputedValuesClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = gtk_css_computed_values_dispose;
|
||||
object_class->finalize = gtk_css_computed_values_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_css_computed_values_init (GtkCssComputedValues *computed_values)
|
||||
_gtk_css_computed_values_init (GtkCssComputedValues *values)
|
||||
{
|
||||
|
||||
values->depends_on_parent = _gtk_bitmask_new ();
|
||||
values->equals_parent = _gtk_bitmask_new ();
|
||||
values->depends_on_color = _gtk_bitmask_new ();
|
||||
values->depends_on_font_size = _gtk_bitmask_new ();
|
||||
}
|
||||
|
||||
GtkCssComputedValues *
|
||||
@ -90,6 +107,7 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
|
||||
GtkCssValue *specified,
|
||||
GtkCssSection *section)
|
||||
{
|
||||
GtkCssDependencies dependencies;
|
||||
|
||||
g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
@ -113,7 +131,16 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
|
||||
else
|
||||
_gtk_css_value_ref (specified);
|
||||
|
||||
g_ptr_array_index (values->values, id) = _gtk_css_value_compute (specified, id, context, NULL);
|
||||
g_ptr_array_index (values->values, id) = _gtk_css_value_compute (specified, id, context, &dependencies);
|
||||
|
||||
if (dependencies & (GTK_CSS_DEPENDS_ON_PARENT | GTK_CSS_EQUALS_PARENT))
|
||||
values->depends_on_parent = _gtk_bitmask_set (values->depends_on_parent, id, TRUE);
|
||||
if (dependencies & (GTK_CSS_EQUALS_PARENT))
|
||||
values->equals_parent = _gtk_bitmask_set (values->equals_parent, id, TRUE);
|
||||
if (dependencies & (GTK_CSS_DEPENDS_ON_COLOR))
|
||||
values->depends_on_color = _gtk_bitmask_set (values->depends_on_color, id, TRUE);
|
||||
if (dependencies & (GTK_CSS_DEPENDS_ON_FONT_SIZE))
|
||||
values->depends_on_font_size = _gtk_bitmask_set (values->depends_on_font_size, id, TRUE);
|
||||
|
||||
if (section)
|
||||
{
|
||||
|
@ -43,8 +43,12 @@ struct _GtkCssComputedValues
|
||||
{
|
||||
GObject parent;
|
||||
|
||||
GPtrArray *values;
|
||||
GPtrArray *values;
|
||||
GPtrArray *sections;
|
||||
GtkBitmask *depends_on_parent;
|
||||
GtkBitmask *equals_parent;
|
||||
GtkBitmask *depends_on_color;
|
||||
GtkBitmask *depends_on_font_size;
|
||||
};
|
||||
|
||||
struct _GtkCssComputedValuesClass
|
||||
|
Loading…
Reference in New Issue
Block a user