Code

Filter effects dialog:
[inkscape.git] / src / sp-style-elem.cpp
index 4408f7ce86f200b0bec6decb435c609c21095ab4..fa756242cab2dc53ba362d438b608dcd509241c0 100644 (file)
@@ -4,6 +4,7 @@
 #include "document.h"
 #include "sp-style-elem.h"
 #include "attributes.h"
+#include "style.h"
 using Inkscape::XML::TEXT_NODE;
 
 static void sp_style_elem_init(SPStyleElem *style_elem);
@@ -131,7 +132,7 @@ sp_style_elem_write(SPObject *const object, Inkscape::XML::Node *repr, guint con
     if (flags & SP_OBJECT_WRITE_BUILD) {
         g_warning("nyi: Forming <style> content for SP_OBJECT_WRITE_BUILD.");
         /* fixme: Consider having the CRStyleSheet be a member of SPStyleElem, and then
-           pretty-print to a string s, then repr->addChild(sp_repr_new_text(s), NULL). */
+           pretty-print to a string s, then repr->addChild(xml_doc->createTextNode(s), NULL). */
     }
     if (style_elem.is_css) {
         repr->setAttribute("type", "text/css");
@@ -358,6 +359,17 @@ sp_style_elem_read_content(SPObject *const object)
     }
     cr_parser_destroy(parser);
     //object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+
+    // Style references via class= do not, and actually cannot, use autoupdating URIReferences.
+    // Therefore, if an object refers to a stylesheet which has not yet loaded when the object is being loaded
+    // (e.g. if the stylesheet is below or inside the object in XML), its class= has no effect (bug 1491639).
+    // Below is a partial hack that fixes this for a single case: when the <style> is a child of the object
+    // that uses a style from it. It just forces the parent of <style> to reread its style as soon as the stylesheet
+    // is fully loaded. Naturally, this won't work if the user of the stylesheet is its grandparent or precedent.
+    SPObject *parent = SP_OBJECT_PARENT (object);
+    if ( parent ) {
+        sp_style_read_from_object(parent->style, parent);
+    }
 }
 
 /**