Keep similar theme nodes so we don't have to recompute CSS so often

Because we calculate and cache CSS properties once per StThemeNode,
and only a certain set of attributes can affect the CSS properties,
it's advantageous for as many widgets as possible to share a single
StThemeNode. Similarly, if a widget changes state and then changes back
(e.g. gaining and losing the :hover pseudo-class), it should ideally
get its original StThemeNode back again when it returns to the old
state.

Here, I'm using the StThemeContext as the location for a cache.
StThemeNodes are currently never freed: this seems OK for Shell's usage
(a finite number of IDs, classes, pseudo-classes and types).

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=687465
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
This commit is contained in:
Simon McVittie
2012-11-08 17:50:01 +00:00
parent 2cfed952bb
commit dc2ec0a8f9
5 changed files with 85 additions and 7 deletions

View File

@ -62,6 +62,9 @@ const PangoFontDescription *st_theme_context_get_font (StThemeContext
StThemeNode * st_theme_context_get_root_node (StThemeContext *context);
StThemeNode * st_theme_context_intern_node (StThemeContext *context,
StThemeNode *node);
G_END_DECLS
#endif /* __ST_THEME_CONTEXT_H__ */