css: Implement inherit properties
Huge performance hit (slows down things roughly by a factor of 3), but necessary for CSS conformance and for implementing "inherit" and percentages.
This commit is contained in:
@ -1108,38 +1108,48 @@ gtk_css_provider_get_style (GtkStyleProvider *provider,
|
|||||||
GtkCssProvider *css_provider;
|
GtkCssProvider *css_provider;
|
||||||
GtkCssProviderPrivate *priv;
|
GtkCssProviderPrivate *priv;
|
||||||
GtkStyleProperties *props;
|
GtkStyleProperties *props;
|
||||||
guint i;
|
guint i, l, length;
|
||||||
|
|
||||||
css_provider = GTK_CSS_PROVIDER (provider);
|
css_provider = GTK_CSS_PROVIDER (provider);
|
||||||
priv = css_provider->priv;
|
priv = css_provider->priv;
|
||||||
|
length = gtk_widget_path_length (path);
|
||||||
props = gtk_style_properties_new ();
|
props = gtk_style_properties_new ();
|
||||||
|
|
||||||
css_provider_dump_symbolic_colors (css_provider, props);
|
css_provider_dump_symbolic_colors (css_provider, props);
|
||||||
|
|
||||||
for (i = 0; i < priv->selectors_info->len; i++)
|
for (l = 1; l <= length; l++)
|
||||||
{
|
{
|
||||||
SelectorStyleInfo *info;
|
for (i = 0; i < priv->selectors_info->len; i++)
|
||||||
GHashTableIter iter;
|
|
||||||
gpointer key, value;
|
|
||||||
|
|
||||||
info = g_ptr_array_index (priv->selectors_info, i);
|
|
||||||
|
|
||||||
if (!_gtk_css_selector_matches (info->selector, path, gtk_widget_path_length (path)))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
g_hash_table_iter_init (&iter, info->style);
|
|
||||||
|
|
||||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
|
||||||
{
|
{
|
||||||
GParamSpec *pspec;
|
SelectorStyleInfo *info;
|
||||||
|
GHashTableIter iter;
|
||||||
|
gpointer key, value;
|
||||||
|
|
||||||
if (!gtk_style_properties_lookup_property (key, NULL, &pspec))
|
info = g_ptr_array_index (priv->selectors_info, i);
|
||||||
|
|
||||||
|
if (l < length && _gtk_css_selector_get_state_flags (info->selector))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
_gtk_style_properties_set_property_by_pspec (props,
|
if (!_gtk_css_selector_matches (info->selector, path, l))
|
||||||
pspec,
|
continue;
|
||||||
_gtk_css_selector_get_state_flags (info->selector),
|
|
||||||
value);
|
g_hash_table_iter_init (&iter, info->style);
|
||||||
|
|
||||||
|
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||||
|
{
|
||||||
|
GParamSpec *pspec;
|
||||||
|
|
||||||
|
if (!gtk_style_properties_lookup_property (key, NULL, &pspec))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (l != length && !gtk_style_param_get_inherit (pspec))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
_gtk_style_properties_set_property_by_pspec (props,
|
||||||
|
pspec,
|
||||||
|
_gtk_css_selector_get_state_flags (info->selector),
|
||||||
|
value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user