Пример #1
0
/**
 * _gtk_css_lookup_resolve:
 * @lookup: the lookup
 * @context: the context the values are resolved for
 * @values: a new #GtkCssStyle to be filled with the new properties
 *
 * Resolves the current lookup into a styleproperties object. This is done
 * by converting from the “winning declaration” to the “computed value”.
 *
 * XXX: This bypasses the notion of “specified value”. If this ever becomes
 * an issue, go fix it.
 **/
void
_gtk_css_lookup_resolve (GtkCssLookup            *lookup,
                         GtkStyleProviderPrivate *provider,
                         GtkCssStaticStyle       *style,
                         GtkCssStyle             *parent_style)
{
  guint i, n;

  gtk_internal_return_if_fail (lookup != NULL);
  gtk_internal_return_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider));
  gtk_internal_return_if_fail (GTK_IS_CSS_STATIC_STYLE (style));
  gtk_internal_return_if_fail (parent_style == NULL || GTK_IS_CSS_STYLE (parent_style));

  n = _gtk_css_style_property_get_n_properties ();

  for (i = 0; i < n; i++)
    {
      if (lookup->values[i].value ||
          _gtk_bitmask_get (lookup->missing, i))
        gtk_css_static_style_compute_value (GTK_CSS_STATIC_STYLE (style),
                                            provider,
                                            parent_style,
                                            i,
                                            lookup->values[i].value,
                                            lookup->values[i].section);
      /* else not a relevant property */
    }
}
Пример #2
0
static void
store_in_global_parent_cache (GtkCssNode                  *node,
                              GtkCssStyle                 *parent,
                              const GtkCssNodeDeclaration *decl,
                              GtkCssStyle                 *style)
{
    GHashTable *cache;

    g_assert (GTK_IS_CSS_STATIC_STYLE (style));

    if (parent == NULL ||
            !may_use_global_parent_cache (node))
        return;

    if (!may_be_stored_in_parent_cache (style))
        return;

    cache = g_object_get_data (G_OBJECT (parent), "gtk-global-cache");
    if (cache == NULL)
    {
        cache = g_hash_table_new_full (gtk_css_node_declaration_hash,
                                       gtk_css_node_declaration_equal,
                                       (GDestroyNotify) gtk_css_node_declaration_unref,
                                       g_object_unref);
        g_object_set_data_full (G_OBJECT (parent), "gtk-global-cache", cache, (GDestroyNotify) g_hash_table_destroy);
    }

    g_hash_table_insert (cache,
                         gtk_css_node_declaration_ref ((GtkCssNodeDeclaration *) decl),
                         g_object_ref (style));
}
Пример #3
0
static void
store_in_global_parent_cache (GtkCssNode                  *node,
                              const GtkCssNodeDeclaration *decl,
                              GtkCssStyle                 *style)
{
  GtkCssNode *parent;

  g_assert (GTK_IS_CSS_STATIC_STYLE (style));

  parent = node->parent;

  if (parent == NULL ||
      !may_use_global_parent_cache (node))
    return;

  if (parent->cache == NULL)
    parent->cache = gtk_css_node_style_cache_new (parent->style);

  node->cache = gtk_css_node_style_cache_insert (parent->cache,
                                                 (GtkCssNodeDeclaration *) decl,
                                                 gtk_css_node_is_first_child (node),
                                                 gtk_css_node_is_last_child (node),
                                                 style);
}