mirror of
https://github.com/typst/typst
synced 2025-05-13 20:46:23 +08:00
Remove unscoped
hack
This commit is contained in:
parent
18511686f3
commit
acdde6d326
@ -7,8 +7,8 @@ use std::ops::{Add, AddAssign};
|
|||||||
use typed_arena::Arena;
|
use typed_arena::Arena;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
CollapsingBuilder, Interruption, Key, Layout, LayoutNode, Property, Show, ShowNode,
|
Barrier, CollapsingBuilder, Interruption, Key, Layout, LayoutNode, Property, Show,
|
||||||
StyleEntry, StyleMap, StyleVecBuilder, Target,
|
ShowNode, StyleEntry, StyleMap, StyleVecBuilder, Target,
|
||||||
};
|
};
|
||||||
use crate::diag::StrResult;
|
use crate::diag::StrResult;
|
||||||
use crate::library::layout::{FlowChild, FlowNode, PageNode, PlaceNode, Spacing};
|
use crate::library::layout::{FlowChild, FlowNode, PageNode, PlaceNode, Spacing};
|
||||||
@ -424,9 +424,14 @@ impl<'a, 'ctx> Builder<'a, 'ctx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn show(&mut self, node: &ShowNode, styles: StyleChain<'a>) -> TypResult<()> {
|
fn show(&mut self, node: &ShowNode, styles: StyleChain<'a>) -> TypResult<()> {
|
||||||
if let Some(realized) = styles.apply(self.ctx, Target::Node(node))? {
|
if let Some(mut realized) = styles.apply(self.ctx, Target::Node(node))? {
|
||||||
|
let mut map = StyleMap::new();
|
||||||
|
let barrier = Barrier::new(node.id());
|
||||||
|
map.push(StyleEntry::Barrier(barrier));
|
||||||
|
map.push(StyleEntry::Barrier(barrier));
|
||||||
|
realized = realized.styled_with_map(map);
|
||||||
let stored = self.scratch.templates.alloc(realized);
|
let stored = self.scratch.templates.alloc(realized);
|
||||||
self.accept(stored, styles.unscoped(node.id()))?;
|
self.accept(stored, styles)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -263,21 +263,6 @@ impl<'a> StyleChain<'a> {
|
|||||||
Self { head: &root.0, tail: None }
|
Self { head: &root.0, tail: None }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the chain, but without trailing scoped properties for the given
|
|
||||||
/// `node`.
|
|
||||||
pub fn unscoped(mut self, node: NodeId) -> Self {
|
|
||||||
while self
|
|
||||||
.head
|
|
||||||
.last()
|
|
||||||
.and_then(StyleEntry::property)
|
|
||||||
.map_or(false, |p| p.scoped && p.node == node)
|
|
||||||
{
|
|
||||||
let len = self.head.len();
|
|
||||||
self.head = &self.head[.. len - 1]
|
|
||||||
}
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the output value of a style property.
|
/// Get the output value of a style property.
|
||||||
///
|
///
|
||||||
/// Returns the property's default value if no map in the chain contains an
|
/// Returns the property's default value if no map in the chain contains an
|
||||||
|
Loading…
x
Reference in New Issue
Block a user