[librsvg: 1/14] Stylesheet.get_matches() - renamed, and return a vec of Declaration
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 1/14] Stylesheet.get_matches() - renamed, and return a vec of Declaration
- Date: Mon, 11 Nov 2019 23:25:47 +0000 (UTC)
commit 389e5b73a1a39a730a9f3187649c46b2cdf93c47
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Nov 11 14:22:42 2019 -0600
Stylesheet.get_matches() - renamed, and return a vec of Declaration
That is, don't apply the matching declarations to the node here; have
the caller do that.
rsvg_internals/src/css.rs | 9 +++------
rsvg_internals/src/document.rs | 6 +++++-
2 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/rsvg_internals/src/css.rs b/rsvg_internals/src/css.rs
index 89d7807c..58a9eefc 100644
--- a/rsvg_internals/src/css.rs
+++ b/rsvg_internals/src/css.rs
@@ -609,11 +609,8 @@ impl Stylesheet {
.and_then(|utf8| self.parse(&utf8, base_url))
}
- /// The main CSS matching function.
- ///
- /// Takes a `node` and modifies its `specified_values` with the
- /// CSS rules that match the node.
- pub fn apply_matches_to_node(&self, node: &mut RsvgNode) {
+ /// Appends the style declarations that match a specified node to a given vector
+ pub fn get_matches<'a>(&'a self, node: &RsvgNode, acc: &mut Vec<&'a Declaration>) {
let mut match_ctx = MatchingContext::new(
MatchingMode::Normal,
@@ -633,7 +630,7 @@ impl Stylesheet {
&mut match_ctx,
) {
for decl in rule.declarations.iter() {
- node.borrow_mut().apply_style_declaration(decl);
+ acc.push(decl);
}
}
}
diff --git a/rsvg_internals/src/document.rs b/rsvg_internals/src/document.rs
index 447cd9d3..f648b808 100644
--- a/rsvg_internals/src/document.rs
+++ b/rsvg_internals/src/document.rs
@@ -328,7 +328,11 @@ impl DocumentBuilder {
if root.borrow().get_type() == NodeType::Svg {
for mut node in root.descendants() {
for stylesheet in &stylesheets {
- stylesheet.apply_matches_to_node(&mut node);
+ let mut decls = Vec::new();
+ stylesheet.get_matches(&node, &mut decls);
+ for decl in decls {
+ node.borrow_mut().apply_style_declaration(decl);
+ }
}
node.borrow_mut().set_style_attribute();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]