mirror of
https://github.com/typst/typst
synced 2025-05-20 03:55:29 +08:00
rename 'in_last_with_offset' to 'may_progress_with_offset'
This commit is contained in:
parent
05d4af43b6
commit
62c5b551f1
@ -1300,9 +1300,11 @@ impl<'a> GridLayouter<'a> {
|
||||
}
|
||||
|
||||
// Skip to fitting region, but only if we aren't part of an unbreakable
|
||||
// row group. We use 'in_last_with_offset' so our 'in_last' call
|
||||
// properly considers that a header and a footer would be added on each
|
||||
// region break.
|
||||
// row group. We use 'may_progress_with_offset' so our 'may_progress'
|
||||
// call properly considers that a header and a footer would be added
|
||||
// on each region break, so we only keep skipping regions until we
|
||||
// reach one with the same height of the 'last' region (which can be
|
||||
// endlessly repeated) when subtracting header and footer height.
|
||||
//
|
||||
// See 'check_for_unbreakable_rows' as for why we're using
|
||||
// 'header_height' to predict header height and not
|
||||
@ -1310,7 +1312,10 @@ impl<'a> GridLayouter<'a> {
|
||||
let height = frame.height();
|
||||
while self.unbreakable_rows_left == 0
|
||||
&& !self.regions.size.y.fits(height)
|
||||
&& !in_last_with_offset(self.regions, self.header_height + self.footer_height)
|
||||
&& may_progress_with_offset(
|
||||
self.regions,
|
||||
self.header_height + self.footer_height,
|
||||
)
|
||||
{
|
||||
self.finish_region(engine, false)?;
|
||||
|
||||
@ -1481,7 +1486,7 @@ impl<'a> GridLayouter<'a> {
|
||||
.and_then(Repeatable::as_repeated)
|
||||
.is_none_or(|footer| footer.start != last_header_end)
|
||||
&& self.lrows.len() == self.current_header_rows
|
||||
&& !in_last_with_offset(
|
||||
&& may_progress_with_offset(
|
||||
self.regions,
|
||||
// Since we're trying to find a region where to place all
|
||||
// repeating + pending headers, it makes sense to use
|
||||
@ -1507,7 +1512,7 @@ impl<'a> GridLayouter<'a> {
|
||||
// TODO: widow prevention for non-repeated footers with a similar
|
||||
// mechanism / when implementing multiple footers.
|
||||
self.lrows.is_empty()
|
||||
&& !in_last_with_offset(
|
||||
&& may_progress_with_offset(
|
||||
self.regions,
|
||||
// This header height isn't doing much as we just confirmed
|
||||
// that there are no headers in this region, but let's keep
|
||||
@ -1738,12 +1743,12 @@ pub(super) fn points(
|
||||
})
|
||||
}
|
||||
|
||||
/// Checks if the first region of a sequence of regions is the last usable
|
||||
/// Checks if the first region of a sequence of regions is not the last usable
|
||||
/// region, assuming that the last region will always be occupied by some
|
||||
/// specific offset height, even after calling `.next()`, due to some
|
||||
/// additional logic which adds content automatically on each region turn (in
|
||||
/// our case, headers).
|
||||
pub(super) fn in_last_with_offset(regions: Regions<'_>, offset: Abs) -> bool {
|
||||
regions.backlog.is_empty()
|
||||
&& regions.last.is_none_or(|height| regions.size.y + offset == height)
|
||||
pub(super) fn may_progress_with_offset(regions: Regions<'_>, offset: Abs) -> bool {
|
||||
!regions.backlog.is_empty()
|
||||
|| regions.last.is_some_and(|height| regions.size.y + offset != height)
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use typst_library::layout::grid::resolve::Repeatable;
|
||||
use typst_library::layout::{Abs, Axes, Frame, Point, Region, Regions, Size, Sizing};
|
||||
use typst_utils::MaybeReverseIter;
|
||||
|
||||
use super::layouter::{in_last_with_offset, points, Row};
|
||||
use super::layouter::{may_progress_with_offset, points, Row};
|
||||
use super::{layout_cell, Cell, GridLayouter};
|
||||
|
||||
/// All information needed to layout a single rowspan.
|
||||
@ -256,7 +256,7 @@ impl GridLayouter<'_> {
|
||||
|
||||
// Skip to fitting region.
|
||||
while !self.regions.size.y.fits(row_group.height)
|
||||
&& !in_last_with_offset(
|
||||
&& may_progress_with_offset(
|
||||
self.regions,
|
||||
// Note that we consider that the exact same headers and footers will be
|
||||
// added if we skip like this (blocking other rows from being laid out)
|
||||
@ -1096,7 +1096,7 @@ impl<'a> RowspanSimulator<'a> {
|
||||
0,
|
||||
)?;
|
||||
while !self.regions.size.y.fits(row_group.height)
|
||||
&& !in_last_with_offset(
|
||||
&& may_progress_with_offset(
|
||||
self.regions,
|
||||
self.header_height + self.footer_height,
|
||||
)
|
||||
@ -1121,7 +1121,7 @@ impl<'a> RowspanSimulator<'a> {
|
||||
let mut skipped_region = false;
|
||||
while unbreakable_rows_left == 0
|
||||
&& !self.regions.size.y.fits(height)
|
||||
&& !in_last_with_offset(
|
||||
&& may_progress_with_offset(
|
||||
self.regions,
|
||||
self.header_height + self.footer_height,
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user