diff --git a/gtk/gtkcsscornervalue.c b/gtk/gtkcsscornervalue.c index 54f4480a0a..b25e6a6fef 100644 --- a/gtk/gtkcsscornervalue.c +++ b/gtk/gtkcsscornervalue.c @@ -18,8 +18,8 @@ #include "config.h" #include "gtkcsscornervalueprivate.h" - #include "gtkcssnumbervalueprivate.h" +#include "gtkcssdimensionvalueprivate.h" struct _GtkCssValue { GTK_CSS_VALUE_BASE @@ -184,3 +184,12 @@ _gtk_css_corner_value_get_y (const GtkCssValue *corner, return _gtk_css_number_value_get (corner->y, one_hundred_percent); } +gboolean +gtk_css_corner_value_is_zero (const GtkCssValue *corner) +{ + if (corner->class != >K_CSS_VALUE_CORNER) + return gtk_css_dimension_value_is_zero (corner); + + return gtk_css_dimension_value_is_zero (corner->x) && + gtk_css_dimension_value_is_zero (corner->y); +} diff --git a/gtk/gtkcsscornervalueprivate.h b/gtk/gtkcsscornervalueprivate.h index 99fa62d6ce..59451a7840 100644 --- a/gtk/gtkcsscornervalueprivate.h +++ b/gtk/gtkcsscornervalueprivate.h @@ -33,6 +33,7 @@ double _gtk_css_corner_value_get_x (const GtkCssValue *cor double one_hundred_percent) G_GNUC_PURE; double _gtk_css_corner_value_get_y (const GtkCssValue *corner, double one_hundred_percent) G_GNUC_PURE; +gboolean gtk_css_corner_value_is_zero (const GtkCssValue *corner) G_GNUC_PURE; G_END_DECLS diff --git a/gtk/gtkcssdimensionvalue.c b/gtk/gtkcssdimensionvalue.c index 0e7020708a..d8e06af052 100644 --- a/gtk/gtkcssdimensionvalue.c +++ b/gtk/gtkcssdimensionvalue.c @@ -497,3 +497,14 @@ gtk_css_dimension_value_parse (GtkCssParser *parser, return result; } +gboolean +gtk_css_dimension_value_is_zero (const GtkCssValue *value) +{ + if (!value) + return TRUE; + + if (value->class != >K_CSS_VALUE_DIMENSION.value_class) + return FALSE; + + return value->value == 0; +} diff --git a/gtk/gtkcssdimensionvalueprivate.h b/gtk/gtkcssdimensionvalueprivate.h index 2e08eba785..f13a9281bb 100644 --- a/gtk/gtkcssdimensionvalueprivate.h +++ b/gtk/gtkcssdimensionvalueprivate.h @@ -30,6 +30,8 @@ GtkCssValue * gtk_css_dimension_value_new (double val GtkCssValue * gtk_css_dimension_value_parse (GtkCssParser *parser, GtkCssNumberParseFlags flags); +gboolean gtk_css_dimension_value_is_zero (const GtkCssValue *value) G_GNUC_PURE; + G_END_DECLS #endif /* __GTK_CSS_DIMENSION_VALUE_PRIVATE_H__ */