diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-03-11 17:42:40 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-03-11 18:29:48 +0100 |
| commit | 529d3e10c6b4d973e88b6c295eb22a45ea426e42 (patch) | |
| tree | 1815aa9336e71565e24d94bacccb98f09e91b693 /src/model/realize.rs | |
| parent | 8e5f446544fd147277ed2e4208c7ea793cc846a7 (diff) | |
Section references
Diffstat (limited to 'src/model/realize.rs')
| -rw-r--r-- | src/model/realize.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/model/realize.rs b/src/model/realize.rs index c4c67a4f..4685a605 100644 --- a/src/model/realize.rs +++ b/src/model/realize.rs @@ -3,7 +3,7 @@ use crate::diag::SourceResult; /// Whether the target is affected by show rules in the given style chain. pub fn applicable(target: &Content, styles: StyleChain) -> bool { - if target.can::<dyn Prepare>() && !target.is_prepared() { + if target.can::<dyn Synthesize>() && !target.is_synthesized() { return true; } @@ -34,6 +34,18 @@ pub fn realize( // Find out how many recipes there are. let mut n = styles.recipes().count(); + // Synthesize if not already happened for this node. + if target.can::<dyn Synthesize>() && !target.is_synthesized() { + return Ok(Some( + target + .clone() + .synthesized() + .with::<dyn Synthesize>() + .unwrap() + .synthesize(vt, styles), + )); + } + // Find an applicable recipe. let mut realized = None; for recipe in styles.recipes() { @@ -132,10 +144,10 @@ fn try_apply( } } -/// Preparations before execution of any show rule. -pub trait Prepare { +/// Synthesize fields on a node. This happens before execution of any show rule. +pub trait Synthesize { /// Prepare the node for show rule application. - fn prepare(&self, vt: &mut Vt, styles: StyleChain) -> SourceResult<Content>; + fn synthesize(&self, vt: &mut Vt, styles: StyleChain) -> Content; } /// The base recipe for a node. |
