diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-01-12 00:53:51 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-01-15 11:14:51 -0500 |
commit | 7a5ab6eea0af6b417a47d6bb61f950e79ac69053 (patch) | |
tree | 434c887aed97cbdf70d390a2f8a244ef8f2288cf | |
parent | e8eb1df29f15361697d7f6062d0466f61d072f2e (diff) | |
download | gtk+-7a5ab6eea0af6b417a47d6bb61f950e79ac69053.tar.gz |
css: Compute selector tree changes ahead of time
These only depend on the selector tree, so we can
compute them while constructing the tree.
-rw-r--r-- | gtk/gtkcssselector.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/gtk/gtkcssselector.c b/gtk/gtkcssselector.c index b6468bd282..2b7461e5eb 100644 --- a/gtk/gtkcssselector.c +++ b/gtk/gtkcssselector.c @@ -104,6 +104,7 @@ union _GtkCssSelector struct _GtkCssSelectorTree { GtkCssSelector selector; + GtkCssChange change; gint32 parent_offset; gint32 previous_offset; gint32 sibling_offset; @@ -1874,7 +1875,7 @@ gtk_css_selector_tree_get_change (const GtkCssSelectorTree *tree, return 0; if (!tree->selector.class->is_simple) - return gtk_css_selector_tree_collect_change (tree) | GTK_CSS_CHANGE_GOT_MATCH; + return tree->change | GTK_CSS_CHANGE_GOT_MATCH; for (prev = gtk_css_selector_tree_get_previous (tree); prev != NULL; @@ -2084,6 +2085,7 @@ subdivide_infos (GByteArray *array, GList *infos, gint32 parent_offset) remaining = NULL; tree = alloc_tree (array, &tree_offset); + tree->change = 0; tree->parent_offset = parent_offset; tree->selector = max_selector; @@ -2193,6 +2195,20 @@ fixup_offsets (GtkCssSelectorTree *tree, guint8 *data) } } +static void +compute_change (GtkCssSelectorTree *tree) +{ + for (; tree != NULL; + tree = (GtkCssSelectorTree *)gtk_css_selector_tree_get_sibling (tree)) + { + GtkCssSelectorTree *prev = (GtkCssSelectorTree *)gtk_css_selector_tree_get_previous (tree); + + tree->change = gtk_css_selector_tree_collect_change (tree); + + compute_change (prev); + } +} + GtkCssSelectorTree * _gtk_css_selector_tree_builder_build (GtkCssSelectorTreeBuilder *builder) { @@ -2216,6 +2232,8 @@ _gtk_css_selector_tree_builder_build (GtkCssSelectorTreeBuilder *builder) fixup_offsets (tree, data); + compute_change (tree); + /* Convert offsets to final pointers */ for (l = builder->infos; l != NULL; l = l->next) { |