diff options
Diffstat (limited to 'library/src/layout')
| -rw-r--r-- | library/src/layout/enum.rs | 4 | ||||
| -rw-r--r-- | library/src/layout/list.rs | 9 | ||||
| -rw-r--r-- | library/src/layout/mod.rs | 9 | ||||
| -rw-r--r-- | library/src/layout/page.rs | 7 | ||||
| -rw-r--r-- | library/src/layout/par.rs | 5 | ||||
| -rw-r--r-- | library/src/layout/table.rs | 11 |
6 files changed, 23 insertions, 22 deletions
diff --git a/library/src/layout/enum.rs b/library/src/layout/enum.rs index 1c08cd5f..05b42bd8 100644 --- a/library/src/layout/enum.rs +++ b/library/src/layout/enum.rs @@ -180,7 +180,7 @@ impl Layout for EnumNode { let resolved = if full { parents.push(number); - let content = numbering.apply(vt.world, &parents)?.display(); + let content = numbering.apply_vt(vt, &parents)?.display(); parents.pop(); content } else { @@ -188,7 +188,7 @@ impl Layout for EnumNode { Numbering::Pattern(pattern) => { TextNode::packed(pattern.apply_kth(parents.len(), number)) } - other => other.apply(vt.world, &[number])?.display(), + other => other.apply_vt(vt, &[number])?.display(), } }; diff --git a/library/src/layout/list.rs b/library/src/layout/list.rs index c954ab67..fe78131d 100644 --- a/library/src/layout/list.rs +++ b/library/src/layout/list.rs @@ -128,7 +128,7 @@ impl Layout for ListNode { }; let depth = self.depth(styles); - let marker = self.marker(styles).resolve(vt.world, depth)?; + let marker = self.marker(styles).resolve(vt, depth)?; let mut cells = vec![]; for item in self.children() { @@ -181,17 +181,14 @@ pub enum ListMarker { impl ListMarker { /// Resolve the marker for the given depth. - fn resolve(&self, world: Tracked<dyn World>, depth: usize) -> SourceResult<Content> { + fn resolve(&self, vt: &mut Vt, depth: usize) -> SourceResult<Content> { Ok(match self { Self::Content(list) => list .get(depth) .or(list.last()) .cloned() .unwrap_or_else(|| TextNode::packed('•')), - Self::Func(func) => { - let args = Args::new(func.span(), [Value::Int(depth as i64)]); - func.call_detached(world, args)?.display() - } + Self::Func(func) => func.call_vt(vt, [Value::Int(depth as i64)])?.display(), }) } } diff --git a/library/src/layout/mod.rs b/library/src/layout/mod.rs index fc0279eb..b29da700 100644 --- a/library/src/layout/mod.rs +++ b/library/src/layout/mod.rs @@ -47,6 +47,7 @@ use std::mem; use typed_arena::Arena; use typst::diag::SourceResult; +use typst::eval::Tracer; use typst::model::{applicable, realize, SequenceNode, StyleVecBuilder, StyledNode}; use crate::math::{FormulaNode, LayoutMath}; @@ -68,11 +69,12 @@ impl LayoutRoot for Content { fn cached( node: &Content, world: Tracked<dyn World>, + tracer: TrackedMut<Tracer>, provider: TrackedMut<StabilityProvider>, introspector: Tracked<Introspector>, styles: StyleChain, ) -> SourceResult<Document> { - let mut vt = Vt { world, provider, introspector }; + let mut vt = Vt { world, tracer, provider, introspector }; let scratch = Scratch::default(); let (realized, styles) = realize_root(&mut vt, &scratch, node, styles)?; realized @@ -84,6 +86,7 @@ impl LayoutRoot for Content { cached( self, vt.world, + TrackedMut::reborrow_mut(&mut vt.tracer), TrackedMut::reborrow_mut(&mut vt.provider), vt.introspector, styles, @@ -129,12 +132,13 @@ impl Layout for Content { fn cached( node: &Content, world: Tracked<dyn World>, + tracer: TrackedMut<Tracer>, provider: TrackedMut<StabilityProvider>, introspector: Tracked<Introspector>, styles: StyleChain, regions: Regions, ) -> SourceResult<Fragment> { - let mut vt = Vt { world, provider, introspector }; + let mut vt = Vt { world, tracer, provider, introspector }; let scratch = Scratch::default(); let (realized, styles) = realize_block(&mut vt, &scratch, node, styles)?; realized @@ -146,6 +150,7 @@ impl Layout for Content { cached( self, vt.world, + TrackedMut::reborrow_mut(&mut vt.tracer), TrackedMut::reborrow_mut(&mut vt.provider), vt.introspector, styles, diff --git a/library/src/layout/page.rs b/library/src/layout/page.rs index 962e8a16..eeb74a55 100644 --- a/library/src/layout/page.rs +++ b/library/src/layout/page.rs @@ -403,13 +403,10 @@ pub enum Marginal { impl Marginal { /// Resolve the marginal based on the page number. - pub fn resolve(&self, vt: &Vt, page: usize) -> SourceResult<Content> { + pub fn resolve(&self, vt: &mut Vt, page: usize) -> SourceResult<Content> { Ok(match self { Self::Content(content) => content.clone(), - Self::Func(func) => { - let args = Args::new(func.span(), [Value::Int(page as i64)]); - func.call_detached(vt.world, args)?.display() - } + Self::Func(func) => func.call_vt(vt, [Value::Int(page as i64)])?.display(), }) } } diff --git a/library/src/layout/par.rs b/library/src/layout/par.rs index 1906dd7c..8657d7fb 100644 --- a/library/src/layout/par.rs +++ b/library/src/layout/par.rs @@ -1,3 +1,4 @@ +use typst::eval::Tracer; use unicode_bidi::{BidiInfo, Level as BidiLevel}; use unicode_script::{Script, UnicodeScript}; use xi_unicode::LineBreakIterator; @@ -138,6 +139,7 @@ impl ParNode { fn cached( par: &ParNode, world: Tracked<dyn World>, + tracer: TrackedMut<Tracer>, provider: TrackedMut<StabilityProvider>, introspector: Tracked<Introspector>, styles: StyleChain, @@ -145,7 +147,7 @@ impl ParNode { region: Size, expand: bool, ) -> SourceResult<Fragment> { - let mut vt = Vt { world, provider, introspector }; + let mut vt = Vt { world, tracer, provider, introspector }; let children = par.children(); // Collect all text into one string for BiDi analysis. @@ -166,6 +168,7 @@ impl ParNode { cached( self, vt.world, + TrackedMut::reborrow_mut(&mut vt.tracer), TrackedMut::reborrow_mut(&mut vt.provider), vt.introspector, styles, diff --git a/library/src/layout/table.rs b/library/src/layout/table.rs index 024bb0d6..d4b6e7d7 100644 --- a/library/src/layout/table.rs +++ b/library/src/layout/table.rs @@ -227,14 +227,13 @@ pub enum Celled<T> { impl<T: Cast + Clone> Celled<T> { /// Resolve the value based on the cell position. - pub fn resolve(&self, vt: &Vt, x: usize, y: usize) -> SourceResult<T> { + pub fn resolve(&self, vt: &mut Vt, x: usize, y: usize) -> SourceResult<T> { Ok(match self { Self::Value(value) => value.clone(), - Self::Func(func) => { - let args = - Args::new(func.span(), [Value::Int(x as i64), Value::Int(y as i64)]); - func.call_detached(vt.world, args)?.cast().at(func.span())? - } + Self::Func(func) => func + .call_vt(vt, [Value::Int(x as i64), Value::Int(y as i64)])? + .cast() + .at(func.span())?, }) } } |
