Esempio n. 1
0
void
gtk_css_node_validate_internal (GtkCssNode *cssnode,
                                gint64      timestamp)
{
  GtkCssNode *child;

  if (!cssnode->invalid)
    return;

  gtk_css_node_ensure_style (cssnode, timestamp);

  /* need to set to FALSE then to TRUE here to make it chain up */
  gtk_css_node_set_invalid (cssnode, FALSE);
  if (!gtk_css_style_is_static (cssnode->style))
    gtk_css_node_set_invalid (cssnode, TRUE);

  GTK_CSS_NODE_GET_CLASS (cssnode)->validate (cssnode);

  for (child = gtk_css_node_get_first_child (cssnode);
       child;
       child = gtk_css_node_get_next_sibling (child))
    {
      if (child->visible)
        gtk_css_node_validate_internal (child, timestamp);
    }
}
Esempio n. 2
0
static void
gtk_css_node_ensure_style (GtkCssNode *cssnode,
                           gint64      current_time)
{
    gboolean style_changed;

    if (!gtk_css_node_needs_new_style (cssnode))
        return;

    if (cssnode->parent)
        gtk_css_node_ensure_style (cssnode->parent, current_time);

    if (cssnode->style_is_invalid)
    {
        GtkCssStyle *new_style;

        if (cssnode->previous_sibling)
            gtk_css_node_ensure_style (cssnode->previous_sibling, current_time);

        new_style = GTK_CSS_NODE_GET_CLASS (cssnode)->update_style (cssnode,
                    cssnode->pending_changes,
                    current_time,
                    cssnode->style);

        style_changed = gtk_css_node_set_style (cssnode, new_style);
        g_object_unref (new_style);

        if (!style_changed && (cssnode->pending_changes & GTK_CSS_CHANGE_SOURCE))
        {
            /* clear the global cache if we reuse the same style after the CSS changed */
            g_object_set_qdata (G_OBJECT (cssnode->style), quark_global_cache, NULL);
        }
    }
    else
    {
        style_changed = FALSE;
    }

    gtk_css_node_propagate_pending_changes (cssnode, style_changed);

    cssnode->pending_changes = 0;
    cssnode->style_is_invalid = FALSE;
}
Esempio n. 3
0
GtkCssStyle *
gtk_css_node_get_style (GtkCssNode *cssnode)
{
  if (gtk_css_node_needs_new_style (cssnode))
    {
      gint64 timestamp = gtk_css_node_get_timestamp (cssnode);

      gtk_css_node_ensure_style (cssnode, timestamp);
    }

  return cssnode->style;
}
Esempio n. 4
0
static void
gtk_css_node_ensure_style (GtkCssNode *cssnode,
                           gint64      current_time)
{
  gboolean style_changed;

  if (!gtk_css_node_needs_new_style (cssnode))
    return;

  if (cssnode->parent)
    gtk_css_node_ensure_style (cssnode->parent, current_time);

  if (cssnode->style_is_invalid)
    {
      GtkCssStyle *new_style;

      if (cssnode->previous_sibling)
        gtk_css_node_ensure_style (cssnode->previous_sibling, current_time);

      g_clear_pointer (&cssnode->cache, gtk_css_node_style_cache_unref);

      new_style = GTK_CSS_NODE_GET_CLASS (cssnode)->update_style (cssnode,
                                                                  cssnode->pending_changes,
                                                                  current_time,
                                                                  cssnode->style);

      style_changed = gtk_css_node_set_style (cssnode, new_style);
      g_object_unref (new_style);
    }
  else
    {
      style_changed = FALSE;
    }

  gtk_css_node_propagate_pending_changes (cssnode, style_changed);

  cssnode->pending_changes = 0;
  cssnode->style_is_invalid = FALSE;
}
Esempio n. 5
0
void
gtk_css_node_validate_internal (GtkCssNode *cssnode,
                                gint64      timestamp)
{
    GtkCssNode *child;

    /* If you run your application with
     *   GTK_DEBUG=no-css-cache
     * every invalidation will purge the cache and completely query
     * everything anew form the cache. This is slow (in particular
     * when animating), but useful for figuring out bugs.
     *
     * We achieve that by pretending that everything that could have
     * changed has and so we of course totally need to redo everything.
     *
     * Note that this also completely revalidates child widgets all
     * the time.
     */
#ifdef G_ENABLE_DEBUG
    if (GTK_DEBUG_CHECK (NO_CSS_CACHE))
        cssnode->pending_changes |= GTK_CSS_CHANGE_ANY;
#endif

    if (!cssnode->invalid)
        return;

    gtk_css_node_ensure_style (cssnode, timestamp);

    /* need to set to FALSE then to TRUE here to make it chain up */
    gtk_css_node_set_invalid (cssnode, FALSE);
    if (!gtk_css_style_is_static (cssnode->style))
        gtk_css_node_set_invalid (cssnode, TRUE);

    GTK_CSS_NODE_GET_CLASS (cssnode)->validate (cssnode);

    for (child = gtk_css_node_get_first_child (cssnode);
            child;
            child = gtk_css_node_get_next_sibling (child))
    {
        if (child->visible)
            gtk_css_node_validate_internal (child, timestamp);
    }
}