summaryrefslogtreecommitdiff
path: root/src/exec
diff options
context:
space:
mode:
Diffstat (limited to 'src/exec')
-rw-r--r--src/exec/context.rs20
-rw-r--r--src/exec/mod.rs19
-rw-r--r--src/exec/state.rs6
3 files changed, 18 insertions, 27 deletions
diff --git a/src/exec/context.rs b/src/exec/context.rs
index d491a251..4d2047a6 100644
--- a/src/exec/context.rs
+++ b/src/exec/context.rs
@@ -7,7 +7,7 @@ use super::*;
use crate::diag::{Diag, DiagSet};
use crate::geom::{ChildAlign, Dir, Gen, LayoutDirs, Length, Linear, Sides, Size};
use crate::layout::{
- Expansion, Node, NodePad, NodePages, NodePar, NodeSpacing, NodeStack, NodeText, Tree,
+ Node, NodePad, NodePages, NodePar, NodeSpacing, NodeStack, NodeText, Tree,
};
use crate::parse::is_newline;
@@ -105,18 +105,18 @@ impl<'a> ExecContext<'a> {
}
}
- /// Execute the body of a function and return the result as a stack node.
- pub fn exec_body(&mut self, body: &ValueTemplate, expand: Spec<Expansion>) -> Node {
+ /// Execute a template and return the result as a stack node.
+ pub fn exec(&mut self, template: &ValueTemplate) -> Node {
let dirs = self.state.dirs;
let align = self.state.align;
self.start_group(ContentGroup);
self.start_par_group();
- body.exec(self);
+ template.exec(self);
self.end_par_group();
let children = self.end_group::<ContentGroup>().1;
- NodeStack { dirs, align, expand, children }.into()
+ NodeStack { dirs, align, children }.into()
}
/// Start a page group based on the active page state.
@@ -128,7 +128,6 @@ impl<'a> ExecContext<'a> {
pub fn start_page_group(&mut self, softness: Softness) {
self.start_group(PageGroup {
size: self.state.page.size,
- expand: self.state.page.expand,
padding: self.state.page.margins(),
dirs: self.state.dirs,
align: self.state.align,
@@ -158,7 +157,6 @@ impl<'a> ExecContext<'a> {
child: NodeStack {
dirs: group.dirs,
align: group.align,
- expand: group.expand,
children,
}
.into(),
@@ -186,13 +184,6 @@ impl<'a> ExecContext<'a> {
self.push(NodePar {
dirs: group.dirs,
align: group.align,
- // FIXME: This is a hack and should be superseded by something
- // better.
- cross_expansion: if self.groups.len() <= 1 {
- Expansion::Fill
- } else {
- Expansion::Fit
- },
line_spacing: group.line_spacing,
children,
});
@@ -306,7 +297,6 @@ pub enum Softness {
#[derive(Debug)]
struct PageGroup {
size: Size,
- expand: Spec<Expansion>,
padding: Sides<Linear>,
dirs: LayoutDirs,
align: ChildAlign,
diff --git a/src/exec/mod.rs b/src/exec/mod.rs
index ea2c90f4..79ad81e7 100644
--- a/src/exec/mod.rs
+++ b/src/exec/mod.rs
@@ -11,8 +11,7 @@ use std::rc::Rc;
use crate::diag::Pass;
use crate::env::Env;
use crate::eval::{ExprMap, TemplateFunc, TemplateNode, Value, ValueTemplate};
-use crate::geom::Spec;
-use crate::layout::{self, Expansion, NodeSpacing, NodeStack};
+use crate::layout::{self, NodeFixed, NodeSpacing, NodeStack};
use crate::pretty::pretty;
use crate::syntax::*;
@@ -120,11 +119,17 @@ impl Exec for NodeRaw {
ctx.apply_parbreak();
}
- ctx.push(NodeStack {
- dirs: ctx.state.dirs,
- align: ctx.state.align,
- expand: Spec::uniform(Expansion::Fit),
- children,
+ // This is wrapped in a fixed node to make sure the stack fits to its
+ // content instead of filling the available area.
+ ctx.push(NodeFixed {
+ width: None,
+ height: None,
+ child: NodeStack {
+ dirs: ctx.state.dirs,
+ align: ctx.state.align,
+ children,
+ }
+ .into(),
});
if self.block {
diff --git a/src/exec/state.rs b/src/exec/state.rs
index 416b5d08..3293662a 100644
--- a/src/exec/state.rs
+++ b/src/exec/state.rs
@@ -3,9 +3,8 @@ use std::rc::Rc;
use fontdock::{fallback, FallbackTree, FontStretch, FontStyle, FontVariant, FontWeight};
use crate::geom::{
- Align, ChildAlign, Dir, LayoutDirs, Length, Linear, Relative, Sides, Size, Spec,
+ Align, ChildAlign, Dir, LayoutDirs, Length, Linear, Relative, Sides, Size,
};
-use crate::layout::Expansion;
use crate::paper::{Paper, PaperClass, PAPER_A4};
/// The evaluation state.
@@ -42,8 +41,6 @@ pub struct PageState {
pub class: PaperClass,
/// The width and height of the page.
pub size: Size,
- /// Whether the expand the pages to the `size` or to fit the content.
- pub expand: Spec<Expansion>,
/// The amount of white space on each side of the page. If a side is set to
/// `None`, the default for the paper class is used.
pub margins: Sides<Option<Linear>>,
@@ -55,7 +52,6 @@ impl PageState {
Self {
class: paper.class,
size: paper.size(),
- expand: Spec::uniform(Expansion::Fill),
margins: Sides::uniform(None),
}
}