Move import syntax closer to css

Css allows @import url ("foo.css") or @import "foo.css" or
@import url ('foo.css') but not @import url(foo.css) or @immport foo.css.
This commit is contained in:
Matthias Clasen 2010-11-18 01:25:41 -05:00 committed by Carlos Garnacho
parent f92c352f96
commit 11cd19987b

View File

@ -197,7 +197,7 @@
* <example> * <example>
* <title>Using the &commat;import rule</title> * <title>Using the &commat;import rule</title>
* <programlisting> * <programlisting>
* &commat;import url (path/to/common.css) * &commat;import url ("path/to/common.css")
* </programlisting> * </programlisting>
* </example> * </example>
* <para> * <para>
@ -358,8 +358,8 @@
* <entry></entry> * <entry></entry>
* <entry> * <entry>
* <programlisting> * <programlisting>
* border-image: url (/path/to/image.png) 3 4 3 4 stretch; * border-image: url ("/path/to/image.png") 3 4 3 4 stretch;
* border-image: url (/path/to/image.png) 3 4 4 3 repeat stretch;</programlisting> * border-image: url ("/path/to/image.png") 3 4 4 3 repeat stretch;</programlisting>
* </entry> * </entry>
* </row> * </row>
* <row> * <row>
@ -1558,6 +1558,7 @@ parse_selector (GtkCssProvider *css_provider,
} }
#define SKIP_SPACES(s) while (s[0] == ' ' || s[0] == '\t' || s[0] == '\n') s++; #define SKIP_SPACES(s) while (s[0] == ' ' || s[0] == '\t' || s[0] == '\n') s++;
#define SKIP_SPACES_BACK(s) while (s[0] == ' ' || s[0] == '\t' || s[0] == '\n') s--;
static GtkSymbolicColor * static GtkSymbolicColor *
symbolic_color_parse_str (const gchar *string, symbolic_color_parse_str (const gchar *string,
@ -2099,37 +2100,60 @@ path_parse_str (GtkCssProvider *css_provider,
{ {
gchar *path, *chr; gchar *path, *chr;
if (!g_str_has_prefix (str, "url")) if (g_str_has_prefix (str, "url"))
{ {
*end_ptr = (gchar *) str; str += strlen ("url");
return NULL; SKIP_SPACES (str);
if (*str != '(')
{
*end_ptr = (gchar *) str;
return NULL;
}
chr = strrchr (str, ')');
if (!chr)
{
*end_ptr = (gchar *) str;
return NULL;
}
str++;
SKIP_SPACES (str);
if (*str == '"' || *str == '\'')
{
gchar *p;
p = str;
str++;
SKIP_SPACES_BACK (chr);
if (*chr != *p)
{
*end_ptr = str;
return NULL;
}
chr--;
}
else
{
*end_ptr = str;
return NULL;
}
path = g_strndup (str, chr - str);
g_strstrip (path);
*end_ptr = chr + 1;
} }
else
str += strlen ("url");
SKIP_SPACES (str);
if (*str != '(')
{ {
*end_ptr = (gchar *) str; path = g_strdup (str);
return NULL; *end_ptr = str + strlen (str);
} }
chr = strchr (str, ')');
if (!chr)
{
*end_ptr = (gchar *) str;
return NULL;
}
str++;
SKIP_SPACES (str);
path = g_strndup (str, chr - str);
g_strstrip (path);
*end_ptr = chr + 1;
/* Always return an absolute path */ /* Always return an absolute path */
if (!g_path_is_absolute (path)) if (!g_path_is_absolute (path))
{ {
@ -2678,13 +2702,13 @@ parse_rule (GtkCssProvider *css_provider,
css_provider_push_scope (css_provider, SCOPE_VALUE); css_provider_push_scope (css_provider, SCOPE_VALUE);
g_scanner_get_next_token (scanner); g_scanner_get_next_token (scanner);
if (scanner->token != G_TOKEN_IDENTIFIER) if (scanner->token == G_TOKEN_IDENTIFIER)
return G_TOKEN_IDENTIFIER; path = path_parse (css_provider,
g_strstrip (scanner->value.v_identifier));
path = path_parse (css_provider, else if (scanner->token == G_TOKEN_STRING)
g_strstrip (scanner->value.v_identifier)); path = path_parse (css_provider,
g_strstrip (scanner->value.v_string));
if (!path) else
return G_TOKEN_IDENTIFIER; return G_TOKEN_IDENTIFIER;
css_provider_pop_scope (css_provider); css_provider_pop_scope (css_provider);