Remove unscoped hack

This commit is contained in:
Laurenz 2022-05-24 18:32:51 +02:00
parent 18511686f3
commit acdde6d326
2 changed files with 9 additions and 19 deletions

View File

@ -7,8 +7,8 @@ use std::ops::{Add, AddAssign};
use typed_arena::Arena;
use super::{
CollapsingBuilder, Interruption, Key, Layout, LayoutNode, Property, Show, ShowNode,
StyleEntry, StyleMap, StyleVecBuilder, Target,
Barrier, CollapsingBuilder, Interruption, Key, Layout, LayoutNode, Property, Show,
ShowNode, StyleEntry, StyleMap, StyleVecBuilder, Target,
};
use crate::diag::StrResult;
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<()> {
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);
self.accept(stored, styles.unscoped(node.id()))?;
self.accept(stored, styles)?;
}
Ok(())
}

View File

@ -263,21 +263,6 @@ impl<'a> StyleChain<'a> {
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.
///
/// Returns the property's default value if no map in the chain contains an