+static GtkBitmask *_properties_affecting_size = NULL;
+static GtkBitmask *_properties_affecting_font = NULL;
+
+static GtkCssStylePropertyClass *gtk_css_style_property_class = NULL;
+
+static void
+gtk_css_style_property_constructed (GObject *object)
+{
+ GtkCssStyleProperty *property = GTK_CSS_STYLE_PROPERTY (object);
+ GtkCssStylePropertyClass *klass = GTK_CSS_STYLE_PROPERTY_GET_CLASS (property);
+
+ property->id = klass->style_properties->len;
+ g_ptr_array_add (klass->style_properties, property);
+
+ if (property->affects_size)
+ _properties_affecting_size = _gtk_bitmask_set (_properties_affecting_size, property->id, TRUE);
+
+ if (property->affects_font)
+ _properties_affecting_font = _gtk_bitmask_set (_properties_affecting_font, property->id, TRUE);
+
+ G_OBJECT_CLASS (_gtk_css_style_property_parent_class)->constructed (object);
+}
+
+static void
+gtk_css_style_property_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtkCssStyleProperty *property = GTK_CSS_STYLE_PROPERTY (object);
+
+ switch (prop_id)
+ {
+ case PROP_ANIMATED:
+ property->animated = g_value_get_boolean (value);
+ break;
+ case PROP_AFFECTS_SIZE:
+ property->affects_size = g_value_get_boolean (value);
+ break;
+ case PROP_AFFECTS_FONT:
+ property->affects_font = g_value_get_boolean (value);
+ break;
+ case PROP_INHERIT:
+ property->inherit = g_value_get_boolean (value);
+ break;
+ case PROP_INITIAL:
+ property->initial_value = g_value_dup_boxed (value);
+ g_assert (property->initial_value != NULL);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_css_style_property_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtkCssStyleProperty *property = GTK_CSS_STYLE_PROPERTY (object);
+
+ switch (prop_id)
+ {
+ case PROP_ANIMATED:
+ g_value_set_boolean (value, property->animated);
+ break;
+ case PROP_AFFECTS_SIZE:
+ g_value_set_boolean (value, property->affects_size);
+ break;
+ case PROP_AFFECTS_FONT:
+ g_value_set_boolean (value, property->affects_font);
+ break;
+ case PROP_ID:
+ g_value_set_boolean (value, property->id);
+ break;
+ case PROP_INHERIT:
+ g_value_set_boolean (value, property->inherit);
+ break;
+ case PROP_INITIAL:
+ g_value_set_boxed (value, property->initial_value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+_gtk_css_style_property_assign (GtkStyleProperty *property,
+ GtkStyleProperties *props,
+ GtkStateFlags state,
+ const GValue *value)
+{
+ GtkCssStyleProperty *style;
+ GtkCssValue *css_value;
+
+ style = GTK_CSS_STYLE_PROPERTY (property);
+ css_value = style->assign_value (style, value);
+
+ _gtk_style_properties_set_property_by_property (props,
+ style,
+ state,
+ css_value);
+ _gtk_css_value_unref (css_value);
+}
+
+static gboolean
+_gtk_css_style_property_query_special_case (GtkCssStyleProperty *property,
+ GValue *value,
+ GtkStyleQueryFunc query_func,
+ gpointer query_data)
+{
+ GtkBorderStyle border_style;
+
+ switch (property->id)
+ {
+ case GTK_CSS_PROPERTY_BORDER_TOP_WIDTH:
+ border_style = _gtk_css_border_style_value_get (query_func (GTK_CSS_PROPERTY_BORDER_TOP_STYLE, query_data));
+ if (border_style == GTK_BORDER_STYLE_NONE || border_style == GTK_BORDER_STYLE_HIDDEN)
+ {
+ g_value_init (value, G_TYPE_INT);
+ return TRUE;
+ }
+ break;
+ case GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH:
+ border_style = _gtk_css_border_style_value_get (query_func (GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE, query_data));
+ if (border_style == GTK_BORDER_STYLE_NONE || border_style == GTK_BORDER_STYLE_HIDDEN)
+ {
+ g_value_init (value, G_TYPE_INT);
+ return TRUE;
+ }
+ break;
+ case GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH:
+ border_style = _gtk_css_border_style_value_get (query_func (GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE, query_data));
+ if (border_style == GTK_BORDER_STYLE_NONE || border_style == GTK_BORDER_STYLE_HIDDEN)
+ {
+ g_value_init (value, G_TYPE_INT);
+ return TRUE;
+ }
+ break;
+ case GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH:
+ border_style = _gtk_css_border_style_value_get (query_func (GTK_CSS_PROPERTY_BORDER_LEFT_STYLE, query_data));
+ if (border_style == GTK_BORDER_STYLE_NONE || border_style == GTK_BORDER_STYLE_HIDDEN)
+ {
+ g_value_init (value, G_TYPE_INT);
+ return TRUE;
+ }
+ break;
+ case GTK_CSS_PROPERTY_OUTLINE_WIDTH:
+ border_style = _gtk_css_border_style_value_get (query_func (GTK_CSS_PROPERTY_OUTLINE_STYLE, query_data));
+ if (border_style == GTK_BORDER_STYLE_NONE || border_style == GTK_BORDER_STYLE_HIDDEN)
+ {
+ g_value_init (value, G_TYPE_INT);
+ return TRUE;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return FALSE;
+}
+
+static void
+_gtk_css_style_property_query (GtkStyleProperty *property,
+ GValue *value,
+ GtkStyleQueryFunc query_func,
+ gpointer query_data)
+{
+ GtkCssStyleProperty *style_property = GTK_CSS_STYLE_PROPERTY (property);
+ GtkCssValue *css_value;
+
+ /* I don't like this special case being here in this generic code path, but no idea where else to put it. */
+ if (_gtk_css_style_property_query_special_case (style_property, value, query_func, query_data))
+ return;
+
+ css_value = (* query_func) (GTK_CSS_STYLE_PROPERTY (property)->id, query_data);
+ if (css_value == NULL)
+ css_value =_gtk_css_style_property_get_initial_value (style_property);
+
+ style_property->query_value (style_property, css_value, value);
+}
+
+static GtkCssValue *
+gtk_css_style_property_parse_value (GtkStyleProperty *property,
+ GtkCssParser *parser)
+{
+ GtkCssStyleProperty *style_property = GTK_CSS_STYLE_PROPERTY (property);
+
+ if (_gtk_css_parser_try (parser, "initial", TRUE))
+ {
+ /* the initial value can be explicitly specified with the
+ * ‘initial’ keyword which all properties accept.
+ */
+ return _gtk_css_initial_value_new ();
+ }
+ else if (_gtk_css_parser_try (parser, "inherit", TRUE))
+ {
+ /* All properties accept the ‘inherit’ value which
+ * explicitly specifies that the value will be determined
+ * by inheritance. The ‘inherit’ value can be used to
+ * strengthen inherited values in the cascade, and it can
+ * also be used on properties that are not normally inherited.
+ */
+ return _gtk_css_inherit_value_new ();
+ }
+
+ return (* style_property->parse_value) (style_property, parser);
+}
+