From acdde6d3266d4158241c2e62aa88a1185a3016fd Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 24 May 2022 18:32:51 +0200 Subject: [PATCH] Remove `unscoped` hack --- src/model/content.rs | 13 +++++++++---- src/model/styles.rs | 15 --------------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/model/content.rs b/src/model/content.rs index ff10de5d4..8b76c7959 100644 --- a/src/model/content.rs +++ b/src/model/content.rs @@ -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(()) } diff --git a/src/model/styles.rs b/src/model/styles.rs index 5c36861ac..821947925 100644 --- a/src/model/styles.rs +++ b/src/model/styles.rs @@ -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