[gtk/wip/otte/center-center-center: 322/326] picture: Return natural size 0 for size 0




commit 7ef54e9c53ee2af95282888fbb7d3286d12e3a42
Author: Ivan Molodetskikh <yalterz gmail com>
Date:   Fri Nov 19 16:26:07 2021 +0300

    picture: Return natural size 0 for size 0
    
    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                                                | 3 ++-
 testsuite/reftests/center-center-150x150-picture-in-100x200.css | 2 +-
 testsuite/reftests/center-center-200x200-picture-in-100x200.css | 2 +-
 testsuite/reftests/center-center-300x300-picture-in-100x200.css | 2 +-
 4 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkpicture.c b/gtk/gtkpicture.c
index 48157d3e14..cf7cd61f83 100644
--- a/gtk/gtkpicture.c
+++ b/gtk/gtkpicture.c
@@ -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;
diff --git a/testsuite/reftests/center-center-150x150-picture-in-100x200.css 
b/testsuite/reftests/center-center-150x150-picture-in-100x200.css
index adbc2cbedc..e496fc2d82 100644
--- a/testsuite/reftests/center-center-150x150-picture-in-100x200.css
+++ b/testsuite/reftests/center-center-150x150-picture-in-100x200.css
@@ -11,5 +11,5 @@ picture {
   background-image: image(lime);
   background-repeat: no-repeat;
   background-position: center;
-  background-size: 150px 150px;
+  background-size: 100px 100px;
 }
diff --git a/testsuite/reftests/center-center-200x200-picture-in-100x200.css 
b/testsuite/reftests/center-center-200x200-picture-in-100x200.css
index cb3b17ba09..e496fc2d82 100644
--- a/testsuite/reftests/center-center-200x200-picture-in-100x200.css
+++ b/testsuite/reftests/center-center-200x200-picture-in-100x200.css
@@ -11,5 +11,5 @@ picture {
   background-image: image(lime);
   background-repeat: no-repeat;
   background-position: center;
-  background-size: 200px 200px;
+  background-size: 100px 100px;
 }
diff --git a/testsuite/reftests/center-center-300x300-picture-in-100x200.css 
b/testsuite/reftests/center-center-300x300-picture-in-100x200.css
index 5b067dd562..e496fc2d82 100644
--- a/testsuite/reftests/center-center-300x300-picture-in-100x200.css
+++ b/testsuite/reftests/center-center-300x300-picture-in-100x200.css
@@ -11,5 +11,5 @@ picture {
   background-image: image(lime);
   background-repeat: no-repeat;
   background-position: center;
-  background-size: 300px 300px;
+  background-size: 100px 100px;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]