Commit 58b6d492 authored by Benjamin Otte's avatar Benjamin Otte

cssvalue: Add a custom RGBA value

Note: custom CSS properties still use the default GtkCssValue and always
will.
So there is a difference in css values used between those, even though
they both carry a GdkRGBA payload.
parent dcec7a55
...@@ -438,6 +438,7 @@ gtk_private_h_sources = \ ...@@ -438,6 +438,7 @@ gtk_private_h_sources = \
gtkcssnumbervalueprivate.h \ gtkcssnumbervalueprivate.h \
gtkcssparserprivate.h \ gtkcssparserprivate.h \
gtkcssproviderprivate.h \ gtkcssproviderprivate.h \
gtkcssrgbavalueprivate.h \
gtkcsssectionprivate.h \ gtkcsssectionprivate.h \
gtkcssselectorprivate.h \ gtkcssselectorprivate.h \
gtkcssshadowvalueprivate.h \ gtkcssshadowvalueprivate.h \
...@@ -639,6 +640,7 @@ gtk_base_c_sources = \ ...@@ -639,6 +640,7 @@ gtk_base_c_sources = \
gtkcssnumbervalue.c \ gtkcssnumbervalue.c \
gtkcssparser.c \ gtkcssparser.c \
gtkcssprovider.c \ gtkcssprovider.c \
gtkcssrgbavalue.c \
gtkcsssection.c \ gtkcsssection.c \
gtkcssselector.c \ gtkcssselector.c \
gtkcssshadowvalue.c \ gtkcssshadowvalue.c \
......
/* GTK - The GIMP Toolkit
* Copyright (C) 2011 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 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/>.
*/
#include "config.h"
#include "gtkcssrgbavalueprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtksymboliccolorprivate.h"
struct _GtkCssValue {
GTK_CSS_VALUE_BASE
GdkRGBA rgba;
};
static void
gtk_css_value_rgba_free (GtkCssValue *value)
{
g_slice_free (GtkCssValue, value);
}
static gboolean
gtk_css_value_rgba_equal (const GtkCssValue *rgba1,
const GtkCssValue *rgba2)
{
return gdk_rgba_equal (&rgba1->rgba, &rgba2->rgba);
}
static void
gtk_css_value_rgba_print (const GtkCssValue *rgba,
GString *string)
{
char *s = gdk_rgba_to_string (&rgba->rgba);
g_string_append (string, s);
g_free (s);
}
static const GtkCssValueClass GTK_CSS_VALUE_RGBA = {
gtk_css_value_rgba_free,
gtk_css_value_rgba_equal,
gtk_css_value_rgba_print
};
GtkCssValue *
_gtk_css_rgba_value_new_from_rgba (const GdkRGBA *rgba)
{
GtkCssValue *value;
g_return_val_if_fail (rgba != NULL, NULL);
value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_RGBA);
value->rgba = *rgba;
return value;
}
const GdkRGBA *
_gtk_css_rgba_value_get_rgba (const GtkCssValue *rgba)
{
g_return_val_if_fail (rgba->class == &GTK_CSS_VALUE_RGBA, NULL);
return &rgba->rgba;
}
GtkCssValue *
_gtk_css_rgba_value_compute_from_symbolic (GtkCssValue *rgba,
GtkCssValue *fallback,
GtkStyleContext *context,
gboolean for_color_property)
{
GtkSymbolicColor *symbolic;
GtkCssValue *resolved;
g_return_val_if_fail (rgba != NULL, NULL);
symbolic = _gtk_css_value_get_symbolic_color (rgba);
if (symbolic == _gtk_symbolic_color_get_current_color ())
{
/* The computed value of the ‘currentColor’ keyword is the computed
* value of the ‘color’ property. If the ‘currentColor’ keyword is
* set on the ‘color’ property itself, it is treated as ‘color: inherit’.
*/
if (for_color_property)
{
GtkStyleContext *parent = gtk_style_context_get_parent (context);
if (parent)
return _gtk_css_value_ref (_gtk_style_context_peek_property (parent, "color"));
else
return _gtk_css_rgba_value_compute_from_symbolic (fallback, NULL, context, TRUE);
}
else
{
return _gtk_css_value_ref (_gtk_style_context_peek_property (context, "color"));
}
}
resolved = _gtk_style_context_resolve_color_value (context, symbolic);
if (resolved == NULL)
return _gtk_css_rgba_value_compute_from_symbolic (fallback, NULL, context, for_color_property);
g_assert (resolved->class == &GTK_CSS_VALUE_RGBA);
return resolved;
}
/*
* 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: Alexander Larsson <alexl@gnome.org>
*/
#ifndef __GTK_CSS_RGBA_VALUE_PRIVATE_H__
#define __GTK_CSS_RGBA_VALUE_PRIVATE_H__
#include "gtkcssparserprivate.h"
#include "gtkcsstypesprivate.h"
#include "gtkcssvalueprivate.h"
G_BEGIN_DECLS
GtkCssValue * _gtk_css_rgba_value_new_from_rgba (const GdkRGBA *rgba);
GtkCssValue * _gtk_css_rgba_value_compute_from_symbolic
(GtkCssValue *rgba,
GtkCssValue *fallback,
GtkStyleContext *context,
gboolean for_color_property);
const GdkRGBA * _gtk_css_rgba_value_get_rgba (const GtkCssValue *rgba);
G_END_DECLS
#endif /* __GTK_CSS_RGBA_VALUE_PRIVATE_H__ */
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "gtkanimationdescription.h" #include "gtkanimationdescription.h"
#include "gtkcssimagegradientprivate.h" #include "gtkcssimagegradientprivate.h"
#include "gtkcssprovider.h" #include "gtkcssprovider.h"
#include "gtkcssrgbavalueprivate.h"
#include "gtkcsstypesprivate.h" #include "gtkcsstypesprivate.h"
#include "gtkgradient.h" #include "gtkgradient.h"
#include "gtkprivatetypebuiltins.h" #include "gtkprivatetypebuiltins.h"
...@@ -213,24 +214,21 @@ rgba_value_print (const GValue *value, ...@@ -213,24 +214,21 @@ rgba_value_print (const GValue *value,
static GtkCssValue * static GtkCssValue *
rgba_value_compute (GtkStyleContext *context, rgba_value_compute (GtkStyleContext *context,
GtkCssValue *specified) GtkCssValue *specified)
{ {
GdkRGBA white = { 1, 1, 1, 1 }; GdkRGBA white = { 1, 1, 1, 1 };
GtkCssValue *res;
if (_gtk_css_value_holds (specified, GTK_TYPE_SYMBOLIC_COLOR)) if (_gtk_css_value_holds (specified, GTK_TYPE_SYMBOLIC_COLOR))
{ {
GtkSymbolicColor *symbolic = _gtk_css_value_get_symbolic_color (specified); GtkSymbolicColor *symbolic = _gtk_css_value_get_symbolic_color (specified);
GdkRGBA rgba;
if (symbolic == _gtk_symbolic_color_get_current_color ()) if (symbolic == _gtk_symbolic_color_get_current_color ())
return _gtk_css_value_ref (_gtk_style_context_peek_property (context, "color")); rgba = *_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, "color"));
else { else if (!gtk_symbolic_color_resolve (symbolic, NULL, &rgba))
res = _gtk_style_context_resolve_color_value (context, symbolic); rgba = white;
if (res != NULL)
return res;
return _gtk_css_value_new_from_rgba (&white); return _gtk_css_value_new_from_boxed (GDK_TYPE_RGBA, &rgba);
}
} }
else else
return _gtk_css_value_ref (specified); return _gtk_css_value_ref (specified);
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#include "gtkcssimageprivate.h" #include "gtkcssimageprivate.h"
#include "gtkcssimageprivate.h" #include "gtkcssimageprivate.h"
#include "gtkcssnumbervalueprivate.h" #include "gtkcssnumbervalueprivate.h"
#include "gtkgradient.h" #include "gtkcssrgbavalueprivate.h"
#include "gtkcssshadowvalueprivate.h" #include "gtkcssshadowvalueprivate.h"
#include "gtksymboliccolorprivate.h" #include "gtksymboliccolorprivate.h"
#include "gtkthemingengine.h" #include "gtkthemingengine.h"
...@@ -190,42 +190,41 @@ color_compute (GtkCssStyleProperty *property, ...@@ -190,42 +190,41 @@ color_compute (GtkCssStyleProperty *property,
GtkStyleContext *context, GtkStyleContext *context,
GtkCssValue *specified) GtkCssValue *specified)
{ {
GtkSymbolicColor *symbolic = _gtk_css_value_get_symbolic_color (specified); return _gtk_css_rgba_value_compute_from_symbolic (specified,
GtkCssValue *resolved; _gtk_css_style_property_get_initial_value (property),
context,
FALSE);
}
if (symbolic == _gtk_symbolic_color_get_current_color ()) static GtkCssValue *
{ color_property_compute (GtkCssStyleProperty *property,
/* The computed value of the ‘currentColor’ keyword is the computed GtkStyleContext *context,
* value of the ‘color’ property. If the ‘currentColor’ keyword is GtkCssValue *specified)
* set on the ‘color’ property itself, it is treated as ‘color: inherit’. {
*/ GtkCssValue *value;
if (g_str_equal (_gtk_style_property_get_name (GTK_STYLE_PROPERTY (property)), "color"))
{ value = _gtk_css_rgba_value_compute_from_symbolic (specified,
GtkStyleContext *parent = gtk_style_context_get_parent (context); _gtk_css_style_property_get_initial_value (property),
context,
TRUE);
_gtk_css_rgba_value_get_rgba (value);
return value;
}
if (parent) static void
return _gtk_css_value_ref (_gtk_style_context_peek_property (parent, "color")); color_query (GtkCssStyleProperty *property,
else const GtkCssValue *css_value,
return _gtk_css_style_compute_value (context, GValue *value)
GDK_TYPE_RGBA, {
_gtk_css_style_property_get_initial_value (property)); g_value_init (value, GDK_TYPE_RGBA);
} g_value_set_boxed (value, _gtk_css_rgba_value_get_rgba (css_value));
else }
{
return _gtk_css_value_ref (_gtk_style_context_peek_property (context, "color")); static GtkCssValue *
} color_assign (GtkCssStyleProperty *property,
} const GValue *value)
else if ((resolved = _gtk_style_context_resolve_color_value (context, {
symbolic)) != NULL) return _gtk_css_rgba_value_new_from_rgba (g_value_get_boxed (value));
{
return resolved;
}
else
{
return color_compute (property,
context,
_gtk_css_style_property_get_initial_value (property));
}
} }
static GtkCssValue * static GtkCssValue *
...@@ -1162,9 +1161,9 @@ _gtk_css_style_property_init_properties (void) ...@@ -1162,9 +1161,9 @@ _gtk_css_style_property_init_properties (void)
GTK_STYLE_PROPERTY_INHERIT, GTK_STYLE_PROPERTY_INHERIT,
color_parse, color_parse,
NULL, NULL,
color_compute, color_property_compute,
query_simple, color_query,
assign_simple, color_assign,
NULL, NULL,
_gtk_css_value_new_take_symbolic_color ( _gtk_css_value_new_take_symbolic_color (
gtk_symbolic_color_new_rgba (1, 1, 1, 1))); gtk_symbolic_color_new_rgba (1, 1, 1, 1)));
...@@ -1187,8 +1186,8 @@ _gtk_css_style_property_init_properties (void) ...@@ -1187,8 +1186,8 @@ _gtk_css_style_property_init_properties (void)
color_parse, color_parse,
NULL, NULL,
color_compute, color_compute,
query_simple, color_query,
assign_simple, color_assign,
NULL, NULL,
_gtk_css_value_new_take_symbolic_color ( _gtk_css_value_new_take_symbolic_color (
gtk_symbolic_color_new_rgba (0, 0, 0, 0))); gtk_symbolic_color_new_rgba (0, 0, 0, 0)));
...@@ -1554,8 +1553,8 @@ _gtk_css_style_property_init_properties (void) ...@@ -1554,8 +1553,8 @@ _gtk_css_style_property_init_properties (void)
color_parse, color_parse,
NULL, NULL,
color_compute, color_compute,
query_simple, color_query,
assign_simple, color_assign,
NULL, NULL,
_gtk_css_value_new_take_symbolic_color ( _gtk_css_value_new_take_symbolic_color (
gtk_symbolic_color_ref ( gtk_symbolic_color_ref (
...@@ -1566,8 +1565,8 @@ _gtk_css_style_property_init_properties (void) ...@@ -1566,8 +1565,8 @@ _gtk_css_style_property_init_properties (void)
color_parse, color_parse,
NULL, NULL,
color_compute, color_compute,
query_simple, color_query,
assign_simple, color_assign,
NULL, NULL,
_gtk_css_value_new_take_symbolic_color ( _gtk_css_value_new_take_symbolic_color (
gtk_symbolic_color_ref ( gtk_symbolic_color_ref (
...@@ -1578,8 +1577,8 @@ _gtk_css_style_property_init_properties (void) ...@@ -1578,8 +1577,8 @@ _gtk_css_style_property_init_properties (void)
color_parse, color_parse,
NULL, NULL,
color_compute, color_compute,
query_simple, color_query,
assign_simple, color_assign,
NULL, NULL,
_gtk_css_value_new_take_symbolic_color ( _gtk_css_value_new_take_symbolic_color (
gtk_symbolic_color_ref ( gtk_symbolic_color_ref (
...@@ -1590,8 +1589,8 @@ _gtk_css_style_property_init_properties (void) ...@@ -1590,8 +1589,8 @@ _gtk_css_style_property_init_properties (void)
color_parse, color_parse,
NULL, NULL,
color_compute, color_compute,
query_simple, color_query,
assign_simple, color_assign,
NULL, NULL,
_gtk_css_value_new_take_symbolic_color ( _gtk_css_value_new_take_symbolic_color (
gtk_symbolic_color_ref ( gtk_symbolic_color_ref (
...@@ -1602,8 +1601,8 @@ _gtk_css_style_property_init_properties (void) ...@@ -1602,8 +1601,8 @@ _gtk_css_style_property_init_properties (void)
color_parse, color_parse,
NULL, NULL,
color_compute, color_compute,
query_simple, color_query,
assign_simple, color_assign,
NULL, NULL,
_gtk_css_value_new_take_symbolic_color ( _gtk_css_value_new_take_symbolic_color (
gtk_symbolic_color_ref ( gtk_symbolic_color_ref (
......
...@@ -302,17 +302,6 @@ _gtk_css_value_new_take_binding_sets (GPtrArray *array) ...@@ -302,17 +302,6 @@ _gtk_css_value_new_take_binding_sets (GPtrArray *array)
return value; return value;
} }
GtkCssValue *
_gtk_css_value_new_from_rgba (const GdkRGBA *v)
{
GtkCssValue *value;
value = gtk_css_value_new (GDK_TYPE_RGBA);
value->u.ptr = g_boxed_copy0 (GDK_TYPE_RGBA, v);
return value;
}
GtkCssValue * GtkCssValue *
_gtk_css_value_new_from_color (const GdkColor *v) _gtk_css_value_new_from_color (const GdkColor *v)
{ {
...@@ -452,12 +441,16 @@ _gtk_css_value_print (const GtkCssValue *value, ...@@ -452,12 +441,16 @@ _gtk_css_value_print (const GtkCssValue *value,
GType GType
_gtk_css_value_get_content_type (const GtkCssValue *value) _gtk_css_value_get_content_type (const GtkCssValue *value)
{ {
g_return_val_if_fail (value->class == &GTK_CSS_VALUE_DEFAULT, G_TYPE_NONE);
return value->type; return value->type;
} }
gboolean gboolean
_gtk_css_value_holds (const GtkCssValue *value, GType type) _gtk_css_value_holds (const GtkCssValue *value, GType type)
{ {
g_return_val_if_fail (value->class == &GTK_CSS_VALUE_DEFAULT, FALSE);
return g_type_is_a (value->type, type); return g_type_is_a (value->type, type);
} }
...@@ -499,6 +492,7 @@ _gtk_css_value_init_gvalue (const GtkCssValue *value, ...@@ -499,6 +492,7 @@ _gtk_css_value_init_gvalue (const GtkCssValue *value,
{ {
if (value != NULL) if (value != NULL)
{ {
g_return_if_fail (value->class == &GTK_CSS_VALUE_DEFAULT);
g_value_init (g_value, value->type); g_value_init (g_value, value->type);
fill_gvalue (value, g_value); fill_gvalue (value, g_value);
} }
...@@ -632,13 +626,6 @@ _gtk_css_value_get_pango_weight (const GtkCssValue *value) ...@@ -632,13 +626,6 @@ _gtk_css_value_get_pango_weight (const GtkCssValue *value)
return value->u.gint; return value->u.gint;
} }
const GdkRGBA *
_gtk_css_value_get_rgba (const GtkCssValue *value)
{
g_return_val_if_fail (_gtk_css_value_holds (value, GDK_TYPE_RGBA), NULL);
return value->u.ptr;
}
GtkGradient * GtkGradient *
_gtk_css_value_get_gradient (const GtkCssValue *value) _gtk_css_value_get_gradient (const GtkCssValue *value)
{ {
......
...@@ -81,7 +81,6 @@ GtkCssValue *_gtk_css_value_new_take_string (char ...@@ -81,7 +81,6 @@ GtkCssValue *_gtk_css_value_new_take_string (char
GtkCssValue *_gtk_css_value_new_take_strv (char **strv); GtkCssValue *_gtk_css_value_new_take_strv (char **strv);
GtkCssValue *_gtk_css_value_new_from_boxed (GType type, GtkCssValue *_gtk_css_value_new_from_boxed (GType type,
gpointer boxed); gpointer boxed);
GtkCssValue *_gtk_css_value_new_from_rgba (const GdkRGBA *v);
GtkCssValue *_gtk_css_value_new_from_color (const GdkColor *v); GtkCssValue *_gtk_css_value_new_from_color (const GdkColor *v);
GtkCssValue *_gtk_css_value_new_take_symbolic_color (GtkSymbolicColor *v); GtkCssValue *_gtk_css_value_new_take_symbolic_color (GtkSymbolicColor *v);
GtkCssValue *_gtk_css_value_new_take_pattern (cairo_pattern_t *v); GtkCssValue *_gtk_css_value_new_take_pattern (cairo_pattern_t *v);
...@@ -114,7 +113,6 @@ const GtkCssBorderImageRepeat *_gtk_css_value_get_border_image_repeat (const ...@@ -114,7 +113,6 @@ const GtkCssBorderImageRepeat *_gtk_css_value_get_border_image_repeat (const
PangoStyle _gtk_css_value_get_pango_style (const GtkCssValue *value); PangoStyle _gtk_css_value_get_pango_style (const GtkCssValue *value);
PangoVariant _gtk_css_value_get_pango_variant (const GtkCssValue *value); PangoVariant _gtk_css_value_get_pango_variant (const GtkCssValue *value);
PangoWeight _gtk_css_value_get_pango_weight (const GtkCssValue *value); PangoWeight _gtk_css_value_get_pango_weight (const GtkCssValue *value);
const GdkRGBA *_gtk_css_value_get_rgba (const GtkCssValue *value);
GtkGradient *_gtk_css_value_get_gradient (const GtkCssValue *value); GtkGradient *_gtk_css_value_get_gradient (const GtkCssValue *value);
G_END_DECLS G_END_DECLS
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <gobject/gvaluecollector.h> #include <gobject/gvaluecollector.h>
#include "gtkstylecontextprivate.h" #include "gtkstylecontextprivate.h"
#include "gtkcssrgbavalueprivate.h"
#include "gtkstylepropertiesprivate.h" #include "gtkstylepropertiesprivate.h"
#include "gtktypebuiltins.h" #include "gtktypebuiltins.h"
#include "gtkthemingengineprivate.h" #include "gtkthemingengineprivate.h"
...@@ -2783,7 +2784,7 @@ _gtk_style_context_resolve_color (GtkStyleContext *context, ...@@ -2783,7 +2784,7 @@ _gtk_style_context_resolve_color (GtkStyleContext *context,
if (val == NULL) if (val == NULL)
return FALSE; return FALSE;
*result = *_gtk_css_value_get_rgba (val); *result = *_gtk_css_rgba_value_get_rgba (val);
_gtk_css_value_unref (val); _gtk_css_value_unref (val);
return TRUE; return TRUE;
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
*/ */
#include "config.h" #include "config.h"
#include "gtkcssrgbavalueprivate.h"
#include "gtksymboliccolorprivate.h" #include "gtksymboliccolorprivate.h"
#include "gtkstyleproperties.h" #include "gtkstyleproperties.h"
#include "gtkintl.h" #include "gtkintl.h"
...@@ -104,7 +105,7 @@ gtk_symbolic_color_new_literal (const GdkRGBA *color) ...@@ -104,7 +105,7 @@ gtk_symbolic_color_new_literal (const GdkRGBA *color)
symbolic_color = g_slice_new0 (GtkSymbolicColor); symbolic_color = g_slice_new0 (GtkSymbolicColor);
symbolic_color->type = COLOR_TYPE_LITERAL; symbolic_color->type = COLOR_TYPE_LITERAL;
symbolic_color->last_value = _gtk_css_value_new_from_rgba (color); symbolic_color->last_value = _gtk_css_rgba_value_new_from_rgba (color);
symbolic_color->ref_count = 1; symbolic_color->ref_count = 1;
return symbolic_color; return symbolic_color;
...@@ -576,7 +577,7 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color, ...@@ -576,7 +577,7 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color,
if (v == NULL) if (v == NULL)
return FALSE; return FALSE;
*resolved_color = *_gtk_css_value_get_rgba (v); *resolved_color = *_gtk_css_rgba_value_get_rgba (v);
_gtk_css_value_unref (v); _gtk_css_value_unref (v);
return TRUE; return TRUE;
} }
...@@ -618,12 +619,12 @@ _gtk_symbolic_color_resolve_full (GtkSymbolicColor *color, ...@@ -618,12 +619,12 @@ _gtk_symbolic_color_resolve_full (GtkSymbolicColor *color,
if (val == NULL) if (val == NULL)
return NULL; return NULL;
shade = *_gtk_css_value_get_rgba (val); shade = *_gtk_css_rgba_value_get_rgba (val);
_shade_color (&shade, color->shade.factor); _shade_color (&shade, color->shade.factor);
_gtk_css_value_unref (val); _gtk_css_value_unref (val);
value = _gtk_css_value_new_from_rgba (&shade); value = _gtk_css_rgba_value_new_from_rgba (&shade);
} }
break; break;
...@@ -636,12 +637,12 @@ _gtk_symbolic_color_resolve_full (GtkSymbolicColor *color, ...@@ -636,12 +637,12 @@ _gtk_symbolic_color_resolve_full (GtkSymbolicColor *color,
if (val == NULL) if (val == NULL)
return NULL; return NULL;
alpha = *_gtk_css_value_get_rgba (val); alpha = *_gtk_css_rgba_value_get_rgba (val);
alpha.alpha = CLAMP (alpha.alpha * color->alpha.factor, 0, 1); alpha.alpha = CLAMP (alpha.alpha * color->alpha.factor, 0, 1);
_gtk_css_value_unref (val); _gtk_css_value_unref (val);
value = _gtk_css_value_new_from_rgba (&alpha); value = _gtk_css_rgba_value_new_from_rgba (&alpha);
} }
break; break;
...@@ -653,13 +654,13 @@ _gtk_symbolic_color_resolve_full (GtkSymbolicColor *color, ...@@ -653,13 +654,13 @@ _gtk_symbolic_color_resolve_full (GtkSymbolicColor *color,
val = _gtk_symbolic_color_resolve_full (color->mix.color1, func, data); val = _gtk_symbolic_color_resolve_full (color->mix.color1, func, data);
if (val == NULL) if (val == NULL)
return NULL; return NULL;
color1 = *_gtk_css_value_get_rgba (val); color1 = *_gtk_css_rgba_value_get_rgba (val);
_gtk_css_value_unref (val); _gtk_css_value_unref (val);
val = _gtk_symbolic_color_resolve_full (color->mix.color2, func, data); val = _gtk_symbolic_color_resolve_full (color->mix.color2, func, data);
if (val == NULL) if (val == NULL)
return NULL; return NULL;
color2 = *_gtk_css_value_get_rgba (val); color2 = *_gtk_css_rgba_value_get_rgba (val);
_gtk_css_value_unref (val); _gtk_css_value_unref (val);
...@@ -668,7 +669,7 @@ _gtk_symbolic_color_resolve_full (GtkSymbolicColor *color, ...@@ -668,7 +669,7 @@ _gtk_symbolic_color_resolve_full (GtkSymbolicColor *color,
res.blue = CLAMP (color1.blue + ((color2.blue - color1.blue) * color->mix.factor), 0, 1); res.blue = CLAMP (color1.blue + ((color2.blue - color1.blue) * color->mix.factor), 0, 1);
res.alpha = CLAMP (color1.alpha + ((color2.alpha - color1.alpha) * color->mix.factor), 0, 1); res.alpha = CLAMP (color1.alpha + ((color2.alpha - color1.alpha) * color->mix.factor), 0, 1);
value =_gtk_css_value_new_from_rgba (&res); value =_gtk_css_rgba_value_new_from_rgba (&res);
} }
break; break;
...@@ -681,7 +682,7 @@ _gtk_symbolic_color_resolve_full (GtkSymbolicColor *color, ...@@ -681,7 +682,7 @@ _gtk_symbolic_color_resolve_full (GtkSymbolicColor *color,
&res)) &res))
return NULL; return NULL;
value = _gtk_css_value_new_from_rgba (&res); value = _gtk_css_rgba_value_new_from_rgba (&res);
} }
break; break;
...@@ -695,8 +696,7 @@ _gtk_symbolic_color_resolve_full (GtkSymbolicColor *color, ...@@ -695,8 +696,7 @@ _gtk_symbolic_color_resolve_full (GtkSymbolicColor *color,
if (value != NULL) if (value != NULL)
{ {
if (color->last_value != NULL && if (color->last_value != NULL &&
gdk_rgba_equal (_gtk_css_value_get_rgba (color->last_value), _gtk_css_value_equal (color->last_value, value))
_gtk_css_value_get_rgba (value)))
{ {
_gtk_css_value_unref (value); _gtk_css_value_unref (value);
value = _gtk_css_value_ref (color->last_value); value = _gtk_css_value_ref (color->last_value);
...@@ -709,6 +709,7 @@ _gtk_symbolic_color_resolve_full (GtkSymbolicColor *color, ...@@ -709,6 +709,7 @@ _gtk_symbolic_color_resolve_full (GtkSymbolicColor *color,
} }
} }
_gtk_css_rgba_value_get_rgba (value);
return value; return value;
} }
...@@ -734,7 +735,7 @@ gtk_symbolic_color_to_string (GtkSymbolicColor *color) ...@@ -734,7 +735,7 @@ gtk_symbolic_color_to_string (GtkSymbolicColor *color)
switch (color->type) switch (color->type)
{ {
case COLOR_TYPE_LITERAL: case COLOR_TYPE_LITERAL:
s = gdk_rgba_to_string (_gtk_css_value_get_rgba (color->last_value)); s = gdk_rgba_to_string (_gtk_css_rgba_value_get_rgba (color->last_value));
break; break;
case COLOR_TYPE_NAME: case COLOR_TYPE_NAME:
s = g_strconcat ("@", color->name, NULL); s = g_strconcat ("@", color->name, NULL);
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "gtkmodulesprivate.h" #include "gtkmodulesprivate.h"
#include "gtkborderimageprivate.h" #include "gtkborderimageprivate.h"
#include "gtkpango.h" #include "gtkpango.h"