summaryrefslogtreecommitdiff
path: root/src/model/styles.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-11-01 16:56:35 +0100
committerLaurenz <laurmaedje@gmail.com>2022-11-02 09:18:33 +0100
commit37ac5d966ebaf97ac79c507028cd5b742b510b89 (patch)
tree249d43ff0f8d880cb5d00c236993f8ff0c1f10d8 /src/model/styles.rs
parentf547c97072881069417acd3b79b08fb7ecf40ba2 (diff)
More dynamic content representation
Diffstat (limited to 'src/model/styles.rs')
-rw-r--r--src/model/styles.rs36
1 files changed, 13 insertions, 23 deletions
diff --git a/src/model/styles.rs b/src/model/styles.rs
index f3bd8c4f..d160a4a6 100644
--- a/src/model/styles.rs
+++ b/src/model/styles.rs
@@ -7,7 +7,6 @@ use comemo::Tracked;
use super::{Barrier, Content, Key, Property, Recipe, Selector, Show, Target};
use crate::diag::SourceResult;
-use crate::util::ReadableTypeId;
use crate::World;
/// A map of style properties.
@@ -98,7 +97,7 @@ impl StyleMap {
pub fn scoped(mut self) -> Self {
for entry in &mut self.0 {
if let StyleEntry::Property(property) = entry {
- property.scoped = true;
+ property.make_scoped();
}
}
self
@@ -125,23 +124,6 @@ impl Debug for StyleMap {
}
}
-/// A unique identifier for a node.
-#[derive(Copy, Clone, Eq, PartialEq, Hash)]
-pub struct NodeId(ReadableTypeId);
-
-impl NodeId {
- /// The id of the given node.
- pub fn of<T: 'static>() -> Self {
- Self(ReadableTypeId::of::<T>())
- }
-}
-
-impl Debug for NodeId {
- fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- self.0.fmt(f)
- }
-}
-
/// Determines whether a style could interrupt some composable structure.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub enum Interruption {
@@ -175,7 +157,7 @@ impl StyleEntry {
if !tail
.entries()
.filter_map(StyleEntry::property)
- .any(|p| p.scoped && barrier.is_for(p.node))
+ .any(|p| p.scoped() && barrier.is_for(p.node()))
{
return *tail;
}
@@ -302,7 +284,13 @@ impl<'a> StyleChain<'a> {
if self.guarded(sel) {
guarded = true;
} else {
- let content = node.unguard(sel).realize(world, self)?;
+ let content = node
+ .to::<dyn Show>()
+ .unwrap()
+ .unguard_parts(sel)
+ .to::<dyn Show>()
+ .unwrap()
+ .realize(world, self)?;
realized = Some(content.styled_with_entry(StyleEntry::Guard(sel)));
}
}
@@ -310,7 +298,9 @@ impl<'a> StyleChain<'a> {
// Finalize only if guarding didn't stop any recipe.
if !guarded {
if let Some(content) = realized {
- realized = Some(node.finalize(world, self, content)?);
+ realized = Some(
+ node.to::<dyn Show>().unwrap().finalize(world, self, content)?,
+ );
}
}
}
@@ -403,7 +393,7 @@ impl<'a, K: Key<'a>> Iterator for Values<'a, K> {
match entry {
StyleEntry::Property(property) => {
if let Some(value) = property.downcast::<K>() {
- if !property.scoped || self.depth <= 1 {
+ if !property.scoped() || self.depth <= 1 {
return Some(value);
}
}