[librsvg: 11/16] ComputedValues::set_value - new function to abstract setting a computed value
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 11/16] ComputedValues::set_value - new function to abstract setting a computed value
- Date: Thu, 26 Mar 2020 00:18:13 +0000 (UTC)
commit 9a8a294d60f0240c74ddbc173a4b09b3c1059ee6
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Mar 25 13:34:29 2020 -0600
ComputedValues::set_value - new function to abstract setting a computed value
We'll change the representation of ComputedValues, so it will not have
independent fields for each property. So, this is a general setter
for individual properties.
Similar to ParsedProperty, we now have a ComputedValue enum with all
possible property longhands (shorthands get expanded at the
SpecifiedValues stage).
rsvg_internals/src/properties.rs | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/rsvg_internals/src/properties.rs b/rsvg_internals/src/properties.rs
index 43901d31..11d4485c 100644
--- a/rsvg_internals/src/properties.rs
+++ b/rsvg_internals/src/properties.rs
@@ -297,6 +297,12 @@ macro_rules! make_properties {
$($long_name(SpecifiedValue<$long_name>),)+
}
+ enum ComputedValue {
+ $(
+ $long_name($long_name),
+ )+
+ }
+
#[derive(Debug, Default, Clone)]
pub struct ComputedValues {
$(
@@ -330,6 +336,12 @@ macro_rules! make_properties {
self.$long_field.clone()
}
)+
+
+ fn set_value(&mut self, computed: ComputedValue) {
+ match computed {
+ $(ComputedValue::$long_name(v) => self.$long_field = v,)+
+ }
+ }
}
};
}
@@ -463,7 +475,7 @@ impl SpecifiedValues {
($name:ident, $field:ident) => {
let prop_val = self.get_property(PropertyId::$name);
if let ParsedProperty::$name(s) = prop_val {
- computed.$field = s.compute(&computed.$field, computed);
+ computed.set_value(ComputedValue::$name(s.compute(&computed.$field, computed)));
} else {
unreachable!();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]