summaryrefslogtreecommitdiff
path: root/src/eval/content.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-04-07 10:50:39 +0200
committerLaurenz <laurmaedje@gmail.com>2022-04-07 11:07:00 +0200
commit3d52387eea321e94c13b61666f7a758052b20c5d (patch)
tree5c55c51ca7e4b53dee61d280c39b7f664b8b9d6b /src/eval/content.rs
parent20b4d590b3efbd9b7a44fd6d3a658e7b84d21b99 (diff)
Rework style chains
Diffstat (limited to 'src/eval/content.rs')
-rw-r--r--src/eval/content.rs18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/eval/content.rs b/src/eval/content.rs
index 1cdd4bb0..01b43473 100644
--- a/src/eval/content.rs
+++ b/src/eval/content.rs
@@ -102,17 +102,15 @@ impl Content {
}
/// Style this content with a single style property.
- pub fn styled<P: Key>(mut self, key: P, value: P::Value) -> Self {
+ pub fn styled<'k, K: Key<'k>>(mut self, key: K, value: K::Value) -> Self {
if let Self::Styled(styled) = &mut self {
if let Some((_, map)) = Arc::get_mut(styled) {
- if !map.has_scoped() {
- map.set(key, value);
- return self;
- }
+ map.apply(key, value);
+ return self;
}
}
- self.styled_with_map(StyleMap::with(key, value))
+ Self::Styled(Arc::new((self, StyleMap::with(key, value))))
}
/// Style this content with a full style map.
@@ -123,10 +121,8 @@ impl Content {
if let Self::Styled(styled) = &mut self {
if let Some((_, map)) = Arc::get_mut(styled) {
- if !styles.has_scoped() && !map.has_scoped() {
- map.apply(&styles);
- return self;
- }
+ map.apply_map(&styles);
+ return self;
}
}
@@ -161,7 +157,7 @@ impl Content {
let tpa = Arena::new();
let styles = ctx.styles.clone();
- let styles = StyleChain::new(&styles);
+ let styles = StyleChain::with_root(&styles);
let mut builder = Builder::new(&sya, &tpa, true);
builder.process(ctx, self, styles)?;