mirror of
https://github.com/typst/typst
synced 2025-07-16 00:52:54 +08:00
repeated method fixes
This commit is contained in:
parent
3de1237f54
commit
e89e3066a4
@ -1768,7 +1768,7 @@ impl<'a> GridLayouter<'a> {
|
|||||||
// TODO(subfooters): let's not...
|
// TODO(subfooters): let's not...
|
||||||
let footers = self.repeating_footers.clone();
|
let footers = self.repeating_footers.clone();
|
||||||
self.prepare_repeating_footers(
|
self.prepare_repeating_footers(
|
||||||
footers.iter().map(|f| *f),
|
footers.iter().copied(),
|
||||||
true,
|
true,
|
||||||
engine,
|
engine,
|
||||||
disambiguator,
|
disambiguator,
|
||||||
|
@ -245,6 +245,7 @@ impl<'a> GridLayouter<'a> {
|
|||||||
// changed.
|
// changed.
|
||||||
let (footer_height, footer_heights) = self.simulate_footer_heights(
|
let (footer_height, footer_heights) = self.simulate_footer_heights(
|
||||||
self.repeating_footers.iter().map(|x| *x),
|
self.repeating_footers.iter().map(|x| *x),
|
||||||
|
&self.regions,
|
||||||
engine,
|
engine,
|
||||||
disambiguator,
|
disambiguator,
|
||||||
)?;
|
)?;
|
||||||
@ -519,7 +520,7 @@ impl<'a> GridLayouter<'a> {
|
|||||||
.first()
|
.first()
|
||||||
.is_none_or(|f| f.level >= footer.level)
|
.is_none_or(|f| f.level >= footer.level)
|
||||||
{
|
{
|
||||||
self.prepare_next_repeating_footers(false, engine);
|
self.prepare_next_repeating_footers(false, engine)?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -564,7 +565,7 @@ impl<'a> GridLayouter<'a> {
|
|||||||
first_footers,
|
first_footers,
|
||||||
engine,
|
engine,
|
||||||
0,
|
0,
|
||||||
);
|
)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -578,8 +579,13 @@ impl<'a> GridLayouter<'a> {
|
|||||||
engine: &mut Engine,
|
engine: &mut Engine,
|
||||||
disambiguator: usize,
|
disambiguator: usize,
|
||||||
) -> SourceResult<()> {
|
) -> SourceResult<()> {
|
||||||
let (mut expected_footer_height, mut expected_footer_heights) =
|
let (mut expected_footer_height, mut expected_footer_heights) = self
|
||||||
self.simulate_footer_heights(footers.clone(), engine, disambiguator)?;
|
.simulate_footer_heights(
|
||||||
|
footers.clone(),
|
||||||
|
&self.regions,
|
||||||
|
engine,
|
||||||
|
disambiguator,
|
||||||
|
)?;
|
||||||
|
|
||||||
// Skip to fitting region where all of them fit at once.
|
// Skip to fitting region where all of them fit at once.
|
||||||
//
|
//
|
||||||
@ -612,8 +618,8 @@ impl<'a> GridLayouter<'a> {
|
|||||||
if skipped_region {
|
if skipped_region {
|
||||||
// Simulate the footer again; the region's 'full' might have
|
// Simulate the footer again; the region's 'full' might have
|
||||||
// changed, and the vector of heights was cleared.
|
// changed, and the vector of heights was cleared.
|
||||||
(expected_footer_height, expected_footer_heights) =
|
(expected_footer_height, expected_footer_heights) = self
|
||||||
self.simulate_footer_heights(footers, engine, disambiguator)?;
|
.simulate_footer_heights(footers, &self.regions, engine, disambiguator)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.current.footer_height += expected_footer_height;
|
self.current.footer_height += expected_footer_height;
|
||||||
@ -622,18 +628,18 @@ impl<'a> GridLayouter<'a> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn simulate_footer_heights(
|
pub fn simulate_footer_heights(
|
||||||
&self,
|
&self,
|
||||||
footers: impl Iterator<Item = &'a Footer> + ExactSizeIterator,
|
footers: impl Iterator<Item = &'a Footer> + ExactSizeIterator,
|
||||||
|
regions: &Regions<'_>,
|
||||||
engine: &mut Engine,
|
engine: &mut Engine,
|
||||||
disambiguator: usize,
|
disambiguator: usize,
|
||||||
) -> SourceResult<(Abs, Vec<Abs>)> {
|
) -> SourceResult<(Abs, Vec<Abs>)> {
|
||||||
let mut total_footer_height = Abs::zero();
|
let mut total_footer_height = Abs::zero();
|
||||||
let mut footer_heights = Vec::with_capacity(footers.len());
|
let mut footer_heights = Vec::with_capacity(footers.len());
|
||||||
for footer in footers {
|
for footer in footers {
|
||||||
let footer_height = self
|
let footer_height =
|
||||||
.simulate_footer(footer, &self.regions, engine, disambiguator)?
|
self.simulate_footer(footer, regions, engine, disambiguator)?.height;
|
||||||
.height;
|
|
||||||
|
|
||||||
total_footer_height += footer_height;
|
total_footer_height += footer_height;
|
||||||
footer_heights.push(footer_height);
|
footer_heights.push(footer_height);
|
||||||
@ -701,11 +707,3 @@ pub fn total_header_row_count<'h>(
|
|||||||
) -> usize {
|
) -> usize {
|
||||||
headers.into_iter().map(|h| h.range.end - h.range.start).sum()
|
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()
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user