forked from AuroraMiddleware/gtk
CssGadget: Round px values up for min-width|height
Otherwise, requesting a min size in em where the equivalent in px had a fractional part would lead to the gadget 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
700d167b9e
commit
daecee75b4
@ -459,6 +459,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)
|
||||
@ -643,16 +651,16 @@ gtk_css_gadget_get_preferred_size (GtkCssGadget *gadget,
|
||||
extra_size = margin.left + margin.right + border.left + border.right + padding.left + padding.right;
|
||||
extra_opposite = margin.top + margin.bottom + border.top + border.bottom + padding.top + padding.bottom;
|
||||
extra_baseline = margin.left + border.left + padding.left;
|
||||
min_size = get_number (style, GTK_CSS_PROPERTY_MIN_WIDTH);
|
||||
min_for_size = get_number (style, GTK_CSS_PROPERTY_MIN_HEIGHT);
|
||||
min_size = get_number_ceil (style, GTK_CSS_PROPERTY_MIN_WIDTH);
|
||||
min_for_size = get_number_ceil (style, GTK_CSS_PROPERTY_MIN_HEIGHT);
|
||||
}
|
||||
else
|
||||
{
|
||||
extra_size = margin.top + margin.bottom + border.top + border.bottom + padding.top + padding.bottom;
|
||||
extra_opposite = margin.left + margin.right + border.left + border.right + padding.left + padding.right;
|
||||
extra_baseline = margin.top + border.top + padding.top;
|
||||
min_size = get_number (style, GTK_CSS_PROPERTY_MIN_HEIGHT);
|
||||
min_for_size = get_number (style, GTK_CSS_PROPERTY_MIN_WIDTH);
|
||||
min_size = get_number_ceil (style, GTK_CSS_PROPERTY_MIN_HEIGHT);
|
||||
min_for_size = get_number_ceil (style, GTK_CSS_PROPERTY_MIN_WIDTH);
|
||||
}
|
||||
|
||||
if (for_size > -1)
|
||||
|
Loading…
Reference in New Issue
Block a user