stylecontext: Use a static style when saved
The only style that is animated is the style of the unsaved primary node. So there's no need to create animated style objects for the other ones. There is a bunch of ugliness in the code currently. Further commits are expected to fix them.
This commit is contained in:
@ -19,9 +19,11 @@
|
|||||||
|
|
||||||
#include "gtkcsslookupprivate.h"
|
#include "gtkcsslookupprivate.h"
|
||||||
|
|
||||||
|
#include "gtkcssanimatedstyleprivate.h"
|
||||||
|
#include "gtkcssstaticstyleprivate.h"
|
||||||
|
#include "gtkcssstylepropertyprivate.h"
|
||||||
#include "gtkcsstypesprivate.h"
|
#include "gtkcsstypesprivate.h"
|
||||||
#include "gtkprivatetypebuiltins.h"
|
#include "gtkprivatetypebuiltins.h"
|
||||||
#include "gtkcssstylepropertyprivate.h"
|
|
||||||
|
|
||||||
GtkCssLookup *
|
GtkCssLookup *
|
||||||
_gtk_css_lookup_new (const GtkBitmask *relevant)
|
_gtk_css_lookup_new (const GtkBitmask *relevant)
|
||||||
@ -106,15 +108,15 @@ void
|
|||||||
_gtk_css_lookup_resolve (GtkCssLookup *lookup,
|
_gtk_css_lookup_resolve (GtkCssLookup *lookup,
|
||||||
GtkStyleProviderPrivate *provider,
|
GtkStyleProviderPrivate *provider,
|
||||||
int scale,
|
int scale,
|
||||||
GtkCssAnimatedStyle *style,
|
GtkCssStyle *style,
|
||||||
GtkCssStyle *parent_style)
|
GtkCssStyle *parent_style)
|
||||||
{
|
{
|
||||||
guint i, n;
|
guint i, n;
|
||||||
|
|
||||||
g_return_if_fail (lookup != NULL);
|
g_return_if_fail (lookup != NULL);
|
||||||
g_return_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider));
|
g_return_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider));
|
||||||
g_return_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style));
|
g_return_if_fail (GTK_IS_CSS_STYLE (style));
|
||||||
g_return_if_fail (parent_style == NULL || GTK_IS_CSS_ANIMATED_STYLE (parent_style));
|
g_return_if_fail (parent_style == NULL || GTK_IS_CSS_STYLE (parent_style));
|
||||||
|
|
||||||
n = _gtk_css_style_property_get_n_properties ();
|
n = _gtk_css_style_property_get_n_properties ();
|
||||||
|
|
||||||
@ -122,13 +124,24 @@ _gtk_css_lookup_resolve (GtkCssLookup *lookup,
|
|||||||
{
|
{
|
||||||
if (lookup->values[i].value ||
|
if (lookup->values[i].value ||
|
||||||
_gtk_bitmask_get (lookup->missing, i))
|
_gtk_bitmask_get (lookup->missing, i))
|
||||||
gtk_css_animated_style_compute_value (style,
|
{
|
||||||
|
if (GTK_IS_CSS_ANIMATED_STYLE (style))
|
||||||
|
gtk_css_animated_style_compute_value (GTK_CSS_ANIMATED_STYLE (style),
|
||||||
provider,
|
provider,
|
||||||
scale,
|
scale,
|
||||||
parent_style,
|
parent_style,
|
||||||
i,
|
i,
|
||||||
lookup->values[i].value,
|
lookup->values[i].value,
|
||||||
lookup->values[i].section);
|
lookup->values[i].section);
|
||||||
|
else
|
||||||
|
gtk_css_static_style_compute_value (GTK_CSS_STATIC_STYLE (style),
|
||||||
|
provider,
|
||||||
|
scale,
|
||||||
|
parent_style,
|
||||||
|
i,
|
||||||
|
lookup->values[i].value,
|
||||||
|
lookup->values[i].section);
|
||||||
|
}
|
||||||
/* else not a relevant property */
|
/* else not a relevant property */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include "gtk/gtkbitmaskprivate.h"
|
#include "gtk/gtkbitmaskprivate.h"
|
||||||
#include "gtk/gtkcssanimatedstyleprivate.h"
|
#include "gtk/gtkcssstyleprivate.h"
|
||||||
#include "gtk/gtkcsssection.h"
|
#include "gtk/gtkcsssection.h"
|
||||||
|
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ void _gtk_css_lookup_set (GtkCssLookup
|
|||||||
void _gtk_css_lookup_resolve (GtkCssLookup *lookup,
|
void _gtk_css_lookup_resolve (GtkCssLookup *lookup,
|
||||||
GtkStyleProviderPrivate *provider,
|
GtkStyleProviderPrivate *provider,
|
||||||
int scale,
|
int scale,
|
||||||
GtkCssAnimatedStyle *style,
|
GtkCssStyle *style,
|
||||||
GtkCssStyle *parent_style);
|
GtkCssStyle *parent_style);
|
||||||
|
|
||||||
static inline const GtkBitmask *
|
static inline const GtkBitmask *
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "gtkstylecontextprivate.h"
|
#include "gtkstylecontextprivate.h"
|
||||||
#include "gtkcontainerprivate.h"
|
#include "gtkcontainerprivate.h"
|
||||||
|
#include "gtkcssanimatedstyleprivate.h"
|
||||||
#include "gtkcsscolorvalueprivate.h"
|
#include "gtkcsscolorvalueprivate.h"
|
||||||
#include "gtkcsscornervalueprivate.h"
|
#include "gtkcsscornervalueprivate.h"
|
||||||
#include "gtkcssenumvalueprivate.h"
|
#include "gtkcssenumvalueprivate.h"
|
||||||
@ -33,6 +34,7 @@
|
|||||||
#include "gtkcssnumbervalueprivate.h"
|
#include "gtkcssnumbervalueprivate.h"
|
||||||
#include "gtkcssrgbavalueprivate.h"
|
#include "gtkcssrgbavalueprivate.h"
|
||||||
#include "gtkcssshadowsvalueprivate.h"
|
#include "gtkcssshadowsvalueprivate.h"
|
||||||
|
#include "gtkcssstaticstyleprivate.h"
|
||||||
#include "gtkcssstylepropertyprivate.h"
|
#include "gtkcssstylepropertyprivate.h"
|
||||||
#include "gtkcsstransformvalueprivate.h"
|
#include "gtkcsstransformvalueprivate.h"
|
||||||
#include "gtkdebug.h"
|
#include "gtkdebug.h"
|
||||||
@ -680,7 +682,7 @@ create_query_path (GtkStyleContext *context,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
build_properties (GtkStyleContext *context,
|
build_properties (GtkStyleContext *context,
|
||||||
GtkCssStyle *values,
|
GtkCssStyle *style,
|
||||||
const GtkCssNodeDeclaration *decl,
|
const GtkCssNodeDeclaration *decl,
|
||||||
const GtkBitmask *relevant_changes,
|
const GtkBitmask *relevant_changes,
|
||||||
GtkCssChange *out_change)
|
GtkCssChange *out_change)
|
||||||
@ -704,7 +706,7 @@ build_properties (GtkStyleContext *context,
|
|||||||
_gtk_css_lookup_resolve (lookup,
|
_gtk_css_lookup_resolve (lookup,
|
||||||
GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
|
GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
|
||||||
priv->scale,
|
priv->scale,
|
||||||
GTK_CSS_ANIMATED_STYLE (values),
|
style,
|
||||||
priv->parent ? style_values_lookup (priv->parent) : NULL);
|
priv->parent ? style_values_lookup (priv->parent) : NULL);
|
||||||
|
|
||||||
_gtk_css_lookup_free (lookup);
|
_gtk_css_lookup_free (lookup);
|
||||||
@ -734,11 +736,11 @@ style_values_lookup (GtkStyleContext *context)
|
|||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
values = gtk_css_animated_style_new ();
|
|
||||||
|
|
||||||
style_info_set_values (info, values);
|
|
||||||
if (gtk_style_context_is_saved (context))
|
if (gtk_style_context_is_saved (context))
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
|
values = gtk_css_static_style_new ();
|
||||||
g_hash_table_insert (priv->style_values,
|
g_hash_table_insert (priv->style_values,
|
||||||
gtk_css_node_declaration_ref (info->decl),
|
gtk_css_node_declaration_ref (info->decl),
|
||||||
g_object_ref (values));
|
g_object_ref (values));
|
||||||
@ -747,11 +749,14 @@ style_values_lookup (GtkStyleContext *context)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
values = gtk_css_animated_style_new ();
|
||||||
|
|
||||||
build_properties (context, values, info->decl, NULL, &priv->relevant_changes);
|
build_properties (context, values, info->decl, NULL, &priv->relevant_changes);
|
||||||
/* These flags are always relevant */
|
/* These flags are always relevant */
|
||||||
priv->relevant_changes |= GTK_CSS_CHANGE_SOURCE;
|
priv->relevant_changes |= GTK_CSS_CHANGE_SOURCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
style_info_set_values (info, values);
|
||||||
g_object_unref (values);
|
g_object_unref (values);
|
||||||
|
|
||||||
return values;
|
return values;
|
||||||
@ -772,7 +777,7 @@ style_values_lookup_for_state (GtkStyleContext *context,
|
|||||||
|
|
||||||
decl = gtk_css_node_declaration_ref (context->priv->info->decl);
|
decl = gtk_css_node_declaration_ref (context->priv->info->decl);
|
||||||
gtk_css_node_declaration_set_state (&decl, state);
|
gtk_css_node_declaration_set_state (&decl, state);
|
||||||
values = gtk_css_animated_style_new ();
|
values = gtk_css_static_style_new ();
|
||||||
build_properties (context, values, decl, NULL, NULL);
|
build_properties (context, values, decl, NULL, NULL);
|
||||||
gtk_css_node_declaration_unref (decl);
|
gtk_css_node_declaration_unref (decl);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user