css: Split style into groups

This commit is contained in:
Matthias Clasen 2020-01-25 23:16:06 -05:00
parent 53c22bf833
commit 0df0de0b5d
5 changed files with 1323 additions and 32 deletions

View File

@ -28,11 +28,14 @@ void
_gtk_css_lookup_init (GtkCssLookup *lookup)
{
memset (lookup, 0, sizeof (*lookup));
lookup->set_values = _gtk_bitmask_new ();
}
void
_gtk_css_lookup_destroy (GtkCssLookup *lookup)
{
_gtk_bitmask_free (lookup->set_values);
}
gboolean
@ -41,13 +44,7 @@ _gtk_css_lookup_is_missing (const GtkCssLookup *lookup,
{
gtk_internal_return_val_if_fail (lookup != NULL, FALSE);
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;
return !_gtk_bitmask_get (lookup->set_values, id);
}
/**
@ -75,7 +72,7 @@ _gtk_css_lookup_set (GtkCssLookup *lookup,
lookup->values[id].value = value;
lookup->values[id].section = section;
lookup->n_set_values ++;
lookup->set_values = _gtk_bitmask_set (lookup->set_values, id, TRUE);
}
/**

View File

@ -36,7 +36,7 @@ typedef struct {
} GtkCssLookupValue;
struct _GtkCssLookup {
guint n_set_values;
GtkBitmask *set_values;
GtkCssLookupValue values[GTK_CSS_PROPERTY_N_PROPERTIES];
};
@ -44,7 +44,6 @@ void _gtk_css_lookup_init (GtkCssLookup
void _gtk_css_lookup_destroy (GtkCssLookup *lookup);
gboolean _gtk_css_lookup_is_missing (const GtkCssLookup *lookup,
guint id);
gboolean _gtk_css_lookup_all_set (const GtkCssLookup *lookup);
void _gtk_css_lookup_set (GtkCssLookup *lookup,
guint id,
GtkCssSection *section,
@ -54,6 +53,12 @@ void _gtk_css_lookup_resolve (GtkCssLookup
GtkCssStaticStyle *style,
GtkCssStyle *parent_style);
static inline const GtkBitmask *
_gtk_css_lookup_get_set_values (const GtkCssLookup *lookup)
{
return lookup->set_values;
}
G_END_DECLS
#endif /* __GTK_CSS_LOOKUP_PRIVATE_H__ */

View File

@ -487,9 +487,6 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider,
ruleset->styles[j].section,
ruleset->styles[j].value);
}
if (_gtk_css_lookup_all_set (lookup))
break;
}
g_ptr_array_free (tree_rules, TRUE);

File diff suppressed because it is too large Load Diff

View File

@ -34,11 +34,164 @@ G_BEGIN_DECLS
typedef struct _GtkCssStaticStyleClass GtkCssStaticStyleClass;
/* inherited */
typedef struct {
int ref_count;
GtkCssValue *color;
GtkCssValue *dpi;
GtkCssValue *font_size;
GtkCssValue *icon_theme;
GtkCssValue *icon_palette;
} GtkCssCoreValues;
typedef struct {
int ref_count;
GtkCssValue *background_color;
GtkCssValue *box_shadow;
GtkCssValue *background_clip;
GtkCssValue *background_origin;
GtkCssValue *background_size;
GtkCssValue *background_position;
GtkCssValue *background_repeat;
GtkCssValue *background_image;
GtkCssValue *background_blend_mode;
} GtkCssBackgroundValues;
typedef struct {
int ref_count;
GtkCssValue *border_top_style;
GtkCssValue *border_top_width;
GtkCssValue *border_left_style;
GtkCssValue *border_left_width;
GtkCssValue *border_bottom_style;
GtkCssValue *border_bottom_width;
GtkCssValue *border_right_style;
GtkCssValue *border_right_width;
GtkCssValue *border_top_left_radius;
GtkCssValue *border_top_right_radius;
GtkCssValue *border_bottom_right_radius;
GtkCssValue *border_bottom_left_radius;
GtkCssValue *border_top_color;
GtkCssValue *border_right_color;
GtkCssValue *border_bottom_color;
GtkCssValue *border_left_color;
GtkCssValue *border_image_source;
GtkCssValue *border_image_repeat;
GtkCssValue *border_image_slice;
GtkCssValue *border_image_width;
} GtkCssBorderValues;
/* inherited */
typedef struct {
int ref_count;
GtkCssValue *icon_size;
GtkCssValue *icon_shadow;
GtkCssValue *icon_style;
} GtkCssIconValues;
typedef struct {
int ref_count;
GtkCssValue *outline_style;
GtkCssValue *outline_width;
GtkCssValue *outline_offset;
GtkCssValue *outline_top_left_radius;
GtkCssValue *outline_top_right_radius;
GtkCssValue *outline_bottom_right_radius;
GtkCssValue *outline_bottom_left_radius;
GtkCssValue *outline_color;
} GtkCssOutlineValues;
/* inherited */
typedef struct {
int ref_count;
GtkCssValue *font_family;
GtkCssValue *font_style;
GtkCssValue *font_weight;
GtkCssValue *font_stretch;
GtkCssValue *letter_spacing;
GtkCssValue *text_shadow;
GtkCssValue *caret_color;
GtkCssValue *secondary_caret_color;
GtkCssValue *font_feature_settings;
GtkCssValue *font_variation_settings;
} GtkCssFontValues;
typedef struct {
int ref_count;
GtkCssValue *text_decoration_line;
GtkCssValue *text_decoration_color;
GtkCssValue *text_decoration_style;
GtkCssValue *font_kerning;
GtkCssValue *font_variant_ligatures;
GtkCssValue *font_variant_position;
GtkCssValue *font_variant_caps;
GtkCssValue *font_variant_numeric;
GtkCssValue *font_variant_alternates;
GtkCssValue *font_variant_east_asian;
} GtkCssFontVariantValues;
typedef struct {
int ref_count;
GtkCssValue *animation_name;
GtkCssValue *animation_duration;
GtkCssValue *animation_timing_function;
GtkCssValue *animation_iteration_count;
GtkCssValue *animation_direction;
GtkCssValue *animation_play_state;
GtkCssValue *animation_delay;
GtkCssValue *animation_fill_mode;
} GtkCssAnimationValues;
typedef struct {
int ref_count;
GtkCssValue *transition_property;
GtkCssValue *transition_duration;
GtkCssValue *transition_timing_function;
GtkCssValue *transition_delay;
} GtkCssTransitionValues;
typedef struct {
int ref_count;
GtkCssValue *margin_top;
GtkCssValue *margin_left;
GtkCssValue *margin_bottom;
GtkCssValue *margin_right;
GtkCssValue *padding_top;
GtkCssValue *padding_left;
GtkCssValue *padding_bottom;
GtkCssValue *padding_right;
GtkCssValue *border_spacing;
GtkCssValue *min_width;
GtkCssValue *min_height;
} GtkCssSizeValues;
typedef struct {
int ref_count;
GtkCssValue *icon_source;
GtkCssValue *icon_transform;
GtkCssValue *icon_filter;
GtkCssValue *transform;
GtkCssValue *opacity;
GtkCssValue *filter;
} GtkCssOtherValues;
struct _GtkCssStaticStyle
{
GtkCssStyle parent;
GtkCssValue *values[GTK_CSS_PROPERTY_N_PROPERTIES]; /* the values */
GtkCssCoreValues *core;
GtkCssBackgroundValues *background;
GtkCssBorderValues *border;
GtkCssIconValues *icon;
GtkCssOutlineValues *outline;
GtkCssFontValues *font;
GtkCssFontVariantValues *font_variant;
GtkCssAnimationValues *animation;
GtkCssTransitionValues *transition;
GtkCssSizeValues *size;
GtkCssOtherValues *other;
GPtrArray *sections; /* sections the values are defined in */
GtkCssChange change; /* change as returned by value lookup */