summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPgBiel <9021226+PgBiel@users.noreply.github.com>2025-05-21 01:06:08 -0300
committerPgBiel <9021226+PgBiel@users.noreply.github.com>2025-06-28 22:39:35 -0300
commite89e3066a4946e7223d521caba02a9d6dc0e5e11 (patch)
tree500fd2465febe07c346f2ba70439a68b2cdfaa6f
parent3de1237f54d1d61f1d7a70f22c69aafae1d178b1 (diff)
repeated method fixes
-rw-r--r--crates/typst-layout/src/grid/layouter.rs2
-rw-r--r--crates/typst-layout/src/grid/repeated.rs34
2 files changed, 17 insertions, 19 deletions
diff --git a/crates/typst-layout/src/grid/layouter.rs b/crates/typst-layout/src/grid/layouter.rs
index 2c7f957f..5d37584e 100644
--- a/crates/typst-layout/src/grid/layouter.rs
+++ b/crates/typst-layout/src/grid/layouter.rs
@@ -1768,7 +1768,7 @@ impl<'a> GridLayouter<'a> {
// TODO(subfooters): let's not...
let footers = self.repeating_footers.clone();
self.prepare_repeating_footers(
- footers.iter().map(|f| *f),
+ footers.iter().copied(),
true,
engine,
disambiguator,
diff --git a/crates/typst-layout/src/grid/repeated.rs b/crates/typst-layout/src/grid/repeated.rs
index 89e785ef..512593a5 100644
--- a/crates/typst-layout/src/grid/repeated.rs
+++ b/crates/typst-layout/src/grid/repeated.rs
@@ -245,6 +245,7 @@ impl<'a> GridLayouter<'a> {
// changed.
let (footer_height, footer_heights) = self.simulate_footer_heights(
self.repeating_footers.iter().map(|x| *x),
+ &self.regions,
engine,
disambiguator,
)?;
@@ -519,7 +520,7 @@ impl<'a> GridLayouter<'a> {
.first()
.is_none_or(|f| f.level >= footer.level)
{
- self.prepare_next_repeating_footers(false, engine);
+ self.prepare_next_repeating_footers(false, engine)?;
return Ok(());
}
@@ -564,7 +565,7 @@ impl<'a> GridLayouter<'a> {
first_footers,
engine,
0,
- );
+ )?;
Ok(())
}
@@ -578,8 +579,13 @@ impl<'a> GridLayouter<'a> {
engine: &mut Engine,
disambiguator: usize,
) -> SourceResult<()> {
- let (mut expected_footer_height, mut expected_footer_heights) =
- self.simulate_footer_heights(footers.clone(), engine, disambiguator)?;
+ let (mut expected_footer_height, mut expected_footer_heights) = self
+ .simulate_footer_heights(
+ footers.clone(),
+ &self.regions,
+ engine,
+ disambiguator,
+ )?;
// Skip to fitting region where all of them fit at once.
//
@@ -612,8 +618,8 @@ impl<'a> GridLayouter<'a> {
if skipped_region {
// Simulate the footer again; the region's 'full' might have
// changed, and the vector of heights was cleared.
- (expected_footer_height, expected_footer_heights) =
- self.simulate_footer_heights(footers, engine, disambiguator)?;
+ (expected_footer_height, expected_footer_heights) = self
+ .simulate_footer_heights(footers, &self.regions, engine, disambiguator)?;
}
self.current.footer_height += expected_footer_height;
@@ -622,18 +628,18 @@ impl<'a> GridLayouter<'a> {
Ok(())
}
- fn simulate_footer_heights(
+ pub fn simulate_footer_heights(
&self,
footers: impl Iterator<Item = &'a Footer> + ExactSizeIterator,
+ regions: &Regions<'_>,
engine: &mut Engine,
disambiguator: usize,
) -> SourceResult<(Abs, Vec<Abs>)> {
let mut total_footer_height = Abs::zero();
let mut footer_heights = Vec::with_capacity(footers.len());
for footer in footers {
- let footer_height = self
- .simulate_footer(footer, &self.regions, engine, disambiguator)?
- .height;
+ let footer_height =
+ self.simulate_footer(footer, regions, engine, disambiguator)?.height;
total_footer_height += footer_height;
footer_heights.push(footer_height);
@@ -701,11 +707,3 @@ pub fn total_header_row_count<'h>(
) -> usize {
headers.into_iter().map(|h| h.range.end - h.range.start).sum()
}
-
-/// The total amount of rows in the given list of headers.
-#[inline]
-pub fn total_footer_row_count<'f>(
- footers: impl IntoIterator<Item = &'f Footer>,
-) -> usize {
- footers.into_iter().map(|f| f.end - f.start).sum()
-}