forked from AuroraMiddleware/gtk
cssnode: Change get_style_provider() vfunc
Instead of always returning a provider, allow the vfunc to return NULL to mane "use same provider as parent". This allows a bunch of optimizations.
This commit is contained in:
parent
c0f6e746a0
commit
16b8972bee
@ -29,6 +29,12 @@
|
||||
|
||||
G_DEFINE_TYPE (GtkCssNode, gtk_css_node, G_TYPE_OBJECT)
|
||||
|
||||
static GtkStyleProviderPrivate *
|
||||
gtk_css_node_get_style_provider_or_null (GtkCssNode *cssnode)
|
||||
{
|
||||
return GTK_CSS_NODE_GET_CLASS (cssnode)->get_style_provider (cssnode);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_node_set_invalid (GtkCssNode *node,
|
||||
gboolean invalid)
|
||||
@ -82,13 +88,15 @@ gtk_css_node_finalize (GObject *object)
|
||||
static gboolean
|
||||
may_use_global_parent_cache (GtkCssNode *node)
|
||||
{
|
||||
GtkStyleProviderPrivate *provider;
|
||||
GtkCssNode *parent;
|
||||
|
||||
parent = gtk_css_node_get_parent (node);
|
||||
if (parent == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (gtk_css_node_get_style_provider (node) != gtk_css_node_get_style_provider (parent))
|
||||
provider = gtk_css_node_get_style_provider_or_null (node);
|
||||
if (provider != NULL && provider != gtk_css_node_get_style_provider (parent))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
@ -275,10 +283,7 @@ gtk_css_node_real_get_widget_path (GtkCssNode *cssnode)
|
||||
static GtkStyleProviderPrivate *
|
||||
gtk_css_node_real_get_style_provider (GtkCssNode *cssnode)
|
||||
{
|
||||
if (cssnode->parent)
|
||||
return gtk_css_node_get_style_provider (cssnode->parent);
|
||||
|
||||
return GTK_STYLE_PROVIDER_PRIVATE (_gtk_settings_get_style_cascade (gtk_settings_get_default (), 1));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -821,5 +826,14 @@ gtk_css_node_get_widget_path (GtkCssNode *cssnode)
|
||||
GtkStyleProviderPrivate *
|
||||
gtk_css_node_get_style_provider (GtkCssNode *cssnode)
|
||||
{
|
||||
return GTK_CSS_NODE_GET_CLASS (cssnode)->get_style_provider (cssnode);
|
||||
GtkStyleProviderPrivate *result;
|
||||
|
||||
result = gtk_css_node_get_style_provider_or_null (cssnode);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (cssnode->parent)
|
||||
return gtk_css_node_get_style_provider (cssnode->parent);
|
||||
|
||||
return GTK_STYLE_PROVIDER_PRIVATE (_gtk_settings_get_style_cascade (gtk_settings_get_default (), 1));
|
||||
}
|
||||
|
@ -68,6 +68,7 @@ struct _GtkCssNodeClass
|
||||
GtkCssMatcher *matcher);
|
||||
GtkWidgetPath * (* create_widget_path) (GtkCssNode *cssnode);
|
||||
const GtkWidgetPath * (* get_widget_path) (GtkCssNode *cssnode);
|
||||
/* get style provider to use or NULL to use parent's */
|
||||
GtkStyleProviderPrivate *(* get_style_provider) (GtkCssNode *cssnode);
|
||||
GtkCssStyle * (* update_style) (GtkCssNode *cssnode,
|
||||
GtkCssChange pending_changes,
|
||||
|
@ -107,7 +107,7 @@ gtk_css_path_node_get_style_provider (GtkCssNode *node)
|
||||
GtkCssPathNode *path_node = GTK_CSS_PATH_NODE (node);
|
||||
|
||||
if (path_node->context == NULL)
|
||||
return GTK_CSS_NODE_CLASS (gtk_css_path_node_parent_class)->get_style_provider (node);
|
||||
return NULL;
|
||||
|
||||
return gtk_style_context_get_style_provider (path_node->context);
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ gtk_css_widget_node_get_style_provider (GtkCssNode *node)
|
||||
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
|
||||
|
||||
if (widget_node->widget == NULL)
|
||||
return GTK_CSS_NODE_CLASS (gtk_css_widget_node_parent_class)->get_style_provider (node);
|
||||
return NULL;
|
||||
|
||||
return gtk_style_context_get_style_provider (gtk_widget_get_style_context (widget_node->widget));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user