diff options
author | Federico Mena Quintero <federico@gnome.org> | 2022-08-29 20:37:07 -0500 |
---|---|---|
committer | Federico Mena Quintero <federico@gnome.org> | 2022-08-29 20:37:07 -0500 |
commit | 86c34e24e6ebc885d6b424b998e828fbf4c23d71 (patch) | |
tree | 7e1bcdd6f9b3cd0a47fca575f9bd38474282bfc7 | |
parent | c7ad43cdfe76e289f46d98c4fac7a8dcc72fa6dd (diff) | |
download | librsvg-86c34e24e6ebc885d6b424b998e828fbf4c23d71.tar.gz |
Create inline stylesheets in the XML module instead of DocumentBuilder
Similar in spirit to the last commit, to remove
DocumentBuilder::append_stylesheet_from_text() this time.
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/738>
-rw-r--r-- | src/document.rs | 12 | ||||
-rw-r--r-- | src/xml/mod.rs | 13 |
2 files changed, 12 insertions, 13 deletions
diff --git a/src/document.rs b/src/document.rs index 569eb312..d0270147 100644 --- a/src/document.rs +++ b/src/document.rs @@ -580,18 +580,6 @@ impl DocumentBuilder { node } - pub fn append_stylesheet_from_text(&mut self, text: &str) { - // FIXME: handle CSS errors - if let Ok(stylesheet) = Stylesheet::from_data( - text, - &self.load_options.url_resolver, - Origin::Author, - self.session.clone(), - ) { - self.append_stylesheet(stylesheet); - } - } - /// Creates a node for an XML text element as a child of `parent`. pub fn append_characters(&mut self, text: &str, parent: &mut Node) { if !text.is_empty() { diff --git a/src/xml/mod.rs b/src/xml/mod.rs index da9788d4..a9ccffac 100644 --- a/src/xml/mod.rs +++ b/src/xml/mod.rs @@ -407,7 +407,18 @@ impl XmlState { .collect::<String>(); let builder = inner.document_builder.as_mut().unwrap(); - builder.append_stylesheet_from_text(&stylesheet_text); + let session = builder.session().clone(); + + if let Ok(stylesheet) = Stylesheet::from_data( + &stylesheet_text, + &self.load_options.url_resolver, + Origin::Author, + session.clone(), + ) { + builder.append_stylesheet(stylesheet); + } else { + rsvg_log!(session, "invalid inline stylesheet"); + } } } |