cssdimenstionvalue: Add common degree value singletons

This commit is contained in:
Timm Bäder 2019-11-07 07:31:04 +01:00
parent fb0b0ddfe0
commit cd3cd64769

View File

@ -318,6 +318,12 @@ gtk_css_dimension_value_new (double value,
{ &GTK_CSS_VALUE_DIMENSION.value_class, 1, GTK_CSS_S, 0 },
{ &GTK_CSS_VALUE_DIMENSION.value_class, 1, GTK_CSS_S, 1 },
};
static GtkCssValue deg_singletons[] = {
{ &GTK_CSS_VALUE_DIMENSION.value_class, 1, GTK_CSS_DEG, 0 },
{ &GTK_CSS_VALUE_DIMENSION.value_class, 1, GTK_CSS_DEG, 90 },
{ &GTK_CSS_VALUE_DIMENSION.value_class, 1, GTK_CSS_DEG, 180 },
{ &GTK_CSS_VALUE_DIMENSION.value_class, 1, GTK_CSS_DEG, 270 },
};
GtkCssValue *result;
switch ((guint)unit)
@ -365,6 +371,18 @@ gtk_css_dimension_value_new (double value,
break;
case GTK_CSS_DEG:
if (value == 0)
return _gtk_css_value_ref (&deg_singletons[0]);
if (value == 90)
return _gtk_css_value_ref (&deg_singletons[1]);
if (value == 180)
return _gtk_css_value_ref (&deg_singletons[2]);
if (value == 270)
return _gtk_css_value_ref (&deg_singletons[3]);
break;
default:
;
}