diff options
author | Matthias Clasen <mclasen@redhat.com> | 2022-09-13 17:04:19 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-09-14 00:08:36 -0400 |
commit | 5bbe811090d11840bbd65f46b6f5100b3079ac97 (patch) | |
tree | 317ac1036a5efce27afe696b5ddc35a023edb7b8 /gtk/gtkcolumnviewcell.c | |
parent | 952f85c12de13e978294af58f26694eddb3a1ee0 (diff) | |
download | gtk+-wip/css-value-unboxing.tar.gz |
wip: Unbox css valueswip/css-value-unboxing
Keep css values unboxed in the values structs, for faster access
to these values, where it makes sense.
Diffstat (limited to 'gtk/gtkcolumnviewcell.c')
-rw-r--r-- | gtk/gtkcolumnviewcell.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/gtk/gtkcolumnviewcell.c b/gtk/gtkcolumnviewcell.c index 1ada1b4292..eff3a1f976 100644 --- a/gtk/gtkcolumnviewcell.c +++ b/gtk/gtkcolumnviewcell.c @@ -47,15 +47,13 @@ struct _GtkColumnViewCellClass G_DEFINE_TYPE (GtkColumnViewCell, gtk_column_view_cell, GTK_TYPE_LIST_ITEM_WIDGET) -static int -get_number (GtkCssValue *value) +static inline int +ceil_or_floor (float d) { - double d = _gtk_css_number_value_get (value, 100); - if (d < 1) - return ceil (d); + return ceilf (d); else - return floor (d); + return floorf (d); } static int @@ -67,12 +65,12 @@ unadjust_width (GtkWidget *widget, int css_extra; style = gtk_css_node_get_style (gtk_widget_get_css_node (widget)); - css_extra = get_number (style->size->margin_left) + - get_number (style->size->margin_right) + - get_number (style->border->border_left_width) + - get_number (style->border->border_right_width) + - get_number (style->size->padding_left) + - get_number (style->size->padding_right); + css_extra = ceil_or_floor (style->size->_margin[GTK_CSS_LEFT]) + + ceil_or_floor (style->size->_margin[GTK_CSS_RIGHT]) + + ceil_or_floor (style->border->_border_width[GTK_CSS_LEFT]) + + ceil_or_floor (style->border->_border_width[GTK_CSS_RIGHT]) + + ceil_or_floor (style->size->_padding[GTK_CSS_LEFT]) + + ceil_or_floor (style->size->_padding[GTK_CSS_RIGHT]); widget_margins = widget->priv->margin.left + widget->priv->margin.right; return MAX (0, width - widget_margins - css_extra); |