css: Move computing of initial and inherit values
... to the compute vfunc. Simplifies code quite a bit. But makes the code no longer a simple step-by-step implementation of the spec.
This commit is contained in:
@ -19,6 +19,9 @@
|
||||
|
||||
#include "gtkcssinheritvalueprivate.h"
|
||||
|
||||
#include "gtkcssstylepropertyprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
|
||||
struct _GtkCssValue {
|
||||
GTK_CSS_VALUE_BASE
|
||||
};
|
||||
@ -35,8 +38,14 @@ gtk_css_value_inherit_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkStyleContext *context)
|
||||
{
|
||||
/* This value should be caught further up */
|
||||
g_return_val_if_reached (_gtk_css_value_ref (value));
|
||||
GtkStyleContext *parent = gtk_style_context_get_parent (context);
|
||||
|
||||
if (parent)
|
||||
return _gtk_css_value_ref (_gtk_style_context_peek_property (parent, property_id));
|
||||
else
|
||||
return _gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
|
||||
property_id,
|
||||
context);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -76,11 +85,3 @@ _gtk_css_inherit_value_new (void)
|
||||
{
|
||||
return _gtk_css_value_ref (&inherit);
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_css_value_is_inherit (const GtkCssValue *value)
|
||||
{
|
||||
g_return_val_if_fail (value != NULL, FALSE);
|
||||
|
||||
return value == &inherit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user