]> Pileus Git - ~andy/gtk/commitdiff
cssvalue: Compute "background-size: 0 0" properly
authorBenjamin Otte <otte@redhat.com>
Fri, 26 Oct 2012 21:36:39 +0000 (23:36 +0200)
committerBenjamin Otte <otte@redhat.com>
Wed, 31 Oct 2012 10:09:10 +0000 (11:09 +0100)
Previously a computed value of 0 was treated as "auto", which is wrong.

gtk/gtkcssbgsizevalue.c

index 01db83d34f3f2961afafed302b710960776eb2ff..a34b3c10d4be24564b57a8c3ff7de09f7a8b4690 100644 (file)
@@ -261,16 +261,33 @@ _gtk_css_bg_size_value_compute_size (const GtkCssValue *value,
   g_return_if_fail (value->class == &GTK_CSS_VALUE_BG_SIZE);
 
   if (value->contain || value->cover)
-    gtk_css_bg_size_compute_size_for_cover_contain (value->cover,
-                                                    image,
-                                                    area_width, area_height,
-                                                    out_width, out_height);
+    {
+      gtk_css_bg_size_compute_size_for_cover_contain (value->cover,
+                                                      image,
+                                                      area_width, area_height,
+                                                      out_width, out_height);
+    }
   else
-    _gtk_css_image_get_concrete_size (image,
-                                      /* note: 0 does the right thing here for 'auto' */
-                                      value->x ? _gtk_css_number_value_get (value->x, area_width) : 0,
-                                      value->y ? _gtk_css_number_value_get (value->y, area_height) : 0,
-                                      area_width, area_height,
-                                      out_width, out_height);
+    {
+      double x, y;
+
+      /* note: 0 does the right thing later for 'auto' */
+      x = value->x ? _gtk_css_number_value_get (value->x, area_width) : 0;
+      y = value->y ? _gtk_css_number_value_get (value->y, area_height) : 0;
+
+      if ((x <= 0 && value->x) ||
+          (y <= 0 && value->y))
+        {
+          *out_width = 0;
+          *out_height = 0;
+        }
+      else
+        {
+          _gtk_css_image_get_concrete_size (image,
+                                            x, y,
+                                            area_width, area_height,
+                                            out_width, out_height);
+        }
+    }
 }