From 3dbf06420df0ad669f12939a788ed44061dcc1e1 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sun, 18 Mar 2012 05:55:50 -0400 Subject: [PATCH] st-theme-node-drawing: Fix implementation of cover and contain The math was incorrect for non-square containers https://bugzilla.gnome.org/show_bug.cgi?id=672321 --- src/st/st-theme-node-drawing.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/st/st-theme-node-drawing.c b/src/st/st-theme-node-drawing.c index 04a35478b..cab254260 100644 --- a/src/st/st-theme-node-drawing.c +++ b/src/st/st-theme-node-drawing.c @@ -409,16 +409,12 @@ get_background_scale (StThemeNode *node, *scale_w = 1.0; break; case ST_BACKGROUND_SIZE_CONTAIN: - if (background_image_width > background_image_height) - *scale_w = painting_area_width / background_image_width; - else - *scale_w = painting_area_height / background_image_height; + *scale_w = MIN (painting_area_width / background_image_width, + painting_area_height / background_image_height); break; case ST_BACKGROUND_SIZE_COVER: - if (background_image_width < background_image_height) - *scale_w = painting_area_width / background_image_width; - else - *scale_w = painting_area_height / background_image_height; + *scale_w = MAX (painting_area_width / background_image_width, + painting_area_height / background_image_height); break; case ST_BACKGROUND_SIZE_FIXED: if (node->background_size_w > -1)