diff --git a/gtk/deprecated/gtkstylecontext.c b/gtk/deprecated/gtkstylecontext.c index c81e719dc6..8c55162a48 100644 --- a/gtk/deprecated/gtkstylecontext.c +++ b/gtk/deprecated/gtkstylecontext.c @@ -789,9 +789,7 @@ gtk_style_context_resolve_color (GtkStyleContext *context, if (gtk_css_node_get_parent (priv->cssnode)) ctx.parent_style = gtk_css_node_get_style (gtk_css_node_get_parent (priv->cssnode)); - val = gtk_css_color_value_resolve (color, - &ctx, - _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR)); + val = gtk_css_value_resolve (color, &ctx, _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR)); if (val == NULL) return FALSE; diff --git a/gtk/gtkaboutdialog.c b/gtk/gtkaboutdialog.c index 004f9466c0..385b167af3 100644 --- a/gtk/gtkaboutdialog.c +++ b/gtk/gtkaboutdialog.c @@ -724,10 +724,10 @@ update_links_cb (GtkAboutDialog *about) GSList *l; style = gtk_css_node_get_style (about->link_node); - link_color = *gtk_css_color_value_get_rgba (style->core->color); + link_color = *gtk_css_color_value_get_rgba (style->used->color); style = gtk_css_node_get_style (about->visited_link_node); - visited_link_color = *gtk_css_color_value_get_rgba (style->core->color); + visited_link_color = *gtk_css_color_value_get_rgba (style->used->color); for (l = about->link_tags; l != NULL; l = l->next) { diff --git a/gtk/gtkcssarrayvalue.c b/gtk/gtkcssarrayvalue.c index 70116e2db4..8d88c4b1c4 100644 --- a/gtk/gtkcssarrayvalue.c +++ b/gtk/gtkcssarrayvalue.c @@ -74,6 +74,40 @@ gtk_css_value_array_compute (GtkCssValue *value, return result; } +static GtkCssValue * +gtk_css_value_array_resolve (GtkCssValue *value, + GtkCssComputeContext *context, + GtkCssValue *current) +{ + GtkCssValue *result; + GtkCssValue *i_value; + guint i, j; + + result = NULL; + for (i = 0; i < value->n_values; i++) + { + i_value = gtk_css_value_resolve (value->values[i], context, current); + + if (result == NULL && + i_value != value->values[i]) + { + result = _gtk_css_array_value_new_from_array (value->values, value->n_values); + for (j = 0; j < i; j++) + gtk_css_value_ref (result->values[j]); + } + + if (result != NULL) + result->values[i] = i_value; + else + gtk_css_value_unref (i_value); + } + + if (result == NULL) + return gtk_css_value_ref (value); + + return result; +} + static gboolean gtk_css_value_array_equal (const GtkCssValue *value1, const GtkCssValue *value2) @@ -364,6 +398,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_ARRAY = { "GtkCssArrayValue", gtk_css_value_array_free, gtk_css_value_array_compute, + gtk_css_value_array_resolve, gtk_css_value_array_equal, gtk_css_value_array_transition, gtk_css_value_array_is_dynamic, @@ -398,6 +433,7 @@ _gtk_css_array_value_new_from_array (GtkCssValue **values, result->is_computed = TRUE; result->contains_variables = FALSE; + result->contains_current_color = FALSE; for (i = 0; i < n_values; i ++) { if (!gtk_css_value_is_computed (values[i])) @@ -406,7 +442,10 @@ _gtk_css_array_value_new_from_array (GtkCssValue **values, if (gtk_css_value_contains_variables (values[i])) result->contains_variables = TRUE; - if (!result->is_computed && result->contains_variables) + if (gtk_css_value_contains_current_color (values[i])) + result->contains_current_color = TRUE; + + if (!result->is_computed && result->contains_variables && result->contains_current_color) break; } @@ -468,5 +507,3 @@ _gtk_css_array_value_get_n_values (const GtkCssValue *value) return value->n_values; } - - diff --git a/gtk/gtkcssarrayvalueprivate.h b/gtk/gtkcssarrayvalueprivate.h index 675a7d73f4..9e81bc37df 100644 --- a/gtk/gtkcssarrayvalueprivate.h +++ b/gtk/gtkcssarrayvalueprivate.h @@ -37,6 +37,5 @@ GtkCssValue * _gtk_css_array_value_get_nth (GtkCssValue * guint i); guint _gtk_css_array_value_get_n_values (const GtkCssValue *value) G_GNUC_PURE; - G_END_DECLS diff --git a/gtk/gtkcssbgsizevalue.c b/gtk/gtkcssbgsizevalue.c index 33e2fb4376..8e2e8b38e1 100644 --- a/gtk/gtkcssbgsizevalue.c +++ b/gtk/gtkcssbgsizevalue.c @@ -154,6 +154,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_BG_SIZE = { "GtkCssBgSizeValue", gtk_css_value_bg_size_free, gtk_css_value_bg_size_compute, + NULL, gtk_css_value_bg_size_equal, gtk_css_value_bg_size_transition, NULL, diff --git a/gtk/gtkcssbordervalue.c b/gtk/gtkcssbordervalue.c index b8ecb88333..8c8eaaf521 100644 --- a/gtk/gtkcssbordervalue.c +++ b/gtk/gtkcssbordervalue.c @@ -141,6 +141,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_BORDER = { "GtkCssBorderValue", gtk_css_value_border_free, gtk_css_value_border_compute, + NULL, gtk_css_value_border_equal, gtk_css_value_border_transition, NULL, diff --git a/gtk/gtkcsscolorvalue.c b/gtk/gtkcsscolorvalue.c index e7bdd3a8a3..b7946bc911 100644 --- a/gtk/gtkcsscolorvalue.c +++ b/gtk/gtkcsscolorvalue.c @@ -46,6 +46,9 @@ static GtkCssValue * gtk_css_color_value_new_color_mix (GtkCssColorSpace GtkCssValue *color2, float percentage1, float percentage2); +static GtkCssValue * gtk_css_color_value_resolve (GtkCssValue *color, + GtkCssComputeContext *context, + GtkCssValue *current); typedef enum { COLOR_TYPE_COLOR, @@ -193,13 +196,21 @@ gtk_css_value_color_compute (GtkCssValue *value, guint property_id, GtkCssComputeContext *context) { - GtkCssValue *resolved; + GtkCssValue *computed; - resolved = gtk_css_color_value_resolve (value, context, NULL); - if (resolved == NULL) + computed = gtk_css_color_value_resolve (value, context, NULL); + if (computed == NULL) return gtk_css_value_color_get_fallback (property_id, context); - return resolved; + return computed; +} + +static GtkCssValue * +gtk_css_value_color_resolve (GtkCssValue *value, + GtkCssComputeContext *context, + GtkCssValue *current) +{ + return gtk_css_color_value_resolve (value, context, current); } static gboolean @@ -512,6 +523,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_COLOR = { "GtkCssColorValue", gtk_css_value_color_free, gtk_css_value_color_compute, + gtk_css_value_color_resolve, gtk_css_value_color_equal, gtk_css_value_color_transition, NULL, @@ -798,7 +810,7 @@ gtk_css_color_value_do_resolve (GtkCssValue *color, * to fully resolve color values that contain currentcolor * references */ -GtkCssValue * +static GtkCssValue * gtk_css_color_value_resolve (GtkCssValue *color, GtkCssComputeContext *context, GtkCssValue *current) diff --git a/gtk/gtkcsscolorvalueprivate.h b/gtk/gtkcsscolorvalueprivate.h index 99b4048845..69fe450ede 100644 --- a/gtk/gtkcsscolorvalueprivate.h +++ b/gtk/gtkcsscolorvalueprivate.h @@ -33,10 +33,6 @@ GtkCssValue * gtk_css_color_value_new_name (const char *name) G gboolean gtk_css_color_value_can_parse (GtkCssParser *parser); GtkCssValue * gtk_css_color_value_parse (GtkCssParser *parser); -GtkCssValue * gtk_css_color_value_resolve (GtkCssValue *color, - GtkCssComputeContext *context, - GtkCssValue *current); - const GdkRGBA * gtk_css_color_value_get_rgba (const GtkCssValue *color) G_GNUC_CONST; GtkCssValue * gtk_css_color_value_new_color (GtkCssColorSpace color_space, diff --git a/gtk/gtkcsscornervalue.c b/gtk/gtkcsscornervalue.c index ec9e6190de..8114e2d206 100644 --- a/gtk/gtkcsscornervalue.c +++ b/gtk/gtkcsscornervalue.c @@ -100,6 +100,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_CORNER = { "GtkCssCornerValue", gtk_css_value_corner_free, gtk_css_value_corner_compute, + NULL, gtk_css_value_corner_equal, gtk_css_value_corner_transition, NULL, diff --git a/gtk/gtkcsseasevalue.c b/gtk/gtkcsseasevalue.c index ca44e7d434..536277454a 100644 --- a/gtk/gtkcsseasevalue.c +++ b/gtk/gtkcsseasevalue.c @@ -136,6 +136,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_EASE = { "GtkCssEaseValue", gtk_css_value_ease_free, gtk_css_value_ease_compute, + NULL, gtk_css_value_ease_equal, gtk_css_value_ease_transition, NULL, diff --git a/gtk/gtkcssenumvalue.c b/gtk/gtkcssenumvalue.c index 8446b37f7b..8876556916 100644 --- a/gtk/gtkcssenumvalue.c +++ b/gtk/gtkcssenumvalue.c @@ -77,6 +77,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_BORDER_STYLE = { "GtkCssBorderStyleValue", gtk_css_value_enum_free, gtk_css_value_enum_compute, + NULL, gtk_css_value_enum_equal, gtk_css_value_enum_transition, NULL, @@ -135,6 +136,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_BLEND_MODE = { "GtkCssBlendModeValue", gtk_css_value_enum_free, gtk_css_value_enum_compute, + NULL, gtk_css_value_enum_equal, gtk_css_value_enum_transition, NULL, @@ -288,6 +290,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_SIZE = { "GtkCssFontSizeValue", gtk_css_value_enum_free, gtk_css_value_font_size_compute, + NULL, gtk_css_value_enum_equal, gtk_css_value_enum_transition, NULL, @@ -345,6 +348,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_STYLE = { "GtkCssFontStyleValue", gtk_css_value_enum_free, gtk_css_value_enum_compute, + NULL, gtk_css_value_enum_equal, gtk_css_value_enum_transition, NULL, @@ -442,6 +446,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_WEIGHT = { "GtkCssFontWeightValue", gtk_css_value_enum_free, gtk_css_value_font_weight_compute, + NULL, gtk_css_value_enum_equal, NULL, NULL, @@ -492,6 +497,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_STRETCH = { "GtkCssFontStretchValue", gtk_css_value_enum_free, gtk_css_value_enum_compute, + NULL, gtk_css_value_enum_equal, gtk_css_value_enum_transition, NULL, @@ -549,6 +555,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_TEXT_DECORATION_STYLE = { "GtkCssTextDecorationStyleValue", gtk_css_value_enum_free, gtk_css_value_enum_compute, + NULL, gtk_css_value_enum_equal, gtk_css_value_enum_transition, NULL, @@ -600,6 +607,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_AREA = { "GtkCssAreaValue", gtk_css_value_enum_free, gtk_css_value_enum_compute, + NULL, gtk_css_value_enum_equal, gtk_css_value_enum_transition, NULL, @@ -657,6 +665,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_DIRECTION = { "GtkCssDirectionValue", gtk_css_value_enum_free, gtk_css_value_enum_compute, + NULL, gtk_css_value_enum_equal, gtk_css_value_enum_transition, NULL, @@ -718,6 +727,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_PLAY_STATE = { "GtkCssPlayStateValue", gtk_css_value_enum_free, gtk_css_value_enum_compute, + NULL, gtk_css_value_enum_equal, gtk_css_value_enum_transition, NULL, @@ -774,6 +784,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_FILL_MODE = { "GtkCssFillModeValue", gtk_css_value_enum_free, gtk_css_value_enum_compute, + NULL, gtk_css_value_enum_equal, gtk_css_value_enum_transition, NULL, @@ -832,6 +843,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_ICON_STYLE = { "GtkCssIconStyleValue", gtk_css_value_enum_free, gtk_css_value_enum_compute, + NULL, gtk_css_value_enum_equal, gtk_css_value_enum_transition, NULL, @@ -889,6 +901,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_KERNING = { "GtkCssFontKerningValue", gtk_css_value_enum_free, gtk_css_value_enum_compute, + NULL, gtk_css_value_enum_equal, gtk_css_value_enum_transition, NULL, @@ -946,6 +959,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT_POSITION = { "GtkCssFontVariationPositionValue", gtk_css_value_enum_free, gtk_css_value_enum_compute, + NULL, gtk_css_value_enum_equal, gtk_css_value_enum_transition, NULL, @@ -1003,6 +1017,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT_CAPS = { "GtkCssFontVariantCapsValue", gtk_css_value_enum_free, gtk_css_value_enum_compute, + NULL, gtk_css_value_enum_equal, gtk_css_value_enum_transition, NULL, @@ -1064,6 +1079,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT_ALTERNATE = { "GtkCssFontVariantAlternateValue", gtk_css_value_enum_free, gtk_css_value_enum_compute, + NULL, gtk_css_value_enum_equal, gtk_css_value_enum_transition, NULL, @@ -1172,6 +1188,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_TEXT_DECORATION_LINE = { "GtkCssTextDecorationLine", gtk_css_value_enum_free, gtk_css_value_enum_compute, + NULL, gtk_css_value_flags_equal, gtk_css_value_enum_transition, NULL, @@ -1271,6 +1288,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT_LIGATURE = { "GtkCssFontVariantLigatureValue", gtk_css_value_enum_free, gtk_css_value_enum_compute, + NULL, gtk_css_value_flags_equal, gtk_css_value_enum_transition, NULL, @@ -1379,6 +1397,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT_NUMERIC = { "GtkCssFontVariantNumbericValue", gtk_css_value_enum_free, gtk_css_value_enum_compute, + NULL, gtk_css_value_flags_equal, gtk_css_value_enum_transition, NULL, @@ -1484,6 +1503,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT_EAST_ASIAN = { "GtkCssFontVariantEastAsianValue", gtk_css_value_enum_free, gtk_css_value_enum_compute, + NULL, gtk_css_value_flags_equal, gtk_css_value_enum_transition, NULL, @@ -1573,6 +1593,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_TEXT_TRANSFORM = { "GtkCssTextTransformValue", gtk_css_value_enum_free, gtk_css_value_enum_compute, + NULL, gtk_css_value_enum_equal, gtk_css_value_enum_transition, NULL, diff --git a/gtk/gtkcssfiltervalue.c b/gtk/gtkcssfiltervalue.c index 1694a9753b..f2ab51ef3e 100644 --- a/gtk/gtkcssfiltervalue.c +++ b/gtk/gtkcssfiltervalue.c @@ -710,6 +710,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_FILTER = { "GtkCssFilterValue", gtk_css_value_filter_free, gtk_css_value_filter_compute, + NULL, gtk_css_value_filter_equal, gtk_css_value_filter_transition, NULL, diff --git a/gtk/gtkcssfontfeaturesvalue.c b/gtk/gtkcssfontfeaturesvalue.c index 6799f58a9e..d06edb0df9 100644 --- a/gtk/gtkcssfontfeaturesvalue.c +++ b/gtk/gtkcssfontfeaturesvalue.c @@ -156,6 +156,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_FEATURES = { "GtkCssFontFeaturesValue", gtk_css_value_font_features_free, gtk_css_value_font_features_compute, + NULL, gtk_css_value_font_features_equal, gtk_css_value_font_features_transition, NULL, diff --git a/gtk/gtkcssfontvariationsvalue.c b/gtk/gtkcssfontvariationsvalue.c index 0d64a09618..7c0971b97e 100644 --- a/gtk/gtkcssfontvariationsvalue.c +++ b/gtk/gtkcssfontvariationsvalue.c @@ -157,6 +157,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIATIONS = { "GtkCssFontVariationsValue", gtk_css_value_font_variations_free, gtk_css_value_font_variations_compute, + NULL, gtk_css_value_font_variations_equal, gtk_css_value_font_variations_transition, NULL, diff --git a/gtk/gtkcssimageconic.c b/gtk/gtkcssimageconic.c index 4f1a290f70..abd5b58cda 100644 --- a/gtk/gtkcssimageconic.c +++ b/gtk/gtkcssimageconic.c @@ -586,7 +586,7 @@ gtk_css_image_conic_resolve (GtkCssImage *image, else resolved->color_stops[i].offset = NULL; - resolved->color_stops[i].color = gtk_css_color_value_resolve (self->color_stops[i].color, context, current_color); + resolved->color_stops[i].color = gtk_css_value_resolve (self->color_stops[i].color, context, current_color); } return GTK_CSS_IMAGE (resolved); diff --git a/gtk/gtkcssimagefallback.c b/gtk/gtkcssimagefallback.c index f081d318fa..1bea6b7362 100644 --- a/gtk/gtkcssimagefallback.c +++ b/gtk/gtkcssimagefallback.c @@ -340,7 +340,7 @@ gtk_css_image_fallback_resolve (GtkCssImage *image, GtkCssValue *resolved_color = NULL; if (fallback->color) - resolved_color = gtk_css_color_value_resolve (fallback->color, context, current_color); + resolved_color = gtk_css_value_resolve (fallback->color, context, current_color); /* image($color) that didn't change */ if (resolved_color && !fallback->images && resolved_color == fallback->color) diff --git a/gtk/gtkcssimageicontheme.c b/gtk/gtkcssimageicontheme.c index 85fbe0c5fd..a221875789 100644 --- a/gtk/gtkcssimageicontheme.c +++ b/gtk/gtkcssimageicontheme.c @@ -240,7 +240,7 @@ gtk_css_image_icon_theme_resolve (GtkCssImage *image, copy->scale = icon_theme->scale; for (guint i = 0; i < 4; i++) - copy->colors[i] = gtk_css_color_value_resolve (icon_theme->colors[i], context, current); + copy->colors[i] = gtk_css_value_resolve (icon_theme->colors[i], context, current); return GTK_CSS_IMAGE (copy); } diff --git a/gtk/gtkcssimagelinear.c b/gtk/gtkcssimagelinear.c index 3ae0e8cd1c..abf3f6f1ae 100644 --- a/gtk/gtkcssimagelinear.c +++ b/gtk/gtkcssimagelinear.c @@ -787,7 +787,7 @@ gtk_css_image_linear_resolve (GtkCssImage *image, const GtkCssImageLinearColorStop *stop = &linear->color_stops[i]; GtkCssImageLinearColorStop *scopy = ©->color_stops[i]; - scopy->color = gtk_css_color_value_resolve (stop->color, context, current_color); + scopy->color = gtk_css_value_resolve (stop->color, context, current_color); if (stop->offset) scopy->offset = gtk_css_value_ref (stop->offset); diff --git a/gtk/gtkcssimageradial.c b/gtk/gtkcssimageradial.c index 5cbe25d126..2a90878101 100644 --- a/gtk/gtkcssimageradial.c +++ b/gtk/gtkcssimageradial.c @@ -794,7 +794,7 @@ gtk_css_image_radial_resolve (GtkCssImage *image, const GtkCssImageRadialColorStop *stop = &radial->color_stops[i]; GtkCssImageRadialColorStop *scopy = ©->color_stops[i]; - scopy->color = gtk_css_color_value_resolve (stop->color, context, current_color); + scopy->color = gtk_css_value_resolve (stop->color, context, current_color); if (stop->offset) scopy->offset = gtk_css_value_ref (stop->offset); diff --git a/gtk/gtkcssimagerecolor.c b/gtk/gtkcssimagerecolor.c index 8534930916..fb3270e833 100644 --- a/gtk/gtkcssimagerecolor.c +++ b/gtk/gtkcssimagerecolor.c @@ -323,8 +323,8 @@ gtk_css_image_recolor_resolve (GtkCssImage *image, img = g_object_new (GTK_TYPE_CSS_IMAGE_RECOLOR, NULL); - img->palette = gtk_css_palette_value_resolve (recolor->palette, context, current_color); - img->color = gtk_css_color_value_resolve (recolor->color, context, current_color); + img->palette = gtk_css_value_resolve (recolor->palette, context, current_color); + img->color = gtk_css_value_resolve (recolor->color, context, current_color); img->file = g_object_ref (recolor->file); if (recolor->texture) img->texture = g_object_ref (recolor->texture); diff --git a/gtk/gtkcssimagevalue.c b/gtk/gtkcssimagevalue.c index de3e607b11..5a7e951693 100644 --- a/gtk/gtkcssimagevalue.c +++ b/gtk/gtkcssimagevalue.c @@ -56,6 +56,17 @@ gtk_css_value_image_compute (GtkCssValue *value, return _gtk_css_image_value_new (computed); } +static GtkCssValue * +gtk_css_value_image_resolve (GtkCssValue *value, + GtkCssComputeContext *context, + GtkCssValue *current_color) +{ + if (!gtk_css_value_contains_current_color (value)) + return gtk_css_value_ref (value); + + return _gtk_css_image_value_new (gtk_css_image_resolve (_gtk_css_image_value_get_image (value), context, current_color)); +} + static gboolean gtk_css_value_image_equal (const GtkCssValue *value1, const GtkCssValue *value2) @@ -124,6 +135,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_IMAGE = { "GtkCssImageValue", gtk_css_value_image_free, gtk_css_value_image_compute, + gtk_css_value_image_resolve, gtk_css_value_image_equal, gtk_css_value_image_transition, gtk_css_value_image_is_dynamic, @@ -155,14 +167,3 @@ _gtk_css_image_value_get_image (const GtkCssValue *value) return value->image; } - -GtkCssValue * -gtk_css_image_value_resolve (GtkCssValue *value, - GtkCssComputeContext *context, - GtkCssValue *current_color) -{ - if (!gtk_css_value_contains_current_color (value)) - return gtk_css_value_ref (value); - - return _gtk_css_image_value_new (gtk_css_image_resolve (_gtk_css_image_value_get_image (value), context, current_color)); -} diff --git a/gtk/gtkcssimagevalueprivate.h b/gtk/gtkcssimagevalueprivate.h index b130ba0397..70a4523619 100644 --- a/gtk/gtkcssimagevalueprivate.h +++ b/gtk/gtkcssimagevalueprivate.h @@ -28,10 +28,6 @@ GtkCssValue * _gtk_css_image_value_new (GtkCssImage *image); GtkCssImage * _gtk_css_image_value_get_image (const GtkCssValue *image); -GtkCssValue * gtk_css_image_value_resolve (GtkCssValue *value, - GtkCssComputeContext *context, - GtkCssValue *current_color); - G_END_DECLS diff --git a/gtk/gtkcssinheritvalue.c b/gtk/gtkcssinheritvalue.c index b2c8b38c4f..6f887cc955 100644 --- a/gtk/gtkcssinheritvalue.c +++ b/gtk/gtkcssinheritvalue.c @@ -77,6 +77,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_INHERIT = { "GtkCssInheritValue", gtk_css_value_inherit_free, gtk_css_value_inherit_compute, + NULL, gtk_css_value_inherit_equal, gtk_css_value_inherit_transition, NULL, diff --git a/gtk/gtkcssinitialvalue.c b/gtk/gtkcssinitialvalue.c index bbdb0d9db9..cee77e693c 100644 --- a/gtk/gtkcssinitialvalue.c +++ b/gtk/gtkcssinitialvalue.c @@ -101,6 +101,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_INITIAL = { "GtkCssInitialValue", gtk_css_value_initial_free, gtk_css_value_initial_compute, + NULL, gtk_css_value_initial_equal, gtk_css_value_initial_transition, NULL, diff --git a/gtk/gtkcsslineheightvalue.c b/gtk/gtkcsslineheightvalue.c index f68966bb9f..fd9115d7bb 100644 --- a/gtk/gtkcsslineheightvalue.c +++ b/gtk/gtkcsslineheightvalue.c @@ -107,6 +107,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_LINE_HEIGHT = { "GtkCssLineHeightValue", gtk_css_value_line_height_free, gtk_css_value_line_height_compute, + NULL, gtk_css_value_line_height_equal, gtk_css_value_line_height_transition, NULL, diff --git a/gtk/gtkcssnumbervalue.c b/gtk/gtkcssnumbervalue.c index 6ec5b10f1b..6da7db619c 100644 --- a/gtk/gtkcssnumbervalue.c +++ b/gtk/gtkcssnumbervalue.c @@ -605,6 +605,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_NUMBER = { "GtkCssNumberValue", gtk_css_value_number_free, gtk_css_value_number_compute, + NULL, gtk_css_value_number_equal, gtk_css_value_number_transition, NULL, diff --git a/gtk/gtkcsspalettevalue.c b/gtk/gtkcsspalettevalue.c index a933b75ded..95b4b7d077 100644 --- a/gtk/gtkcsspalettevalue.c +++ b/gtk/gtkcsspalettevalue.c @@ -134,6 +134,26 @@ gtk_css_value_palette_compute (GtkCssValue *specified, return result; } +static GtkCssValue * +gtk_css_value_palette_resolve (GtkCssValue *value, + GtkCssComputeContext *context, + GtkCssValue *current_color) +{ + GtkCssValue *result; + + if (!gtk_css_value_contains_current_color (value)) + return gtk_css_value_ref (value); + + result = gtk_css_palette_value_new_sized (value->n_colors); + for (guint i = 0; i < value->n_colors; i++) + { + result->color_names[i] = g_strdup (value->color_names[i]); + result->color_values[i] = gtk_css_value_resolve (value->color_values[i], context, current_color); + } + + return result; +} + static gboolean gtk_css_value_palette_equal (const GtkCssValue *value1, const GtkCssValue *value2) @@ -243,6 +263,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_PALETTE = { "GtkCssPaletteValue", gtk_css_value_palette_free, gtk_css_value_palette_compute, + gtk_css_value_palette_resolve, gtk_css_value_palette_equal, gtk_css_value_palette_transition, NULL, @@ -353,23 +374,3 @@ gtk_css_palette_value_get_color (GtkCssValue *value, return NULL; } - -GtkCssValue * -gtk_css_palette_value_resolve (GtkCssValue *value, - GtkCssComputeContext *context, - GtkCssValue *current_color) -{ - GtkCssValue *result; - - if (!gtk_css_value_contains_current_color (value)) - return gtk_css_value_ref (value); - - result = gtk_css_palette_value_new_sized (value->n_colors); - for (guint i = 0; i < value->n_colors; i++) - { - result->color_names[i] = g_strdup (value->color_names[i]); - result->color_values[i] = gtk_css_color_value_resolve (value->color_values[i], context, current_color); - } - - return result; -} diff --git a/gtk/gtkcsspalettevalueprivate.h b/gtk/gtkcsspalettevalueprivate.h index 2c43c33140..217883ad03 100644 --- a/gtk/gtkcsspalettevalueprivate.h +++ b/gtk/gtkcsspalettevalueprivate.h @@ -33,9 +33,5 @@ GtkCssValue * gtk_css_palette_value_parse (GtkCssParser *pa GtkCssValue * gtk_css_palette_value_get_color (GtkCssValue *value, const char *color_name); -GtkCssValue * gtk_css_palette_value_resolve (GtkCssValue *value, - GtkCssComputeContext *context, - GtkCssValue *current_color); - G_END_DECLS diff --git a/gtk/gtkcsspositionvalue.c b/gtk/gtkcsspositionvalue.c index 0e65e02545..6b4b69d2f9 100644 --- a/gtk/gtkcsspositionvalue.c +++ b/gtk/gtkcsspositionvalue.c @@ -150,6 +150,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_POSITION = { "GtkCssPositionValue", gtk_css_value_position_free, gtk_css_value_position_compute, + NULL, gtk_css_value_position_equal, gtk_css_value_position_transition, NULL, diff --git a/gtk/gtkcssreferencevalue.c b/gtk/gtkcssreferencevalue.c index 27881cb17d..ee6d9a7fcc 100644 --- a/gtk/gtkcssreferencevalue.c +++ b/gtk/gtkcssreferencevalue.c @@ -362,6 +362,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_REFERENCE = { "GtkCssReferenceValue", gtk_css_value_reference_free, gtk_css_value_reference_compute, + NULL, gtk_css_value_reference_equal, gtk_css_value_reference_transition, NULL, diff --git a/gtk/gtkcssrepeatvalue.c b/gtk/gtkcssrepeatvalue.c index 1be9363187..c1d12bd983 100644 --- a/gtk/gtkcssrepeatvalue.c +++ b/gtk/gtkcssrepeatvalue.c @@ -114,6 +114,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_BACKGROUND_REPEAT = { "GtkCssBackgroundRepeatValue", gtk_css_value_repeat_free, gtk_css_value_repeat_compute, + NULL, gtk_css_value_repeat_equal, gtk_css_value_repeat_transition, NULL, @@ -125,6 +126,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_BORDER_REPEAT = { "GtkCssBorderRepeatValue", gtk_css_value_repeat_free, gtk_css_value_repeat_compute, + NULL, gtk_css_value_repeat_equal, gtk_css_value_repeat_transition, NULL, diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c index 464a752871..2ffe9a5b2b 100644 --- a/gtk/gtkcssshadowvalue.c +++ b/gtk/gtkcssshadowvalue.c @@ -138,6 +138,34 @@ gtk_css_value_shadow_compute (GtkCssValue *value, return gtk_css_shadow_value_new (shadows, value->n_shadows, value->is_filter); } +static GtkCssValue * +gtk_css_value_shadow_resolve (GtkCssValue *value, + GtkCssComputeContext *context, + GtkCssValue *current_color) +{ + guint i; + ShadowValue *shadows; + + if (!gtk_css_value_contains_current_color (value)) + return gtk_css_value_ref (value); + + shadows = g_alloca (sizeof (ShadowValue) * value->n_shadows); + + for (i = 0; i < value->n_shadows; i++) + { + const ShadowValue *shadow = &value->shadows[i]; + + shadows[i].hoffset = gtk_css_value_ref (shadow->hoffset); + shadows[i].voffset = gtk_css_value_ref (shadow->voffset); + shadows[i].radius = gtk_css_value_ref (shadow->radius); + shadows[i].spread = gtk_css_value_ref (shadow->spread); + shadows[i].color = gtk_css_value_resolve (shadow->color, context, current_color); + shadows[i].inset = shadow->inset; + } + + return gtk_css_shadow_value_new (shadows, value->n_shadows, value->is_filter); +} + static gboolean gtk_css_value_shadow_equal (const GtkCssValue *value1, const GtkCssValue *value2) @@ -279,11 +307,12 @@ static const GtkCssValueClass GTK_CSS_VALUE_SHADOW = { "GtkCssShadowValue", gtk_css_value_shadow_free, gtk_css_value_shadow_compute, + gtk_css_value_shadow_resolve, gtk_css_value_shadow_equal, gtk_css_value_shadow_transition, NULL, NULL, - gtk_css_value_shadow_print + gtk_css_value_shadow_print, }; static GtkCssValue shadow_none_singleton = { >K_CSS_VALUE_SHADOW, 1, 1, 0, 0, 0, 0 }; @@ -748,31 +777,3 @@ gtk_css_shadow_value_pop_snapshot (const GtkCssValue *value, if (!gtk_css_shadow_value_is_clear (value)) gtk_snapshot_pop (snapshot); } - -GtkCssValue * -gtk_css_shadow_value_resolve (GtkCssValue *value, - GtkCssComputeContext *context, - GtkCssValue *current_color) -{ - guint i; - ShadowValue *shadows; - - if (!gtk_css_value_contains_current_color (value)) - return gtk_css_value_ref (value); - - shadows = g_alloca (sizeof (ShadowValue) * value->n_shadows); - - for (i = 0; i < value->n_shadows; i++) - { - const ShadowValue *shadow = &value->shadows[i]; - - shadows[i].hoffset = gtk_css_value_ref (shadow->hoffset); - shadows[i].voffset = gtk_css_value_ref (shadow->voffset); - shadows[i].radius = gtk_css_value_ref (shadow->radius); - shadows[i].spread = gtk_css_value_ref (shadow->spread); - shadows[i].color = gtk_css_color_value_resolve (shadow->color, context, current_color); - shadows[i].inset = shadow->inset; - } - - return gtk_css_shadow_value_new (shadows, value->n_shadows, value->is_filter); -} diff --git a/gtk/gtkcssshadowvalueprivate.h b/gtk/gtkcssshadowvalueprivate.h index 27e2f06162..df56b0ee58 100644 --- a/gtk/gtkcssshadowvalueprivate.h +++ b/gtk/gtkcssshadowvalueprivate.h @@ -56,9 +56,5 @@ gboolean gtk_css_shadow_value_push_snapshot (const GtkCssValue void gtk_css_shadow_value_pop_snapshot (const GtkCssValue *value, GtkSnapshot *snapshot); -GtkCssValue * gtk_css_shadow_value_resolve (GtkCssValue *value, - GtkCssComputeContext *context, - GtkCssValue *current_color); - G_END_DECLS diff --git a/gtk/gtkcssstringvalue.c b/gtk/gtkcssstringvalue.c index 6478263617..ba13a4a353 100644 --- a/gtk/gtkcssstringvalue.c +++ b/gtk/gtkcssstringvalue.c @@ -119,6 +119,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_STRING = { "GtkCssStringValue", gtk_css_value_string_free, gtk_css_value_string_compute, + NULL, gtk_css_value_string_equal, gtk_css_value_string_transition, NULL, @@ -130,6 +131,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_IDENT = { "GtkCssIdentValue", gtk_css_value_string_free, gtk_css_value_string_compute, + NULL, gtk_css_value_string_equal, gtk_css_value_string_transition, NULL, diff --git a/gtk/gtkcssstyle.c b/gtk/gtkcssstyle.c index e37e9ea281..d5f69ba845 100644 --- a/gtk/gtkcssstyle.c +++ b/gtk/gtkcssstyle.c @@ -1017,7 +1017,7 @@ gtk_css_style_resolve_used_value (GtkCssStyle *style, else current = _gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (GTK_CSS_PROPERTY_COLOR)); - used = gtk_css_color_value_resolve (value, context, current); + used = gtk_css_value_resolve (value, context, current); } break; @@ -1030,23 +1030,14 @@ gtk_css_style_resolve_used_value (GtkCssStyle *style, case GTK_CSS_PROPERTY_OUTLINE_COLOR: case GTK_CSS_PROPERTY_CARET_COLOR: case GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR: - used = gtk_css_color_value_resolve (value, context, style->used->color); - break; - case GTK_CSS_PROPERTY_BOX_SHADOW: case GTK_CSS_PROPERTY_TEXT_SHADOW: case GTK_CSS_PROPERTY_ICON_SHADOW: - used = gtk_css_shadow_value_resolve (value, context, style->used->color); - break; - case GTK_CSS_PROPERTY_ICON_PALETTE: - used = gtk_css_palette_value_resolve (value, context, style->used->color); - break; - case GTK_CSS_PROPERTY_BACKGROUND_IMAGE: case GTK_CSS_PROPERTY_ICON_SOURCE: case GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE: - used = gtk_css_image_value_resolve (value, context, style->used->color); + used = gtk_css_value_resolve (value, context, style->used->color); break; default: diff --git a/gtk/gtkcsstransformvalue.c b/gtk/gtkcsstransformvalue.c index 402d08e0bb..7083ef8f5b 100644 --- a/gtk/gtkcsstransformvalue.c +++ b/gtk/gtkcsstransformvalue.c @@ -788,6 +788,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_TRANSFORM = { "GtkCssTransformValue", gtk_css_value_transform_free, gtk_css_value_transform_compute, + NULL, gtk_css_value_transform_equal, gtk_css_value_transform_transition, NULL, diff --git a/gtk/gtkcssunsetvalue.c b/gtk/gtkcssunsetvalue.c index a78e0352bc..fe0022cbcd 100644 --- a/gtk/gtkcssunsetvalue.c +++ b/gtk/gtkcssunsetvalue.c @@ -79,6 +79,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_UNSET = { "GtkCssUnsetValue", gtk_css_value_unset_free, gtk_css_value_unset_compute, + NULL, gtk_css_value_unset_equal, gtk_css_value_unset_transition, NULL, diff --git a/gtk/gtkcssvalue.c b/gtk/gtkcssvalue.c index 4c9454e798..cc27a234c0 100644 --- a/gtk/gtkcssvalue.c +++ b/gtk/gtkcssvalue.c @@ -196,11 +196,8 @@ void * gtk_css_value_compute: * @value: the value to compute from * @property_id: the ID of the property to compute - * @provider: Style provider for looking up extra information - * @style: Style to compute for - * @parent_style: parent style to use for inherited values - * @variables: an additional set of variables to use along with @style - * @shorthands: (nullable): Already computed values for shorthands + * @context: the context containing the style provider, style + * parent style and variables that might be used during computation * * Converts the specified @value into the computed value for the CSS * property given by @property_id using the information in @context. @@ -224,6 +221,29 @@ gtk_css_value_compute (GtkCssValue *value, return value->class->compute (value, property_id, context); } +/** + * gtk_css_value_resolve: + * @value: the value to resolve + * @context: the context containing the style provider, style + * parent style and variables that might be used during computation + * @current: the value to use for currentcolor + * + * Converts the computed @value into the used value, by replacing + * currentcolor with @current. + * + * Returns: the used value + */ +GtkCssValue * +gtk_css_value_resolve (GtkCssValue *value, + GtkCssComputeContext *context, + GtkCssValue *current) +{ + if (!value->class->resolve) + return gtk_css_value_ref (value); + + return value->class->resolve (value, context, current); +} + gboolean gtk_css_value_equal (const GtkCssValue *value1, const GtkCssValue *value2) diff --git a/gtk/gtkcssvalueprivate.h b/gtk/gtkcssvalueprivate.h index d8f5052170..3ebe2ba035 100644 --- a/gtk/gtkcssvalueprivate.h +++ b/gtk/gtkcssvalueprivate.h @@ -57,6 +57,9 @@ struct _GtkCssValueClass { GtkCssValue * (* compute) (GtkCssValue *value, guint property_id, GtkCssComputeContext *context); + GtkCssValue * (* resolve) (GtkCssValue *value, + GtkCssComputeContext *context, + GtkCssValue *current); gboolean (* equal) (const GtkCssValue *value1, const GtkCssValue *value2); GtkCssValue * (* transition) (GtkCssValue *start, @@ -82,6 +85,9 @@ void (gtk_css_value_unref) (GtkCssValue GtkCssValue * gtk_css_value_compute (GtkCssValue *value, guint property_id, GtkCssComputeContext *context) G_GNUC_PURE; +GtkCssValue * gtk_css_value_resolve (GtkCssValue *value, + GtkCssComputeContext *context, + GtkCssValue *current) G_GNUC_PURE; gboolean gtk_css_value_equal (const GtkCssValue *value1, const GtkCssValue *value2) G_GNUC_PURE; gboolean gtk_css_value_equal0 (const GtkCssValue *value1, diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index 56e8cd7d44..370909ea68 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -873,7 +873,7 @@ gtk_label_update_layout_attributes (GtkLabel *self, g_slist_free (attributes); } - link_color = gtk_css_color_value_get_rgba (style->core->color); + link_color = gtk_css_color_value_get_rgba (style->used->color); attr = pango_attr_foreground_new (CLAMP (link_color->red * 65535. + 0.5, 0, 65535), CLAMP (link_color->green * 65535. + 0.5, 0, 65535), diff --git a/gtk/gtknative.c b/gtk/gtknative.c index d842c8caf9..3067ed4d7c 100644 --- a/gtk/gtknative.c +++ b/gtk/gtknative.c @@ -415,7 +415,7 @@ get_shadow_width (GtkWidget *widget, GtkCssNode *css_node = gtk_widget_get_css_node (widget); const GtkCssStyle *style = gtk_css_node_get_style (css_node); - gtk_css_shadow_value_get_extents (style->background->box_shadow, shadow_width); + gtk_css_shadow_value_get_extents (style->used->box_shadow, shadow_width); shadow_width->left = MAX (shadow_width->left, resize_handle_size); shadow_width->top = MAX (shadow_width->top, resize_handle_size); diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c index 8927232a9e..bdd66f2f8b 100644 --- a/gtk/gtkpopover.c +++ b/gtk/gtkpopover.c @@ -507,7 +507,7 @@ create_popup_layout (GtkPopover *popover) compute_surface_pointing_to (popover, &rect); style = gtk_css_node_get_style (gtk_widget_get_css_node (GTK_WIDGET (priv->contents_widget))); - gtk_css_shadow_value_get_extents (style->background->box_shadow, &shadow_width); + gtk_css_shadow_value_get_extents (style->used->box_shadow, &shadow_width); switch (priv->position) { @@ -1274,7 +1274,7 @@ gtk_popover_get_gap_coords (GtkPopover *popover, border_right = gtk_css_number_value_get (style->border->border_right_width, 100); border_bottom = gtk_css_number_value_get (style->border->border_bottom_width, 100); - gtk_css_shadow_value_get_extents (style->background->box_shadow, &shadow_width); + gtk_css_shadow_value_get_extents (style->used->box_shadow, &shadow_width); if (pos == GTK_POS_BOTTOM) { @@ -1448,7 +1448,7 @@ gtk_popover_update_shape (GtkPopover *popover) content_css_node = gtk_widget_get_css_node (GTK_WIDGET (priv->contents_widget)); style = gtk_css_node_get_style (content_css_node); - gtk_css_shadow_value_get_extents (style->background->box_shadow, &shadow_width); + gtk_css_shadow_value_get_extents (style->used->box_shadow, &shadow_width); input_rect.x = shadow_width.left; input_rect.y = shadow_width.top; @@ -1515,7 +1515,7 @@ gtk_popover_measure (GtkWidget *widget, for_size -= tail_height; style = gtk_css_node_get_style (gtk_widget_get_css_node (GTK_WIDGET (priv->contents_widget))); - gtk_css_shadow_value_get_extents (style->background->box_shadow, &shadow_width); + gtk_css_shadow_value_get_extents (style->used->box_shadow, &shadow_width); gtk_widget_measure (priv->contents_widget, orientation, for_size, @@ -1558,7 +1558,7 @@ gtk_popover_size_allocate (GtkWidget *widget, GtkBorder shadow_width; style = gtk_css_node_get_style (gtk_widget_get_css_node (GTK_WIDGET (priv->contents_widget))); - gtk_css_shadow_value_get_extents (style->background->box_shadow, &shadow_width); + gtk_css_shadow_value_get_extents (style->used->box_shadow, &shadow_width); switch (priv->final_position) { diff --git a/gtk/gtkrenderborder.c b/gtk/gtkrenderborder.c index 65a9356fe7..be2ad32779 100644 --- a/gtk/gtkrenderborder.c +++ b/gtk/gtkrenderborder.c @@ -54,7 +54,7 @@ static gboolean gtk_border_image_init (GtkBorderImage *image, GtkCssStyle *style) { - image->source = _gtk_css_image_value_get_image (style->border->border_image_source); + image->source = _gtk_css_image_value_get_image (style->used->border_image_source); if (image->source == NULL) return FALSE; diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 661a8a9b3c..f8877367ba 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -4046,7 +4046,7 @@ get_shadow_width (GtkWindow *window, style = gtk_css_node_get_style (gtk_widget_get_css_node (GTK_WIDGET (window))); /* Calculate the size of the drop shadows ... */ - gtk_css_shadow_value_get_extents (style->background->box_shadow, shadow_width); + gtk_css_shadow_value_get_extents (style->used->box_shadow, shadow_width); shadow_width->left = MAX (shadow_width->left, RESIZE_HANDLE_SIZE); shadow_width->top = MAX (shadow_width->top, RESIZE_HANDLE_SIZE);