csslookup: Remove 'missing' bitmask

It's almost never useful to have a bitmask here, since it's only used
for the intersection case in gtk_css_style_provider_lookup. However,
even if that returns true, we still need to check every single style
property for being set again in the look afterwards.

Just remove the bitmask.
This commit is contained in:
Timm Bäder 2019-08-22 18:00:37 +02:00
parent ceb8aedf97
commit ecad4743bd
3 changed files with 13 additions and 31 deletions

View File

@ -29,22 +29,11 @@ _gtk_css_lookup_init (GtkCssLookup *lookup,
const GtkBitmask *relevant) const GtkBitmask *relevant)
{ {
memset (lookup, 0, sizeof (*lookup)); memset (lookup, 0, sizeof (*lookup));
if (relevant)
{
lookup->missing = _gtk_bitmask_copy (relevant);
}
else
{
lookup->missing = _gtk_bitmask_new ();
lookup->missing = _gtk_bitmask_invert_range (lookup->missing, 0, GTK_CSS_PROPERTY_N_PROPERTIES);
}
} }
void void
_gtk_css_lookup_destroy (GtkCssLookup *lookup) _gtk_css_lookup_destroy (GtkCssLookup *lookup)
{ {
_gtk_bitmask_free (lookup->missing);
} }
gboolean gboolean
@ -53,7 +42,13 @@ _gtk_css_lookup_is_missing (const GtkCssLookup *lookup,
{ {
gtk_internal_return_val_if_fail (lookup != NULL, FALSE); gtk_internal_return_val_if_fail (lookup != NULL, FALSE);
return _gtk_bitmask_get (lookup->missing, id); return lookup->values[id].value == NULL;
}
gboolean
_gtk_css_lookup_all_set (const GtkCssLookup *lookup)
{
return lookup->n_set_values == GTK_CSS_PROPERTY_N_PROPERTIES;
} }
/** /**
@ -76,12 +71,12 @@ _gtk_css_lookup_set (GtkCssLookup *lookup,
GtkCssValue *value) GtkCssValue *value)
{ {
gtk_internal_return_if_fail (lookup != NULL); gtk_internal_return_if_fail (lookup != NULL);
gtk_internal_return_if_fail (_gtk_bitmask_get (lookup->missing, id));
gtk_internal_return_if_fail (value != NULL); gtk_internal_return_if_fail (value != NULL);
gtk_internal_return_if_fail (lookup->values[id].value == NULL);
lookup->missing = _gtk_bitmask_set (lookup->missing, id, FALSE);
lookup->values[id].value = value; lookup->values[id].value = value;
lookup->values[id].section = section; lookup->values[id].section = section;
lookup->n_set_values ++;
} }
/** /**

View File

@ -36,17 +36,16 @@ typedef struct {
} GtkCssLookupValue; } GtkCssLookupValue;
struct _GtkCssLookup { struct _GtkCssLookup {
GtkBitmask *missing; guint n_set_values;
GtkCssLookupValue values[GTK_CSS_PROPERTY_N_PROPERTIES]; GtkCssLookupValue values[GTK_CSS_PROPERTY_N_PROPERTIES];
}; };
void _gtk_css_lookup_init (GtkCssLookup *lookup, void _gtk_css_lookup_init (GtkCssLookup *lookup,
const GtkBitmask *relevant); const GtkBitmask *relevant);
void _gtk_css_lookup_destroy (GtkCssLookup *lookup); void _gtk_css_lookup_destroy (GtkCssLookup *lookup);
static inline const GtkBitmask *_gtk_css_lookup_get_missing (const GtkCssLookup *lookup);
gboolean _gtk_css_lookup_is_missing (const GtkCssLookup *lookup, gboolean _gtk_css_lookup_is_missing (const GtkCssLookup *lookup,
guint id); guint id);
gboolean _gtk_css_lookup_all_set (const GtkCssLookup *lookup);
void _gtk_css_lookup_set (GtkCssLookup *lookup, void _gtk_css_lookup_set (GtkCssLookup *lookup,
guint id, guint id,
GtkCssSection *section, GtkCssSection *section,
@ -56,14 +55,6 @@ void _gtk_css_lookup_resolve (GtkCssLookup
GtkCssStaticStyle *style, GtkCssStaticStyle *style,
GtkCssStyle *parent_style); GtkCssStyle *parent_style);
static inline const GtkBitmask *
_gtk_css_lookup_get_missing (const GtkCssLookup *lookup)
{
return lookup->missing;
}
G_END_DECLS G_END_DECLS
#endif /* __GTK_CSS_LOOKUP_PRIVATE_H__ */ #endif /* __GTK_CSS_LOOKUP_PRIVATE_H__ */

View File

@ -539,10 +539,6 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider,
if (ruleset->styles == NULL) if (ruleset->styles == NULL)
continue; continue;
if (!_gtk_bitmask_intersects (_gtk_css_lookup_get_missing (lookup),
ruleset->set_styles))
continue;
for (j = 0; j < ruleset->n_styles; j++) for (j = 0; j < ruleset->n_styles; j++)
{ {
GtkCssStyleProperty *prop = ruleset->styles[j].property; GtkCssStyleProperty *prop = ruleset->styles[j].property;
@ -554,10 +550,10 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider,
_gtk_css_lookup_set (lookup, _gtk_css_lookup_set (lookup,
id, id,
ruleset->styles[j].section, ruleset->styles[j].section,
ruleset->styles[j].value); ruleset->styles[j].value);
} }
if (_gtk_bitmask_is_empty (_gtk_css_lookup_get_missing (lookup))) if (_gtk_css_lookup_all_set (lookup))
break; break;
} }