Compare commits

..

No commits in common. "1d217e4019aa865970fb18c9771d007a3615929c" and "07a060a9dac594ec603852a667f491557c0c6910" have entirely different histories.

8 changed files with 17 additions and 70 deletions

View File

@ -1376,13 +1376,14 @@ impl<'a> GridLayouter<'a> {
// endlessly repeated) when subtracting header and footer height. // endlessly repeated) when subtracting header and footer height.
// //
// See 'check_for_unbreakable_rows' as for why we're using // See 'check_for_unbreakable_rows' as for why we're using
// 'repeating_header_height' to predict header height. // 'header_height' to predict header height and not
// 'repeating_header_height'.
let height = frame.height(); let height = frame.height();
while self.unbreakable_rows_left == 0 while self.unbreakable_rows_left == 0
&& !self.regions.size.y.fits(height) && !self.regions.size.y.fits(height)
&& may_progress_with_offset( && may_progress_with_offset(
self.regions, self.regions,
self.current.repeating_header_height + self.current.footer_height, self.current.header_height + self.current.footer_height,
) )
{ {
self.finish_region(engine, false)?; self.finish_region(engine, false)?;
@ -1570,9 +1571,11 @@ impl<'a> GridLayouter<'a> {
&& self.current.lrows.is_empty() && self.current.lrows.is_empty()
&& may_progress_with_offset( && may_progress_with_offset(
self.regions, self.regions,
// Don't sum header height as we just confirmed that there // This header height isn't doing much as we just
// are no headers in this region. // confirmed that there are no headers in this region,
self.current.footer_height, // but let's keep it here for correctness. It will add
// zero anyway.
self.current.header_height + self.current.footer_height,
); );
let mut laid_out_footer_start = None; let mut laid_out_footer_start = None;
@ -1799,9 +1802,6 @@ pub(super) fn points(
/// additional logic which adds content automatically on each region turn (in /// additional logic which adds content automatically on each region turn (in
/// our case, headers). /// our case, headers).
pub(super) fn may_progress_with_offset(regions: Regions<'_>, offset: Abs) -> bool { pub(super) fn may_progress_with_offset(regions: Regions<'_>, offset: Abs) -> bool {
// Use 'approx_eq' as float addition and subtraction are not associative.
!regions.backlog.is_empty() !regions.backlog.is_empty()
|| regions || regions.last.is_some_and(|height| regions.size.y + offset != height)
.last
.is_some_and(|height| !(regions.size.y + offset).approx_eq(height))
} }

View File

@ -377,7 +377,7 @@ impl<'a> GridLayouter<'a> {
// 'header_height == repeating_header_height' here // 'header_height == repeating_header_height' here
// (there won't be any pending headers at this point, other // (there won't be any pending headers at this point, other
// than the ones we are about to place). // than the ones we are about to place).
self.current.repeating_header_height + self.current.footer_height, self.current.header_height + self.current.footer_height,
) )
{ {
// Note that, after the first region skip, the new headers will go // Note that, after the first region skip, the new headers will go
@ -393,7 +393,7 @@ impl<'a> GridLayouter<'a> {
&& self.current.lrows_orphan_snapshot.is_none() && self.current.lrows_orphan_snapshot.is_none()
&& may_progress_with_offset( && may_progress_with_offset(
self.regions, self.regions,
self.current.repeating_header_height + self.current.footer_height, self.current.header_height + self.current.footer_height,
); );
if should_snapshot { if should_snapshot {

View File

@ -258,11 +258,12 @@ impl GridLayouter<'_> {
while !self.regions.size.y.fits(row_group.height) while !self.regions.size.y.fits(row_group.height)
&& may_progress_with_offset( && may_progress_with_offset(
self.regions, self.regions,
// Use 'repeating_header_height' (ignoring the height of // Note that we consider that the exact same headers and footers will be
// non-repeated headers) to allow skipping if the // added if we skip like this (blocking other rows from being laid out)
// non-repeated header is too large. It will become an // due to orphan/widow prevention, which explains the usage of
// orphan, but when there is no space left, anything goes. // 'header_height' (include non-repeating but pending headers) rather
self.current.repeating_header_height + self.current.footer_height, // than 'repeating_header_height'.
self.current.header_height + self.current.footer_height,
) )
{ {
self.finish_region(engine, false)?; self.finish_region(engine, false)?;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 542 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 525 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 437 B

View File

@ -815,57 +815,3 @@
[a], [a],
) )
) )
--- grid-subheaders-too-large-non-repeating-orphan-before-auto ---
#set page(height: 8em)
#grid(
grid.header([1]),
grid.header(
[a\ ] * 2,
level: 2,
repeat: false,
),
grid.header([2], level: 3),
[b\ b\ b],
)
--- grid-subheaders-too-large-repeating-orphan-before-auto ---
#set page(height: 8em)
#grid(
grid.header([1]),
grid.header(
[a\ ] * 2,
level: 2,
repeat: true,
),
grid.header([2], level: 3),
rect(width: 10pt, height: 3em, fill: red),
)
--- grid-subheaders-too-large-repeating-orphan-before-relative ---
#set page(height: 8em)
#grid(
rows: (auto, auto, auto, 3em),
grid.header([1]),
grid.header(
[a\ ] * 2,
level: 2,
repeat: true,
),
grid.header([2], level: 3),
rect(width: 10pt, height: 3em, fill: red),
)
--- grid-subheaders-too-large-non-repeating-orphan-before-relative ---
#set page(height: 8em)
#grid(
rows: (auto, auto, auto, 3em),
grid.header([1]),
grid.header(
[a\ ] * 2,
level: 2,
repeat: false,
),
grid.header([2], level: 3),
rect(width: 10pt, height: 3em, fill: red),
)