[gnome-shell] StThemeNode: handle url() in inline styles better



commit c648a5f117f0a642a540ca73c30dc366dc6f4257
Author: Ray Strode <rstrode redhat com>
Date:   Wed Dec 8 18:05:31 2010 -0500

    StThemeNode: handle url() in inline styles better
    
    non-absolute paths specified as url()'s in
    stylesheets are resolved to be relative to the location
    of the stylesheets they are in.
    
    Inline styles don't have physical styleshseets sitting on disk,
    which leads to a crash in the url resolving code.
    
    This commit ensures that we don't try to use the stylesheet associated
    with a url, if there isn't one to use.
    
    This commit doesn't try to handle relative paths in inline styles.
    It only prevents crashes when absolute paths are used.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=636975

 src/st/st-theme-node.c |   28 ++++++++++++++++++++++++----
 1 files changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/src/st/st-theme-node.c b/src/st/st-theme-node.c
index ce4cdbe..4a6a121 100644
--- a/src/st/st-theme-node.c
+++ b/src/st/st-theme-node.c
@@ -1617,9 +1617,16 @@ _st_theme_node_ensure_background (StThemeNode *node)
                 }
               else if (term->type == TERM_URI)
                 {
+                  CRStyleSheet *base_stylesheet;
+
+                  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,
-                                                                     decl->parent_statement->parent_sheet,
-                                                                     term->content.str->stryng->str);
+                                                                  base_stylesheet,
+                                                                  term->content.str->stryng->str);
                 }
             }
         }
@@ -1669,9 +1676,16 @@ _st_theme_node_ensure_background (StThemeNode *node)
 
           if (decl->value->type == TERM_URI)
             {
+              CRStyleSheet *base_stylesheet;
+
+              if (decl->parent_statement != NULL)
+                base_stylesheet = decl->parent_statement->parent_sheet;
+              else
+                base_stylesheet = NULL;
+
               g_free (node->background_image);
               node->background_image = _st_theme_resolve_url (node->theme,
-                                                              decl->parent_statement->parent_sheet,
+                                                              base_stylesheet,
                                                               decl->value->content.str->stryng->str);
             }
           else if (term_is_inherit (decl->value))
@@ -2455,6 +2469,7 @@ st_theme_node_get_border_image (StThemeNode *node)
       if (strcmp (decl->property->stryng->str, "border-image") == 0)
         {
           CRTerm *term = decl->value;
+          CRStyleSheet *base_stylesheet;
           int borders[4];
           int n_borders = 0;
           int i;
@@ -2529,7 +2544,12 @@ st_theme_node_get_border_image (StThemeNode *node)
               break;
             }
 
-          filename = _st_theme_resolve_url (node->theme, decl->parent_statement->parent_sheet, url);
+          if (decl->parent_statement != NULL)
+            base_stylesheet = decl->parent_statement->parent_sheet;
+          else
+            base_stylesheet = NULL;
+
+          filename = _st_theme_resolve_url (node->theme, base_stylesheet, url);
           if (filename == NULL)
             goto next_property;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]