Commit 492469a9 authored by Timm Bäder's avatar Timm Bäder 👎 Committed by Matthias Clasen

css: Replace _AFFECTS_TEXT with _TEXT_SIZE and _TEXT_CLIP

It was used to mark css properties that affect widgets with text, but it
caused unnecessary invalidations. E.g. 'color' was marked as
AFFECTS_TEXT but changing just the color of a label should not
automatically queue a resize, which is what the code in
gtk_widget_real_style_updated does.

Replace this flag with GTK_CSS_AFFECTS_TEXT_SIZE and
GTK_CSS_AFFECTS_TEXT_CLIP, which GtkWidget can use only if the widget
actually has text.

https://bugzilla.gnome.org/show_bug.cgi?id=791281
parent ecc99465
......@@ -167,7 +167,7 @@ gtk_builtin_icon_style_changed (GtkCssGadget *gadget,
{
GtkBuiltinIconPrivate *priv = gtk_builtin_icon_get_instance_private (GTK_BUILTIN_ICON (gadget));
if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_FONT))
if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT))
priv->strikethrough_valid = FALSE;
GTK_CSS_GADGET_CLASS (gtk_builtin_icon_parent_class)->style_changed (gadget, change);
......
......@@ -1058,7 +1058,7 @@ _gtk_css_style_property_init_properties (void)
GTK_CSS_PROPERTY_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_FOREGROUND | GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_SYMBOLIC_ICON,
GTK_CSS_AFFECTS_CONTENT | GTK_CSS_AFFECTS_SYMBOLIC_ICON,
color_parse,
color_query,
color_assign,
......@@ -1067,7 +1067,7 @@ _gtk_css_style_property_init_properties (void)
GTK_CSS_PROPERTY_DPI,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_FONT | GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_SIZE,
GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_TEXT_SIZE,
dpi_parse,
NULL,
NULL,
......@@ -1076,7 +1076,7 @@ _gtk_css_style_property_init_properties (void)
GTK_CSS_PROPERTY_FONT_SIZE,
G_TYPE_DOUBLE,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_FONT | GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_SIZE,
GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_TEXT_SIZE,
font_size_parse,
query_font_size,
assign_font_size,
......@@ -1117,7 +1117,7 @@ _gtk_css_style_property_init_properties (void)
GTK_CSS_PROPERTY_FONT_FAMILY,
G_TYPE_STRV,
GTK_STYLE_PROPERTY_INHERIT,
GTK_CSS_AFFECTS_FONT | GTK_CSS_AFFECTS_TEXT,
GTK_CSS_AFFECTS_TEXT_SIZE,
font_family_parse,
font_family_query,
font_family_assign,
......@@ -1126,7 +1126,7 @@ _gtk_css_style_property_init_properties (void)
GTK_CSS_PROPERTY_FONT_STYLE,
PANGO_TYPE_STYLE,
GTK_STYLE_PROPERTY_INHERIT,
GTK_CSS_AFFECTS_FONT | GTK_CSS_AFFECTS_TEXT,
GTK_CSS_AFFECTS_TEXT_SIZE,
font_style_parse,
font_style_query,
font_style_assign,
......@@ -1135,7 +1135,7 @@ _gtk_css_style_property_init_properties (void)
GTK_CSS_PROPERTY_FONT_VARIANT,
PANGO_TYPE_VARIANT,
GTK_STYLE_PROPERTY_INHERIT,
GTK_CSS_AFFECTS_FONT | GTK_CSS_AFFECTS_TEXT,
GTK_CSS_AFFECTS_TEXT,
font_variant_parse,
font_variant_query,
font_variant_assign,
......@@ -1144,7 +1144,7 @@ _gtk_css_style_property_init_properties (void)
GTK_CSS_PROPERTY_FONT_WEIGHT,
PANGO_TYPE_WEIGHT,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_FONT | GTK_CSS_AFFECTS_TEXT,
GTK_CSS_AFFECTS_TEXT_SIZE,
font_weight_parse,
font_weight_query,
font_weight_assign,
......@@ -1153,7 +1153,7 @@ _gtk_css_style_property_init_properties (void)
GTK_CSS_PROPERTY_FONT_STRETCH,
PANGO_TYPE_STRETCH,
GTK_STYLE_PROPERTY_INHERIT,
GTK_CSS_AFFECTS_FONT | GTK_CSS_AFFECTS_TEXT,
GTK_CSS_AFFECTS_TEXT_SIZE,
font_stretch_parse,
font_stretch_query,
font_stretch_assign,
......@@ -1163,7 +1163,7 @@ _gtk_css_style_property_init_properties (void)
GTK_CSS_PROPERTY_LETTER_SPACING,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_TEXT_ATTRS,
GTK_CSS_AFFECTS_TEXT_ATTRS,
parse_letter_spacing,
NULL,
NULL,
......@@ -1173,7 +1173,7 @@ _gtk_css_style_property_init_properties (void)
GTK_CSS_PROPERTY_TEXT_DECORATION_LINE,
G_TYPE_NONE,
0,
GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_TEXT_ATTRS,
GTK_CSS_AFFECTS_TEXT_ATTRS,
parse_text_decoration_line,
NULL,
NULL,
......@@ -1182,7 +1182,7 @@ _gtk_css_style_property_init_properties (void)
GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_TEXT_ATTRS,
GTK_CSS_AFFECTS_TEXT_ATTRS,
color_parse,
NULL,
NULL,
......@@ -1191,7 +1191,7 @@ _gtk_css_style_property_init_properties (void)
GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE,
G_TYPE_NONE,
0,
GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_TEXT_ATTRS,
GTK_CSS_AFFECTS_TEXT_ATTRS,
parse_text_decoration_style,
NULL,
NULL,
......@@ -1201,7 +1201,7 @@ _gtk_css_style_property_init_properties (void)
GTK_CSS_PROPERTY_TEXT_SHADOW,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_CLIP,
GTK_CSS_AFFECTS_TEXT_CLIP,
shadow_value_parse,
NULL,
NULL,
......@@ -1855,7 +1855,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
GTK_CSS_PROPERTY_CARET_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_TEXT,
GTK_CSS_AFFECTS_CONTENT,
color_parse,
color_query,
color_assign,
......@@ -1864,7 +1864,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_TEXT,
GTK_CSS_AFFECTS_CONTENT,
color_parse,
color_query,
color_assign,
......
......@@ -96,13 +96,10 @@ typedef guint64 GtkCssChange;
/*
* GtkCssAffects:
* @GTK_CSS_AFFECTS_FOREGROUND: The foreground rendering is affected.
* This does not include things that affect the font. For those,
* see @GTK_CSS_AFFECTS_FONT.
* This does not include things that affect the font.
* @GTK_CSS_AFFECTS_BACKGROUND: The background rendering is affected.
* @GTK_CSS_AFFECTS_BORDER: The border styling is affected.
* @GTK_CSS_AFFECTS_PANGO_LAYOUT: Font rendering is affected.
* @GTK_CSS_AFFECTS_FONT: The font is affected and should be reloaded
* if it was cached.
* @GTK_CSS_AFFECTS_TEXT: Text rendering is affected.
* @GTK_CSS_AFFECTS_TEXT_ATTRS: Text attributes are affected.
* @GTK_CSS_AFFECTS_ICON: Fullcolor icons and their rendering is affected.
......@@ -122,26 +119,31 @@ typedef guint64 GtkCssChange;
* Note that multiple values can be set.
*/
typedef enum {
GTK_CSS_AFFECTS_FOREGROUND = (1 << 0),
GTK_CSS_AFFECTS_BACKGROUND = (1 << 1),
GTK_CSS_AFFECTS_BORDER = (1 << 2),
GTK_CSS_AFFECTS_FONT = (1 << 3),
GTK_CSS_AFFECTS_TEXT = (1 << 4),
GTK_CSS_AFFECTS_TEXT_ATTRS = (1 << 5),
GTK_CSS_AFFECTS_ICON = (1 << 6),
GTK_CSS_AFFECTS_SYMBOLIC_ICON = (1 << 7),
GTK_CSS_AFFECTS_OUTLINE = (1 << 8),
GTK_CSS_AFFECTS_CLIP = (1 << 9),
GTK_CSS_AFFECTS_SIZE = (1 << 10)
GTK_CSS_AFFECTS_CONTENT = (1 << 0),
GTK_CSS_AFFECTS_BACKGROUND = (1 << 1),
GTK_CSS_AFFECTS_BORDER = (1 << 2),
GTK_CSS_AFFECTS_TEXT_ATTRS = (1 << 4),
GTK_CSS_AFFECTS_TEXT_SIZE = (1 << 5),
GTK_CSS_AFFECTS_TEXT_CLIP = (1 << 6),
GTK_CSS_AFFECTS_ICON = (1 << 7),
GTK_CSS_AFFECTS_SYMBOLIC_ICON = (1 << 8),
GTK_CSS_AFFECTS_OUTLINE = (1 << 9),
GTK_CSS_AFFECTS_CLIP = (1 << 10),
GTK_CSS_AFFECTS_SIZE = (1 << 11),
GTK_CSS_AFFECTS_POSTEFFECT = (1 << 12)
} GtkCssAffects;
#define GTK_CSS_AFFECTS_REDRAW (GTK_CSS_AFFECTS_FOREGROUND | \
#define GTK_CSS_AFFECTS_REDRAW (GTK_CSS_AFFECTS_CONTENT | \
GTK_CSS_AFFECTS_BACKGROUND | \
GTK_CSS_AFFECTS_BORDER | \
GTK_CSS_AFFECTS_ICON | \
GTK_CSS_AFFECTS_SYMBOLIC_ICON | \
GTK_CSS_AFFECTS_OUTLINE)
#define GTK_CSS_AFFECTS_TEXT (GTK_CSS_AFFECTS_TEXT_SIZE | \
GTK_CSS_AFFECTS_TEXT_CLIP)
enum { /*< skip >*/
GTK_CSS_PROPERTY_COLOR,
GTK_CSS_PROPERTY_DPI,
......
......@@ -1521,7 +1521,7 @@ gtk_progress_bar_text_style_changed (GtkCssNode *node,
{
if (change == NULL ||
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT_ATTRS) ||
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_FONT))
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT))
{
gtk_widget_queue_resize (GTK_WIDGET (pbar));
}
......
......@@ -1594,7 +1594,7 @@ gtk_scale_value_style_changed (GtkCssNode *node,
{
if (change == NULL ||
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT_ATTRS) ||
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_FONT))
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT))
{
gtk_scale_clear_value_layout (scale);
gtk_widget_queue_resize (GTK_WIDGET (scale));
......@@ -1608,7 +1608,7 @@ gtk_scale_mark_style_changed (GtkCssNode *node,
{
if (change == NULL ||
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT_ATTRS) ||
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_FONT))
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT))
{
GtkCssNode *widget_node;
GtkWidget *scale;
......
......@@ -332,7 +332,7 @@ gtk_switch_style_updated (GtkWidget *widget)
context = gtk_widget_get_style_context (widget);
change = gtk_style_context_get_change (context);
if (change == NULL || gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_FONT))
if (change == NULL || gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT))
gtk_switch_create_pango_layouts (self);
}
......
......@@ -4895,7 +4895,7 @@ gtk_text_view_style_updated (GtkWidget *widget)
style_context = gtk_widget_get_style_context (widget);
change = gtk_style_context_get_change (style_context);
if ((change == NULL || gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_FONT)) &&
if ((change == NULL || gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT)) &&
priv->layout && priv->layout->default_style)
{
gtk_text_view_set_attributes_from_style (text_view,
......
......@@ -8168,22 +8168,29 @@ gtk_widget_real_style_updated (GtkWidget *widget)
if (widget->priv->context)
{
GtkCssStyleChange *change = gtk_style_context_get_change (widget->priv->context);
gboolean has_text = gtk_widget_peek_pango_context (widget) != NULL;
const gboolean has_text = gtk_widget_peek_pango_context (widget) != NULL;
if (change == NULL ||
(has_text && gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_FONT)))
if (has_text && gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT))
gtk_widget_update_pango_context (widget);
if (widget->priv->anchored)
{
if (change == NULL ||
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE) ||
(has_text && gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT)))
gtk_widget_queue_resize (widget);
else if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_CLIP))
gtk_widget_queue_allocate (widget);
(has_text && gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT_SIZE)))
{
gtk_widget_queue_resize (widget);
}
else if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_CLIP) ||
(has_text && gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT_CLIP)))
{
gtk_widget_queue_allocate (widget);
}
else if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_REDRAW))
gtk_widget_queue_draw (widget);
{
gtk_widget_queue_draw (widget);
}
}
}
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment