mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-01 00:11:29 +00:00
cssprovider: Keep only the curent section while parsing
We don't need a list of sections, the section can give us the parent when we need it (d'oh).
This commit is contained in:
parent
19c44967cb
commit
d985b95ef9
@ -965,7 +965,7 @@ struct _GtkCssScanner
|
|||||||
{
|
{
|
||||||
GtkCssProvider *provider;
|
GtkCssProvider *provider;
|
||||||
GtkCssParser *parser;
|
GtkCssParser *parser;
|
||||||
GSList *sections;
|
GtkCssSection *section;
|
||||||
GtkCssScanner *parent;
|
GtkCssScanner *parent;
|
||||||
GFile *file;
|
GFile *file;
|
||||||
GFile *base;
|
GFile *base;
|
||||||
@ -1219,8 +1219,6 @@ gtk_css_ruleset_matches (GtkCssRuleset *ruleset,
|
|||||||
static void
|
static void
|
||||||
gtk_css_scanner_destroy (GtkCssScanner *scanner)
|
gtk_css_scanner_destroy (GtkCssScanner *scanner)
|
||||||
{
|
{
|
||||||
g_assert (scanner->sections == NULL);
|
|
||||||
|
|
||||||
g_object_unref (scanner->provider);
|
g_object_unref (scanner->provider);
|
||||||
if (scanner->file)
|
if (scanner->file)
|
||||||
g_object_unref (scanner->file);
|
g_object_unref (scanner->file);
|
||||||
@ -1247,6 +1245,7 @@ gtk_css_scanner_parser_error (GtkCssParser *parser,
|
|||||||
static GtkCssScanner *
|
static GtkCssScanner *
|
||||||
gtk_css_scanner_new (GtkCssProvider *provider,
|
gtk_css_scanner_new (GtkCssProvider *provider,
|
||||||
GtkCssScanner *parent,
|
GtkCssScanner *parent,
|
||||||
|
GtkCssSection *section,
|
||||||
GFile *file,
|
GFile *file,
|
||||||
const gchar *data,
|
const gchar *data,
|
||||||
gsize length)
|
gsize length)
|
||||||
@ -1260,6 +1259,8 @@ gtk_css_scanner_new (GtkCssProvider *provider,
|
|||||||
g_object_ref (provider);
|
g_object_ref (provider);
|
||||||
scanner->provider = provider;
|
scanner->provider = provider;
|
||||||
scanner->parent = parent;
|
scanner->parent = parent;
|
||||||
|
if (section)
|
||||||
|
scanner->section = gtk_css_section_ref (section);
|
||||||
|
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
@ -1305,34 +1306,33 @@ static void
|
|||||||
gtk_css_scanner_push_section (GtkCssScanner *scanner,
|
gtk_css_scanner_push_section (GtkCssScanner *scanner,
|
||||||
GtkCssSectionType section_type)
|
GtkCssSectionType section_type)
|
||||||
{
|
{
|
||||||
GtkCssSection *parent, *section;
|
GtkCssSection *section;
|
||||||
|
|
||||||
if (scanner->sections)
|
section = _gtk_css_section_new (scanner->section,
|
||||||
parent = scanner->sections->data;
|
|
||||||
else if (scanner->parent)
|
|
||||||
parent = scanner->parent->sections->data;
|
|
||||||
else
|
|
||||||
parent = NULL;
|
|
||||||
|
|
||||||
section = _gtk_css_section_new (parent,
|
|
||||||
section_type,
|
section_type,
|
||||||
scanner->parser,
|
scanner->parser,
|
||||||
scanner->file);
|
scanner->file);
|
||||||
scanner->sections = g_slist_prepend (scanner->sections, section);
|
|
||||||
|
gtk_css_section_unref (scanner->section);
|
||||||
|
scanner->section = section;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_css_scanner_pop_section (GtkCssScanner *scanner,
|
gtk_css_scanner_pop_section (GtkCssScanner *scanner,
|
||||||
GtkCssSectionType check_type)
|
GtkCssSectionType check_type)
|
||||||
{
|
{
|
||||||
GtkCssSection *section = scanner->sections->data;
|
GtkCssSection *parent;
|
||||||
|
|
||||||
g_assert (check_type == gtk_css_section_get_section_type (section));
|
g_assert (gtk_css_section_get_section_type (scanner->section) == check_type);
|
||||||
|
|
||||||
scanner->sections = g_slist_delete_link (scanner->sections, scanner->sections);
|
parent = gtk_css_section_get_parent (scanner->section);
|
||||||
|
if (parent)
|
||||||
|
gtk_css_section_ref (parent);
|
||||||
|
|
||||||
_gtk_css_section_end (section);
|
_gtk_css_section_end (scanner->section);
|
||||||
gtk_css_section_unref (section);
|
gtk_css_section_unref (scanner->section);
|
||||||
|
|
||||||
|
scanner->section = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2520,7 +2520,12 @@ gtk_css_provider_load_internal (GtkCssProvider *css_provider,
|
|||||||
|
|
||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
scanner = gtk_css_scanner_new (css_provider, parent, file, data, length);
|
scanner = gtk_css_scanner_new (css_provider,
|
||||||
|
parent,
|
||||||
|
parent ? parent->section : NULL,
|
||||||
|
file,
|
||||||
|
data,
|
||||||
|
length);
|
||||||
|
|
||||||
parse_stylesheet (scanner);
|
parse_stylesheet (scanner);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user