St: avoid blocking IO to resolve relative urls
realpath() does a series of lstat() on each path component to resolve symbolic links, but we just want to get an absolute path, and we don't really care if it is physical or not. Going through a GFile does the canonicalization we need, and is a lot faster. https://bugzilla.gnome.org/show_bug.cgi?id=687881
This commit is contained in:
@ -1738,15 +1738,19 @@ _st_theme_node_ensure_background (StThemeNode *node)
|
||||
else if (term->type == TERM_URI)
|
||||
{
|
||||
CRStyleSheet *base_stylesheet;
|
||||
GFile *file;
|
||||
|
||||
if (decl->parent_statement != NULL)
|
||||
base_stylesheet = decl->parent_statement->parent_sheet;
|
||||
else
|
||||
base_stylesheet = NULL;
|
||||
|
||||
node->background_image = _st_theme_resolve_url (node->theme,
|
||||
base_stylesheet,
|
||||
term->content.str->stryng->str);
|
||||
file = _st_theme_resolve_url (node->theme,
|
||||
base_stylesheet,
|
||||
term->content.str->stryng->str);
|
||||
|
||||
node->background_image = g_strdup (g_file_get_path (file));
|
||||
g_object_unref (file);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1843,6 +1847,7 @@ _st_theme_node_ensure_background (StThemeNode *node)
|
||||
if (decl->value->type == TERM_URI)
|
||||
{
|
||||
CRStyleSheet *base_stylesheet;
|
||||
GFile *file;
|
||||
|
||||
if (decl->parent_statement != NULL)
|
||||
base_stylesheet = decl->parent_statement->parent_sheet;
|
||||
@ -1850,9 +1855,12 @@ _st_theme_node_ensure_background (StThemeNode *node)
|
||||
base_stylesheet = NULL;
|
||||
|
||||
g_free (node->background_image);
|
||||
node->background_image = _st_theme_resolve_url (node->theme,
|
||||
base_stylesheet,
|
||||
decl->value->content.str->stryng->str);
|
||||
file = _st_theme_resolve_url (node->theme,
|
||||
base_stylesheet,
|
||||
decl->value->content.str->stryng->str);
|
||||
|
||||
node->background_image = g_strdup (g_file_get_path (file));
|
||||
g_object_unref (file);
|
||||
}
|
||||
else if (term_is_inherit (decl->value))
|
||||
{
|
||||
@ -2668,6 +2676,7 @@ st_theme_node_get_border_image (StThemeNode *node)
|
||||
int border_bottom;
|
||||
int border_left;
|
||||
|
||||
GFile *file;
|
||||
char *filename;
|
||||
|
||||
/* Support border-image: none; to suppress a previously specified border image */
|
||||
@ -2746,7 +2755,10 @@ st_theme_node_get_border_image (StThemeNode *node)
|
||||
else
|
||||
base_stylesheet = NULL;
|
||||
|
||||
filename = _st_theme_resolve_url (node->theme, base_stylesheet, url);
|
||||
file = _st_theme_resolve_url (node->theme, base_stylesheet, url);
|
||||
filename = g_strdup (g_file_get_path (file));
|
||||
g_object_unref (file);
|
||||
|
||||
if (filename == NULL)
|
||||
goto next_property;
|
||||
|
||||
|
Reference in New Issue
Block a user