diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-01-07 10:46:55 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-01-07 10:46:55 +0100 |
| commit | af014cfe5eea4233d8034c79c1a5f898c972396c (patch) | |
| tree | 3345554e62d3f1696006fdb42296be5c744fbf77 /src/eval/styles.rs | |
| parent | 5fd9c0b0d7b519802d56dd04cb61340c11014cb1 (diff) | |
Tidy up styling
Diffstat (limited to 'src/eval/styles.rs')
| -rw-r--r-- | src/eval/styles.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/eval/styles.rs b/src/eval/styles.rs index 54ac2697..0f3d694a 100644 --- a/src/eval/styles.rs +++ b/src/eval/styles.rs @@ -106,7 +106,6 @@ impl StyleMap { /// `outer`. The ones from `self` take precedence over the ones from /// `outer`. For folded properties `self` contributes the inner value. pub fn chain<'a>(&'a self, outer: &'a StyleChain<'a>) -> StyleChain<'a> { - // No need to chain an empty map. if self.is_empty() { *outer } else { @@ -182,7 +181,9 @@ impl PartialEq for StyleMap { /// matches further up the chain. #[derive(Clone, Copy, Hash)] pub struct StyleChain<'a> { + /// The first map in the chain. inner: &'a StyleMap, + /// The remaining maps in the chain. outer: Option<&'a Self>, } @@ -238,14 +239,13 @@ impl<'a> StyleChain<'a> { /// entry for it. pub fn get_cloned<P: Property>(self, key: P) -> P::Value { if let Some(value) = self.find(key).cloned() { - if P::FOLDABLE { - if let Some(outer) = self.outer { - P::fold(value, outer.get_cloned(key)) - } else { - P::fold(value, P::default()) - } - } else { - value + if !P::FOLDABLE { + return value; + } + + match self.outer { + Some(outer) => P::fold(value, outer.get_cloned(key)), + None => P::fold(value, P::default()), } } else if let Some(outer) = self.outer { outer.get_cloned(key) |
