GtkCssStyle * gtk_css_node_get_style (GtkCssNode *cssnode) { if (gtk_css_node_needs_new_style (cssnode)) { gint64 timestamp = gtk_css_node_get_timestamp (cssnode); gtk_css_node_ensure_style (cssnode, timestamp); } return cssnode->style; }
static void gtk_css_node_ensure_style (GtkCssNode *cssnode, gint64 current_time) { gboolean style_changed; if (!gtk_css_node_needs_new_style (cssnode)) return; if (cssnode->parent) gtk_css_node_ensure_style (cssnode->parent, current_time); if (cssnode->style_is_invalid) { GtkCssStyle *new_style; if (cssnode->previous_sibling) gtk_css_node_ensure_style (cssnode->previous_sibling, current_time); new_style = GTK_CSS_NODE_GET_CLASS (cssnode)->update_style (cssnode, cssnode->pending_changes, current_time, cssnode->style); style_changed = gtk_css_node_set_style (cssnode, new_style); g_object_unref (new_style); if (!style_changed && (cssnode->pending_changes & GTK_CSS_CHANGE_SOURCE)) { /* clear the global cache if we reuse the same style after the CSS changed */ g_object_set_qdata (G_OBJECT (cssnode->style), quark_global_cache, NULL); } } else { style_changed = FALSE; } gtk_css_node_propagate_pending_changes (cssnode, style_changed); cssnode->pending_changes = 0; cssnode->style_is_invalid = FALSE; }
static void gtk_css_node_ensure_style (GtkCssNode *cssnode, gint64 current_time) { gboolean style_changed; if (!gtk_css_node_needs_new_style (cssnode)) return; if (cssnode->parent) gtk_css_node_ensure_style (cssnode->parent, current_time); if (cssnode->style_is_invalid) { GtkCssStyle *new_style; if (cssnode->previous_sibling) gtk_css_node_ensure_style (cssnode->previous_sibling, current_time); g_clear_pointer (&cssnode->cache, gtk_css_node_style_cache_unref); new_style = GTK_CSS_NODE_GET_CLASS (cssnode)->update_style (cssnode, cssnode->pending_changes, current_time, cssnode->style); style_changed = gtk_css_node_set_style (cssnode, new_style); g_object_unref (new_style); } else { style_changed = FALSE; } gtk_css_node_propagate_pending_changes (cssnode, style_changed); cssnode->pending_changes = 0; cssnode->style_is_invalid = FALSE; }