stylecontext: Handle querying the wrong state better
When a getter function (like get_color()) is called and the passed in state doesn't match the current state returned via get_state(), we used to do a trick: We called save()/set_state() on the context before getting the values. Unfortunately, since3a337156d1this has the unfortunate side effect that it also creates a child element. This breaks various old codebases (spinbutton has been fixed in998feeb2bc, Webkit is fixed in https://bugs.webkit.org/show_bug.cgi?id=137803 ) unfortunately. So instead, look up the values manually ensuring that no child element is created but the correct state is used.
This commit is contained in:
@ -738,15 +738,17 @@ static GtkCssComputedValues *
|
||||
style_values_lookup_for_state (GtkStyleContext *context,
|
||||
GtkStateFlags state)
|
||||
{
|
||||
GtkCssNodeDeclaration *decl;
|
||||
GtkCssComputedValues *values;
|
||||
|
||||
if (gtk_css_node_declaration_get_state (context->priv->info->decl) == state)
|
||||
return g_object_ref (style_values_lookup (context));
|
||||
|
||||
gtk_style_context_save (context);
|
||||
gtk_style_context_set_state (context, state);
|
||||
values = g_object_ref (style_values_lookup (context));
|
||||
gtk_style_context_restore (context);
|
||||
decl = gtk_css_node_declaration_ref (context->priv->info->decl);
|
||||
gtk_css_node_declaration_set_state (&decl, state);
|
||||
values = _gtk_css_computed_values_new ();
|
||||
build_properties (context, values, decl, NULL);
|
||||
gtk_css_node_declaration_unref (decl);
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user