[librsvg: 4/13] Add an "extra" set of stylesheets to the arguments of cascade



commit e8f199a1a6f4c5e42ebfdb38e0d529d9057e4435
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Jan 23 16:47:24 2020 -0600

    Add an "extra" set of stylesheets to the arguments of cascade
    
    Do I need to mention that I love iterators?

 rsvg_internals/src/css.rs      | 4 ++--
 rsvg_internals/src/document.rs | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/rsvg_internals/src/css.rs b/rsvg_internals/src/css.rs
index e8ea7416..8b4e5cb6 100644
--- a/rsvg_internals/src/css.rs
+++ b/rsvg_internals/src/css.rs
@@ -736,7 +736,7 @@ impl Stylesheet {
 }
 
 /// Runs the CSS cascade on the specified tree from all the stylesheets
-pub fn cascade(root: &mut RsvgNode, stylesheets: &[Stylesheet]) {
+pub fn cascade(root: &mut RsvgNode, stylesheets: &[Stylesheet], extra: &[Stylesheet]) {
     for mut node in root.descendants() {
         let mut matches = Vec::new();
 
@@ -749,7 +749,7 @@ pub fn cascade(root: &mut RsvgNode, stylesheets: &[Stylesheet]) {
             QuirksMode::NoQuirks,
         );
 
-        for stylesheet in stylesheets {
+        for stylesheet in stylesheets.iter().chain(extra.iter()) {
             stylesheet.get_matches(&node, &mut match_ctx, &mut matches);
         }
 
diff --git a/rsvg_internals/src/document.rs b/rsvg_internals/src/document.rs
index 6bbd7cc4..1ae414a7 100644
--- a/rsvg_internals/src/document.rs
+++ b/rsvg_internals/src/document.rs
@@ -101,8 +101,8 @@ impl Document {
         node_data.get_impl::<Svg>().get_intrinsic_dimensions()
     }
 
-    pub fn cascade(&mut self) {
-        css::cascade(&mut self.tree, &self.stylesheets);
+    pub fn cascade(&mut self, extra: &[Stylesheet]) {
+        css::cascade(&mut self.tree, &self.stylesheets, extra);
     }
 }
 
@@ -363,7 +363,7 @@ impl DocumentBuilder {
                         stylesheets,
                     };
 
-                    document.cascade();
+                    document.cascade(&[]);
 
                     Ok(document)
                 } else {


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