Commit 0111b9d5 authored by Benjamin Otte's avatar Benjamin Otte

symboliccolor: Treat it as a CssValue

.. now that it is one.
parent 0048c8ba
......@@ -288,7 +288,7 @@ _gtk_gradient_parse (GtkCssParser *parser)
return NULL;
}
color = _gtk_css_parser_read_symbolic_color (parser);
color = _gtk_symbolic_color_new_take_value (_gtk_css_symbolic_value_new (parser));
if (color == NULL)
{
gtk_gradient_unref (gradient);
......
......@@ -315,10 +315,9 @@ gtk_css_image_linear_parse (GtkCssImage *image,
do {
GtkCssImageLinearColorStop stop;
GtkSymbolicColor *symbolic;
symbolic = _gtk_css_parser_read_symbolic_color (parser);
if (symbolic == NULL)
stop.color = _gtk_css_symbolic_value_new (parser);
if (stop.color == NULL)
return FALSE;
if (_gtk_css_parser_has_number (parser))
......@@ -328,7 +327,7 @@ gtk_css_image_linear_parse (GtkCssImage *image,
| GTK_CSS_PARSE_LENGTH);
if (stop.offset == NULL)
{
gtk_symbolic_color_unref (symbolic);
_gtk_css_value_unref (stop.color);
return FALSE;
}
}
......@@ -337,7 +336,6 @@ gtk_css_image_linear_parse (GtkCssImage *image,
stop.offset = NULL;
}
stop.color = _gtk_css_value_new_take_symbolic_color (symbolic);
g_array_append_val (linear->stops, stop);
} while (_gtk_css_parser_try (parser, ",", TRUE));
......@@ -426,7 +424,7 @@ gtk_css_image_linear_compute (GtkCssImage *image,
copy->angle = _gtk_css_number_value_compute (linear->angle, context);
fallback = _gtk_css_value_new_take_symbolic_color (gtk_symbolic_color_new_literal (&transparent));
fallback = _gtk_css_symbolic_value_new_take_symbolic_color (gtk_symbolic_color_new_literal (&transparent));
g_array_set_size (copy->stops, linear->stops->len);
for (i = 0; i < linear->stops->len; i++)
{
......
......@@ -1942,7 +1942,7 @@ parse_import (GtkCssScanner *scanner)
static gboolean
parse_color_definition (GtkCssScanner *scanner)
{
GtkSymbolicColor *symbolic;
GtkCssValue *symbolic;
char *name;
gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_COLOR_DEFINITION);
......@@ -1966,7 +1966,7 @@ parse_color_definition (GtkCssScanner *scanner)
return TRUE;
}
symbolic = _gtk_css_parser_read_symbolic_color (scanner->parser);
symbolic = _gtk_css_symbolic_value_new (scanner->parser);
if (symbolic == NULL)
{
g_free (name);
......@@ -1978,7 +1978,7 @@ parse_color_definition (GtkCssScanner *scanner)
if (!_gtk_css_parser_try (scanner->parser, ";", TRUE))
{
g_free (name);
gtk_symbolic_color_unref (symbolic);
_gtk_css_value_unref (symbolic);
gtk_css_provider_error_literal (scanner->provider,
scanner,
GTK_CSS_PROVIDER_ERROR,
......
......@@ -95,15 +95,14 @@ _gtk_css_rgba_value_get_rgba (const GtkCssValue *rgba)
}
GtkCssValue *
_gtk_css_rgba_value_compute_from_symbolic (GtkCssValue *rgba,
_gtk_css_rgba_value_compute_from_symbolic (GtkCssValue *symbolic,
GtkCssValue *fallback,
GtkStyleContext *context,
gboolean for_color_property)
{
GtkSymbolicColor *symbolic;
GtkCssValue *resolved, *current;
g_return_val_if_fail (rgba != NULL, NULL);
g_return_val_if_fail (symbolic != NULL, NULL);
/* The computed value of the ‘currentColor’ keyword is the computed
* value of the ‘color’ property. If the ‘currentColor’ keyword is
......
......@@ -29,7 +29,7 @@ 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 *symbolic,
GtkCssValue *fallback,
GtkStyleContext *context,
gboolean for_color_property);
......
......@@ -234,13 +234,10 @@ _gtk_css_shadow_value_parse (GtkCssParser *parser)
}
else if (values[COLOR] == NULL)
{
GtkSymbolicColor *symbolic;
values[COLOR] = _gtk_css_symbolic_value_new (parser);
symbolic = _gtk_css_parser_read_symbolic_color (parser);
if (symbolic == NULL)
if (values[COLOR] == NULL)
goto fail;
values[COLOR] = _gtk_css_value_new_take_symbolic_color (symbolic);
}
else
{
......@@ -253,7 +250,7 @@ _gtk_css_shadow_value_parse (GtkCssParser *parser)
while (values[HOFFSET] == NULL || !value_is_done_parsing (parser));
if (values[COLOR] == NULL)
values[COLOR] = _gtk_css_value_new_take_symbolic_color (
values[COLOR] = _gtk_css_symbolic_value_new_take_symbolic_color (
gtk_symbolic_color_ref (
_gtk_symbolic_color_get_current_color ()));
......@@ -278,7 +275,7 @@ _gtk_css_shadow_value_compute (GtkCssValue *shadow,
GtkCssValue *color;
color = _gtk_css_rgba_value_compute_from_symbolic (shadow->color,
_gtk_css_value_new_take_symbolic_color (
_gtk_css_symbolic_value_new_take_symbolic_color (
gtk_symbolic_color_ref (
_gtk_symbolic_color_get_current_color ())),
context,
......
......@@ -216,17 +216,14 @@ parse_border_color (GtkCssShorthandProperty *shorthand,
GtkCssParser *parser,
GFile *base)
{
GtkSymbolicColor *symbolic;
guint i;
for (i = 0; i < 4; i++)
{
symbolic = _gtk_css_parser_read_symbolic_color (parser);
if (symbolic == NULL)
values[i] = _gtk_css_symbolic_value_new (parser);
if (values[i] == NULL)
return FALSE;
values[i] = _gtk_css_value_new_take_symbolic_color (symbolic);
if (value_is_done_parsing (parser))
break;
}
......@@ -358,13 +355,9 @@ parse_border_side (GtkCssShorthandProperty *shorthand,
}
else if (values[2] == NULL)
{
GtkSymbolicColor *symbolic;
symbolic = _gtk_css_parser_read_symbolic_color (parser);
if (symbolic == NULL)
values[2] = _gtk_css_symbolic_value_new (parser);
if (values[2] == NULL)
return FALSE;
values[2] = _gtk_css_value_new_take_symbolic_color (symbolic);
}
}
while (!value_is_done_parsing (parser));
......@@ -402,13 +395,10 @@ parse_border (GtkCssShorthandProperty *shorthand,
}
else if (!G_IS_VALUE (&values[8]))
{
GtkSymbolicColor *symbolic;
symbolic = _gtk_css_parser_read_symbolic_color (parser);
if (symbolic == NULL)
values[8] = _gtk_css_symbolic_value_new (parser);
if (values[8] == NULL)
return FALSE;
values[8] = _gtk_css_value_new_take_symbolic_color (symbolic);
values[9] = _gtk_css_value_ref (values[8]);
values[10] = _gtk_css_value_ref (values[8]);
values[11] = _gtk_css_value_ref (values[8]);
......@@ -516,13 +506,9 @@ parse_background (GtkCssShorthandProperty *shorthand,
}
else if (values[4] == NULL)
{
GtkSymbolicColor *symbolic;
symbolic = _gtk_css_parser_read_symbolic_color (parser);
if (symbolic == NULL)
values[4] = _gtk_css_symbolic_value_new (parser);
if (values[4] == NULL)
return FALSE;
values[4] = _gtk_css_value_new_take_symbolic_color (symbolic);
}
else
{
......
......@@ -169,7 +169,7 @@ rgba_value_parse (GtkCssParser *parser,
GtkSymbolicColor *symbolic;
GdkRGBA rgba;
symbolic = _gtk_css_parser_read_symbolic_color (parser);
symbolic = _gtk_symbolic_color_new_take_value (_gtk_css_symbolic_value_new (parser));
if (symbolic == NULL)
return FALSE;
......@@ -212,12 +212,10 @@ rgba_value_compute (GtkStyleContext *context,
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_boxed (specified);
GdkRGBA rgba;
if (symbolic == _gtk_symbolic_color_get_current_color ())
rgba = *_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR));
else if (!gtk_symbolic_color_resolve (symbolic, NULL, &rgba))
if (!_gtk_style_context_resolve_color (context, symbolic, &rgba))
rgba = white;
return _gtk_css_value_new_from_boxed (GDK_TYPE_RGBA, &rgba);
......@@ -234,7 +232,7 @@ color_value_parse (GtkCssParser *parser,
GtkSymbolicColor *symbolic;
GdkRGBA rgba;
symbolic = _gtk_css_parser_read_symbolic_color (parser);
symbolic = _gtk_symbolic_color_new_take_value (_gtk_css_symbolic_value_new (parser));
if (symbolic == NULL)
return FALSE;
......@@ -284,7 +282,7 @@ color_value_compute (GtkStyleContext *context,
if (_gtk_css_value_holds (specified, GTK_TYPE_SYMBOLIC_COLOR))
{
if (_gtk_style_context_resolve_color (context,
_gtk_css_value_get_symbolic_color (specified),
_gtk_css_value_get_boxed (specified),
&rgba))
{
color.red = rgba.red * 65535. + 0.5;
......@@ -305,7 +303,7 @@ symbolic_color_value_parse (GtkCssParser *parser,
{
GtkSymbolicColor *symbolic;
symbolic = _gtk_css_parser_read_symbolic_color (parser);
symbolic = _gtk_symbolic_color_new_take_value (_gtk_css_symbolic_value_new (parser));
if (symbolic == NULL)
return FALSE;
......
......@@ -181,13 +181,7 @@ color_parse (GtkCssStyleProperty *property,
GtkCssParser *parser,
GFile *base)
{
GtkSymbolicColor *symbolic;
symbolic = _gtk_css_parser_read_symbolic_color (parser);
if (symbolic == NULL)
return NULL;
return _gtk_css_value_new_take_symbolic_color (symbolic);
return _gtk_css_symbolic_value_new (parser);
}
static GtkCssValue *
......@@ -938,7 +932,7 @@ _gtk_css_style_property_init_properties (void)
color_query,
color_assign,
NULL,
_gtk_css_value_new_take_symbolic_color (
_gtk_css_symbolic_value_new_take_symbolic_color (
gtk_symbolic_color_new_rgba (1, 1, 1, 1)));
gtk_css_style_property_register ("font-size",
GTK_CSS_PROPERTY_FONT_SIZE,
......@@ -965,7 +959,7 @@ _gtk_css_style_property_init_properties (void)
color_query,
color_assign,
NULL,
_gtk_css_value_new_take_symbolic_color (
_gtk_css_symbolic_value_new_take_symbolic_color (
gtk_symbolic_color_new_rgba (0, 0, 0, 0)));
gtk_css_style_property_register ("font-family",
......@@ -1368,7 +1362,7 @@ _gtk_css_style_property_init_properties (void)
color_query,
color_assign,
NULL,
_gtk_css_value_new_take_symbolic_color (
_gtk_css_symbolic_value_new_take_symbolic_color (
gtk_symbolic_color_ref (
_gtk_symbolic_color_get_current_color ())));
gtk_css_style_property_register ("border-right-color",
......@@ -1381,7 +1375,7 @@ _gtk_css_style_property_init_properties (void)
color_query,
color_assign,
NULL,
_gtk_css_value_new_take_symbolic_color (
_gtk_css_symbolic_value_new_take_symbolic_color (
gtk_symbolic_color_ref (
_gtk_symbolic_color_get_current_color ())));
gtk_css_style_property_register ("border-bottom-color",
......@@ -1394,7 +1388,7 @@ _gtk_css_style_property_init_properties (void)
color_query,
color_assign,
NULL,
_gtk_css_value_new_take_symbolic_color (
_gtk_css_symbolic_value_new_take_symbolic_color (
gtk_symbolic_color_ref (
_gtk_symbolic_color_get_current_color ())));
gtk_css_style_property_register ("border-left-color",
......@@ -1407,7 +1401,7 @@ _gtk_css_style_property_init_properties (void)
color_query,
color_assign,
NULL,
_gtk_css_value_new_take_symbolic_color (
_gtk_css_symbolic_value_new_take_symbolic_color (
gtk_symbolic_color_ref (
_gtk_symbolic_color_get_current_color ())));
gtk_css_style_property_register ("outline-color",
......@@ -1420,7 +1414,7 @@ _gtk_css_style_property_init_properties (void)
color_query,
color_assign,
NULL,
_gtk_css_value_new_take_symbolic_color (
_gtk_css_symbolic_value_new_take_symbolic_color (
gtk_symbolic_color_ref (
_gtk_symbolic_color_get_current_color ())));
......
......@@ -87,7 +87,6 @@ GtkCssValue *_gtk_css_value_new_take_strv (char
GtkCssValue *_gtk_css_value_new_from_boxed (GType type,
gpointer boxed);
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_pattern (cairo_pattern_t *v);
GtkCssValue *_gtk_css_value_new_take_binding_sets (GPtrArray *array);
void _gtk_css_value_init_gvalue (const GtkCssValue *value,
......@@ -99,7 +98,6 @@ gpointer _gtk_css_value_dup_object (const
gpointer _gtk_css_value_get_object (const GtkCssValue *value);
gpointer _gtk_css_value_get_boxed (const GtkCssValue *value);
const char ** _gtk_css_value_get_strv (const GtkCssValue *value);
GtkSymbolicColor *_gtk_css_value_get_symbolic_color (const GtkCssValue *value);
GtkGradient *_gtk_css_value_get_gradient (const GtkCssValue *value);
G_END_DECLS
......
......@@ -2525,13 +2525,13 @@ gtk_style_context_color_lookup_func (gpointer contextp,
GtkCssValue *
_gtk_style_context_resolve_color_value (GtkStyleContext *context,
GtkCssValue *current,
GtkSymbolicColor *color)
GtkCssValue *color)
{
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE);
g_return_val_if_fail (current != NULL, FALSE);
g_return_val_if_fail (color != NULL, FALSE);
return _gtk_symbolic_color_resolve_full (color,
return _gtk_symbolic_color_resolve_full ((GtkSymbolicColor *) color,
current,
gtk_style_context_color_lookup_func,
context);
......
......@@ -46,7 +46,7 @@ gboolean _gtk_style_context_resolve_color (GtkStyleContext *
GdkRGBA *result);
GtkCssValue * _gtk_style_context_resolve_color_value (GtkStyleContext *context,
GtkCssValue *current,
GtkSymbolicColor *color);
GtkCssValue *color);
void _gtk_style_context_get_cursor_color (GtkStyleContext *context,
GdkRGBA *primary_color,
GdkRGBA *secondary_color);
......
......@@ -872,6 +872,8 @@ typedef enum {
COLOR_WIN32
} ColorParseType;
static GtkSymbolicColor * gtk_css_parser_read_symbolic_color (GtkCssParser *parser);
static GtkSymbolicColor *
gtk_css_parser_read_symbolic_color_function (GtkCssParser *parser,
ColorParseType color)
......@@ -946,7 +948,7 @@ gtk_css_parser_read_symbolic_color_function (GtkCssParser *parser,
}
else
{
child1 = _gtk_css_parser_read_symbolic_color (parser);
child1 = gtk_css_parser_read_symbolic_color (parser);
if (child1 == NULL)
return NULL;
......@@ -959,7 +961,7 @@ gtk_css_parser_read_symbolic_color_function (GtkCssParser *parser,
return NULL;
}
child2 = _gtk_css_parser_read_symbolic_color (parser);
child2 = gtk_css_parser_read_symbolic_color (parser);
if (child2 == NULL)
{
gtk_symbolic_color_unref (child1);
......@@ -1027,8 +1029,8 @@ gtk_css_parser_read_symbolic_color_function (GtkCssParser *parser,
return symbolic;
}
GtkSymbolicColor *
_gtk_css_parser_read_symbolic_color (GtkCssParser *parser)
static GtkSymbolicColor *
gtk_css_parser_read_symbolic_color (GtkCssParser *parser)
{
GtkSymbolicColor *symbolic;
GdkRGBA rgba;
......@@ -1037,8 +1039,6 @@ _gtk_css_parser_read_symbolic_color (GtkCssParser *parser)
GTK_WIN32_THEME_SYMBOLIC_COLOR_NAME};
char *name;
g_return_val_if_fail (parser != NULL, NULL);
if (_gtk_css_parser_try (parser, "currentColor", TRUE))
return gtk_symbolic_color_ref (_gtk_symbolic_color_get_current_color ());
......@@ -1099,3 +1099,11 @@ _gtk_css_parser_read_symbolic_color (GtkCssParser *parser)
return NULL;
}
GtkCssValue *
_gtk_css_symbolic_value_new (GtkCssParser *parser)
{
g_return_val_if_fail (parser != NULL, NULL);
return _gtk_css_symbolic_value_new_take_symbolic_color (gtk_css_parser_read_symbolic_color (parser));
}
......@@ -33,7 +33,20 @@ GtkCssValue * _gtk_symbolic_color_resolve_full (GtkSymbolicColor
GtkSymbolicColor * _gtk_symbolic_color_get_current_color (void);
GtkSymbolicColor * _gtk_css_parser_read_symbolic_color (GtkCssParser *parser);
GtkCssValue * _gtk_css_symbolic_value_new (GtkCssParser *parser);
/* I made these inline functions instead of macros to gain type safety for the arguments passed in. */
static inline GtkSymbolicColor *
_gtk_symbolic_color_new_take_value (GtkCssValue *value)
{
return (GtkSymbolicColor *) value;
}
static inline GtkCssValue *
_gtk_css_symbolic_value_new_take_symbolic_color (GtkSymbolicColor *color)
{
return (GtkCssValue *) color;
}
G_END_DECLS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment