forked from AuroraMiddleware/gtk
SizeRequest: Round px values up for min CSS sizes
Otherwise, requesting a min size in em where the equivalent in px had a fractional part would lead to the widget getting allocated 1 too few px. You could see this in the CSS property vs. allocation in the Inspector. Note that margin/border/padding are left alone: the rationale is that we do as browsers do, and Benjamin said we already do that for those, whereas his tests on min-(width|height) showed otherwise. My subsequent analysis indicated it to be far less clear-cut than that, but he remains unconvinced that we should ceil() all the things! So just do these ones. https://gitlab.gnome.org/GNOME/gtk/issues/1088
This commit is contained in:
parent
5c24bbf00c
commit
3396c5e983
@ -82,6 +82,14 @@ get_number (GtkCssStyle *style,
|
||||
return floor (d);
|
||||
}
|
||||
|
||||
/* Special-case min-width|height to round upwards, to avoid underalloc by 1px */
|
||||
static int
|
||||
get_number_ceil (GtkCssStyle *style,
|
||||
guint property)
|
||||
{
|
||||
return ceil (_gtk_css_number_value_get (gtk_css_style_get_value (style, property), 100));
|
||||
}
|
||||
|
||||
static void
|
||||
get_box_margin (GtkCssStyle *style,
|
||||
GtkBorder *margin)
|
||||
@ -166,15 +174,15 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget,
|
||||
{
|
||||
css_extra_size = margin.left + margin.right + border.left + border.right + padding.left + padding.right;
|
||||
css_extra_for_size = margin.top + margin.bottom + border.top + border.bottom + padding.top + padding.bottom;
|
||||
css_min_size = get_number (style, GTK_CSS_PROPERTY_MIN_WIDTH);
|
||||
css_min_for_size = get_number (style, GTK_CSS_PROPERTY_MIN_HEIGHT);
|
||||
css_min_size = get_number_ceil (style, GTK_CSS_PROPERTY_MIN_WIDTH);
|
||||
css_min_for_size = get_number_ceil (style, GTK_CSS_PROPERTY_MIN_HEIGHT);
|
||||
}
|
||||
else
|
||||
{
|
||||
css_extra_size = margin.top + margin.bottom + border.top + border.bottom + padding.top + padding.bottom;
|
||||
css_extra_for_size = margin.left + margin.right + border.left + border.right + padding.left + padding.right;
|
||||
css_min_size = get_number (style, GTK_CSS_PROPERTY_MIN_HEIGHT);
|
||||
css_min_for_size = get_number (style, GTK_CSS_PROPERTY_MIN_WIDTH);
|
||||
css_min_size = get_number_ceil (style, GTK_CSS_PROPERTY_MIN_HEIGHT);
|
||||
css_min_for_size = get_number_ceil (style, GTK_CSS_PROPERTY_MIN_WIDTH);
|
||||
}
|
||||
|
||||
if (for_size < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user