cssimage: Scale images to contain, not cover
Images with just an aspect ratio, but without a size, should be scaled to be fully visible in the given area. But we scaled them to completely cover the given area, which made them partially invisible. Reftest included.
This commit is contained in:
		@ -307,13 +307,13 @@ _gtk_css_image_get_concrete_size (GtkCssImage *image,
 | 
			
		||||
        {
 | 
			
		||||
          if (image_aspect * default_height > default_width)
 | 
			
		||||
            {
 | 
			
		||||
              *concrete_width = default_height * image_aspect;
 | 
			
		||||
              *concrete_height = default_height;
 | 
			
		||||
              *concrete_width = default_width;
 | 
			
		||||
              *concrete_height = default_width / image_aspect;
 | 
			
		||||
            }
 | 
			
		||||
          else
 | 
			
		||||
            {
 | 
			
		||||
              *concrete_width = default_width;
 | 
			
		||||
              *concrete_height = default_width / image_aspect;
 | 
			
		||||
              *concrete_width = default_height * image_aspect;
 | 
			
		||||
              *concrete_height = default_height;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
      else
 | 
			
		||||
 | 
			
		||||
@ -206,6 +206,9 @@ testdata = \
 | 
			
		||||
	css-currentcolor-alpha.css \
 | 
			
		||||
	css-currentcolor-alpha.ui \
 | 
			
		||||
	css-currentcolor-alpha.ref.ui \
 | 
			
		||||
	css-image-aspect-ratio.css \
 | 
			
		||||
	css-image-aspect-ratio.ui \
 | 
			
		||||
	css-image-aspect-ratio.ref.ui \
 | 
			
		||||
	css-match-class.css \
 | 
			
		||||
	css-match-class.ref.ui \
 | 
			
		||||
	css-match-class.ui \
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										8
									
								
								testsuite/reftests/css-image-aspect-ratio.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								testsuite/reftests/css-image-aspect-ratio.css
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,8 @@
 | 
			
		||||
window {
 | 
			
		||||
  background-image: -gtk-icontheme("edit-delete");
 | 
			
		||||
  background-repeat: no-repeat;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#reference {
 | 
			
		||||
  background-size: 24px 24px;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										11
									
								
								testsuite/reftests/css-image-aspect-ratio.ref.ui
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								testsuite/reftests/css-image-aspect-ratio.ref.ui
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<interface>
 | 
			
		||||
  <!-- interface-requires gtk+ 3.0 -->
 | 
			
		||||
  <object class="GtkWindow" id="window1">
 | 
			
		||||
    <property name="width_request">48</property>
 | 
			
		||||
    <property name="height_request">24</property>
 | 
			
		||||
    <property name="can_focus">False</property>
 | 
			
		||||
    <property name="type">popup</property>
 | 
			
		||||
    <property name="name">reference</property>
 | 
			
		||||
  </object>
 | 
			
		||||
</interface>
 | 
			
		||||
							
								
								
									
										10
									
								
								testsuite/reftests/css-image-aspect-ratio.ui
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								testsuite/reftests/css-image-aspect-ratio.ui
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,10 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<interface>
 | 
			
		||||
  <!-- interface-requires gtk+ 3.0 -->
 | 
			
		||||
  <object class="GtkWindow" id="window1">
 | 
			
		||||
    <property name="width_request">48</property>
 | 
			
		||||
    <property name="height_request">24</property>
 | 
			
		||||
    <property name="can_focus">False</property>
 | 
			
		||||
    <property name="type">popup</property>
 | 
			
		||||
  </object>
 | 
			
		||||
</interface>
 | 
			
		||||
		Reference in New Issue
	
	Block a user