mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
css: Fix up incomplete resolve plumbing
I didn't quite get it right for all our image subtypes at first. Fixes: #6814
This commit is contained in:
parent
cb9c57f223
commit
3c8e9231ea
@ -448,6 +448,49 @@ gtk_css_image_cross_fade_is_computed (GtkCssImage *image)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_image_cross_fade_contains_current_color (GtkCssImage *image)
|
||||
{
|
||||
GtkCssImageCrossFade *cross_fade = GTK_CSS_IMAGE_CROSS_FADE (image);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < cross_fade->images->len; i++)
|
||||
{
|
||||
const CrossFadeEntry *entry = &g_array_index (cross_fade->images, CrossFadeEntry, i);
|
||||
if (gtk_css_image_contains_current_color (entry->image))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GtkCssImage *
|
||||
gtk_css_image_cross_fade_resolve (GtkCssImage *image,
|
||||
GtkCssComputeContext *context,
|
||||
GtkCssValue *current)
|
||||
{
|
||||
GtkCssImageCrossFade *self = GTK_CSS_IMAGE_CROSS_FADE (image);
|
||||
GtkCssImageCrossFade *result;
|
||||
guint i;
|
||||
|
||||
if (!gtk_css_image_cross_fade_contains_current_color (image))
|
||||
return g_object_ref (image);
|
||||
|
||||
result = gtk_css_image_cross_fade_new_empty ();
|
||||
|
||||
for (i = 0; i < self->images->len; i++)
|
||||
{
|
||||
CrossFadeEntry *entry = &g_array_index (self->images, CrossFadeEntry, i);
|
||||
|
||||
gtk_css_image_cross_fade_add (result,
|
||||
entry->has_progress,
|
||||
entry->progress,
|
||||
gtk_css_image_resolve (entry->image, context, current));
|
||||
}
|
||||
|
||||
return GTK_CSS_IMAGE (result);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_cross_fade_class_init (GtkCssImageCrossFadeClass *klass)
|
||||
{
|
||||
@ -464,6 +507,8 @@ gtk_css_image_cross_fade_class_init (GtkCssImageCrossFadeClass *klass)
|
||||
image_class->parse = gtk_css_image_cross_fade_parse;
|
||||
image_class->print = gtk_css_image_cross_fade_print;
|
||||
image_class->is_computed = gtk_css_image_cross_fade_is_computed;
|
||||
image_class->contains_current_color = gtk_css_image_cross_fade_contains_current_color;
|
||||
image_class->resolve = gtk_css_image_cross_fade_resolve;
|
||||
|
||||
object_class->dispose = gtk_css_image_cross_fade_dispose;
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ gtk_css_image_fallback_contains_current_color (GtkCssImage *image)
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return gtk_css_image_contains_current_color (fallback->images[fallback->used]);
|
||||
}
|
||||
|
||||
static GtkCssImage *
|
||||
@ -335,6 +335,9 @@ gtk_css_image_fallback_resolve (GtkCssImage *image,
|
||||
GtkCssImageFallback *resolved;
|
||||
int i;
|
||||
|
||||
if (!gtk_css_image_fallback_contains_current_color (image))
|
||||
return g_object_ref (image);
|
||||
|
||||
if (fallback->used < 0)
|
||||
{
|
||||
GtkCssValue *resolved_color = NULL;
|
||||
@ -351,7 +354,7 @@ gtk_css_image_fallback_resolve (GtkCssImage *image,
|
||||
resolved->images = g_new (GtkCssImage *, fallback->n_images);
|
||||
for (i = 0; i < fallback->n_images; i++)
|
||||
{
|
||||
resolved->images[i] = g_object_ref (fallback->images[i]);
|
||||
resolved->images[i] = gtk_css_image_resolve (fallback->images[i], context, current_color);
|
||||
|
||||
if (gtk_css_image_is_invalid (resolved->images[i]))
|
||||
continue;
|
||||
@ -365,7 +368,7 @@ gtk_css_image_fallback_resolve (GtkCssImage *image,
|
||||
return GTK_CSS_IMAGE (resolved);
|
||||
}
|
||||
else
|
||||
return GTK_CSS_IMAGE (g_object_ref (image));
|
||||
return gtk_css_image_resolve (fallback->images[fallback->used], context, current_color);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -772,6 +772,9 @@ gtk_css_image_linear_resolve (GtkCssImage *image,
|
||||
GtkCssImageLinear *copy;
|
||||
guint i;
|
||||
|
||||
if (!gtk_css_image_linear_contains_current_color (image))
|
||||
return g_object_ref (image);
|
||||
|
||||
copy = g_object_new (GTK_TYPE_CSS_IMAGE_LINEAR, NULL);
|
||||
copy->repeating = linear->repeating;
|
||||
copy->side = linear->side;
|
||||
|
@ -157,6 +157,20 @@ gtk_css_image_paintable_is_computed (GtkCssImage *image)
|
||||
return (gdk_paintable_get_flags (self->paintable) & GDK_PAINTABLE_IMMUTABLE) == GDK_PAINTABLE_IMMUTABLE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_image_paintable_contains_current_color (GtkCssImage *image)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GtkCssImage *
|
||||
gtk_css_image_paintable_resolve (GtkCssImage *image,
|
||||
GtkCssComputeContext *context,
|
||||
GtkCssValue *value)
|
||||
{
|
||||
return g_object_ref (image);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_paintable_class_init (GtkCssImagePaintableClass *klass)
|
||||
{
|
||||
@ -173,6 +187,8 @@ gtk_css_image_paintable_class_init (GtkCssImagePaintableClass *klass)
|
||||
image_class->is_dynamic = gtk_css_image_paintable_is_dynamic;
|
||||
image_class->is_computed = gtk_css_image_paintable_is_computed;
|
||||
image_class->get_dynamic_image = gtk_css_image_paintable_get_dynamic_image;
|
||||
image_class->contains_current_color = gtk_css_image_paintable_contains_current_color;
|
||||
image_class->resolve = gtk_css_image_paintable_resolve;
|
||||
|
||||
object_class->dispose = gtk_css_image_paintable_dispose;
|
||||
}
|
||||
|
@ -773,6 +773,9 @@ gtk_css_image_radial_resolve (GtkCssImage *image,
|
||||
GtkCssImageRadial *radial = GTK_CSS_IMAGE_RADIAL (image);
|
||||
GtkCssImageRadial *copy;
|
||||
|
||||
if (!gtk_css_image_radial_contains_current_color (image))
|
||||
return g_object_ref (image);
|
||||
|
||||
copy = g_object_new (GTK_TYPE_CSS_IMAGE_RADIAL, NULL);
|
||||
copy->repeating = radial->repeating;
|
||||
copy->circle = radial->circle;
|
||||
|
@ -230,6 +230,9 @@ gtk_css_image_scaled_resolve (GtkCssImage *image,
|
||||
GtkCssImageScaled *self = GTK_CSS_IMAGE_SCALED (image);
|
||||
GtkCssImageScaled *res;
|
||||
|
||||
if (!gtk_css_image_scaled_contains_current_color (image))
|
||||
return g_object_ref (image);
|
||||
|
||||
res = g_object_new (GTK_TYPE_CSS_IMAGE_SCALED, NULL);
|
||||
|
||||
res->n_images = self->n_images;
|
||||
|
@ -159,6 +159,21 @@ gtk_css_image_url_is_computed (GtkCssImage *image)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GtkCssImage *
|
||||
gtk_css_image_url_resolve (GtkCssImage *image,
|
||||
GtkCssComputeContext *context,
|
||||
GtkCssValue *current)
|
||||
{
|
||||
return g_object_ref (image);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_image_url_contains_current_color (GtkCssImage *image)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
gtk_css_image_url_parse (GtkCssImage *image,
|
||||
GtkCssParser *parser)
|
||||
@ -253,6 +268,8 @@ _gtk_css_image_url_class_init (GtkCssImageUrlClass *klass)
|
||||
image_class->equal = gtk_css_image_url_equal;
|
||||
image_class->is_invalid = gtk_css_image_url_is_invalid;
|
||||
image_class->is_computed = gtk_css_image_url_is_computed;
|
||||
image_class->contains_current_color = gtk_css_image_url_contains_current_color;
|
||||
image_class->resolve = gtk_css_image_url_resolve;
|
||||
|
||||
object_class->dispose = gtk_css_image_url_dispose;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user