mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 14:10:30 +00:00
css provider: Set bytes on sections
Pass the bytes we're parsing to the sections, and keep a pointer to them around, so we can compare them in the has_section implementation. This commit also corrects some of the location information that we add into the section for variables to be more accurate.
This commit is contained in:
parent
fc1c6cfb1a
commit
8846f85874
@ -382,9 +382,10 @@ gtk_css_scanner_parser_error (GtkCssParser *parser,
|
|||||||
GtkCssScanner *scanner = user_data;
|
GtkCssScanner *scanner = user_data;
|
||||||
GtkCssSection *section;
|
GtkCssSection *section;
|
||||||
|
|
||||||
section = gtk_css_section_new (gtk_css_parser_get_file (parser),
|
section = gtk_css_section_new_with_bytes (gtk_css_parser_get_file (parser),
|
||||||
start,
|
gtk_css_parser_get_bytes (parser),
|
||||||
end);
|
start,
|
||||||
|
end);
|
||||||
|
|
||||||
gtk_css_style_provider_emit_error (GTK_STYLE_PROVIDER (scanner->provider), section, error);
|
gtk_css_style_provider_emit_error (GTK_STYLE_PROVIDER (scanner->provider), section, error);
|
||||||
|
|
||||||
@ -881,6 +882,7 @@ parse_declaration (GtkCssScanner *scanner,
|
|||||||
if (name[0] == '-' && name[1] == '-')
|
if (name[0] == '-' && name[1] == '-')
|
||||||
{
|
{
|
||||||
GtkCssVariableValue *value;
|
GtkCssVariableValue *value;
|
||||||
|
GtkCssLocation start_location;
|
||||||
GtkCssSection *section;
|
GtkCssSection *section;
|
||||||
|
|
||||||
if (!gtk_css_parser_try_token (scanner->parser, GTK_CSS_TOKEN_COLON))
|
if (!gtk_css_parser_try_token (scanner->parser, GTK_CSS_TOKEN_COLON))
|
||||||
@ -889,15 +891,21 @@ parse_declaration (GtkCssScanner *scanner,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gtk_css_parser_skip_whitespace (scanner->parser);
|
||||||
|
|
||||||
|
if (gtk_keep_css_sections)
|
||||||
|
start_location = *gtk_css_parser_get_start_location (scanner->parser);
|
||||||
|
|
||||||
value = gtk_css_parser_parse_value_into_token_stream (scanner->parser);
|
value = gtk_css_parser_parse_value_into_token_stream (scanner->parser);
|
||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (gtk_keep_css_sections)
|
if (gtk_keep_css_sections)
|
||||||
{
|
{
|
||||||
section = gtk_css_section_new (gtk_css_parser_get_file (scanner->parser),
|
section = gtk_css_section_new_with_bytes (gtk_css_parser_get_file (scanner->parser),
|
||||||
gtk_css_parser_get_block_location (scanner->parser),
|
gtk_css_parser_get_bytes (scanner->parser),
|
||||||
gtk_css_parser_get_end_location (scanner->parser));
|
&start_location,
|
||||||
|
gtk_css_parser_get_start_location (scanner->parser));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
section = NULL;
|
section = NULL;
|
||||||
@ -941,9 +949,10 @@ parse_declaration (GtkCssScanner *scanner,
|
|||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (gtk_keep_css_sections)
|
if (gtk_keep_css_sections)
|
||||||
section = gtk_css_section_new (gtk_css_parser_get_file (scanner->parser),
|
section = gtk_css_section_new_with_bytes (gtk_css_parser_get_file (scanner->parser),
|
||||||
&start_location,
|
gtk_css_parser_get_bytes (scanner->parser),
|
||||||
gtk_css_parser_get_start_location (scanner->parser));
|
&start_location,
|
||||||
|
gtk_css_parser_get_start_location (scanner->parser));
|
||||||
else
|
else
|
||||||
section = NULL;
|
section = NULL;
|
||||||
|
|
||||||
@ -1003,9 +1012,10 @@ parse_declaration (GtkCssScanner *scanner,
|
|||||||
|
|
||||||
if (gtk_keep_css_sections)
|
if (gtk_keep_css_sections)
|
||||||
{
|
{
|
||||||
section = gtk_css_section_new (gtk_css_parser_get_file (scanner->parser),
|
section = gtk_css_section_new_with_bytes (gtk_css_parser_get_file (scanner->parser),
|
||||||
gtk_css_parser_get_block_location (scanner->parser),
|
gtk_css_parser_get_bytes (scanner->parser),
|
||||||
gtk_css_parser_get_end_location (scanner->parser));
|
gtk_css_parser_get_block_location (scanner->parser),
|
||||||
|
gtk_css_parser_get_end_location (scanner->parser));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
section = NULL;
|
section = NULL;
|
||||||
@ -1803,4 +1813,3 @@ gtk_css_provider_to_string (GtkCssProvider *provider)
|
|||||||
|
|
||||||
return g_string_free (str, FALSE);
|
return g_string_free (str, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user