[gtk/wip/otte/css: 76/85] css: Pass node through the lookup code
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/css: 76/85] css: Pass node through the lookup code
- Date: Mon, 27 Jan 2020 03:01:42 +0000 (UTC)
commit bffe3d3b172966c2bd8ddb1d1407d5102c64306c
Author: Benjamin Otte <otte redhat com>
Date: Thu Jan 23 02:42:01 2020 +0100
css: Pass node through the lookup code
... instead of passing a matcher.
The matcher code is now local to the CssProvider/CssSelector machinery.
gtk/gtkcssnode.c | 9 +--------
gtk/gtkcssprovider.c | 11 +++++++----
gtk/gtkcssstaticstyle.c | 18 +++++++++++-------
gtk/gtkcssstaticstyleprivate.h | 4 +---
gtk/gtkstylecascade.c | 4 ++--
gtk/gtkstyleprovider.c | 12 ++++++------
gtk/gtkstyleproviderprivate.h | 34 +++++++++++++++++-----------------
7 files changed, 45 insertions(+), 47 deletions(-)
---
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c
index 59e16e1495..1bf56b0646 100644
--- a/gtk/gtkcssnode.c
+++ b/gtk/gtkcssnode.c
@@ -358,8 +358,6 @@ gtk_css_node_create_style (GtkCssNode *cssnode,
GtkCssChange change)
{
const GtkCssNodeDeclaration *decl;
- GtkCssMatcher matcher;
- GtkCssStyle *parent;
GtkCssStyle *style;
GtkCssChange style_change;
@@ -371,8 +369,6 @@ gtk_css_node_create_style (GtkCssNode *cssnode,
created_styles++;
- parent = cssnode->parent ? cssnode->parent->style : NULL;
-
if (change & GTK_CSS_CHANGE_NEEDS_RECOMPUTE)
{
/* Need to recompute the change flags */
@@ -383,11 +379,8 @@ gtk_css_node_create_style (GtkCssNode *cssnode,
style_change = gtk_css_static_style_get_change (gtk_css_style_get_static_style (cssnode->style));
}
- _gtk_css_matcher_node_init (&matcher, cssnode);
-
style = gtk_css_static_style_new_compute (gtk_css_node_get_style_provider (cssnode),
- &matcher,
- parent,
+ cssnode,
style_change);
store_in_global_parent_cache (cssnode, decl, style);
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index e2d92ad32c..9ee07fcc95 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -447,13 +447,14 @@ gtk_css_style_provider_get_keyframes (GtkStyleProvider *provider,
static void
gtk_css_style_provider_lookup (GtkStyleProvider *provider,
- const GtkCssMatcher *matcher,
+ GtkCssNode *node,
GtkCssLookup *lookup,
GtkCssChange *change)
{
GtkCssProvider *css_provider = GTK_CSS_PROVIDER (provider);
GtkCssProviderPrivate *priv = gtk_css_provider_get_instance_private (css_provider);
GtkCssRuleset *ruleset;
+ GtkCssMatcher matcher;
guint j;
int i;
GPtrArray *tree_rules;
@@ -461,10 +462,12 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider,
if (_gtk_css_selector_tree_is_empty (priv->tree))
return;
- tree_rules = _gtk_css_selector_tree_match_all (priv->tree, matcher);
+ _gtk_css_matcher_node_init (&matcher, node);
+
+ tree_rules = _gtk_css_selector_tree_match_all (priv->tree, &matcher);
if (tree_rules)
{
- verify_tree_match_results (css_provider, matcher, tree_rules);
+ verify_tree_match_results (css_provider, &matcher, tree_rules);
for (i = tree_rules->len - 1; i >= 0; i--)
{
@@ -495,7 +498,7 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider,
}
if (change)
- *change = _gtk_css_selector_tree_get_change_all (priv->tree, matcher);
+ *change = _gtk_css_selector_tree_get_change_all (priv->tree, &matcher);
}
static void
diff --git a/gtk/gtkcssstaticstyle.c b/gtk/gtkcssstaticstyle.c
index 0c6b8da04b..bbae7098b4 100644
--- a/gtk/gtkcssstaticstyle.c
+++ b/gtk/gtkcssstaticstyle.c
@@ -166,8 +166,7 @@ gtk_css_static_style_get_default (void)
settings = gtk_settings_get_default ();
default_style = gtk_css_static_style_new_compute (GTK_STYLE_PROVIDER (settings),
NULL,
- NULL,
- TRUE);
+ 0);
g_object_set_data_full (G_OBJECT (settings), I_("gtk-default-style"),
default_style, clear_default_style);
}
@@ -177,18 +176,18 @@ gtk_css_static_style_get_default (void)
GtkCssStyle *
gtk_css_static_style_new_compute (GtkStyleProvider *provider,
- const GtkCssMatcher *matcher,
- GtkCssStyle *parent,
+ GtkCssNode *node,
GtkCssChange change)
{
GtkCssStaticStyle *result;
GtkCssLookup lookup;
+ GtkCssNode *parent;
_gtk_css_lookup_init (&lookup);
- if (matcher)
+ if (node)
gtk_style_provider_lookup (provider,
- matcher,
+ node,
&lookup,
change == 0 ? &change : NULL);
@@ -196,10 +195,15 @@ gtk_css_static_style_new_compute (GtkStyleProvider *provider,
result->change = change;
+ if (node)
+ parent = gtk_css_node_get_parent (node);
+ else
+ parent = NULL;
+
_gtk_css_lookup_resolve (&lookup,
provider,
result,
- parent);
+ parent ? gtk_css_node_get_style (parent) : NULL);
_gtk_css_lookup_destroy (&lookup);
diff --git a/gtk/gtkcssstaticstyleprivate.h b/gtk/gtkcssstaticstyleprivate.h
index 81c97bbdc0..1073f7bb0a 100644
--- a/gtk/gtkcssstaticstyleprivate.h
+++ b/gtk/gtkcssstaticstyleprivate.h
@@ -20,7 +20,6 @@
#ifndef __GTK_CSS_STATIC_STYLE_PRIVATE_H__
#define __GTK_CSS_STATIC_STYLE_PRIVATE_H__
-#include "gtk/gtkcssmatcherprivate.h"
#include "gtk/gtkcssstyleprivate.h"
G_BEGIN_DECLS
@@ -53,8 +52,7 @@ GType gtk_css_static_style_get_type (void) G_GNUC_CO
GtkCssStyle * gtk_css_static_style_get_default (void);
GtkCssStyle * gtk_css_static_style_new_compute (GtkStyleProvider *provider,
- const GtkCssMatcher *matcher,
- GtkCssStyle *parent,
+ GtkCssNode *node,
GtkCssChange change);
void gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
diff --git a/gtk/gtkstylecascade.c b/gtk/gtkstylecascade.c
index ea0f128481..1bc60e12be 100644
--- a/gtk/gtkstylecascade.c
+++ b/gtk/gtkstylecascade.c
@@ -180,7 +180,7 @@ gtk_style_cascade_get_keyframes (GtkStyleProvider *provider,
static void
gtk_style_cascade_lookup (GtkStyleProvider *provider,
- const GtkCssMatcher *matcher,
+ GtkCssNode *node,
GtkCssLookup *lookup,
GtkCssChange *change)
{
@@ -193,7 +193,7 @@ gtk_style_cascade_lookup (GtkStyleProvider *provider,
item;
item = gtk_style_cascade_iter_next (cascade, &iter))
{
- gtk_style_provider_lookup (item, matcher, lookup,
+ gtk_style_provider_lookup (item, node, lookup,
change ? &iter_change : NULL);
if (change)
*change |= iter_change;
diff --git a/gtk/gtkstyleprovider.c b/gtk/gtkstyleprovider.c
index 46d5755659..6dd380b95c 100644
--- a/gtk/gtkstyleprovider.c
+++ b/gtk/gtkstyleprovider.c
@@ -92,15 +92,15 @@ gtk_style_provider_get_keyframes (GtkStyleProvider *provider,
}
void
-gtk_style_provider_lookup (GtkStyleProvider *provider,
- const GtkCssMatcher *matcher,
- GtkCssLookup *lookup,
- GtkCssChange *out_change)
+gtk_style_provider_lookup (GtkStyleProvider *provider,
+ GtkCssNode *node,
+ GtkCssLookup *lookup,
+ GtkCssChange *out_change)
{
GtkStyleProviderInterface *iface;
gtk_internal_return_if_fail (GTK_IS_STYLE_PROVIDER (provider));
- gtk_internal_return_if_fail (matcher != NULL);
+ gtk_internal_return_if_fail (GTK_IS_CSS_NODE (node));
gtk_internal_return_if_fail (lookup != NULL);
if (out_change)
@@ -111,7 +111,7 @@ gtk_style_provider_lookup (GtkStyleProvider *provider,
if (!iface->lookup)
return;
- iface->lookup (provider, matcher, lookup, out_change);
+ iface->lookup (provider, node, lookup, out_change);
}
void
diff --git a/gtk/gtkstyleproviderprivate.h b/gtk/gtkstyleproviderprivate.h
index c33438dd99..2cdfbed16b 100644
--- a/gtk/gtkstyleproviderprivate.h
+++ b/gtk/gtkstyleproviderprivate.h
@@ -21,7 +21,7 @@
#include <glib-object.h>
#include "gtk/gtkcsskeyframesprivate.h"
#include "gtk/gtkcsslookupprivate.h"
-#include "gtk/gtkcssmatcherprivate.h"
+#include "gtk/gtkcssnodeprivate.h"
#include "gtk/gtkcssvalueprivate.h"
#include <gtk/gtktypes.h>
@@ -35,37 +35,37 @@ struct _GtkStyleProviderInterface
{
GTypeInterface g_iface;
- GtkCssValue * (* get_color) (GtkStyleProvider *provider,
+ GtkCssValue * (* get_color) (GtkStyleProvider *provider,
const char *name);
- GtkSettings * (* get_settings) (GtkStyleProvider *provider);
- GtkCssKeyframes * (* get_keyframes) (GtkStyleProvider *provider,
+ GtkSettings * (* get_settings) (GtkStyleProvider *provider);
+ GtkCssKeyframes * (* get_keyframes) (GtkStyleProvider *provider,
const char *name);
- int (* get_scale) (GtkStyleProvider *provider);
- void (* lookup) (GtkStyleProvider *provider,
- const GtkCssMatcher *matcher,
+ int (* get_scale) (GtkStyleProvider *provider);
+ void (* lookup) (GtkStyleProvider *provider,
+ GtkCssNode *node,
GtkCssLookup *lookup,
GtkCssChange *out_change);
- void (* emit_error) (GtkStyleProvider *provider,
+ void (* emit_error) (GtkStyleProvider *provider,
GtkCssSection *section,
const GError *error);
/* signal */
- void (* changed) (GtkStyleProvider *provider);
+ void (* changed) (GtkStyleProvider *provider);
};
-GtkSettings * gtk_style_provider_get_settings (GtkStyleProvider *provider);
-GtkCssValue * gtk_style_provider_get_color (GtkStyleProvider *provider,
+GtkSettings * gtk_style_provider_get_settings (GtkStyleProvider *provider);
+GtkCssValue * gtk_style_provider_get_color (GtkStyleProvider *provider,
const char *name);
-GtkCssKeyframes * gtk_style_provider_get_keyframes (GtkStyleProvider *provider,
+GtkCssKeyframes * gtk_style_provider_get_keyframes (GtkStyleProvider *provider,
const char *name);
-int gtk_style_provider_get_scale (GtkStyleProvider *provider);
-void gtk_style_provider_lookup (GtkStyleProvider *provider,
- const GtkCssMatcher *matcher,
+int gtk_style_provider_get_scale (GtkStyleProvider *provider);
+void gtk_style_provider_lookup (GtkStyleProvider *provider,
+ GtkCssNode *node,
GtkCssLookup *lookup,
GtkCssChange *out_change);
-void gtk_style_provider_changed (GtkStyleProvider *provider);
+void gtk_style_provider_changed (GtkStyleProvider *provider);
-void gtk_style_provider_emit_error (GtkStyleProvider *provider,
+void gtk_style_provider_emit_error (GtkStyleProvider *provider,
GtkCssSection *section,
GError *error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]