picture: Return natural size 0 for size 0
authorIvan Molodetskikh <yalterz@gmail.com>
Fri, 19 Nov 2021 13:26:07 +0000 (16:26 +0300)
committerBenjamin Otte <otte@redhat.com>
Wed, 8 Dec 2021 18:20:24 +0000 (19:20 +0100)
It was returning the full natural size (same as -1) due to default value
handling in the code below.

Tests have been updated to match this output.

gtk/gtkpicture.c
testsuite/reftests/center-center-150x150-picture-in-100x200.css
testsuite/reftests/center-center-200x200-picture-in-100x200.css
testsuite/reftests/center-center-300x300-picture-in-100x200.css

index 48157d3e143fbeed04930bda4709bb7e7f6bf7e1..cf7cd61f835a1442acff5f5063d4e7c97837e1af 100644 (file)
@@ -178,7 +178,8 @@ gtk_picture_measure (GtkWidget      *widget,
   double min_width, min_height, nat_width, nat_height;
   double default_size;
 
-  if (self->paintable == NULL)
+  /* for_size = 0 below is treated as -1, but we want to return zeros. */
+  if (self->paintable == NULL || for_size == 0)
     {
       *minimum = 0;
       *natural = 0;
index adbc2cbedcf9b834243cfa454155c534667d09a1..e496fc2d82d10784a89cbbdd66a5988ed182bfb0 100644 (file)
@@ -11,5 +11,5 @@ picture {
   background-image: image(lime);
   background-repeat: no-repeat;
   background-position: center;
-  background-size: 150px 150px;
+  background-size: 100px 100px;
 }
index cb3b17ba099d1194ba786f2bd13fd5e5b0b016db..e496fc2d82d10784a89cbbdd66a5988ed182bfb0 100644 (file)
@@ -11,5 +11,5 @@ picture {
   background-image: image(lime);
   background-repeat: no-repeat;
   background-position: center;
-  background-size: 200px 200px;
+  background-size: 100px 100px;
 }
index 5b067dd56251914372610b607b0b044b3618c279..e496fc2d82d10784a89cbbdd66a5988ed182bfb0 100644 (file)
@@ -11,5 +11,5 @@ picture {
   background-image: image(lime);
   background-repeat: no-repeat;
   background-position: center;
-  background-size: 300px 300px;
+  background-size: 100px 100px;
 }