summaryrefslogtreecommitdiff
path: root/src/model/content.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-09-19 11:14:58 +0200
committerLaurenz <laurmaedje@gmail.com>2022-09-19 11:16:05 +0200
commit4ec3bcee487c1567bc6551f81d4f69eee4379076 (patch)
tree84ece5a894679adbe06c43712af685c5561a83ca /src/model/content.rs
parente5f958b92161732ae46ccc66ce3d6eea213cf925 (diff)
Remove pins and memoization
Diffstat (limited to 'src/model/content.rs')
-rw-r--r--src/model/content.rs38
1 files changed, 2 insertions, 36 deletions
diff --git a/src/model/content.rs b/src/model/content.rs
index 264785ec..efbaed0e 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::{
- Barrier, CollapsingBuilder, Interruption, Key, Layout, LayoutNode, LocateNode,
- 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};
@@ -23,30 +23,6 @@ use crate::util::EcoString;
///
/// Relayouts until all pinned locations are converged.
pub fn layout(ctx: &mut Context, content: &Content) -> TypResult<Vec<Frame>> {
- let mut pass = 0;
- let mut frames;
-
- loop {
- let prev = ctx.pins.clone();
- let result = layout_once(ctx, content);
- ctx.pins.reset();
- frames = result?;
- pass += 1;
-
- ctx.pins.locate(&frames);
-
- // Quit if we're done or if we've had five passes.
- let unresolved = ctx.pins.unresolved(&prev);
- if unresolved == 0 || pass >= 5 {
- break;
- }
- }
-
- Ok(frames)
-}
-
-/// Layout content into a collection of pages once.
-fn layout_once(ctx: &mut Context, content: &Content) -> TypResult<Vec<Frame>> {
let copy = ctx.config.styles.clone();
let styles = StyleChain::with_root(&copy);
let scratch = Scratch::default();
@@ -114,8 +90,6 @@ pub enum Content {
/// A node that can be realized with styles, optionally with attached
/// properties.
Show(ShowNode, Option<Dict>),
- /// A node that can be realized with its location on the page.
- Locate(LocateNode),
/// A pin identified by index.
Pin(usize),
/// Content with attached styles.
@@ -307,7 +281,6 @@ impl Debug for Content {
Self::Pagebreak { weak } => write!(f, "Pagebreak({weak})"),
Self::Page(page) => page.fmt(f),
Self::Show(node, _) => node.fmt(f),
- Self::Locate(node) => node.fmt(f),
Self::Pin(idx) => write!(f, "Pin({idx})"),
Self::Styled(styled) => {
let (sub, map) = styled.as_ref();
@@ -425,7 +398,6 @@ impl<'a, 'ctx> Builder<'a, 'ctx> {
}
Content::Show(node, _) => return self.show(node, styles),
- Content::Locate(node) => return self.locate(node, styles),
Content::Styled(styled) => return self.styled(styled, styles),
Content::Sequence(seq) => return self.sequence(seq, styles),
@@ -474,12 +446,6 @@ impl<'a, 'ctx> Builder<'a, 'ctx> {
Ok(())
}
- fn locate(&mut self, node: &LocateNode, styles: StyleChain<'a>) -> TypResult<()> {
- let realized = node.realize(self.ctx)?;
- let stored = self.scratch.templates.alloc(realized);
- self.accept(stored, styles)
- }
-
fn styled(
&mut self,
(content, map): &'a (Content, StyleMap),