[gtk+] stylecontext: Handle querying the wrong state better
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] stylecontext: Handle querying the wrong state better
- Date: Tue, 21 Oct 2014 01:04:15 +0000 (UTC)
commit a3995d8c86e80d39d6044f3f976c9f6deef1fa05
Author: Benjamin Otte <otte redhat com>
Date: Tue Oct 21 02:06:46 2014 +0200
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, since 3a337156d11a86c7a88f1f30a09276fdf6f63008 this
has the unfortunate side effect that it also creates a child element.
This breaks various old codebases (spinbutton has been fixed in
998feeb2bc3e37275cfe915e128179d2704ca9c8, 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.
gtk/gtkstylecontext.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 3752ce3..4cb8348 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]