summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk/gtkcssimageurl.c58
-rw-r--r--gtk/gtkcssparser.c56
-rw-r--r--gtk/gtkcssparserprivate.h2
-rw-r--r--gtk/gtkcssstylefuncs.c58
4 files changed, 60 insertions, 114 deletions
diff --git a/gtk/gtkcssimageurl.c b/gtk/gtkcssimageurl.c
index cc0509f3fa..8bfd70861a 100644
--- a/gtk/gtkcssimageurl.c
+++ b/gtk/gtkcssimageurl.c
@@ -59,62 +59,6 @@ gtk_css_image_url_draw (GtkCssImage *image,
cairo_fill (cr);
}
-static GFile *
-gtk_css_parse_url (GtkCssParser *parser,
- GFile *base)
-{
- gchar *path;
- GFile *file;
-
- if (_gtk_css_parser_try (parser, "url", FALSE))
- {
- if (!_gtk_css_parser_try (parser, "(", TRUE))
- {
- _gtk_css_parser_skip_whitespace (parser);
- if (_gtk_css_parser_try (parser, "(", TRUE))
- {
- GError *error;
-
- error = g_error_new_literal (GTK_CSS_PROVIDER_ERROR,
- GTK_CSS_PROVIDER_ERROR_DEPRECATED,
- "Whitespace between 'url' and '(' is deprecated");
-
- _gtk_css_parser_take_error (parser, error);
- }
- else
- {
- _gtk_css_parser_error (parser, "Expected '(' after 'url'");
- return NULL;
- }
- }
-
- path = _gtk_css_parser_read_string (parser);
- if (path == NULL)
- return NULL;
-
- if (!_gtk_css_parser_try (parser, ")", TRUE))
- {
- _gtk_css_parser_error (parser, "No closing ')' found for 'url'");
- g_free (path);
- return NULL;
- }
- }
- else
- {
- path = _gtk_css_parser_try_name (parser, TRUE);
- if (path == NULL)
- {
- _gtk_css_parser_error (parser, "Not a valid url");
- return NULL;
- }
- }
-
- file = g_file_resolve_relative_path (base, path);
- g_free (path);
-
- return file;
-}
-
static gboolean
gtk_css_image_url_parse (GtkCssImage *image,
GtkCssParser *parser,
@@ -127,7 +71,7 @@ gtk_css_image_url_parse (GtkCssImage *image,
cairo_t *cr;
GError *error = NULL;
- file = gtk_css_parse_url (parser, base);
+ file = _gtk_css_parser_read_url (parser, base);
if (file == NULL)
return FALSE;
diff --git a/gtk/gtkcssparser.c b/gtk/gtkcssparser.c
index a136466ee5..fc6dc3e95a 100644
--- a/gtk/gtkcssparser.c
+++ b/gtk/gtkcssparser.c
@@ -917,6 +917,62 @@ _gtk_css_parser_read_symbolic_color (GtkCssParser *parser)
return NULL;
}
+GFile *
+_gtk_css_parser_read_url (GtkCssParser *parser,
+ GFile *base)
+{
+ gchar *path;
+ GFile *file;
+
+ if (_gtk_css_parser_try (parser, "url", FALSE))
+ {
+ if (!_gtk_css_parser_try (parser, "(", TRUE))
+ {
+ _gtk_css_parser_skip_whitespace (parser);
+ if (_gtk_css_parser_try (parser, "(", TRUE))
+ {
+ GError *error;
+
+ error = g_error_new_literal (GTK_CSS_PROVIDER_ERROR,
+ GTK_CSS_PROVIDER_ERROR_DEPRECATED,
+ "Whitespace between 'url' and '(' is deprecated");
+
+ _gtk_css_parser_take_error (parser, error);
+ }
+ else
+ {
+ _gtk_css_parser_error (parser, "Expected '(' after 'url'");
+ return NULL;
+ }
+ }
+
+ path = _gtk_css_parser_read_string (parser);
+ if (path == NULL)
+ return NULL;
+
+ if (!_gtk_css_parser_try (parser, ")", TRUE))
+ {
+ _gtk_css_parser_error (parser, "No closing ')' found for 'url'");
+ g_free (path);
+ return NULL;
+ }
+ }
+ else
+ {
+ path = _gtk_css_parser_try_name (parser, TRUE);
+ if (path == NULL)
+ {
+ _gtk_css_parser_error (parser, "Not a valid url");
+ return NULL;
+ }
+ }
+
+ file = g_file_resolve_relative_path (base, path);
+ g_free (path);
+
+ return file;
+}
+
void
_gtk_css_parser_resync_internal (GtkCssParser *parser,
gboolean sync_at_semicolon,
diff --git a/gtk/gtkcssparserprivate.h b/gtk/gtkcssparserprivate.h
index 35c01eafaa..4fbee6f2af 100644
--- a/gtk/gtkcssparserprivate.h
+++ b/gtk/gtkcssparserprivate.h
@@ -84,6 +84,8 @@ char * _gtk_css_parser_read_uri (GtkCssParser *parser
char * _gtk_css_parser_read_value (GtkCssParser *parser);
GtkSymbolicColor *_gtk_css_parser_read_symbolic_color
(GtkCssParser *parser);
+GFile * _gtk_css_parser_read_url (GtkCssParser *parser,
+ GFile *base);
void _gtk_css_parser_resync (GtkCssParser *parser,
gboolean sync_at_semicolon,
diff --git a/gtk/gtkcssstylefuncs.c b/gtk/gtkcssstylefuncs.c
index 5184b526c5..21404bb243 100644
--- a/gtk/gtkcssstylefuncs.c
+++ b/gtk/gtkcssstylefuncs.c
@@ -740,62 +740,6 @@ gradient_value_print (const GValue *value,
}
}
-static GFile *
-gtk_css_parse_url (GtkCssParser *parser,
- GFile *base)
-{
- gchar *path;
- GFile *file;
-
- if (_gtk_css_parser_try (parser, "url", FALSE))
- {
- if (!_gtk_css_parser_try (parser, "(", TRUE))
- {
- _gtk_css_parser_skip_whitespace (parser);
- if (_gtk_css_parser_try (parser, "(", TRUE))
- {
- GError *error;
-
- error = g_error_new_literal (GTK_CSS_PROVIDER_ERROR,
- GTK_CSS_PROVIDER_ERROR_DEPRECATED,
- "Whitespace between 'url' and '(' is deprecated");
-
- _gtk_css_parser_take_error (parser, error);
- }
- else
- {
- _gtk_css_parser_error (parser, "Expected '(' after 'url'");
- return NULL;
- }
- }
-
- path = _gtk_css_parser_read_string (parser);
- if (path == NULL)
- return NULL;
-
- if (!_gtk_css_parser_try (parser, ")", TRUE))
- {
- _gtk_css_parser_error (parser, "No closing ')' found for 'url'");
- g_free (path);
- return NULL;
- }
- }
- else
- {
- path = _gtk_css_parser_try_name (parser, TRUE);
- if (path == NULL)
- {
- _gtk_css_parser_error (parser, "Not a valid url");
- return NULL;
- }
- }
-
- file = g_file_resolve_relative_path (base, path);
- g_free (path);
-
- return file;
-}
-
static gboolean
pattern_value_parse (GtkCssParser *parser,
GFile *base,
@@ -822,7 +766,7 @@ pattern_value_parse (GtkCssParser *parser,
cairo_t *cr;
cairo_matrix_t matrix;
- file = gtk_css_parse_url (parser, base);
+ file = _gtk_css_parser_read_url (parser, base);
if (file == NULL)
return FALSE;