static void store_in_global_parent_cache (GtkCssNode *node, GtkCssStyle *parent, const GtkCssNodeDeclaration *decl, GtkCssStyle *style) { GHashTable *cache; g_assert (GTK_IS_CSS_STATIC_STYLE (style)); if (parent == NULL || !may_use_global_parent_cache (node)) return; if (!may_be_stored_in_parent_cache (style)) return; cache = g_object_get_data (G_OBJECT (parent), "gtk-global-cache"); if (cache == NULL) { cache = g_hash_table_new_full (gtk_global_parent_cache_hash, gtk_global_parent_cache_equal, gtk_global_parent_cache_free, g_object_unref); g_object_set_data_full (G_OBJECT (parent), "gtk-global-cache", cache, (GDestroyNotify) g_hash_table_destroy); } g_hash_table_insert (cache, PACK (gtk_css_node_declaration_ref ((GtkCssNodeDeclaration *) decl), gtk_css_node_get_previous_sibling (node) == NULL, gtk_css_node_get_next_sibling (node) == NULL), g_object_ref (style)); }
static GtkCssNode * get_previous_visible_sibling (GtkCssNode *node) { do { node = gtk_css_node_get_previous_sibling (node); } while (node && !gtk_css_node_get_visible (node)); return node; }
static GtkCssStyle * lookup_in_global_parent_cache (GtkCssNode *node, GtkCssStyle *parent, const GtkCssNodeDeclaration *decl) { GHashTable *cache; GtkCssStyle *style; if (parent == NULL || !may_use_global_parent_cache (node)) return NULL; cache = g_object_get_qdata (G_OBJECT (parent), quark_global_cache); if (cache == NULL) return NULL; style = g_hash_table_lookup (cache, PACK (decl, gtk_css_node_get_previous_sibling (node) == NULL, gtk_css_node_get_next_sibling (node) == NULL)); return style; }