cssstyle: Rename GtkCssComputedValues => GtkCssStyle

This is literally just renaming of the object (and the associated source
files). No other changes are in there.
This commit is contained in:
Benjamin Otte 2014-10-22 23:41:50 +02:00
parent f51419adb0
commit 572f46067f
51 changed files with 960 additions and 956 deletions

View File

@ -372,7 +372,6 @@ gtk_private_h_sources = \
gtkcssbgsizevalueprivate.h \
gtkcssbordervalueprivate.h \
gtkcsscolorvalueprivate.h \
gtkcsscomputedvaluesprivate.h \
gtkcsscornervalueprivate.h \
gtkcsscustompropertyprivate.h \
gtkcsseasevalueprivate.h \
@ -408,6 +407,7 @@ gtk_private_h_sources = \
gtkcssshorthandpropertyprivate.h \
gtkcssstringvalueprivate.h \
gtkcssstylefuncsprivate.h \
gtkcssstyleprivate.h \
gtkcssstylepropertyprivate.h \
gtkcsstransformvalueprivate.h \
gtkcsstransitionprivate.h \
@ -596,7 +596,6 @@ gtk_base_c_sources = \
gtkcssbgsizevalue.c \
gtkcssbordervalue.c \
gtkcsscolorvalue.c \
gtkcsscomputedvalues.c \
gtkcsscornervalue.c \
gtkcsscustomproperty.c \
gtkcsseasevalue.c \
@ -628,6 +627,7 @@ gtk_base_c_sources = \
gtkcsssection.c \
gtkcssselector.c \
gtkcssstringvalue.c \
gtkcssstyle.c \
gtkcssshadowsvalue.c \
gtkcssshadowvalue.c \
gtkcssshorthandproperty.c \

View File

@ -305,8 +305,8 @@ gtk_gradient_resolve (GtkGradient *gradient,
cairo_pattern_t *
_gtk_gradient_resolve_full (GtkGradient *gradient,
GtkStyleProviderPrivate *provider,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
cairo_pattern_t *pattern;
@ -314,8 +314,8 @@ _gtk_gradient_resolve_full (GtkGradient *gradient,
g_return_val_if_fail (gradient != NULL, NULL);
g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
g_return_val_if_fail (parent_values == NULL || GTK_IS_CSS_COMPUTED_VALUES (parent_values), NULL);
g_return_val_if_fail (GTK_IS_CSS_STYLE (values), NULL);
g_return_val_if_fail (parent_values == NULL || GTK_IS_CSS_STYLE (parent_values), NULL);
g_return_val_if_fail (*dependencies == 0, NULL);
if (gradient->radius0 == 0 && gradient->radius1 == 0)
@ -339,7 +339,7 @@ _gtk_gradient_resolve_full (GtkGradient *gradient,
/* if color resolving fails, assume transparency */
val = _gtk_css_color_value_resolve (_gtk_symbolic_color_get_css_value (stop->color),
provider,
_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_COLOR),
gtk_css_style_get_value (values, GTK_CSS_PROPERTY_COLOR),
GTK_CSS_DEPENDS_ON_COLOR,
&stop_deps,
NULL);

View File

@ -25,8 +25,8 @@ G_BEGIN_DECLS
cairo_pattern_t * _gtk_gradient_resolve_full (GtkGradient *gradient,
GtkStyleProviderPrivate *provider,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies);
GtkGradient * _gtk_gradient_transition (GtkGradient *start,

View File

@ -104,7 +104,7 @@ gtk_css_animation_get_progress_from_iteration (GtkCssAnimation *animation,
static void
gtk_css_animation_set_values (GtkStyleAnimation *style_animation,
gint64 for_time_us,
GtkCssComputedValues *values)
GtkCssStyle *values)
{
GtkCssAnimation *animation = GTK_CSS_ANIMATION (style_animation);
double iteration, progress;
@ -128,8 +128,8 @@ gtk_css_animation_set_values (GtkStyleAnimation *style_animation,
value = _gtk_css_keyframes_get_value (animation->keyframes,
i,
progress,
_gtk_css_computed_values_get_intrinsic_value (values, property_id));
_gtk_css_computed_values_set_animated_value (values, property_id, value);
gtk_css_style_get_intrinsic_value (values, property_id));
gtk_css_style_set_animated_value (values, property_id, value);
_gtk_css_value_unref (value);
}
}

View File

@ -47,8 +47,8 @@ gtk_css_value_array_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
GtkCssValue *result;

View File

@ -45,8 +45,8 @@ gtk_css_value_bg_size_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
GtkCssValue *x, *y;

View File

@ -46,8 +46,8 @@ gtk_css_value_border_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
GtkCssValue *computed;

View File

@ -101,8 +101,8 @@ static GtkCssValue *
gtk_css_value_color_get_fallback (guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values)
GtkCssStyle *values,
GtkCssStyle *parent_values)
{
static const GdkRGBA transparent = { 0, 0, 0, 0 };
@ -303,8 +303,8 @@ gtk_css_value_color_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
GtkCssValue *resolved, *current;
@ -318,7 +318,7 @@ gtk_css_value_color_compute (GtkCssValue *value,
{
if (parent_values)
{
current = _gtk_css_computed_values_get_value (parent_values, GTK_CSS_PROPERTY_COLOR);
current = gtk_css_style_get_value (parent_values, GTK_CSS_PROPERTY_COLOR);
current_deps = GTK_CSS_EQUALS_PARENT;
}
else
@ -329,7 +329,7 @@ gtk_css_value_color_compute (GtkCssValue *value,
}
else
{
current = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_COLOR);
current = gtk_css_style_get_value (values, GTK_CSS_PROPERTY_COLOR);
current_deps = GTK_CSS_DEPENDS_ON_COLOR;
}

View File

@ -1,657 +0,0 @@
/*
* Copyright © 2012 Red Hat Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#include "config.h"
#include "gtkprivate.h"
#include "gtkcsscomputedvaluesprivate.h"
#include "gtkcssanimationprivate.h"
#include "gtkcssarrayvalueprivate.h"
#include "gtkcssenumvalueprivate.h"
#include "gtkcssinheritvalueprivate.h"
#include "gtkcssinitialvalueprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkcsssectionprivate.h"
#include "gtkcssshorthandpropertyprivate.h"
#include "gtkcssstringvalueprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkcsstransitionprivate.h"
#include "gtkstyleanimationprivate.h"
#include "gtkstylepropertyprivate.h"
#include "gtkstyleproviderprivate.h"
G_DEFINE_TYPE (GtkCssComputedValues, _gtk_css_computed_values, G_TYPE_OBJECT)
static void
gtk_css_computed_values_dispose (GObject *object)
{
GtkCssComputedValues *values = GTK_CSS_COMPUTED_VALUES (object);
if (values->values)
{
g_ptr_array_unref (values->values);
values->values = NULL;
}
if (values->sections)
{
g_ptr_array_unref (values->sections);
values->sections = NULL;
}
if (values->animated_values)
{
g_ptr_array_unref (values->animated_values);
values->animated_values = NULL;
}
g_slist_free_full (values->animations, g_object_unref);
values->animations = NULL;
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 *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 *
_gtk_css_computed_values_new (void)
{
return g_object_new (GTK_TYPE_CSS_COMPUTED_VALUES, NULL);
}
static void
maybe_unref_section (gpointer section)
{
if (section)
gtk_css_section_unref (section);
}
void
_gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *parent_values,
guint id,
GtkCssValue *specified,
GtkCssSection *section)
{
GtkCssDependencies dependencies;
GtkCssValue *value;
gtk_internal_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
gtk_internal_return_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider));
gtk_internal_return_if_fail (parent_values == NULL || GTK_IS_CSS_COMPUTED_VALUES (parent_values));
/* http://www.w3.org/TR/css3-cascade/#cascade
* Then, for every element, the value for each property can be found
* by following this pseudo-algorithm:
* 1) Identify all declarations that apply to the element
*/
if (specified == NULL)
{
GtkCssStyleProperty *prop = _gtk_css_style_property_lookup_by_id (id);
if (_gtk_css_style_property_is_inherit (prop))
specified = _gtk_css_inherit_value_new ();
else
specified = _gtk_css_initial_value_new ();
}
else
_gtk_css_value_ref (specified);
value = _gtk_css_value_compute (specified, id, provider, scale, values, parent_values, &dependencies);
if (values->values == NULL)
values->values = g_ptr_array_new_full (_gtk_css_style_property_get_n_properties (),
(GDestroyNotify)_gtk_css_value_unref);
if (id >= values->values->len)
g_ptr_array_set_size (values->values, id + 1);
if (g_ptr_array_index (values->values, id))
_gtk_css_value_unref (g_ptr_array_index (values->values, id));
g_ptr_array_index (values->values, id) = _gtk_css_value_ref (value);
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 (values->sections && values->sections->len > id && g_ptr_array_index (values->sections, id))
{
gtk_css_section_unref (g_ptr_array_index (values->sections, id));
g_ptr_array_index (values->sections, id) = NULL;
}
if (section)
{
if (values->sections == NULL)
values->sections = g_ptr_array_new_with_free_func (maybe_unref_section);
if (values->sections->len <= id)
g_ptr_array_set_size (values->sections, id + 1);
g_ptr_array_index (values->sections, id) = gtk_css_section_ref (section);
}
_gtk_css_value_unref (value);
_gtk_css_value_unref (specified);
}
void
_gtk_css_computed_values_set_animated_value (GtkCssComputedValues *values,
guint id,
GtkCssValue *value)
{
gtk_internal_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
gtk_internal_return_if_fail (value != NULL);
if (values->animated_values == NULL)
values->animated_values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref);
if (id >= values->animated_values->len)
g_ptr_array_set_size (values->animated_values, id + 1);
if (g_ptr_array_index (values->animated_values, id))
_gtk_css_value_unref (g_ptr_array_index (values->animated_values, id));
g_ptr_array_index (values->animated_values, id) = _gtk_css_value_ref (value);
}
GtkCssValue *
_gtk_css_computed_values_get_value (GtkCssComputedValues *values,
guint id)
{
gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
if (values->animated_values &&
id < values->animated_values->len &&
g_ptr_array_index (values->animated_values, id))
return g_ptr_array_index (values->animated_values, id);
return _gtk_css_computed_values_get_intrinsic_value (values, id);
}
GtkCssValue *
_gtk_css_computed_values_get_intrinsic_value (GtkCssComputedValues *values,
guint id)
{
gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
if (values->values == NULL ||
id >= values->values->len)
return NULL;
return g_ptr_array_index (values->values, id);
}
GtkCssSection *
_gtk_css_computed_values_get_section (GtkCssComputedValues *values,
guint id)
{
gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
if (values->sections == NULL ||
id >= values->sections->len)
return NULL;
return g_ptr_array_index (values->sections, id);
}
GtkBitmask *
_gtk_css_computed_values_get_difference (GtkCssComputedValues *values,
GtkCssComputedValues *other)
{
GtkBitmask *result;
guint i, len;
len = MIN (values->values->len, other->values->len);
result = _gtk_bitmask_new ();
if (values->values->len != other->values->len)
result = _gtk_bitmask_invert_range (result, len, MAX (values->values->len, other->values->len));
for (i = 0; i < len; i++)
{
if (!_gtk_css_value_equal (g_ptr_array_index (values->values, i),
g_ptr_array_index (other->values, i)))
result = _gtk_bitmask_set (result, i, TRUE);
}
return result;
}
/* TRANSITIONS */
typedef struct _TransitionInfo TransitionInfo;
struct _TransitionInfo {
guint index; /* index into value arrays */
gboolean pending; /* TRUE if we still need to handle it */
};
static void
transition_info_add (TransitionInfo infos[GTK_CSS_PROPERTY_N_PROPERTIES],
GtkStyleProperty *property,
guint index)
{
if (property == NULL)
{
guint i;
for (i = 0; i < _gtk_css_style_property_get_n_properties (); i++)
{
GtkCssStyleProperty *prop = _gtk_css_style_property_lookup_by_id (i);
transition_info_add (infos, GTK_STYLE_PROPERTY (prop), index);
}
}
else if (GTK_IS_CSS_SHORTHAND_PROPERTY (property))
{
GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property);
guint i;
for (i = 0; i < _gtk_css_shorthand_property_get_n_subproperties (shorthand); i++)
{
GtkCssStyleProperty *prop = _gtk_css_shorthand_property_get_subproperty (shorthand, i);
transition_info_add (infos, GTK_STYLE_PROPERTY (prop), index);
}
}
else if (GTK_IS_CSS_STYLE_PROPERTY (property))
{
guint id;
if (!_gtk_css_style_property_is_animated (GTK_CSS_STYLE_PROPERTY (property)))
return;
id = _gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (property));
g_assert (id < GTK_CSS_PROPERTY_N_PROPERTIES);
infos[id].index = index;
infos[id].pending = TRUE;
}
else
{
g_assert_not_reached ();
}
}
static void
transition_infos_set (TransitionInfo infos[GTK_CSS_PROPERTY_N_PROPERTIES],
GtkCssValue *transitions)
{
guint i;
for (i = 0; i < _gtk_css_array_value_get_n_values (transitions); i++)
{
GtkStyleProperty *property;
GtkCssValue *prop_value;
prop_value = _gtk_css_array_value_get_nth (transitions, i);
if (g_ascii_strcasecmp (_gtk_css_ident_value_get (prop_value), "all") == 0)
property = NULL;
else
{
property = _gtk_style_property_lookup (_gtk_css_ident_value_get (prop_value));
if (property == NULL)
continue;
}
transition_info_add (infos, property, i);
}
}
static GtkStyleAnimation *
gtk_css_computed_values_find_transition (GtkCssComputedValues *values,
guint property_id)
{
GSList *list;
for (list = values->animations; list; list = list->next)
{
if (!GTK_IS_CSS_TRANSITION (list->data))
continue;
if (_gtk_css_transition_get_property (list->data) == property_id)
return list->data;
}
return NULL;
}
static void
gtk_css_computed_values_create_css_transitions (GtkCssComputedValues *values,
gint64 timestamp,
GtkCssComputedValues *source)
{
TransitionInfo transitions[GTK_CSS_PROPERTY_N_PROPERTIES] = { { 0, } };
GtkCssValue *durations, *delays, *timing_functions;
guint i;
transition_infos_set (transitions, _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_TRANSITION_PROPERTY));
durations = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_TRANSITION_DURATION);
delays = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_TRANSITION_DELAY);
timing_functions = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION);
for (i = 0; i < GTK_CSS_PROPERTY_N_PROPERTIES; i++)
{
GtkStyleAnimation *animation;
GtkCssValue *start, *end;
double duration, delay;
if (!transitions[i].pending)
continue;
duration = _gtk_css_number_value_get (_gtk_css_array_value_get_nth (durations, transitions[i].index), 100);
delay = _gtk_css_number_value_get (_gtk_css_array_value_get_nth (delays, transitions[i].index), 100);
if (duration + delay == 0.0)
continue;
start = _gtk_css_computed_values_get_intrinsic_value (source, i);
end = _gtk_css_computed_values_get_intrinsic_value (values, i);
if (_gtk_css_value_equal (start, end))
{
animation = gtk_css_computed_values_find_transition (GTK_CSS_COMPUTED_VALUES (source), i);
if (animation)
values->animations = g_slist_prepend (values->animations, g_object_ref (animation));
}
else
{
animation = _gtk_css_transition_new (i,
_gtk_css_computed_values_get_value (source, i),
_gtk_css_array_value_get_nth (timing_functions, i),
timestamp + delay * G_USEC_PER_SEC,
timestamp + (delay + duration) * G_USEC_PER_SEC);
values->animations = g_slist_prepend (values->animations, animation);
}
}
}
static GtkStyleAnimation *
gtk_css_computed_values_find_animation (GtkCssComputedValues *values,
const char *name)
{
GSList *list;
for (list = values->animations; list; list = list->next)
{
if (!GTK_IS_CSS_ANIMATION (list->data))
continue;
if (g_str_equal (_gtk_css_animation_get_name (list->data), name))
return list->data;
}
return NULL;
}
static void
gtk_css_computed_values_create_css_animations (GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
gint64 timestamp,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *source)
{
GtkCssValue *durations, *delays, *timing_functions, *animations;
GtkCssValue *iteration_counts, *directions, *play_states, *fill_modes;
guint i;
animations = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_NAME);
durations = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_DURATION);
delays = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_DELAY);
timing_functions = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_TIMING_FUNCTION);
iteration_counts = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_ITERATION_COUNT);
directions = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_DIRECTION);
play_states = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_PLAY_STATE);
fill_modes = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_FILL_MODE);
for (i = 0; i < _gtk_css_array_value_get_n_values (animations); i++)
{
GtkStyleAnimation *animation;
GtkCssKeyframes *keyframes;
const char *name;
name = _gtk_css_ident_value_get (_gtk_css_array_value_get_nth (animations, i));
if (g_ascii_strcasecmp (name, "none") == 0)
continue;
animation = gtk_css_computed_values_find_animation (values, name);
if (animation)
continue;
if (source)
animation = gtk_css_computed_values_find_animation (source, name);
if (animation)
{
animation = _gtk_css_animation_copy (GTK_CSS_ANIMATION (animation),
timestamp,
_gtk_css_play_state_value_get (_gtk_css_array_value_get_nth (play_states, i)));
}
else
{
keyframes = _gtk_style_provider_private_get_keyframes (provider, name);
if (keyframes == NULL)
continue;
keyframes = _gtk_css_keyframes_compute (keyframes, provider, scale, values, parent_values);
animation = _gtk_css_animation_new (name,
keyframes,
timestamp,
_gtk_css_number_value_get (_gtk_css_array_value_get_nth (delays, i), 100) * G_USEC_PER_SEC,
_gtk_css_number_value_get (_gtk_css_array_value_get_nth (durations, i), 100) * G_USEC_PER_SEC,
_gtk_css_array_value_get_nth (timing_functions, i),
_gtk_css_direction_value_get (_gtk_css_array_value_get_nth (directions, i)),
_gtk_css_play_state_value_get (_gtk_css_array_value_get_nth (play_states, i)),
_gtk_css_fill_mode_value_get (_gtk_css_array_value_get_nth (fill_modes, i)),
_gtk_css_number_value_get (_gtk_css_array_value_get_nth (iteration_counts, i), 100));
_gtk_css_keyframes_unref (keyframes);
}
values->animations = g_slist_prepend (values->animations, animation);
}
}
/* PUBLIC API */
void
_gtk_css_computed_values_create_animations (GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
gint64 timestamp,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *source)
{
if (source != NULL)
gtk_css_computed_values_create_css_transitions (values, timestamp, source);
gtk_css_computed_values_create_css_animations (values, parent_values, timestamp, provider, scale, source);
}
GtkBitmask *
_gtk_css_computed_values_advance (GtkCssComputedValues *values,
gint64 timestamp)
{
GtkBitmask *changed;
GPtrArray *old_computed_values;
GSList *list;
guint i;
gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
gtk_internal_return_val_if_fail (timestamp >= values->current_time, NULL);
values->current_time = timestamp;
old_computed_values = values->animated_values;
values->animated_values = NULL;
list = values->animations;
while (list)
{
GtkStyleAnimation *animation = list->data;
list = list->next;
_gtk_style_animation_set_values (animation,
timestamp,
GTK_CSS_COMPUTED_VALUES (values));
if (_gtk_style_animation_is_finished (animation, timestamp))
{
values->animations = g_slist_remove (values->animations, animation);
g_object_unref (animation);
}
}
/* figure out changes */
changed = _gtk_bitmask_new ();
for (i = 0; i < GTK_CSS_PROPERTY_N_PROPERTIES; i++)
{
GtkCssValue *old_animated, *new_animated;
old_animated = old_computed_values && i < old_computed_values->len ? g_ptr_array_index (old_computed_values, i) : NULL;
new_animated = values->animated_values && i < values->animated_values->len ? g_ptr_array_index (values->animated_values, i) : NULL;
if (!_gtk_css_value_equal0 (old_animated, new_animated))
changed = _gtk_bitmask_set (changed, i, TRUE);
}
if (old_computed_values)
g_ptr_array_unref (old_computed_values);
return changed;
}
gboolean
_gtk_css_computed_values_is_static (GtkCssComputedValues *values)
{
GSList *list;
gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), TRUE);
for (list = values->animations; list; list = list->next)
{
if (!_gtk_style_animation_is_static (list->data, values->current_time))
return FALSE;
}
return TRUE;
}
void
_gtk_css_computed_values_cancel_animations (GtkCssComputedValues *values)
{
gtk_internal_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
if (values->animated_values)
{
g_ptr_array_unref (values->animated_values);
values->animated_values = NULL;
}
g_slist_free_full (values->animations, g_object_unref);
values->animations = NULL;
}
GtkBitmask *
_gtk_css_computed_values_compute_dependencies (GtkCssComputedValues *values,
const GtkBitmask *parent_changes)
{
GtkBitmask *changes;
gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), _gtk_bitmask_new ());
changes = _gtk_bitmask_copy (parent_changes);
changes = _gtk_bitmask_intersect (changes, values->depends_on_parent);
if (_gtk_bitmask_get (changes, GTK_CSS_PROPERTY_COLOR))
changes = _gtk_bitmask_union (changes, values->depends_on_color);
if (_gtk_bitmask_get (changes, GTK_CSS_PROPERTY_FONT_SIZE))
changes = _gtk_bitmask_union (changes, values->depends_on_font_size);
return changes;
}
void
gtk_css_computed_values_print (GtkCssComputedValues *values,
GString *string)
{
guint i;
g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
g_return_if_fail (string != NULL);
for (i = 0; i < _gtk_css_style_property_get_n_properties (); i++)
{
GtkCssSection *section = _gtk_css_computed_values_get_section (values, i);
g_string_append (string, _gtk_style_property_get_name (GTK_STYLE_PROPERTY (_gtk_css_style_property_lookup_by_id (i))));
g_string_append (string, ": ");
_gtk_css_value_print (_gtk_css_computed_values_get_value (values, i), string);
g_string_append (string, ";");
if (section)
{
g_string_append (string, " /* ");
_gtk_css_section_print (section, string);
g_string_append (string, " */");
}
g_string_append (string, "\n");
}
}
char *
gtk_css_computed_values_to_string (GtkCssComputedValues *values)
{
GString *string;
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
string = g_string_new ("");
gtk_css_computed_values_print (values, string);
return g_string_free (string, FALSE);
}

View File

@ -1,106 +0,0 @@
/*
* Copyright © 2012 Red Hat Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#ifndef __GTK_CSS_COMPUTED_VALUES_PRIVATE_H__
#define __GTK_CSS_COMPUTED_VALUES_PRIVATE_H__
#include <glib-object.h>
#include "gtk/gtkbitmaskprivate.h"
#include "gtk/gtkcsssection.h"
#include "gtk/gtkcssvalueprivate.h"
G_BEGIN_DECLS
#define GTK_TYPE_CSS_COMPUTED_VALUES (_gtk_css_computed_values_get_type ())
#define GTK_CSS_COMPUTED_VALUES(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_CSS_COMPUTED_VALUES, GtkCssComputedValues))
#define GTK_CSS_COMPUTED_VALUES_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_CSS_COMPUTED_VALUES, GtkCssComputedValuesClass))
#define GTK_IS_CSS_COMPUTED_VALUES(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_CSS_COMPUTED_VALUES))
#define GTK_IS_CSS_COMPUTED_VALUES_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_CSS_COMPUTED_VALUES))
#define GTK_CSS_COMPUTED_VALUES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CSS_COMPUTED_VALUES, GtkCssComputedValuesClass))
/* typedef struct _GtkCssComputedValues GtkCssComputedValues; */
typedef struct _GtkCssComputedValuesClass GtkCssComputedValuesClass;
struct _GtkCssComputedValues
{
GObject parent;
GPtrArray *values; /* the unanimated (aka intrinsic) values */
GPtrArray *sections; /* sections the values are defined in */
GPtrArray *animated_values; /* NULL or array of animated values/NULL if not animated */
gint64 current_time; /* the current time in our world */
GSList *animations; /* the running animations, least important one first */
GtkBitmask *depends_on_parent; /* for intrinsic values */
GtkBitmask *equals_parent; /* dito */
GtkBitmask *depends_on_color; /* dito */
GtkBitmask *depends_on_font_size; /* dito */
};
struct _GtkCssComputedValuesClass
{
GObjectClass parent_class;
};
GType _gtk_css_computed_values_get_type (void) G_GNUC_CONST;
GtkCssComputedValues * _gtk_css_computed_values_new (void);
void _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *parent_values,
guint id,
GtkCssValue *specified,
GtkCssSection *section);
void _gtk_css_computed_values_set_animated_value (GtkCssComputedValues *values,
guint id,
GtkCssValue *value);
GtkCssValue * _gtk_css_computed_values_get_value (GtkCssComputedValues *values,
guint id);
GtkCssSection * _gtk_css_computed_values_get_section (GtkCssComputedValues *values,
guint id);
GtkCssValue * _gtk_css_computed_values_get_intrinsic_value (GtkCssComputedValues *values,
guint id);
GtkBitmask * _gtk_css_computed_values_get_difference (GtkCssComputedValues *values,
GtkCssComputedValues *other);
GtkBitmask * _gtk_css_computed_values_compute_dependencies (GtkCssComputedValues *values,
const GtkBitmask *parent_changes);
void _gtk_css_computed_values_create_animations (GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
gint64 timestamp,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *source);
GtkBitmask * _gtk_css_computed_values_advance (GtkCssComputedValues *values,
gint64 timestamp);
void _gtk_css_computed_values_cancel_animations (GtkCssComputedValues *values);
gboolean _gtk_css_computed_values_is_static (GtkCssComputedValues *values);
char * gtk_css_computed_values_to_string (GtkCssComputedValues *values);
void gtk_css_computed_values_print (GtkCssComputedValues *values,
GString *string);
G_END_DECLS
#endif /* __GTK_CSS_COMPUTED_VALUES_PRIVATE_H__ */

View File

@ -41,8 +41,8 @@ gtk_css_value_corner_compute (GtkCssValue *corner,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
GtkCssValue *x, *y;

View File

@ -54,8 +54,8 @@ gtk_css_value_ease_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
return _gtk_css_value_ref (value);

View File

@ -40,8 +40,8 @@ gtk_css_value_engine_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
return _gtk_css_value_ref (value);

View File

@ -19,7 +19,7 @@
#include "gtkcssenumvalueprivate.h"
#include "gtkcsscomputedvaluesprivate.h"
#include "gtkcssstyleprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkstyleproviderprivate.h"
@ -42,8 +42,8 @@ gtk_css_value_enum_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
return _gtk_css_value_ref (value);
@ -166,8 +166,8 @@ gtk_css_value_font_size_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
double font_size;
@ -201,7 +201,7 @@ gtk_css_value_font_size_compute (GtkCssValue *value,
case GTK_CSS_FONT_SIZE_SMALLER:
*dependencies = GTK_CSS_DEPENDS_ON_PARENT;
if (parent_values)
font_size = _gtk_css_number_value_get (_gtk_css_computed_values_get_value (parent_values, GTK_CSS_PROPERTY_FONT_SIZE), 100);
font_size = _gtk_css_number_value_get (gtk_css_style_get_value (parent_values, GTK_CSS_PROPERTY_FONT_SIZE), 100);
else
font_size = _gtk_css_font_size_get_default (provider);
/* XXX: This is what WebKit does... */
@ -210,7 +210,7 @@ gtk_css_value_font_size_compute (GtkCssValue *value,
case GTK_CSS_FONT_SIZE_LARGER:
*dependencies = GTK_CSS_DEPENDS_ON_PARENT;
if (parent_values)
font_size = _gtk_css_number_value_get (_gtk_css_computed_values_get_value (parent_values, GTK_CSS_PROPERTY_FONT_SIZE), 100);
font_size = _gtk_css_number_value_get (gtk_css_style_get_value (parent_values, GTK_CSS_PROPERTY_FONT_SIZE), 100);
else
font_size = _gtk_css_font_size_get_default (provider);
/* XXX: This is what WebKit does... */

View File

@ -21,7 +21,7 @@
#include "gtkcssimageprivate.h"
#include "gtkcsscomputedvaluesprivate.h"
#include "gtkcssstyleprivate.h"
/* for the types only */
#include "gtk/gtkcssimagecrossfadeprivate.h"
@ -65,8 +65,8 @@ gtk_css_image_real_compute (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
return g_object_ref (image);
@ -150,16 +150,16 @@ _gtk_css_image_compute (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
GtkCssDependencies unused;
GtkCssImageClass *klass;
g_return_val_if_fail (GTK_IS_CSS_IMAGE (image), NULL);
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
g_return_val_if_fail (parent_values == NULL || GTK_IS_CSS_COMPUTED_VALUES (parent_values), NULL);
g_return_val_if_fail (GTK_IS_CSS_STYLE (values), NULL);
g_return_val_if_fail (parent_values == NULL || GTK_IS_CSS_STYLE (parent_values), NULL);
if (dependencies == NULL)
dependencies = &unused;

View File

@ -60,8 +60,8 @@ gtk_css_image_builtin_compute (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
return g_object_ref (image);

View File

@ -35,8 +35,8 @@ gtk_css_image_gradient_compute (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
GtkCssImageGradient *gradient = GTK_CSS_IMAGE_GRADIENT (image);

View File

@ -129,8 +129,8 @@ gtk_css_image_icon_theme_compute (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
GtkCssImageIconTheme *icon_theme = GTK_CSS_IMAGE_ICON_THEME (image);
@ -148,7 +148,7 @@ gtk_css_image_icon_theme_compute (GtkCssImage *image,
copy->name = g_strdup (icon_theme->name);
copy->icon_theme = gtk_icon_theme_get_for_screen (screen);
copy->scale = scale;
copy->color = *_gtk_css_rgba_value_get_rgba (_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_COLOR));
copy->color = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (values, GTK_CSS_PROPERTY_COLOR));
*dependencies = GTK_CSS_DEPENDS_ON_COLOR;

View File

@ -421,8 +421,8 @@ gtk_css_image_linear_compute (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
GtkCssImageLinear *linear = GTK_CSS_IMAGE_LINEAR (image);

View File

@ -59,8 +59,8 @@ struct _GtkCssImageClass
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies);
/* compare two images for equality */
gboolean (* equal) (GtkCssImage *image1,
@ -97,8 +97,8 @@ GtkCssImage * _gtk_css_image_compute (GtkCssImage *
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies);
gboolean _gtk_css_image_equal (GtkCssImage *image1,
GtkCssImage *image2);

View File

@ -95,8 +95,8 @@ gtk_css_image_scaled_compute (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
GtkCssImageScaled *scaled = GTK_CSS_IMAGE_SCALED (image);

View File

@ -124,8 +124,8 @@ gtk_css_image_url_compute (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
GtkCssImageUrl *url = GTK_CSS_IMAGE_URL (image);

View File

@ -38,8 +38,8 @@ gtk_css_value_image_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
GtkCssImage *image, *computed;

View File

@ -38,14 +38,14 @@ gtk_css_value_inherit_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
if (parent_values)
{
*dependencies = GTK_CSS_EQUALS_PARENT;
return _gtk_css_value_ref (_gtk_css_computed_values_get_value (parent_values, property_id));
return _gtk_css_value_ref (gtk_css_style_get_value (parent_values, property_id));
}
else
{

View File

@ -41,8 +41,8 @@ gtk_css_value_initial_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
GtkSettings *settings;

View File

@ -438,16 +438,16 @@ GtkCssKeyframes *
_gtk_css_keyframes_compute (GtkCssKeyframes *keyframes,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values)
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssKeyframes *resolved;
guint k, p;
g_return_val_if_fail (keyframes != NULL, NULL);
g_return_val_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider), NULL);
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
g_return_val_if_fail (parent_values == NULL || GTK_IS_CSS_COMPUTED_VALUES (parent_values), NULL);
g_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
g_return_val_if_fail (parent_style == NULL || GTK_IS_CSS_STYLE (parent_style), NULL);
resolved = gtk_css_keyframes_alloc ();
resolved->n_keyframes = keyframes->n_keyframes;
@ -467,8 +467,8 @@ _gtk_css_keyframes_compute (GtkCssKeyframes *keyframes,
resolved->property_ids[p],
provider,
scale,
values,
parent_values,
style,
parent_style,
NULL);
}
}

View File

@ -39,8 +39,8 @@ void _gtk_css_keyframes_print (GtkCssKeyframes
GtkCssKeyframes * _gtk_css_keyframes_compute (GtkCssKeyframes *keyframes,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values);
GtkCssStyle *style,
GtkCssStyle *parent_style);
guint _gtk_css_keyframes_get_n_properties (GtkCssKeyframes *keyframes);
guint _gtk_css_keyframes_get_property_id (GtkCssKeyframes *keyframes,

View File

@ -94,7 +94,7 @@ _gtk_css_lookup_set (GtkCssLookup *lookup,
* _gtk_css_lookup_resolve:
* @lookup: the lookup
* @context: the context the values are resolved for
* @values: a new #GtkCssComputedValues to be filled with the new properties
* @values: a new #GtkCssStyle to be filled with the new properties
*
* Resolves the current lookup into a styleproperties object. This is done
* by converting from the winning declaration to the computed value.
@ -106,15 +106,15 @@ void
_gtk_css_lookup_resolve (GtkCssLookup *lookup,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values)
GtkCssStyle *values,
GtkCssStyle *parent_values)
{
guint i, n;
g_return_if_fail (lookup != NULL);
g_return_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider));
g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
g_return_if_fail (parent_values == NULL || GTK_IS_CSS_COMPUTED_VALUES (parent_values));
g_return_if_fail (GTK_IS_CSS_STYLE (values));
g_return_if_fail (parent_values == NULL || GTK_IS_CSS_STYLE (parent_values));
n = _gtk_css_style_property_get_n_properties ();
@ -122,13 +122,13 @@ _gtk_css_lookup_resolve (GtkCssLookup *lookup,
{
if (lookup->values[i].value ||
_gtk_bitmask_get (lookup->missing, i))
_gtk_css_computed_values_compute_value (values,
provider,
scale,
parent_values,
i,
lookup->values[i].value,
lookup->values[i].section);
gtk_css_style_compute_value (values,
provider,
scale,
parent_values,
i,
lookup->values[i].value,
lookup->values[i].section);
/* else not a relevant property */
}
}

View File

@ -20,7 +20,7 @@
#include <glib-object.h>
#include "gtk/gtkbitmaskprivate.h"
#include "gtk/gtkcsscomputedvaluesprivate.h"
#include "gtk/gtkcssstyleprivate.h"
#include "gtk/gtkcsssection.h"
@ -51,8 +51,8 @@ void _gtk_css_lookup_set (GtkCssLookup
void _gtk_css_lookup_resolve (GtkCssLookup *lookup,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values);
GtkCssStyle *values,
GtkCssStyle *parent_values);
static inline const GtkBitmask *
_gtk_css_lookup_get_missing (const GtkCssLookup *lookup)

View File

@ -38,21 +38,21 @@ gtk_css_value_number_free (GtkCssValue *value)
static double
get_base_font_size (guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
if (property_id == GTK_CSS_PROPERTY_FONT_SIZE)
{
*dependencies = GTK_CSS_DEPENDS_ON_PARENT;
if (parent_values)
return _gtk_css_number_value_get (_gtk_css_computed_values_get_value (parent_values, GTK_CSS_PROPERTY_FONT_SIZE), 100);
return _gtk_css_number_value_get (gtk_css_style_get_value (parent_values, GTK_CSS_PROPERTY_FONT_SIZE), 100);
else
return _gtk_css_font_size_get_default (provider);
}
*dependencies = GTK_CSS_DEPENDS_ON_FONT_SIZE;
return _gtk_css_number_value_get (_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_FONT_SIZE), 100);
return _gtk_css_number_value_get (gtk_css_style_get_value (values, GTK_CSS_PROPERTY_FONT_SIZE), 100);
}
static GtkCssValue *
@ -60,8 +60,8 @@ gtk_css_value_number_compute (GtkCssValue *number,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
switch (number->unit)

View File

@ -41,8 +41,8 @@ gtk_css_value_position_compute (GtkCssValue *position,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
GtkCssValue *x, *y;

View File

@ -38,8 +38,8 @@ gtk_css_value_repeat_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
return _gtk_css_value_ref (value);

View File

@ -38,8 +38,8 @@ gtk_css_value_rgba_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
return _gtk_css_value_ref (value);

View File

@ -55,8 +55,8 @@ gtk_css_value_shadows_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
GtkCssValue *result;

View File

@ -67,8 +67,8 @@ gtk_css_value_shadow_compute (GtkCssValue *shadow,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
GtkCssValue *hoffset, *voffset, *radius, *spread, *color;

View File

@ -38,8 +38,8 @@ gtk_css_value_string_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
return _gtk_css_value_ref (value);

657
gtk/gtkcssstyle.c Normal file
View File

@ -0,0 +1,657 @@
/*
* Copyright © 2012 Red Hat Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#include "config.h"
#include "gtkprivate.h"
#include "gtkcssstyleprivate.h"
#include "gtkcssanimationprivate.h"
#include "gtkcssarrayvalueprivate.h"
#include "gtkcssenumvalueprivate.h"
#include "gtkcssinheritvalueprivate.h"
#include "gtkcssinitialvalueprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkcsssectionprivate.h"
#include "gtkcssshorthandpropertyprivate.h"
#include "gtkcssstringvalueprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkcsstransitionprivate.h"
#include "gtkstyleanimationprivate.h"
#include "gtkstylepropertyprivate.h"
#include "gtkstyleproviderprivate.h"
G_DEFINE_TYPE (GtkCssStyle, gtk_css_style, G_TYPE_OBJECT)
static void
gtk_css_style_dispose (GObject *object)
{
GtkCssStyle *style = GTK_CSS_STYLE (object);
if (style->values)
{
g_ptr_array_unref (style->values);
style->values = NULL;
}
if (style->sections)
{
g_ptr_array_unref (style->sections);
style->sections = NULL;
}
if (style->animated_values)
{
g_ptr_array_unref (style->animated_values);
style->animated_values = NULL;
}
g_slist_free_full (style->animations, g_object_unref);
style->animations = NULL;
G_OBJECT_CLASS (gtk_css_style_parent_class)->dispose (object);
}
static void
gtk_css_style_finalize (GObject *object)
{
GtkCssStyle *style = GTK_CSS_STYLE (object);
_gtk_bitmask_free (style->depends_on_parent);
_gtk_bitmask_free (style->equals_parent);
_gtk_bitmask_free (style->depends_on_color);
_gtk_bitmask_free (style->depends_on_font_size);
G_OBJECT_CLASS (gtk_css_style_parent_class)->finalize (object);
}
static void
gtk_css_style_class_init (GtkCssStyleClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = gtk_css_style_dispose;
object_class->finalize = gtk_css_style_finalize;
}
static void
gtk_css_style_init (GtkCssStyle *style)
{
style->depends_on_parent = _gtk_bitmask_new ();
style->equals_parent = _gtk_bitmask_new ();
style->depends_on_color = _gtk_bitmask_new ();
style->depends_on_font_size = _gtk_bitmask_new ();
}
GtkCssStyle *
gtk_css_style_new (void)
{
return g_object_new (GTK_TYPE_CSS_STYLE, NULL);
}
static void
maybe_unref_section (gpointer section)
{
if (section)
gtk_css_section_unref (section);
}
void
gtk_css_style_compute_value (GtkCssStyle *style,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssStyle *parent_style,
guint id,
GtkCssValue *specified,
GtkCssSection *section)
{
GtkCssDependencies dependencies;
GtkCssValue *value;
gtk_internal_return_if_fail (GTK_IS_CSS_STYLE (style));
gtk_internal_return_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider));
gtk_internal_return_if_fail (parent_style == NULL || GTK_IS_CSS_STYLE (parent_style));
/* http://www.w3.org/TR/css3-cascade/#cascade
* Then, for every element, the value for each property can be found
* by following this pseudo-algorithm:
* 1) Identify all declarations that apply to the element
*/
if (specified == NULL)
{
GtkCssStyleProperty *prop = _gtk_css_style_property_lookup_by_id (id);
if (_gtk_css_style_property_is_inherit (prop))
specified = _gtk_css_inherit_value_new ();
else
specified = _gtk_css_initial_value_new ();
}
else
_gtk_css_value_ref (specified);
value = _gtk_css_value_compute (specified, id, provider, scale, style, parent_style, &dependencies);
if (style->values == NULL)
style->values = g_ptr_array_new_full (_gtk_css_style_property_get_n_properties (),
(GDestroyNotify)_gtk_css_value_unref);
if (id >= style->values->len)
g_ptr_array_set_size (style->values, id + 1);
if (g_ptr_array_index (style->values, id))
_gtk_css_value_unref (g_ptr_array_index (style->values, id));
g_ptr_array_index (style->values, id) = _gtk_css_value_ref (value);
if (dependencies & (GTK_CSS_DEPENDS_ON_PARENT | GTK_CSS_EQUALS_PARENT))
style->depends_on_parent = _gtk_bitmask_set (style->depends_on_parent, id, TRUE);
if (dependencies & (GTK_CSS_EQUALS_PARENT))
style->equals_parent = _gtk_bitmask_set (style->equals_parent, id, TRUE);
if (dependencies & (GTK_CSS_DEPENDS_ON_COLOR))
style->depends_on_color = _gtk_bitmask_set (style->depends_on_color, id, TRUE);
if (dependencies & (GTK_CSS_DEPENDS_ON_FONT_SIZE))
style->depends_on_font_size = _gtk_bitmask_set (style->depends_on_font_size, id, TRUE);
if (style->sections && style->sections->len > id && g_ptr_array_index (style->sections, id))
{
gtk_css_section_unref (g_ptr_array_index (style->sections, id));
g_ptr_array_index (style->sections, id) = NULL;
}
if (section)
{
if (style->sections == NULL)
style->sections = g_ptr_array_new_with_free_func (maybe_unref_section);
if (style->sections->len <= id)
g_ptr_array_set_size (style->sections, id + 1);
g_ptr_array_index (style->sections, id) = gtk_css_section_ref (section);
}
_gtk_css_value_unref (value);
_gtk_css_value_unref (specified);
}
void
gtk_css_style_set_animated_value (GtkCssStyle *style,
guint id,
GtkCssValue *value)
{
gtk_internal_return_if_fail (GTK_IS_CSS_STYLE (style));
gtk_internal_return_if_fail (value != NULL);
if (style->animated_values == NULL)
style->animated_values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref);
if (id >= style->animated_values->len)
g_ptr_array_set_size (style->animated_values, id + 1);
if (g_ptr_array_index (style->animated_values, id))
_gtk_css_value_unref (g_ptr_array_index (style->animated_values, id));
g_ptr_array_index (style->animated_values, id) = _gtk_css_value_ref (value);
}
GtkCssValue *
gtk_css_style_get_value (GtkCssStyle *style,
guint id)
{
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
if (style->animated_values &&
id < style->animated_values->len &&
g_ptr_array_index (style->animated_values, id))
return g_ptr_array_index (style->animated_values, id);
return gtk_css_style_get_intrinsic_value (style, id);
}
GtkCssValue *
gtk_css_style_get_intrinsic_value (GtkCssStyle *style,
guint id)
{
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
if (style->values == NULL ||
id >= style->values->len)
return NULL;
return g_ptr_array_index (style->values, id);
}
GtkCssSection *
gtk_css_style_get_section (GtkCssStyle *style,
guint id)
{
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
if (style->sections == NULL ||
id >= style->sections->len)
return NULL;
return g_ptr_array_index (style->sections, id);
}
GtkBitmask *
gtk_css_style_get_difference (GtkCssStyle *style,
GtkCssStyle *other)
{
GtkBitmask *result;
guint i, len;
len = MIN (style->values->len, other->values->len);
result = _gtk_bitmask_new ();
if (style->values->len != other->values->len)
result = _gtk_bitmask_invert_range (result, len, MAX (style->values->len, other->values->len));
for (i = 0; i < len; i++)
{
if (!_gtk_css_value_equal (g_ptr_array_index (style->values, i),
g_ptr_array_index (other->values, i)))
result = _gtk_bitmask_set (result, i, TRUE);
}
return result;
}
/* TRANSITIONS */
typedef struct _TransitionInfo TransitionInfo;
struct _TransitionInfo {
guint index; /* index into value arrays */
gboolean pending; /* TRUE if we still need to handle it */
};
static void
transition_info_add (TransitionInfo infos[GTK_CSS_PROPERTY_N_PROPERTIES],
GtkStyleProperty *property,
guint index)
{
if (property == NULL)
{
guint i;
for (i = 0; i < _gtk_css_style_property_get_n_properties (); i++)
{
GtkCssStyleProperty *prop = _gtk_css_style_property_lookup_by_id (i);
transition_info_add (infos, GTK_STYLE_PROPERTY (prop), index);
}
}
else if (GTK_IS_CSS_SHORTHAND_PROPERTY (property))
{
GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property);
guint i;
for (i = 0; i < _gtk_css_shorthand_property_get_n_subproperties (shorthand); i++)
{
GtkCssStyleProperty *prop = _gtk_css_shorthand_property_get_subproperty (shorthand, i);
transition_info_add (infos, GTK_STYLE_PROPERTY (prop), index);
}
}
else if (GTK_IS_CSS_STYLE_PROPERTY (property))
{
guint id;
if (!_gtk_css_style_property_is_animated (GTK_CSS_STYLE_PROPERTY (property)))
return;
id = _gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (property));
g_assert (id < GTK_CSS_PROPERTY_N_PROPERTIES);
infos[id].index = index;
infos[id].pending = TRUE;
}
else
{
g_assert_not_reached ();
}
}
static void
transition_infos_set (TransitionInfo infos[GTK_CSS_PROPERTY_N_PROPERTIES],
GtkCssValue *transitions)
{
guint i;
for (i = 0; i < _gtk_css_array_value_get_n_values (transitions); i++)
{
GtkStyleProperty *property;
GtkCssValue *prop_value;
prop_value = _gtk_css_array_value_get_nth (transitions, i);
if (g_ascii_strcasecmp (_gtk_css_ident_value_get (prop_value), "all") == 0)
property = NULL;
else
{
property = _gtk_style_property_lookup (_gtk_css_ident_value_get (prop_value));
if (property == NULL)
continue;
}
transition_info_add (infos, property, i);
}
}
static GtkStyleAnimation *
gtk_css_style_find_transition (GtkCssStyle *style,
guint property_id)
{
GSList *list;
for (list = style->animations; list; list = list->next)
{
if (!GTK_IS_CSS_TRANSITION (list->data))
continue;
if (_gtk_css_transition_get_property (list->data) == property_id)
return list->data;
}
return NULL;
}
static void
gtk_css_style_create_css_transitions (GtkCssStyle *style,
gint64 timestamp,
GtkCssStyle *source)
{
TransitionInfo transitions[GTK_CSS_PROPERTY_N_PROPERTIES] = { { 0, } };
GtkCssValue *durations, *delays, *timing_functions;
guint i;
transition_infos_set (transitions, gtk_css_style_get_value (style, GTK_CSS_PROPERTY_TRANSITION_PROPERTY));
durations = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_TRANSITION_DURATION);
delays = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_TRANSITION_DELAY);
timing_functions = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION);
for (i = 0; i < GTK_CSS_PROPERTY_N_PROPERTIES; i++)
{
GtkStyleAnimation *animation;
GtkCssValue *start, *end;
double duration, delay;
if (!transitions[i].pending)
continue;
duration = _gtk_css_number_value_get (_gtk_css_array_value_get_nth (durations, transitions[i].index), 100);
delay = _gtk_css_number_value_get (_gtk_css_array_value_get_nth (delays, transitions[i].index), 100);
if (duration + delay == 0.0)
continue;
start = gtk_css_style_get_intrinsic_value (source, i);
end = gtk_css_style_get_intrinsic_value (style, i);
if (_gtk_css_value_equal (start, end))
{
animation = gtk_css_style_find_transition (GTK_CSS_STYLE (source), i);
if (animation)
style->animations = g_slist_prepend (style->animations, g_object_ref (animation));
}
else
{
animation = _gtk_css_transition_new (i,
gtk_css_style_get_value (source, i),
_gtk_css_array_value_get_nth (timing_functions, i),
timestamp + delay * G_USEC_PER_SEC,
timestamp + (delay + duration) * G_USEC_PER_SEC);
style->animations = g_slist_prepend (style->animations, animation);
}
}
}
static GtkStyleAnimation *
gtk_css_style_find_animation (GtkCssStyle *style,
const char *name)
{
GSList *list;
for (list = style->animations; list; list = list->next)
{
if (!GTK_IS_CSS_ANIMATION (list->data))
continue;
if (g_str_equal (_gtk_css_animation_get_name (list->data), name))
return list->data;
}
return NULL;
}
static void
gtk_css_style_create_css_animations (GtkCssStyle *style,
GtkCssStyle *parent_style,
gint64 timestamp,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssStyle *source)
{
GtkCssValue *durations, *delays, *timing_functions, *animations;
GtkCssValue *iteration_counts, *directions, *play_states, *fill_modes;
guint i;
animations = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ANIMATION_NAME);
durations = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ANIMATION_DURATION);
delays = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ANIMATION_DELAY);
timing_functions = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ANIMATION_TIMING_FUNCTION);
iteration_counts = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ANIMATION_ITERATION_COUNT);
directions = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ANIMATION_DIRECTION);
play_states = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ANIMATION_PLAY_STATE);
fill_modes = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ANIMATION_FILL_MODE);
for (i = 0; i < _gtk_css_array_value_get_n_values (animations); i++)
{
GtkStyleAnimation *animation;
GtkCssKeyframes *keyframes;
const char *name;
name = _gtk_css_ident_value_get (_gtk_css_array_value_get_nth (animations, i));
if (g_ascii_strcasecmp (name, "none") == 0)
continue;
animation = gtk_css_style_find_animation (style, name);
if (animation)
continue;
if (source)
animation = gtk_css_style_find_animation (source, name);
if (animation)
{
animation = _gtk_css_animation_copy (GTK_CSS_ANIMATION (animation),
timestamp,
_gtk_css_play_state_value_get (_gtk_css_array_value_get_nth (play_states, i)));
}
else
{
keyframes = _gtk_style_provider_private_get_keyframes (provider, name);
if (keyframes == NULL)
continue;
keyframes = _gtk_css_keyframes_compute (keyframes, provider, scale, style, parent_style);
animation = _gtk_css_animation_new (name,
keyframes,
timestamp,
_gtk_css_number_value_get (_gtk_css_array_value_get_nth (delays, i), 100) * G_USEC_PER_SEC,
_gtk_css_number_value_get (_gtk_css_array_value_get_nth (durations, i), 100) * G_USEC_PER_SEC,
_gtk_css_array_value_get_nth (timing_functions, i),
_gtk_css_direction_value_get (_gtk_css_array_value_get_nth (directions, i)),
_gtk_css_play_state_value_get (_gtk_css_array_value_get_nth (play_states, i)),
_gtk_css_fill_mode_value_get (_gtk_css_array_value_get_nth (fill_modes, i)),
_gtk_css_number_value_get (_gtk_css_array_value_get_nth (iteration_counts, i), 100));
_gtk_css_keyframes_unref (keyframes);
}
style->animations = g_slist_prepend (style->animations, animation);
}
}
/* PUBLIC API */
void
gtk_css_style_create_animations (GtkCssStyle *style,
GtkCssStyle *parent_style,
gint64 timestamp,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssStyle *source)
{
if (source != NULL)
gtk_css_style_create_css_transitions (style, timestamp, source);
gtk_css_style_create_css_animations (style, parent_style, timestamp, provider, scale, source);
}
GtkBitmask *
gtk_css_style_advance (GtkCssStyle *style,
gint64 timestamp)
{
GtkBitmask *changed;
GPtrArray *old_computed_values;
GSList *list;
guint i;
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
gtk_internal_return_val_if_fail (timestamp >= style->current_time, NULL);
style->current_time = timestamp;
old_computed_values = style->animated_values;
style->animated_values = NULL;
list = style->animations;
while (list)
{
GtkStyleAnimation *animation = list->data;
list = list->next;
_gtk_style_animation_set_values (animation,
timestamp,
GTK_CSS_STYLE (style));
if (_gtk_style_animation_is_finished (animation, timestamp))
{
style->animations = g_slist_remove (style->animations, animation);
g_object_unref (animation);
}
}
/* figure out changes */
changed = _gtk_bitmask_new ();
for (i = 0; i < GTK_CSS_PROPERTY_N_PROPERTIES; i++)
{
GtkCssValue *old_animated, *new_animated;
old_animated = old_computed_values && i < old_computed_values->len ? g_ptr_array_index (old_computed_values, i) : NULL;
new_animated = style->animated_values && i < style->animated_values->len ? g_ptr_array_index (style->animated_values, i) : NULL;
if (!_gtk_css_value_equal0 (old_animated, new_animated))
changed = _gtk_bitmask_set (changed, i, TRUE);
}
if (old_computed_values)
g_ptr_array_unref (old_computed_values);
return changed;
}
gboolean
gtk_css_style_is_static (GtkCssStyle *style)
{
GSList *list;
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (style), TRUE);
for (list = style->animations; list; list = list->next)
{
if (!_gtk_style_animation_is_static (list->data, style->current_time))
return FALSE;
}
return TRUE;
}
void
gtk_css_style_cancel_animations (GtkCssStyle *style)
{
gtk_internal_return_if_fail (GTK_IS_CSS_STYLE (style));
if (style->animated_values)
{
g_ptr_array_unref (style->animated_values);
style->animated_values = NULL;
}
g_slist_free_full (style->animations, g_object_unref);
style->animations = NULL;
}
GtkBitmask *
gtk_css_style_compute_dependencies (GtkCssStyle *style,
const GtkBitmask *parent_changes)
{
GtkBitmask *changes;
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (style), _gtk_bitmask_new ());
changes = _gtk_bitmask_copy (parent_changes);
changes = _gtk_bitmask_intersect (changes, style->depends_on_parent);
if (_gtk_bitmask_get (changes, GTK_CSS_PROPERTY_COLOR))
changes = _gtk_bitmask_union (changes, style->depends_on_color);
if (_gtk_bitmask_get (changes, GTK_CSS_PROPERTY_FONT_SIZE))
changes = _gtk_bitmask_union (changes, style->depends_on_font_size);
return changes;
}
void
gtk_css_style_print (GtkCssStyle *style,
GString *string)
{
guint i;
g_return_if_fail (GTK_IS_CSS_STYLE (style));
g_return_if_fail (string != NULL);
for (i = 0; i < _gtk_css_style_property_get_n_properties (); i++)
{
GtkCssSection *section = gtk_css_style_get_section (style, i);
g_string_append (string, _gtk_style_property_get_name (GTK_STYLE_PROPERTY (_gtk_css_style_property_lookup_by_id (i))));
g_string_append (string, ": ");
_gtk_css_value_print (gtk_css_style_get_value (style, i), string);
g_string_append (string, ";");
if (section)
{
g_string_append (string, " /* ");
_gtk_css_section_print (section, string);
g_string_append (string, " */");
}
g_string_append (string, "\n");
}
}
char *
gtk_css_style_to_string (GtkCssStyle *style)
{
GString *string;
g_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
string = g_string_new ("");
gtk_css_style_print (style, string);
return g_string_free (string, FALSE);
}

View File

@ -56,8 +56,8 @@ typedef gboolean (* GtkStyleParseFunc) (GtkCssParser
typedef void (* GtkStylePrintFunc) (const GValue *value,
GString *string);
typedef GtkCssValue * (* GtkStyleComputeFunc) (GtkStyleProviderPrivate *provider,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssValue *specified,
GtkCssDependencies *dependencies);
@ -183,8 +183,8 @@ rgba_value_print (const GValue *value,
static GtkCssValue *
rgba_value_compute (GtkStyleProviderPrivate *provider,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssValue *specified,
GtkCssDependencies *dependencies)
{
@ -204,7 +204,7 @@ rgba_value_compute (GtkStyleProviderPrivate *provider,
val = _gtk_css_color_value_resolve (_gtk_symbolic_color_get_css_value (symbolic),
provider,
_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_COLOR),
gtk_css_style_get_value (values, GTK_CSS_PROPERTY_COLOR),
GTK_CSS_DEPENDS_ON_COLOR,
dependencies,
NULL);
@ -282,8 +282,8 @@ G_GNUC_END_IGNORE_DEPRECATIONS
static GtkCssValue *
color_value_compute (GtkStyleProviderPrivate *provider,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssValue *specified,
GtkCssDependencies *dependencies)
{
@ -301,7 +301,7 @@ color_value_compute (GtkStyleProviderPrivate *provider,
val = _gtk_css_color_value_resolve (_gtk_symbolic_color_get_css_value (g_value_get_boxed (value)),
provider,
_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_COLOR),
gtk_css_style_get_value (values, GTK_CSS_PROPERTY_COLOR),
GTK_CSS_DEPENDS_ON_COLOR,
dependencies,
NULL);
@ -847,8 +847,8 @@ pattern_value_print (const GValue *value,
static GtkCssValue *
pattern_value_compute (GtkStyleProviderPrivate *provider,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssValue *specified,
GtkCssDependencies *dependencies)
{
@ -1154,8 +1154,8 @@ _gtk_css_style_funcs_print_value (const GValue *value,
**/
GtkCssValue *
_gtk_css_style_funcs_compute_value (GtkStyleProviderPrivate *provider,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GType target_type,
GtkCssValue *specified,
GtkCssDependencies *dependencies)
@ -1163,8 +1163,8 @@ _gtk_css_style_funcs_compute_value (GtkStyleProviderPrivate *provider,
GtkStyleComputeFunc func;
g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
g_return_val_if_fail (parent_values == NULL || GTK_IS_CSS_COMPUTED_VALUES (parent_values), NULL);
g_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
g_return_val_if_fail (parent_style == NULL || GTK_IS_CSS_STYLE (parent_style), NULL);
g_return_val_if_fail (*dependencies == 0, NULL);
gtk_css_style_funcs_init ();
@ -1176,7 +1176,7 @@ _gtk_css_style_funcs_compute_value (GtkStyleProviderPrivate *provider,
GSIZE_TO_POINTER (g_type_fundamental (target_type)));
if (func)
return func (provider, values, parent_values, specified, dependencies);
return func (provider, style, parent_style, specified, dependencies);
else
return _gtk_css_value_ref (specified);
}

View File

@ -29,8 +29,8 @@ gboolean _gtk_css_style_funcs_parse_value (GValue
void _gtk_css_style_funcs_print_value (const GValue *value,
GString *string);
GtkCssValue * _gtk_css_style_funcs_compute_value (GtkStyleProviderPrivate *provider,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GType target_type,
GtkCssValue *specified,
GtkCssDependencies *dependencies);

106
gtk/gtkcssstyleprivate.h Normal file
View File

@ -0,0 +1,106 @@
/*
* Copyright © 2012 Red Hat Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#ifndef __GTK_CSS_STYLE_PRIVATE_H__
#define __GTK_CSS_STYLE_PRIVATE_H__
#include <glib-object.h>
#include "gtk/gtkbitmaskprivate.h"
#include "gtk/gtkcsssection.h"
#include "gtk/gtkcssvalueprivate.h"
G_BEGIN_DECLS
#define GTK_TYPE_CSS_STYLE (gtk_css_style_get_type ())
#define GTK_CSS_STYLE(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_CSS_STYLE, GtkCssStyle))
#define GTK_CSS_STYLE_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_CSS_STYLE, GtkCssStyleClass))
#define GTK_IS_CSS_STYLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_CSS_STYLE))
#define GTK_IS_CSS_STYLE_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_CSS_STYLE))
#define GTK_CSS_STYLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CSS_STYLE, GtkCssStyleClass))
/* typedef struct _GtkCssStyle GtkCssStyle; */
typedef struct _GtkCssStyleClass GtkCssStyleClass;
struct _GtkCssStyle
{
GObject parent;
GPtrArray *values; /* the unanimated (aka intrinsic) values */
GPtrArray *sections; /* sections the values are defined in */
GPtrArray *animated_values; /* NULL or array of animated values/NULL if not animated */
gint64 current_time; /* the current time in our world */
GSList *animations; /* the running animations, least important one first */
GtkBitmask *depends_on_parent; /* for intrinsic values */
GtkBitmask *equals_parent; /* dito */
GtkBitmask *depends_on_color; /* dito */
GtkBitmask *depends_on_font_size; /* dito */
};
struct _GtkCssStyleClass
{
GObjectClass parent_class;
};
GType gtk_css_style_get_type (void) G_GNUC_CONST;
GtkCssStyle * gtk_css_style_new (void);
void gtk_css_style_compute_value (GtkCssStyle *style,
GtkStyleProviderPrivate*provider,
int scale,
GtkCssStyle *parent_style,
guint id,
GtkCssValue *specified,
GtkCssSection *section);
void gtk_css_style_set_animated_value (GtkCssStyle *style,
guint id,
GtkCssValue *value);
GtkCssValue * gtk_css_style_get_value (GtkCssStyle *style,
guint id);
GtkCssSection * gtk_css_style_get_section (GtkCssStyle *style,
guint id);
GtkCssValue * gtk_css_style_get_intrinsic_value (GtkCssStyle *style,
guint id);
GtkBitmask * gtk_css_style_get_difference (GtkCssStyle *style,
GtkCssStyle *other);
GtkBitmask * gtk_css_style_compute_dependencies (GtkCssStyle *style,
const GtkBitmask *parent_changes);
void gtk_css_style_create_animations (GtkCssStyle *style,
GtkCssStyle *parent_style,
gint64 timestamp,
GtkStyleProviderPrivate*provider,
int scale,
GtkCssStyle *source);
GtkBitmask * gtk_css_style_advance (GtkCssStyle *style,
gint64 timestamp);
void gtk_css_style_cancel_animations (GtkCssStyle *style);
gboolean gtk_css_style_is_static (GtkCssStyle *style);
char * gtk_css_style_to_string (GtkCssStyle *style);
void gtk_css_style_print (GtkCssStyle *style,
GString *string);
G_END_DECLS
#endif /* __GTK_CSS_STYLE_PRIVATE_H__ */

View File

@ -232,8 +232,8 @@ gtk_css_transform_compute (GtkCssTransform *dest,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
GtkCssDependencies x_deps, y_deps;
@ -286,8 +286,8 @@ gtk_css_value_transform_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
GtkCssDependencies transform_deps;

View File

@ -26,15 +26,15 @@
G_DEFINE_TYPE (GtkCssTransition, _gtk_css_transition, GTK_TYPE_STYLE_ANIMATION)
static void
gtk_css_transition_set_values (GtkStyleAnimation *animation,
gint64 for_time_us,
GtkCssComputedValues *values)
gtk_css_transition_set_values (GtkStyleAnimation *animation,
gint64 for_time_us,
GtkCssStyle *style)
{
GtkCssTransition *transition = GTK_CSS_TRANSITION (animation);
GtkCssValue *value, *end;
double progress;
end = _gtk_css_computed_values_get_intrinsic_value (values, transition->property);
end = gtk_css_style_get_intrinsic_value (style, transition->property);
if (transition->start_time >= for_time_us)
value = _gtk_css_value_ref (transition->start);
@ -55,7 +55,7 @@ gtk_css_transition_set_values (GtkStyleAnimation *animation,
if (value)
{
_gtk_css_computed_values_set_animated_value (values, transition->property, value);
gtk_css_style_set_animated_value (style, transition->property, value);
_gtk_css_value_unref (value);
}
}

View File

@ -39,8 +39,8 @@ gtk_css_value_typed_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
GtkCssCustomProperty *custom = GTK_CSS_CUSTOM_PROPERTY (_gtk_css_style_property_lookup_by_id (property_id));

View File

@ -24,7 +24,7 @@
G_BEGIN_DECLS
/* forward declaration for GtkCssValue */
typedef struct _GtkCssComputedValues GtkCssComputedValues;
typedef struct _GtkCssStyle GtkCssStyle;
typedef struct _GtkStyleProviderPrivate GtkStyleProviderPrivate; /* dummy typedef */
typedef enum { /*< skip >*/

View File

@ -39,8 +39,8 @@ gtk_css_value_unset_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
GtkCssStyleProperty *property;

View File

@ -20,7 +20,7 @@
#include "gtkprivate.h"
#include "gtkcssvalueprivate.h"
#include "gtkcsscomputedvaluesprivate.h"
#include "gtkcssstyleprivate.h"
#include "gtkstyleproviderprivate.h"
struct _GtkCssValue {
@ -88,16 +88,16 @@ _gtk_css_value_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
{
GtkCssDependencies fallback;
gtk_internal_return_val_if_fail (value != NULL, NULL);
gtk_internal_return_val_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider), NULL);
gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
gtk_internal_return_val_if_fail (parent_values == NULL || GTK_IS_CSS_COMPUTED_VALUES (parent_values), NULL);
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (values), NULL);
gtk_internal_return_val_if_fail (parent_values == NULL || GTK_IS_CSS_STYLE (parent_values), NULL);
if (dependencies == NULL)
dependencies = &fallback;

View File

@ -44,8 +44,8 @@ struct _GtkCssValueClass {
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies);
gboolean (* equal) (const GtkCssValue *value1,
const GtkCssValue *value2);
@ -70,8 +70,8 @@ GtkCssValue *_gtk_css_value_compute (GtkCssValue
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies);
gboolean _gtk_css_value_equal (const GtkCssValue *value1,
const GtkCssValue *value2);

View File

@ -221,17 +221,19 @@ _cairo_ellipsis (cairo_t *cr,
double xradius, double yradius,
double angle1, double angle2)
{
cairo_matrix_t save;
if (xradius <= 0.0 || yradius <= 0.0)
{
cairo_line_to (cr, xc, yc);
return;
}
cairo_save (cr);
cairo_get_matrix (cr, &save);
cairo_translate (cr, xc, yc);
cairo_scale (cr, xradius, yradius);
cairo_arc (cr, 0, 0, 1.0, angle1, angle2);
cairo_restore (cr);
cairo_set_matrix (cr, &save);
}
static void
@ -240,17 +242,19 @@ _cairo_ellipsis_negative (cairo_t *cr,
double xradius, double yradius,
double angle1, double angle2)
{
cairo_matrix_t save;
if (xradius <= 0.0 || yradius <= 0.0)
{
cairo_line_to (cr, xc, yc);
return;
}
cairo_save (cr);
cairo_get_matrix (cr, &save);
cairo_translate (cr, xc, yc);
cairo_scale (cr, xradius, yradius);
cairo_arc_negative (cr, 0, 0, 1.0, angle1, angle2);
cairo_restore (cr);
cairo_set_matrix (cr, &save);
}
void

View File

@ -26,7 +26,7 @@ G_DEFINE_ABSTRACT_TYPE (GtkStyleAnimation, _gtk_style_animation, G_TYPE_OBJECT)
static void
gtk_style_animation_real_set_values (GtkStyleAnimation *animation,
gint64 for_time_us,
GtkCssComputedValues *values)
GtkCssStyle *values)
{
}
@ -60,12 +60,12 @@ _gtk_style_animation_init (GtkStyleAnimation *animation)
void
_gtk_style_animation_set_values (GtkStyleAnimation *animation,
gint64 for_time_us,
GtkCssComputedValues *values)
GtkCssStyle *values)
{
GtkStyleAnimationClass *klass;
g_return_if_fail (GTK_IS_STYLE_ANIMATION (animation));
g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
g_return_if_fail (GTK_IS_CSS_STYLE (values));
klass = GTK_STYLE_ANIMATION_GET_CLASS (animation);

View File

@ -21,7 +21,7 @@
#define __GTK_STYLE_ANIMATION_PRIVATE_H__
#include <glib-object.h>
#include "gtkcsscomputedvaluesprivate.h"
#include "gtkcssstyleprivate.h"
G_BEGIN_DECLS
@ -50,14 +50,14 @@ struct _GtkStyleAnimationClass
gint64 at_time_us);
void (* set_values) (GtkStyleAnimation *animation,
gint64 for_time_us,
GtkCssComputedValues *values);
GtkCssStyle *values);
};
GType _gtk_style_animation_get_type (void) G_GNUC_CONST;
void _gtk_style_animation_set_values (GtkStyleAnimation *animation,
gint64 for_time_us,
GtkCssComputedValues *values);
GtkCssStyle *values);
gboolean _gtk_style_animation_is_finished (GtkStyleAnimation *animation,
gint64 at_time_us);
gboolean _gtk_style_animation_is_static (GtkStyleAnimation *animation,

View File

@ -143,7 +143,7 @@ struct PropertyValue
struct GtkStyleInfo
{
GtkCssNodeDeclaration *decl;
GtkCssComputedValues *values;
GtkCssStyle *values;
};
struct _GtkStyleContextPrivate
@ -198,7 +198,7 @@ static void gtk_style_context_impl_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static GtkCssComputedValues *style_values_lookup(GtkStyleContext *context);
static GtkCssStyle *style_values_lookup(GtkStyleContext *context);
static void gtk_style_context_disconnect_update (GtkStyleContext *context);
@ -305,7 +305,7 @@ style_info_new (void)
static void
style_info_set_values (GtkStyleInfo *info,
GtkCssComputedValues *values)
GtkCssStyle *values)
{
if (info->values == values)
return;
@ -491,7 +491,7 @@ static gboolean
gtk_style_context_should_animate (GtkStyleContext *context)
{
GtkStyleContextPrivate *priv;
GtkCssComputedValues *values;
GtkCssStyle *values;
gboolean animate;
priv = context->priv;
@ -503,7 +503,7 @@ gtk_style_context_should_animate (GtkStyleContext *context)
return FALSE;
values = style_values_lookup (context);
if (_gtk_css_computed_values_is_static (values))
if (gtk_css_style_is_static (values))
return FALSE;
g_object_get (gtk_widget_get_settings (context->priv->widget),
@ -680,7 +680,7 @@ create_query_path (GtkStyleContext *context,
static void
build_properties (GtkStyleContext *context,
GtkCssComputedValues *values,
GtkCssStyle *values,
const GtkCssNodeDeclaration *decl,
const GtkBitmask *relevant_changes,
GtkCssChange *out_change)
@ -711,11 +711,11 @@ build_properties (GtkStyleContext *context,
gtk_widget_path_free (path);
}
static GtkCssComputedValues *
static GtkCssStyle *
style_values_lookup (GtkStyleContext *context)
{
GtkStyleContextPrivate *priv;
GtkCssComputedValues *values;
GtkCssStyle *values;
GtkStyleInfo *info;
priv = context->priv;
@ -734,7 +734,7 @@ style_values_lookup (GtkStyleContext *context)
return values;
}
values = _gtk_css_computed_values_new ();
values = gtk_css_style_new ();
style_info_set_values (info, values);
if (gtk_style_context_is_saved (context))
@ -757,12 +757,12 @@ style_values_lookup (GtkStyleContext *context)
return values;
}
static GtkCssComputedValues *
static GtkCssStyle *
style_values_lookup_for_state (GtkStyleContext *context,
GtkStateFlags state)
{
GtkCssNodeDeclaration *decl;
GtkCssComputedValues *values;
GtkCssStyle *values;
if (gtk_css_node_declaration_get_state (context->priv->info->decl) == state)
return g_object_ref (style_values_lookup (context));
@ -772,7 +772,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 ();
values = gtk_css_style_new ();
build_properties (context, values, decl, NULL, NULL);
gtk_css_node_declaration_unref (decl);
@ -1050,7 +1050,7 @@ gtk_style_context_get_section (GtkStyleContext *context,
const gchar *property)
{
GtkStyleContextPrivate *priv;
GtkCssComputedValues *values;
GtkCssStyle *values;
GtkStyleProperty *prop;
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
@ -1064,14 +1064,14 @@ gtk_style_context_get_section (GtkStyleContext *context,
return NULL;
values = style_values_lookup (context);
return _gtk_css_computed_values_get_section (values, _gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (prop)));
return gtk_css_style_get_section (values, _gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (prop)));
}
static GtkCssValue *
gtk_style_context_query_func (guint id,
gpointer values)
{
return _gtk_css_computed_values_get_value (values, id);
return gtk_css_style_get_value (values, id);
}
/**
@ -1095,7 +1095,7 @@ gtk_style_context_get_property (GtkStyleContext *context,
GValue *value)
{
GtkStyleContextPrivate *priv;
GtkCssComputedValues *values;
GtkCssStyle *values;
GtkStyleProperty *prop;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
@ -1824,9 +1824,9 @@ GtkCssValue *
_gtk_style_context_peek_property (GtkStyleContext *context,
guint property_id)
{
GtkCssComputedValues *values = style_values_lookup (context);
GtkCssStyle *values = style_values_lookup (context);
return _gtk_css_computed_values_get_value (values, property_id);
return gtk_css_style_get_value (values, property_id);
}
const GValue *
@ -2650,10 +2650,10 @@ gtk_style_context_update_cache (GtkStyleContext *context,
while (g_hash_table_iter_next (&iter, &key, &value))
{
const GtkCssNodeDeclaration *decl = key;
GtkCssComputedValues *values = value;
GtkCssStyle *values = value;
GtkBitmask *changes;
changes = _gtk_css_computed_values_compute_dependencies (values, parent_changes);
changes = gtk_css_style_compute_dependencies (values, parent_changes);
if (!_gtk_bitmask_is_empty (changes))
build_properties (context, values, decl, changes, NULL);
@ -2692,13 +2692,13 @@ gtk_style_context_update_animations (GtkStyleContext *context,
gint64 timestamp)
{
GtkBitmask *differences;
GtkCssComputedValues *values;
GtkCssStyle *values;
values = style_values_lookup (context);
differences = _gtk_css_computed_values_advance (values, timestamp);
differences = gtk_css_style_advance (values, timestamp);
if (_gtk_css_computed_values_is_static (values))
if (gtk_css_style_is_static (values))
_gtk_style_context_update_animating (context);
return differences;
@ -2749,7 +2749,7 @@ _gtk_style_context_validate (GtkStyleContext *context,
{
GtkStyleContextPrivate *priv;
GtkStyleInfo *info;
GtkCssComputedValues *current;
GtkCssStyle *current;
GtkBitmask *changes;
GSList *list;
@ -2790,7 +2790,7 @@ _gtk_style_context_validate (GtkStyleContext *context,
if (current == NULL ||
gtk_style_context_needs_full_revalidate (context, change))
{
GtkCssComputedValues *values;
GtkCssStyle *values;
if ((priv->relevant_changes & change) & ~GTK_STYLE_CONTEXT_CACHED_CHANGE)
{
@ -2805,13 +2805,13 @@ _gtk_style_context_validate (GtkStyleContext *context,
values = style_values_lookup (context);
if (values != current)
_gtk_css_computed_values_create_animations (values,
priv->parent ? style_values_lookup (priv->parent) : NULL,
timestamp,
GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
priv->scale,
gtk_style_context_should_create_transitions (context) ? current : NULL);
if (_gtk_css_computed_values_is_static (values))
gtk_css_style_create_animations (values,
priv->parent ? style_values_lookup (priv->parent) : NULL,
timestamp,
GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
priv->scale,
gtk_style_context_should_create_transitions (context) ? current : NULL);
if (gtk_css_style_is_static (values))
change &= ~GTK_CSS_CHANGE_ANIMATE;
else
change |= GTK_CSS_CHANGE_ANIMATE;
@ -2819,7 +2819,7 @@ _gtk_style_context_validate (GtkStyleContext *context,
if (current)
{
changes = _gtk_css_computed_values_get_difference (values, current);
changes = gtk_css_style_get_difference (values, current);
}
else
{
@ -2829,7 +2829,7 @@ _gtk_style_context_validate (GtkStyleContext *context,
}
else
{
changes = _gtk_css_computed_values_compute_dependencies (current, parent_changes);
changes = gtk_css_style_compute_dependencies (current, parent_changes);
if (!_gtk_bitmask_is_empty (changes))
build_properties (context, current, info->decl, changes, NULL);